babylon.max.js 7.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs", [], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs"] = factory();
  8. else
  9. root["BABYLON"] = factory();
  10. })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function() {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./Legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../node_modules/tslib/tslib.es6.js":
  99. /*!******************************************!*\
  100. !*** ../node_modules/tslib/tslib.es6.js ***!
  101. \******************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  125. /*! *****************************************************************************
  126. Copyright (c) Microsoft Corporation. All rights reserved.
  127. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  128. this file except in compliance with the License. You may obtain a copy of the
  129. License at http://www.apache.org/licenses/LICENSE-2.0
  130. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  131. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  132. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  133. MERCHANTABLITY OR NON-INFRINGEMENT.
  134. See the Apache Version 2.0 License for specific language governing permissions
  135. and limitations under the License.
  136. ***************************************************************************** */
  137. /* global Reflect, Promise */
  138. var extendStatics = function(d, b) {
  139. extendStatics = Object.setPrototypeOf ||
  140. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  141. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  142. return extendStatics(d, b);
  143. };
  144. function __extends(d, b) {
  145. extendStatics(d, b);
  146. function __() { this.constructor = d; }
  147. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  148. }
  149. var __assign = function() {
  150. __assign = Object.assign || function __assign(t) {
  151. for (var s, i = 1, n = arguments.length; i < n; i++) {
  152. s = arguments[i];
  153. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  154. }
  155. return t;
  156. }
  157. return __assign.apply(this, arguments);
  158. }
  159. function __rest(s, e) {
  160. var t = {};
  161. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  162. t[p] = s[p];
  163. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  164. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  165. t[p[i]] = s[p[i]];
  166. return t;
  167. }
  168. function __decorate(decorators, target, key, desc) {
  169. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  170. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  171. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  172. return c > 3 && r && Object.defineProperty(target, key, r), r;
  173. }
  174. function __param(paramIndex, decorator) {
  175. return function (target, key) { decorator(target, key, paramIndex); }
  176. }
  177. function __metadata(metadataKey, metadataValue) {
  178. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  179. }
  180. function __awaiter(thisArg, _arguments, P, generator) {
  181. return new (P || (P = Promise))(function (resolve, reject) {
  182. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  183. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  184. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  185. step((generator = generator.apply(thisArg, _arguments || [])).next());
  186. });
  187. }
  188. function __generator(thisArg, body) {
  189. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  190. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  191. function verb(n) { return function (v) { return step([n, v]); }; }
  192. function step(op) {
  193. if (f) throw new TypeError("Generator is already executing.");
  194. while (_) try {
  195. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  196. if (y = 0, t) op = [op[0] & 2, t.value];
  197. switch (op[0]) {
  198. case 0: case 1: t = op; break;
  199. case 4: _.label++; return { value: op[1], done: false };
  200. case 5: _.label++; y = op[1]; op = [0]; continue;
  201. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  202. default:
  203. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  204. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  205. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  206. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  207. if (t[2]) _.ops.pop();
  208. _.trys.pop(); continue;
  209. }
  210. op = body.call(thisArg, _);
  211. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  212. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  213. }
  214. }
  215. function __exportStar(m, exports) {
  216. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  217. }
  218. function __values(o) {
  219. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  220. if (m) return m.call(o);
  221. return {
  222. next: function () {
  223. if (o && i >= o.length) o = void 0;
  224. return { value: o && o[i++], done: !o };
  225. }
  226. };
  227. }
  228. function __read(o, n) {
  229. var m = typeof Symbol === "function" && o[Symbol.iterator];
  230. if (!m) return o;
  231. var i = m.call(o), r, ar = [], e;
  232. try {
  233. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  234. }
  235. catch (error) { e = { error: error }; }
  236. finally {
  237. try {
  238. if (r && !r.done && (m = i["return"])) m.call(i);
  239. }
  240. finally { if (e) throw e.error; }
  241. }
  242. return ar;
  243. }
  244. function __spread() {
  245. for (var ar = [], i = 0; i < arguments.length; i++)
  246. ar = ar.concat(__read(arguments[i]));
  247. return ar;
  248. }
  249. function __await(v) {
  250. return this instanceof __await ? (this.v = v, this) : new __await(v);
  251. }
  252. function __asyncGenerator(thisArg, _arguments, generator) {
  253. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  254. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  255. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  256. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  257. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  258. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  259. function fulfill(value) { resume("next", value); }
  260. function reject(value) { resume("throw", value); }
  261. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  262. }
  263. function __asyncDelegator(o) {
  264. var i, p;
  265. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  266. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  267. }
  268. function __asyncValues(o) {
  269. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  270. var m = o[Symbol.asyncIterator], i;
  271. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  272. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  273. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  274. }
  275. function __makeTemplateObject(cooked, raw) {
  276. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  277. return cooked;
  278. };
  279. function __importStar(mod) {
  280. if (mod && mod.__esModule) return mod;
  281. var result = {};
  282. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  283. result.default = mod;
  284. return result;
  285. }
  286. function __importDefault(mod) {
  287. return (mod && mod.__esModule) ? mod : { default: mod };
  288. }
  289. /***/ }),
  290. /***/ "../node_modules/webpack/buildin/global.js":
  291. /*!*************************************************!*\
  292. !*** ../node_modules/webpack/buildin/global.js ***!
  293. \*************************************************/
  294. /*! no static exports found */
  295. /***/ (function(module, exports) {
  296. var g;
  297. // This works in non-strict mode
  298. g = (function() {
  299. return this;
  300. })();
  301. try {
  302. // This works if eval is allowed (see CSP)
  303. g = g || new Function("return this")();
  304. } catch (e) {
  305. // This works if the window reference is available
  306. if (typeof window === "object") g = window;
  307. }
  308. // g can still be undefined, but nothing to do about it...
  309. // We return undefined, instead of nothing here, so it's
  310. // easier to handle this case. if(!global) { ...}
  311. module.exports = g;
  312. /***/ }),
  313. /***/ "./Actions/abstractActionManager.ts":
  314. /*!******************************************!*\
  315. !*** ./Actions/abstractActionManager.ts ***!
  316. \******************************************/
  317. /*! exports provided: AbstractActionManager */
  318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  319. "use strict";
  320. __webpack_require__.r(__webpack_exports__);
  321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractActionManager", function() { return AbstractActionManager; });
  322. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  323. /**
  324. * Abstract class used to decouple action Manager from scene and meshes.
  325. * Do not instantiate.
  326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  327. */
  328. var AbstractActionManager = /** @class */ (function () {
  329. function AbstractActionManager() {
  330. /** Gets the cursor to use when hovering items */
  331. this.hoverCursor = '';
  332. /** Gets the list of actions */
  333. this.actions = new Array();
  334. /**
  335. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  336. */
  337. this.isRecursive = false;
  338. }
  339. Object.defineProperty(AbstractActionManager, "HasTriggers", {
  340. /**
  341. * Does exist one action manager with at least one trigger
  342. **/
  343. get: function () {
  344. for (var t in AbstractActionManager.Triggers) {
  345. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  346. return true;
  347. }
  348. }
  349. return false;
  350. },
  351. enumerable: true,
  352. configurable: true
  353. });
  354. Object.defineProperty(AbstractActionManager, "HasPickTriggers", {
  355. /**
  356. * Does exist one action manager with at least one pick trigger
  357. **/
  358. get: function () {
  359. for (var t in AbstractActionManager.Triggers) {
  360. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  361. var t_int = parseInt(t);
  362. if (t_int >= _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ACTION_OnPickTrigger && t_int <= _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ACTION_OnPickUpTrigger) {
  363. return true;
  364. }
  365. }
  366. }
  367. return false;
  368. },
  369. enumerable: true,
  370. configurable: true
  371. });
  372. /**
  373. * Does exist one action manager that handles actions of a given trigger
  374. * @param trigger defines the trigger to be tested
  375. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  376. **/
  377. AbstractActionManager.HasSpecificTrigger = function (trigger) {
  378. for (var t in AbstractActionManager.Triggers) {
  379. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  380. var t_int = parseInt(t);
  381. if (t_int === trigger) {
  382. return true;
  383. }
  384. }
  385. }
  386. return false;
  387. };
  388. /** Gets the list of active triggers */
  389. AbstractActionManager.Triggers = {};
  390. return AbstractActionManager;
  391. }());
  392. /***/ }),
  393. /***/ "./Actions/action.ts":
  394. /*!***************************!*\
  395. !*** ./Actions/action.ts ***!
  396. \***************************/
  397. /*! exports provided: Action */
  398. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  399. "use strict";
  400. __webpack_require__.r(__webpack_exports__);
  401. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return Action; });
  402. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  403. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  404. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  405. /**
  406. * The action to be carried out following a trigger
  407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  408. */
  409. var Action = /** @class */ (function () {
  410. /**
  411. * Creates a new Action
  412. * @param triggerOptions the trigger, with or without parameters, for the action
  413. * @param condition an optional determinant of action
  414. */
  415. function Action(
  416. /** the trigger, with or without parameters, for the action */
  417. triggerOptions, condition) {
  418. this.triggerOptions = triggerOptions;
  419. /**
  420. * An event triggered prior to action being executed.
  421. */
  422. this.onBeforeExecuteObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  423. if (triggerOptions.parameter) {
  424. this.trigger = triggerOptions.trigger;
  425. this._triggerParameter = triggerOptions.parameter;
  426. }
  427. else if (triggerOptions.trigger) {
  428. this.trigger = triggerOptions.trigger;
  429. }
  430. else {
  431. this.trigger = triggerOptions;
  432. }
  433. this._nextActiveAction = this;
  434. this._condition = condition;
  435. }
  436. /**
  437. * Internal only
  438. * @hidden
  439. */
  440. Action.prototype._prepare = function () {
  441. };
  442. /**
  443. * Gets the trigger parameters
  444. * @returns the trigger parameters
  445. */
  446. Action.prototype.getTriggerParameter = function () {
  447. return this._triggerParameter;
  448. };
  449. /**
  450. * Internal only - executes current action event
  451. * @hidden
  452. */
  453. Action.prototype._executeCurrent = function (evt) {
  454. if (this._nextActiveAction._condition) {
  455. var condition = this._nextActiveAction._condition;
  456. var currentRenderId = this._actionManager.getScene().getRenderId();
  457. // We cache the current evaluation for the current frame
  458. if (condition._evaluationId === currentRenderId) {
  459. if (!condition._currentResult) {
  460. return;
  461. }
  462. }
  463. else {
  464. condition._evaluationId = currentRenderId;
  465. if (!condition.isValid()) {
  466. condition._currentResult = false;
  467. return;
  468. }
  469. condition._currentResult = true;
  470. }
  471. }
  472. this.onBeforeExecuteObservable.notifyObservers(this);
  473. this._nextActiveAction.execute(evt);
  474. this.skipToNextActiveAction();
  475. };
  476. /**
  477. * Execute placeholder for child classes
  478. * @param evt optional action event
  479. */
  480. Action.prototype.execute = function (evt) {
  481. };
  482. /**
  483. * Skips to next active action
  484. */
  485. Action.prototype.skipToNextActiveAction = function () {
  486. if (this._nextActiveAction._child) {
  487. if (!this._nextActiveAction._child._actionManager) {
  488. this._nextActiveAction._child._actionManager = this._actionManager;
  489. }
  490. this._nextActiveAction = this._nextActiveAction._child;
  491. }
  492. else {
  493. this._nextActiveAction = this;
  494. }
  495. };
  496. /**
  497. * Adds action to chain of actions, may be a DoNothingAction
  498. * @param action defines the next action to execute
  499. * @returns The action passed in
  500. * @see https://www.babylonjs-playground.com/#1T30HR#0
  501. */
  502. Action.prototype.then = function (action) {
  503. this._child = action;
  504. action._actionManager = this._actionManager;
  505. action._prepare();
  506. return action;
  507. };
  508. /**
  509. * Internal only
  510. * @hidden
  511. */
  512. Action.prototype._getProperty = function (propertyPath) {
  513. return this._actionManager._getProperty(propertyPath);
  514. };
  515. /**
  516. * Internal only
  517. * @hidden
  518. */
  519. Action.prototype._getEffectiveTarget = function (target, propertyPath) {
  520. return this._actionManager._getEffectiveTarget(target, propertyPath);
  521. };
  522. /**
  523. * Serialize placeholder for child classes
  524. * @param parent of child
  525. * @returns the serialized object
  526. */
  527. Action.prototype.serialize = function (parent) {
  528. };
  529. /**
  530. * Internal only called by serialize
  531. * @hidden
  532. */
  533. Action.prototype._serialize = function (serializedAction, parent) {
  534. var serializationObject = {
  535. type: 1,
  536. children: [],
  537. name: serializedAction.name,
  538. properties: serializedAction.properties || []
  539. };
  540. // Serialize child
  541. if (this._child) {
  542. this._child.serialize(serializationObject);
  543. }
  544. // Check if "this" has a condition
  545. if (this._condition) {
  546. var serializedCondition = this._condition.serialize();
  547. serializedCondition.children.push(serializationObject);
  548. if (parent) {
  549. parent.children.push(serializedCondition);
  550. }
  551. return serializedCondition;
  552. }
  553. if (parent) {
  554. parent.children.push(serializationObject);
  555. }
  556. return serializationObject;
  557. };
  558. /**
  559. * Internal only
  560. * @hidden
  561. */
  562. Action._SerializeValueAsString = function (value) {
  563. if (typeof value === "number") {
  564. return value.toString();
  565. }
  566. if (typeof value === "boolean") {
  567. return value ? "true" : "false";
  568. }
  569. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]) {
  570. return value.x + ", " + value.y;
  571. }
  572. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]) {
  573. return value.x + ", " + value.y + ", " + value.z;
  574. }
  575. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"]) {
  576. return value.r + ", " + value.g + ", " + value.b;
  577. }
  578. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"]) {
  579. return value.r + ", " + value.g + ", " + value.b + ", " + value.a;
  580. }
  581. return value; // string
  582. };
  583. /**
  584. * Internal only
  585. * @hidden
  586. */
  587. Action._GetTargetProperty = function (target) {
  588. return {
  589. name: "target",
  590. targetType: target._isMesh ? "MeshProperties"
  591. : target._isLight ? "LightProperties"
  592. : target._isCamera ? "CameraProperties"
  593. : "SceneProperties",
  594. value: target._isScene ? "Scene" : target.name
  595. };
  596. };
  597. return Action;
  598. }());
  599. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.Action"] = Action;
  600. /***/ }),
  601. /***/ "./Actions/actionEvent.ts":
  602. /*!********************************!*\
  603. !*** ./Actions/actionEvent.ts ***!
  604. \********************************/
  605. /*! exports provided: ActionEvent */
  606. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  607. "use strict";
  608. __webpack_require__.r(__webpack_exports__);
  609. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return ActionEvent; });
  610. /**
  611. * ActionEvent is the event being sent when an action is triggered.
  612. */
  613. var ActionEvent = /** @class */ (function () {
  614. /**
  615. * Creates a new ActionEvent
  616. * @param source The mesh or sprite that triggered the action
  617. * @param pointerX The X mouse cursor position at the time of the event
  618. * @param pointerY The Y mouse cursor position at the time of the event
  619. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  620. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  621. * @param additionalData additional data for the event
  622. */
  623. function ActionEvent(
  624. /** The mesh or sprite that triggered the action */
  625. source,
  626. /** The X mouse cursor position at the time of the event */
  627. pointerX,
  628. /** The Y mouse cursor position at the time of the event */
  629. pointerY,
  630. /** The mesh that is currently pointed at (can be null) */
  631. meshUnderPointer,
  632. /** the original (browser) event that triggered the ActionEvent */
  633. sourceEvent,
  634. /** additional data for the event */
  635. additionalData) {
  636. this.source = source;
  637. this.pointerX = pointerX;
  638. this.pointerY = pointerY;
  639. this.meshUnderPointer = meshUnderPointer;
  640. this.sourceEvent = sourceEvent;
  641. this.additionalData = additionalData;
  642. }
  643. /**
  644. * Helper function to auto-create an ActionEvent from a source mesh.
  645. * @param source The source mesh that triggered the event
  646. * @param evt The original (browser) event
  647. * @param additionalData additional data for the event
  648. * @returns the new ActionEvent
  649. */
  650. ActionEvent.CreateNew = function (source, evt, additionalData) {
  651. var scene = source.getScene();
  652. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
  653. };
  654. /**
  655. * Helper function to auto-create an ActionEvent from a source sprite
  656. * @param source The source sprite that triggered the event
  657. * @param scene Scene associated with the sprite
  658. * @param evt The original (browser) event
  659. * @param additionalData additional data for the event
  660. * @returns the new ActionEvent
  661. */
  662. ActionEvent.CreateNewFromSprite = function (source, scene, evt, additionalData) {
  663. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
  664. };
  665. /**
  666. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  667. * @param scene the scene where the event occurred
  668. * @param evt The original (browser) event
  669. * @returns the new ActionEvent
  670. */
  671. ActionEvent.CreateNewFromScene = function (scene, evt) {
  672. return new ActionEvent(null, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt);
  673. };
  674. /**
  675. * Helper function to auto-create an ActionEvent from a primitive
  676. * @param prim defines the target primitive
  677. * @param pointerPos defines the pointer position
  678. * @param evt The original (browser) event
  679. * @param additionalData additional data for the event
  680. * @returns the new ActionEvent
  681. */
  682. ActionEvent.CreateNewFromPrimitive = function (prim, pointerPos, evt, additionalData) {
  683. return new ActionEvent(prim, pointerPos.x, pointerPos.y, null, evt, additionalData);
  684. };
  685. return ActionEvent;
  686. }());
  687. /***/ }),
  688. /***/ "./Actions/actionManager.ts":
  689. /*!**********************************!*\
  690. !*** ./Actions/actionManager.ts ***!
  691. \**********************************/
  692. /*! exports provided: ActionManager */
  693. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  694. "use strict";
  695. __webpack_require__.r(__webpack_exports__);
  696. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return ActionManager; });
  697. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  698. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  699. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  700. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  701. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  702. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  703. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  704. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  705. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  706. /* harmony import */ var _abstractActionManager__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./abstractActionManager */ "./Actions/abstractActionManager.ts");
  707. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  708. /**
  709. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  710. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  712. */
  713. var ActionManager = /** @class */ (function (_super) {
  714. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ActionManager, _super);
  715. /**
  716. * Creates a new action manager
  717. * @param scene defines the hosting scene
  718. */
  719. function ActionManager(scene) {
  720. var _this = _super.call(this) || this;
  721. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  722. scene.actionManagers.push(_this);
  723. return _this;
  724. }
  725. // Methods
  726. /**
  727. * Releases all associated resources
  728. */
  729. ActionManager.prototype.dispose = function () {
  730. var index = this._scene.actionManagers.indexOf(this);
  731. for (var i = 0; i < this.actions.length; i++) {
  732. var action = this.actions[i];
  733. ActionManager.Triggers[action.trigger]--;
  734. if (ActionManager.Triggers[action.trigger] === 0) {
  735. delete ActionManager.Triggers[action.trigger];
  736. }
  737. }
  738. if (index > -1) {
  739. this._scene.actionManagers.splice(index, 1);
  740. }
  741. };
  742. /**
  743. * Gets hosting scene
  744. * @returns the hosting scene
  745. */
  746. ActionManager.prototype.getScene = function () {
  747. return this._scene;
  748. };
  749. /**
  750. * Does this action manager handles actions of any of the given triggers
  751. * @param triggers defines the triggers to be tested
  752. * @return a boolean indicating whether one (or more) of the triggers is handled
  753. */
  754. ActionManager.prototype.hasSpecificTriggers = function (triggers) {
  755. for (var index = 0; index < this.actions.length; index++) {
  756. var action = this.actions[index];
  757. if (triggers.indexOf(action.trigger) > -1) {
  758. return true;
  759. }
  760. }
  761. return false;
  762. };
  763. /**
  764. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  765. * speed.
  766. * @param triggerA defines the trigger to be tested
  767. * @param triggerB defines the trigger to be tested
  768. * @return a boolean indicating whether one (or more) of the triggers is handled
  769. */
  770. ActionManager.prototype.hasSpecificTriggers2 = function (triggerA, triggerB) {
  771. for (var index = 0; index < this.actions.length; index++) {
  772. var action = this.actions[index];
  773. if (triggerA == action.trigger || triggerB == action.trigger) {
  774. return true;
  775. }
  776. }
  777. return false;
  778. };
  779. /**
  780. * Does this action manager handles actions of a given trigger
  781. * @param trigger defines the trigger to be tested
  782. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  783. * @return whether the trigger is handled
  784. */
  785. ActionManager.prototype.hasSpecificTrigger = function (trigger, parameterPredicate) {
  786. for (var index = 0; index < this.actions.length; index++) {
  787. var action = this.actions[index];
  788. if (action.trigger === trigger) {
  789. if (parameterPredicate) {
  790. if (parameterPredicate(action.getTriggerParameter())) {
  791. return true;
  792. }
  793. }
  794. else {
  795. return true;
  796. }
  797. }
  798. }
  799. return false;
  800. };
  801. Object.defineProperty(ActionManager.prototype, "hasPointerTriggers", {
  802. /**
  803. * Does this action manager has pointer triggers
  804. */
  805. get: function () {
  806. for (var index = 0; index < this.actions.length; index++) {
  807. var action = this.actions[index];
  808. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPointerOutTrigger) {
  809. return true;
  810. }
  811. }
  812. return false;
  813. },
  814. enumerable: true,
  815. configurable: true
  816. });
  817. Object.defineProperty(ActionManager.prototype, "hasPickTriggers", {
  818. /**
  819. * Does this action manager has pick triggers
  820. */
  821. get: function () {
  822. for (var index = 0; index < this.actions.length; index++) {
  823. var action = this.actions[index];
  824. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPickUpTrigger) {
  825. return true;
  826. }
  827. }
  828. return false;
  829. },
  830. enumerable: true,
  831. configurable: true
  832. });
  833. /**
  834. * Registers an action to this action manager
  835. * @param action defines the action to be registered
  836. * @return the action amended (prepared) after registration
  837. */
  838. ActionManager.prototype.registerAction = function (action) {
  839. if (action.trigger === ActionManager.OnEveryFrameTrigger) {
  840. if (this.getScene().actionManager !== this) {
  841. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Warn("OnEveryFrameTrigger can only be used with scene.actionManager");
  842. return null;
  843. }
  844. }
  845. this.actions.push(action);
  846. if (ActionManager.Triggers[action.trigger]) {
  847. ActionManager.Triggers[action.trigger]++;
  848. }
  849. else {
  850. ActionManager.Triggers[action.trigger] = 1;
  851. }
  852. action._actionManager = this;
  853. action._prepare();
  854. return action;
  855. };
  856. /**
  857. * Unregisters an action to this action manager
  858. * @param action defines the action to be unregistered
  859. * @return a boolean indicating whether the action has been unregistered
  860. */
  861. ActionManager.prototype.unregisterAction = function (action) {
  862. var index = this.actions.indexOf(action);
  863. if (index !== -1) {
  864. this.actions.splice(index, 1);
  865. ActionManager.Triggers[action.trigger] -= 1;
  866. if (ActionManager.Triggers[action.trigger] === 0) {
  867. delete ActionManager.Triggers[action.trigger];
  868. }
  869. delete action._actionManager;
  870. return true;
  871. }
  872. return false;
  873. };
  874. /**
  875. * Process a specific trigger
  876. * @param trigger defines the trigger to process
  877. * @param evt defines the event details to be processed
  878. */
  879. ActionManager.prototype.processTrigger = function (trigger, evt) {
  880. for (var index = 0; index < this.actions.length; index++) {
  881. var action = this.actions[index];
  882. if (action.trigger === trigger) {
  883. if (evt) {
  884. if (trigger === ActionManager.OnKeyUpTrigger
  885. || trigger === ActionManager.OnKeyDownTrigger) {
  886. var parameter = action.getTriggerParameter();
  887. if (parameter && parameter !== evt.sourceEvent.keyCode) {
  888. if (!parameter.toLowerCase) {
  889. continue;
  890. }
  891. var lowerCase = parameter.toLowerCase();
  892. if (lowerCase !== evt.sourceEvent.key) {
  893. var unicode = evt.sourceEvent.charCode ? evt.sourceEvent.charCode : evt.sourceEvent.keyCode;
  894. var actualkey = String.fromCharCode(unicode).toLowerCase();
  895. if (actualkey !== lowerCase) {
  896. continue;
  897. }
  898. }
  899. }
  900. }
  901. }
  902. action._executeCurrent(evt);
  903. }
  904. }
  905. };
  906. /** @hidden */
  907. ActionManager.prototype._getEffectiveTarget = function (target, propertyPath) {
  908. var properties = propertyPath.split(".");
  909. for (var index = 0; index < properties.length - 1; index++) {
  910. target = target[properties[index]];
  911. }
  912. return target;
  913. };
  914. /** @hidden */
  915. ActionManager.prototype._getProperty = function (propertyPath) {
  916. var properties = propertyPath.split(".");
  917. return properties[properties.length - 1];
  918. };
  919. /**
  920. * Serialize this manager to a JSON object
  921. * @param name defines the property name to store this manager
  922. * @returns a JSON representation of this manager
  923. */
  924. ActionManager.prototype.serialize = function (name) {
  925. var root = {
  926. children: new Array(),
  927. name: name,
  928. type: 3,
  929. properties: new Array() // Empty for root but required
  930. };
  931. for (var i = 0; i < this.actions.length; i++) {
  932. var triggerObject = {
  933. type: 0,
  934. children: new Array(),
  935. name: ActionManager.GetTriggerName(this.actions[i].trigger),
  936. properties: new Array()
  937. };
  938. var triggerOptions = this.actions[i].triggerOptions;
  939. if (triggerOptions && typeof triggerOptions !== "number") {
  940. if (triggerOptions.parameter instanceof Node) {
  941. triggerObject.properties.push(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(triggerOptions.parameter));
  942. }
  943. else {
  944. var parameter = {};
  945. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__["DeepCopier"].DeepCopy(triggerOptions.parameter, parameter, ["mesh"]);
  946. if (triggerOptions.parameter && triggerOptions.parameter.mesh) {
  947. parameter._meshId = triggerOptions.parameter.mesh.id;
  948. }
  949. triggerObject.properties.push({ name: "parameter", targetType: null, value: parameter });
  950. }
  951. }
  952. // Serialize child action, recursively
  953. this.actions[i].serialize(triggerObject);
  954. // Add serialized trigger
  955. root.children.push(triggerObject);
  956. }
  957. return root;
  958. };
  959. /**
  960. * Creates a new ActionManager from a JSON data
  961. * @param parsedActions defines the JSON data to read from
  962. * @param object defines the hosting mesh
  963. * @param scene defines the hosting scene
  964. */
  965. ActionManager.Parse = function (parsedActions, object, scene) {
  966. var actionManager = new ActionManager(scene);
  967. if (object === null) {
  968. scene.actionManager = actionManager;
  969. }
  970. else {
  971. object.actionManager = actionManager;
  972. }
  973. // instanciate a new object
  974. var instanciate = function (name, params) {
  975. var internalClassType = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON." + name);
  976. if (internalClassType) {
  977. var newInstance = Object.create(internalClassType.prototype);
  978. newInstance.constructor.apply(newInstance, params);
  979. return newInstance;
  980. }
  981. };
  982. var parseParameter = function (name, value, target, propertyPath) {
  983. if (propertyPath === null) {
  984. // String, boolean or float
  985. var floatValue = parseFloat(value);
  986. if (value === "true" || value === "false") {
  987. return value === "true";
  988. }
  989. else {
  990. return isNaN(floatValue) ? value : floatValue;
  991. }
  992. }
  993. var effectiveTarget = propertyPath.split(".");
  994. var values = value.split(",");
  995. // Get effective Target
  996. for (var i = 0; i < effectiveTarget.length; i++) {
  997. target = target[effectiveTarget[i]];
  998. }
  999. // Return appropriate value with its type
  1000. if (typeof (target) === "boolean") {
  1001. return values[0] === "true";
  1002. }
  1003. if (typeof (target) === "string") {
  1004. return values[0];
  1005. }
  1006. // Parameters with multiple values such as Vector3 etc.
  1007. var split = new Array();
  1008. for (var i = 0; i < values.length; i++) {
  1009. split.push(parseFloat(values[i]));
  1010. }
  1011. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]) {
  1012. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(split);
  1013. }
  1014. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]) {
  1015. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"].FromArray(split);
  1016. }
  1017. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"]) {
  1018. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(split);
  1019. }
  1020. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"]) {
  1021. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(split);
  1022. }
  1023. return parseFloat(values[0]);
  1024. };
  1025. // traverse graph per trigger
  1026. var traverse = function (parsedAction, trigger, condition, action, combineArray) {
  1027. if (combineArray === void 0) { combineArray = null; }
  1028. if (parsedAction.detached) {
  1029. return;
  1030. }
  1031. var parameters = new Array();
  1032. var target = null;
  1033. var propertyPath = null;
  1034. var combine = parsedAction.combine && parsedAction.combine.length > 0;
  1035. // Parameters
  1036. if (parsedAction.type === 2) {
  1037. parameters.push(actionManager);
  1038. }
  1039. else {
  1040. parameters.push(trigger);
  1041. }
  1042. if (combine) {
  1043. var actions = new Array();
  1044. for (var j = 0; j < parsedAction.combine.length; j++) {
  1045. traverse(parsedAction.combine[j], ActionManager.NothingTrigger, condition, action, actions);
  1046. }
  1047. parameters.push(actions);
  1048. }
  1049. else {
  1050. for (var i = 0; i < parsedAction.properties.length; i++) {
  1051. var value = parsedAction.properties[i].value;
  1052. var name = parsedAction.properties[i].name;
  1053. var targetType = parsedAction.properties[i].targetType;
  1054. if (name === "target") {
  1055. if (targetType !== null && targetType === "SceneProperties") {
  1056. value = target = scene;
  1057. }
  1058. else {
  1059. value = target = scene.getNodeByName(value);
  1060. }
  1061. }
  1062. else if (name === "parent") {
  1063. value = scene.getNodeByName(value);
  1064. }
  1065. else if (name === "sound") {
  1066. // Can not externalize to component, so only checks for the presence off the API.
  1067. if (scene.getSoundByName) {
  1068. value = scene.getSoundByName(value);
  1069. }
  1070. }
  1071. else if (name !== "propertyPath") {
  1072. if (parsedAction.type === 2 && name === "operator") {
  1073. value = _condition__WEBPACK_IMPORTED_MODULE_2__["ValueCondition"][value];
  1074. }
  1075. else {
  1076. value = parseParameter(name, value, target, name === "value" ? propertyPath : null);
  1077. }
  1078. }
  1079. else {
  1080. propertyPath = value;
  1081. }
  1082. parameters.push(value);
  1083. }
  1084. }
  1085. if (combineArray === null) {
  1086. parameters.push(condition);
  1087. }
  1088. else {
  1089. parameters.push(null);
  1090. }
  1091. // If interpolate value action
  1092. if (parsedAction.name === "InterpolateValueAction") {
  1093. var param = parameters[parameters.length - 2];
  1094. parameters[parameters.length - 1] = param;
  1095. parameters[parameters.length - 2] = condition;
  1096. }
  1097. // Action or condition(s) and not CombineAction
  1098. var newAction = instanciate(parsedAction.name, parameters);
  1099. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_2__["Condition"] && condition !== null) {
  1100. var nothing = new _directActions__WEBPACK_IMPORTED_MODULE_4__["DoNothingAction"](trigger, condition);
  1101. if (action) {
  1102. action.then(nothing);
  1103. }
  1104. else {
  1105. actionManager.registerAction(nothing);
  1106. }
  1107. action = nothing;
  1108. }
  1109. if (combineArray === null) {
  1110. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_2__["Condition"]) {
  1111. condition = newAction;
  1112. newAction = action;
  1113. }
  1114. else {
  1115. condition = null;
  1116. if (action) {
  1117. action.then(newAction);
  1118. }
  1119. else {
  1120. actionManager.registerAction(newAction);
  1121. }
  1122. }
  1123. }
  1124. else {
  1125. combineArray.push(newAction);
  1126. }
  1127. for (var i = 0; i < parsedAction.children.length; i++) {
  1128. traverse(parsedAction.children[i], trigger, condition, newAction, null);
  1129. }
  1130. };
  1131. // triggers
  1132. for (var i = 0; i < parsedActions.children.length; i++) {
  1133. var triggerParams;
  1134. var trigger = parsedActions.children[i];
  1135. if (trigger.properties.length > 0) {
  1136. var param = trigger.properties[0].value;
  1137. var value = trigger.properties[0].targetType === null ? param : scene.getMeshByName(param);
  1138. if (value._meshId) {
  1139. value.mesh = scene.getMeshByID(value._meshId);
  1140. }
  1141. triggerParams = { trigger: ActionManager[trigger.name], parameter: value };
  1142. }
  1143. else {
  1144. triggerParams = ActionManager[trigger.name];
  1145. }
  1146. for (var j = 0; j < trigger.children.length; j++) {
  1147. if (!trigger.detached) {
  1148. traverse(trigger.children[j], triggerParams, null, null);
  1149. }
  1150. }
  1151. }
  1152. };
  1153. /**
  1154. * Get a trigger name by index
  1155. * @param trigger defines the trigger index
  1156. * @returns a trigger name
  1157. */
  1158. ActionManager.GetTriggerName = function (trigger) {
  1159. switch (trigger) {
  1160. case 0: return "NothingTrigger";
  1161. case 1: return "OnPickTrigger";
  1162. case 2: return "OnLeftPickTrigger";
  1163. case 3: return "OnRightPickTrigger";
  1164. case 4: return "OnCenterPickTrigger";
  1165. case 5: return "OnPickDownTrigger";
  1166. case 6: return "OnPickUpTrigger";
  1167. case 7: return "OnLongPressTrigger";
  1168. case 8: return "OnPointerOverTrigger";
  1169. case 9: return "OnPointerOutTrigger";
  1170. case 10: return "OnEveryFrameTrigger";
  1171. case 11: return "OnIntersectionEnterTrigger";
  1172. case 12: return "OnIntersectionExitTrigger";
  1173. case 13: return "OnKeyDownTrigger";
  1174. case 14: return "OnKeyUpTrigger";
  1175. case 15: return "OnPickOutTrigger";
  1176. default: return "";
  1177. }
  1178. };
  1179. /**
  1180. * Nothing
  1181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1182. */
  1183. ActionManager.NothingTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_NothingTrigger;
  1184. /**
  1185. * On pick
  1186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1187. */
  1188. ActionManager.OnPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickTrigger;
  1189. /**
  1190. * On left pick
  1191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1192. */
  1193. ActionManager.OnLeftPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnLeftPickTrigger;
  1194. /**
  1195. * On right pick
  1196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1197. */
  1198. ActionManager.OnRightPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnRightPickTrigger;
  1199. /**
  1200. * On center pick
  1201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1202. */
  1203. ActionManager.OnCenterPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnCenterPickTrigger;
  1204. /**
  1205. * On pick down
  1206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1207. */
  1208. ActionManager.OnPickDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickDownTrigger;
  1209. /**
  1210. * On double pick
  1211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1212. */
  1213. ActionManager.OnDoublePickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnDoublePickTrigger;
  1214. /**
  1215. * On pick up
  1216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1217. */
  1218. ActionManager.OnPickUpTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickUpTrigger;
  1219. /**
  1220. * On pick out.
  1221. * This trigger will only be raised if you also declared a OnPickDown
  1222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1223. */
  1224. ActionManager.OnPickOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickOutTrigger;
  1225. /**
  1226. * On long press
  1227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1228. */
  1229. ActionManager.OnLongPressTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnLongPressTrigger;
  1230. /**
  1231. * On pointer over
  1232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1233. */
  1234. ActionManager.OnPointerOverTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPointerOverTrigger;
  1235. /**
  1236. * On pointer out
  1237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1238. */
  1239. ActionManager.OnPointerOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPointerOutTrigger;
  1240. /**
  1241. * On every frame
  1242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1243. */
  1244. ActionManager.OnEveryFrameTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnEveryFrameTrigger;
  1245. /**
  1246. * On intersection enter
  1247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1248. */
  1249. ActionManager.OnIntersectionEnterTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnIntersectionEnterTrigger;
  1250. /**
  1251. * On intersection exit
  1252. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1253. */
  1254. ActionManager.OnIntersectionExitTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnIntersectionExitTrigger;
  1255. /**
  1256. * On key down
  1257. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1258. */
  1259. ActionManager.OnKeyDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnKeyDownTrigger;
  1260. /**
  1261. * On key up
  1262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1263. */
  1264. ActionManager.OnKeyUpTrigger = 15;
  1265. return ActionManager;
  1266. }(_abstractActionManager__WEBPACK_IMPORTED_MODULE_9__["AbstractActionManager"]));
  1267. /***/ }),
  1268. /***/ "./Actions/condition.ts":
  1269. /*!******************************!*\
  1270. !*** ./Actions/condition.ts ***!
  1271. \******************************/
  1272. /*! exports provided: Condition, ValueCondition, PredicateCondition, StateCondition */
  1273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1274. "use strict";
  1275. __webpack_require__.r(__webpack_exports__);
  1276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return Condition; });
  1277. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return ValueCondition; });
  1278. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return PredicateCondition; });
  1279. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return StateCondition; });
  1280. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1281. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1282. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1283. /**
  1284. * A Condition applied to an Action
  1285. */
  1286. var Condition = /** @class */ (function () {
  1287. /**
  1288. * Creates a new Condition
  1289. * @param actionManager the manager of the action the condition is applied to
  1290. */
  1291. function Condition(actionManager) {
  1292. this._actionManager = actionManager;
  1293. }
  1294. /**
  1295. * Check if the current condition is valid
  1296. * @returns a boolean
  1297. */
  1298. Condition.prototype.isValid = function () {
  1299. return true;
  1300. };
  1301. /**
  1302. * Internal only
  1303. * @hidden
  1304. */
  1305. Condition.prototype._getProperty = function (propertyPath) {
  1306. return this._actionManager._getProperty(propertyPath);
  1307. };
  1308. /**
  1309. * Internal only
  1310. * @hidden
  1311. */
  1312. Condition.prototype._getEffectiveTarget = function (target, propertyPath) {
  1313. return this._actionManager._getEffectiveTarget(target, propertyPath);
  1314. };
  1315. /**
  1316. * Serialize placeholder for child classes
  1317. * @returns the serialized object
  1318. */
  1319. Condition.prototype.serialize = function () {
  1320. };
  1321. /**
  1322. * Internal only
  1323. * @hidden
  1324. */
  1325. Condition.prototype._serialize = function (serializedCondition) {
  1326. return {
  1327. type: 2,
  1328. children: [],
  1329. name: serializedCondition.name,
  1330. properties: serializedCondition.properties
  1331. };
  1332. };
  1333. return Condition;
  1334. }());
  1335. /**
  1336. * Defines specific conditional operators as extensions of Condition
  1337. */
  1338. var ValueCondition = /** @class */ (function (_super) {
  1339. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ValueCondition, _super);
  1340. /**
  1341. * Creates a new ValueCondition
  1342. * @param actionManager manager for the action the condition applies to
  1343. * @param target for the action
  1344. * @param propertyPath path to specify the property of the target the conditional operator uses
  1345. * @param value the value compared by the conditional operator against the current value of the property
  1346. * @param operator the conditional operator, default ValueCondition.IsEqual
  1347. */
  1348. function ValueCondition(actionManager, target,
  1349. /** path to specify the property of the target the conditional operator uses */
  1350. propertyPath,
  1351. /** the value compared by the conditional operator against the current value of the property */
  1352. value,
  1353. /** the conditional operator, default ValueCondition.IsEqual */
  1354. operator) {
  1355. if (operator === void 0) { operator = ValueCondition.IsEqual; }
  1356. var _this = _super.call(this, actionManager) || this;
  1357. _this.propertyPath = propertyPath;
  1358. _this.value = value;
  1359. _this.operator = operator;
  1360. _this._target = target;
  1361. _this._effectiveTarget = _this._getEffectiveTarget(target, _this.propertyPath);
  1362. _this._property = _this._getProperty(_this.propertyPath);
  1363. return _this;
  1364. }
  1365. Object.defineProperty(ValueCondition, "IsEqual", {
  1366. /**
  1367. * returns the number for IsEqual
  1368. */
  1369. get: function () {
  1370. return ValueCondition._IsEqual;
  1371. },
  1372. enumerable: true,
  1373. configurable: true
  1374. });
  1375. Object.defineProperty(ValueCondition, "IsDifferent", {
  1376. /**
  1377. * Returns the number for IsDifferent
  1378. */
  1379. get: function () {
  1380. return ValueCondition._IsDifferent;
  1381. },
  1382. enumerable: true,
  1383. configurable: true
  1384. });
  1385. Object.defineProperty(ValueCondition, "IsGreater", {
  1386. /**
  1387. * Returns the number for IsGreater
  1388. */
  1389. get: function () {
  1390. return ValueCondition._IsGreater;
  1391. },
  1392. enumerable: true,
  1393. configurable: true
  1394. });
  1395. Object.defineProperty(ValueCondition, "IsLesser", {
  1396. /**
  1397. * Returns the number for IsLesser
  1398. */
  1399. get: function () {
  1400. return ValueCondition._IsLesser;
  1401. },
  1402. enumerable: true,
  1403. configurable: true
  1404. });
  1405. /**
  1406. * Compares the given value with the property value for the specified conditional operator
  1407. * @returns the result of the comparison
  1408. */
  1409. ValueCondition.prototype.isValid = function () {
  1410. switch (this.operator) {
  1411. case ValueCondition.IsGreater:
  1412. return this._effectiveTarget[this._property] > this.value;
  1413. case ValueCondition.IsLesser:
  1414. return this._effectiveTarget[this._property] < this.value;
  1415. case ValueCondition.IsEqual:
  1416. case ValueCondition.IsDifferent:
  1417. var check;
  1418. if (this.value.equals) {
  1419. check = this.value.equals(this._effectiveTarget[this._property]);
  1420. }
  1421. else {
  1422. check = this.value === this._effectiveTarget[this._property];
  1423. }
  1424. return this.operator === ValueCondition.IsEqual ? check : !check;
  1425. }
  1426. return false;
  1427. };
  1428. /**
  1429. * Serialize the ValueCondition into a JSON compatible object
  1430. * @returns serialization object
  1431. */
  1432. ValueCondition.prototype.serialize = function () {
  1433. return this._serialize({
  1434. name: "ValueCondition",
  1435. properties: [
  1436. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1437. { name: "propertyPath", value: this.propertyPath },
  1438. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  1439. { name: "operator", value: ValueCondition.GetOperatorName(this.operator) }
  1440. ]
  1441. });
  1442. };
  1443. /**
  1444. * Gets the name of the conditional operator for the ValueCondition
  1445. * @param operator the conditional operator
  1446. * @returns the name
  1447. */
  1448. ValueCondition.GetOperatorName = function (operator) {
  1449. switch (operator) {
  1450. case ValueCondition._IsEqual: return "IsEqual";
  1451. case ValueCondition._IsDifferent: return "IsDifferent";
  1452. case ValueCondition._IsGreater: return "IsGreater";
  1453. case ValueCondition._IsLesser: return "IsLesser";
  1454. default: return "";
  1455. }
  1456. };
  1457. /**
  1458. * Internal only
  1459. * @hidden
  1460. */
  1461. ValueCondition._IsEqual = 0;
  1462. /**
  1463. * Internal only
  1464. * @hidden
  1465. */
  1466. ValueCondition._IsDifferent = 1;
  1467. /**
  1468. * Internal only
  1469. * @hidden
  1470. */
  1471. ValueCondition._IsGreater = 2;
  1472. /**
  1473. * Internal only
  1474. * @hidden
  1475. */
  1476. ValueCondition._IsLesser = 3;
  1477. return ValueCondition;
  1478. }(Condition));
  1479. /**
  1480. * Defines a predicate condition as an extension of Condition
  1481. */
  1482. var PredicateCondition = /** @class */ (function (_super) {
  1483. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PredicateCondition, _super);
  1484. /**
  1485. * Creates a new PredicateCondition
  1486. * @param actionManager manager for the action the condition applies to
  1487. * @param predicate defines the predicate function used to validate the condition
  1488. */
  1489. function PredicateCondition(actionManager,
  1490. /** defines the predicate function used to validate the condition */
  1491. predicate) {
  1492. var _this = _super.call(this, actionManager) || this;
  1493. _this.predicate = predicate;
  1494. return _this;
  1495. }
  1496. /**
  1497. * @returns the validity of the predicate condition
  1498. */
  1499. PredicateCondition.prototype.isValid = function () {
  1500. return this.predicate();
  1501. };
  1502. return PredicateCondition;
  1503. }(Condition));
  1504. /**
  1505. * Defines a state condition as an extension of Condition
  1506. */
  1507. var StateCondition = /** @class */ (function (_super) {
  1508. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StateCondition, _super);
  1509. /**
  1510. * Creates a new StateCondition
  1511. * @param actionManager manager for the action the condition applies to
  1512. * @param target of the condition
  1513. * @param value to compare with target state
  1514. */
  1515. function StateCondition(actionManager, target,
  1516. /** Value to compare with target state */
  1517. value) {
  1518. var _this = _super.call(this, actionManager) || this;
  1519. _this.value = value;
  1520. _this._target = target;
  1521. return _this;
  1522. }
  1523. /**
  1524. * Gets a boolean indicating if the current condition is met
  1525. * @returns the validity of the state
  1526. */
  1527. StateCondition.prototype.isValid = function () {
  1528. return this._target.state === this.value;
  1529. };
  1530. /**
  1531. * Serialize the StateCondition into a JSON compatible object
  1532. * @returns serialization object
  1533. */
  1534. StateCondition.prototype.serialize = function () {
  1535. return this._serialize({
  1536. name: "StateCondition",
  1537. properties: [
  1538. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1539. { name: "value", value: this.value }
  1540. ]
  1541. });
  1542. };
  1543. return StateCondition;
  1544. }(Condition));
  1545. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.ValueCondition"] = ValueCondition;
  1546. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PredicateCondition"] = PredicateCondition;
  1547. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StateCondition"] = StateCondition;
  1548. /***/ }),
  1549. /***/ "./Actions/directActions.ts":
  1550. /*!**********************************!*\
  1551. !*** ./Actions/directActions.ts ***!
  1552. \**********************************/
  1553. /*! exports provided: SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction */
  1554. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1555. "use strict";
  1556. __webpack_require__.r(__webpack_exports__);
  1557. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return SwitchBooleanAction; });
  1558. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return SetStateAction; });
  1559. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return SetValueAction; });
  1560. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return IncrementValueAction; });
  1561. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return PlayAnimationAction; });
  1562. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return StopAnimationAction; });
  1563. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return DoNothingAction; });
  1564. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return CombineAction; });
  1565. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return ExecuteCodeAction; });
  1566. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return SetParentAction; });
  1567. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1568. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  1569. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  1570. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1571. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  1572. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1573. /**
  1574. * This defines an action responsible to toggle a boolean once triggered.
  1575. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1576. */
  1577. var SwitchBooleanAction = /** @class */ (function (_super) {
  1578. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SwitchBooleanAction, _super);
  1579. /**
  1580. * Instantiate the action
  1581. * @param triggerOptions defines the trigger options
  1582. * @param target defines the object containing the boolean
  1583. * @param propertyPath defines the path to the boolean property in the target object
  1584. * @param condition defines the trigger related conditions
  1585. */
  1586. function SwitchBooleanAction(triggerOptions, target, propertyPath, condition) {
  1587. var _this = _super.call(this, triggerOptions, condition) || this;
  1588. _this.propertyPath = propertyPath;
  1589. _this._target = _this._effectiveTarget = target;
  1590. return _this;
  1591. }
  1592. /** @hidden */
  1593. SwitchBooleanAction.prototype._prepare = function () {
  1594. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1595. this._property = this._getProperty(this.propertyPath);
  1596. };
  1597. /**
  1598. * Execute the action toggle the boolean value.
  1599. */
  1600. SwitchBooleanAction.prototype.execute = function () {
  1601. this._effectiveTarget[this._property] = !this._effectiveTarget[this._property];
  1602. };
  1603. /**
  1604. * Serializes the actions and its related information.
  1605. * @param parent defines the object to serialize in
  1606. * @returns the serialized object
  1607. */
  1608. SwitchBooleanAction.prototype.serialize = function (parent) {
  1609. return _super.prototype._serialize.call(this, {
  1610. name: "SwitchBooleanAction",
  1611. properties: [
  1612. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1613. { name: "propertyPath", value: this.propertyPath }
  1614. ]
  1615. }, parent);
  1616. };
  1617. return SwitchBooleanAction;
  1618. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1619. /**
  1620. * This defines an action responsible to set a the state field of the target
  1621. * to a desired value once triggered.
  1622. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1623. */
  1624. var SetStateAction = /** @class */ (function (_super) {
  1625. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetStateAction, _super);
  1626. /**
  1627. * Instantiate the action
  1628. * @param triggerOptions defines the trigger options
  1629. * @param target defines the object containing the state property
  1630. * @param value defines the value to store in the state field
  1631. * @param condition defines the trigger related conditions
  1632. */
  1633. function SetStateAction(triggerOptions, target, value, condition) {
  1634. var _this = _super.call(this, triggerOptions, condition) || this;
  1635. _this.value = value;
  1636. _this._target = target;
  1637. return _this;
  1638. }
  1639. /**
  1640. * Execute the action and store the value on the target state property.
  1641. */
  1642. SetStateAction.prototype.execute = function () {
  1643. this._target.state = this.value;
  1644. };
  1645. /**
  1646. * Serializes the actions and its related information.
  1647. * @param parent defines the object to serialize in
  1648. * @returns the serialized object
  1649. */
  1650. SetStateAction.prototype.serialize = function (parent) {
  1651. return _super.prototype._serialize.call(this, {
  1652. name: "SetStateAction",
  1653. properties: [
  1654. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1655. { name: "value", value: this.value }
  1656. ]
  1657. }, parent);
  1658. };
  1659. return SetStateAction;
  1660. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1661. /**
  1662. * This defines an action responsible to set a property of the target
  1663. * to a desired value once triggered.
  1664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1665. */
  1666. var SetValueAction = /** @class */ (function (_super) {
  1667. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetValueAction, _super);
  1668. /**
  1669. * Instantiate the action
  1670. * @param triggerOptions defines the trigger options
  1671. * @param target defines the object containing the property
  1672. * @param propertyPath defines the path of the property to set in the target
  1673. * @param value defines the value to set in the property
  1674. * @param condition defines the trigger related conditions
  1675. */
  1676. function SetValueAction(triggerOptions, target, propertyPath, value, condition) {
  1677. var _this = _super.call(this, triggerOptions, condition) || this;
  1678. _this.propertyPath = propertyPath;
  1679. _this.value = value;
  1680. _this._target = _this._effectiveTarget = target;
  1681. return _this;
  1682. }
  1683. /** @hidden */
  1684. SetValueAction.prototype._prepare = function () {
  1685. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1686. this._property = this._getProperty(this.propertyPath);
  1687. };
  1688. /**
  1689. * Execute the action and set the targetted property to the desired value.
  1690. */
  1691. SetValueAction.prototype.execute = function () {
  1692. this._effectiveTarget[this._property] = this.value;
  1693. if (this._target.markAsDirty) {
  1694. this._target.markAsDirty(this._property);
  1695. }
  1696. };
  1697. /**
  1698. * Serializes the actions and its related information.
  1699. * @param parent defines the object to serialize in
  1700. * @returns the serialized object
  1701. */
  1702. SetValueAction.prototype.serialize = function (parent) {
  1703. return _super.prototype._serialize.call(this, {
  1704. name: "SetValueAction",
  1705. properties: [
  1706. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1707. { name: "propertyPath", value: this.propertyPath },
  1708. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1709. ]
  1710. }, parent);
  1711. };
  1712. return SetValueAction;
  1713. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1714. /**
  1715. * This defines an action responsible to increment the target value
  1716. * to a desired value once triggered.
  1717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1718. */
  1719. var IncrementValueAction = /** @class */ (function (_super) {
  1720. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IncrementValueAction, _super);
  1721. /**
  1722. * Instantiate the action
  1723. * @param triggerOptions defines the trigger options
  1724. * @param target defines the object containing the property
  1725. * @param propertyPath defines the path of the property to increment in the target
  1726. * @param value defines the value value we should increment the property by
  1727. * @param condition defines the trigger related conditions
  1728. */
  1729. function IncrementValueAction(triggerOptions, target, propertyPath, value, condition) {
  1730. var _this = _super.call(this, triggerOptions, condition) || this;
  1731. _this.propertyPath = propertyPath;
  1732. _this.value = value;
  1733. _this._target = _this._effectiveTarget = target;
  1734. return _this;
  1735. }
  1736. /** @hidden */
  1737. IncrementValueAction.prototype._prepare = function () {
  1738. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1739. this._property = this._getProperty(this.propertyPath);
  1740. if (typeof this._effectiveTarget[this._property] !== "number") {
  1741. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Warning: IncrementValueAction can only be used with number values");
  1742. }
  1743. };
  1744. /**
  1745. * Execute the action and increment the target of the value amount.
  1746. */
  1747. IncrementValueAction.prototype.execute = function () {
  1748. this._effectiveTarget[this._property] += this.value;
  1749. if (this._target.markAsDirty) {
  1750. this._target.markAsDirty(this._property);
  1751. }
  1752. };
  1753. /**
  1754. * Serializes the actions and its related information.
  1755. * @param parent defines the object to serialize in
  1756. * @returns the serialized object
  1757. */
  1758. IncrementValueAction.prototype.serialize = function (parent) {
  1759. return _super.prototype._serialize.call(this, {
  1760. name: "IncrementValueAction",
  1761. properties: [
  1762. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1763. { name: "propertyPath", value: this.propertyPath },
  1764. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1765. ]
  1766. }, parent);
  1767. };
  1768. return IncrementValueAction;
  1769. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1770. /**
  1771. * This defines an action responsible to start an animation once triggered.
  1772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1773. */
  1774. var PlayAnimationAction = /** @class */ (function (_super) {
  1775. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlayAnimationAction, _super);
  1776. /**
  1777. * Instantiate the action
  1778. * @param triggerOptions defines the trigger options
  1779. * @param target defines the target animation or animation name
  1780. * @param from defines from where the animation should start (animation frame)
  1781. * @param end defines where the animation should stop (animation frame)
  1782. * @param loop defines if the animation should loop or stop after the first play
  1783. * @param condition defines the trigger related conditions
  1784. */
  1785. function PlayAnimationAction(triggerOptions, target, from, to, loop, condition) {
  1786. var _this = _super.call(this, triggerOptions, condition) || this;
  1787. _this.from = from;
  1788. _this.to = to;
  1789. _this.loop = loop;
  1790. _this._target = target;
  1791. return _this;
  1792. }
  1793. /** @hidden */
  1794. PlayAnimationAction.prototype._prepare = function () {
  1795. };
  1796. /**
  1797. * Execute the action and play the animation.
  1798. */
  1799. PlayAnimationAction.prototype.execute = function () {
  1800. var scene = this._actionManager.getScene();
  1801. scene.beginAnimation(this._target, this.from, this.to, this.loop);
  1802. };
  1803. /**
  1804. * Serializes the actions and its related information.
  1805. * @param parent defines the object to serialize in
  1806. * @returns the serialized object
  1807. */
  1808. PlayAnimationAction.prototype.serialize = function (parent) {
  1809. return _super.prototype._serialize.call(this, {
  1810. name: "PlayAnimationAction",
  1811. properties: [
  1812. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1813. { name: "from", value: String(this.from) },
  1814. { name: "to", value: String(this.to) },
  1815. { name: "loop", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.loop) || false }
  1816. ]
  1817. }, parent);
  1818. };
  1819. return PlayAnimationAction;
  1820. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1821. /**
  1822. * This defines an action responsible to stop an animation once triggered.
  1823. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1824. */
  1825. var StopAnimationAction = /** @class */ (function (_super) {
  1826. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopAnimationAction, _super);
  1827. /**
  1828. * Instantiate the action
  1829. * @param triggerOptions defines the trigger options
  1830. * @param target defines the target animation or animation name
  1831. * @param condition defines the trigger related conditions
  1832. */
  1833. function StopAnimationAction(triggerOptions, target, condition) {
  1834. var _this = _super.call(this, triggerOptions, condition) || this;
  1835. _this._target = target;
  1836. return _this;
  1837. }
  1838. /** @hidden */
  1839. StopAnimationAction.prototype._prepare = function () {
  1840. };
  1841. /**
  1842. * Execute the action and stop the animation.
  1843. */
  1844. StopAnimationAction.prototype.execute = function () {
  1845. var scene = this._actionManager.getScene();
  1846. scene.stopAnimation(this._target);
  1847. };
  1848. /**
  1849. * Serializes the actions and its related information.
  1850. * @param parent defines the object to serialize in
  1851. * @returns the serialized object
  1852. */
  1853. StopAnimationAction.prototype.serialize = function (parent) {
  1854. return _super.prototype._serialize.call(this, {
  1855. name: "StopAnimationAction",
  1856. properties: [_action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target)]
  1857. }, parent);
  1858. };
  1859. return StopAnimationAction;
  1860. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1861. /**
  1862. * This defines an action responsible that does nothing once triggered.
  1863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1864. */
  1865. var DoNothingAction = /** @class */ (function (_super) {
  1866. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DoNothingAction, _super);
  1867. /**
  1868. * Instantiate the action
  1869. * @param triggerOptions defines the trigger options
  1870. * @param condition defines the trigger related conditions
  1871. */
  1872. function DoNothingAction(triggerOptions, condition) {
  1873. if (triggerOptions === void 0) { triggerOptions = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_NothingTrigger; }
  1874. return _super.call(this, triggerOptions, condition) || this;
  1875. }
  1876. /**
  1877. * Execute the action and do nothing.
  1878. */
  1879. DoNothingAction.prototype.execute = function () {
  1880. };
  1881. /**
  1882. * Serializes the actions and its related information.
  1883. * @param parent defines the object to serialize in
  1884. * @returns the serialized object
  1885. */
  1886. DoNothingAction.prototype.serialize = function (parent) {
  1887. return _super.prototype._serialize.call(this, {
  1888. name: "DoNothingAction",
  1889. properties: []
  1890. }, parent);
  1891. };
  1892. return DoNothingAction;
  1893. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1894. /**
  1895. * This defines an action responsible to trigger several actions once triggered.
  1896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1897. */
  1898. var CombineAction = /** @class */ (function (_super) {
  1899. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CombineAction, _super);
  1900. /**
  1901. * Instantiate the action
  1902. * @param triggerOptions defines the trigger options
  1903. * @param children defines the list of aggregated animations to run
  1904. * @param condition defines the trigger related conditions
  1905. */
  1906. function CombineAction(triggerOptions, children, condition) {
  1907. var _this = _super.call(this, triggerOptions, condition) || this;
  1908. _this.children = children;
  1909. return _this;
  1910. }
  1911. /** @hidden */
  1912. CombineAction.prototype._prepare = function () {
  1913. for (var index = 0; index < this.children.length; index++) {
  1914. this.children[index]._actionManager = this._actionManager;
  1915. this.children[index]._prepare();
  1916. }
  1917. };
  1918. /**
  1919. * Execute the action and executes all the aggregated actions.
  1920. */
  1921. CombineAction.prototype.execute = function (evt) {
  1922. for (var index = 0; index < this.children.length; index++) {
  1923. this.children[index].execute(evt);
  1924. }
  1925. };
  1926. /**
  1927. * Serializes the actions and its related information.
  1928. * @param parent defines the object to serialize in
  1929. * @returns the serialized object
  1930. */
  1931. CombineAction.prototype.serialize = function (parent) {
  1932. var serializationObject = _super.prototype._serialize.call(this, {
  1933. name: "CombineAction",
  1934. properties: [],
  1935. combine: []
  1936. }, parent);
  1937. for (var i = 0; i < this.children.length; i++) {
  1938. serializationObject.combine.push(this.children[i].serialize(null));
  1939. }
  1940. return serializationObject;
  1941. };
  1942. return CombineAction;
  1943. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1944. /**
  1945. * This defines an action responsible to run code (external event) once triggered.
  1946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1947. */
  1948. var ExecuteCodeAction = /** @class */ (function (_super) {
  1949. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExecuteCodeAction, _super);
  1950. /**
  1951. * Instantiate the action
  1952. * @param triggerOptions defines the trigger options
  1953. * @param func defines the callback function to run
  1954. * @param condition defines the trigger related conditions
  1955. */
  1956. function ExecuteCodeAction(triggerOptions, func, condition) {
  1957. var _this = _super.call(this, triggerOptions, condition) || this;
  1958. _this.func = func;
  1959. return _this;
  1960. }
  1961. /**
  1962. * Execute the action and run the attached code.
  1963. */
  1964. ExecuteCodeAction.prototype.execute = function (evt) {
  1965. this.func(evt);
  1966. };
  1967. return ExecuteCodeAction;
  1968. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1969. /**
  1970. * This defines an action responsible to set the parent property of the target once triggered.
  1971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1972. */
  1973. var SetParentAction = /** @class */ (function (_super) {
  1974. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetParentAction, _super);
  1975. /**
  1976. * Instantiate the action
  1977. * @param triggerOptions defines the trigger options
  1978. * @param target defines the target containing the parent property
  1979. * @param parent defines from where the animation should start (animation frame)
  1980. * @param condition defines the trigger related conditions
  1981. */
  1982. function SetParentAction(triggerOptions, target, parent, condition) {
  1983. var _this = _super.call(this, triggerOptions, condition) || this;
  1984. _this._target = target;
  1985. _this._parent = parent;
  1986. return _this;
  1987. }
  1988. /** @hidden */
  1989. SetParentAction.prototype._prepare = function () {
  1990. };
  1991. /**
  1992. * Execute the action and set the parent property.
  1993. */
  1994. SetParentAction.prototype.execute = function () {
  1995. if (this._target.parent === this._parent) {
  1996. return;
  1997. }
  1998. var invertParentWorldMatrix = this._parent.getWorldMatrix().clone();
  1999. invertParentWorldMatrix.invert();
  2000. this._target.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this._target.position, invertParentWorldMatrix);
  2001. this._target.parent = this._parent;
  2002. };
  2003. /**
  2004. * Serializes the actions and its related information.
  2005. * @param parent defines the object to serialize in
  2006. * @returns the serialized object
  2007. */
  2008. SetParentAction.prototype.serialize = function (parent) {
  2009. return _super.prototype._serialize.call(this, {
  2010. name: "SetParentAction",
  2011. properties: [
  2012. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  2013. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._parent),
  2014. ]
  2015. }, parent);
  2016. };
  2017. return SetParentAction;
  2018. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  2019. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  2020. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.ExecuteCodeAction"] = ExecuteCodeAction;
  2021. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.DoNothingAction"] = DoNothingAction;
  2022. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.StopAnimationAction"] = StopAnimationAction;
  2023. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PlayAnimationAction"] = PlayAnimationAction;
  2024. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.IncrementValueAction"] = IncrementValueAction;
  2025. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetValueAction"] = SetValueAction;
  2026. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetStateAction"] = SetStateAction;
  2027. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  2028. /***/ }),
  2029. /***/ "./Actions/directAudioActions.ts":
  2030. /*!***************************************!*\
  2031. !*** ./Actions/directAudioActions.ts ***!
  2032. \***************************************/
  2033. /*! exports provided: PlaySoundAction, StopSoundAction */
  2034. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2035. "use strict";
  2036. __webpack_require__.r(__webpack_exports__);
  2037. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return PlaySoundAction; });
  2038. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return StopSoundAction; });
  2039. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2040. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2041. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2042. /**
  2043. * This defines an action helpful to play a defined sound on a triggered action.
  2044. */
  2045. var PlaySoundAction = /** @class */ (function (_super) {
  2046. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaySoundAction, _super);
  2047. /**
  2048. * Instantiate the action
  2049. * @param triggerOptions defines the trigger options
  2050. * @param sound defines the sound to play
  2051. * @param condition defines the trigger related conditions
  2052. */
  2053. function PlaySoundAction(triggerOptions, sound, condition) {
  2054. var _this = _super.call(this, triggerOptions, condition) || this;
  2055. _this._sound = sound;
  2056. return _this;
  2057. }
  2058. /** @hidden */
  2059. PlaySoundAction.prototype._prepare = function () {
  2060. };
  2061. /**
  2062. * Execute the action and play the sound.
  2063. */
  2064. PlaySoundAction.prototype.execute = function () {
  2065. if (this._sound !== undefined) {
  2066. this._sound.play();
  2067. }
  2068. };
  2069. /**
  2070. * Serializes the actions and its related information.
  2071. * @param parent defines the object to serialize in
  2072. * @returns the serialized object
  2073. */
  2074. PlaySoundAction.prototype.serialize = function (parent) {
  2075. return _super.prototype._serialize.call(this, {
  2076. name: "PlaySoundAction",
  2077. properties: [{ name: "sound", value: this._sound.name }]
  2078. }, parent);
  2079. };
  2080. return PlaySoundAction;
  2081. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2082. /**
  2083. * This defines an action helpful to stop a defined sound on a triggered action.
  2084. */
  2085. var StopSoundAction = /** @class */ (function (_super) {
  2086. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopSoundAction, _super);
  2087. /**
  2088. * Instantiate the action
  2089. * @param triggerOptions defines the trigger options
  2090. * @param sound defines the sound to stop
  2091. * @param condition defines the trigger related conditions
  2092. */
  2093. function StopSoundAction(triggerOptions, sound, condition) {
  2094. var _this = _super.call(this, triggerOptions, condition) || this;
  2095. _this._sound = sound;
  2096. return _this;
  2097. }
  2098. /** @hidden */
  2099. StopSoundAction.prototype._prepare = function () {
  2100. };
  2101. /**
  2102. * Execute the action and stop the sound.
  2103. */
  2104. StopSoundAction.prototype.execute = function () {
  2105. if (this._sound !== undefined) {
  2106. this._sound.stop();
  2107. }
  2108. };
  2109. /**
  2110. * Serializes the actions and its related information.
  2111. * @param parent defines the object to serialize in
  2112. * @returns the serialized object
  2113. */
  2114. StopSoundAction.prototype.serialize = function (parent) {
  2115. return _super.prototype._serialize.call(this, {
  2116. name: "StopSoundAction",
  2117. properties: [{ name: "sound", value: this._sound.name }]
  2118. }, parent);
  2119. };
  2120. return StopSoundAction;
  2121. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2122. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PlaySoundAction"] = StopSoundAction;
  2123. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StopSoundAction"] = StopSoundAction;
  2124. /***/ }),
  2125. /***/ "./Actions/index.ts":
  2126. /*!**************************!*\
  2127. !*** ./Actions/index.ts ***!
  2128. \**************************/
  2129. /*! exports provided: Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction */
  2130. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2131. "use strict";
  2132. __webpack_require__.r(__webpack_exports__);
  2133. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _action__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  2135. /* harmony import */ var _actionEvent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./actionEvent */ "./Actions/actionEvent.ts");
  2136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _actionEvent__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  2137. /* harmony import */ var _actionManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actionManager */ "./Actions/actionManager.ts");
  2138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _actionManager__WEBPACK_IMPORTED_MODULE_2__["ActionManager"]; });
  2139. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  2140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["Condition"]; });
  2141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["ValueCondition"]; });
  2142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["PredicateCondition"]; });
  2143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["StateCondition"]; });
  2144. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  2145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SwitchBooleanAction"]; });
  2146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetStateAction"]; });
  2147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetValueAction"]; });
  2148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["IncrementValueAction"]; });
  2149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["PlayAnimationAction"]; });
  2150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["StopAnimationAction"]; });
  2151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["DoNothingAction"]; });
  2152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["CombineAction"]; });
  2153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["ExecuteCodeAction"]; });
  2154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetParentAction"]; });
  2155. /* harmony import */ var _directAudioActions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./directAudioActions */ "./Actions/directAudioActions.ts");
  2156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["PlaySoundAction"]; });
  2157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["StopSoundAction"]; });
  2158. /* harmony import */ var _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./interpolateValueAction */ "./Actions/interpolateValueAction.ts");
  2159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__["InterpolateValueAction"]; });
  2160. /***/ }),
  2161. /***/ "./Actions/interpolateValueAction.ts":
  2162. /*!*******************************************!*\
  2163. !*** ./Actions/interpolateValueAction.ts ***!
  2164. \*******************************************/
  2165. /*! exports provided: InterpolateValueAction */
  2166. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2167. "use strict";
  2168. __webpack_require__.r(__webpack_exports__);
  2169. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return InterpolateValueAction; });
  2170. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2171. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2172. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  2173. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2174. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2175. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  2176. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2177. /**
  2178. * This defines an action responsible to change the value of a property
  2179. * by interpolating between its current value and the newly set one once triggered.
  2180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2181. */
  2182. var InterpolateValueAction = /** @class */ (function (_super) {
  2183. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InterpolateValueAction, _super);
  2184. /**
  2185. * Instantiate the action
  2186. * @param triggerOptions defines the trigger options
  2187. * @param target defines the object containing the value to interpolate
  2188. * @param propertyPath defines the path to the property in the target object
  2189. * @param value defines the target value at the end of the interpolation
  2190. * @param duration deines the time it will take for the property to interpolate to the value.
  2191. * @param condition defines the trigger related conditions
  2192. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  2193. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  2194. */
  2195. function InterpolateValueAction(triggerOptions, target, propertyPath, value, duration, condition, stopOtherAnimations, onInterpolationDone) {
  2196. if (duration === void 0) { duration = 1000; }
  2197. var _this = _super.call(this, triggerOptions, condition) || this;
  2198. /**
  2199. * Defines the time it will take for the property to interpolate to the value.
  2200. */
  2201. _this.duration = 1000;
  2202. /**
  2203. * Observable triggered once the interpolation animation has been done.
  2204. */
  2205. _this.onInterpolationDoneObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  2206. _this.propertyPath = propertyPath;
  2207. _this.value = value;
  2208. _this.duration = duration;
  2209. _this.stopOtherAnimations = stopOtherAnimations;
  2210. _this.onInterpolationDone = onInterpolationDone;
  2211. _this._target = _this._effectiveTarget = target;
  2212. return _this;
  2213. }
  2214. /** @hidden */
  2215. InterpolateValueAction.prototype._prepare = function () {
  2216. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  2217. this._property = this._getProperty(this.propertyPath);
  2218. };
  2219. /**
  2220. * Execute the action starts the value interpolation.
  2221. */
  2222. InterpolateValueAction.prototype.execute = function () {
  2223. var _this = this;
  2224. var scene = this._actionManager.getScene();
  2225. var keys = [
  2226. {
  2227. frame: 0,
  2228. value: this._effectiveTarget[this._property]
  2229. }, {
  2230. frame: 100,
  2231. value: this.value
  2232. }
  2233. ];
  2234. var dataType;
  2235. if (typeof this.value === "number") {
  2236. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT;
  2237. }
  2238. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"]) {
  2239. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_COLOR3;
  2240. }
  2241. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"]) {
  2242. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3;
  2243. }
  2244. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]) {
  2245. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_MATRIX;
  2246. }
  2247. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]) {
  2248. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_QUATERNION;
  2249. }
  2250. else {
  2251. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("InterpolateValueAction: Unsupported type (" + typeof this.value + ")");
  2252. return;
  2253. }
  2254. var animation = new _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"]("InterpolateValueAction", this._property, 100 * (1000.0 / this.duration), dataType, _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  2255. animation.setKeys(keys);
  2256. if (this.stopOtherAnimations) {
  2257. scene.stopAnimation(this._effectiveTarget);
  2258. }
  2259. var wrapper = function () {
  2260. _this.onInterpolationDoneObservable.notifyObservers(_this);
  2261. if (_this.onInterpolationDone) {
  2262. _this.onInterpolationDone();
  2263. }
  2264. };
  2265. scene.beginDirectAnimation(this._effectiveTarget, [animation], 0, 100, false, 1, wrapper);
  2266. };
  2267. /**
  2268. * Serializes the actions and its related information.
  2269. * @param parent defines the object to serialize in
  2270. * @returns the serialized object
  2271. */
  2272. InterpolateValueAction.prototype.serialize = function (parent) {
  2273. return _super.prototype._serialize.call(this, {
  2274. name: "InterpolateValueAction",
  2275. properties: [
  2276. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  2277. { name: "propertyPath", value: this.propertyPath },
  2278. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  2279. { name: "duration", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.duration) },
  2280. { name: "stopOtherAnimations", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.stopOtherAnimations) || false }
  2281. ]
  2282. }, parent);
  2283. };
  2284. return InterpolateValueAction;
  2285. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2286. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__["_TypeStore"].RegisteredTypes["BABYLON.InterpolateValueAction"] = InterpolateValueAction;
  2287. /***/ }),
  2288. /***/ "./Animations/animatable.ts":
  2289. /*!**********************************!*\
  2290. !*** ./Animations/animatable.ts ***!
  2291. \**********************************/
  2292. /*! exports provided: Animatable */
  2293. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2294. "use strict";
  2295. __webpack_require__.r(__webpack_exports__);
  2296. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return Animatable; });
  2297. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  2298. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  2299. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2300. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  2301. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2302. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/precisionDate */ "./Misc/precisionDate.ts");
  2303. /* harmony import */ var _Bones_bone__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Bones/bone */ "./Bones/bone.ts");
  2304. /**
  2305. * Class used to store an actual running animation
  2306. */
  2307. var Animatable = /** @class */ (function () {
  2308. /**
  2309. * Creates a new Animatable
  2310. * @param scene defines the hosting scene
  2311. * @param target defines the target object
  2312. * @param fromFrame defines the starting frame number (default is 0)
  2313. * @param toFrame defines the ending frame number (default is 100)
  2314. * @param loopAnimation defines if the animation must loop (default is false)
  2315. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  2316. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  2317. * @param animations defines a group of animation to add to the new Animatable
  2318. * @param onAnimationLoop defines a callback to call when animation loops
  2319. */
  2320. function Animatable(scene,
  2321. /** defines the target object */
  2322. target,
  2323. /** defines the starting frame number (default is 0) */
  2324. fromFrame,
  2325. /** defines the ending frame number (default is 100) */
  2326. toFrame,
  2327. /** defines if the animation must loop (default is false) */
  2328. loopAnimation, speedRatio,
  2329. /** defines a callback to call when animation ends if it is not looping */
  2330. onAnimationEnd, animations,
  2331. /** defines a callback to call when animation loops */
  2332. onAnimationLoop) {
  2333. if (fromFrame === void 0) { fromFrame = 0; }
  2334. if (toFrame === void 0) { toFrame = 100; }
  2335. if (loopAnimation === void 0) { loopAnimation = false; }
  2336. if (speedRatio === void 0) { speedRatio = 1.0; }
  2337. this.target = target;
  2338. this.fromFrame = fromFrame;
  2339. this.toFrame = toFrame;
  2340. this.loopAnimation = loopAnimation;
  2341. this.onAnimationEnd = onAnimationEnd;
  2342. this.onAnimationLoop = onAnimationLoop;
  2343. this._localDelayOffset = null;
  2344. this._pausedDelay = null;
  2345. this._runtimeAnimations = new Array();
  2346. this._paused = false;
  2347. this._speedRatio = 1;
  2348. this._weight = -1.0;
  2349. /**
  2350. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  2351. * This will only apply for non looping animation (default is true)
  2352. */
  2353. this.disposeOnEnd = true;
  2354. /**
  2355. * Gets a boolean indicating if the animation has started
  2356. */
  2357. this.animationStarted = false;
  2358. /**
  2359. * Observer raised when the animation ends
  2360. */
  2361. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  2362. /**
  2363. * Observer raised when the animation loops
  2364. */
  2365. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  2366. this._scene = scene;
  2367. if (animations) {
  2368. this.appendAnimations(target, animations);
  2369. }
  2370. this._speedRatio = speedRatio;
  2371. scene._activeAnimatables.push(this);
  2372. }
  2373. Object.defineProperty(Animatable.prototype, "syncRoot", {
  2374. /**
  2375. * Gets the root Animatable used to synchronize and normalize animations
  2376. */
  2377. get: function () {
  2378. return this._syncRoot;
  2379. },
  2380. enumerable: true,
  2381. configurable: true
  2382. });
  2383. Object.defineProperty(Animatable.prototype, "masterFrame", {
  2384. /**
  2385. * Gets the current frame of the first RuntimeAnimation
  2386. * Used to synchronize Animatables
  2387. */
  2388. get: function () {
  2389. if (this._runtimeAnimations.length === 0) {
  2390. return 0;
  2391. }
  2392. return this._runtimeAnimations[0].currentFrame;
  2393. },
  2394. enumerable: true,
  2395. configurable: true
  2396. });
  2397. Object.defineProperty(Animatable.prototype, "weight", {
  2398. /**
  2399. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  2400. */
  2401. get: function () {
  2402. return this._weight;
  2403. },
  2404. set: function (value) {
  2405. if (value === -1) { // -1 is ok and means no weight
  2406. this._weight = -1;
  2407. return;
  2408. }
  2409. // Else weight must be in [0, 1] range
  2410. this._weight = Math.min(Math.max(value, 0), 1.0);
  2411. },
  2412. enumerable: true,
  2413. configurable: true
  2414. });
  2415. Object.defineProperty(Animatable.prototype, "speedRatio", {
  2416. /**
  2417. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  2418. */
  2419. get: function () {
  2420. return this._speedRatio;
  2421. },
  2422. set: function (value) {
  2423. for (var index = 0; index < this._runtimeAnimations.length; index++) {
  2424. var animation = this._runtimeAnimations[index];
  2425. animation._prepareForSpeedRatioChange(value);
  2426. }
  2427. this._speedRatio = value;
  2428. },
  2429. enumerable: true,
  2430. configurable: true
  2431. });
  2432. // Methods
  2433. /**
  2434. * Synchronize and normalize current Animatable with a source Animatable
  2435. * This is useful when using animation weights and when animations are not of the same length
  2436. * @param root defines the root Animatable to synchronize with
  2437. * @returns the current Animatable
  2438. */
  2439. Animatable.prototype.syncWith = function (root) {
  2440. this._syncRoot = root;
  2441. if (root) {
  2442. // Make sure this animatable will animate after the root
  2443. var index = this._scene._activeAnimatables.indexOf(this);
  2444. if (index > -1) {
  2445. this._scene._activeAnimatables.splice(index, 1);
  2446. this._scene._activeAnimatables.push(this);
  2447. }
  2448. }
  2449. return this;
  2450. };
  2451. /**
  2452. * Gets the list of runtime animations
  2453. * @returns an array of RuntimeAnimation
  2454. */
  2455. Animatable.prototype.getAnimations = function () {
  2456. return this._runtimeAnimations;
  2457. };
  2458. /**
  2459. * Adds more animations to the current animatable
  2460. * @param target defines the target of the animations
  2461. * @param animations defines the new animations to add
  2462. */
  2463. Animatable.prototype.appendAnimations = function (target, animations) {
  2464. for (var index = 0; index < animations.length; index++) {
  2465. var animation = animations[index];
  2466. this._runtimeAnimations.push(new _runtimeAnimation__WEBPACK_IMPORTED_MODULE_1__["RuntimeAnimation"](target, animation, this._scene, this));
  2467. }
  2468. };
  2469. /**
  2470. * Gets the source animation for a specific property
  2471. * @param property defines the propertyu to look for
  2472. * @returns null or the source animation for the given property
  2473. */
  2474. Animatable.prototype.getAnimationByTargetProperty = function (property) {
  2475. var runtimeAnimations = this._runtimeAnimations;
  2476. for (var index = 0; index < runtimeAnimations.length; index++) {
  2477. if (runtimeAnimations[index].animation.targetProperty === property) {
  2478. return runtimeAnimations[index].animation;
  2479. }
  2480. }
  2481. return null;
  2482. };
  2483. /**
  2484. * Gets the runtime animation for a specific property
  2485. * @param property defines the propertyu to look for
  2486. * @returns null or the runtime animation for the given property
  2487. */
  2488. Animatable.prototype.getRuntimeAnimationByTargetProperty = function (property) {
  2489. var runtimeAnimations = this._runtimeAnimations;
  2490. for (var index = 0; index < runtimeAnimations.length; index++) {
  2491. if (runtimeAnimations[index].animation.targetProperty === property) {
  2492. return runtimeAnimations[index];
  2493. }
  2494. }
  2495. return null;
  2496. };
  2497. /**
  2498. * Resets the animatable to its original state
  2499. */
  2500. Animatable.prototype.reset = function () {
  2501. var runtimeAnimations = this._runtimeAnimations;
  2502. for (var index = 0; index < runtimeAnimations.length; index++) {
  2503. runtimeAnimations[index].reset(true);
  2504. }
  2505. this._localDelayOffset = null;
  2506. this._pausedDelay = null;
  2507. };
  2508. /**
  2509. * Allows the animatable to blend with current running animations
  2510. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2511. * @param blendingSpeed defines the blending speed to use
  2512. */
  2513. Animatable.prototype.enableBlending = function (blendingSpeed) {
  2514. var runtimeAnimations = this._runtimeAnimations;
  2515. for (var index = 0; index < runtimeAnimations.length; index++) {
  2516. runtimeAnimations[index].animation.enableBlending = true;
  2517. runtimeAnimations[index].animation.blendingSpeed = blendingSpeed;
  2518. }
  2519. };
  2520. /**
  2521. * Disable animation blending
  2522. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2523. */
  2524. Animatable.prototype.disableBlending = function () {
  2525. var runtimeAnimations = this._runtimeAnimations;
  2526. for (var index = 0; index < runtimeAnimations.length; index++) {
  2527. runtimeAnimations[index].animation.enableBlending = false;
  2528. }
  2529. };
  2530. /**
  2531. * Jump directly to a given frame
  2532. * @param frame defines the frame to jump to
  2533. */
  2534. Animatable.prototype.goToFrame = function (frame) {
  2535. var runtimeAnimations = this._runtimeAnimations;
  2536. if (runtimeAnimations[0]) {
  2537. var fps = runtimeAnimations[0].animation.framePerSecond;
  2538. var currentFrame = runtimeAnimations[0].currentFrame;
  2539. var adjustTime = frame - currentFrame;
  2540. var delay = adjustTime * 1000 / (fps * this.speedRatio);
  2541. if (this._localDelayOffset === null) {
  2542. this._localDelayOffset = 0;
  2543. }
  2544. this._localDelayOffset -= delay;
  2545. }
  2546. for (var index = 0; index < runtimeAnimations.length; index++) {
  2547. runtimeAnimations[index].goToFrame(frame);
  2548. }
  2549. };
  2550. /**
  2551. * Pause the animation
  2552. */
  2553. Animatable.prototype.pause = function () {
  2554. if (this._paused) {
  2555. return;
  2556. }
  2557. this._paused = true;
  2558. };
  2559. /**
  2560. * Restart the animation
  2561. */
  2562. Animatable.prototype.restart = function () {
  2563. this._paused = false;
  2564. };
  2565. Animatable.prototype._raiseOnAnimationEnd = function () {
  2566. if (this.onAnimationEnd) {
  2567. this.onAnimationEnd();
  2568. }
  2569. this.onAnimationEndObservable.notifyObservers(this);
  2570. };
  2571. /**
  2572. * Stop and delete the current animation
  2573. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  2574. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  2575. */
  2576. Animatable.prototype.stop = function (animationName, targetMask) {
  2577. if (animationName || targetMask) {
  2578. var idx = this._scene._activeAnimatables.indexOf(this);
  2579. if (idx > -1) {
  2580. var runtimeAnimations = this._runtimeAnimations;
  2581. for (var index = runtimeAnimations.length - 1; index >= 0; index--) {
  2582. var runtimeAnimation = runtimeAnimations[index];
  2583. if (animationName && runtimeAnimation.animation.name != animationName) {
  2584. continue;
  2585. }
  2586. if (targetMask && !targetMask(runtimeAnimation.target)) {
  2587. continue;
  2588. }
  2589. runtimeAnimation.dispose();
  2590. runtimeAnimations.splice(index, 1);
  2591. }
  2592. if (runtimeAnimations.length == 0) {
  2593. this._scene._activeAnimatables.splice(idx, 1);
  2594. this._raiseOnAnimationEnd();
  2595. }
  2596. }
  2597. }
  2598. else {
  2599. var index = this._scene._activeAnimatables.indexOf(this);
  2600. if (index > -1) {
  2601. this._scene._activeAnimatables.splice(index, 1);
  2602. var runtimeAnimations = this._runtimeAnimations;
  2603. for (var index = 0; index < runtimeAnimations.length; index++) {
  2604. runtimeAnimations[index].dispose();
  2605. }
  2606. this._raiseOnAnimationEnd();
  2607. }
  2608. }
  2609. };
  2610. /**
  2611. * Wait asynchronously for the animation to end
  2612. * @returns a promise which will be fullfilled when the animation ends
  2613. */
  2614. Animatable.prototype.waitAsync = function () {
  2615. var _this = this;
  2616. return new Promise(function (resolve, reject) {
  2617. _this.onAnimationEndObservable.add(function () {
  2618. resolve(_this);
  2619. }, undefined, undefined, _this, true);
  2620. });
  2621. };
  2622. /** @hidden */
  2623. Animatable.prototype._animate = function (delay) {
  2624. var _this = this;
  2625. if (this._paused) {
  2626. this.animationStarted = false;
  2627. if (this._pausedDelay === null) {
  2628. this._pausedDelay = delay;
  2629. }
  2630. return true;
  2631. }
  2632. if (this._localDelayOffset === null) {
  2633. this._localDelayOffset = delay;
  2634. this._pausedDelay = null;
  2635. }
  2636. else if (this._pausedDelay !== null) {
  2637. this._localDelayOffset += delay - this._pausedDelay;
  2638. this._pausedDelay = null;
  2639. }
  2640. if (this._weight === 0) { // We consider that an animation with a weight === 0 is "actively" paused
  2641. return true;
  2642. }
  2643. // Animating
  2644. var running = false;
  2645. var runtimeAnimations = this._runtimeAnimations;
  2646. var index;
  2647. for (index = 0; index < runtimeAnimations.length; index++) {
  2648. var animation = runtimeAnimations[index];
  2649. var isRunning = animation.animate(delay - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this._speedRatio, this._weight, function () {
  2650. _this.onAnimationLoopObservable.notifyObservers(_this);
  2651. if (_this.onAnimationLoop) {
  2652. _this.onAnimationLoop();
  2653. }
  2654. });
  2655. running = running || isRunning;
  2656. }
  2657. this.animationStarted = running;
  2658. if (!running) {
  2659. if (this.disposeOnEnd) {
  2660. // Remove from active animatables
  2661. index = this._scene._activeAnimatables.indexOf(this);
  2662. this._scene._activeAnimatables.splice(index, 1);
  2663. // Dispose all runtime animations
  2664. for (index = 0; index < runtimeAnimations.length; index++) {
  2665. runtimeAnimations[index].dispose();
  2666. }
  2667. }
  2668. this._raiseOnAnimationEnd();
  2669. if (this.disposeOnEnd) {
  2670. this.onAnimationEnd = null;
  2671. this.onAnimationLoop = null;
  2672. this.onAnimationLoopObservable.clear();
  2673. this.onAnimationEndObservable.clear();
  2674. }
  2675. }
  2676. return running;
  2677. };
  2678. return Animatable;
  2679. }());
  2680. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._animate = function () {
  2681. if (!this.animationsEnabled || this._activeAnimatables.length === 0) {
  2682. return;
  2683. }
  2684. // Getting time
  2685. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_5__["PrecisionDate"].Now;
  2686. if (!this._animationTimeLast) {
  2687. if (this._pendingData.length > 0) {
  2688. return;
  2689. }
  2690. this._animationTimeLast = now;
  2691. }
  2692. var deltaTime = this.useConstantAnimationDeltaTime ? 16.0 : (now - this._animationTimeLast) * this.animationTimeScale;
  2693. this._animationTime += deltaTime;
  2694. this._animationTimeLast = now;
  2695. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2696. this._activeAnimatables[index]._animate(this._animationTime);
  2697. }
  2698. // Late animation bindings
  2699. this._processLateAnimationBindings();
  2700. };
  2701. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginWeightedAnimation = function (target, from, to, weight, loop, speedRatio, onAnimationEnd, animatable, targetMask, onAnimationLoop) {
  2702. if (weight === void 0) { weight = 1.0; }
  2703. if (speedRatio === void 0) { speedRatio = 1.0; }
  2704. var returnedAnimatable = this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, false, targetMask, onAnimationLoop);
  2705. returnedAnimatable.weight = weight;
  2706. return returnedAnimatable;
  2707. };
  2708. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginAnimation = function (target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  2709. if (speedRatio === void 0) { speedRatio = 1.0; }
  2710. if (stopCurrent === void 0) { stopCurrent = true; }
  2711. if (from > to && speedRatio > 0) {
  2712. speedRatio *= -1;
  2713. }
  2714. if (stopCurrent) {
  2715. this.stopAnimation(target, undefined, targetMask);
  2716. }
  2717. if (!animatable) {
  2718. animatable = new Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, undefined, onAnimationLoop);
  2719. }
  2720. var shouldRunTargetAnimations = targetMask ? targetMask(target) : true;
  2721. // Local animations
  2722. if (target.animations && shouldRunTargetAnimations) {
  2723. animatable.appendAnimations(target, target.animations);
  2724. }
  2725. // Children animations
  2726. if (target.getAnimatables) {
  2727. var animatables = target.getAnimatables();
  2728. for (var index = 0; index < animatables.length; index++) {
  2729. this.beginAnimation(animatables[index], from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop);
  2730. }
  2731. }
  2732. animatable.reset();
  2733. return animatable;
  2734. };
  2735. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginHierarchyAnimation = function (target, directDescendantsOnly, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  2736. if (speedRatio === void 0) { speedRatio = 1.0; }
  2737. if (stopCurrent === void 0) { stopCurrent = true; }
  2738. var children = target.getDescendants(directDescendantsOnly);
  2739. var result = [];
  2740. result.push(this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  2741. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  2742. var child = children_1[_i];
  2743. result.push(this.beginAnimation(child, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  2744. }
  2745. return result;
  2746. };
  2747. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginDirectAnimation = function (target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  2748. if (speedRatio === undefined) {
  2749. speedRatio = 1.0;
  2750. }
  2751. var animatable = new Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, animations, onAnimationLoop);
  2752. return animatable;
  2753. };
  2754. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginDirectHierarchyAnimation = function (target, directDescendantsOnly, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  2755. var children = target.getDescendants(directDescendantsOnly);
  2756. var result = [];
  2757. result.push(this.beginDirectAnimation(target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  2758. for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
  2759. var child = children_2[_i];
  2760. result.push(this.beginDirectAnimation(child, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  2761. }
  2762. return result;
  2763. };
  2764. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.getAnimatableByTarget = function (target) {
  2765. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2766. if (this._activeAnimatables[index].target === target) {
  2767. return this._activeAnimatables[index];
  2768. }
  2769. }
  2770. return null;
  2771. };
  2772. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.getAllAnimatablesByTarget = function (target) {
  2773. var result = [];
  2774. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2775. if (this._activeAnimatables[index].target === target) {
  2776. result.push(this._activeAnimatables[index]);
  2777. }
  2778. }
  2779. return result;
  2780. };
  2781. /**
  2782. * Will stop the animation of the given target
  2783. * @param target - the target
  2784. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  2785. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  2786. */
  2787. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.stopAnimation = function (target, animationName, targetMask) {
  2788. var animatables = this.getAllAnimatablesByTarget(target);
  2789. for (var _i = 0, animatables_1 = animatables; _i < animatables_1.length; _i++) {
  2790. var animatable = animatables_1[_i];
  2791. animatable.stop(animationName, targetMask);
  2792. }
  2793. };
  2794. /**
  2795. * Stops and removes all animations that have been applied to the scene
  2796. */
  2797. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.stopAllAnimations = function () {
  2798. if (this._activeAnimatables) {
  2799. for (var i = 0; i < this._activeAnimatables.length; i++) {
  2800. this._activeAnimatables[i].stop();
  2801. }
  2802. this._activeAnimatables = [];
  2803. }
  2804. for (var _i = 0, _a = this.animationGroups; _i < _a.length; _i++) {
  2805. var group = _a[_i];
  2806. group.stop();
  2807. }
  2808. };
  2809. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._registerTargetForLateAnimationBinding = function (runtimeAnimation, originalValue) {
  2810. var target = runtimeAnimation.target;
  2811. this._registeredForLateAnimationBindings.pushNoDuplicate(target);
  2812. if (!target._lateAnimationHolders) {
  2813. target._lateAnimationHolders = {};
  2814. }
  2815. if (!target._lateAnimationHolders[runtimeAnimation.targetPath]) {
  2816. target._lateAnimationHolders[runtimeAnimation.targetPath] = {
  2817. totalWeight: 0,
  2818. animations: [],
  2819. originalValue: originalValue
  2820. };
  2821. }
  2822. target._lateAnimationHolders[runtimeAnimation.targetPath].animations.push(runtimeAnimation);
  2823. target._lateAnimationHolders[runtimeAnimation.targetPath].totalWeight += runtimeAnimation.weight;
  2824. };
  2825. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindingsForMatrices = function (holder) {
  2826. var normalizer = 1.0;
  2827. var finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  2828. var finalScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  2829. var finalQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  2830. var startIndex = 0;
  2831. var originalAnimation = holder.animations[0];
  2832. var originalValue = holder.originalValue;
  2833. var scale = 1;
  2834. if (holder.totalWeight < 1.0) {
  2835. // We need to mix the original value in
  2836. originalValue.decompose(finalScaling, finalQuaternion, finalPosition);
  2837. scale = 1.0 - holder.totalWeight;
  2838. }
  2839. else {
  2840. startIndex = 1;
  2841. // We need to normalize the weights
  2842. normalizer = holder.totalWeight;
  2843. originalAnimation.currentValue.decompose(finalScaling, finalQuaternion, finalPosition);
  2844. scale = originalAnimation.weight / normalizer;
  2845. if (scale == 1) {
  2846. return originalAnimation.currentValue;
  2847. }
  2848. }
  2849. finalScaling.scaleInPlace(scale);
  2850. finalPosition.scaleInPlace(scale);
  2851. finalQuaternion.scaleInPlace(scale);
  2852. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  2853. var runtimeAnimation = holder.animations[animIndex];
  2854. var scale = runtimeAnimation.weight / normalizer;
  2855. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[2];
  2856. var currentScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[3];
  2857. var currentQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[1];
  2858. runtimeAnimation.currentValue.decompose(currentScaling, currentQuaternion, currentPosition);
  2859. currentScaling.scaleAndAddToRef(scale, finalScaling);
  2860. currentQuaternion.scaleAndAddToRef(scale, finalQuaternion);
  2861. currentPosition.scaleAndAddToRef(scale, finalPosition);
  2862. }
  2863. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(finalScaling, finalQuaternion, finalPosition, originalAnimation._workValue);
  2864. return originalAnimation._workValue;
  2865. };
  2866. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindingsForQuaternions = function (holder, refQuaternion) {
  2867. var originalAnimation = holder.animations[0];
  2868. var originalValue = holder.originalValue;
  2869. if (holder.animations.length === 1) {
  2870. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(originalValue, originalAnimation.currentValue, Math.min(1.0, holder.totalWeight), refQuaternion);
  2871. return refQuaternion;
  2872. }
  2873. var normalizer = 1.0;
  2874. var quaternions;
  2875. var weights;
  2876. if (holder.totalWeight < 1.0) {
  2877. var scale = 1.0 - holder.totalWeight;
  2878. quaternions = [];
  2879. weights = [];
  2880. quaternions.push(originalValue);
  2881. weights.push(scale);
  2882. }
  2883. else {
  2884. if (holder.animations.length === 2) { // Slerp as soon as we can
  2885. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(holder.animations[0].currentValue, holder.animations[1].currentValue, holder.animations[1].weight / holder.totalWeight, refQuaternion);
  2886. return refQuaternion;
  2887. }
  2888. quaternions = [];
  2889. weights = [];
  2890. normalizer = holder.totalWeight;
  2891. }
  2892. for (var animIndex = 0; animIndex < holder.animations.length; animIndex++) {
  2893. var runtimeAnimation = holder.animations[animIndex];
  2894. quaternions.push(runtimeAnimation.currentValue);
  2895. weights.push(runtimeAnimation.weight / normalizer);
  2896. }
  2897. // https://gamedev.stackexchange.com/questions/62354/method-for-interpolation-between-3-quaternions
  2898. var cumulativeAmount = 0;
  2899. var cumulativeQuaternion = null;
  2900. for (var index = 0; index < quaternions.length;) {
  2901. if (!cumulativeQuaternion) {
  2902. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(quaternions[index], quaternions[index + 1], weights[index + 1] / (weights[index] + weights[index + 1]), refQuaternion);
  2903. cumulativeQuaternion = refQuaternion;
  2904. cumulativeAmount = weights[index] + weights[index + 1];
  2905. index += 2;
  2906. continue;
  2907. }
  2908. cumulativeAmount += weights[index];
  2909. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(cumulativeQuaternion, quaternions[index], weights[index] / cumulativeAmount, cumulativeQuaternion);
  2910. index++;
  2911. }
  2912. return cumulativeQuaternion;
  2913. };
  2914. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindings = function () {
  2915. if (!this._registeredForLateAnimationBindings.length) {
  2916. return;
  2917. }
  2918. for (var index = 0; index < this._registeredForLateAnimationBindings.length; index++) {
  2919. var target = this._registeredForLateAnimationBindings.data[index];
  2920. for (var path in target._lateAnimationHolders) {
  2921. var holder = target._lateAnimationHolders[path];
  2922. var originalAnimation = holder.animations[0];
  2923. var originalValue = holder.originalValue;
  2924. var matrixDecomposeMode = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].AllowMatrixDecomposeForInterpolation && originalValue.m; // ie. data is matrix
  2925. var finalValue = target[path];
  2926. if (matrixDecomposeMode) {
  2927. finalValue = this._processLateAnimationBindingsForMatrices(holder);
  2928. }
  2929. else {
  2930. var quaternionMode = originalValue.w !== undefined;
  2931. if (quaternionMode) {
  2932. finalValue = this._processLateAnimationBindingsForQuaternions(holder, finalValue || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity());
  2933. }
  2934. else {
  2935. var startIndex = 0;
  2936. var normalizer = 1.0;
  2937. if (holder.totalWeight < 1.0) {
  2938. // We need to mix the original value in
  2939. if (originalValue.scale) {
  2940. finalValue = originalValue.scale(1.0 - holder.totalWeight);
  2941. }
  2942. else {
  2943. finalValue = originalValue * (1.0 - holder.totalWeight);
  2944. }
  2945. }
  2946. else {
  2947. // We need to normalize the weights
  2948. normalizer = holder.totalWeight;
  2949. var scale_1 = originalAnimation.weight / normalizer;
  2950. if (scale_1 !== 1) {
  2951. if (originalAnimation.currentValue.scale) {
  2952. finalValue = originalAnimation.currentValue.scale(scale_1);
  2953. }
  2954. else {
  2955. finalValue = originalAnimation.currentValue * scale_1;
  2956. }
  2957. }
  2958. else {
  2959. finalValue = originalAnimation.currentValue;
  2960. }
  2961. startIndex = 1;
  2962. }
  2963. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  2964. var runtimeAnimation = holder.animations[animIndex];
  2965. var scale = runtimeAnimation.weight / normalizer;
  2966. if (runtimeAnimation.currentValue.scaleAndAddToRef) {
  2967. runtimeAnimation.currentValue.scaleAndAddToRef(scale, finalValue);
  2968. }
  2969. else {
  2970. finalValue += runtimeAnimation.currentValue * scale;
  2971. }
  2972. }
  2973. }
  2974. }
  2975. target[path] = finalValue;
  2976. }
  2977. target._lateAnimationHolders = {};
  2978. }
  2979. this._registeredForLateAnimationBindings.reset();
  2980. };
  2981. _Bones_bone__WEBPACK_IMPORTED_MODULE_6__["Bone"].prototype.copyAnimationRange = function (source, rangeName, frameOffset, rescaleAsRequired, skelDimensionsRatio) {
  2982. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  2983. if (skelDimensionsRatio === void 0) { skelDimensionsRatio = null; }
  2984. // all animation may be coming from a library skeleton, so may need to create animation
  2985. if (this.animations.length === 0) {
  2986. this.animations.push(new _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"](this.name, "_matrix", source.animations[0].framePerSecond, _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONTYPE_MATRIX, 0));
  2987. this.animations[0].setKeys([]);
  2988. }
  2989. // get animation info / verify there is such a range from the source bone
  2990. var sourceRange = source.animations[0].getRange(rangeName);
  2991. if (!sourceRange) {
  2992. return false;
  2993. }
  2994. var from = sourceRange.from;
  2995. var to = sourceRange.to;
  2996. var sourceKeys = source.animations[0].getKeys();
  2997. // rescaling prep
  2998. var sourceBoneLength = source.length;
  2999. var sourceParent = source.getParent();
  3000. var parent = this.getParent();
  3001. var parentScalingReqd = rescaleAsRequired && sourceParent && sourceBoneLength && this.length && sourceBoneLength !== this.length;
  3002. var parentRatio = parentScalingReqd && parent && sourceParent ? parent.length / sourceParent.length : 1;
  3003. var dimensionsScalingReqd = rescaleAsRequired && !parent && skelDimensionsRatio && (skelDimensionsRatio.x !== 1 || skelDimensionsRatio.y !== 1 || skelDimensionsRatio.z !== 1);
  3004. var destKeys = this.animations[0].getKeys();
  3005. // loop vars declaration
  3006. var orig;
  3007. var origTranslation;
  3008. var mat;
  3009. for (var key = 0, nKeys = sourceKeys.length; key < nKeys; key++) {
  3010. orig = sourceKeys[key];
  3011. if (orig.frame >= from && orig.frame <= to) {
  3012. if (rescaleAsRequired) {
  3013. mat = orig.value.clone();
  3014. // scale based on parent ratio, when bone has parent
  3015. if (parentScalingReqd) {
  3016. origTranslation = mat.getTranslation();
  3017. mat.setTranslation(origTranslation.scaleInPlace(parentRatio));
  3018. // scale based on skeleton dimension ratio when root bone, and value is passed
  3019. }
  3020. else if (dimensionsScalingReqd && skelDimensionsRatio) {
  3021. origTranslation = mat.getTranslation();
  3022. mat.setTranslation(origTranslation.multiplyInPlace(skelDimensionsRatio));
  3023. // use original when root bone, and no data for skelDimensionsRatio
  3024. }
  3025. else {
  3026. mat = orig.value;
  3027. }
  3028. }
  3029. else {
  3030. mat = orig.value;
  3031. }
  3032. destKeys.push({ frame: orig.frame + frameOffset, value: mat });
  3033. }
  3034. }
  3035. this.animations[0].createRange(rangeName, from + frameOffset, to + frameOffset);
  3036. return true;
  3037. };
  3038. /***/ }),
  3039. /***/ "./Animations/animation.ts":
  3040. /*!*********************************!*\
  3041. !*** ./Animations/animation.ts ***!
  3042. \*********************************/
  3043. /*! exports provided: Animation */
  3044. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3045. "use strict";
  3046. __webpack_require__.r(__webpack_exports__);
  3047. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return Animation; });
  3048. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  3049. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  3050. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  3051. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  3052. /* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  3053. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  3054. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  3055. /**
  3056. * Class used to store any kind of animation
  3057. */
  3058. var Animation = /** @class */ (function () {
  3059. /**
  3060. * Initializes the animation
  3061. * @param name Name of the animation
  3062. * @param targetProperty Property to animate
  3063. * @param framePerSecond The frames per second of the animation
  3064. * @param dataType The data type of the animation
  3065. * @param loopMode The loop mode of the animation
  3066. * @param enableBlending Specifies if blending should be enabled
  3067. */
  3068. function Animation(
  3069. /**Name of the animation */
  3070. name,
  3071. /**Property to animate */
  3072. targetProperty,
  3073. /**The frames per second of the animation */
  3074. framePerSecond,
  3075. /**The data type of the animation */
  3076. dataType,
  3077. /**The loop mode of the animation */
  3078. loopMode,
  3079. /**Specifies if blending should be enabled */
  3080. enableBlending) {
  3081. this.name = name;
  3082. this.targetProperty = targetProperty;
  3083. this.framePerSecond = framePerSecond;
  3084. this.dataType = dataType;
  3085. this.loopMode = loopMode;
  3086. this.enableBlending = enableBlending;
  3087. /**
  3088. * @hidden Internal use only
  3089. */
  3090. this._runtimeAnimations = new Array();
  3091. /**
  3092. * The set of event that will be linked to this animation
  3093. */
  3094. this._events = new Array();
  3095. /**
  3096. * Stores the blending speed of the animation
  3097. */
  3098. this.blendingSpeed = 0.01;
  3099. /**
  3100. * Stores the animation ranges for the animation
  3101. */
  3102. this._ranges = {};
  3103. this.targetPropertyPath = targetProperty.split(".");
  3104. this.dataType = dataType;
  3105. this.loopMode = loopMode === undefined ? Animation.ANIMATIONLOOPMODE_CYCLE : loopMode;
  3106. }
  3107. /**
  3108. * @hidden Internal use
  3109. */
  3110. Animation._PrepareAnimation = function (name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction) {
  3111. var dataType = undefined;
  3112. if (!isNaN(parseFloat(from)) && isFinite(from)) {
  3113. dataType = Animation.ANIMATIONTYPE_FLOAT;
  3114. }
  3115. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]) {
  3116. dataType = Animation.ANIMATIONTYPE_QUATERNION;
  3117. }
  3118. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  3119. dataType = Animation.ANIMATIONTYPE_VECTOR3;
  3120. }
  3121. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"]) {
  3122. dataType = Animation.ANIMATIONTYPE_VECTOR2;
  3123. }
  3124. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"]) {
  3125. dataType = Animation.ANIMATIONTYPE_COLOR3;
  3126. }
  3127. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"]) {
  3128. dataType = Animation.ANIMATIONTYPE_SIZE;
  3129. }
  3130. if (dataType == undefined) {
  3131. return null;
  3132. }
  3133. var animation = new Animation(name, targetProperty, framePerSecond, dataType, loopMode);
  3134. var keys = [{ frame: 0, value: from }, { frame: totalFrame, value: to }];
  3135. animation.setKeys(keys);
  3136. if (easingFunction !== undefined) {
  3137. animation.setEasingFunction(easingFunction);
  3138. }
  3139. return animation;
  3140. };
  3141. /**
  3142. * Sets up an animation
  3143. * @param property The property to animate
  3144. * @param animationType The animation type to apply
  3145. * @param framePerSecond The frames per second of the animation
  3146. * @param easingFunction The easing function used in the animation
  3147. * @returns The created animation
  3148. */
  3149. Animation.CreateAnimation = function (property, animationType, framePerSecond, easingFunction) {
  3150. var animation = new Animation(property + "Animation", property, framePerSecond, animationType, Animation.ANIMATIONLOOPMODE_CONSTANT);
  3151. animation.setEasingFunction(easingFunction);
  3152. return animation;
  3153. };
  3154. /**
  3155. * Create and start an animation on a node
  3156. * @param name defines the name of the global animation that will be run on all nodes
  3157. * @param node defines the root node where the animation will take place
  3158. * @param targetProperty defines property to animate
  3159. * @param framePerSecond defines the number of frame per second yo use
  3160. * @param totalFrame defines the number of frames in total
  3161. * @param from defines the initial value
  3162. * @param to defines the final value
  3163. * @param loopMode defines which loop mode you want to use (off by default)
  3164. * @param easingFunction defines the easing function to use (linear by default)
  3165. * @param onAnimationEnd defines the callback to call when animation end
  3166. * @returns the animatable created for this animation
  3167. */
  3168. Animation.CreateAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3169. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3170. if (!animation) {
  3171. return null;
  3172. }
  3173. return node.getScene().beginDirectAnimation(node, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3174. };
  3175. /**
  3176. * Create and start an animation on a node and its descendants
  3177. * @param name defines the name of the global animation that will be run on all nodes
  3178. * @param node defines the root node where the animation will take place
  3179. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  3180. * @param targetProperty defines property to animate
  3181. * @param framePerSecond defines the number of frame per second to use
  3182. * @param totalFrame defines the number of frames in total
  3183. * @param from defines the initial value
  3184. * @param to defines the final value
  3185. * @param loopMode defines which loop mode you want to use (off by default)
  3186. * @param easingFunction defines the easing function to use (linear by default)
  3187. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3188. * @returns the list of animatables created for all nodes
  3189. * @example https://www.babylonjs-playground.com/#MH0VLI
  3190. */
  3191. Animation.CreateAndStartHierarchyAnimation = function (name, node, directDescendantsOnly, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3192. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3193. if (!animation) {
  3194. return null;
  3195. }
  3196. var scene = node.getScene();
  3197. return scene.beginDirectHierarchyAnimation(node, directDescendantsOnly, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3198. };
  3199. /**
  3200. * Creates a new animation, merges it with the existing animations and starts it
  3201. * @param name Name of the animation
  3202. * @param node Node which contains the scene that begins the animations
  3203. * @param targetProperty Specifies which property to animate
  3204. * @param framePerSecond The frames per second of the animation
  3205. * @param totalFrame The total number of frames
  3206. * @param from The frame at the beginning of the animation
  3207. * @param to The frame at the end of the animation
  3208. * @param loopMode Specifies the loop mode of the animation
  3209. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3210. * @param onAnimationEnd Callback to run once the animation is complete
  3211. * @returns Nullable animation
  3212. */
  3213. Animation.CreateMergeAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3214. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3215. if (!animation) {
  3216. return null;
  3217. }
  3218. node.animations.push(animation);
  3219. return node.getScene().beginAnimation(node, 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3220. };
  3221. /**
  3222. * Transition property of an host to the target Value
  3223. * @param property The property to transition
  3224. * @param targetValue The target Value of the property
  3225. * @param host The object where the property to animate belongs
  3226. * @param scene Scene used to run the animation
  3227. * @param frameRate Framerate (in frame/s) to use
  3228. * @param transition The transition type we want to use
  3229. * @param duration The duration of the animation, in milliseconds
  3230. * @param onAnimationEnd Callback trigger at the end of the animation
  3231. * @returns Nullable animation
  3232. */
  3233. Animation.TransitionTo = function (property, targetValue, host, scene, frameRate, transition, duration, onAnimationEnd) {
  3234. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  3235. if (duration <= 0) {
  3236. host[property] = targetValue;
  3237. if (onAnimationEnd) {
  3238. onAnimationEnd();
  3239. }
  3240. return null;
  3241. }
  3242. var endFrame = frameRate * (duration / 1000);
  3243. transition.setKeys([{
  3244. frame: 0,
  3245. value: host[property].clone ? host[property].clone() : host[property]
  3246. },
  3247. {
  3248. frame: endFrame,
  3249. value: targetValue
  3250. }]);
  3251. if (!host.animations) {
  3252. host.animations = [];
  3253. }
  3254. host.animations.push(transition);
  3255. var animation = scene.beginAnimation(host, 0, endFrame, false);
  3256. animation.onAnimationEnd = onAnimationEnd;
  3257. return animation;
  3258. };
  3259. Object.defineProperty(Animation.prototype, "runtimeAnimations", {
  3260. /**
  3261. * Return the array of runtime animations currently using this animation
  3262. */
  3263. get: function () {
  3264. return this._runtimeAnimations;
  3265. },
  3266. enumerable: true,
  3267. configurable: true
  3268. });
  3269. Object.defineProperty(Animation.prototype, "hasRunningRuntimeAnimations", {
  3270. /**
  3271. * Specifies if any of the runtime animations are currently running
  3272. */
  3273. get: function () {
  3274. for (var _i = 0, _a = this._runtimeAnimations; _i < _a.length; _i++) {
  3275. var runtimeAnimation = _a[_i];
  3276. if (!runtimeAnimation.isStopped) {
  3277. return true;
  3278. }
  3279. }
  3280. return false;
  3281. },
  3282. enumerable: true,
  3283. configurable: true
  3284. });
  3285. // Methods
  3286. /**
  3287. * Converts the animation to a string
  3288. * @param fullDetails support for multiple levels of logging within scene loading
  3289. * @returns String form of the animation
  3290. */
  3291. Animation.prototype.toString = function (fullDetails) {
  3292. var ret = "Name: " + this.name + ", property: " + this.targetProperty;
  3293. ret += ", datatype: " + (["Float", "Vector3", "Quaternion", "Matrix", "Color3", "Vector2"])[this.dataType];
  3294. ret += ", nKeys: " + (this._keys ? this._keys.length : "none");
  3295. ret += ", nRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  3296. if (fullDetails) {
  3297. ret += ", Ranges: {";
  3298. var first = true;
  3299. for (var name in this._ranges) {
  3300. if (first) {
  3301. ret += ", ";
  3302. first = false;
  3303. }
  3304. ret += name;
  3305. }
  3306. ret += "}";
  3307. }
  3308. return ret;
  3309. };
  3310. /**
  3311. * Add an event to this animation
  3312. * @param event Event to add
  3313. */
  3314. Animation.prototype.addEvent = function (event) {
  3315. this._events.push(event);
  3316. };
  3317. /**
  3318. * Remove all events found at the given frame
  3319. * @param frame The frame to remove events from
  3320. */
  3321. Animation.prototype.removeEvents = function (frame) {
  3322. for (var index = 0; index < this._events.length; index++) {
  3323. if (this._events[index].frame === frame) {
  3324. this._events.splice(index, 1);
  3325. index--;
  3326. }
  3327. }
  3328. };
  3329. /**
  3330. * Retrieves all the events from the animation
  3331. * @returns Events from the animation
  3332. */
  3333. Animation.prototype.getEvents = function () {
  3334. return this._events;
  3335. };
  3336. /**
  3337. * Creates an animation range
  3338. * @param name Name of the animation range
  3339. * @param from Starting frame of the animation range
  3340. * @param to Ending frame of the animation
  3341. */
  3342. Animation.prototype.createRange = function (name, from, to) {
  3343. // check name not already in use; could happen for bones after serialized
  3344. if (!this._ranges[name]) {
  3345. this._ranges[name] = new _animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  3346. }
  3347. };
  3348. /**
  3349. * Deletes an animation range by name
  3350. * @param name Name of the animation range to delete
  3351. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3352. */
  3353. Animation.prototype.deleteRange = function (name, deleteFrames) {
  3354. if (deleteFrames === void 0) { deleteFrames = true; }
  3355. var range = this._ranges[name];
  3356. if (!range) {
  3357. return;
  3358. }
  3359. if (deleteFrames) {
  3360. var from = range.from;
  3361. var to = range.to;
  3362. // this loop MUST go high to low for multiple splices to work
  3363. for (var key = this._keys.length - 1; key >= 0; key--) {
  3364. if (this._keys[key].frame >= from && this._keys[key].frame <= to) {
  3365. this._keys.splice(key, 1);
  3366. }
  3367. }
  3368. }
  3369. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  3370. };
  3371. /**
  3372. * Gets the animation range by name, or null if not defined
  3373. * @param name Name of the animation range
  3374. * @returns Nullable animation range
  3375. */
  3376. Animation.prototype.getRange = function (name) {
  3377. return this._ranges[name];
  3378. };
  3379. /**
  3380. * Gets the key frames from the animation
  3381. * @returns The key frames of the animation
  3382. */
  3383. Animation.prototype.getKeys = function () {
  3384. return this._keys;
  3385. };
  3386. /**
  3387. * Gets the highest frame rate of the animation
  3388. * @returns Highest frame rate of the animation
  3389. */
  3390. Animation.prototype.getHighestFrame = function () {
  3391. var ret = 0;
  3392. for (var key = 0, nKeys = this._keys.length; key < nKeys; key++) {
  3393. if (ret < this._keys[key].frame) {
  3394. ret = this._keys[key].frame;
  3395. }
  3396. }
  3397. return ret;
  3398. };
  3399. /**
  3400. * Gets the easing function of the animation
  3401. * @returns Easing function of the animation
  3402. */
  3403. Animation.prototype.getEasingFunction = function () {
  3404. return this._easingFunction;
  3405. };
  3406. /**
  3407. * Sets the easing function of the animation
  3408. * @param easingFunction A custom mathematical formula for animation
  3409. */
  3410. Animation.prototype.setEasingFunction = function (easingFunction) {
  3411. this._easingFunction = easingFunction;
  3412. };
  3413. /**
  3414. * Interpolates a scalar linearly
  3415. * @param startValue Start value of the animation curve
  3416. * @param endValue End value of the animation curve
  3417. * @param gradient Scalar amount to interpolate
  3418. * @returns Interpolated scalar value
  3419. */
  3420. Animation.prototype.floatInterpolateFunction = function (startValue, endValue, gradient) {
  3421. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Lerp(startValue, endValue, gradient);
  3422. };
  3423. /**
  3424. * Interpolates a scalar cubically
  3425. * @param startValue Start value of the animation curve
  3426. * @param outTangent End tangent of the animation
  3427. * @param endValue End value of the animation curve
  3428. * @param inTangent Start tangent of the animation curve
  3429. * @param gradient Scalar amount to interpolate
  3430. * @returns Interpolated scalar value
  3431. */
  3432. Animation.prototype.floatInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3433. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3434. };
  3435. /**
  3436. * Interpolates a quaternion using a spherical linear interpolation
  3437. * @param startValue Start value of the animation curve
  3438. * @param endValue End value of the animation curve
  3439. * @param gradient Scalar amount to interpolate
  3440. * @returns Interpolated quaternion value
  3441. */
  3442. Animation.prototype.quaternionInterpolateFunction = function (startValue, endValue, gradient) {
  3443. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Slerp(startValue, endValue, gradient);
  3444. };
  3445. /**
  3446. * Interpolates a quaternion cubically
  3447. * @param startValue Start value of the animation curve
  3448. * @param outTangent End tangent of the animation curve
  3449. * @param endValue End value of the animation curve
  3450. * @param inTangent Start tangent of the animation curve
  3451. * @param gradient Scalar amount to interpolate
  3452. * @returns Interpolated quaternion value
  3453. */
  3454. Animation.prototype.quaternionInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3455. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Hermite(startValue, outTangent, endValue, inTangent, gradient).normalize();
  3456. };
  3457. /**
  3458. * Interpolates a Vector3 linearl
  3459. * @param startValue Start value of the animation curve
  3460. * @param endValue End value of the animation curve
  3461. * @param gradient Scalar amount to interpolate
  3462. * @returns Interpolated scalar value
  3463. */
  3464. Animation.prototype.vector3InterpolateFunction = function (startValue, endValue, gradient) {
  3465. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(startValue, endValue, gradient);
  3466. };
  3467. /**
  3468. * Interpolates a Vector3 cubically
  3469. * @param startValue Start value of the animation curve
  3470. * @param outTangent End tangent of the animation
  3471. * @param endValue End value of the animation curve
  3472. * @param inTangent Start tangent of the animation curve
  3473. * @param gradient Scalar amount to interpolate
  3474. * @returns InterpolatedVector3 value
  3475. */
  3476. Animation.prototype.vector3InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3477. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3478. };
  3479. /**
  3480. * Interpolates a Vector2 linearly
  3481. * @param startValue Start value of the animation curve
  3482. * @param endValue End value of the animation curve
  3483. * @param gradient Scalar amount to interpolate
  3484. * @returns Interpolated Vector2 value
  3485. */
  3486. Animation.prototype.vector2InterpolateFunction = function (startValue, endValue, gradient) {
  3487. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(startValue, endValue, gradient);
  3488. };
  3489. /**
  3490. * Interpolates a Vector2 cubically
  3491. * @param startValue Start value of the animation curve
  3492. * @param outTangent End tangent of the animation
  3493. * @param endValue End value of the animation curve
  3494. * @param inTangent Start tangent of the animation curve
  3495. * @param gradient Scalar amount to interpolate
  3496. * @returns Interpolated Vector2 value
  3497. */
  3498. Animation.prototype.vector2InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3499. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3500. };
  3501. /**
  3502. * Interpolates a size linearly
  3503. * @param startValue Start value of the animation curve
  3504. * @param endValue End value of the animation curve
  3505. * @param gradient Scalar amount to interpolate
  3506. * @returns Interpolated Size value
  3507. */
  3508. Animation.prototype.sizeInterpolateFunction = function (startValue, endValue, gradient) {
  3509. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Lerp(startValue, endValue, gradient);
  3510. };
  3511. /**
  3512. * Interpolates a Color3 linearly
  3513. * @param startValue Start value of the animation curve
  3514. * @param endValue End value of the animation curve
  3515. * @param gradient Scalar amount to interpolate
  3516. * @returns Interpolated Color3 value
  3517. */
  3518. Animation.prototype.color3InterpolateFunction = function (startValue, endValue, gradient) {
  3519. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Lerp(startValue, endValue, gradient);
  3520. };
  3521. /**
  3522. * @hidden Internal use only
  3523. */
  3524. Animation.prototype._getKeyValue = function (value) {
  3525. if (typeof value === "function") {
  3526. return value();
  3527. }
  3528. return value;
  3529. };
  3530. /**
  3531. * @hidden Internal use only
  3532. */
  3533. Animation.prototype._interpolate = function (currentFrame, repeatCount, workValue, loopMode, offsetValue, highLimitValue) {
  3534. if (loopMode === Animation.ANIMATIONLOOPMODE_CONSTANT && repeatCount > 0) {
  3535. return highLimitValue.clone ? highLimitValue.clone() : highLimitValue;
  3536. }
  3537. var keys = this.getKeys();
  3538. if (keys.length === 1) {
  3539. return this._getKeyValue(keys[0].value);
  3540. }
  3541. // Try to get a hash to find the right key
  3542. var startKeyIndex = Math.max(0, Math.min(keys.length - 1, Math.floor(keys.length * (currentFrame - keys[0].frame) / (keys[keys.length - 1].frame - keys[0].frame)) - 1));
  3543. if (keys[startKeyIndex].frame >= currentFrame) {
  3544. while (startKeyIndex - 1 >= 0 && keys[startKeyIndex].frame >= currentFrame) {
  3545. startKeyIndex--;
  3546. }
  3547. }
  3548. for (var key = startKeyIndex; key < keys.length; key++) {
  3549. var endKey = keys[key + 1];
  3550. if (endKey.frame >= currentFrame) {
  3551. var startKey = keys[key];
  3552. var startValue = this._getKeyValue(startKey.value);
  3553. if (startKey.interpolation === _animationKey__WEBPACK_IMPORTED_MODULE_4__["AnimationKeyInterpolation"].STEP) {
  3554. return startValue;
  3555. }
  3556. var endValue = this._getKeyValue(endKey.value);
  3557. var useTangent = startKey.outTangent !== undefined && endKey.inTangent !== undefined;
  3558. var frameDelta = endKey.frame - startKey.frame;
  3559. // gradient : percent of currentFrame between the frame inf and the frame sup
  3560. var gradient = (currentFrame - startKey.frame) / frameDelta;
  3561. // check for easingFunction and correction of gradient
  3562. var easingFunction = this.getEasingFunction();
  3563. if (easingFunction != null) {
  3564. gradient = easingFunction.ease(gradient);
  3565. }
  3566. switch (this.dataType) {
  3567. // Float
  3568. case Animation.ANIMATIONTYPE_FLOAT:
  3569. var floatValue = useTangent ? this.floatInterpolateFunctionWithTangents(startValue, startKey.outTangent * frameDelta, endValue, endKey.inTangent * frameDelta, gradient) : this.floatInterpolateFunction(startValue, endValue, gradient);
  3570. switch (loopMode) {
  3571. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3572. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3573. return floatValue;
  3574. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3575. return offsetValue * repeatCount + floatValue;
  3576. }
  3577. break;
  3578. // Quaternion
  3579. case Animation.ANIMATIONTYPE_QUATERNION:
  3580. var quatValue = useTangent ? this.quaternionInterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.quaternionInterpolateFunction(startValue, endValue, gradient);
  3581. switch (loopMode) {
  3582. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3583. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3584. return quatValue;
  3585. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3586. return quatValue.addInPlace(offsetValue.scale(repeatCount));
  3587. }
  3588. return quatValue;
  3589. // Vector3
  3590. case Animation.ANIMATIONTYPE_VECTOR3:
  3591. var vec3Value = useTangent ? this.vector3InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector3InterpolateFunction(startValue, endValue, gradient);
  3592. switch (loopMode) {
  3593. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3594. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3595. return vec3Value;
  3596. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3597. return vec3Value.add(offsetValue.scale(repeatCount));
  3598. }
  3599. // Vector2
  3600. case Animation.ANIMATIONTYPE_VECTOR2:
  3601. var vec2Value = useTangent ? this.vector2InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector2InterpolateFunction(startValue, endValue, gradient);
  3602. switch (loopMode) {
  3603. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3604. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3605. return vec2Value;
  3606. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3607. return vec2Value.add(offsetValue.scale(repeatCount));
  3608. }
  3609. // Size
  3610. case Animation.ANIMATIONTYPE_SIZE:
  3611. switch (loopMode) {
  3612. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3613. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3614. return this.sizeInterpolateFunction(startValue, endValue, gradient);
  3615. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3616. return this.sizeInterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
  3617. }
  3618. // Color3
  3619. case Animation.ANIMATIONTYPE_COLOR3:
  3620. switch (loopMode) {
  3621. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3622. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3623. return this.color3InterpolateFunction(startValue, endValue, gradient);
  3624. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3625. return this.color3InterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
  3626. }
  3627. // Matrix
  3628. case Animation.ANIMATIONTYPE_MATRIX:
  3629. switch (loopMode) {
  3630. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3631. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3632. if (Animation.AllowMatricesInterpolation) {
  3633. return this.matrixInterpolateFunction(startValue, endValue, gradient, workValue);
  3634. }
  3635. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3636. return startValue;
  3637. }
  3638. default:
  3639. break;
  3640. }
  3641. break;
  3642. }
  3643. }
  3644. return this._getKeyValue(keys[keys.length - 1].value);
  3645. };
  3646. /**
  3647. * Defines the function to use to interpolate matrices
  3648. * @param startValue defines the start matrix
  3649. * @param endValue defines the end matrix
  3650. * @param gradient defines the gradient between both matrices
  3651. * @param result defines an optional target matrix where to store the interpolation
  3652. * @returns the interpolated matrix
  3653. */
  3654. Animation.prototype.matrixInterpolateFunction = function (startValue, endValue, gradient, result) {
  3655. if (Animation.AllowMatrixDecomposeForInterpolation) {
  3656. if (result) {
  3657. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(startValue, endValue, gradient, result);
  3658. return result;
  3659. }
  3660. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(startValue, endValue, gradient);
  3661. }
  3662. if (result) {
  3663. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(startValue, endValue, gradient, result);
  3664. return result;
  3665. }
  3666. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(startValue, endValue, gradient);
  3667. };
  3668. /**
  3669. * Makes a copy of the animation
  3670. * @returns Cloned animation
  3671. */
  3672. Animation.prototype.clone = function () {
  3673. var clone = new Animation(this.name, this.targetPropertyPath.join("."), this.framePerSecond, this.dataType, this.loopMode);
  3674. clone.enableBlending = this.enableBlending;
  3675. clone.blendingSpeed = this.blendingSpeed;
  3676. if (this._keys) {
  3677. clone.setKeys(this._keys);
  3678. }
  3679. if (this._ranges) {
  3680. clone._ranges = {};
  3681. for (var name in this._ranges) {
  3682. var range = this._ranges[name];
  3683. if (!range) {
  3684. continue;
  3685. }
  3686. clone._ranges[name] = range.clone();
  3687. }
  3688. }
  3689. return clone;
  3690. };
  3691. /**
  3692. * Sets the key frames of the animation
  3693. * @param values The animation key frames to set
  3694. */
  3695. Animation.prototype.setKeys = function (values) {
  3696. this._keys = values.slice(0);
  3697. };
  3698. /**
  3699. * Serializes the animation to an object
  3700. * @returns Serialized object
  3701. */
  3702. Animation.prototype.serialize = function () {
  3703. var serializationObject = {};
  3704. serializationObject.name = this.name;
  3705. serializationObject.property = this.targetProperty;
  3706. serializationObject.framePerSecond = this.framePerSecond;
  3707. serializationObject.dataType = this.dataType;
  3708. serializationObject.loopBehavior = this.loopMode;
  3709. serializationObject.enableBlending = this.enableBlending;
  3710. serializationObject.blendingSpeed = this.blendingSpeed;
  3711. var dataType = this.dataType;
  3712. serializationObject.keys = [];
  3713. var keys = this.getKeys();
  3714. for (var index = 0; index < keys.length; index++) {
  3715. var animationKey = keys[index];
  3716. var key = {};
  3717. key.frame = animationKey.frame;
  3718. switch (dataType) {
  3719. case Animation.ANIMATIONTYPE_FLOAT:
  3720. key.values = [animationKey.value];
  3721. break;
  3722. case Animation.ANIMATIONTYPE_QUATERNION:
  3723. case Animation.ANIMATIONTYPE_MATRIX:
  3724. case Animation.ANIMATIONTYPE_VECTOR3:
  3725. case Animation.ANIMATIONTYPE_COLOR3:
  3726. key.values = animationKey.value.asArray();
  3727. break;
  3728. }
  3729. serializationObject.keys.push(key);
  3730. }
  3731. serializationObject.ranges = [];
  3732. for (var name in this._ranges) {
  3733. var source = this._ranges[name];
  3734. if (!source) {
  3735. continue;
  3736. }
  3737. var range = {};
  3738. range.name = name;
  3739. range.from = source.from;
  3740. range.to = source.to;
  3741. serializationObject.ranges.push(range);
  3742. }
  3743. return serializationObject;
  3744. };
  3745. Object.defineProperty(Animation, "ANIMATIONTYPE_FLOAT", {
  3746. /**
  3747. * Get the float animation type
  3748. */
  3749. get: function () {
  3750. return Animation._ANIMATIONTYPE_FLOAT;
  3751. },
  3752. enumerable: true,
  3753. configurable: true
  3754. });
  3755. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR3", {
  3756. /**
  3757. * Get the Vector3 animation type
  3758. */
  3759. get: function () {
  3760. return Animation._ANIMATIONTYPE_VECTOR3;
  3761. },
  3762. enumerable: true,
  3763. configurable: true
  3764. });
  3765. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR2", {
  3766. /**
  3767. * Get the Vector2 animation type
  3768. */
  3769. get: function () {
  3770. return Animation._ANIMATIONTYPE_VECTOR2;
  3771. },
  3772. enumerable: true,
  3773. configurable: true
  3774. });
  3775. Object.defineProperty(Animation, "ANIMATIONTYPE_SIZE", {
  3776. /**
  3777. * Get the Size animation type
  3778. */
  3779. get: function () {
  3780. return Animation._ANIMATIONTYPE_SIZE;
  3781. },
  3782. enumerable: true,
  3783. configurable: true
  3784. });
  3785. Object.defineProperty(Animation, "ANIMATIONTYPE_QUATERNION", {
  3786. /**
  3787. * Get the Quaternion animation type
  3788. */
  3789. get: function () {
  3790. return Animation._ANIMATIONTYPE_QUATERNION;
  3791. },
  3792. enumerable: true,
  3793. configurable: true
  3794. });
  3795. Object.defineProperty(Animation, "ANIMATIONTYPE_MATRIX", {
  3796. /**
  3797. * Get the Matrix animation type
  3798. */
  3799. get: function () {
  3800. return Animation._ANIMATIONTYPE_MATRIX;
  3801. },
  3802. enumerable: true,
  3803. configurable: true
  3804. });
  3805. Object.defineProperty(Animation, "ANIMATIONTYPE_COLOR3", {
  3806. /**
  3807. * Get the Color3 animation type
  3808. */
  3809. get: function () {
  3810. return Animation._ANIMATIONTYPE_COLOR3;
  3811. },
  3812. enumerable: true,
  3813. configurable: true
  3814. });
  3815. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_RELATIVE", {
  3816. /**
  3817. * Get the Relative Loop Mode
  3818. */
  3819. get: function () {
  3820. return Animation._ANIMATIONLOOPMODE_RELATIVE;
  3821. },
  3822. enumerable: true,
  3823. configurable: true
  3824. });
  3825. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CYCLE", {
  3826. /**
  3827. * Get the Cycle Loop Mode
  3828. */
  3829. get: function () {
  3830. return Animation._ANIMATIONLOOPMODE_CYCLE;
  3831. },
  3832. enumerable: true,
  3833. configurable: true
  3834. });
  3835. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CONSTANT", {
  3836. /**
  3837. * Get the Constant Loop Mode
  3838. */
  3839. get: function () {
  3840. return Animation._ANIMATIONLOOPMODE_CONSTANT;
  3841. },
  3842. enumerable: true,
  3843. configurable: true
  3844. });
  3845. /** @hidden */
  3846. Animation._UniversalLerp = function (left, right, amount) {
  3847. var constructor = left.constructor;
  3848. if (constructor.Lerp) { // Lerp supported
  3849. return constructor.Lerp(left, right, amount);
  3850. }
  3851. else if (constructor.Slerp) { // Slerp supported
  3852. return constructor.Slerp(left, right, amount);
  3853. }
  3854. else if (left.toFixed) { // Number
  3855. return left * (1.0 - amount) + amount * right;
  3856. }
  3857. else { // Blending not supported
  3858. return right;
  3859. }
  3860. };
  3861. /**
  3862. * Parses an animation object and creates an animation
  3863. * @param parsedAnimation Parsed animation object
  3864. * @returns Animation object
  3865. */
  3866. Animation.Parse = function (parsedAnimation) {
  3867. var animation = new Animation(parsedAnimation.name, parsedAnimation.property, parsedAnimation.framePerSecond, parsedAnimation.dataType, parsedAnimation.loopBehavior);
  3868. var dataType = parsedAnimation.dataType;
  3869. var keys = [];
  3870. var data;
  3871. var index;
  3872. if (parsedAnimation.enableBlending) {
  3873. animation.enableBlending = parsedAnimation.enableBlending;
  3874. }
  3875. if (parsedAnimation.blendingSpeed) {
  3876. animation.blendingSpeed = parsedAnimation.blendingSpeed;
  3877. }
  3878. for (index = 0; index < parsedAnimation.keys.length; index++) {
  3879. var key = parsedAnimation.keys[index];
  3880. var inTangent;
  3881. var outTangent;
  3882. switch (dataType) {
  3883. case Animation.ANIMATIONTYPE_FLOAT:
  3884. data = key.values[0];
  3885. if (key.values.length >= 1) {
  3886. inTangent = key.values[1];
  3887. }
  3888. if (key.values.length >= 2) {
  3889. outTangent = key.values[2];
  3890. }
  3891. break;
  3892. case Animation.ANIMATIONTYPE_QUATERNION:
  3893. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values);
  3894. if (key.values.length >= 8) {
  3895. var _inTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(4, 8));
  3896. if (!_inTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3897. inTangent = _inTangent;
  3898. }
  3899. }
  3900. if (key.values.length >= 12) {
  3901. var _outTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(8, 12));
  3902. if (!_outTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3903. outTangent = _outTangent;
  3904. }
  3905. }
  3906. break;
  3907. case Animation.ANIMATIONTYPE_MATRIX:
  3908. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromArray(key.values);
  3909. break;
  3910. case Animation.ANIMATIONTYPE_COLOR3:
  3911. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(key.values);
  3912. break;
  3913. case Animation.ANIMATIONTYPE_VECTOR3:
  3914. default:
  3915. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(key.values);
  3916. break;
  3917. }
  3918. var keyData = {};
  3919. keyData.frame = key.frame;
  3920. keyData.value = data;
  3921. if (inTangent != undefined) {
  3922. keyData.inTangent = inTangent;
  3923. }
  3924. if (outTangent != undefined) {
  3925. keyData.outTangent = outTangent;
  3926. }
  3927. keys.push(keyData);
  3928. }
  3929. animation.setKeys(keys);
  3930. if (parsedAnimation.ranges) {
  3931. for (index = 0; index < parsedAnimation.ranges.length; index++) {
  3932. data = parsedAnimation.ranges[index];
  3933. animation.createRange(data.name, data.from, data.to);
  3934. }
  3935. }
  3936. return animation;
  3937. };
  3938. /**
  3939. * Appends the serialized animations from the source animations
  3940. * @param source Source containing the animations
  3941. * @param destination Target to store the animations
  3942. */
  3943. Animation.AppendSerializedAnimations = function (source, destination) {
  3944. _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].AppendSerializedAnimations(source, destination);
  3945. };
  3946. /**
  3947. * Use matrix interpolation instead of using direct key value when animating matrices
  3948. */
  3949. Animation.AllowMatricesInterpolation = false;
  3950. /**
  3951. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3952. */
  3953. Animation.AllowMatrixDecomposeForInterpolation = true;
  3954. // Statics
  3955. /**
  3956. * Float animation type
  3957. */
  3958. Animation._ANIMATIONTYPE_FLOAT = 0;
  3959. /**
  3960. * Vector3 animation type
  3961. */
  3962. Animation._ANIMATIONTYPE_VECTOR3 = 1;
  3963. /**
  3964. * Quaternion animation type
  3965. */
  3966. Animation._ANIMATIONTYPE_QUATERNION = 2;
  3967. /**
  3968. * Matrix animation type
  3969. */
  3970. Animation._ANIMATIONTYPE_MATRIX = 3;
  3971. /**
  3972. * Color3 animation type
  3973. */
  3974. Animation._ANIMATIONTYPE_COLOR3 = 4;
  3975. /**
  3976. * Vector2 animation type
  3977. */
  3978. Animation._ANIMATIONTYPE_VECTOR2 = 5;
  3979. /**
  3980. * Size animation type
  3981. */
  3982. Animation._ANIMATIONTYPE_SIZE = 6;
  3983. /**
  3984. * Relative Loop Mode
  3985. */
  3986. Animation._ANIMATIONLOOPMODE_RELATIVE = 0;
  3987. /**
  3988. * Cycle Loop Mode
  3989. */
  3990. Animation._ANIMATIONLOOPMODE_CYCLE = 1;
  3991. /**
  3992. * Constant Loop Mode
  3993. */
  3994. Animation._ANIMATIONLOOPMODE_CONSTANT = 2;
  3995. return Animation;
  3996. }());
  3997. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.Animation"] = Animation;
  3998. _node__WEBPACK_IMPORTED_MODULE_6__["Node"]._AnimationRangeFactory = function (name, from, to) { return new _animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to); };
  3999. /***/ }),
  4000. /***/ "./Animations/animationEvent.ts":
  4001. /*!**************************************!*\
  4002. !*** ./Animations/animationEvent.ts ***!
  4003. \**************************************/
  4004. /*! exports provided: AnimationEvent */
  4005. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4006. "use strict";
  4007. __webpack_require__.r(__webpack_exports__);
  4008. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return AnimationEvent; });
  4009. /**
  4010. * Composed of a frame, and an action function
  4011. */
  4012. var AnimationEvent = /** @class */ (function () {
  4013. /**
  4014. * Initializes the animation event
  4015. * @param frame The frame for which the event is triggered
  4016. * @param action The event to perform when triggered
  4017. * @param onlyOnce Specifies if the event should be triggered only once
  4018. */
  4019. function AnimationEvent(
  4020. /** The frame for which the event is triggered **/
  4021. frame,
  4022. /** The event to perform when triggered **/
  4023. action,
  4024. /** Specifies if the event should be triggered only once**/
  4025. onlyOnce) {
  4026. this.frame = frame;
  4027. this.action = action;
  4028. this.onlyOnce = onlyOnce;
  4029. /**
  4030. * Specifies if the animation event is done
  4031. */
  4032. this.isDone = false;
  4033. }
  4034. /** @hidden */
  4035. AnimationEvent.prototype._clone = function () {
  4036. return new AnimationEvent(this.frame, this.action, this.onlyOnce);
  4037. };
  4038. return AnimationEvent;
  4039. }());
  4040. /***/ }),
  4041. /***/ "./Animations/animationGroup.ts":
  4042. /*!**************************************!*\
  4043. !*** ./Animations/animationGroup.ts ***!
  4044. \**************************************/
  4045. /*! exports provided: TargetedAnimation, AnimationGroup */
  4046. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4047. "use strict";
  4048. __webpack_require__.r(__webpack_exports__);
  4049. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return TargetedAnimation; });
  4050. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return AnimationGroup; });
  4051. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  4052. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  4053. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  4054. /**
  4055. * This class defines the direct association between an animation and a target
  4056. */
  4057. var TargetedAnimation = /** @class */ (function () {
  4058. function TargetedAnimation() {
  4059. }
  4060. return TargetedAnimation;
  4061. }());
  4062. /**
  4063. * Use this class to create coordinated animations on multiple targets
  4064. */
  4065. var AnimationGroup = /** @class */ (function () {
  4066. /**
  4067. * Instantiates a new Animation Group.
  4068. * This helps managing several animations at once.
  4069. * @see http://doc.babylonjs.com/how_to/group
  4070. * @param name Defines the name of the group
  4071. * @param scene Defines the scene the group belongs to
  4072. */
  4073. function AnimationGroup(
  4074. /** The name of the animation group */
  4075. name, scene) {
  4076. if (scene === void 0) { scene = null; }
  4077. this.name = name;
  4078. this._targetedAnimations = new Array();
  4079. this._animatables = new Array();
  4080. this._from = Number.MAX_VALUE;
  4081. this._to = -Number.MAX_VALUE;
  4082. this._speedRatio = 1;
  4083. /**
  4084. * This observable will notify when one animation have ended
  4085. */
  4086. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4087. /**
  4088. * Observer raised when one animation loops
  4089. */
  4090. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4091. /**
  4092. * This observable will notify when all animations have ended.
  4093. */
  4094. this.onAnimationGroupEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4095. /**
  4096. * This observable will notify when all animations have paused.
  4097. */
  4098. this.onAnimationGroupPauseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4099. /**
  4100. * This observable will notify when all animations are playing.
  4101. */
  4102. this.onAnimationGroupPlayObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4103. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  4104. this.uniqueId = this._scene.getUniqueId();
  4105. this._scene.animationGroups.push(this);
  4106. }
  4107. Object.defineProperty(AnimationGroup.prototype, "from", {
  4108. /**
  4109. * Gets the first frame
  4110. */
  4111. get: function () {
  4112. return this._from;
  4113. },
  4114. enumerable: true,
  4115. configurable: true
  4116. });
  4117. Object.defineProperty(AnimationGroup.prototype, "to", {
  4118. /**
  4119. * Gets the last frame
  4120. */
  4121. get: function () {
  4122. return this._to;
  4123. },
  4124. enumerable: true,
  4125. configurable: true
  4126. });
  4127. Object.defineProperty(AnimationGroup.prototype, "isStarted", {
  4128. /**
  4129. * Define if the animations are started
  4130. */
  4131. get: function () {
  4132. return this._isStarted;
  4133. },
  4134. enumerable: true,
  4135. configurable: true
  4136. });
  4137. Object.defineProperty(AnimationGroup.prototype, "isPlaying", {
  4138. /**
  4139. * Gets a value indicating that the current group is playing
  4140. */
  4141. get: function () {
  4142. return this._isStarted && !this._isPaused;
  4143. },
  4144. enumerable: true,
  4145. configurable: true
  4146. });
  4147. Object.defineProperty(AnimationGroup.prototype, "speedRatio", {
  4148. /**
  4149. * Gets or sets the speed ratio to use for all animations
  4150. */
  4151. get: function () {
  4152. return this._speedRatio;
  4153. },
  4154. /**
  4155. * Gets or sets the speed ratio to use for all animations
  4156. */
  4157. set: function (value) {
  4158. if (this._speedRatio === value) {
  4159. return;
  4160. }
  4161. this._speedRatio = value;
  4162. for (var index = 0; index < this._animatables.length; index++) {
  4163. var animatable = this._animatables[index];
  4164. animatable.speedRatio = this._speedRatio;
  4165. }
  4166. },
  4167. enumerable: true,
  4168. configurable: true
  4169. });
  4170. Object.defineProperty(AnimationGroup.prototype, "targetedAnimations", {
  4171. /**
  4172. * Gets the targeted animations for this animation group
  4173. */
  4174. get: function () {
  4175. return this._targetedAnimations;
  4176. },
  4177. enumerable: true,
  4178. configurable: true
  4179. });
  4180. Object.defineProperty(AnimationGroup.prototype, "animatables", {
  4181. /**
  4182. * returning the list of animatables controlled by this animation group.
  4183. */
  4184. get: function () {
  4185. return this._animatables;
  4186. },
  4187. enumerable: true,
  4188. configurable: true
  4189. });
  4190. /**
  4191. * Add an animation (with its target) in the group
  4192. * @param animation defines the animation we want to add
  4193. * @param target defines the target of the animation
  4194. * @returns the TargetedAnimation object
  4195. */
  4196. AnimationGroup.prototype.addTargetedAnimation = function (animation, target) {
  4197. var targetedAnimation = {
  4198. animation: animation,
  4199. target: target
  4200. };
  4201. var keys = animation.getKeys();
  4202. if (this._from > keys[0].frame) {
  4203. this._from = keys[0].frame;
  4204. }
  4205. if (this._to < keys[keys.length - 1].frame) {
  4206. this._to = keys[keys.length - 1].frame;
  4207. }
  4208. this._targetedAnimations.push(targetedAnimation);
  4209. return targetedAnimation;
  4210. };
  4211. /**
  4212. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4213. * It can add constant keys at begin or end
  4214. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4215. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4216. * @returns the animation group
  4217. */
  4218. AnimationGroup.prototype.normalize = function (beginFrame, endFrame) {
  4219. if (beginFrame === void 0) { beginFrame = null; }
  4220. if (endFrame === void 0) { endFrame = null; }
  4221. if (beginFrame == null) {
  4222. beginFrame = this._from;
  4223. }
  4224. if (endFrame == null) {
  4225. endFrame = this._to;
  4226. }
  4227. for (var index = 0; index < this._targetedAnimations.length; index++) {
  4228. var targetedAnimation = this._targetedAnimations[index];
  4229. var keys = targetedAnimation.animation.getKeys();
  4230. var startKey = keys[0];
  4231. var endKey = keys[keys.length - 1];
  4232. if (startKey.frame > beginFrame) {
  4233. var newKey = {
  4234. frame: beginFrame,
  4235. value: startKey.value,
  4236. inTangent: startKey.inTangent,
  4237. outTangent: startKey.outTangent,
  4238. interpolation: startKey.interpolation
  4239. };
  4240. keys.splice(0, 0, newKey);
  4241. }
  4242. if (endKey.frame < endFrame) {
  4243. var newKey = {
  4244. frame: endFrame,
  4245. value: endKey.value,
  4246. inTangent: endKey.outTangent,
  4247. outTangent: endKey.outTangent,
  4248. interpolation: endKey.interpolation
  4249. };
  4250. keys.push(newKey);
  4251. }
  4252. }
  4253. this._from = beginFrame;
  4254. this._to = endFrame;
  4255. return this;
  4256. };
  4257. /**
  4258. * Start all animations on given targets
  4259. * @param loop defines if animations must loop
  4260. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4261. * @param from defines the from key (optional)
  4262. * @param to defines the to key (optional)
  4263. * @returns the current animation group
  4264. */
  4265. AnimationGroup.prototype.start = function (loop, speedRatio, from, to) {
  4266. var _this = this;
  4267. if (loop === void 0) { loop = false; }
  4268. if (speedRatio === void 0) { speedRatio = 1; }
  4269. if (this._isStarted || this._targetedAnimations.length === 0) {
  4270. return this;
  4271. }
  4272. var _loop_1 = function (targetedAnimation) {
  4273. var animatable = this_1._scene.beginDirectAnimation(targetedAnimation.target, [targetedAnimation.animation], from !== undefined ? from : this_1._from, to !== undefined ? to : this_1._to, loop, speedRatio);
  4274. animatable.onAnimationEnd = function () {
  4275. _this.onAnimationEndObservable.notifyObservers(targetedAnimation);
  4276. _this._checkAnimationGroupEnded(animatable);
  4277. };
  4278. animatable.onAnimationLoop = function () {
  4279. _this.onAnimationLoopObservable.notifyObservers(targetedAnimation);
  4280. };
  4281. this_1._animatables.push(animatable);
  4282. };
  4283. var this_1 = this;
  4284. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4285. var targetedAnimation = _a[_i];
  4286. _loop_1(targetedAnimation);
  4287. }
  4288. this._speedRatio = speedRatio;
  4289. if (from !== undefined && to !== undefined && from > to && this._speedRatio > 0) {
  4290. this._speedRatio = -speedRatio;
  4291. }
  4292. this._isStarted = true;
  4293. this._isPaused = false;
  4294. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4295. return this;
  4296. };
  4297. /**
  4298. * Pause all animations
  4299. * @returns the animation group
  4300. */
  4301. AnimationGroup.prototype.pause = function () {
  4302. if (!this._isStarted) {
  4303. return this;
  4304. }
  4305. this._isPaused = true;
  4306. for (var index = 0; index < this._animatables.length; index++) {
  4307. var animatable = this._animatables[index];
  4308. animatable.pause();
  4309. }
  4310. this.onAnimationGroupPauseObservable.notifyObservers(this);
  4311. return this;
  4312. };
  4313. /**
  4314. * Play all animations to initial state
  4315. * This function will start() the animations if they were not started or will restart() them if they were paused
  4316. * @param loop defines if animations must loop
  4317. * @returns the animation group
  4318. */
  4319. AnimationGroup.prototype.play = function (loop) {
  4320. // only if all animatables are ready and exist
  4321. if (this.isStarted && this._animatables.length === this._targetedAnimations.length) {
  4322. if (loop !== undefined) {
  4323. for (var index = 0; index < this._animatables.length; index++) {
  4324. var animatable = this._animatables[index];
  4325. animatable.loopAnimation = loop;
  4326. }
  4327. }
  4328. this.restart();
  4329. }
  4330. else {
  4331. this.stop();
  4332. this.start(loop, this._speedRatio);
  4333. }
  4334. this._isPaused = false;
  4335. return this;
  4336. };
  4337. /**
  4338. * Reset all animations to initial state
  4339. * @returns the animation group
  4340. */
  4341. AnimationGroup.prototype.reset = function () {
  4342. if (!this._isStarted) {
  4343. return this;
  4344. }
  4345. for (var index = 0; index < this._animatables.length; index++) {
  4346. var animatable = this._animatables[index];
  4347. animatable.reset();
  4348. }
  4349. return this;
  4350. };
  4351. /**
  4352. * Restart animations from key 0
  4353. * @returns the animation group
  4354. */
  4355. AnimationGroup.prototype.restart = function () {
  4356. if (!this._isStarted) {
  4357. return this;
  4358. }
  4359. for (var index = 0; index < this._animatables.length; index++) {
  4360. var animatable = this._animatables[index];
  4361. animatable.restart();
  4362. }
  4363. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4364. return this;
  4365. };
  4366. /**
  4367. * Stop all animations
  4368. * @returns the animation group
  4369. */
  4370. AnimationGroup.prototype.stop = function () {
  4371. if (!this._isStarted) {
  4372. return this;
  4373. }
  4374. var list = this._animatables.slice();
  4375. for (var index = 0; index < list.length; index++) {
  4376. list[index].stop();
  4377. }
  4378. this._isStarted = false;
  4379. return this;
  4380. };
  4381. /**
  4382. * Set animation weight for all animatables
  4383. * @param weight defines the weight to use
  4384. * @return the animationGroup
  4385. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4386. */
  4387. AnimationGroup.prototype.setWeightForAllAnimatables = function (weight) {
  4388. for (var index = 0; index < this._animatables.length; index++) {
  4389. var animatable = this._animatables[index];
  4390. animatable.weight = weight;
  4391. }
  4392. return this;
  4393. };
  4394. /**
  4395. * Synchronize and normalize all animatables with a source animatable
  4396. * @param root defines the root animatable to synchronize with
  4397. * @return the animationGroup
  4398. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4399. */
  4400. AnimationGroup.prototype.syncAllAnimationsWith = function (root) {
  4401. for (var index = 0; index < this._animatables.length; index++) {
  4402. var animatable = this._animatables[index];
  4403. animatable.syncWith(root);
  4404. }
  4405. return this;
  4406. };
  4407. /**
  4408. * Goes to a specific frame in this animation group
  4409. * @param frame the frame number to go to
  4410. * @return the animationGroup
  4411. */
  4412. AnimationGroup.prototype.goToFrame = function (frame) {
  4413. if (!this._isStarted) {
  4414. return this;
  4415. }
  4416. for (var index = 0; index < this._animatables.length; index++) {
  4417. var animatable = this._animatables[index];
  4418. animatable.goToFrame(frame);
  4419. }
  4420. return this;
  4421. };
  4422. /**
  4423. * Dispose all associated resources
  4424. */
  4425. AnimationGroup.prototype.dispose = function () {
  4426. this._targetedAnimations = [];
  4427. this._animatables = [];
  4428. var index = this._scene.animationGroups.indexOf(this);
  4429. if (index > -1) {
  4430. this._scene.animationGroups.splice(index, 1);
  4431. }
  4432. this.onAnimationEndObservable.clear();
  4433. this.onAnimationGroupEndObservable.clear();
  4434. this.onAnimationGroupPauseObservable.clear();
  4435. this.onAnimationGroupPlayObservable.clear();
  4436. this.onAnimationLoopObservable.clear();
  4437. };
  4438. AnimationGroup.prototype._checkAnimationGroupEnded = function (animatable) {
  4439. // animatable should be taken out of the array
  4440. var idx = this._animatables.indexOf(animatable);
  4441. if (idx > -1) {
  4442. this._animatables.splice(idx, 1);
  4443. }
  4444. // all animatables were removed? animation group ended!
  4445. if (this._animatables.length === 0) {
  4446. this._isStarted = false;
  4447. this.onAnimationGroupEndObservable.notifyObservers(this);
  4448. }
  4449. };
  4450. /**
  4451. * Clone the current animation group and returns a copy
  4452. * @param newName defines the name of the new group
  4453. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  4454. * @returns the new aniamtion group
  4455. */
  4456. AnimationGroup.prototype.clone = function (newName, targetConverter) {
  4457. var newGroup = new AnimationGroup(newName || this.name, this._scene);
  4458. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4459. var targetAnimation = _a[_i];
  4460. newGroup.addTargetedAnimation(targetAnimation.animation.clone(), targetConverter ? targetConverter(targetAnimation.target) : targetAnimation.target);
  4461. }
  4462. return newGroup;
  4463. };
  4464. // Statics
  4465. /**
  4466. * Returns a new AnimationGroup object parsed from the source provided.
  4467. * @param parsedAnimationGroup defines the source
  4468. * @param scene defines the scene that will receive the animationGroup
  4469. * @returns a new AnimationGroup
  4470. */
  4471. AnimationGroup.Parse = function (parsedAnimationGroup, scene) {
  4472. var animationGroup = new AnimationGroup(parsedAnimationGroup.name, scene);
  4473. for (var i = 0; i < parsedAnimationGroup.targetedAnimations.length; i++) {
  4474. var targetedAnimation = parsedAnimationGroup.targetedAnimations[i];
  4475. var animation = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].Parse(targetedAnimation.animation);
  4476. var id = targetedAnimation.targetId;
  4477. if (targetedAnimation.animation.property === "influence") { // morph target animation
  4478. var morphTarget = scene.getMorphTargetById(id);
  4479. if (morphTarget) {
  4480. animationGroup.addTargetedAnimation(animation, morphTarget);
  4481. }
  4482. }
  4483. else {
  4484. var targetNode = scene.getNodeByID(id);
  4485. if (targetNode != null) {
  4486. animationGroup.addTargetedAnimation(animation, targetNode);
  4487. }
  4488. }
  4489. }
  4490. if (parsedAnimationGroup.from !== null && parsedAnimationGroup.from !== null) {
  4491. animationGroup.normalize(parsedAnimationGroup.from, parsedAnimationGroup.to);
  4492. }
  4493. return animationGroup;
  4494. };
  4495. /**
  4496. * Returns the string "AnimationGroup"
  4497. * @returns "AnimationGroup"
  4498. */
  4499. AnimationGroup.prototype.getClassName = function () {
  4500. return "AnimationGroup";
  4501. };
  4502. /**
  4503. * Creates a detailled string about the object
  4504. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4505. * @returns a string representing the object
  4506. */
  4507. AnimationGroup.prototype.toString = function (fullDetails) {
  4508. var ret = "Name: " + this.name;
  4509. ret += ", type: " + this.getClassName();
  4510. if (fullDetails) {
  4511. ret += ", from: " + this._from;
  4512. ret += ", to: " + this._to;
  4513. ret += ", isStarted: " + this._isStarted;
  4514. ret += ", speedRatio: " + this._speedRatio;
  4515. ret += ", targetedAnimations length: " + this._targetedAnimations.length;
  4516. ret += ", animatables length: " + this._animatables;
  4517. }
  4518. return ret;
  4519. };
  4520. return AnimationGroup;
  4521. }());
  4522. /***/ }),
  4523. /***/ "./Animations/animationKey.ts":
  4524. /*!************************************!*\
  4525. !*** ./Animations/animationKey.ts ***!
  4526. \************************************/
  4527. /*! exports provided: AnimationKeyInterpolation */
  4528. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4529. "use strict";
  4530. __webpack_require__.r(__webpack_exports__);
  4531. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return AnimationKeyInterpolation; });
  4532. /**
  4533. * Enum for the animation key frame interpolation type
  4534. */
  4535. var AnimationKeyInterpolation;
  4536. (function (AnimationKeyInterpolation) {
  4537. /**
  4538. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4539. */
  4540. AnimationKeyInterpolation[AnimationKeyInterpolation["STEP"] = 1] = "STEP";
  4541. })(AnimationKeyInterpolation || (AnimationKeyInterpolation = {}));
  4542. /***/ }),
  4543. /***/ "./Animations/animationPropertiesOverride.ts":
  4544. /*!***************************************************!*\
  4545. !*** ./Animations/animationPropertiesOverride.ts ***!
  4546. \***************************************************/
  4547. /*! exports provided: AnimationPropertiesOverride */
  4548. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4549. "use strict";
  4550. __webpack_require__.r(__webpack_exports__);
  4551. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return AnimationPropertiesOverride; });
  4552. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  4553. /**
  4554. * Class used to override all child animations of a given target
  4555. */
  4556. var AnimationPropertiesOverride = /** @class */ (function () {
  4557. function AnimationPropertiesOverride() {
  4558. /**
  4559. * Gets or sets a value indicating if animation blending must be used
  4560. */
  4561. this.enableBlending = false;
  4562. /**
  4563. * Gets or sets the blending speed to use when enableBlending is true
  4564. */
  4565. this.blendingSpeed = 0.01;
  4566. /**
  4567. * Gets or sets the default loop mode to use
  4568. */
  4569. this.loopMode = _Animations_animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONLOOPMODE_CYCLE;
  4570. }
  4571. return AnimationPropertiesOverride;
  4572. }());
  4573. /***/ }),
  4574. /***/ "./Animations/animationRange.ts":
  4575. /*!**************************************!*\
  4576. !*** ./Animations/animationRange.ts ***!
  4577. \**************************************/
  4578. /*! exports provided: AnimationRange */
  4579. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4580. "use strict";
  4581. __webpack_require__.r(__webpack_exports__);
  4582. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return AnimationRange; });
  4583. /**
  4584. * Represents the range of an animation
  4585. */
  4586. var AnimationRange = /** @class */ (function () {
  4587. /**
  4588. * Initializes the range of an animation
  4589. * @param name The name of the animation range
  4590. * @param from The starting frame of the animation
  4591. * @param to The ending frame of the animation
  4592. */
  4593. function AnimationRange(
  4594. /**The name of the animation range**/
  4595. name,
  4596. /**The starting frame of the animation */
  4597. from,
  4598. /**The ending frame of the animation*/
  4599. to) {
  4600. this.name = name;
  4601. this.from = from;
  4602. this.to = to;
  4603. }
  4604. /**
  4605. * Makes a copy of the animation range
  4606. * @returns A copy of the animation range
  4607. */
  4608. AnimationRange.prototype.clone = function () {
  4609. return new AnimationRange(this.name, this.from, this.to);
  4610. };
  4611. return AnimationRange;
  4612. }());
  4613. /***/ }),
  4614. /***/ "./Animations/easing.ts":
  4615. /*!******************************!*\
  4616. !*** ./Animations/easing.ts ***!
  4617. \******************************/
  4618. /*! exports provided: EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase */
  4619. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4620. "use strict";
  4621. __webpack_require__.r(__webpack_exports__);
  4622. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return EasingFunction; });
  4623. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return CircleEase; });
  4624. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return BackEase; });
  4625. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return BounceEase; });
  4626. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return CubicEase; });
  4627. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return ElasticEase; });
  4628. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return ExponentialEase; });
  4629. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return PowerEase; });
  4630. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return QuadraticEase; });
  4631. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return QuarticEase; });
  4632. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return QuinticEase; });
  4633. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return SineEase; });
  4634. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return BezierCurveEase; });
  4635. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  4636. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  4637. /**
  4638. * Base class used for every default easing function.
  4639. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4640. */
  4641. var EasingFunction = /** @class */ (function () {
  4642. function EasingFunction() {
  4643. this._easingMode = EasingFunction.EASINGMODE_EASEIN;
  4644. }
  4645. /**
  4646. * Sets the easing mode of the current function.
  4647. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4648. */
  4649. EasingFunction.prototype.setEasingMode = function (easingMode) {
  4650. var n = Math.min(Math.max(easingMode, 0), 2);
  4651. this._easingMode = n;
  4652. };
  4653. /**
  4654. * Gets the current easing mode.
  4655. * @returns the easing mode
  4656. */
  4657. EasingFunction.prototype.getEasingMode = function () {
  4658. return this._easingMode;
  4659. };
  4660. /**
  4661. * @hidden
  4662. */
  4663. EasingFunction.prototype.easeInCore = function (gradient) {
  4664. throw new Error('You must implement this method');
  4665. };
  4666. /**
  4667. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4668. * of the easing function.
  4669. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4670. * @returns the corresponding value on the curve defined by the easing function
  4671. */
  4672. EasingFunction.prototype.ease = function (gradient) {
  4673. switch (this._easingMode) {
  4674. case EasingFunction.EASINGMODE_EASEIN:
  4675. return this.easeInCore(gradient);
  4676. case EasingFunction.EASINGMODE_EASEOUT:
  4677. return (1 - this.easeInCore(1 - gradient));
  4678. }
  4679. if (gradient >= 0.5) {
  4680. return (((1 - this.easeInCore((1 - gradient) * 2)) * 0.5) + 0.5);
  4681. }
  4682. return (this.easeInCore(gradient * 2) * 0.5);
  4683. };
  4684. /**
  4685. * Interpolation follows the mathematical formula associated with the easing function.
  4686. */
  4687. EasingFunction.EASINGMODE_EASEIN = 0;
  4688. /**
  4689. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4690. */
  4691. EasingFunction.EASINGMODE_EASEOUT = 1;
  4692. /**
  4693. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4694. */
  4695. EasingFunction.EASINGMODE_EASEINOUT = 2;
  4696. return EasingFunction;
  4697. }());
  4698. /**
  4699. * Easing function with a circle shape (see link below).
  4700. * @see https://easings.net/#easeInCirc
  4701. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4702. */
  4703. var CircleEase = /** @class */ (function (_super) {
  4704. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleEase, _super);
  4705. function CircleEase() {
  4706. return _super !== null && _super.apply(this, arguments) || this;
  4707. }
  4708. /** @hidden */
  4709. CircleEase.prototype.easeInCore = function (gradient) {
  4710. gradient = Math.max(0, Math.min(1, gradient));
  4711. return (1.0 - Math.sqrt(1.0 - (gradient * gradient)));
  4712. };
  4713. return CircleEase;
  4714. }(EasingFunction));
  4715. /**
  4716. * Easing function with a ease back shape (see link below).
  4717. * @see https://easings.net/#easeInBack
  4718. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4719. */
  4720. var BackEase = /** @class */ (function (_super) {
  4721. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackEase, _super);
  4722. /**
  4723. * Instantiates a back ease easing
  4724. * @see https://easings.net/#easeInBack
  4725. * @param amplitude Defines the amplitude of the function
  4726. */
  4727. function BackEase(
  4728. /** Defines the amplitude of the function */
  4729. amplitude) {
  4730. if (amplitude === void 0) { amplitude = 1; }
  4731. var _this = _super.call(this) || this;
  4732. _this.amplitude = amplitude;
  4733. return _this;
  4734. }
  4735. /** @hidden */
  4736. BackEase.prototype.easeInCore = function (gradient) {
  4737. var num = Math.max(0, this.amplitude);
  4738. return (Math.pow(gradient, 3.0) - ((gradient * num) * Math.sin(3.1415926535897931 * gradient)));
  4739. };
  4740. return BackEase;
  4741. }(EasingFunction));
  4742. /**
  4743. * Easing function with a bouncing shape (see link below).
  4744. * @see https://easings.net/#easeInBounce
  4745. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4746. */
  4747. var BounceEase = /** @class */ (function (_super) {
  4748. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BounceEase, _super);
  4749. /**
  4750. * Instantiates a bounce easing
  4751. * @see https://easings.net/#easeInBounce
  4752. * @param bounces Defines the number of bounces
  4753. * @param bounciness Defines the amplitude of the bounce
  4754. */
  4755. function BounceEase(
  4756. /** Defines the number of bounces */
  4757. bounces,
  4758. /** Defines the amplitude of the bounce */
  4759. bounciness) {
  4760. if (bounces === void 0) { bounces = 3; }
  4761. if (bounciness === void 0) { bounciness = 2; }
  4762. var _this = _super.call(this) || this;
  4763. _this.bounces = bounces;
  4764. _this.bounciness = bounciness;
  4765. return _this;
  4766. }
  4767. /** @hidden */
  4768. BounceEase.prototype.easeInCore = function (gradient) {
  4769. var y = Math.max(0.0, this.bounces);
  4770. var bounciness = this.bounciness;
  4771. if (bounciness <= 1.0) {
  4772. bounciness = 1.001;
  4773. }
  4774. var num9 = Math.pow(bounciness, y);
  4775. var num5 = 1.0 - bounciness;
  4776. var num4 = ((1.0 - num9) / num5) + (num9 * 0.5);
  4777. var num15 = gradient * num4;
  4778. var num65 = Math.log((-num15 * (1.0 - bounciness)) + 1.0) / Math.log(bounciness);
  4779. var num3 = Math.floor(num65);
  4780. var num13 = num3 + 1.0;
  4781. var num8 = (1.0 - Math.pow(bounciness, num3)) / (num5 * num4);
  4782. var num12 = (1.0 - Math.pow(bounciness, num13)) / (num5 * num4);
  4783. var num7 = (num8 + num12) * 0.5;
  4784. var num6 = gradient - num7;
  4785. var num2 = num7 - num8;
  4786. return (((-Math.pow(1.0 / bounciness, y - num3) / (num2 * num2)) * (num6 - num2)) * (num6 + num2));
  4787. };
  4788. return BounceEase;
  4789. }(EasingFunction));
  4790. /**
  4791. * Easing function with a power of 3 shape (see link below).
  4792. * @see https://easings.net/#easeInCubic
  4793. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4794. */
  4795. var CubicEase = /** @class */ (function (_super) {
  4796. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubicEase, _super);
  4797. function CubicEase() {
  4798. return _super !== null && _super.apply(this, arguments) || this;
  4799. }
  4800. /** @hidden */
  4801. CubicEase.prototype.easeInCore = function (gradient) {
  4802. return (gradient * gradient * gradient);
  4803. };
  4804. return CubicEase;
  4805. }(EasingFunction));
  4806. /**
  4807. * Easing function with an elastic shape (see link below).
  4808. * @see https://easings.net/#easeInElastic
  4809. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4810. */
  4811. var ElasticEase = /** @class */ (function (_super) {
  4812. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ElasticEase, _super);
  4813. /**
  4814. * Instantiates an elastic easing function
  4815. * @see https://easings.net/#easeInElastic
  4816. * @param oscillations Defines the number of oscillations
  4817. * @param springiness Defines the amplitude of the oscillations
  4818. */
  4819. function ElasticEase(
  4820. /** Defines the number of oscillations*/
  4821. oscillations,
  4822. /** Defines the amplitude of the oscillations*/
  4823. springiness) {
  4824. if (oscillations === void 0) { oscillations = 3; }
  4825. if (springiness === void 0) { springiness = 3; }
  4826. var _this = _super.call(this) || this;
  4827. _this.oscillations = oscillations;
  4828. _this.springiness = springiness;
  4829. return _this;
  4830. }
  4831. /** @hidden */
  4832. ElasticEase.prototype.easeInCore = function (gradient) {
  4833. var num2;
  4834. var num3 = Math.max(0.0, this.oscillations);
  4835. var num = Math.max(0.0, this.springiness);
  4836. if (num == 0) {
  4837. num2 = gradient;
  4838. }
  4839. else {
  4840. num2 = (Math.exp(num * gradient) - 1.0) / (Math.exp(num) - 1.0);
  4841. }
  4842. return (num2 * Math.sin(((6.2831853071795862 * num3) + 1.5707963267948966) * gradient));
  4843. };
  4844. return ElasticEase;
  4845. }(EasingFunction));
  4846. /**
  4847. * Easing function with an exponential shape (see link below).
  4848. * @see https://easings.net/#easeInExpo
  4849. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4850. */
  4851. var ExponentialEase = /** @class */ (function (_super) {
  4852. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExponentialEase, _super);
  4853. /**
  4854. * Instantiates an exponential easing function
  4855. * @see https://easings.net/#easeInExpo
  4856. * @param exponent Defines the exponent of the function
  4857. */
  4858. function ExponentialEase(
  4859. /** Defines the exponent of the function */
  4860. exponent) {
  4861. if (exponent === void 0) { exponent = 2; }
  4862. var _this = _super.call(this) || this;
  4863. _this.exponent = exponent;
  4864. return _this;
  4865. }
  4866. /** @hidden */
  4867. ExponentialEase.prototype.easeInCore = function (gradient) {
  4868. if (this.exponent <= 0) {
  4869. return gradient;
  4870. }
  4871. return ((Math.exp(this.exponent * gradient) - 1.0) / (Math.exp(this.exponent) - 1.0));
  4872. };
  4873. return ExponentialEase;
  4874. }(EasingFunction));
  4875. /**
  4876. * Easing function with a power shape (see link below).
  4877. * @see https://easings.net/#easeInQuad
  4878. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4879. */
  4880. var PowerEase = /** @class */ (function (_super) {
  4881. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PowerEase, _super);
  4882. /**
  4883. * Instantiates an power base easing function
  4884. * @see https://easings.net/#easeInQuad
  4885. * @param power Defines the power of the function
  4886. */
  4887. function PowerEase(
  4888. /** Defines the power of the function */
  4889. power) {
  4890. if (power === void 0) { power = 2; }
  4891. var _this = _super.call(this) || this;
  4892. _this.power = power;
  4893. return _this;
  4894. }
  4895. /** @hidden */
  4896. PowerEase.prototype.easeInCore = function (gradient) {
  4897. var y = Math.max(0.0, this.power);
  4898. return Math.pow(gradient, y);
  4899. };
  4900. return PowerEase;
  4901. }(EasingFunction));
  4902. /**
  4903. * Easing function with a power of 2 shape (see link below).
  4904. * @see https://easings.net/#easeInQuad
  4905. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4906. */
  4907. var QuadraticEase = /** @class */ (function (_super) {
  4908. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuadraticEase, _super);
  4909. function QuadraticEase() {
  4910. return _super !== null && _super.apply(this, arguments) || this;
  4911. }
  4912. /** @hidden */
  4913. QuadraticEase.prototype.easeInCore = function (gradient) {
  4914. return (gradient * gradient);
  4915. };
  4916. return QuadraticEase;
  4917. }(EasingFunction));
  4918. /**
  4919. * Easing function with a power of 4 shape (see link below).
  4920. * @see https://easings.net/#easeInQuart
  4921. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4922. */
  4923. var QuarticEase = /** @class */ (function (_super) {
  4924. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuarticEase, _super);
  4925. function QuarticEase() {
  4926. return _super !== null && _super.apply(this, arguments) || this;
  4927. }
  4928. /** @hidden */
  4929. QuarticEase.prototype.easeInCore = function (gradient) {
  4930. return (gradient * gradient * gradient * gradient);
  4931. };
  4932. return QuarticEase;
  4933. }(EasingFunction));
  4934. /**
  4935. * Easing function with a power of 5 shape (see link below).
  4936. * @see https://easings.net/#easeInQuint
  4937. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4938. */
  4939. var QuinticEase = /** @class */ (function (_super) {
  4940. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuinticEase, _super);
  4941. function QuinticEase() {
  4942. return _super !== null && _super.apply(this, arguments) || this;
  4943. }
  4944. /** @hidden */
  4945. QuinticEase.prototype.easeInCore = function (gradient) {
  4946. return (gradient * gradient * gradient * gradient * gradient);
  4947. };
  4948. return QuinticEase;
  4949. }(EasingFunction));
  4950. /**
  4951. * Easing function with a sin shape (see link below).
  4952. * @see https://easings.net/#easeInSine
  4953. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4954. */
  4955. var SineEase = /** @class */ (function (_super) {
  4956. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SineEase, _super);
  4957. function SineEase() {
  4958. return _super !== null && _super.apply(this, arguments) || this;
  4959. }
  4960. /** @hidden */
  4961. SineEase.prototype.easeInCore = function (gradient) {
  4962. return (1.0 - Math.sin(1.5707963267948966 * (1.0 - gradient)));
  4963. };
  4964. return SineEase;
  4965. }(EasingFunction));
  4966. /**
  4967. * Easing function with a bezier shape (see link below).
  4968. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4969. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4970. */
  4971. var BezierCurveEase = /** @class */ (function (_super) {
  4972. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BezierCurveEase, _super);
  4973. /**
  4974. * Instantiates a bezier function
  4975. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4976. * @param x1 Defines the x component of the start tangent in the bezier curve
  4977. * @param y1 Defines the y component of the start tangent in the bezier curve
  4978. * @param x2 Defines the x component of the end tangent in the bezier curve
  4979. * @param y2 Defines the y component of the end tangent in the bezier curve
  4980. */
  4981. function BezierCurveEase(
  4982. /** Defines the x component of the start tangent in the bezier curve */
  4983. x1,
  4984. /** Defines the y component of the start tangent in the bezier curve */
  4985. y1,
  4986. /** Defines the x component of the end tangent in the bezier curve */
  4987. x2,
  4988. /** Defines the y component of the end tangent in the bezier curve */
  4989. y2) {
  4990. if (x1 === void 0) { x1 = 0; }
  4991. if (y1 === void 0) { y1 = 0; }
  4992. if (x2 === void 0) { x2 = 1; }
  4993. if (y2 === void 0) { y2 = 1; }
  4994. var _this = _super.call(this) || this;
  4995. _this.x1 = x1;
  4996. _this.y1 = y1;
  4997. _this.x2 = x2;
  4998. _this.y2 = y2;
  4999. return _this;
  5000. }
  5001. /** @hidden */
  5002. BezierCurveEase.prototype.easeInCore = function (gradient) {
  5003. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"].Interpolate(gradient, this.x1, this.y1, this.x2, this.y2);
  5004. };
  5005. return BezierCurveEase;
  5006. }(EasingFunction));
  5007. /***/ }),
  5008. /***/ "./Animations/index.ts":
  5009. /*!*****************************!*\
  5010. !*** ./Animations/index.ts ***!
  5011. \*****************************/
  5012. /*! exports provided: Animatable, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange */
  5013. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5014. "use strict";
  5015. __webpack_require__.r(__webpack_exports__);
  5016. /* harmony import */ var _animatable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animatable */ "./Animations/animatable.ts");
  5017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _animatable__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  5018. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]; });
  5020. /* harmony import */ var _animationGroup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./animationGroup */ "./Animations/animationGroup.ts");
  5021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  5022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  5023. /* harmony import */ var _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./animationPropertiesOverride */ "./Animations/animationPropertiesOverride.ts");
  5024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__["AnimationPropertiesOverride"]; });
  5025. /* harmony import */ var _easing__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./easing */ "./Animations/easing.ts");
  5026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["EasingFunction"]; });
  5027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CircleEase"]; });
  5028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BackEase"]; });
  5029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BounceEase"]; });
  5030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CubicEase"]; });
  5031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ElasticEase"]; });
  5032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ExponentialEase"]; });
  5033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["PowerEase"]; });
  5034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuadraticEase"]; });
  5035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuarticEase"]; });
  5036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuinticEase"]; });
  5037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["SineEase"]; });
  5038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BezierCurveEase"]; });
  5039. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  5040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__["RuntimeAnimation"]; });
  5041. /* harmony import */ var _animationEvent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./animationEvent */ "./Animations/animationEvent.ts");
  5042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _animationEvent__WEBPACK_IMPORTED_MODULE_6__["AnimationEvent"]; });
  5043. /* empty/unused harmony star reexport *//* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  5044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _animationKey__WEBPACK_IMPORTED_MODULE_7__["AnimationKeyInterpolation"]; });
  5045. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  5046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _animationRange__WEBPACK_IMPORTED_MODULE_8__["AnimationRange"]; });
  5047. /***/ }),
  5048. /***/ "./Animations/runtimeAnimation.ts":
  5049. /*!****************************************!*\
  5050. !*** ./Animations/runtimeAnimation.ts ***!
  5051. \****************************************/
  5052. /*! exports provided: RuntimeAnimation */
  5053. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5054. "use strict";
  5055. __webpack_require__.r(__webpack_exports__);
  5056. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return RuntimeAnimation; });
  5057. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  5058. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5059. // Static values to help the garbage collector
  5060. // Quaternion
  5061. var _staticOffsetValueQuaternion = Object.freeze(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"](0, 0, 0, 0));
  5062. // Vector3
  5063. var _staticOffsetValueVector3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero());
  5064. // Vector2
  5065. var _staticOffsetValueVector2 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero());
  5066. // Size
  5067. var _staticOffsetValueSize = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Zero());
  5068. // Color3
  5069. var _staticOffsetValueColor3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Black());
  5070. /**
  5071. * Defines a runtime animation
  5072. */
  5073. var RuntimeAnimation = /** @class */ (function () {
  5074. /**
  5075. * Create a new RuntimeAnimation object
  5076. * @param target defines the target of the animation
  5077. * @param animation defines the source animation object
  5078. * @param scene defines the hosting scene
  5079. * @param host defines the initiating Animatable
  5080. */
  5081. function RuntimeAnimation(target, animation, scene, host) {
  5082. var _this = this;
  5083. this._events = new Array();
  5084. /**
  5085. * The current frame of the runtime animation
  5086. */
  5087. this._currentFrame = 0;
  5088. /**
  5089. * The original value of the runtime animation
  5090. */
  5091. this._originalValue = new Array();
  5092. /**
  5093. * The offsets cache of the runtime animation
  5094. */
  5095. this._offsetsCache = {};
  5096. /**
  5097. * The high limits cache of the runtime animation
  5098. */
  5099. this._highLimitsCache = {};
  5100. /**
  5101. * Specifies if the runtime animation has been stopped
  5102. */
  5103. this._stopped = false;
  5104. /**
  5105. * The blending factor of the runtime animation
  5106. */
  5107. this._blendingFactor = 0;
  5108. /**
  5109. * The target path of the runtime animation
  5110. */
  5111. this._targetPath = "";
  5112. /**
  5113. * The weight of the runtime animation
  5114. */
  5115. this._weight = 1.0;
  5116. /**
  5117. * The ratio offset of the runtime animation
  5118. */
  5119. this._ratioOffset = 0;
  5120. /**
  5121. * The previous delay of the runtime animation
  5122. */
  5123. this._previousDelay = 0;
  5124. /**
  5125. * The previous ratio of the runtime animation
  5126. */
  5127. this._previousRatio = 0;
  5128. this._animation = animation;
  5129. this._target = target;
  5130. this._scene = scene;
  5131. this._host = host;
  5132. animation._runtimeAnimations.push(this);
  5133. // Cloning events locally
  5134. var events = animation.getEvents();
  5135. if (events && events.length > 0) {
  5136. events.forEach(function (e) {
  5137. _this._events.push(e._clone());
  5138. });
  5139. }
  5140. }
  5141. Object.defineProperty(RuntimeAnimation.prototype, "currentFrame", {
  5142. /**
  5143. * Gets the current frame of the runtime animation
  5144. */
  5145. get: function () {
  5146. return this._currentFrame;
  5147. },
  5148. enumerable: true,
  5149. configurable: true
  5150. });
  5151. Object.defineProperty(RuntimeAnimation.prototype, "weight", {
  5152. /**
  5153. * Gets the weight of the runtime animation
  5154. */
  5155. get: function () {
  5156. return this._weight;
  5157. },
  5158. enumerable: true,
  5159. configurable: true
  5160. });
  5161. Object.defineProperty(RuntimeAnimation.prototype, "currentValue", {
  5162. /**
  5163. * Gets the current value of the runtime animation
  5164. */
  5165. get: function () {
  5166. return this._currentValue;
  5167. },
  5168. enumerable: true,
  5169. configurable: true
  5170. });
  5171. Object.defineProperty(RuntimeAnimation.prototype, "targetPath", {
  5172. /**
  5173. * Gets the target path of the runtime animation
  5174. */
  5175. get: function () {
  5176. return this._targetPath;
  5177. },
  5178. enumerable: true,
  5179. configurable: true
  5180. });
  5181. Object.defineProperty(RuntimeAnimation.prototype, "target", {
  5182. /**
  5183. * Gets the actual target of the runtime animation
  5184. */
  5185. get: function () {
  5186. return this._activeTarget;
  5187. },
  5188. enumerable: true,
  5189. configurable: true
  5190. });
  5191. Object.defineProperty(RuntimeAnimation.prototype, "animation", {
  5192. /**
  5193. * Gets the animation from the runtime animation
  5194. */
  5195. get: function () {
  5196. return this._animation;
  5197. },
  5198. enumerable: true,
  5199. configurable: true
  5200. });
  5201. /**
  5202. * Resets the runtime animation to the beginning
  5203. * @param restoreOriginal defines whether to restore the target property to the original value
  5204. */
  5205. RuntimeAnimation.prototype.reset = function (restoreOriginal) {
  5206. if (restoreOriginal === void 0) { restoreOriginal = false; }
  5207. if (restoreOriginal) {
  5208. if (this._target instanceof Array) {
  5209. var index = 0;
  5210. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5211. var target = _a[_i];
  5212. if (this._originalValue[index] !== undefined) {
  5213. this._setValue(target, this._originalValue[index], -1);
  5214. }
  5215. index++;
  5216. }
  5217. }
  5218. else {
  5219. if (this._originalValue[0] !== undefined) {
  5220. this._setValue(this._target, this._originalValue[0], -1);
  5221. }
  5222. }
  5223. }
  5224. this._offsetsCache = {};
  5225. this._highLimitsCache = {};
  5226. this._currentFrame = 0;
  5227. this._blendingFactor = 0;
  5228. this._originalValue = new Array();
  5229. // Events
  5230. for (var index = 0; index < this._events.length; index++) {
  5231. this._events[index].isDone = false;
  5232. }
  5233. };
  5234. /**
  5235. * Specifies if the runtime animation is stopped
  5236. * @returns Boolean specifying if the runtime animation is stopped
  5237. */
  5238. RuntimeAnimation.prototype.isStopped = function () {
  5239. return this._stopped;
  5240. };
  5241. /**
  5242. * Disposes of the runtime animation
  5243. */
  5244. RuntimeAnimation.prototype.dispose = function () {
  5245. var index = this._animation.runtimeAnimations.indexOf(this);
  5246. if (index > -1) {
  5247. this._animation.runtimeAnimations.splice(index, 1);
  5248. }
  5249. };
  5250. /**
  5251. * Interpolates the animation from the current frame
  5252. * @param currentFrame The frame to interpolate the animation to
  5253. * @param repeatCount The number of times that the animation should loop
  5254. * @param loopMode The type of looping mode to use
  5255. * @param offsetValue Animation offset value
  5256. * @param highLimitValue The high limit value
  5257. * @returns The interpolated value
  5258. */
  5259. RuntimeAnimation.prototype._interpolate = function (currentFrame, repeatCount, loopMode, offsetValue, highLimitValue) {
  5260. this._currentFrame = currentFrame;
  5261. if (this._animation.dataType === _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_MATRIX && !this._workValue) {
  5262. this._workValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Zero();
  5263. }
  5264. return this._animation._interpolate(currentFrame, repeatCount, this._workValue, loopMode, offsetValue, highLimitValue);
  5265. };
  5266. /**
  5267. * Apply the interpolated value to the target
  5268. * @param currentValue defines the value computed by the animation
  5269. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5270. */
  5271. RuntimeAnimation.prototype.setValue = function (currentValue, weight) {
  5272. if (weight === void 0) { weight = 1.0; }
  5273. if (this._target instanceof Array) {
  5274. var index = 0;
  5275. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5276. var target = _a[_i];
  5277. this._setValue(target, currentValue, weight, index);
  5278. index++;
  5279. }
  5280. }
  5281. else {
  5282. this._setValue(this._target, currentValue, weight);
  5283. }
  5284. };
  5285. RuntimeAnimation.prototype._setValue = function (target, currentValue, weight, targetIndex) {
  5286. if (targetIndex === void 0) { targetIndex = 0; }
  5287. // Set value
  5288. var path;
  5289. var destination;
  5290. var targetPropertyPath = this._animation.targetPropertyPath;
  5291. if (targetPropertyPath.length > 1) {
  5292. var property = target[targetPropertyPath[0]];
  5293. for (var index = 1; index < targetPropertyPath.length - 1; index++) {
  5294. property = property[targetPropertyPath[index]];
  5295. }
  5296. path = targetPropertyPath[targetPropertyPath.length - 1];
  5297. destination = property;
  5298. }
  5299. else {
  5300. path = targetPropertyPath[0];
  5301. destination = target;
  5302. }
  5303. this._targetPath = path;
  5304. this._activeTarget = destination;
  5305. this._weight = weight;
  5306. if (this._originalValue[targetIndex] === undefined) {
  5307. var originalValue = void 0;
  5308. if (destination.getRestPose && path === "_matrix") { // For bones
  5309. originalValue = destination.getRestPose();
  5310. }
  5311. else {
  5312. originalValue = destination[path];
  5313. }
  5314. if (originalValue && originalValue.clone) {
  5315. this._originalValue[targetIndex] = originalValue.clone();
  5316. }
  5317. else {
  5318. this._originalValue[targetIndex] = originalValue;
  5319. }
  5320. }
  5321. // Blending
  5322. var enableBlending = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.enableBlending : this._animation.enableBlending;
  5323. if (enableBlending && this._blendingFactor <= 1.0) {
  5324. if (!this._originalBlendValue) {
  5325. var originalValue = destination[path];
  5326. if (originalValue.clone) {
  5327. this._originalBlendValue = originalValue.clone();
  5328. }
  5329. else {
  5330. this._originalBlendValue = originalValue;
  5331. }
  5332. }
  5333. if (this._originalBlendValue.m) { // Matrix
  5334. if (_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].AllowMatrixDecomposeForInterpolation) {
  5335. if (this._currentValue) {
  5336. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5337. }
  5338. else {
  5339. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5340. }
  5341. }
  5342. else {
  5343. if (this._currentValue) {
  5344. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5345. }
  5346. else {
  5347. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5348. }
  5349. }
  5350. }
  5351. else {
  5352. this._currentValue = _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]._UniversalLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5353. }
  5354. var blendingSpeed = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
  5355. this._blendingFactor += blendingSpeed;
  5356. }
  5357. else {
  5358. this._currentValue = currentValue;
  5359. }
  5360. if (weight !== -1.0) {
  5361. this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[targetIndex]);
  5362. }
  5363. else {
  5364. destination[path] = this._currentValue;
  5365. }
  5366. if (target.markAsDirty) {
  5367. target.markAsDirty(this._animation.targetProperty);
  5368. }
  5369. };
  5370. /**
  5371. * Gets the loop pmode of the runtime animation
  5372. * @returns Loop Mode
  5373. */
  5374. RuntimeAnimation.prototype._getCorrectLoopMode = function () {
  5375. if (this._target && this._target.animationPropertiesOverride) {
  5376. return this._target.animationPropertiesOverride.loopMode;
  5377. }
  5378. return this._animation.loopMode;
  5379. };
  5380. /**
  5381. * Move the current animation to a given frame
  5382. * @param frame defines the frame to move to
  5383. */
  5384. RuntimeAnimation.prototype.goToFrame = function (frame) {
  5385. var keys = this._animation.getKeys();
  5386. if (frame < keys[0].frame) {
  5387. frame = keys[0].frame;
  5388. }
  5389. else if (frame > keys[keys.length - 1].frame) {
  5390. frame = keys[keys.length - 1].frame;
  5391. }
  5392. var currentValue = this._interpolate(frame, 0, this._getCorrectLoopMode());
  5393. this.setValue(currentValue, -1);
  5394. };
  5395. /**
  5396. * @hidden Internal use only
  5397. */
  5398. RuntimeAnimation.prototype._prepareForSpeedRatioChange = function (newSpeedRatio) {
  5399. var newRatio = this._previousDelay * (this._animation.framePerSecond * newSpeedRatio) / 1000.0;
  5400. this._ratioOffset = this._previousRatio - newRatio;
  5401. };
  5402. /**
  5403. * Execute the current animation
  5404. * @param delay defines the delay to add to the current frame
  5405. * @param from defines the lower bound of the animation range
  5406. * @param to defines the upper bound of the animation range
  5407. * @param loop defines if the current animation must loop
  5408. * @param speedRatio defines the current speed ratio
  5409. * @param weight defines the weight of the animation (default is -1 so no weight)
  5410. * @param onLoop optional callback called when animation loops
  5411. * @returns a boolean indicating if the animation is running
  5412. */
  5413. RuntimeAnimation.prototype.animate = function (delay, from, to, loop, speedRatio, weight, onLoop) {
  5414. if (weight === void 0) { weight = -1.0; }
  5415. var targetPropertyPath = this._animation.targetPropertyPath;
  5416. if (!targetPropertyPath || targetPropertyPath.length < 1) {
  5417. this._stopped = true;
  5418. return false;
  5419. }
  5420. var returnValue = true;
  5421. var keys = this._animation.getKeys();
  5422. var min = keys[0].frame;
  5423. var max = keys[keys.length - 1].frame;
  5424. // Add a start key at frame 0 if missing
  5425. if (min !== 0) {
  5426. var newKey = { frame: 0, value: keys[0].value };
  5427. keys.splice(0, 0, newKey);
  5428. }
  5429. // Check limits
  5430. if (from < min || from > max) {
  5431. from = min;
  5432. }
  5433. if (to < min || to > max) {
  5434. to = max;
  5435. }
  5436. var range = to - from;
  5437. var offsetValue;
  5438. // Compute ratio which represents the frame delta between from and to
  5439. var ratio = (delay * (this._animation.framePerSecond * speedRatio) / 1000.0) + this._ratioOffset;
  5440. var highLimitValue = 0;
  5441. this._previousDelay = delay;
  5442. this._previousRatio = ratio;
  5443. if ((to > from && ratio >= range) && !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 if ((from > to && ratio <= range) && !loop) {
  5448. returnValue = false;
  5449. highLimitValue = this._animation._getKeyValue(keys[0].value);
  5450. }
  5451. else {
  5452. // Get max value if required
  5453. if (this._getCorrectLoopMode() !== _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE) {
  5454. var keyOffset = to.toString() + from.toString();
  5455. if (!this._offsetsCache[keyOffset]) {
  5456. var fromValue = this._interpolate(from, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5457. var toValue = this._interpolate(to, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5458. switch (this._animation.dataType) {
  5459. // Float
  5460. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5461. this._offsetsCache[keyOffset] = toValue - fromValue;
  5462. break;
  5463. // Quaternion
  5464. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5465. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5466. break;
  5467. // Vector3
  5468. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5469. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5470. // Vector2
  5471. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5472. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5473. // Size
  5474. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5475. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5476. // Color3
  5477. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5478. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5479. default:
  5480. break;
  5481. }
  5482. this._highLimitsCache[keyOffset] = toValue;
  5483. }
  5484. highLimitValue = this._highLimitsCache[keyOffset];
  5485. offsetValue = this._offsetsCache[keyOffset];
  5486. }
  5487. }
  5488. if (offsetValue === undefined) {
  5489. switch (this._animation.dataType) {
  5490. // Float
  5491. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5492. offsetValue = 0;
  5493. break;
  5494. // Quaternion
  5495. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5496. offsetValue = _staticOffsetValueQuaternion;
  5497. break;
  5498. // Vector3
  5499. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5500. offsetValue = _staticOffsetValueVector3;
  5501. break;
  5502. // Vector2
  5503. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5504. offsetValue = _staticOffsetValueVector2;
  5505. break;
  5506. // Size
  5507. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5508. offsetValue = _staticOffsetValueSize;
  5509. break;
  5510. // Color3
  5511. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5512. offsetValue = _staticOffsetValueColor3;
  5513. }
  5514. }
  5515. // Compute value
  5516. var currentFrame = (returnValue && range !== 0) ? from + ratio % range : to;
  5517. // Need to normalize?
  5518. if (this._host && this._host.syncRoot) {
  5519. var syncRoot = this._host.syncRoot;
  5520. var hostNormalizedFrame = (syncRoot.masterFrame - syncRoot.fromFrame) / (syncRoot.toFrame - syncRoot.fromFrame);
  5521. currentFrame = from + (to - from) * hostNormalizedFrame;
  5522. }
  5523. // Reset events if looping
  5524. var events = this._events;
  5525. if (range > 0 && this.currentFrame > currentFrame ||
  5526. range < 0 && this.currentFrame < currentFrame) {
  5527. if (onLoop) {
  5528. onLoop();
  5529. }
  5530. // Need to reset animation events
  5531. for (var index = 0; index < events.length; index++) {
  5532. if (!events[index].onlyOnce) {
  5533. // reset event, the animation is looping
  5534. events[index].isDone = false;
  5535. }
  5536. }
  5537. }
  5538. var repeatCount = range === 0 ? 0 : (ratio / range) >> 0;
  5539. var currentValue = this._interpolate(currentFrame, repeatCount, this._getCorrectLoopMode(), offsetValue, highLimitValue);
  5540. // Set value
  5541. this.setValue(currentValue, weight);
  5542. // Check events
  5543. for (var index = 0; index < events.length; index++) {
  5544. // Make sure current frame has passed event frame and that event frame is within the current range
  5545. // Also, handle both forward and reverse animations
  5546. if ((range > 0 && currentFrame >= events[index].frame && events[index].frame >= from) ||
  5547. (range < 0 && currentFrame <= events[index].frame && events[index].frame <= from)) {
  5548. var event = events[index];
  5549. if (!event.isDone) {
  5550. // If event should be done only once, remove it.
  5551. if (event.onlyOnce) {
  5552. events.splice(index, 1);
  5553. index--;
  5554. }
  5555. event.isDone = true;
  5556. event.action(currentFrame);
  5557. } // Don't do anything if the event has already be done.
  5558. }
  5559. }
  5560. if (!returnValue) {
  5561. this._stopped = true;
  5562. }
  5563. return returnValue;
  5564. };
  5565. return RuntimeAnimation;
  5566. }());
  5567. /***/ }),
  5568. /***/ "./Audio/analyser.ts":
  5569. /*!***************************!*\
  5570. !*** ./Audio/analyser.ts ***!
  5571. \***************************/
  5572. /*! exports provided: Analyser */
  5573. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5574. "use strict";
  5575. __webpack_require__.r(__webpack_exports__);
  5576. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return Analyser; });
  5577. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5578. /**
  5579. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5580. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5581. */
  5582. var Analyser = /** @class */ (function () {
  5583. /**
  5584. * Creates a new analyser
  5585. * @param scene defines hosting scene
  5586. */
  5587. function Analyser(scene) {
  5588. /**
  5589. * Gets or sets the smoothing
  5590. * @ignorenaming
  5591. */
  5592. this.SMOOTHING = 0.75;
  5593. /**
  5594. * Gets or sets the FFT table size
  5595. * @ignorenaming
  5596. */
  5597. this.FFT_SIZE = 512;
  5598. /**
  5599. * Gets or sets the bar graph amplitude
  5600. * @ignorenaming
  5601. */
  5602. this.BARGRAPHAMPLITUDE = 256;
  5603. /**
  5604. * Gets or sets the position of the debug canvas
  5605. * @ignorenaming
  5606. */
  5607. this.DEBUGCANVASPOS = { x: 20, y: 20 };
  5608. /**
  5609. * Gets or sets the debug canvas size
  5610. * @ignorenaming
  5611. */
  5612. this.DEBUGCANVASSIZE = { width: 320, height: 200 };
  5613. this._scene = scene;
  5614. this._audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine;
  5615. if (this._audioEngine.canUseWebAudio && this._audioEngine.audioContext) {
  5616. this._webAudioAnalyser = this._audioEngine.audioContext.createAnalyser();
  5617. this._webAudioAnalyser.minDecibels = -140;
  5618. this._webAudioAnalyser.maxDecibels = 0;
  5619. this._byteFreqs = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5620. this._byteTime = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5621. this._floatFreqs = new Float32Array(this._webAudioAnalyser.frequencyBinCount);
  5622. }
  5623. }
  5624. /**
  5625. * Get the number of data values you will have to play with for the visualization
  5626. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5627. * @returns a number
  5628. */
  5629. Analyser.prototype.getFrequencyBinCount = function () {
  5630. if (this._audioEngine.canUseWebAudio) {
  5631. return this._webAudioAnalyser.frequencyBinCount;
  5632. }
  5633. else {
  5634. return 0;
  5635. }
  5636. };
  5637. /**
  5638. * Gets the current frequency data as a byte array
  5639. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5640. * @returns a Uint8Array
  5641. */
  5642. Analyser.prototype.getByteFrequencyData = function () {
  5643. if (this._audioEngine.canUseWebAudio) {
  5644. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5645. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5646. this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs);
  5647. }
  5648. return this._byteFreqs;
  5649. };
  5650. /**
  5651. * Gets the current waveform as a byte array
  5652. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5653. * @returns a Uint8Array
  5654. */
  5655. Analyser.prototype.getByteTimeDomainData = function () {
  5656. if (this._audioEngine.canUseWebAudio) {
  5657. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5658. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5659. this._webAudioAnalyser.getByteTimeDomainData(this._byteTime);
  5660. }
  5661. return this._byteTime;
  5662. };
  5663. /**
  5664. * Gets the current frequency data as a float array
  5665. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5666. * @returns a Float32Array
  5667. */
  5668. Analyser.prototype.getFloatFrequencyData = function () {
  5669. if (this._audioEngine.canUseWebAudio) {
  5670. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5671. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5672. this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs);
  5673. }
  5674. return this._floatFreqs;
  5675. };
  5676. /**
  5677. * Renders the debug canvas
  5678. */
  5679. Analyser.prototype.drawDebugCanvas = function () {
  5680. var _this = this;
  5681. if (this._audioEngine.canUseWebAudio) {
  5682. if (!this._debugCanvas) {
  5683. this._debugCanvas = document.createElement("canvas");
  5684. this._debugCanvas.width = this.DEBUGCANVASSIZE.width;
  5685. this._debugCanvas.height = this.DEBUGCANVASSIZE.height;
  5686. this._debugCanvas.style.position = "absolute";
  5687. this._debugCanvas.style.top = this.DEBUGCANVASPOS.y + "px";
  5688. this._debugCanvas.style.left = this.DEBUGCANVASPOS.x + "px";
  5689. this._debugCanvasContext = this._debugCanvas.getContext("2d");
  5690. document.body.appendChild(this._debugCanvas);
  5691. this._registerFunc = function () {
  5692. _this.drawDebugCanvas();
  5693. };
  5694. this._scene.registerBeforeRender(this._registerFunc);
  5695. }
  5696. if (this._registerFunc && this._debugCanvasContext) {
  5697. var workingArray = this.getByteFrequencyData();
  5698. this._debugCanvasContext.fillStyle = 'rgb(0, 0, 0)';
  5699. this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height);
  5700. // Draw the frequency domain chart.
  5701. for (var i = 0; i < this.getFrequencyBinCount(); i++) {
  5702. var value = workingArray[i];
  5703. var percent = value / this.BARGRAPHAMPLITUDE;
  5704. var height = this.DEBUGCANVASSIZE.height * percent;
  5705. var offset = this.DEBUGCANVASSIZE.height - height - 1;
  5706. var barWidth = this.DEBUGCANVASSIZE.width / this.getFrequencyBinCount();
  5707. var hue = i / this.getFrequencyBinCount() * 360;
  5708. this._debugCanvasContext.fillStyle = 'hsl(' + hue + ', 100%, 50%)';
  5709. this._debugCanvasContext.fillRect(i * barWidth, offset, barWidth, height);
  5710. }
  5711. }
  5712. }
  5713. };
  5714. /**
  5715. * Stops rendering the debug canvas and removes it
  5716. */
  5717. Analyser.prototype.stopDebugCanvas = function () {
  5718. if (this._debugCanvas) {
  5719. if (this._registerFunc) {
  5720. this._scene.unregisterBeforeRender(this._registerFunc);
  5721. this._registerFunc = null;
  5722. }
  5723. document.body.removeChild(this._debugCanvas);
  5724. this._debugCanvas = null;
  5725. this._debugCanvasContext = null;
  5726. }
  5727. };
  5728. /**
  5729. * Connects two audio nodes
  5730. * @param inputAudioNode defines first node to connect
  5731. * @param outputAudioNode defines second node to connect
  5732. */
  5733. Analyser.prototype.connectAudioNodes = function (inputAudioNode, outputAudioNode) {
  5734. if (this._audioEngine.canUseWebAudio) {
  5735. inputAudioNode.connect(this._webAudioAnalyser);
  5736. this._webAudioAnalyser.connect(outputAudioNode);
  5737. }
  5738. };
  5739. /**
  5740. * Releases all associated resources
  5741. */
  5742. Analyser.prototype.dispose = function () {
  5743. if (this._audioEngine.canUseWebAudio) {
  5744. this._webAudioAnalyser.disconnect();
  5745. }
  5746. };
  5747. return Analyser;
  5748. }());
  5749. /***/ }),
  5750. /***/ "./Audio/audioEngine.ts":
  5751. /*!******************************!*\
  5752. !*** ./Audio/audioEngine.ts ***!
  5753. \******************************/
  5754. /*! exports provided: AudioEngine */
  5755. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5756. "use strict";
  5757. __webpack_require__.r(__webpack_exports__);
  5758. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return AudioEngine; });
  5759. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  5760. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  5761. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5762. // Sets the default audio engine to Babylon.js
  5763. _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].AudioEngineFactory = function (hostElement) { return new AudioEngine(hostElement); };
  5764. /**
  5765. * This represents the default audio engine used in babylon.
  5766. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5767. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5768. */
  5769. var AudioEngine = /** @class */ (function () {
  5770. /**
  5771. * Instantiates a new audio engine.
  5772. *
  5773. * There should be only one per page as some browsers restrict the number
  5774. * of audio contexts you can create.
  5775. * @param hostElement defines the host element where to display the mute icon if necessary
  5776. */
  5777. function AudioEngine(hostElement) {
  5778. if (hostElement === void 0) { hostElement = null; }
  5779. var _this = this;
  5780. this._audioContext = null;
  5781. this._audioContextInitialized = false;
  5782. this._muteButton = null;
  5783. /**
  5784. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5785. */
  5786. this.canUseWebAudio = false;
  5787. /**
  5788. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5789. * @ignoreNaming
  5790. */
  5791. this.WarnedWebAudioUnsupported = false;
  5792. /**
  5793. * Gets whether or not mp3 are supported by your browser.
  5794. */
  5795. this.isMP3supported = false;
  5796. /**
  5797. * Gets whether or not ogg are supported by your browser.
  5798. */
  5799. this.isOGGsupported = false;
  5800. /**
  5801. * Gets whether audio has been unlocked on the device.
  5802. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5803. * a user interaction has happened.
  5804. */
  5805. this.unlocked = true;
  5806. /**
  5807. * Defines if the audio engine relies on a custom unlocked button.
  5808. * In this case, the embedded button will not be displayed.
  5809. */
  5810. this.useCustomUnlockedButton = false;
  5811. /**
  5812. * Event raised when audio has been unlocked on the browser.
  5813. */
  5814. this.onAudioUnlockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5815. /**
  5816. * Event raised when audio has been locked on the browser.
  5817. */
  5818. this.onAudioLockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5819. this._tryToRun = false;
  5820. this._onResize = function () {
  5821. _this._moveButtonToTopLeft();
  5822. };
  5823. if (typeof window.AudioContext !== 'undefined' || typeof window.webkitAudioContext !== 'undefined') {
  5824. window.AudioContext = window.AudioContext || window.webkitAudioContext;
  5825. this.canUseWebAudio = true;
  5826. }
  5827. var audioElem = document.createElement('audio');
  5828. this._hostElement = hostElement;
  5829. try {
  5830. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, '')) {
  5831. this.isMP3supported = true;
  5832. }
  5833. }
  5834. catch (e) {
  5835. // protect error during capability check.
  5836. }
  5837. try {
  5838. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) {
  5839. this.isOGGsupported = true;
  5840. }
  5841. }
  5842. catch (e) {
  5843. // protect error during capability check.
  5844. }
  5845. }
  5846. Object.defineProperty(AudioEngine.prototype, "audioContext", {
  5847. /**
  5848. * Gets the current AudioContext if available.
  5849. */
  5850. get: function () {
  5851. if (!this._audioContextInitialized) {
  5852. this._initializeAudioContext();
  5853. }
  5854. else {
  5855. if (!this.unlocked && !this._muteButton) {
  5856. this._displayMuteButton();
  5857. }
  5858. }
  5859. return this._audioContext;
  5860. },
  5861. enumerable: true,
  5862. configurable: true
  5863. });
  5864. /**
  5865. * Flags the audio engine in Locked state.
  5866. * This happens due to new browser policies preventing audio to autoplay.
  5867. */
  5868. AudioEngine.prototype.lock = function () {
  5869. this._triggerSuspendedState();
  5870. };
  5871. /**
  5872. * Unlocks the audio engine once a user action has been done on the dom.
  5873. * This is helpful to resume play once browser policies have been satisfied.
  5874. */
  5875. AudioEngine.prototype.unlock = function () {
  5876. this._triggerRunningState();
  5877. };
  5878. AudioEngine.prototype._resumeAudioContext = function () {
  5879. var result;
  5880. if (this._audioContext.resume) {
  5881. result = this._audioContext.resume();
  5882. }
  5883. return result || Promise.resolve();
  5884. };
  5885. AudioEngine.prototype._initializeAudioContext = function () {
  5886. try {
  5887. if (this.canUseWebAudio) {
  5888. this._audioContext = new AudioContext();
  5889. // create a global volume gain node
  5890. this.masterGain = this._audioContext.createGain();
  5891. this.masterGain.gain.value = 1;
  5892. this.masterGain.connect(this._audioContext.destination);
  5893. this._audioContextInitialized = true;
  5894. if (this._audioContext.state === "running") {
  5895. // Do not wait for the promise to unlock.
  5896. this._triggerRunningState();
  5897. }
  5898. }
  5899. }
  5900. catch (e) {
  5901. this.canUseWebAudio = false;
  5902. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Web Audio: " + e.message);
  5903. }
  5904. };
  5905. AudioEngine.prototype._triggerRunningState = function () {
  5906. var _this = this;
  5907. if (this._tryToRun) {
  5908. return;
  5909. }
  5910. this._tryToRun = true;
  5911. this._resumeAudioContext()
  5912. .then(function () {
  5913. _this._tryToRun = false;
  5914. if (_this._muteButton) {
  5915. _this._hideMuteButton();
  5916. }
  5917. }).catch(function () {
  5918. _this._tryToRun = false;
  5919. _this.unlocked = false;
  5920. });
  5921. // Notify users that the audio stack is unlocked/unmuted
  5922. this.unlocked = true;
  5923. this.onAudioUnlockedObservable.notifyObservers(this);
  5924. };
  5925. AudioEngine.prototype._triggerSuspendedState = function () {
  5926. this.unlocked = false;
  5927. this.onAudioLockedObservable.notifyObservers(this);
  5928. this._displayMuteButton();
  5929. };
  5930. AudioEngine.prototype._displayMuteButton = function () {
  5931. var _this = this;
  5932. if (this.useCustomUnlockedButton || this._muteButton) {
  5933. return;
  5934. }
  5935. this._muteButton = document.createElement("BUTTON");
  5936. this._muteButton.className = "babylonUnmuteIcon";
  5937. this._muteButton.id = "babylonUnmuteIconBtn";
  5938. this._muteButton.title = "Unmute";
  5939. 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) }";
  5940. var style = document.createElement('style');
  5941. style.appendChild(document.createTextNode(css));
  5942. document.getElementsByTagName('head')[0].appendChild(style);
  5943. document.body.appendChild(this._muteButton);
  5944. this._moveButtonToTopLeft();
  5945. this._muteButton.addEventListener('touchend', function () {
  5946. _this._triggerRunningState();
  5947. }, true);
  5948. this._muteButton.addEventListener('click', function () {
  5949. _this._triggerRunningState();
  5950. }, true);
  5951. window.addEventListener("resize", this._onResize);
  5952. };
  5953. AudioEngine.prototype._moveButtonToTopLeft = function () {
  5954. if (this._hostElement && this._muteButton) {
  5955. this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px";
  5956. this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px";
  5957. }
  5958. };
  5959. AudioEngine.prototype._hideMuteButton = function () {
  5960. if (this._muteButton) {
  5961. document.body.removeChild(this._muteButton);
  5962. this._muteButton = null;
  5963. }
  5964. };
  5965. /**
  5966. * Destroy and release the resources associated with the audio ccontext.
  5967. */
  5968. AudioEngine.prototype.dispose = function () {
  5969. if (this.canUseWebAudio && this._audioContextInitialized) {
  5970. if (this._connectedAnalyser && this._audioContext) {
  5971. this._connectedAnalyser.stopDebugCanvas();
  5972. this._connectedAnalyser.dispose();
  5973. this.masterGain.disconnect();
  5974. this.masterGain.connect(this._audioContext.destination);
  5975. this._connectedAnalyser = null;
  5976. }
  5977. this.masterGain.gain.value = 1;
  5978. }
  5979. this.WarnedWebAudioUnsupported = false;
  5980. this._hideMuteButton();
  5981. window.removeEventListener("resize", this._onResize);
  5982. this.onAudioUnlockedObservable.clear();
  5983. this.onAudioLockedObservable.clear();
  5984. };
  5985. /**
  5986. * Gets the global volume sets on the master gain.
  5987. * @returns the global volume if set or -1 otherwise
  5988. */
  5989. AudioEngine.prototype.getGlobalVolume = function () {
  5990. if (this.canUseWebAudio && this._audioContextInitialized) {
  5991. return this.masterGain.gain.value;
  5992. }
  5993. else {
  5994. return -1;
  5995. }
  5996. };
  5997. /**
  5998. * Sets the global volume of your experience (sets on the master gain).
  5999. * @param newVolume Defines the new global volume of the application
  6000. */
  6001. AudioEngine.prototype.setGlobalVolume = function (newVolume) {
  6002. if (this.canUseWebAudio && this._audioContextInitialized) {
  6003. this.masterGain.gain.value = newVolume;
  6004. }
  6005. };
  6006. /**
  6007. * Connect the audio engine to an audio analyser allowing some amazing
  6008. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  6009. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  6010. * @param analyser The analyser to connect to the engine
  6011. */
  6012. AudioEngine.prototype.connectToAnalyser = function (analyser) {
  6013. if (this._connectedAnalyser) {
  6014. this._connectedAnalyser.stopDebugCanvas();
  6015. }
  6016. if (this.canUseWebAudio && this._audioContextInitialized && this._audioContext) {
  6017. this._connectedAnalyser = analyser;
  6018. this.masterGain.disconnect();
  6019. this._connectedAnalyser.connectAudioNodes(this.masterGain, this._audioContext.destination);
  6020. }
  6021. };
  6022. return AudioEngine;
  6023. }());
  6024. /***/ }),
  6025. /***/ "./Audio/audioSceneComponent.ts":
  6026. /*!**************************************!*\
  6027. !*** ./Audio/audioSceneComponent.ts ***!
  6028. \**************************************/
  6029. /*! exports provided: AudioSceneComponent */
  6030. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6031. "use strict";
  6032. __webpack_require__.r(__webpack_exports__);
  6033. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return AudioSceneComponent; });
  6034. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6035. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6036. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6037. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6038. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  6039. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  6040. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  6041. // Adds the parser to the scene parsers.
  6042. _abstractScene__WEBPACK_IMPORTED_MODULE_6__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO, function (parsedData, scene, container, rootUrl) {
  6043. // TODO: add sound
  6044. var loadedSounds = [];
  6045. var loadedSound;
  6046. container.sounds = container.sounds || [];
  6047. if (parsedData.sounds !== undefined && parsedData.sounds !== null) {
  6048. for (var index = 0, cache = parsedData.sounds.length; index < cache; index++) {
  6049. var parsedSound = parsedData.sounds[index];
  6050. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine.canUseWebAudio) {
  6051. if (!parsedSound.url) {
  6052. parsedSound.url = parsedSound.name;
  6053. }
  6054. if (!loadedSounds[parsedSound.url]) {
  6055. loadedSound = _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl);
  6056. loadedSounds[parsedSound.url] = loadedSound;
  6057. container.sounds.push(loadedSound);
  6058. }
  6059. else {
  6060. container.sounds.push(_sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl, loadedSounds[parsedSound.url]));
  6061. }
  6062. }
  6063. else {
  6064. container.sounds.push(new _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"](parsedSound.name, null, scene));
  6065. }
  6066. }
  6067. }
  6068. loadedSounds = [];
  6069. });
  6070. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "mainSoundTrack", {
  6071. get: function () {
  6072. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6073. if (!compo) {
  6074. compo = new AudioSceneComponent(this);
  6075. this._addComponent(compo);
  6076. }
  6077. if (!this._mainSoundTrack) {
  6078. this._mainSoundTrack = new _soundTrack__WEBPACK_IMPORTED_MODULE_1__["SoundTrack"](this, { mainTrack: true });
  6079. }
  6080. return this._mainSoundTrack;
  6081. },
  6082. enumerable: true,
  6083. configurable: true
  6084. });
  6085. _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype.getSoundByName = function (name) {
  6086. var index;
  6087. for (index = 0; index < this.mainSoundTrack.soundCollection.length; index++) {
  6088. if (this.mainSoundTrack.soundCollection[index].name === name) {
  6089. return this.mainSoundTrack.soundCollection[index];
  6090. }
  6091. }
  6092. if (this.soundTracks) {
  6093. for (var sdIndex = 0; sdIndex < this.soundTracks.length; sdIndex++) {
  6094. for (index = 0; index < this.soundTracks[sdIndex].soundCollection.length; index++) {
  6095. if (this.soundTracks[sdIndex].soundCollection[index].name === name) {
  6096. return this.soundTracks[sdIndex].soundCollection[index];
  6097. }
  6098. }
  6099. }
  6100. }
  6101. return null;
  6102. };
  6103. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "audioEnabled", {
  6104. get: function () {
  6105. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6106. if (!compo) {
  6107. compo = new AudioSceneComponent(this);
  6108. this._addComponent(compo);
  6109. }
  6110. return compo.audioEnabled;
  6111. },
  6112. set: function (value) {
  6113. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6114. if (!compo) {
  6115. compo = new AudioSceneComponent(this);
  6116. this._addComponent(compo);
  6117. }
  6118. if (value) {
  6119. compo.enableAudio();
  6120. }
  6121. else {
  6122. compo.disableAudio();
  6123. }
  6124. },
  6125. enumerable: true,
  6126. configurable: true
  6127. });
  6128. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "headphone", {
  6129. get: function () {
  6130. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6131. if (!compo) {
  6132. compo = new AudioSceneComponent(this);
  6133. this._addComponent(compo);
  6134. }
  6135. return compo.headphone;
  6136. },
  6137. set: function (value) {
  6138. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6139. if (!compo) {
  6140. compo = new AudioSceneComponent(this);
  6141. this._addComponent(compo);
  6142. }
  6143. if (value) {
  6144. compo.switchAudioModeForHeadphones();
  6145. }
  6146. else {
  6147. compo.switchAudioModeForNormalSpeakers();
  6148. }
  6149. },
  6150. enumerable: true,
  6151. configurable: true
  6152. });
  6153. /**
  6154. * Defines the sound scene component responsible to manage any sounds
  6155. * in a given scene.
  6156. */
  6157. var AudioSceneComponent = /** @class */ (function () {
  6158. /**
  6159. * Creates a new instance of the component for the given scene
  6160. * @param scene Defines the scene to register the component in
  6161. */
  6162. function AudioSceneComponent(scene) {
  6163. /**
  6164. * The component name helpfull to identify the component in the list of scene components.
  6165. */
  6166. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO;
  6167. this._audioEnabled = true;
  6168. this._headphone = false;
  6169. this.scene = scene;
  6170. scene.soundTracks = new Array();
  6171. scene.sounds = new Array();
  6172. }
  6173. Object.defineProperty(AudioSceneComponent.prototype, "audioEnabled", {
  6174. /**
  6175. * Gets whether audio is enabled or not.
  6176. * Please use related enable/disable method to switch state.
  6177. */
  6178. get: function () {
  6179. return this._audioEnabled;
  6180. },
  6181. enumerable: true,
  6182. configurable: true
  6183. });
  6184. Object.defineProperty(AudioSceneComponent.prototype, "headphone", {
  6185. /**
  6186. * Gets whether audio is outputing to headphone or not.
  6187. * Please use the according Switch methods to change output.
  6188. */
  6189. get: function () {
  6190. return this._headphone;
  6191. },
  6192. enumerable: true,
  6193. configurable: true
  6194. });
  6195. /**
  6196. * Registers the component in a given scene
  6197. */
  6198. AudioSceneComponent.prototype.register = function () {
  6199. this.scene._afterRenderStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDER_AUDIO, this, this._afterRender);
  6200. };
  6201. /**
  6202. * Rebuilds the elements related to this component in case of
  6203. * context lost for instance.
  6204. */
  6205. AudioSceneComponent.prototype.rebuild = function () {
  6206. // Nothing to do here. (Not rendering related)
  6207. };
  6208. /**
  6209. * Serializes the component data to the specified json object
  6210. * @param serializationObject The object to serialize to
  6211. */
  6212. AudioSceneComponent.prototype.serialize = function (serializationObject) {
  6213. serializationObject.sounds = [];
  6214. if (this.scene.soundTracks) {
  6215. for (var index = 0; index < this.scene.soundTracks.length; index++) {
  6216. var soundtrack = this.scene.soundTracks[index];
  6217. for (var soundId = 0; soundId < soundtrack.soundCollection.length; soundId++) {
  6218. serializationObject.sounds.push(soundtrack.soundCollection[soundId].serialize());
  6219. }
  6220. }
  6221. }
  6222. };
  6223. /**
  6224. * Adds all the element from the container to the scene
  6225. * @param container the container holding the elements
  6226. */
  6227. AudioSceneComponent.prototype.addFromContainer = function (container) {
  6228. var _this = this;
  6229. if (!container.sounds) {
  6230. return;
  6231. }
  6232. container.sounds.forEach(function (sound) {
  6233. sound.play();
  6234. sound.autoplay = true;
  6235. _this.scene.mainSoundTrack.AddSound(sound);
  6236. });
  6237. };
  6238. /**
  6239. * Removes all the elements in the container from the scene
  6240. * @param container contains the elements to remove
  6241. * @param dispose if the removed element should be disposed (default: false)
  6242. */
  6243. AudioSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  6244. var _this = this;
  6245. if (dispose === void 0) { dispose = false; }
  6246. if (!container.sounds) {
  6247. return;
  6248. }
  6249. container.sounds.forEach(function (sound) {
  6250. sound.stop();
  6251. sound.autoplay = false;
  6252. _this.scene.mainSoundTrack.RemoveSound(sound);
  6253. if (dispose) {
  6254. sound.dispose();
  6255. }
  6256. });
  6257. };
  6258. /**
  6259. * Disposes the component and the associated ressources.
  6260. */
  6261. AudioSceneComponent.prototype.dispose = function () {
  6262. var scene = this.scene;
  6263. if (scene._mainSoundTrack) {
  6264. scene.mainSoundTrack.dispose();
  6265. }
  6266. if (scene.soundTracks) {
  6267. for (var scIndex = 0; scIndex < scene.soundTracks.length; scIndex++) {
  6268. scene.soundTracks[scIndex].dispose();
  6269. }
  6270. }
  6271. };
  6272. /**
  6273. * Disables audio in the associated scene.
  6274. */
  6275. AudioSceneComponent.prototype.disableAudio = function () {
  6276. var scene = this.scene;
  6277. this._audioEnabled = false;
  6278. var i;
  6279. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6280. scene.mainSoundTrack.soundCollection[i].pause();
  6281. }
  6282. if (scene.soundTracks) {
  6283. for (i = 0; i < scene.soundTracks.length; i++) {
  6284. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6285. scene.soundTracks[i].soundCollection[j].pause();
  6286. }
  6287. }
  6288. }
  6289. };
  6290. /**
  6291. * Enables audio in the associated scene.
  6292. */
  6293. AudioSceneComponent.prototype.enableAudio = function () {
  6294. var scene = this.scene;
  6295. this._audioEnabled = true;
  6296. var i;
  6297. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6298. if (scene.mainSoundTrack.soundCollection[i].isPaused) {
  6299. scene.mainSoundTrack.soundCollection[i].play();
  6300. }
  6301. }
  6302. if (scene.soundTracks) {
  6303. for (i = 0; i < scene.soundTracks.length; i++) {
  6304. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6305. if (scene.soundTracks[i].soundCollection[j].isPaused) {
  6306. scene.soundTracks[i].soundCollection[j].play();
  6307. }
  6308. }
  6309. }
  6310. }
  6311. };
  6312. /**
  6313. * Switch audio to headphone output.
  6314. */
  6315. AudioSceneComponent.prototype.switchAudioModeForHeadphones = function () {
  6316. var scene = this.scene;
  6317. this._headphone = true;
  6318. scene.mainSoundTrack.switchPanningModelToHRTF();
  6319. if (scene.soundTracks) {
  6320. for (var i = 0; i < scene.soundTracks.length; i++) {
  6321. scene.soundTracks[i].switchPanningModelToHRTF();
  6322. }
  6323. }
  6324. };
  6325. /**
  6326. * Switch audio to normal speakers.
  6327. */
  6328. AudioSceneComponent.prototype.switchAudioModeForNormalSpeakers = function () {
  6329. var scene = this.scene;
  6330. this._headphone = false;
  6331. scene.mainSoundTrack.switchPanningModelToEqualPower();
  6332. if (scene.soundTracks) {
  6333. for (var i = 0; i < scene.soundTracks.length; i++) {
  6334. scene.soundTracks[i].switchPanningModelToEqualPower();
  6335. }
  6336. }
  6337. };
  6338. AudioSceneComponent.prototype._afterRender = function () {
  6339. var scene = this.scene;
  6340. if (!this._audioEnabled || !scene._mainSoundTrack || !scene.soundTracks || (scene._mainSoundTrack.soundCollection.length === 0 && scene.soundTracks.length === 1)) {
  6341. return;
  6342. }
  6343. var listeningCamera;
  6344. var audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine;
  6345. if (scene.activeCameras.length > 0) {
  6346. listeningCamera = scene.activeCameras[0];
  6347. }
  6348. else {
  6349. listeningCamera = scene.activeCamera;
  6350. }
  6351. if (listeningCamera && audioEngine.audioContext) {
  6352. audioEngine.audioContext.listener.setPosition(listeningCamera.position.x, listeningCamera.position.y, listeningCamera.position.z);
  6353. // for VR cameras
  6354. if (listeningCamera.rigCameras && listeningCamera.rigCameras.length > 0) {
  6355. listeningCamera = listeningCamera.rigCameras[0];
  6356. }
  6357. var mat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(listeningCamera.getViewMatrix());
  6358. var cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1), mat);
  6359. cameraDirection.normalize();
  6360. // To avoid some errors on GearVR
  6361. if (!isNaN(cameraDirection.x) && !isNaN(cameraDirection.y) && !isNaN(cameraDirection.z)) {
  6362. audioEngine.audioContext.listener.setOrientation(cameraDirection.x, cameraDirection.y, cameraDirection.z, 0, 1, 0);
  6363. }
  6364. var i;
  6365. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6366. var sound = scene.mainSoundTrack.soundCollection[i];
  6367. if (sound.useCustomAttenuation) {
  6368. sound.updateDistanceFromListener();
  6369. }
  6370. }
  6371. if (scene.soundTracks) {
  6372. for (i = 0; i < scene.soundTracks.length; i++) {
  6373. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6374. sound = scene.soundTracks[i].soundCollection[j];
  6375. if (sound.useCustomAttenuation) {
  6376. sound.updateDistanceFromListener();
  6377. }
  6378. }
  6379. }
  6380. }
  6381. }
  6382. };
  6383. return AudioSceneComponent;
  6384. }());
  6385. _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"]._SceneComponentInitialization = function (scene) {
  6386. var compo = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6387. if (!compo) {
  6388. compo = new AudioSceneComponent(scene);
  6389. scene._addComponent(compo);
  6390. }
  6391. };
  6392. /***/ }),
  6393. /***/ "./Audio/index.ts":
  6394. /*!************************!*\
  6395. !*** ./Audio/index.ts ***!
  6396. \************************/
  6397. /*! exports provided: Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound */
  6398. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6399. "use strict";
  6400. __webpack_require__.r(__webpack_exports__);
  6401. /* harmony import */ var _analyser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./analyser */ "./Audio/analyser.ts");
  6402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _analyser__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  6403. /* harmony import */ var _audioEngine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./audioEngine */ "./Audio/audioEngine.ts");
  6404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _audioEngine__WEBPACK_IMPORTED_MODULE_1__["AudioEngine"]; });
  6405. /* harmony import */ var _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./audioSceneComponent */ "./Audio/audioSceneComponent.ts");
  6406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__["AudioSceneComponent"]; });
  6407. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _sound__WEBPACK_IMPORTED_MODULE_3__["Sound"]; });
  6409. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _soundTrack__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  6411. /* harmony import */ var _weightedsound__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./weightedsound */ "./Audio/weightedsound.ts");
  6412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _weightedsound__WEBPACK_IMPORTED_MODULE_5__["WeightedSound"]; });
  6413. /***/ }),
  6414. /***/ "./Audio/sound.ts":
  6415. /*!************************!*\
  6416. !*** ./Audio/sound.ts ***!
  6417. \************************/
  6418. /*! exports provided: Sound */
  6419. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6420. "use strict";
  6421. __webpack_require__.r(__webpack_exports__);
  6422. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return Sound; });
  6423. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  6424. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  6425. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6426. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6427. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  6428. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  6429. /**
  6430. * Defines a sound that can be played in the application.
  6431. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  6432. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6433. */
  6434. var Sound = /** @class */ (function () {
  6435. /**
  6436. * Create a sound and attach it to a scene
  6437. * @param name Name of your sound
  6438. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  6439. * @param scene defines the scene the sound belongs to
  6440. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  6441. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  6442. */
  6443. function Sound(name, urlOrArrayBuffer, scene, readyToPlayCallback, options) {
  6444. if (readyToPlayCallback === void 0) { readyToPlayCallback = null; }
  6445. var _this = this;
  6446. /**
  6447. * Does the sound autoplay once loaded.
  6448. */
  6449. this.autoplay = false;
  6450. /**
  6451. * Does the sound loop after it finishes playing once.
  6452. */
  6453. this.loop = false;
  6454. /**
  6455. * Does the sound use a custom attenuation curve to simulate the falloff
  6456. * happening when the source gets further away from the camera.
  6457. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6458. */
  6459. this.useCustomAttenuation = false;
  6460. /**
  6461. * Is this sound currently played.
  6462. */
  6463. this.isPlaying = false;
  6464. /**
  6465. * Is this sound currently paused.
  6466. */
  6467. this.isPaused = false;
  6468. /**
  6469. * Does this sound enables spatial sound.
  6470. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6471. */
  6472. this.spatialSound = false;
  6473. /**
  6474. * Define the reference distance the sound should be heard perfectly.
  6475. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6476. */
  6477. this.refDistance = 1;
  6478. /**
  6479. * Define the roll off factor of spatial sounds.
  6480. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6481. */
  6482. this.rolloffFactor = 1;
  6483. /**
  6484. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  6485. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6486. */
  6487. this.maxDistance = 100;
  6488. /**
  6489. * Define the distance attenuation model the sound will follow.
  6490. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6491. */
  6492. this.distanceModel = "linear";
  6493. /**
  6494. * Observable event when the current playing sound finishes.
  6495. */
  6496. this.onEndedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6497. this._panningModel = "equalpower";
  6498. this._playbackRate = 1;
  6499. this._streaming = false;
  6500. this._startTime = 0;
  6501. this._startOffset = 0;
  6502. this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  6503. /** @hidden */
  6504. this._positionInEmitterSpace = false;
  6505. this._localDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 0, 0);
  6506. this._volume = 1;
  6507. this._isReadyToPlay = false;
  6508. this._isDirectional = false;
  6509. // Used if you'd like to create a directional sound.
  6510. // If not set, the sound will be omnidirectional
  6511. this._coneInnerAngle = 360;
  6512. this._coneOuterAngle = 360;
  6513. this._coneOuterGain = 0;
  6514. this._isOutputConnected = false;
  6515. this._urlType = "Unknown";
  6516. this.name = name;
  6517. this._scene = scene;
  6518. Sound._SceneComponentInitialization(scene);
  6519. this._readyToPlayCallback = readyToPlayCallback;
  6520. // Default custom attenuation function is a linear attenuation
  6521. this._customAttenuationFunction = function (currentVolume, currentDistance, maxDistance, refDistance, rolloffFactor) {
  6522. if (currentDistance < maxDistance) {
  6523. return currentVolume * (1 - currentDistance / maxDistance);
  6524. }
  6525. else {
  6526. return 0;
  6527. }
  6528. };
  6529. if (options) {
  6530. this.autoplay = options.autoplay || false;
  6531. this.loop = options.loop || false;
  6532. // if volume === 0, we need another way to check this option
  6533. if (options.volume !== undefined) {
  6534. this._volume = options.volume;
  6535. }
  6536. this.spatialSound = options.spatialSound || false;
  6537. this.maxDistance = options.maxDistance || 100;
  6538. this.useCustomAttenuation = options.useCustomAttenuation || false;
  6539. this.rolloffFactor = options.rolloffFactor || 1;
  6540. this.refDistance = options.refDistance || 1;
  6541. this.distanceModel = options.distanceModel || "linear";
  6542. this._playbackRate = options.playbackRate || 1;
  6543. this._streaming = options.streaming || false;
  6544. }
  6545. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6546. this._soundGain = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createGain();
  6547. this._soundGain.gain.value = this._volume;
  6548. this._inputAudioNode = this._soundGain;
  6549. this._outputAudioNode = this._soundGain;
  6550. if (this.spatialSound) {
  6551. this._createSpatialParameters();
  6552. }
  6553. this._scene.mainSoundTrack.AddSound(this);
  6554. var validParameter = true;
  6555. // if no parameter is passed, you need to call setAudioBuffer yourself to prepare the sound
  6556. if (urlOrArrayBuffer) {
  6557. try {
  6558. if (typeof (urlOrArrayBuffer) === "string") {
  6559. this._urlType = "String";
  6560. }
  6561. else if (urlOrArrayBuffer instanceof ArrayBuffer) {
  6562. this._urlType = "ArrayBuffer";
  6563. }
  6564. else if (urlOrArrayBuffer instanceof MediaStream) {
  6565. this._urlType = "MediaStream";
  6566. }
  6567. else if (Array.isArray(urlOrArrayBuffer)) {
  6568. this._urlType = "Array";
  6569. }
  6570. var urls = [];
  6571. var codecSupportedFound = false;
  6572. switch (this._urlType) {
  6573. case "MediaStream":
  6574. this._streaming = true;
  6575. this._isReadyToPlay = true;
  6576. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(urlOrArrayBuffer);
  6577. if (this.autoplay) {
  6578. this.play();
  6579. }
  6580. if (this._readyToPlayCallback) {
  6581. this._readyToPlayCallback();
  6582. }
  6583. break;
  6584. case "ArrayBuffer":
  6585. if (urlOrArrayBuffer.byteLength > 0) {
  6586. codecSupportedFound = true;
  6587. this._soundLoaded(urlOrArrayBuffer);
  6588. }
  6589. break;
  6590. case "String":
  6591. urls.push(urlOrArrayBuffer);
  6592. case "Array":
  6593. if (urls.length === 0) {
  6594. urls = urlOrArrayBuffer;
  6595. }
  6596. // If we found a supported format, we load it immediately and stop the loop
  6597. for (var i = 0; i < urls.length; i++) {
  6598. var url = urls[i];
  6599. if (url.indexOf(".mp3", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isMP3supported) {
  6600. codecSupportedFound = true;
  6601. }
  6602. if (url.indexOf(".ogg", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isOGGsupported) {
  6603. codecSupportedFound = true;
  6604. }
  6605. if (url.indexOf(".wav", url.length - 4) !== -1) {
  6606. codecSupportedFound = true;
  6607. }
  6608. if (url.indexOf("blob:") !== -1) {
  6609. codecSupportedFound = true;
  6610. }
  6611. if (codecSupportedFound) {
  6612. // Loading sound using XHR2
  6613. if (!this._streaming) {
  6614. this._scene._loadFile(url, function (data) {
  6615. _this._soundLoaded(data);
  6616. }, undefined, true, true, function (exception) {
  6617. if (exception) {
  6618. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("XHR " + exception.status + " error on: " + url + ".");
  6619. }
  6620. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Sound creation aborted.");
  6621. _this._scene.mainSoundTrack.RemoveSound(_this);
  6622. });
  6623. }
  6624. // Streaming sound using HTML5 Audio tag
  6625. else {
  6626. this._htmlAudioElement = new Audio(url);
  6627. this._htmlAudioElement.controls = false;
  6628. this._htmlAudioElement.loop = this.loop;
  6629. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetCorsBehavior(url, this._htmlAudioElement);
  6630. this._htmlAudioElement.preload = "auto";
  6631. this._htmlAudioElement.addEventListener("canplaythrough", function () {
  6632. _this._isReadyToPlay = true;
  6633. if (_this.autoplay) {
  6634. _this.play();
  6635. }
  6636. if (_this._readyToPlayCallback) {
  6637. _this._readyToPlayCallback();
  6638. }
  6639. });
  6640. document.body.appendChild(this._htmlAudioElement);
  6641. this._htmlAudioElement.load();
  6642. }
  6643. break;
  6644. }
  6645. }
  6646. break;
  6647. default:
  6648. validParameter = false;
  6649. break;
  6650. }
  6651. if (!validParameter) {
  6652. _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.");
  6653. }
  6654. else {
  6655. if (!codecSupportedFound) {
  6656. this._isReadyToPlay = true;
  6657. // Simulating a ready to play event to avoid breaking code path
  6658. if (this._readyToPlayCallback) {
  6659. window.setTimeout(function () {
  6660. if (_this._readyToPlayCallback) {
  6661. _this._readyToPlayCallback();
  6662. }
  6663. }, 1000);
  6664. }
  6665. }
  6666. }
  6667. }
  6668. catch (ex) {
  6669. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Unexpected error. Sound creation aborted.");
  6670. this._scene.mainSoundTrack.RemoveSound(this);
  6671. }
  6672. }
  6673. }
  6674. else {
  6675. // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers
  6676. this._scene.mainSoundTrack.AddSound(this);
  6677. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported) {
  6678. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Web Audio is not supported by your browser.");
  6679. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported = true;
  6680. }
  6681. // Simulating a ready to play event to avoid breaking code for non web audio browsers
  6682. if (this._readyToPlayCallback) {
  6683. window.setTimeout(function () {
  6684. if (_this._readyToPlayCallback) {
  6685. _this._readyToPlayCallback();
  6686. }
  6687. }, 1000);
  6688. }
  6689. }
  6690. }
  6691. /**
  6692. * Release the sound and its associated resources
  6693. */
  6694. Sound.prototype.dispose = function () {
  6695. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6696. if (this.isPlaying) {
  6697. this.stop();
  6698. }
  6699. this._isReadyToPlay = false;
  6700. if (this.soundTrackId === -1) {
  6701. this._scene.mainSoundTrack.RemoveSound(this);
  6702. }
  6703. else if (this._scene.soundTracks) {
  6704. this._scene.soundTracks[this.soundTrackId].RemoveSound(this);
  6705. }
  6706. if (this._soundGain) {
  6707. this._soundGain.disconnect();
  6708. this._soundGain = null;
  6709. }
  6710. if (this._soundPanner) {
  6711. this._soundPanner.disconnect();
  6712. this._soundPanner = null;
  6713. }
  6714. if (this._soundSource) {
  6715. this._soundSource.disconnect();
  6716. this._soundSource = null;
  6717. }
  6718. this._audioBuffer = null;
  6719. if (this._htmlAudioElement) {
  6720. this._htmlAudioElement.pause();
  6721. this._htmlAudioElement.src = "";
  6722. document.body.removeChild(this._htmlAudioElement);
  6723. }
  6724. if (this._streamingSource) {
  6725. this._streamingSource.disconnect();
  6726. }
  6727. if (this._connectedTransformNode && this._registerFunc) {
  6728. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  6729. this._connectedTransformNode = null;
  6730. }
  6731. }
  6732. };
  6733. /**
  6734. * Gets if the sounds is ready to be played or not.
  6735. * @returns true if ready, otherwise false
  6736. */
  6737. Sound.prototype.isReady = function () {
  6738. return this._isReadyToPlay;
  6739. };
  6740. Sound.prototype._soundLoaded = function (audioData) {
  6741. var _this = this;
  6742. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6743. return;
  6744. }
  6745. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.decodeAudioData(audioData, function (buffer) {
  6746. _this._audioBuffer = buffer;
  6747. _this._isReadyToPlay = true;
  6748. if (_this.autoplay) {
  6749. _this.play();
  6750. }
  6751. if (_this._readyToPlayCallback) {
  6752. _this._readyToPlayCallback();
  6753. }
  6754. }, function (err) { _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while decoding audio data for: " + _this.name + " / Error: " + err); });
  6755. };
  6756. /**
  6757. * Sets the data of the sound from an audiobuffer
  6758. * @param audioBuffer The audioBuffer containing the data
  6759. */
  6760. Sound.prototype.setAudioBuffer = function (audioBuffer) {
  6761. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6762. this._audioBuffer = audioBuffer;
  6763. this._isReadyToPlay = true;
  6764. }
  6765. };
  6766. /**
  6767. * Updates the current sounds options such as maxdistance, loop...
  6768. * @param options A JSON object containing values named as the object properties
  6769. */
  6770. Sound.prototype.updateOptions = function (options) {
  6771. if (options) {
  6772. this.loop = options.loop || this.loop;
  6773. this.maxDistance = options.maxDistance || this.maxDistance;
  6774. this.useCustomAttenuation = options.useCustomAttenuation || this.useCustomAttenuation;
  6775. this.rolloffFactor = options.rolloffFactor || this.rolloffFactor;
  6776. this.refDistance = options.refDistance || this.refDistance;
  6777. this.distanceModel = options.distanceModel || this.distanceModel;
  6778. this._playbackRate = options.playbackRate || this._playbackRate;
  6779. this._updateSpatialParameters();
  6780. if (this.isPlaying) {
  6781. if (this._streaming && this._htmlAudioElement) {
  6782. this._htmlAudioElement.playbackRate = this._playbackRate;
  6783. }
  6784. else {
  6785. if (this._soundSource) {
  6786. this._soundSource.playbackRate.value = this._playbackRate;
  6787. }
  6788. }
  6789. }
  6790. }
  6791. };
  6792. Sound.prototype._createSpatialParameters = function () {
  6793. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6794. if (this._scene.headphone) {
  6795. this._panningModel = "HRTF";
  6796. }
  6797. this._soundPanner = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createPanner();
  6798. this._updateSpatialParameters();
  6799. this._soundPanner.connect(this._outputAudioNode);
  6800. this._inputAudioNode = this._soundPanner;
  6801. }
  6802. };
  6803. Sound.prototype._updateSpatialParameters = function () {
  6804. if (this.spatialSound && this._soundPanner) {
  6805. if (this.useCustomAttenuation) {
  6806. // Tricks to disable in a way embedded Web Audio attenuation
  6807. this._soundPanner.distanceModel = "linear";
  6808. this._soundPanner.maxDistance = Number.MAX_VALUE;
  6809. this._soundPanner.refDistance = 1;
  6810. this._soundPanner.rolloffFactor = 1;
  6811. this._soundPanner.panningModel = this._panningModel;
  6812. }
  6813. else {
  6814. this._soundPanner.distanceModel = this.distanceModel;
  6815. this._soundPanner.maxDistance = this.maxDistance;
  6816. this._soundPanner.refDistance = this.refDistance;
  6817. this._soundPanner.rolloffFactor = this.rolloffFactor;
  6818. this._soundPanner.panningModel = this._panningModel;
  6819. }
  6820. }
  6821. };
  6822. /**
  6823. * Switch the panning model to HRTF:
  6824. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  6825. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6826. */
  6827. Sound.prototype.switchPanningModelToHRTF = function () {
  6828. this._panningModel = "HRTF";
  6829. this._switchPanningModel();
  6830. };
  6831. /**
  6832. * Switch the panning model to Equal Power:
  6833. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  6834. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6835. */
  6836. Sound.prototype.switchPanningModelToEqualPower = function () {
  6837. this._panningModel = "equalpower";
  6838. this._switchPanningModel();
  6839. };
  6840. Sound.prototype._switchPanningModel = function () {
  6841. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6842. this._soundPanner.panningModel = this._panningModel;
  6843. }
  6844. };
  6845. /**
  6846. * Connect this sound to a sound track audio node like gain...
  6847. * @param soundTrackAudioNode the sound track audio node to connect to
  6848. */
  6849. Sound.prototype.connectToSoundTrackAudioNode = function (soundTrackAudioNode) {
  6850. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6851. if (this._isOutputConnected) {
  6852. this._outputAudioNode.disconnect();
  6853. }
  6854. this._outputAudioNode.connect(soundTrackAudioNode);
  6855. this._isOutputConnected = true;
  6856. }
  6857. };
  6858. /**
  6859. * Transform this sound into a directional source
  6860. * @param coneInnerAngle Size of the inner cone in degree
  6861. * @param coneOuterAngle Size of the outer cone in degree
  6862. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  6863. */
  6864. Sound.prototype.setDirectionalCone = function (coneInnerAngle, coneOuterAngle, coneOuterGain) {
  6865. if (coneOuterAngle < coneInnerAngle) {
  6866. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.");
  6867. return;
  6868. }
  6869. this._coneInnerAngle = coneInnerAngle;
  6870. this._coneOuterAngle = coneOuterAngle;
  6871. this._coneOuterGain = coneOuterGain;
  6872. this._isDirectional = true;
  6873. if (this.isPlaying && this.loop) {
  6874. this.stop();
  6875. this.play();
  6876. }
  6877. };
  6878. Object.defineProperty(Sound.prototype, "directionalConeInnerAngle", {
  6879. /**
  6880. * Gets or sets the inner angle for the directional cone.
  6881. */
  6882. get: function () {
  6883. return this._coneInnerAngle;
  6884. },
  6885. /**
  6886. * Gets or sets the inner angle for the directional cone.
  6887. */
  6888. set: function (value) {
  6889. if (value != this._coneInnerAngle) {
  6890. if (this._coneOuterAngle < value) {
  6891. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6892. return;
  6893. }
  6894. this._coneInnerAngle = value;
  6895. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6896. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6897. }
  6898. }
  6899. },
  6900. enumerable: true,
  6901. configurable: true
  6902. });
  6903. Object.defineProperty(Sound.prototype, "directionalConeOuterAngle", {
  6904. /**
  6905. * Gets or sets the outer angle for the directional cone.
  6906. */
  6907. get: function () {
  6908. return this._coneOuterAngle;
  6909. },
  6910. /**
  6911. * Gets or sets the outer angle for the directional cone.
  6912. */
  6913. set: function (value) {
  6914. if (value != this._coneOuterAngle) {
  6915. if (value < this._coneInnerAngle) {
  6916. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6917. return;
  6918. }
  6919. this._coneOuterAngle = value;
  6920. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6921. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6922. }
  6923. }
  6924. },
  6925. enumerable: true,
  6926. configurable: true
  6927. });
  6928. /**
  6929. * Sets the position of the emitter if spatial sound is enabled
  6930. * @param newPosition Defines the new posisiton
  6931. */
  6932. Sound.prototype.setPosition = function (newPosition) {
  6933. this._position = newPosition;
  6934. 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)) {
  6935. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6936. }
  6937. };
  6938. /**
  6939. * Sets the local direction of the emitter if spatial sound is enabled
  6940. * @param newLocalDirection Defines the new local direction
  6941. */
  6942. Sound.prototype.setLocalDirectionToMesh = function (newLocalDirection) {
  6943. this._localDirection = newLocalDirection;
  6944. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.isPlaying) {
  6945. this._updateDirection();
  6946. }
  6947. };
  6948. Sound.prototype._updateDirection = function () {
  6949. if (!this._connectedTransformNode || !this._soundPanner) {
  6950. return;
  6951. }
  6952. var mat = this._connectedTransformNode.getWorldMatrix();
  6953. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(this._localDirection, mat);
  6954. direction.normalize();
  6955. this._soundPanner.setOrientation(direction.x, direction.y, direction.z);
  6956. };
  6957. /** @hidden */
  6958. Sound.prototype.updateDistanceFromListener = function () {
  6959. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
  6960. var distance = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);
  6961. this._soundGain.gain.value = this._customAttenuationFunction(this._volume, distance, this.maxDistance, this.refDistance, this.rolloffFactor);
  6962. }
  6963. };
  6964. /**
  6965. * Sets a new custom attenuation function for the sound.
  6966. * @param callback Defines the function used for the attenuation
  6967. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6968. */
  6969. Sound.prototype.setAttenuationFunction = function (callback) {
  6970. this._customAttenuationFunction = callback;
  6971. };
  6972. /**
  6973. * Play the sound
  6974. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  6975. * @param offset (optional) Start the sound setting it at a specific time
  6976. */
  6977. Sound.prototype.play = function (time, offset) {
  6978. var _this = this;
  6979. if (this._isReadyToPlay && this._scene.audioEnabled && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6980. try {
  6981. if (this._startOffset < 0) {
  6982. time = -this._startOffset;
  6983. this._startOffset = 0;
  6984. }
  6985. var startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  6986. if (!this._soundSource || !this._streamingSource) {
  6987. if (this.spatialSound && this._soundPanner) {
  6988. if (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
  6989. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6990. }
  6991. if (this._isDirectional) {
  6992. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6993. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6994. this._soundPanner.coneOuterGain = this._coneOuterGain;
  6995. if (this._connectedTransformNode) {
  6996. this._updateDirection();
  6997. }
  6998. else {
  6999. this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z);
  7000. }
  7001. }
  7002. }
  7003. }
  7004. if (this._streaming) {
  7005. if (!this._streamingSource) {
  7006. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement);
  7007. this._htmlAudioElement.onended = function () { _this._onended(); };
  7008. this._htmlAudioElement.playbackRate = this._playbackRate;
  7009. }
  7010. this._streamingSource.disconnect();
  7011. this._streamingSource.connect(this._inputAudioNode);
  7012. if (this._htmlAudioElement) {
  7013. // required to manage properly the new suspended default state of Chrome
  7014. // When the option 'streaming: true' is used, we need first to wait for
  7015. // the audio engine to be unlocked by a user gesture before trying to play
  7016. // an HTML Audio elememt
  7017. var tryToPlay = function () {
  7018. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.unlocked) {
  7019. var playPromise = _this._htmlAudioElement.play();
  7020. // In browsers that don’t yet support this functionality,
  7021. // playPromise won’t be defined.
  7022. if (playPromise !== undefined) {
  7023. playPromise.catch(function (error) {
  7024. // Automatic playback failed.
  7025. // Waiting for the audio engine to be unlocked by user click on unmute
  7026. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7027. if (_this.loop || _this.autoplay) {
  7028. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7029. }
  7030. });
  7031. }
  7032. }
  7033. else {
  7034. if (_this.loop || _this.autoplay) {
  7035. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7036. }
  7037. }
  7038. };
  7039. tryToPlay();
  7040. }
  7041. }
  7042. else {
  7043. var tryToPlay = function () {
  7044. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7045. _this._soundSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createBufferSource();
  7046. _this._soundSource.buffer = _this._audioBuffer;
  7047. _this._soundSource.connect(_this._inputAudioNode);
  7048. _this._soundSource.loop = _this.loop;
  7049. _this._soundSource.playbackRate.value = _this._playbackRate;
  7050. _this._soundSource.onended = function () { _this._onended(); };
  7051. startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7052. _this._soundSource.start(startTime, _this.isPaused ? _this._startOffset % _this._soundSource.buffer.duration : offset ? offset : 0);
  7053. }
  7054. };
  7055. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7056. // Wait a bit for FF as context seems late to be ready.
  7057. setTimeout(function () {
  7058. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7059. // Automatic playback failed.
  7060. // Waiting for the audio engine to be unlocked by user click on unmute
  7061. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7062. if (_this.loop || _this.autoplay) {
  7063. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7064. }
  7065. }
  7066. else {
  7067. tryToPlay();
  7068. }
  7069. }, 500);
  7070. }
  7071. else {
  7072. tryToPlay();
  7073. }
  7074. }
  7075. this._startTime = startTime;
  7076. this.isPlaying = true;
  7077. this.isPaused = false;
  7078. }
  7079. catch (ex) {
  7080. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while trying to play audio: " + this.name + ", " + ex.message);
  7081. }
  7082. }
  7083. };
  7084. Sound.prototype._onended = function () {
  7085. this.isPlaying = false;
  7086. if (this.onended) {
  7087. this.onended();
  7088. }
  7089. this.onEndedObservable.notifyObservers(this);
  7090. };
  7091. /**
  7092. * Stop the sound
  7093. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  7094. */
  7095. Sound.prototype.stop = function (time) {
  7096. var _this = this;
  7097. if (this.isPlaying) {
  7098. if (this._streaming) {
  7099. if (this._htmlAudioElement) {
  7100. this._htmlAudioElement.pause();
  7101. // Test needed for Firefox or it will generate an Invalid State Error
  7102. if (this._htmlAudioElement.currentTime > 0) {
  7103. this._htmlAudioElement.currentTime = 0;
  7104. }
  7105. }
  7106. else {
  7107. this._streamingSource.disconnect();
  7108. }
  7109. this.isPlaying = false;
  7110. }
  7111. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext && this._soundSource) {
  7112. var stopTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7113. this._soundSource.stop(stopTime);
  7114. this._soundSource.onended = function () { _this.isPlaying = false; };
  7115. if (!this.isPaused) {
  7116. this._startOffset = 0;
  7117. }
  7118. }
  7119. }
  7120. };
  7121. /**
  7122. * Put the sound in pause
  7123. */
  7124. Sound.prototype.pause = function () {
  7125. if (this.isPlaying) {
  7126. this.isPaused = true;
  7127. if (this._streaming) {
  7128. if (this._htmlAudioElement) {
  7129. this._htmlAudioElement.pause();
  7130. }
  7131. else {
  7132. this._streamingSource.disconnect();
  7133. }
  7134. }
  7135. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7136. this.stop(0);
  7137. this._startOffset += _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime - this._startTime;
  7138. }
  7139. }
  7140. };
  7141. /**
  7142. * Sets a dedicated volume for this sounds
  7143. * @param newVolume Define the new volume of the sound
  7144. * @param time Define in how long the sound should be at this value
  7145. */
  7146. Sound.prototype.setVolume = function (newVolume, time) {
  7147. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._soundGain) {
  7148. if (time && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7149. this._soundGain.gain.cancelScheduledValues(_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7150. this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7151. this._soundGain.gain.linearRampToValueAtTime(newVolume, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time);
  7152. }
  7153. else {
  7154. this._soundGain.gain.value = newVolume;
  7155. }
  7156. }
  7157. this._volume = newVolume;
  7158. };
  7159. /**
  7160. * Set the sound play back rate
  7161. * @param newPlaybackRate Define the playback rate the sound should be played at
  7162. */
  7163. Sound.prototype.setPlaybackRate = function (newPlaybackRate) {
  7164. this._playbackRate = newPlaybackRate;
  7165. if (this.isPlaying) {
  7166. if (this._streaming && this._htmlAudioElement) {
  7167. this._htmlAudioElement.playbackRate = this._playbackRate;
  7168. }
  7169. else if (this._soundSource) {
  7170. this._soundSource.playbackRate.value = this._playbackRate;
  7171. }
  7172. }
  7173. };
  7174. /**
  7175. * Gets the volume of the sound.
  7176. * @returns the volume of the sound
  7177. */
  7178. Sound.prototype.getVolume = function () {
  7179. return this._volume;
  7180. };
  7181. /**
  7182. * Attach the sound to a dedicated mesh
  7183. * @param transformNode The transform node to connect the sound with
  7184. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7185. */
  7186. Sound.prototype.attachToMesh = function (transformNode) {
  7187. var _this = this;
  7188. if (this._connectedTransformNode && this._registerFunc) {
  7189. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7190. this._registerFunc = null;
  7191. }
  7192. this._connectedTransformNode = transformNode;
  7193. if (!this.spatialSound) {
  7194. this.spatialSound = true;
  7195. this._createSpatialParameters();
  7196. if (this.isPlaying && this.loop) {
  7197. this.stop();
  7198. this.play();
  7199. }
  7200. }
  7201. this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode);
  7202. this._registerFunc = function (transformNode) { return _this._onRegisterAfterWorldMatrixUpdate(transformNode); };
  7203. this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc);
  7204. };
  7205. /**
  7206. * Detach the sound from the previously attached mesh
  7207. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7208. */
  7209. Sound.prototype.detachFromMesh = function () {
  7210. if (this._connectedTransformNode && this._registerFunc) {
  7211. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7212. this._registerFunc = null;
  7213. this._connectedTransformNode = null;
  7214. }
  7215. };
  7216. Sound.prototype._onRegisterAfterWorldMatrixUpdate = function (node) {
  7217. if (!node.getBoundingInfo) {
  7218. return;
  7219. }
  7220. var mesh = node;
  7221. if (this._positionInEmitterSpace) {
  7222. mesh.worldMatrixFromCache.invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0]);
  7223. this.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0].getTranslation());
  7224. }
  7225. else {
  7226. var boundingInfo = mesh.getBoundingInfo();
  7227. this.setPosition(boundingInfo.boundingSphere.centerWorld);
  7228. }
  7229. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._isDirectional && this.isPlaying) {
  7230. this._updateDirection();
  7231. }
  7232. };
  7233. /**
  7234. * Clone the current sound in the scene.
  7235. * @returns the new sound clone
  7236. */
  7237. Sound.prototype.clone = function () {
  7238. var _this = this;
  7239. if (!this._streaming) {
  7240. var setBufferAndRun = function () {
  7241. if (_this._isReadyToPlay) {
  7242. clonedSound._audioBuffer = _this.getAudioBuffer();
  7243. clonedSound._isReadyToPlay = true;
  7244. if (clonedSound.autoplay) {
  7245. clonedSound.play();
  7246. }
  7247. }
  7248. else {
  7249. window.setTimeout(setBufferAndRun, 300);
  7250. }
  7251. };
  7252. var currentOptions = {
  7253. autoplay: this.autoplay, loop: this.loop,
  7254. volume: this._volume, spatialSound: this.spatialSound, maxDistance: this.maxDistance,
  7255. useCustomAttenuation: this.useCustomAttenuation, rolloffFactor: this.rolloffFactor,
  7256. refDistance: this.refDistance, distanceModel: this.distanceModel
  7257. };
  7258. var clonedSound = new Sound(this.name + "_cloned", new ArrayBuffer(0), this._scene, null, currentOptions);
  7259. if (this.useCustomAttenuation) {
  7260. clonedSound.setAttenuationFunction(this._customAttenuationFunction);
  7261. }
  7262. clonedSound.setPosition(this._position);
  7263. clonedSound.setPlaybackRate(this._playbackRate);
  7264. setBufferAndRun();
  7265. return clonedSound;
  7266. }
  7267. // Can't clone a streaming sound
  7268. else {
  7269. return null;
  7270. }
  7271. };
  7272. /**
  7273. * Gets the current underlying audio buffer containing the data
  7274. * @returns the audio buffer
  7275. */
  7276. Sound.prototype.getAudioBuffer = function () {
  7277. return this._audioBuffer;
  7278. };
  7279. /**
  7280. * Serializes the Sound in a JSON representation
  7281. * @returns the JSON representation of the sound
  7282. */
  7283. Sound.prototype.serialize = function () {
  7284. var serializationObject = {
  7285. name: this.name,
  7286. url: this.name,
  7287. autoplay: this.autoplay,
  7288. loop: this.loop,
  7289. volume: this._volume,
  7290. spatialSound: this.spatialSound,
  7291. maxDistance: this.maxDistance,
  7292. rolloffFactor: this.rolloffFactor,
  7293. refDistance: this.refDistance,
  7294. distanceModel: this.distanceModel,
  7295. playbackRate: this._playbackRate,
  7296. panningModel: this._panningModel,
  7297. soundTrackId: this.soundTrackId
  7298. };
  7299. if (this.spatialSound) {
  7300. if (this._connectedTransformNode) {
  7301. serializationObject.connectedMeshId = this._connectedTransformNode.id;
  7302. }
  7303. serializationObject.position = this._position.asArray();
  7304. serializationObject.refDistance = this.refDistance;
  7305. serializationObject.distanceModel = this.distanceModel;
  7306. serializationObject.isDirectional = this._isDirectional;
  7307. serializationObject.localDirectionToMesh = this._localDirection.asArray();
  7308. serializationObject.coneInnerAngle = this._coneInnerAngle;
  7309. serializationObject.coneOuterAngle = this._coneOuterAngle;
  7310. serializationObject.coneOuterGain = this._coneOuterGain;
  7311. }
  7312. return serializationObject;
  7313. };
  7314. /**
  7315. * Parse a JSON representation of a sound to innstantiate in a given scene
  7316. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  7317. * @param scene Define the scene the new parsed sound should be created in
  7318. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  7319. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  7320. * @returns the newly parsed sound
  7321. */
  7322. Sound.Parse = function (parsedSound, scene, rootUrl, sourceSound) {
  7323. var soundName = parsedSound.name;
  7324. var soundUrl;
  7325. if (parsedSound.url) {
  7326. soundUrl = rootUrl + parsedSound.url;
  7327. }
  7328. else {
  7329. soundUrl = rootUrl + soundName;
  7330. }
  7331. var options = {
  7332. autoplay: parsedSound.autoplay, loop: parsedSound.loop, volume: parsedSound.volume,
  7333. spatialSound: parsedSound.spatialSound, maxDistance: parsedSound.maxDistance,
  7334. rolloffFactor: parsedSound.rolloffFactor,
  7335. refDistance: parsedSound.refDistance,
  7336. distanceModel: parsedSound.distanceModel,
  7337. playbackRate: parsedSound.playbackRate
  7338. };
  7339. var newSound;
  7340. if (!sourceSound) {
  7341. newSound = new Sound(soundName, soundUrl, scene, function () { scene._removePendingData(newSound); }, options);
  7342. scene._addPendingData(newSound);
  7343. }
  7344. else {
  7345. var setBufferAndRun = function () {
  7346. if (sourceSound._isReadyToPlay) {
  7347. newSound._audioBuffer = sourceSound.getAudioBuffer();
  7348. newSound._isReadyToPlay = true;
  7349. if (newSound.autoplay) {
  7350. newSound.play();
  7351. }
  7352. }
  7353. else {
  7354. window.setTimeout(setBufferAndRun, 300);
  7355. }
  7356. };
  7357. newSound = new Sound(soundName, new ArrayBuffer(0), scene, null, options);
  7358. setBufferAndRun();
  7359. }
  7360. if (parsedSound.position) {
  7361. var soundPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.position);
  7362. newSound.setPosition(soundPosition);
  7363. }
  7364. if (parsedSound.isDirectional) {
  7365. newSound.setDirectionalCone(parsedSound.coneInnerAngle || 360, parsedSound.coneOuterAngle || 360, parsedSound.coneOuterGain || 0);
  7366. if (parsedSound.localDirectionToMesh) {
  7367. var localDirectionToMesh = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.localDirectionToMesh);
  7368. newSound.setLocalDirectionToMesh(localDirectionToMesh);
  7369. }
  7370. }
  7371. if (parsedSound.connectedMeshId) {
  7372. var connectedMesh = scene.getMeshByID(parsedSound.connectedMeshId);
  7373. if (connectedMesh) {
  7374. newSound.attachToMesh(connectedMesh);
  7375. }
  7376. }
  7377. return newSound;
  7378. };
  7379. /** @hidden */
  7380. Sound._SceneComponentInitialization = function (_) {
  7381. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AudioSceneComponent");
  7382. };
  7383. return Sound;
  7384. }());
  7385. /***/ }),
  7386. /***/ "./Audio/soundTrack.ts":
  7387. /*!*****************************!*\
  7388. !*** ./Audio/soundTrack.ts ***!
  7389. \*****************************/
  7390. /*! exports provided: SoundTrack */
  7391. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7392. "use strict";
  7393. __webpack_require__.r(__webpack_exports__);
  7394. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return SoundTrack; });
  7395. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  7396. /**
  7397. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  7398. * It will be also used in a future release to apply effects on a specific track.
  7399. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7400. */
  7401. var SoundTrack = /** @class */ (function () {
  7402. /**
  7403. * Creates a new sound track.
  7404. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7405. * @param scene Define the scene the sound track belongs to
  7406. * @param options
  7407. */
  7408. function SoundTrack(scene, options) {
  7409. if (options === void 0) { options = {}; }
  7410. /**
  7411. * The unique identifier of the sound track in the scene.
  7412. */
  7413. this.id = -1;
  7414. this._isMainTrack = false;
  7415. this._isInitialized = false;
  7416. this._scene = scene;
  7417. this.soundCollection = new Array();
  7418. this._options = options;
  7419. if (!this._isMainTrack && this._scene.soundTracks) {
  7420. this._scene.soundTracks.push(this);
  7421. this.id = this._scene.soundTracks.length - 1;
  7422. }
  7423. }
  7424. SoundTrack.prototype._initializeSoundTrackAudioGraph = function () {
  7425. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext) {
  7426. this._outputAudioNode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext.createGain();
  7427. this._outputAudioNode.connect(_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7428. if (this._options) {
  7429. if (this._options.volume) {
  7430. this._outputAudioNode.gain.value = this._options.volume;
  7431. }
  7432. if (this._options.mainTrack) {
  7433. this._isMainTrack = this._options.mainTrack;
  7434. }
  7435. }
  7436. this._isInitialized = true;
  7437. }
  7438. };
  7439. /**
  7440. * Release the sound track and its associated resources
  7441. */
  7442. SoundTrack.prototype.dispose = function () {
  7443. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7444. if (this._connectedAnalyser) {
  7445. this._connectedAnalyser.stopDebugCanvas();
  7446. }
  7447. while (this.soundCollection.length) {
  7448. this.soundCollection[0].dispose();
  7449. }
  7450. if (this._outputAudioNode) {
  7451. this._outputAudioNode.disconnect();
  7452. }
  7453. this._outputAudioNode = null;
  7454. }
  7455. };
  7456. /**
  7457. * Adds a sound to this sound track
  7458. * @param sound define the cound to add
  7459. * @ignoreNaming
  7460. */
  7461. SoundTrack.prototype.AddSound = function (sound) {
  7462. if (!this._isInitialized) {
  7463. this._initializeSoundTrackAudioGraph();
  7464. }
  7465. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7466. sound.connectToSoundTrackAudioNode(this._outputAudioNode);
  7467. }
  7468. if (sound.soundTrackId) {
  7469. if (sound.soundTrackId === -1) {
  7470. this._scene.mainSoundTrack.RemoveSound(sound);
  7471. }
  7472. else if (this._scene.soundTracks) {
  7473. this._scene.soundTracks[sound.soundTrackId].RemoveSound(sound);
  7474. }
  7475. }
  7476. this.soundCollection.push(sound);
  7477. sound.soundTrackId = this.id;
  7478. };
  7479. /**
  7480. * Removes a sound to this sound track
  7481. * @param sound define the cound to remove
  7482. * @ignoreNaming
  7483. */
  7484. SoundTrack.prototype.RemoveSound = function (sound) {
  7485. var index = this.soundCollection.indexOf(sound);
  7486. if (index !== -1) {
  7487. this.soundCollection.splice(index, 1);
  7488. }
  7489. };
  7490. /**
  7491. * Set a global volume for the full sound track.
  7492. * @param newVolume Define the new volume of the sound track
  7493. */
  7494. SoundTrack.prototype.setVolume = function (newVolume) {
  7495. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7496. this._outputAudioNode.gain.value = newVolume;
  7497. }
  7498. };
  7499. /**
  7500. * Switch the panning model to HRTF:
  7501. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  7502. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7503. */
  7504. SoundTrack.prototype.switchPanningModelToHRTF = function () {
  7505. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7506. for (var i = 0; i < this.soundCollection.length; i++) {
  7507. this.soundCollection[i].switchPanningModelToHRTF();
  7508. }
  7509. }
  7510. };
  7511. /**
  7512. * Switch the panning model to Equal Power:
  7513. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  7514. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7515. */
  7516. SoundTrack.prototype.switchPanningModelToEqualPower = function () {
  7517. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7518. for (var i = 0; i < this.soundCollection.length; i++) {
  7519. this.soundCollection[i].switchPanningModelToEqualPower();
  7520. }
  7521. }
  7522. };
  7523. /**
  7524. * Connect the sound track to an audio analyser allowing some amazing
  7525. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  7526. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  7527. * @param analyser The analyser to connect to the engine
  7528. */
  7529. SoundTrack.prototype.connectToAnalyser = function (analyser) {
  7530. if (this._connectedAnalyser) {
  7531. this._connectedAnalyser.stopDebugCanvas();
  7532. }
  7533. this._connectedAnalyser = analyser;
  7534. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7535. this._outputAudioNode.disconnect();
  7536. this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7537. }
  7538. };
  7539. return SoundTrack;
  7540. }());
  7541. /***/ }),
  7542. /***/ "./Audio/weightedsound.ts":
  7543. /*!********************************!*\
  7544. !*** ./Audio/weightedsound.ts ***!
  7545. \********************************/
  7546. /*! exports provided: WeightedSound */
  7547. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7548. "use strict";
  7549. __webpack_require__.r(__webpack_exports__);
  7550. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return WeightedSound; });
  7551. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  7552. /**
  7553. * Wraps one or more Sound objects and selects one with random weight for playback.
  7554. */
  7555. var WeightedSound = /** @class */ (function () {
  7556. /**
  7557. * Creates a new WeightedSound from the list of sounds given.
  7558. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  7559. * @param sounds Array of Sounds that will be selected from.
  7560. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  7561. */
  7562. function WeightedSound(loop, sounds, weights) {
  7563. var _this = this;
  7564. /** When true a Sound will be selected and played when the current playing Sound completes. */
  7565. this.loop = false;
  7566. this._coneInnerAngle = 360;
  7567. this._coneOuterAngle = 360;
  7568. this._volume = 1;
  7569. /** A Sound is currently playing. */
  7570. this.isPlaying = false;
  7571. /** A Sound is currently paused. */
  7572. this.isPaused = false;
  7573. this._sounds = [];
  7574. this._weights = [];
  7575. if (sounds.length !== weights.length) {
  7576. throw new Error('Sounds length does not equal weights length');
  7577. }
  7578. this.loop = loop;
  7579. this._weights = weights;
  7580. // Normalize the weights
  7581. var weightSum = 0;
  7582. for (var _i = 0, weights_1 = weights; _i < weights_1.length; _i++) {
  7583. var weight = weights_1[_i];
  7584. weightSum += weight;
  7585. }
  7586. var invWeightSum = weightSum > 0 ? 1 / weightSum : 0;
  7587. for (var i = 0; i < this._weights.length; i++) {
  7588. this._weights[i] *= invWeightSum;
  7589. }
  7590. this._sounds = sounds;
  7591. for (var _a = 0, _b = this._sounds; _a < _b.length; _a++) {
  7592. var sound = _b[_a];
  7593. sound.onEndedObservable.add(function () { _this._onended(); });
  7594. }
  7595. }
  7596. Object.defineProperty(WeightedSound.prototype, "directionalConeInnerAngle", {
  7597. /**
  7598. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  7599. */
  7600. get: function () {
  7601. return this._coneInnerAngle;
  7602. },
  7603. /**
  7604. * The size of cone in degress for a directional sound in which there will be no attenuation.
  7605. */
  7606. set: function (value) {
  7607. if (value !== this._coneInnerAngle) {
  7608. if (this._coneOuterAngle < value) {
  7609. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7610. return;
  7611. }
  7612. this._coneInnerAngle = value;
  7613. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7614. var sound = _a[_i];
  7615. sound.directionalConeInnerAngle = value;
  7616. }
  7617. }
  7618. },
  7619. enumerable: true,
  7620. configurable: true
  7621. });
  7622. Object.defineProperty(WeightedSound.prototype, "directionalConeOuterAngle", {
  7623. /**
  7624. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7625. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7626. */
  7627. get: function () {
  7628. return this._coneOuterAngle;
  7629. },
  7630. /**
  7631. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7632. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7633. */
  7634. set: function (value) {
  7635. if (value !== this._coneOuterAngle) {
  7636. if (value < this._coneInnerAngle) {
  7637. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7638. return;
  7639. }
  7640. this._coneOuterAngle = value;
  7641. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7642. var sound = _a[_i];
  7643. sound.directionalConeOuterAngle = value;
  7644. }
  7645. }
  7646. },
  7647. enumerable: true,
  7648. configurable: true
  7649. });
  7650. Object.defineProperty(WeightedSound.prototype, "volume", {
  7651. /**
  7652. * Playback volume.
  7653. */
  7654. get: function () {
  7655. return this._volume;
  7656. },
  7657. /**
  7658. * Playback volume.
  7659. */
  7660. set: function (value) {
  7661. if (value !== this._volume) {
  7662. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7663. var sound = _a[_i];
  7664. sound.setVolume(value);
  7665. }
  7666. }
  7667. },
  7668. enumerable: true,
  7669. configurable: true
  7670. });
  7671. WeightedSound.prototype._onended = function () {
  7672. if (this._currentIndex !== undefined) {
  7673. this._sounds[this._currentIndex].autoplay = false;
  7674. }
  7675. if (this.loop && this.isPlaying) {
  7676. this.play();
  7677. }
  7678. else {
  7679. this.isPlaying = false;
  7680. }
  7681. };
  7682. /**
  7683. * Suspend playback
  7684. */
  7685. WeightedSound.prototype.pause = function () {
  7686. this.isPaused = true;
  7687. if (this._currentIndex !== undefined) {
  7688. this._sounds[this._currentIndex].pause();
  7689. }
  7690. };
  7691. /**
  7692. * Stop playback
  7693. */
  7694. WeightedSound.prototype.stop = function () {
  7695. this.isPlaying = false;
  7696. if (this._currentIndex !== undefined) {
  7697. this._sounds[this._currentIndex].stop();
  7698. }
  7699. };
  7700. /**
  7701. * Start playback.
  7702. * @param startOffset Position the clip head at a specific time in seconds.
  7703. */
  7704. WeightedSound.prototype.play = function (startOffset) {
  7705. if (!this.isPaused) {
  7706. this.stop();
  7707. var randomValue = Math.random();
  7708. var total = 0;
  7709. for (var i = 0; i < this._weights.length; i++) {
  7710. total += this._weights[i];
  7711. if (randomValue <= total) {
  7712. this._currentIndex = i;
  7713. break;
  7714. }
  7715. }
  7716. }
  7717. var sound = this._sounds[this._currentIndex];
  7718. if (sound.isReady()) {
  7719. sound.play(0, this.isPaused ? undefined : startOffset);
  7720. }
  7721. else {
  7722. sound.autoplay = true;
  7723. }
  7724. this.isPlaying = true;
  7725. this.isPaused = false;
  7726. };
  7727. return WeightedSound;
  7728. }());
  7729. /***/ }),
  7730. /***/ "./Behaviors/Cameras/autoRotationBehavior.ts":
  7731. /*!***************************************************!*\
  7732. !*** ./Behaviors/Cameras/autoRotationBehavior.ts ***!
  7733. \***************************************************/
  7734. /*! exports provided: AutoRotationBehavior */
  7735. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7736. "use strict";
  7737. __webpack_require__.r(__webpack_exports__);
  7738. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return AutoRotationBehavior; });
  7739. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  7740. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  7741. /**
  7742. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  7743. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7744. */
  7745. var AutoRotationBehavior = /** @class */ (function () {
  7746. function AutoRotationBehavior() {
  7747. this._zoomStopsAnimation = false;
  7748. this._idleRotationSpeed = 0.05;
  7749. this._idleRotationWaitTime = 2000;
  7750. this._idleRotationSpinupTime = 2000;
  7751. this._isPointerDown = false;
  7752. this._lastFrameTime = null;
  7753. this._lastInteractionTime = -Infinity;
  7754. this._cameraRotationSpeed = 0;
  7755. this._lastFrameRadius = 0;
  7756. }
  7757. Object.defineProperty(AutoRotationBehavior.prototype, "name", {
  7758. /**
  7759. * Gets the name of the behavior.
  7760. */
  7761. get: function () {
  7762. return "AutoRotation";
  7763. },
  7764. enumerable: true,
  7765. configurable: true
  7766. });
  7767. Object.defineProperty(AutoRotationBehavior.prototype, "zoomStopsAnimation", {
  7768. /**
  7769. * Gets the flag that indicates if user zooming should stop animation.
  7770. */
  7771. get: function () {
  7772. return this._zoomStopsAnimation;
  7773. },
  7774. /**
  7775. * Sets the flag that indicates if user zooming should stop animation.
  7776. */
  7777. set: function (flag) {
  7778. this._zoomStopsAnimation = flag;
  7779. },
  7780. enumerable: true,
  7781. configurable: true
  7782. });
  7783. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpeed", {
  7784. /**
  7785. * Gets the default speed at which the camera rotates around the model.
  7786. */
  7787. get: function () {
  7788. return this._idleRotationSpeed;
  7789. },
  7790. /**
  7791. * Sets the default speed at which the camera rotates around the model.
  7792. */
  7793. set: function (speed) {
  7794. this._idleRotationSpeed = speed;
  7795. },
  7796. enumerable: true,
  7797. configurable: true
  7798. });
  7799. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationWaitTime", {
  7800. /**
  7801. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  7802. */
  7803. get: function () {
  7804. return this._idleRotationWaitTime;
  7805. },
  7806. /**
  7807. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  7808. */
  7809. set: function (time) {
  7810. this._idleRotationWaitTime = time;
  7811. },
  7812. enumerable: true,
  7813. configurable: true
  7814. });
  7815. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpinupTime", {
  7816. /**
  7817. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7818. */
  7819. get: function () {
  7820. return this._idleRotationSpinupTime;
  7821. },
  7822. /**
  7823. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7824. */
  7825. set: function (time) {
  7826. this._idleRotationSpinupTime = time;
  7827. },
  7828. enumerable: true,
  7829. configurable: true
  7830. });
  7831. Object.defineProperty(AutoRotationBehavior.prototype, "rotationInProgress", {
  7832. /**
  7833. * Gets a value indicating if the camera is currently rotating because of this behavior
  7834. */
  7835. get: function () {
  7836. return Math.abs(this._cameraRotationSpeed) > 0;
  7837. },
  7838. enumerable: true,
  7839. configurable: true
  7840. });
  7841. /**
  7842. * Initializes the behavior.
  7843. */
  7844. AutoRotationBehavior.prototype.init = function () {
  7845. // Do notihng
  7846. };
  7847. /**
  7848. * Attaches the behavior to its arc rotate camera.
  7849. * @param camera Defines the camera to attach the behavior to
  7850. */
  7851. AutoRotationBehavior.prototype.attach = function (camera) {
  7852. var _this = this;
  7853. this._attachedCamera = camera;
  7854. var scene = this._attachedCamera.getScene();
  7855. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  7856. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  7857. _this._isPointerDown = true;
  7858. return;
  7859. }
  7860. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  7861. _this._isPointerDown = false;
  7862. }
  7863. });
  7864. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  7865. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7866. var dt = 0;
  7867. if (_this._lastFrameTime != null) {
  7868. dt = now - _this._lastFrameTime;
  7869. }
  7870. _this._lastFrameTime = now;
  7871. // Stop the animation if there is user interaction and the animation should stop for this interaction
  7872. _this._applyUserInteraction();
  7873. var timeToRotation = now - _this._lastInteractionTime - _this._idleRotationWaitTime;
  7874. var scale = Math.max(Math.min(timeToRotation / (_this._idleRotationSpinupTime), 1), 0);
  7875. _this._cameraRotationSpeed = _this._idleRotationSpeed * scale;
  7876. // Step camera rotation by rotation speed
  7877. if (_this._attachedCamera) {
  7878. _this._attachedCamera.alpha -= _this._cameraRotationSpeed * (dt / 1000);
  7879. }
  7880. });
  7881. };
  7882. /**
  7883. * Detaches the behavior from its current arc rotate camera.
  7884. */
  7885. AutoRotationBehavior.prototype.detach = function () {
  7886. if (!this._attachedCamera) {
  7887. return;
  7888. }
  7889. var scene = this._attachedCamera.getScene();
  7890. if (this._onPrePointerObservableObserver) {
  7891. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  7892. }
  7893. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  7894. this._attachedCamera = null;
  7895. };
  7896. /**
  7897. * Returns true if user is scrolling.
  7898. * @return true if user is scrolling.
  7899. */
  7900. AutoRotationBehavior.prototype._userIsZooming = function () {
  7901. if (!this._attachedCamera) {
  7902. return false;
  7903. }
  7904. return this._attachedCamera.inertialRadiusOffset !== 0;
  7905. };
  7906. AutoRotationBehavior.prototype._shouldAnimationStopForInteraction = function () {
  7907. if (!this._attachedCamera) {
  7908. return false;
  7909. }
  7910. var zoomHasHitLimit = false;
  7911. if (this._lastFrameRadius === this._attachedCamera.radius && this._attachedCamera.inertialRadiusOffset !== 0) {
  7912. zoomHasHitLimit = true;
  7913. }
  7914. // Update the record of previous radius - works as an approx. indicator of hitting radius limits
  7915. this._lastFrameRadius = this._attachedCamera.radius;
  7916. return this._zoomStopsAnimation ? zoomHasHitLimit : this._userIsZooming();
  7917. };
  7918. /**
  7919. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  7920. */
  7921. AutoRotationBehavior.prototype._applyUserInteraction = function () {
  7922. if (this._userIsMoving() && !this._shouldAnimationStopForInteraction()) {
  7923. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7924. }
  7925. };
  7926. // Tools
  7927. AutoRotationBehavior.prototype._userIsMoving = function () {
  7928. if (!this._attachedCamera) {
  7929. return false;
  7930. }
  7931. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  7932. this._attachedCamera.inertialBetaOffset !== 0 ||
  7933. this._attachedCamera.inertialRadiusOffset !== 0 ||
  7934. this._attachedCamera.inertialPanningX !== 0 ||
  7935. this._attachedCamera.inertialPanningY !== 0 ||
  7936. this._isPointerDown;
  7937. };
  7938. return AutoRotationBehavior;
  7939. }());
  7940. /***/ }),
  7941. /***/ "./Behaviors/Cameras/bouncingBehavior.ts":
  7942. /*!***********************************************!*\
  7943. !*** ./Behaviors/Cameras/bouncingBehavior.ts ***!
  7944. \***********************************************/
  7945. /*! exports provided: BouncingBehavior */
  7946. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7947. "use strict";
  7948. __webpack_require__.r(__webpack_exports__);
  7949. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return BouncingBehavior; });
  7950. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  7951. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  7952. /**
  7953. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  7954. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7955. */
  7956. var BouncingBehavior = /** @class */ (function () {
  7957. function BouncingBehavior() {
  7958. /**
  7959. * The duration of the animation, in milliseconds
  7960. */
  7961. this.transitionDuration = 450;
  7962. /**
  7963. * Length of the distance animated by the transition when lower radius is reached
  7964. */
  7965. this.lowerRadiusTransitionRange = 2;
  7966. /**
  7967. * Length of the distance animated by the transition when upper radius is reached
  7968. */
  7969. this.upperRadiusTransitionRange = -2;
  7970. this._autoTransitionRange = false;
  7971. // Animations
  7972. this._radiusIsAnimating = false;
  7973. this._radiusBounceTransition = null;
  7974. this._animatables = new Array();
  7975. }
  7976. Object.defineProperty(BouncingBehavior.prototype, "name", {
  7977. /**
  7978. * Gets the name of the behavior.
  7979. */
  7980. get: function () {
  7981. return "Bouncing";
  7982. },
  7983. enumerable: true,
  7984. configurable: true
  7985. });
  7986. Object.defineProperty(BouncingBehavior.prototype, "autoTransitionRange", {
  7987. /**
  7988. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  7989. */
  7990. get: function () {
  7991. return this._autoTransitionRange;
  7992. },
  7993. /**
  7994. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  7995. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  7996. */
  7997. set: function (value) {
  7998. var _this = this;
  7999. if (this._autoTransitionRange === value) {
  8000. return;
  8001. }
  8002. this._autoTransitionRange = value;
  8003. var camera = this._attachedCamera;
  8004. if (!camera) {
  8005. return;
  8006. }
  8007. if (value) {
  8008. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  8009. if (!mesh) {
  8010. return;
  8011. }
  8012. mesh.computeWorldMatrix(true);
  8013. var diagonal = mesh.getBoundingInfo().diagonalLength;
  8014. _this.lowerRadiusTransitionRange = diagonal * 0.05;
  8015. _this.upperRadiusTransitionRange = diagonal * 0.05;
  8016. });
  8017. }
  8018. else if (this._onMeshTargetChangedObserver) {
  8019. camera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8020. }
  8021. },
  8022. enumerable: true,
  8023. configurable: true
  8024. });
  8025. /**
  8026. * Initializes the behavior.
  8027. */
  8028. BouncingBehavior.prototype.init = function () {
  8029. // Do notihng
  8030. };
  8031. /**
  8032. * Attaches the behavior to its arc rotate camera.
  8033. * @param camera Defines the camera to attach the behavior to
  8034. */
  8035. BouncingBehavior.prototype.attach = function (camera) {
  8036. var _this = this;
  8037. this._attachedCamera = camera;
  8038. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8039. if (!_this._attachedCamera) {
  8040. return;
  8041. }
  8042. // Add the bounce animation to the lower radius limit
  8043. if (_this._isRadiusAtLimit(_this._attachedCamera.lowerRadiusLimit)) {
  8044. _this._applyBoundRadiusAnimation(_this.lowerRadiusTransitionRange);
  8045. }
  8046. // Add the bounce animation to the upper radius limit
  8047. if (_this._isRadiusAtLimit(_this._attachedCamera.upperRadiusLimit)) {
  8048. _this._applyBoundRadiusAnimation(_this.upperRadiusTransitionRange);
  8049. }
  8050. });
  8051. };
  8052. /**
  8053. * Detaches the behavior from its current arc rotate camera.
  8054. */
  8055. BouncingBehavior.prototype.detach = function () {
  8056. if (!this._attachedCamera) {
  8057. return;
  8058. }
  8059. if (this._onAfterCheckInputsObserver) {
  8060. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8061. }
  8062. if (this._onMeshTargetChangedObserver) {
  8063. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8064. }
  8065. this._attachedCamera = null;
  8066. };
  8067. /**
  8068. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  8069. * @param radiusLimit The limit to check against.
  8070. * @return Bool to indicate if at limit.
  8071. */
  8072. BouncingBehavior.prototype._isRadiusAtLimit = function (radiusLimit) {
  8073. if (!this._attachedCamera) {
  8074. return false;
  8075. }
  8076. if (this._attachedCamera.radius === radiusLimit && !this._radiusIsAnimating) {
  8077. return true;
  8078. }
  8079. return false;
  8080. };
  8081. /**
  8082. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  8083. * @param radiusDelta The delta by which to animate to. Can be negative.
  8084. */
  8085. BouncingBehavior.prototype._applyBoundRadiusAnimation = function (radiusDelta) {
  8086. var _this = this;
  8087. if (!this._attachedCamera) {
  8088. return;
  8089. }
  8090. if (!this._radiusBounceTransition) {
  8091. BouncingBehavior.EasingFunction.setEasingMode(BouncingBehavior.EasingMode);
  8092. this._radiusBounceTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT, 60, BouncingBehavior.EasingFunction);
  8093. }
  8094. // Prevent zoom until bounce has completed
  8095. this._cachedWheelPrecision = this._attachedCamera.wheelPrecision;
  8096. this._attachedCamera.wheelPrecision = Infinity;
  8097. this._attachedCamera.inertialRadiusOffset = 0;
  8098. // Animate to the radius limit
  8099. this.stopAllAnimations();
  8100. this._radiusIsAnimating = true;
  8101. 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(); });
  8102. if (animatable) {
  8103. this._animatables.push(animatable);
  8104. }
  8105. };
  8106. /**
  8107. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  8108. */
  8109. BouncingBehavior.prototype._clearAnimationLocks = function () {
  8110. this._radiusIsAnimating = false;
  8111. if (this._attachedCamera) {
  8112. this._attachedCamera.wheelPrecision = this._cachedWheelPrecision;
  8113. }
  8114. };
  8115. /**
  8116. * Stops and removes all animations that have been applied to the camera
  8117. */
  8118. BouncingBehavior.prototype.stopAllAnimations = function () {
  8119. if (this._attachedCamera) {
  8120. this._attachedCamera.animations = [];
  8121. }
  8122. while (this._animatables.length) {
  8123. this._animatables[0].onAnimationEnd = null;
  8124. this._animatables[0].stop();
  8125. this._animatables.shift();
  8126. }
  8127. };
  8128. /**
  8129. * The easing function used by animations
  8130. */
  8131. BouncingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["BackEase"](0.3);
  8132. /**
  8133. * The easing mode used by animations
  8134. */
  8135. BouncingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEOUT;
  8136. return BouncingBehavior;
  8137. }());
  8138. /***/ }),
  8139. /***/ "./Behaviors/Cameras/framingBehavior.ts":
  8140. /*!**********************************************!*\
  8141. !*** ./Behaviors/Cameras/framingBehavior.ts ***!
  8142. \**********************************************/
  8143. /*! exports provided: FramingBehavior */
  8144. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8145. "use strict";
  8146. __webpack_require__.r(__webpack_exports__);
  8147. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return FramingBehavior; });
  8148. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  8149. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  8150. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  8151. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  8152. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8153. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  8154. /**
  8155. * 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.
  8156. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  8157. */
  8158. var FramingBehavior = /** @class */ (function () {
  8159. function FramingBehavior() {
  8160. this._mode = FramingBehavior.FitFrustumSidesMode;
  8161. this._radiusScale = 1.0;
  8162. this._positionScale = 0.5;
  8163. this._defaultElevation = 0.3;
  8164. this._elevationReturnTime = 1500;
  8165. this._elevationReturnWaitTime = 1000;
  8166. this._zoomStopsAnimation = false;
  8167. this._framingTime = 1500;
  8168. /**
  8169. * Define if the behavior should automatically change the configured
  8170. * camera limits and sensibilities.
  8171. */
  8172. this.autoCorrectCameraLimitsAndSensibility = true;
  8173. this._isPointerDown = false;
  8174. this._lastInteractionTime = -Infinity;
  8175. // Framing control
  8176. this._animatables = new Array();
  8177. this._betaIsAnimating = false;
  8178. }
  8179. Object.defineProperty(FramingBehavior.prototype, "name", {
  8180. /**
  8181. * Gets the name of the behavior.
  8182. */
  8183. get: function () {
  8184. return "Framing";
  8185. },
  8186. enumerable: true,
  8187. configurable: true
  8188. });
  8189. Object.defineProperty(FramingBehavior.prototype, "mode", {
  8190. /**
  8191. * Gets current mode used by the behavior.
  8192. */
  8193. get: function () {
  8194. return this._mode;
  8195. },
  8196. /**
  8197. * Sets the current mode used by the behavior
  8198. */
  8199. set: function (mode) {
  8200. this._mode = mode;
  8201. },
  8202. enumerable: true,
  8203. configurable: true
  8204. });
  8205. Object.defineProperty(FramingBehavior.prototype, "radiusScale", {
  8206. /**
  8207. * Gets the scale applied to the radius
  8208. */
  8209. get: function () {
  8210. return this._radiusScale;
  8211. },
  8212. /**
  8213. * Sets the scale applied to the radius (1 by default)
  8214. */
  8215. set: function (radius) {
  8216. this._radiusScale = radius;
  8217. },
  8218. enumerable: true,
  8219. configurable: true
  8220. });
  8221. Object.defineProperty(FramingBehavior.prototype, "positionScale", {
  8222. /**
  8223. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8224. */
  8225. get: function () {
  8226. return this._positionScale;
  8227. },
  8228. /**
  8229. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8230. */
  8231. set: function (scale) {
  8232. this._positionScale = scale;
  8233. },
  8234. enumerable: true,
  8235. configurable: true
  8236. });
  8237. Object.defineProperty(FramingBehavior.prototype, "defaultElevation", {
  8238. /**
  8239. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8240. * behaviour is triggered, in radians.
  8241. */
  8242. get: function () {
  8243. return this._defaultElevation;
  8244. },
  8245. /**
  8246. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8247. * behaviour is triggered, in radians.
  8248. */
  8249. set: function (elevation) {
  8250. this._defaultElevation = elevation;
  8251. },
  8252. enumerable: true,
  8253. configurable: true
  8254. });
  8255. Object.defineProperty(FramingBehavior.prototype, "elevationReturnTime", {
  8256. /**
  8257. * Gets the time (in milliseconds) taken to return to the default beta position.
  8258. * Negative value indicates camera should not return to default.
  8259. */
  8260. get: function () {
  8261. return this._elevationReturnTime;
  8262. },
  8263. /**
  8264. * Sets the time (in milliseconds) taken to return to the default beta position.
  8265. * Negative value indicates camera should not return to default.
  8266. */
  8267. set: function (speed) {
  8268. this._elevationReturnTime = speed;
  8269. },
  8270. enumerable: true,
  8271. configurable: true
  8272. });
  8273. Object.defineProperty(FramingBehavior.prototype, "elevationReturnWaitTime", {
  8274. /**
  8275. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8276. */
  8277. get: function () {
  8278. return this._elevationReturnWaitTime;
  8279. },
  8280. /**
  8281. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8282. */
  8283. set: function (time) {
  8284. this._elevationReturnWaitTime = time;
  8285. },
  8286. enumerable: true,
  8287. configurable: true
  8288. });
  8289. Object.defineProperty(FramingBehavior.prototype, "zoomStopsAnimation", {
  8290. /**
  8291. * Gets the flag that indicates if user zooming should stop animation.
  8292. */
  8293. get: function () {
  8294. return this._zoomStopsAnimation;
  8295. },
  8296. /**
  8297. * Sets the flag that indicates if user zooming should stop animation.
  8298. */
  8299. set: function (flag) {
  8300. this._zoomStopsAnimation = flag;
  8301. },
  8302. enumerable: true,
  8303. configurable: true
  8304. });
  8305. Object.defineProperty(FramingBehavior.prototype, "framingTime", {
  8306. /**
  8307. * Gets the transition time when framing the mesh, in milliseconds
  8308. */
  8309. get: function () {
  8310. return this._framingTime;
  8311. },
  8312. /**
  8313. * Sets the transition time when framing the mesh, in milliseconds
  8314. */
  8315. set: function (time) {
  8316. this._framingTime = time;
  8317. },
  8318. enumerable: true,
  8319. configurable: true
  8320. });
  8321. /**
  8322. * Initializes the behavior.
  8323. */
  8324. FramingBehavior.prototype.init = function () {
  8325. // Do notihng
  8326. };
  8327. /**
  8328. * Attaches the behavior to its arc rotate camera.
  8329. * @param camera Defines the camera to attach the behavior to
  8330. */
  8331. FramingBehavior.prototype.attach = function (camera) {
  8332. var _this = this;
  8333. this._attachedCamera = camera;
  8334. var scene = this._attachedCamera.getScene();
  8335. FramingBehavior.EasingFunction.setEasingMode(FramingBehavior.EasingMode);
  8336. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  8337. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  8338. _this._isPointerDown = true;
  8339. return;
  8340. }
  8341. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  8342. _this._isPointerDown = false;
  8343. }
  8344. });
  8345. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  8346. if (mesh) {
  8347. _this.zoomOnMesh(mesh);
  8348. }
  8349. });
  8350. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8351. // Stop the animation if there is user interaction and the animation should stop for this interaction
  8352. _this._applyUserInteraction();
  8353. // Maintain the camera above the ground. If the user pulls the camera beneath the ground plane, lift it
  8354. // back to the default position after a given timeout
  8355. _this._maintainCameraAboveGround();
  8356. });
  8357. };
  8358. /**
  8359. * Detaches the behavior from its current arc rotate camera.
  8360. */
  8361. FramingBehavior.prototype.detach = function () {
  8362. if (!this._attachedCamera) {
  8363. return;
  8364. }
  8365. var scene = this._attachedCamera.getScene();
  8366. if (this._onPrePointerObservableObserver) {
  8367. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  8368. }
  8369. if (this._onAfterCheckInputsObserver) {
  8370. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8371. }
  8372. if (this._onMeshTargetChangedObserver) {
  8373. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8374. }
  8375. this._attachedCamera = null;
  8376. };
  8377. /**
  8378. * Targets the given mesh and updates zoom level accordingly.
  8379. * @param mesh The mesh to target.
  8380. * @param radius Optional. If a cached radius position already exists, overrides default.
  8381. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8382. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8383. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8384. */
  8385. FramingBehavior.prototype.zoomOnMesh = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8386. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8387. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8388. mesh.computeWorldMatrix(true);
  8389. var boundingBox = mesh.getBoundingInfo().boundingBox;
  8390. this.zoomOnBoundingInfo(boundingBox.minimumWorld, boundingBox.maximumWorld, focusOnOriginXZ, onAnimationEnd);
  8391. };
  8392. /**
  8393. * Targets the given mesh with its children and updates zoom level accordingly.
  8394. * @param mesh The mesh to target.
  8395. * @param radius Optional. If a cached radius position already exists, overrides default.
  8396. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8397. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8398. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8399. */
  8400. FramingBehavior.prototype.zoomOnMeshHierarchy = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8401. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8402. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8403. mesh.computeWorldMatrix(true);
  8404. var boundingBox = mesh.getHierarchyBoundingVectors(true);
  8405. this.zoomOnBoundingInfo(boundingBox.min, boundingBox.max, focusOnOriginXZ, onAnimationEnd);
  8406. };
  8407. /**
  8408. * Targets the given meshes with their children and updates zoom level accordingly.
  8409. * @param meshes The mesh to target.
  8410. * @param radius Optional. If a cached radius position already exists, overrides default.
  8411. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8412. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8413. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8414. */
  8415. FramingBehavior.prototype.zoomOnMeshesHierarchy = function (meshes, focusOnOriginXZ, onAnimationEnd) {
  8416. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8417. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8418. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  8419. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  8420. for (var i = 0; i < meshes.length; i++) {
  8421. var boundingInfo = meshes[i].getHierarchyBoundingVectors(true);
  8422. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.min, min, max);
  8423. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.max, min, max);
  8424. }
  8425. this.zoomOnBoundingInfo(min, max, focusOnOriginXZ, onAnimationEnd);
  8426. };
  8427. /**
  8428. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  8429. * @param minimumWorld Determines the smaller position of the bounding box extend
  8430. * @param maximumWorld Determines the bigger position of the bounding box extend
  8431. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8432. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8433. */
  8434. FramingBehavior.prototype.zoomOnBoundingInfo = function (minimumWorld, maximumWorld, focusOnOriginXZ, onAnimationEnd) {
  8435. var _this = this;
  8436. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8437. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8438. var zoomTarget;
  8439. if (!this._attachedCamera) {
  8440. return;
  8441. }
  8442. // Find target by interpolating from bottom of bounding box in world-space to top via framingPositionY
  8443. var bottom = minimumWorld.y;
  8444. var top = maximumWorld.y;
  8445. var zoomTargetY = bottom + (top - bottom) * this._positionScale;
  8446. var radiusWorld = maximumWorld.subtract(minimumWorld).scale(0.5);
  8447. if (focusOnOriginXZ) {
  8448. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, zoomTargetY, 0);
  8449. }
  8450. else {
  8451. var centerWorld = minimumWorld.add(radiusWorld);
  8452. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](centerWorld.x, zoomTargetY, centerWorld.z);
  8453. }
  8454. if (!this._vectorTransition) {
  8455. this._vectorTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("target", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
  8456. }
  8457. this._betaIsAnimating = true;
  8458. var animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);
  8459. if (animatable) {
  8460. this._animatables.push(animatable);
  8461. }
  8462. // sets the radius and lower radius bounds
  8463. // Small delta ensures camera is not always at lower zoom limit.
  8464. var radius = 0;
  8465. if (this._mode === FramingBehavior.FitFrustumSidesMode) {
  8466. var position = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8467. if (this.autoCorrectCameraLimitsAndSensibility) {
  8468. this._attachedCamera.lowerRadiusLimit = radiusWorld.length() + this._attachedCamera.minZ;
  8469. }
  8470. radius = position;
  8471. }
  8472. else if (this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8473. radius = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8474. if (this.autoCorrectCameraLimitsAndSensibility && this._attachedCamera.lowerRadiusLimit === null) {
  8475. this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ;
  8476. }
  8477. }
  8478. // Set sensibilities
  8479. if (this.autoCorrectCameraLimitsAndSensibility) {
  8480. var extend = maximumWorld.subtract(minimumWorld).length();
  8481. this._attachedCamera.panningSensibility = 5000 / extend;
  8482. this._attachedCamera.wheelPrecision = 100 / radius;
  8483. }
  8484. // transition to new radius
  8485. if (!this._radiusTransition) {
  8486. this._radiusTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8487. }
  8488. animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function () {
  8489. _this.stopAllAnimations();
  8490. if (onAnimationEnd) {
  8491. onAnimationEnd();
  8492. }
  8493. if (_this._attachedCamera && _this._attachedCamera.useInputToRestoreState) {
  8494. _this._attachedCamera.storeState();
  8495. }
  8496. });
  8497. if (animatable) {
  8498. this._animatables.push(animatable);
  8499. }
  8500. };
  8501. /**
  8502. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  8503. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  8504. * frustum width.
  8505. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  8506. * to fully enclose the mesh in the viewing frustum.
  8507. */
  8508. FramingBehavior.prototype._calculateLowerRadiusFromModelBoundingSphere = function (minimumWorld, maximumWorld) {
  8509. var size = maximumWorld.subtract(minimumWorld);
  8510. var boxVectorGlobalDiagonal = size.length();
  8511. var frustumSlope = this._getFrustumSlope();
  8512. // Formula for setting distance
  8513. // (Good explanation: http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene)
  8514. var radiusWithoutFraming = boxVectorGlobalDiagonal * 0.5;
  8515. // Horizon distance
  8516. var radius = radiusWithoutFraming * this._radiusScale;
  8517. var distanceForHorizontalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.x * frustumSlope.x));
  8518. var distanceForVerticalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.y * frustumSlope.y));
  8519. var distance = Math.max(distanceForHorizontalFrustum, distanceForVerticalFrustum);
  8520. var camera = this._attachedCamera;
  8521. if (!camera) {
  8522. return 0;
  8523. }
  8524. if (camera.lowerRadiusLimit && this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8525. // Don't exceed the requested limit
  8526. distance = distance < camera.lowerRadiusLimit ? camera.lowerRadiusLimit : distance;
  8527. }
  8528. // Don't exceed the upper radius limit
  8529. if (camera.upperRadiusLimit) {
  8530. distance = distance > camera.upperRadiusLimit ? camera.upperRadiusLimit : distance;
  8531. }
  8532. return distance;
  8533. };
  8534. /**
  8535. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  8536. * is automatically returned to its default position (expected to be above ground plane).
  8537. */
  8538. FramingBehavior.prototype._maintainCameraAboveGround = function () {
  8539. var _this = this;
  8540. if (this._elevationReturnTime < 0) {
  8541. return;
  8542. }
  8543. var timeSinceInteraction = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now - this._lastInteractionTime;
  8544. var defaultBeta = Math.PI * 0.5 - this._defaultElevation;
  8545. var limitBeta = Math.PI * 0.5;
  8546. // Bring the camera back up if below the ground plane
  8547. if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > limitBeta && timeSinceInteraction >= this._elevationReturnWaitTime) {
  8548. this._betaIsAnimating = true;
  8549. //Transition to new position
  8550. this.stopAllAnimations();
  8551. if (!this._betaTransition) {
  8552. this._betaTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("beta", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8553. }
  8554. var animatabe = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("beta", defaultBeta, this._attachedCamera, this._attachedCamera.getScene(), 60, this._betaTransition, this._elevationReturnTime, function () {
  8555. _this._clearAnimationLocks();
  8556. _this.stopAllAnimations();
  8557. });
  8558. if (animatabe) {
  8559. this._animatables.push(animatabe);
  8560. }
  8561. }
  8562. };
  8563. /**
  8564. * Returns the frustum slope based on the canvas ratio and camera FOV
  8565. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  8566. */
  8567. FramingBehavior.prototype._getFrustumSlope = function () {
  8568. // Calculate the viewport ratio
  8569. // Aspect Ratio is Height/Width.
  8570. var camera = this._attachedCamera;
  8571. if (!camera) {
  8572. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"].Zero();
  8573. }
  8574. var engine = camera.getScene().getEngine();
  8575. var aspectRatio = engine.getAspectRatio(camera);
  8576. // Camera FOV is the vertical field of view (top-bottom) in radians.
  8577. // Slope of the frustum top/bottom planes in view space, relative to the forward vector.
  8578. var frustumSlopeY = Math.tan(camera.fov / 2);
  8579. // Slope of the frustum left/right planes in view space, relative to the forward vector.
  8580. // Provides the amount that one side (e.g. left) of the frustum gets wider for every unit
  8581. // along the forward vector.
  8582. var frustumSlopeX = frustumSlopeY * aspectRatio;
  8583. return new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"](frustumSlopeX, frustumSlopeY);
  8584. };
  8585. /**
  8586. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  8587. */
  8588. FramingBehavior.prototype._clearAnimationLocks = function () {
  8589. this._betaIsAnimating = false;
  8590. };
  8591. /**
  8592. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  8593. */
  8594. FramingBehavior.prototype._applyUserInteraction = function () {
  8595. if (this.isUserIsMoving) {
  8596. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now;
  8597. this.stopAllAnimations();
  8598. this._clearAnimationLocks();
  8599. }
  8600. };
  8601. /**
  8602. * Stops and removes all animations that have been applied to the camera
  8603. */
  8604. FramingBehavior.prototype.stopAllAnimations = function () {
  8605. if (this._attachedCamera) {
  8606. this._attachedCamera.animations = [];
  8607. }
  8608. while (this._animatables.length) {
  8609. if (this._animatables[0]) {
  8610. this._animatables[0].onAnimationEnd = null;
  8611. this._animatables[0].stop();
  8612. }
  8613. this._animatables.shift();
  8614. }
  8615. };
  8616. Object.defineProperty(FramingBehavior.prototype, "isUserIsMoving", {
  8617. /**
  8618. * Gets a value indicating if the user is moving the camera
  8619. */
  8620. get: function () {
  8621. if (!this._attachedCamera) {
  8622. return false;
  8623. }
  8624. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  8625. this._attachedCamera.inertialBetaOffset !== 0 ||
  8626. this._attachedCamera.inertialRadiusOffset !== 0 ||
  8627. this._attachedCamera.inertialPanningX !== 0 ||
  8628. this._attachedCamera.inertialPanningY !== 0 ||
  8629. this._isPointerDown;
  8630. },
  8631. enumerable: true,
  8632. configurable: true
  8633. });
  8634. /**
  8635. * The easing function used by animations
  8636. */
  8637. FramingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]();
  8638. /**
  8639. * The easing mode used by animations
  8640. */
  8641. FramingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEINOUT;
  8642. // Statics
  8643. /**
  8644. * The camera can move all the way towards the mesh.
  8645. */
  8646. FramingBehavior.IgnoreBoundsSizeMode = 0;
  8647. /**
  8648. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  8649. */
  8650. FramingBehavior.FitFrustumSidesMode = 1;
  8651. return FramingBehavior;
  8652. }());
  8653. /***/ }),
  8654. /***/ "./Behaviors/Cameras/index.ts":
  8655. /*!************************************!*\
  8656. !*** ./Behaviors/Cameras/index.ts ***!
  8657. \************************************/
  8658. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior */
  8659. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8660. "use strict";
  8661. __webpack_require__.r(__webpack_exports__);
  8662. /* harmony import */ var _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  8663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  8664. /* harmony import */ var _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  8665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__["BouncingBehavior"]; });
  8666. /* harmony import */ var _framingBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  8667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _framingBehavior__WEBPACK_IMPORTED_MODULE_2__["FramingBehavior"]; });
  8668. /***/ }),
  8669. /***/ "./Behaviors/Meshes/attachToBoxBehavior.ts":
  8670. /*!*************************************************!*\
  8671. !*** ./Behaviors/Meshes/attachToBoxBehavior.ts ***!
  8672. \*************************************************/
  8673. /*! exports provided: AttachToBoxBehavior */
  8674. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8675. "use strict";
  8676. __webpack_require__.r(__webpack_exports__);
  8677. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return AttachToBoxBehavior; });
  8678. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8679. /**
  8680. * @hidden
  8681. */
  8682. var FaceDirectionInfo = /** @class */ (function () {
  8683. function FaceDirectionInfo(direction, rotatedDirection, diff, ignore) {
  8684. if (rotatedDirection === void 0) { rotatedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](); }
  8685. if (diff === void 0) { diff = 0; }
  8686. if (ignore === void 0) { ignore = false; }
  8687. this.direction = direction;
  8688. this.rotatedDirection = rotatedDirection;
  8689. this.diff = diff;
  8690. this.ignore = ignore;
  8691. }
  8692. return FaceDirectionInfo;
  8693. }());
  8694. /**
  8695. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  8696. */
  8697. var AttachToBoxBehavior = /** @class */ (function () {
  8698. /**
  8699. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  8700. * @param ui The transform node that should be attched to the mesh
  8701. */
  8702. function AttachToBoxBehavior(ui) {
  8703. this.ui = ui;
  8704. /**
  8705. * The name of the behavior
  8706. */
  8707. this.name = "AttachToBoxBehavior";
  8708. /**
  8709. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  8710. */
  8711. this.distanceAwayFromFace = 0.15;
  8712. /**
  8713. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  8714. */
  8715. this.distanceAwayFromBottomOfFace = 0.15;
  8716. 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))];
  8717. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8718. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  8719. this._zeroVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  8720. this._lookAtTmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8721. /* Does nothing */
  8722. }
  8723. /**
  8724. * Initializes the behavior
  8725. */
  8726. AttachToBoxBehavior.prototype.init = function () {
  8727. /* Does nothing */
  8728. };
  8729. AttachToBoxBehavior.prototype._closestFace = function (targetDirection) {
  8730. var _this = this;
  8731. // Go over each face and calculate the angle between the face's normal and targetDirection
  8732. this._faceVectors.forEach(function (v) {
  8733. if (!_this._target.rotationQuaternion) {
  8734. _this._target.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this._target.rotation.y, _this._target.rotation.x, _this._target.rotation.z);
  8735. }
  8736. _this._target.rotationQuaternion.toRotationMatrix(_this._tmpMatrix);
  8737. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(v.direction, _this._tmpMatrix, v.rotatedDirection);
  8738. v.diff = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetAngleBetweenVectors(v.rotatedDirection, targetDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v.rotatedDirection, targetDirection));
  8739. });
  8740. // Return the face information of the one with the normal closeset to target direction
  8741. return this._faceVectors.reduce(function (min, p) {
  8742. if (min.ignore) {
  8743. return p;
  8744. }
  8745. else if (p.ignore) {
  8746. return min;
  8747. }
  8748. else {
  8749. return min.diff < p.diff ? min : p;
  8750. }
  8751. }, this._faceVectors[0]);
  8752. };
  8753. AttachToBoxBehavior.prototype._lookAtToRef = function (pos, up, ref) {
  8754. if (up === void 0) { up = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0); }
  8755. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LookAtLHToRef(this._zeroVector, pos, up, this._lookAtTmpMatrix);
  8756. this._lookAtTmpMatrix.invert();
  8757. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._lookAtTmpMatrix, ref);
  8758. };
  8759. /**
  8760. * Attaches the AttachToBoxBehavior to the passed in mesh
  8761. * @param target The mesh that the specified node will be attached to
  8762. */
  8763. AttachToBoxBehavior.prototype.attach = function (target) {
  8764. var _this = this;
  8765. this._target = target;
  8766. this._scene = this._target.getScene();
  8767. // Every frame, update the app bars position
  8768. this._onRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  8769. if (!_this._scene.activeCamera) {
  8770. return;
  8771. }
  8772. // Find the face closest to the cameras position
  8773. var cameraPos = _this._scene.activeCamera.position;
  8774. if (_this._scene.activeCamera.devicePosition) {
  8775. cameraPos = _this._scene.activeCamera.devicePosition;
  8776. }
  8777. var facing = _this._closestFace(cameraPos.subtract(target.position));
  8778. if (_this._scene.activeCamera.leftCamera) {
  8779. _this._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8780. }
  8781. else {
  8782. _this._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8783. }
  8784. // Get camera up direction
  8785. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), _this._tmpMatrix, _this._tmpVector);
  8786. // Ignore faces to not select a parrelel face for the up vector of the UI
  8787. _this._faceVectors.forEach(function (v) {
  8788. if (facing.direction.x && v.direction.x) {
  8789. v.ignore = true;
  8790. }
  8791. if (facing.direction.y && v.direction.y) {
  8792. v.ignore = true;
  8793. }
  8794. if (facing.direction.z && v.direction.z) {
  8795. v.ignore = true;
  8796. }
  8797. });
  8798. var facingUp = _this._closestFace(_this._tmpVector);
  8799. // Unignore faces
  8800. _this._faceVectors.forEach(function (v) {
  8801. v.ignore = false;
  8802. });
  8803. // Position the app bar on that face
  8804. _this.ui.position.copyFrom(target.position);
  8805. if (facing.direction.x) {
  8806. facing.rotatedDirection.scaleToRef((target.scaling.x / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8807. _this.ui.position.addInPlace(_this._tmpVector);
  8808. }
  8809. if (facing.direction.y) {
  8810. facing.rotatedDirection.scaleToRef((target.scaling.y / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8811. _this.ui.position.addInPlace(_this._tmpVector);
  8812. }
  8813. if (facing.direction.z) {
  8814. facing.rotatedDirection.scaleToRef((target.scaling.z / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8815. _this.ui.position.addInPlace(_this._tmpVector);
  8816. }
  8817. // Rotate to be oriented properly to the camera
  8818. if (!_this.ui.rotationQuaternion) {
  8819. _this.ui.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this.ui.rotation.y, _this.ui.rotation.x, _this.ui.rotation.z);
  8820. }
  8821. facing.rotatedDirection.scaleToRef(-1, _this._tmpVector);
  8822. _this._lookAtToRef(_this._tmpVector, facingUp.rotatedDirection, _this.ui.rotationQuaternion);
  8823. // Place ui the correct distance from the bottom of the mesh
  8824. if (facingUp.direction.x) {
  8825. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.x / 2, _this._tmpVector);
  8826. }
  8827. if (facingUp.direction.y) {
  8828. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.y / 2, _this._tmpVector);
  8829. }
  8830. if (facingUp.direction.z) {
  8831. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.z / 2, _this._tmpVector);
  8832. }
  8833. _this.ui.position.addInPlace(_this._tmpVector);
  8834. });
  8835. };
  8836. /**
  8837. * Detaches the behavior from the mesh
  8838. */
  8839. AttachToBoxBehavior.prototype.detach = function () {
  8840. this._scene.onBeforeRenderObservable.remove(this._onRenderObserver);
  8841. };
  8842. return AttachToBoxBehavior;
  8843. }());
  8844. /***/ }),
  8845. /***/ "./Behaviors/Meshes/fadeInOutBehavior.ts":
  8846. /*!***********************************************!*\
  8847. !*** ./Behaviors/Meshes/fadeInOutBehavior.ts ***!
  8848. \***********************************************/
  8849. /*! exports provided: FadeInOutBehavior */
  8850. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8851. "use strict";
  8852. __webpack_require__.r(__webpack_exports__);
  8853. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return FadeInOutBehavior; });
  8854. /**
  8855. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  8856. */
  8857. var FadeInOutBehavior = /** @class */ (function () {
  8858. /**
  8859. * Instatiates the FadeInOutBehavior
  8860. */
  8861. function FadeInOutBehavior() {
  8862. var _this = this;
  8863. /**
  8864. * Time in milliseconds to delay before fading in (Default: 0)
  8865. */
  8866. this.delay = 0;
  8867. /**
  8868. * Time in milliseconds for the mesh to fade in (Default: 300)
  8869. */
  8870. this.fadeInTime = 300;
  8871. this._millisecondsPerFrame = 1000 / 60;
  8872. this._hovered = false;
  8873. this._hoverValue = 0;
  8874. this._ownerNode = null;
  8875. this._update = function () {
  8876. if (_this._ownerNode) {
  8877. _this._hoverValue += _this._hovered ? _this._millisecondsPerFrame : -_this._millisecondsPerFrame;
  8878. _this._setAllVisibility(_this._ownerNode, (_this._hoverValue - _this.delay) / _this.fadeInTime);
  8879. if (_this._ownerNode.visibility > 1) {
  8880. _this._setAllVisibility(_this._ownerNode, 1);
  8881. _this._hoverValue = _this.fadeInTime + _this.delay;
  8882. return;
  8883. }
  8884. else if (_this._ownerNode.visibility < 0) {
  8885. _this._setAllVisibility(_this._ownerNode, 0);
  8886. if (_this._hoverValue < 0) {
  8887. _this._hoverValue = 0;
  8888. return;
  8889. }
  8890. }
  8891. setTimeout(_this._update, _this._millisecondsPerFrame);
  8892. }
  8893. };
  8894. }
  8895. Object.defineProperty(FadeInOutBehavior.prototype, "name", {
  8896. /**
  8897. * The name of the behavior
  8898. */
  8899. get: function () {
  8900. return "FadeInOut";
  8901. },
  8902. enumerable: true,
  8903. configurable: true
  8904. });
  8905. /**
  8906. * Initializes the behavior
  8907. */
  8908. FadeInOutBehavior.prototype.init = function () {
  8909. };
  8910. /**
  8911. * Attaches the fade behavior on the passed in mesh
  8912. * @param ownerNode The mesh that will be faded in/out once attached
  8913. */
  8914. FadeInOutBehavior.prototype.attach = function (ownerNode) {
  8915. this._ownerNode = ownerNode;
  8916. this._setAllVisibility(this._ownerNode, 0);
  8917. };
  8918. /**
  8919. * Detaches the behavior from the mesh
  8920. */
  8921. FadeInOutBehavior.prototype.detach = function () {
  8922. this._ownerNode = null;
  8923. };
  8924. /**
  8925. * Triggers the mesh to begin fading in or out
  8926. * @param value if the object should fade in or out (true to fade in)
  8927. */
  8928. FadeInOutBehavior.prototype.fadeIn = function (value) {
  8929. this._hovered = value;
  8930. this._update();
  8931. };
  8932. FadeInOutBehavior.prototype._setAllVisibility = function (mesh, value) {
  8933. var _this = this;
  8934. mesh.visibility = value;
  8935. mesh.getChildMeshes().forEach(function (c) {
  8936. _this._setAllVisibility(c, value);
  8937. });
  8938. };
  8939. return FadeInOutBehavior;
  8940. }());
  8941. /***/ }),
  8942. /***/ "./Behaviors/Meshes/index.ts":
  8943. /*!***********************************!*\
  8944. !*** ./Behaviors/Meshes/index.ts ***!
  8945. \***********************************/
  8946. /*! exports provided: AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  8947. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8948. "use strict";
  8949. __webpack_require__.r(__webpack_exports__);
  8950. /* harmony import */ var _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./attachToBoxBehavior */ "./Behaviors/Meshes/attachToBoxBehavior.ts");
  8951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  8952. /* harmony import */ var _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./fadeInOutBehavior */ "./Behaviors/Meshes/fadeInOutBehavior.ts");
  8953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  8954. /* harmony import */ var _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./multiPointerScaleBehavior */ "./Behaviors/Meshes/multiPointerScaleBehavior.ts");
  8955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__["MultiPointerScaleBehavior"]; });
  8956. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__["PointerDragBehavior"]; });
  8958. /* harmony import */ var _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  8959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__["SixDofDragBehavior"]; });
  8960. /***/ }),
  8961. /***/ "./Behaviors/Meshes/multiPointerScaleBehavior.ts":
  8962. /*!*******************************************************!*\
  8963. !*** ./Behaviors/Meshes/multiPointerScaleBehavior.ts ***!
  8964. \*******************************************************/
  8965. /*! exports provided: MultiPointerScaleBehavior */
  8966. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8967. "use strict";
  8968. __webpack_require__.r(__webpack_exports__);
  8969. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return MultiPointerScaleBehavior; });
  8970. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8971. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8972. /**
  8973. * A behavior that when attached to a mesh will allow the mesh to be scaled
  8974. */
  8975. var MultiPointerScaleBehavior = /** @class */ (function () {
  8976. /**
  8977. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  8978. */
  8979. function MultiPointerScaleBehavior() {
  8980. this._startDistance = 0;
  8981. this._initialScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  8982. this._targetScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  8983. this._sceneRenderObserver = null;
  8984. this._dragBehaviorA = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  8985. this._dragBehaviorA.moveAttached = false;
  8986. this._dragBehaviorB = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  8987. this._dragBehaviorB.moveAttached = false;
  8988. }
  8989. Object.defineProperty(MultiPointerScaleBehavior.prototype, "name", {
  8990. /**
  8991. * The name of the behavior
  8992. */
  8993. get: function () {
  8994. return "MultiPointerScale";
  8995. },
  8996. enumerable: true,
  8997. configurable: true
  8998. });
  8999. /**
  9000. * Initializes the behavior
  9001. */
  9002. MultiPointerScaleBehavior.prototype.init = function () { };
  9003. MultiPointerScaleBehavior.prototype._getCurrentDistance = function () {
  9004. return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length();
  9005. };
  9006. /**
  9007. * Attaches the scale behavior the passed in mesh
  9008. * @param ownerNode The mesh that will be scaled around once attached
  9009. */
  9010. MultiPointerScaleBehavior.prototype.attach = function (ownerNode) {
  9011. var _this = this;
  9012. this._ownerNode = ownerNode;
  9013. // Create 2 drag behaviors such that each will only be triggered by a separate pointer
  9014. this._dragBehaviorA.onDragStartObservable.add(function (e) {
  9015. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9016. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9017. _this._dragBehaviorA.releaseDrag();
  9018. }
  9019. else {
  9020. _this._initialScale.copyFrom(ownerNode.scaling);
  9021. _this._startDistance = _this._getCurrentDistance();
  9022. }
  9023. }
  9024. });
  9025. this._dragBehaviorB.onDragStartObservable.add(function (e) {
  9026. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9027. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9028. _this._dragBehaviorB.releaseDrag();
  9029. }
  9030. else {
  9031. _this._initialScale.copyFrom(ownerNode.scaling);
  9032. _this._startDistance = _this._getCurrentDistance();
  9033. }
  9034. }
  9035. });
  9036. // Once both drag behaviors are active scale based on the distance between the two pointers
  9037. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9038. behavior.onDragObservable.add(function () {
  9039. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9040. var ratio = _this._getCurrentDistance() / _this._startDistance;
  9041. _this._initialScale.scaleToRef(ratio, _this._targetScale);
  9042. }
  9043. });
  9044. });
  9045. ownerNode.addBehavior(this._dragBehaviorA);
  9046. ownerNode.addBehavior(this._dragBehaviorB);
  9047. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9048. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9049. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9050. var change = _this._targetScale.subtract(ownerNode.scaling).scaleInPlace(0.1);
  9051. if (change.length() > 0.01) {
  9052. ownerNode.scaling.addInPlace(change);
  9053. }
  9054. }
  9055. });
  9056. };
  9057. /**
  9058. * Detaches the behavior from the mesh
  9059. */
  9060. MultiPointerScaleBehavior.prototype.detach = function () {
  9061. var _this = this;
  9062. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9063. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9064. behavior.onDragStartObservable.clear();
  9065. behavior.onDragObservable.clear();
  9066. _this._ownerNode.removeBehavior(behavior);
  9067. });
  9068. };
  9069. return MultiPointerScaleBehavior;
  9070. }());
  9071. /***/ }),
  9072. /***/ "./Behaviors/Meshes/pointerDragBehavior.ts":
  9073. /*!*************************************************!*\
  9074. !*** ./Behaviors/Meshes/pointerDragBehavior.ts ***!
  9075. \*************************************************/
  9076. /*! exports provided: PointerDragBehavior */
  9077. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9078. "use strict";
  9079. __webpack_require__.r(__webpack_exports__);
  9080. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return PointerDragBehavior; });
  9081. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  9082. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9083. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9084. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9085. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9086. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  9087. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9088. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  9089. /**
  9090. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  9091. */
  9092. var PointerDragBehavior = /** @class */ (function () {
  9093. /**
  9094. * Creates a pointer drag behavior that can be attached to a mesh
  9095. * @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)
  9096. */
  9097. function PointerDragBehavior(options) {
  9098. this._useAlternatePickedPointAboveMaxDragAngleDragSpeed = -1.1;
  9099. /**
  9100. * 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)
  9101. */
  9102. this.maxDragAngle = 0;
  9103. /**
  9104. * @hidden
  9105. */
  9106. this._useAlternatePickedPointAboveMaxDragAngle = false;
  9107. /**
  9108. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9109. */
  9110. this.currentDraggingPointerID = -1;
  9111. /**
  9112. * If the behavior is currently in a dragging state
  9113. */
  9114. this.dragging = false;
  9115. /**
  9116. * 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)
  9117. */
  9118. this.dragDeltaRatio = 0.2;
  9119. /**
  9120. * If the drag plane orientation should be updated during the dragging (Default: true)
  9121. */
  9122. this.updateDragPlane = true;
  9123. // Debug mode will display drag planes to help visualize behavior
  9124. this._debugMode = false;
  9125. this._moving = false;
  9126. /**
  9127. * Fires each time the attached mesh is dragged with the pointer
  9128. * * delta between last drag position and current drag position in world space
  9129. * * dragDistance along the drag axis
  9130. * * dragPlaneNormal normal of the current drag plane used during the drag
  9131. * * dragPlanePoint in world space where the drag intersects the drag plane
  9132. */
  9133. this.onDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9134. /**
  9135. * Fires each time a drag begins (eg. mouse down on mesh)
  9136. */
  9137. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9138. /**
  9139. * Fires each time a drag ends (eg. mouse release after drag)
  9140. */
  9141. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9142. /**
  9143. * If the attached mesh should be moved when dragged
  9144. */
  9145. this.moveAttached = true;
  9146. /**
  9147. * If the drag behavior will react to drag events (Default: true)
  9148. */
  9149. this.enabled = true;
  9150. /**
  9151. * If camera controls should be detached during the drag
  9152. */
  9153. this.detachCameraControls = true;
  9154. /**
  9155. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  9156. */
  9157. this.useObjectOrienationForDragging = true;
  9158. /**
  9159. * Predicate to determine if it is valid to move the object to a new position when it is moved
  9160. */
  9161. this.validateDrag = function (targetPosition) { return true; };
  9162. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9163. this._alternatePickedPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9164. this._worldDragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9165. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9166. this._attachedElement = null;
  9167. 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"]());
  9168. this._lastPointerRay = {};
  9169. this._dragDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  9170. // Variables to avoid instantiation in the below method
  9171. this._pointA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9172. this._pointB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9173. this._pointC = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9174. this._lineA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9175. this._lineB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9176. this._localAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9177. this._lookAt = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9178. this._options = options ? options : {};
  9179. var optionCount = 0;
  9180. if (this._options.dragAxis) {
  9181. optionCount++;
  9182. }
  9183. if (this._options.dragPlaneNormal) {
  9184. optionCount++;
  9185. }
  9186. if (optionCount > 1) {
  9187. throw "Multiple drag modes specified in dragBehavior options. Only one expected";
  9188. }
  9189. }
  9190. Object.defineProperty(PointerDragBehavior.prototype, "name", {
  9191. /**
  9192. * The name of the behavior
  9193. */
  9194. get: function () {
  9195. return "PointerDrag";
  9196. },
  9197. enumerable: true,
  9198. configurable: true
  9199. });
  9200. /**
  9201. * Initializes the behavior
  9202. */
  9203. PointerDragBehavior.prototype.init = function () { };
  9204. /**
  9205. * Attaches the drag behavior the passed in mesh
  9206. * @param ownerNode The mesh that will be dragged around once attached
  9207. */
  9208. PointerDragBehavior.prototype.attach = function (ownerNode) {
  9209. var _this = this;
  9210. this._scene = ownerNode.getScene();
  9211. this._attachedNode = ownerNode;
  9212. // Initialize drag plane to not interfere with existing scene
  9213. if (!PointerDragBehavior._planeScene) {
  9214. if (this._debugMode) {
  9215. PointerDragBehavior._planeScene = this._scene;
  9216. }
  9217. else {
  9218. PointerDragBehavior._planeScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9219. PointerDragBehavior._planeScene.detachControl();
  9220. this._scene.getEngine().scenes.pop();
  9221. this._scene.onDisposeObservable.addOnce(function () {
  9222. PointerDragBehavior._planeScene.dispose();
  9223. PointerDragBehavior._planeScene = null;
  9224. });
  9225. }
  9226. }
  9227. 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);
  9228. // State of the drag
  9229. this.lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9230. var pickPredicate = function (m) {
  9231. return _this._attachedNode == m || m.isDescendantOf(_this._attachedNode);
  9232. };
  9233. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9234. if (!_this.enabled) {
  9235. return;
  9236. }
  9237. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN) {
  9238. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.pickedPoint && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9239. _this._startDrag(pointerInfo.event.pointerId, pointerInfo.pickInfo.ray, pointerInfo.pickInfo.pickedPoint);
  9240. }
  9241. }
  9242. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP) {
  9243. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9244. _this.releaseDrag();
  9245. }
  9246. }
  9247. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  9248. var pointerId = pointerInfo.event.pointerId;
  9249. // If drag was started with anyMouseID specified, set pointerID to the next mouse that moved
  9250. if (_this.currentDraggingPointerID === PointerDragBehavior._AnyMouseID && pointerId !== PointerDragBehavior._AnyMouseID && pointerInfo.event.pointerType == "mouse") {
  9251. if (_this._lastPointerRay[_this.currentDraggingPointerID]) {
  9252. _this._lastPointerRay[pointerId] = _this._lastPointerRay[_this.currentDraggingPointerID];
  9253. delete _this._lastPointerRay[_this.currentDraggingPointerID];
  9254. }
  9255. _this.currentDraggingPointerID = pointerId;
  9256. }
  9257. // Keep track of last pointer ray, this is used simulating the start of a drag in startDrag()
  9258. if (!_this._lastPointerRay[pointerId]) {
  9259. _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"]());
  9260. }
  9261. if (pointerInfo.pickInfo && pointerInfo.pickInfo.ray) {
  9262. _this._lastPointerRay[pointerId].origin.copyFrom(pointerInfo.pickInfo.ray.origin);
  9263. _this._lastPointerRay[pointerId].direction.copyFrom(pointerInfo.pickInfo.ray.direction);
  9264. if (_this.currentDraggingPointerID == pointerId && _this.dragging) {
  9265. _this._moveDrag(pointerInfo.pickInfo.ray);
  9266. }
  9267. }
  9268. }
  9269. });
  9270. this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  9271. if (_this._moving && _this.moveAttached) {
  9272. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(_this._attachedNode);
  9273. // Slowly move mesh to avoid jitter
  9274. _this._targetPosition.subtractToRef((_this._attachedNode).absolutePosition, _this._tmpVector);
  9275. _this._tmpVector.scaleInPlace(_this.dragDeltaRatio);
  9276. (_this._attachedNode).getAbsolutePosition().addToRef(_this._tmpVector, _this._tmpVector);
  9277. if (_this.validateDrag(_this._tmpVector)) {
  9278. (_this._attachedNode).setAbsolutePosition(_this._tmpVector);
  9279. }
  9280. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(_this._attachedNode);
  9281. }
  9282. });
  9283. };
  9284. /**
  9285. * Force relase the drag action by code.
  9286. */
  9287. PointerDragBehavior.prototype.releaseDrag = function () {
  9288. this.dragging = false;
  9289. this.onDragEndObservable.notifyObservers({ dragPlanePoint: this.lastDragPosition, pointerId: this.currentDraggingPointerID });
  9290. this.currentDraggingPointerID = -1;
  9291. this._moving = false;
  9292. // Reattach camera controls
  9293. if (this.detachCameraControls && this._attachedElement && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9294. this._scene.activeCamera.attachControl(this._attachedElement, true);
  9295. }
  9296. };
  9297. /**
  9298. * Simulates the start of a pointer drag event on the behavior
  9299. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  9300. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  9301. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  9302. */
  9303. PointerDragBehavior.prototype.startDrag = function (pointerId, fromRay, startPickedPoint) {
  9304. if (pointerId === void 0) { pointerId = PointerDragBehavior._AnyMouseID; }
  9305. this._startDrag(pointerId, fromRay, startPickedPoint);
  9306. var lastRay = this._lastPointerRay[pointerId];
  9307. if (pointerId === PointerDragBehavior._AnyMouseID) {
  9308. lastRay = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]];
  9309. }
  9310. if (lastRay) {
  9311. // if there was a last pointer ray drag the object there
  9312. this._moveDrag(lastRay);
  9313. }
  9314. };
  9315. PointerDragBehavior.prototype._startDrag = function (pointerId, fromRay, startPickedPoint) {
  9316. if (!this._scene.activeCamera || this.dragging || !this._attachedNode) {
  9317. return;
  9318. }
  9319. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(this._attachedNode);
  9320. // Create start ray from the camera to the object
  9321. if (fromRay) {
  9322. this._startDragRay.direction.copyFrom(fromRay.direction);
  9323. this._startDragRay.origin.copyFrom(fromRay.origin);
  9324. }
  9325. else {
  9326. this._startDragRay.origin.copyFrom(this._scene.activeCamera.position);
  9327. this._attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector);
  9328. this._tmpVector.subtractToRef(this._scene.activeCamera.position, this._startDragRay.direction);
  9329. }
  9330. this._updateDragPlanePosition(this._startDragRay, startPickedPoint ? startPickedPoint : this._tmpVector);
  9331. var pickedPoint = this._pickWithRayOnDragPlane(this._startDragRay);
  9332. if (pickedPoint) {
  9333. this.dragging = true;
  9334. this.currentDraggingPointerID = pointerId;
  9335. this.lastDragPosition.copyFrom(pickedPoint);
  9336. this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: this.currentDraggingPointerID });
  9337. this._targetPosition.copyFrom((this._attachedNode).absolutePosition);
  9338. // Detatch camera controls
  9339. if (this.detachCameraControls && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9340. if (this._scene.activeCamera.inputs.attachedElement) {
  9341. this._attachedElement = this._scene.activeCamera.inputs.attachedElement;
  9342. this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement);
  9343. }
  9344. else {
  9345. this._attachedElement = null;
  9346. }
  9347. }
  9348. }
  9349. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(this._attachedNode);
  9350. };
  9351. PointerDragBehavior.prototype._moveDrag = function (ray) {
  9352. this._moving = true;
  9353. var pickedPoint = this._pickWithRayOnDragPlane(ray);
  9354. if (pickedPoint) {
  9355. if (this.updateDragPlane) {
  9356. this._updateDragPlanePosition(ray, pickedPoint);
  9357. }
  9358. var dragLength = 0;
  9359. // depending on the drag mode option drag accordingly
  9360. if (this._options.dragAxis) {
  9361. // Convert local drag axis to world
  9362. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragAxis, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis);
  9363. // Project delta drag from the drag plane onto the drag axis
  9364. pickedPoint.subtractToRef(this.lastDragPosition, this._tmpVector);
  9365. dragLength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._tmpVector, this._worldDragAxis);
  9366. this._worldDragAxis.scaleToRef(dragLength, this._dragDelta);
  9367. }
  9368. else {
  9369. dragLength = this._dragDelta.length();
  9370. pickedPoint.subtractToRef(this.lastDragPosition, this._dragDelta);
  9371. }
  9372. this._targetPosition.addInPlace(this._dragDelta);
  9373. this.onDragObservable.notifyObservers({ dragDistance: dragLength, delta: this._dragDelta, dragPlanePoint: pickedPoint, dragPlaneNormal: this._dragPlane.forward, pointerId: this.currentDraggingPointerID });
  9374. this.lastDragPosition.copyFrom(pickedPoint);
  9375. }
  9376. };
  9377. PointerDragBehavior.prototype._pickWithRayOnDragPlane = function (ray) {
  9378. var _this = this;
  9379. if (!ray) {
  9380. return null;
  9381. }
  9382. // Calculate angle between plane normal and ray
  9383. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, ray.direction));
  9384. // Correct if ray is casted from oposite side
  9385. if (angle > Math.PI / 2) {
  9386. angle = Math.PI - angle;
  9387. }
  9388. // If the angle is too perpendicular to the plane pick another point on the plane where it is looking
  9389. if (this.maxDragAngle > 0 && angle > this.maxDragAngle) {
  9390. if (this._useAlternatePickedPointAboveMaxDragAngle) {
  9391. // Invert ray direction along the towards object axis
  9392. this._tmpVector.copyFrom(ray.direction);
  9393. (this._attachedNode).absolutePosition.subtractToRef(ray.origin, this._alternatePickedPoint);
  9394. this._alternatePickedPoint.normalize();
  9395. this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._alternatePickedPoint, this._tmpVector));
  9396. this._tmpVector.addInPlace(this._alternatePickedPoint);
  9397. // Project resulting vector onto the drag plane and add it to the attached nodes absolute position to get a picked point
  9398. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, this._tmpVector);
  9399. this._dragPlane.forward.scaleToRef(-dot, this._alternatePickedPoint);
  9400. this._alternatePickedPoint.addInPlace(this._tmpVector);
  9401. this._alternatePickedPoint.addInPlace((this._attachedNode).absolutePosition);
  9402. return this._alternatePickedPoint;
  9403. }
  9404. else {
  9405. return null;
  9406. }
  9407. }
  9408. var pickResult = PointerDragBehavior._planeScene.pickWithRay(ray, function (m) { return m == _this._dragPlane; });
  9409. if (pickResult && pickResult.hit && pickResult.pickedMesh && pickResult.pickedPoint) {
  9410. return pickResult.pickedPoint;
  9411. }
  9412. else {
  9413. return null;
  9414. }
  9415. };
  9416. // Position the drag plane based on the attached mesh position, for single axis rotate the plane along the axis to face the camera
  9417. PointerDragBehavior.prototype._updateDragPlanePosition = function (ray, dragPlanePosition) {
  9418. this._pointA.copyFrom(dragPlanePosition);
  9419. if (this._options.dragAxis) {
  9420. 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);
  9421. // Calculate plane normal in direction of camera but perpendicular to drag axis
  9422. this._pointA.addToRef(this._localAxis, this._pointB); // towards drag axis
  9423. ray.origin.subtractToRef(this._pointA, this._pointC);
  9424. this._pointA.addToRef(this._pointC.normalize(), this._pointC); // towards camera
  9425. // Get perpendicular line from direction to camera and drag axis
  9426. this._pointB.subtractToRef(this._pointA, this._lineA);
  9427. this._pointC.subtractToRef(this._pointA, this._lineB);
  9428. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lineB, this._lookAt);
  9429. // Get perpendicular line from previous result and drag axis to adjust lineB to be perpendiculat to camera
  9430. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lookAt, this._lookAt);
  9431. this._lookAt.normalize();
  9432. this._dragPlane.position.copyFrom(this._pointA);
  9433. this._pointA.addToRef(this._lookAt, this._lookAt);
  9434. this._dragPlane.lookAt(this._lookAt);
  9435. }
  9436. else if (this._options.dragPlaneNormal) {
  9437. 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);
  9438. this._dragPlane.position.copyFrom(this._pointA);
  9439. this._pointA.addToRef(this._localAxis, this._lookAt);
  9440. this._dragPlane.lookAt(this._lookAt);
  9441. }
  9442. else {
  9443. this._dragPlane.position.copyFrom(this._pointA);
  9444. this._dragPlane.lookAt(ray.origin);
  9445. }
  9446. // 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)
  9447. this._dragPlane.position.copyFrom(this._attachedNode.absolutePosition);
  9448. this._dragPlane.computeWorldMatrix(true);
  9449. };
  9450. /**
  9451. * Detaches the behavior from the mesh
  9452. */
  9453. PointerDragBehavior.prototype.detach = function () {
  9454. if (this._pointerObserver) {
  9455. this._scene.onPointerObservable.remove(this._pointerObserver);
  9456. }
  9457. if (this._beforeRenderObserver) {
  9458. this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  9459. }
  9460. this.releaseDrag();
  9461. };
  9462. PointerDragBehavior._AnyMouseID = -2;
  9463. return PointerDragBehavior;
  9464. }());
  9465. /***/ }),
  9466. /***/ "./Behaviors/Meshes/sixDofDragBehavior.ts":
  9467. /*!************************************************!*\
  9468. !*** ./Behaviors/Meshes/sixDofDragBehavior.ts ***!
  9469. \************************************************/
  9470. /*! exports provided: SixDofDragBehavior */
  9471. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9472. "use strict";
  9473. __webpack_require__.r(__webpack_exports__);
  9474. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return SixDofDragBehavior; });
  9475. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  9476. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9477. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9478. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9479. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9480. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  9481. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9482. /**
  9483. * 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
  9484. */
  9485. var SixDofDragBehavior = /** @class */ (function () {
  9486. /**
  9487. * 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
  9488. */
  9489. function SixDofDragBehavior() {
  9490. this._sceneRenderObserver = null;
  9491. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9492. this._moving = false;
  9493. this._startingOrientation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9494. /**
  9495. * 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)
  9496. */
  9497. this.zDragFactor = 3;
  9498. /**
  9499. * If the object should rotate to face the drag origin
  9500. */
  9501. this.rotateDraggedObject = true;
  9502. /**
  9503. * If the behavior is currently in a dragging state
  9504. */
  9505. this.dragging = false;
  9506. /**
  9507. * 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)
  9508. */
  9509. this.dragDeltaRatio = 0.2;
  9510. /**
  9511. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9512. */
  9513. this.currentDraggingPointerID = -1;
  9514. /**
  9515. * If camera controls should be detached during the drag
  9516. */
  9517. this.detachCameraControls = true;
  9518. /**
  9519. * Fires each time a drag starts
  9520. */
  9521. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9522. /**
  9523. * Fires each time a drag ends (eg. mouse release after drag)
  9524. */
  9525. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9526. }
  9527. Object.defineProperty(SixDofDragBehavior.prototype, "name", {
  9528. /**
  9529. * The name of the behavior
  9530. */
  9531. get: function () {
  9532. return "SixDofDrag";
  9533. },
  9534. enumerable: true,
  9535. configurable: true
  9536. });
  9537. /**
  9538. * Initializes the behavior
  9539. */
  9540. SixDofDragBehavior.prototype.init = function () { };
  9541. /**
  9542. * Attaches the scale behavior the passed in mesh
  9543. * @param ownerNode The mesh that will be scaled around once attached
  9544. */
  9545. SixDofDragBehavior.prototype.attach = function (ownerNode) {
  9546. var _this = this;
  9547. this._ownerNode = ownerNode;
  9548. this._scene = this._ownerNode.getScene();
  9549. if (!SixDofDragBehavior._virtualScene) {
  9550. SixDofDragBehavior._virtualScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9551. SixDofDragBehavior._virtualScene.detachControl();
  9552. this._scene.getEngine().scenes.pop();
  9553. }
  9554. var pickedMesh = null;
  9555. var lastSixDofOriginPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9556. // Setup virtual meshes to be used for dragging without dirtying the existing scene
  9557. this._virtualOriginMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9558. this._virtualOriginMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9559. this._virtualDragMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9560. this._virtualDragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9561. var pickPredicate = function (m) {
  9562. return _this._ownerNode == m || m.isDescendantOf(_this._ownerNode);
  9563. };
  9564. var attachedElement = null;
  9565. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9566. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  9567. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9568. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9569. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9570. }
  9571. pickedMesh = _this._ownerNode;
  9572. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9573. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9574. // Set position and orientation of the controller
  9575. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9576. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9577. // Attach the virtual drag mesh to the virtual origin mesh so it can be dragged
  9578. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9579. pickedMesh.computeWorldMatrix();
  9580. _this._virtualDragMesh.position.copyFrom(pickedMesh.absolutePosition);
  9581. if (!pickedMesh.rotationQuaternion) {
  9582. pickedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(pickedMesh.rotation.y, pickedMesh.rotation.x, pickedMesh.rotation.z);
  9583. }
  9584. var oldParent = pickedMesh.parent;
  9585. pickedMesh.setParent(null);
  9586. _this._virtualDragMesh.rotationQuaternion.copyFrom(pickedMesh.rotationQuaternion);
  9587. pickedMesh.setParent(oldParent);
  9588. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9589. // Update state
  9590. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9591. _this.dragging = true;
  9592. _this.currentDraggingPointerID = pointerInfo.event.pointerId;
  9593. // Detatch camera controls
  9594. if (_this.detachCameraControls && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9595. if (_this._scene.activeCamera.inputs.attachedElement) {
  9596. attachedElement = _this._scene.activeCamera.inputs.attachedElement;
  9597. _this._scene.activeCamera.detachControl(_this._scene.activeCamera.inputs.attachedElement);
  9598. }
  9599. else {
  9600. attachedElement = null;
  9601. }
  9602. }
  9603. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9604. _this.onDragStartObservable.notifyObservers({});
  9605. }
  9606. }
  9607. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP) {
  9608. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9609. _this.dragging = false;
  9610. _this._moving = false;
  9611. _this.currentDraggingPointerID = -1;
  9612. pickedMesh = null;
  9613. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9614. // Reattach camera controls
  9615. if (_this.detachCameraControls && attachedElement && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9616. _this._scene.activeCamera.attachControl(attachedElement, true);
  9617. }
  9618. _this.onDragEndObservable.notifyObservers({});
  9619. }
  9620. }
  9621. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE) {
  9622. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
  9623. var zDragFactor = _this.zDragFactor;
  9624. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9625. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9626. zDragFactor = 0;
  9627. }
  9628. // Calculate controller drag distance in controller space
  9629. var originDragDifference = pointerInfo.pickInfo.ray.origin.subtract(lastSixDofOriginPosition);
  9630. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9631. var localOriginDragDifference = -_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(originDragDifference, pointerInfo.pickInfo.ray.direction);
  9632. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9633. // Determine how much the controller moved to/away towards the dragged object and use this to move the object further when its further away
  9634. _this._virtualDragMesh.position.z -= _this._virtualDragMesh.position.z < 1 ? localOriginDragDifference * _this.zDragFactor : localOriginDragDifference * zDragFactor * _this._virtualDragMesh.position.z;
  9635. if (_this._virtualDragMesh.position.z < 0) {
  9636. _this._virtualDragMesh.position.z = 0;
  9637. }
  9638. // Update the controller position
  9639. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9640. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9641. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9642. // Move the virtualObjectsPosition into the picked mesh's space if needed
  9643. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9644. if (pickedMesh.parent) {
  9645. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._targetPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(pickedMesh.parent.getWorldMatrix()), _this._targetPosition);
  9646. }
  9647. if (!_this._moving) {
  9648. _this._startingOrientation.copyFrom(_this._virtualDragMesh.rotationQuaternion);
  9649. }
  9650. _this._moving = true;
  9651. }
  9652. }
  9653. });
  9654. var tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9655. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9656. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9657. if (_this.dragging && _this._moving && pickedMesh) {
  9658. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9659. // Slowly move mesh to avoid jitter
  9660. pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
  9661. if (_this.rotateDraggedObject) {
  9662. // Get change in rotation
  9663. tmpQuaternion.copyFrom(_this._startingOrientation);
  9664. tmpQuaternion.x = -tmpQuaternion.x;
  9665. tmpQuaternion.y = -tmpQuaternion.y;
  9666. tmpQuaternion.z = -tmpQuaternion.z;
  9667. _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
  9668. // Convert change in rotation to only y axis rotation
  9669. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
  9670. tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
  9671. // Slowly move mesh to avoid jitter
  9672. var oldParent = pickedMesh.parent;
  9673. // Only rotate the mesh if it's parent has uniform scaling
  9674. if (!oldParent || (oldParent.scaling && !oldParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  9675. pickedMesh.setParent(null);
  9676. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
  9677. pickedMesh.setParent(oldParent);
  9678. }
  9679. }
  9680. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9681. }
  9682. });
  9683. };
  9684. /**
  9685. * Detaches the behavior from the mesh
  9686. */
  9687. SixDofDragBehavior.prototype.detach = function () {
  9688. if (this._scene) {
  9689. this._scene.onPointerObservable.remove(this._pointerObserver);
  9690. }
  9691. if (this._ownerNode) {
  9692. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9693. }
  9694. if (this._virtualOriginMesh) {
  9695. this._virtualOriginMesh.dispose();
  9696. }
  9697. if (this._virtualDragMesh) {
  9698. this._virtualDragMesh.dispose();
  9699. }
  9700. this.onDragEndObservable.clear();
  9701. this.onDragStartObservable.clear();
  9702. };
  9703. return SixDofDragBehavior;
  9704. }());
  9705. /***/ }),
  9706. /***/ "./Behaviors/index.ts":
  9707. /*!****************************!*\
  9708. !*** ./Behaviors/index.ts ***!
  9709. \****************************/
  9710. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  9711. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9712. "use strict";
  9713. __webpack_require__.r(__webpack_exports__);
  9714. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Cameras/index */ "./Behaviors/Cameras/index.ts");
  9715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  9716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  9717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  9718. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Meshes/index */ "./Behaviors/Meshes/index.ts");
  9719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["AttachToBoxBehavior"]; });
  9720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  9721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["MultiPointerScaleBehavior"]; });
  9722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["PointerDragBehavior"]; });
  9723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["SixDofDragBehavior"]; });
  9724. /***/ }),
  9725. /***/ "./Bones/bone.ts":
  9726. /*!***********************!*\
  9727. !*** ./Bones/bone.ts ***!
  9728. \***********************/
  9729. /*! exports provided: Bone */
  9730. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9731. "use strict";
  9732. __webpack_require__.r(__webpack_exports__);
  9733. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return Bone; });
  9734. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  9735. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  9736. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  9737. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  9738. /**
  9739. * Class used to store bone information
  9740. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9741. */
  9742. var Bone = /** @class */ (function (_super) {
  9743. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Bone, _super);
  9744. /**
  9745. * Create a new bone
  9746. * @param name defines the bone name
  9747. * @param skeleton defines the parent skeleton
  9748. * @param parentBone defines the parent (can be null if the bone is the root)
  9749. * @param localMatrix defines the local matrix
  9750. * @param restPose defines the rest pose matrix
  9751. * @param baseMatrix defines the base matrix
  9752. * @param index defines index of the bone in the hiearchy
  9753. */
  9754. function Bone(
  9755. /**
  9756. * defines the bone name
  9757. */
  9758. name, skeleton, parentBone, localMatrix, restPose, baseMatrix, index) {
  9759. if (parentBone === void 0) { parentBone = null; }
  9760. if (localMatrix === void 0) { localMatrix = null; }
  9761. if (restPose === void 0) { restPose = null; }
  9762. if (baseMatrix === void 0) { baseMatrix = null; }
  9763. if (index === void 0) { index = null; }
  9764. var _this = _super.call(this, name, skeleton.getScene(), false) || this;
  9765. _this.name = name;
  9766. /**
  9767. * Gets the list of child bones
  9768. */
  9769. _this.children = new Array();
  9770. /** Gets the animations associated with this bone */
  9771. _this.animations = new Array();
  9772. /**
  9773. * @hidden Internal only
  9774. * Set this value to map this bone to a different index in the transform matrices
  9775. * Set this value to -1 to exclude the bone from the transform matrices
  9776. */
  9777. _this._index = null;
  9778. _this._absoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9779. _this._invertedAbsoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9780. _this._scalingDeterminant = 1;
  9781. _this._worldTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9782. _this._needToDecompose = true;
  9783. _this._needToCompose = false;
  9784. /** @hidden */
  9785. _this._linkedTransformNode = null;
  9786. _this._skeleton = skeleton;
  9787. _this._localMatrix = localMatrix ? localMatrix.clone() : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  9788. _this._restPose = restPose ? restPose : _this._localMatrix.clone();
  9789. _this._baseMatrix = baseMatrix ? baseMatrix : _this._localMatrix.clone();
  9790. _this._index = index;
  9791. skeleton.bones.push(_this);
  9792. _this.setParent(parentBone, false);
  9793. if (baseMatrix || localMatrix) {
  9794. _this._updateDifferenceMatrix();
  9795. }
  9796. return _this;
  9797. }
  9798. Object.defineProperty(Bone.prototype, "_matrix", {
  9799. /** @hidden */
  9800. get: function () {
  9801. this._compose();
  9802. return this._localMatrix;
  9803. },
  9804. /** @hidden */
  9805. set: function (value) {
  9806. this._localMatrix.copyFrom(value);
  9807. this._needToDecompose = true;
  9808. },
  9809. enumerable: true,
  9810. configurable: true
  9811. });
  9812. /**
  9813. * Gets the current object class name.
  9814. * @return the class name
  9815. */
  9816. Bone.prototype.getClassName = function () {
  9817. return "Bone";
  9818. };
  9819. // Members
  9820. /**
  9821. * Gets the parent skeleton
  9822. * @returns a skeleton
  9823. */
  9824. Bone.prototype.getSkeleton = function () {
  9825. return this._skeleton;
  9826. };
  9827. /**
  9828. * Gets parent bone
  9829. * @returns a bone or null if the bone is the root of the bone hierarchy
  9830. */
  9831. Bone.prototype.getParent = function () {
  9832. return this._parent;
  9833. };
  9834. /**
  9835. * Returns an array containing the root bones
  9836. * @returns an array containing the root bones
  9837. */
  9838. Bone.prototype.getChildren = function () {
  9839. return this.children;
  9840. };
  9841. /**
  9842. * Sets the parent bone
  9843. * @param parent defines the parent (can be null if the bone is the root)
  9844. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9845. */
  9846. Bone.prototype.setParent = function (parent, updateDifferenceMatrix) {
  9847. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  9848. if (this._parent === parent) {
  9849. return;
  9850. }
  9851. if (this._parent) {
  9852. var index = this._parent.children.indexOf(this);
  9853. if (index !== -1) {
  9854. this._parent.children.splice(index, 1);
  9855. }
  9856. }
  9857. this._parent = parent;
  9858. if (this._parent) {
  9859. this._parent.children.push(this);
  9860. }
  9861. if (updateDifferenceMatrix) {
  9862. this._updateDifferenceMatrix();
  9863. }
  9864. this.markAsDirty();
  9865. };
  9866. /**
  9867. * Gets the local matrix
  9868. * @returns a matrix
  9869. */
  9870. Bone.prototype.getLocalMatrix = function () {
  9871. this._compose();
  9872. return this._localMatrix;
  9873. };
  9874. /**
  9875. * Gets the base matrix (initial matrix which remains unchanged)
  9876. * @returns a matrix
  9877. */
  9878. Bone.prototype.getBaseMatrix = function () {
  9879. return this._baseMatrix;
  9880. };
  9881. /**
  9882. * Gets the rest pose matrix
  9883. * @returns a matrix
  9884. */
  9885. Bone.prototype.getRestPose = function () {
  9886. return this._restPose;
  9887. };
  9888. /**
  9889. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9890. */
  9891. Bone.prototype.getWorldMatrix = function () {
  9892. return this._worldTransform;
  9893. };
  9894. /**
  9895. * Sets the local matrix to rest pose matrix
  9896. */
  9897. Bone.prototype.returnToRest = function () {
  9898. this.updateMatrix(this._restPose.clone());
  9899. };
  9900. /**
  9901. * Gets the inverse of the absolute transform matrix.
  9902. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9903. * @returns a matrix
  9904. */
  9905. Bone.prototype.getInvertedAbsoluteTransform = function () {
  9906. return this._invertedAbsoluteTransform;
  9907. };
  9908. /**
  9909. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9910. * @returns a matrix
  9911. */
  9912. Bone.prototype.getAbsoluteTransform = function () {
  9913. return this._absoluteTransform;
  9914. };
  9915. /**
  9916. * Links with the given transform node.
  9917. * The local matrix of this bone is copied from the transform node every frame.
  9918. * @param transformNode defines the transform node to link to
  9919. */
  9920. Bone.prototype.linkTransformNode = function (transformNode) {
  9921. if (this._linkedTransformNode) {
  9922. this._skeleton._numBonesWithLinkedTransformNode--;
  9923. }
  9924. this._linkedTransformNode = transformNode;
  9925. if (this._linkedTransformNode) {
  9926. this._skeleton._numBonesWithLinkedTransformNode++;
  9927. }
  9928. };
  9929. Object.defineProperty(Bone.prototype, "position", {
  9930. // Properties (matches AbstractMesh properties)
  9931. /** Gets or sets current position (in local space) */
  9932. get: function () {
  9933. this._decompose();
  9934. return this._localPosition;
  9935. },
  9936. set: function (newPosition) {
  9937. this._decompose();
  9938. this._localPosition.copyFrom(newPosition);
  9939. this._markAsDirtyAndCompose();
  9940. },
  9941. enumerable: true,
  9942. configurable: true
  9943. });
  9944. Object.defineProperty(Bone.prototype, "rotation", {
  9945. /** Gets or sets current rotation (in local space) */
  9946. get: function () {
  9947. return this.getRotation();
  9948. },
  9949. set: function (newRotation) {
  9950. this.setRotation(newRotation);
  9951. },
  9952. enumerable: true,
  9953. configurable: true
  9954. });
  9955. Object.defineProperty(Bone.prototype, "rotationQuaternion", {
  9956. /** Gets or sets current rotation quaternion (in local space) */
  9957. get: function () {
  9958. this._decompose();
  9959. return this._localRotation;
  9960. },
  9961. set: function (newRotation) {
  9962. this.setRotationQuaternion(newRotation);
  9963. },
  9964. enumerable: true,
  9965. configurable: true
  9966. });
  9967. Object.defineProperty(Bone.prototype, "scaling", {
  9968. /** Gets or sets current scaling (in local space) */
  9969. get: function () {
  9970. return this.getScale();
  9971. },
  9972. set: function (newScaling) {
  9973. this.setScale(newScaling);
  9974. },
  9975. enumerable: true,
  9976. configurable: true
  9977. });
  9978. Object.defineProperty(Bone.prototype, "animationPropertiesOverride", {
  9979. /**
  9980. * Gets the animation properties override
  9981. */
  9982. get: function () {
  9983. return this._skeleton.animationPropertiesOverride;
  9984. },
  9985. enumerable: true,
  9986. configurable: true
  9987. });
  9988. // Methods
  9989. Bone.prototype._decompose = function () {
  9990. if (!this._needToDecompose) {
  9991. return;
  9992. }
  9993. this._needToDecompose = false;
  9994. if (!this._localScaling) {
  9995. this._localScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9996. this._localRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Zero();
  9997. this._localPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9998. }
  9999. this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition);
  10000. };
  10001. Bone.prototype._compose = function () {
  10002. if (!this._needToCompose) {
  10003. return;
  10004. }
  10005. this._needToCompose = false;
  10006. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ComposeToRef(this._localScaling, this._localRotation, this._localPosition, this._localMatrix);
  10007. };
  10008. /**
  10009. * Update the base and local matrices
  10010. * @param matrix defines the new base or local matrix
  10011. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  10012. * @param updateLocalMatrix defines if the local matrix should be updated
  10013. */
  10014. Bone.prototype.updateMatrix = function (matrix, updateDifferenceMatrix, updateLocalMatrix) {
  10015. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  10016. if (updateLocalMatrix === void 0) { updateLocalMatrix = true; }
  10017. this._baseMatrix.copyFrom(matrix);
  10018. if (updateDifferenceMatrix) {
  10019. this._updateDifferenceMatrix();
  10020. }
  10021. if (updateLocalMatrix) {
  10022. this._localMatrix.copyFrom(matrix);
  10023. this._markAsDirtyAndDecompose();
  10024. }
  10025. else {
  10026. this.markAsDirty();
  10027. }
  10028. };
  10029. /** @hidden */
  10030. Bone.prototype._updateDifferenceMatrix = function (rootMatrix, updateChildren) {
  10031. if (updateChildren === void 0) { updateChildren = true; }
  10032. if (!rootMatrix) {
  10033. rootMatrix = this._baseMatrix;
  10034. }
  10035. if (this._parent) {
  10036. rootMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10037. }
  10038. else {
  10039. this._absoluteTransform.copyFrom(rootMatrix);
  10040. }
  10041. this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform);
  10042. if (updateChildren) {
  10043. for (var index = 0; index < this.children.length; index++) {
  10044. this.children[index]._updateDifferenceMatrix();
  10045. }
  10046. }
  10047. this._scalingDeterminant = (this._absoluteTransform.determinant() < 0 ? -1 : 1);
  10048. };
  10049. /**
  10050. * Flag the bone as dirty (Forcing it to update everything)
  10051. */
  10052. Bone.prototype.markAsDirty = function () {
  10053. this._currentRenderId++;
  10054. this._childUpdateId++;
  10055. this._skeleton._markAsDirty();
  10056. };
  10057. Bone.prototype._markAsDirtyAndCompose = function () {
  10058. this.markAsDirty();
  10059. this._needToCompose = true;
  10060. };
  10061. Bone.prototype._markAsDirtyAndDecompose = function () {
  10062. this.markAsDirty();
  10063. this._needToDecompose = true;
  10064. };
  10065. /**
  10066. * Translate the bone in local or world space
  10067. * @param vec The amount to translate the bone
  10068. * @param space The space that the translation is in
  10069. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10070. */
  10071. Bone.prototype.translate = function (vec, space, mesh) {
  10072. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10073. var lm = this.getLocalMatrix();
  10074. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10075. lm.addAtIndex(12, vec.x);
  10076. lm.addAtIndex(13, vec.y);
  10077. lm.addAtIndex(14, vec.z);
  10078. }
  10079. else {
  10080. var wm = null;
  10081. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10082. if (mesh) {
  10083. wm = mesh.getWorldMatrix();
  10084. }
  10085. this._skeleton.computeAbsoluteTransforms();
  10086. var tmat = Bone._tmpMats[0];
  10087. var tvec = Bone._tmpVecs[0];
  10088. if (this._parent) {
  10089. if (mesh && wm) {
  10090. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10091. tmat.multiplyToRef(wm, tmat);
  10092. }
  10093. else {
  10094. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10095. }
  10096. }
  10097. tmat.setTranslationFromFloats(0, 0, 0);
  10098. tmat.invert();
  10099. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vec, tmat, tvec);
  10100. lm.addAtIndex(12, tvec.x);
  10101. lm.addAtIndex(13, tvec.y);
  10102. lm.addAtIndex(14, tvec.z);
  10103. }
  10104. this._markAsDirtyAndDecompose();
  10105. };
  10106. /**
  10107. * Set the postion of the bone in local or world space
  10108. * @param position The position to set the bone
  10109. * @param space The space that the position is in
  10110. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10111. */
  10112. Bone.prototype.setPosition = function (position, space, mesh) {
  10113. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10114. var lm = this.getLocalMatrix();
  10115. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10116. lm.setTranslationFromFloats(position.x, position.y, position.z);
  10117. }
  10118. else {
  10119. var wm = null;
  10120. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10121. if (mesh) {
  10122. wm = mesh.getWorldMatrix();
  10123. }
  10124. this._skeleton.computeAbsoluteTransforms();
  10125. var tmat = Bone._tmpMats[0];
  10126. var vec = Bone._tmpVecs[0];
  10127. if (this._parent) {
  10128. if (mesh && wm) {
  10129. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10130. tmat.multiplyToRef(wm, tmat);
  10131. }
  10132. else {
  10133. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10134. }
  10135. }
  10136. tmat.invert();
  10137. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, vec);
  10138. lm.setTranslationFromFloats(vec.x, vec.y, vec.z);
  10139. }
  10140. this._markAsDirtyAndDecompose();
  10141. };
  10142. /**
  10143. * Set the absolute position of the bone (world space)
  10144. * @param position The position to set the bone
  10145. * @param mesh The mesh that this bone is attached to
  10146. */
  10147. Bone.prototype.setAbsolutePosition = function (position, mesh) {
  10148. this.setPosition(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh);
  10149. };
  10150. /**
  10151. * Scale the bone on the x, y and z axes (in local space)
  10152. * @param x The amount to scale the bone on the x axis
  10153. * @param y The amount to scale the bone on the y axis
  10154. * @param z The amount to scale the bone on the z axis
  10155. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  10156. */
  10157. Bone.prototype.scale = function (x, y, z, scaleChildren) {
  10158. if (scaleChildren === void 0) { scaleChildren = false; }
  10159. var locMat = this.getLocalMatrix();
  10160. // Apply new scaling on top of current local matrix
  10161. var scaleMat = Bone._tmpMats[0];
  10162. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(x, y, z, scaleMat);
  10163. scaleMat.multiplyToRef(locMat, locMat);
  10164. // Invert scaling matrix and apply the inverse to all children
  10165. scaleMat.invert();
  10166. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  10167. var child = _a[_i];
  10168. var cm = child.getLocalMatrix();
  10169. cm.multiplyToRef(scaleMat, cm);
  10170. cm.multiplyAtIndex(12, x);
  10171. cm.multiplyAtIndex(13, y);
  10172. cm.multiplyAtIndex(14, z);
  10173. child._markAsDirtyAndDecompose();
  10174. }
  10175. this._markAsDirtyAndDecompose();
  10176. if (scaleChildren) {
  10177. for (var _b = 0, _c = this.children; _b < _c.length; _b++) {
  10178. var child = _c[_b];
  10179. child.scale(x, y, z, scaleChildren);
  10180. }
  10181. }
  10182. };
  10183. /**
  10184. * Set the bone scaling in local space
  10185. * @param scale defines the scaling vector
  10186. */
  10187. Bone.prototype.setScale = function (scale) {
  10188. this._decompose();
  10189. this._localScaling.copyFrom(scale);
  10190. this._markAsDirtyAndCompose();
  10191. };
  10192. /**
  10193. * Gets the current scaling in local space
  10194. * @returns the current scaling vector
  10195. */
  10196. Bone.prototype.getScale = function () {
  10197. this._decompose();
  10198. return this._localScaling;
  10199. };
  10200. /**
  10201. * Gets the current scaling in local space and stores it in a target vector
  10202. * @param result defines the target vector
  10203. */
  10204. Bone.prototype.getScaleToRef = function (result) {
  10205. this._decompose();
  10206. result.copyFrom(this._localScaling);
  10207. };
  10208. /**
  10209. * Set the yaw, pitch, and roll of the bone in local or world space
  10210. * @param yaw The rotation of the bone on the y axis
  10211. * @param pitch The rotation of the bone on the x axis
  10212. * @param roll The rotation of the bone on the z axis
  10213. * @param space The space that the axes of rotation are in
  10214. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10215. */
  10216. Bone.prototype.setYawPitchRoll = function (yaw, pitch, roll, space, mesh) {
  10217. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10218. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10219. var quat = Bone._tmpQuat;
  10220. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationYawPitchRollToRef(yaw, pitch, roll, quat);
  10221. this.setRotationQuaternion(quat, space, mesh);
  10222. return;
  10223. }
  10224. var rotMatInv = Bone._tmpMats[0];
  10225. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10226. return;
  10227. }
  10228. var rotMat = Bone._tmpMats[1];
  10229. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yaw, pitch, roll, rotMat);
  10230. rotMatInv.multiplyToRef(rotMat, rotMat);
  10231. this._rotateWithMatrix(rotMat, space, mesh);
  10232. };
  10233. /**
  10234. * Add a rotation to the bone on an axis in local or world space
  10235. * @param axis The axis to rotate the bone on
  10236. * @param amount The amount to rotate the bone
  10237. * @param space The space that the axis is in
  10238. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10239. */
  10240. Bone.prototype.rotate = function (axis, amount, space, mesh) {
  10241. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10242. var rmat = Bone._tmpMats[0];
  10243. rmat.setTranslationFromFloats(0, 0, 0);
  10244. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, amount, rmat);
  10245. this._rotateWithMatrix(rmat, space, mesh);
  10246. };
  10247. /**
  10248. * Set the rotation of the bone to a particular axis angle in local or world space
  10249. * @param axis The axis to rotate the bone on
  10250. * @param angle The angle that the bone should be rotated to
  10251. * @param space The space that the axis is in
  10252. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10253. */
  10254. Bone.prototype.setAxisAngle = function (axis, angle, space, mesh) {
  10255. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10256. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10257. var quat = Bone._tmpQuat;
  10258. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationAxisToRef(axis, angle, quat);
  10259. this.setRotationQuaternion(quat, space, mesh);
  10260. return;
  10261. }
  10262. var rotMatInv = Bone._tmpMats[0];
  10263. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10264. return;
  10265. }
  10266. var rotMat = Bone._tmpMats[1];
  10267. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, angle, rotMat);
  10268. rotMatInv.multiplyToRef(rotMat, rotMat);
  10269. this._rotateWithMatrix(rotMat, space, mesh);
  10270. };
  10271. /**
  10272. * Set the euler rotation of the bone in local of world space
  10273. * @param rotation The euler rotation that the bone should be set to
  10274. * @param space The space that the rotation is in
  10275. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10276. */
  10277. Bone.prototype.setRotation = function (rotation, space, mesh) {
  10278. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10279. this.setYawPitchRoll(rotation.y, rotation.x, rotation.z, space, mesh);
  10280. };
  10281. /**
  10282. * Set the quaternion rotation of the bone in local of world space
  10283. * @param quat The quaternion rotation that the bone should be set to
  10284. * @param space The space that the rotation is in
  10285. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10286. */
  10287. Bone.prototype.setRotationQuaternion = function (quat, space, mesh) {
  10288. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10289. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10290. this._decompose();
  10291. this._localRotation.copyFrom(quat);
  10292. this._markAsDirtyAndCompose();
  10293. return;
  10294. }
  10295. var rotMatInv = Bone._tmpMats[0];
  10296. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10297. return;
  10298. }
  10299. var rotMat = Bone._tmpMats[1];
  10300. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromQuaternionToRef(quat, rotMat);
  10301. rotMatInv.multiplyToRef(rotMat, rotMat);
  10302. this._rotateWithMatrix(rotMat, space, mesh);
  10303. };
  10304. /**
  10305. * Set the rotation matrix of the bone in local of world space
  10306. * @param rotMat The rotation matrix that the bone should be set to
  10307. * @param space The space that the rotation is in
  10308. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10309. */
  10310. Bone.prototype.setRotationMatrix = function (rotMat, space, mesh) {
  10311. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10312. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10313. var quat = Bone._tmpQuat;
  10314. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(rotMat, quat);
  10315. this.setRotationQuaternion(quat, space, mesh);
  10316. return;
  10317. }
  10318. var rotMatInv = Bone._tmpMats[0];
  10319. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10320. return;
  10321. }
  10322. var rotMat2 = Bone._tmpMats[1];
  10323. rotMat2.copyFrom(rotMat);
  10324. rotMatInv.multiplyToRef(rotMat, rotMat2);
  10325. this._rotateWithMatrix(rotMat2, space, mesh);
  10326. };
  10327. Bone.prototype._rotateWithMatrix = function (rmat, space, mesh) {
  10328. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10329. var lmat = this.getLocalMatrix();
  10330. var lx = lmat.m[12];
  10331. var ly = lmat.m[13];
  10332. var lz = lmat.m[14];
  10333. var parent = this.getParent();
  10334. var parentScale = Bone._tmpMats[3];
  10335. var parentScaleInv = Bone._tmpMats[4];
  10336. if (parent && space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD) {
  10337. if (mesh) {
  10338. parentScale.copyFrom(mesh.getWorldMatrix());
  10339. parent.getAbsoluteTransform().multiplyToRef(parentScale, parentScale);
  10340. }
  10341. else {
  10342. parentScale.copyFrom(parent.getAbsoluteTransform());
  10343. }
  10344. parentScaleInv.copyFrom(parentScale);
  10345. parentScaleInv.invert();
  10346. lmat.multiplyToRef(parentScale, lmat);
  10347. lmat.multiplyToRef(rmat, lmat);
  10348. lmat.multiplyToRef(parentScaleInv, lmat);
  10349. }
  10350. else {
  10351. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD && mesh) {
  10352. parentScale.copyFrom(mesh.getWorldMatrix());
  10353. parentScaleInv.copyFrom(parentScale);
  10354. parentScaleInv.invert();
  10355. lmat.multiplyToRef(parentScale, lmat);
  10356. lmat.multiplyToRef(rmat, lmat);
  10357. lmat.multiplyToRef(parentScaleInv, lmat);
  10358. }
  10359. else {
  10360. lmat.multiplyToRef(rmat, lmat);
  10361. }
  10362. }
  10363. lmat.setTranslationFromFloats(lx, ly, lz);
  10364. this.computeAbsoluteTransforms();
  10365. this._markAsDirtyAndDecompose();
  10366. };
  10367. Bone.prototype._getNegativeRotationToRef = function (rotMatInv, mesh) {
  10368. var scaleMatrix = Bone._tmpMats[2];
  10369. rotMatInv.copyFrom(this.getAbsoluteTransform());
  10370. if (mesh) {
  10371. rotMatInv.multiplyToRef(mesh.getWorldMatrix(), rotMatInv);
  10372. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(mesh.scaling.x, mesh.scaling.y, mesh.scaling.z, scaleMatrix);
  10373. }
  10374. rotMatInv.invert();
  10375. if (isNaN(rotMatInv.m[0])) {
  10376. // Matrix failed to invert.
  10377. // This can happen if scale is zero for example.
  10378. return false;
  10379. }
  10380. scaleMatrix.multiplyAtIndex(0, this._scalingDeterminant);
  10381. rotMatInv.multiplyToRef(scaleMatrix, rotMatInv);
  10382. return true;
  10383. };
  10384. /**
  10385. * Get the position of the bone in local or world space
  10386. * @param space The space that the returned position is in
  10387. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10388. * @returns The position of the bone
  10389. */
  10390. Bone.prototype.getPosition = function (space, mesh) {
  10391. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10392. if (mesh === void 0) { mesh = null; }
  10393. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10394. this.getPositionToRef(space, mesh, pos);
  10395. return pos;
  10396. };
  10397. /**
  10398. * Copy the position of the bone to a vector3 in local or world space
  10399. * @param space The space that the returned position is in
  10400. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10401. * @param result The vector3 to copy the position to
  10402. */
  10403. Bone.prototype.getPositionToRef = function (space, mesh, result) {
  10404. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10405. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10406. var lm = this.getLocalMatrix();
  10407. result.x = lm.m[12];
  10408. result.y = lm.m[13];
  10409. result.z = lm.m[14];
  10410. }
  10411. else {
  10412. var wm = null;
  10413. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10414. if (mesh) {
  10415. wm = mesh.getWorldMatrix();
  10416. }
  10417. this._skeleton.computeAbsoluteTransforms();
  10418. var tmat = Bone._tmpMats[0];
  10419. if (mesh && wm) {
  10420. tmat.copyFrom(this.getAbsoluteTransform());
  10421. tmat.multiplyToRef(wm, tmat);
  10422. }
  10423. else {
  10424. tmat = this.getAbsoluteTransform();
  10425. }
  10426. result.x = tmat.m[12];
  10427. result.y = tmat.m[13];
  10428. result.z = tmat.m[14];
  10429. }
  10430. };
  10431. /**
  10432. * Get the absolute position of the bone (world space)
  10433. * @param mesh The mesh that this bone is attached to
  10434. * @returns The absolute position of the bone
  10435. */
  10436. Bone.prototype.getAbsolutePosition = function (mesh) {
  10437. if (mesh === void 0) { mesh = null; }
  10438. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10439. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, pos);
  10440. return pos;
  10441. };
  10442. /**
  10443. * Copy the absolute position of the bone (world space) to the result param
  10444. * @param mesh The mesh that this bone is attached to
  10445. * @param result The vector3 to copy the absolute position to
  10446. */
  10447. Bone.prototype.getAbsolutePositionToRef = function (mesh, result) {
  10448. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, result);
  10449. };
  10450. /**
  10451. * Compute the absolute transforms of this bone and its children
  10452. */
  10453. Bone.prototype.computeAbsoluteTransforms = function () {
  10454. this._compose();
  10455. if (this._parent) {
  10456. this._localMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10457. }
  10458. else {
  10459. this._absoluteTransform.copyFrom(this._localMatrix);
  10460. var poseMatrix = this._skeleton.getPoseMatrix();
  10461. if (poseMatrix) {
  10462. this._absoluteTransform.multiplyToRef(poseMatrix, this._absoluteTransform);
  10463. }
  10464. }
  10465. var children = this.children;
  10466. var len = children.length;
  10467. for (var i = 0; i < len; i++) {
  10468. children[i].computeAbsoluteTransforms();
  10469. }
  10470. };
  10471. /**
  10472. * Get the world direction from an axis that is in the local space of the bone
  10473. * @param localAxis The local direction that is used to compute the world direction
  10474. * @param mesh The mesh that this bone is attached to
  10475. * @returns The world direction
  10476. */
  10477. Bone.prototype.getDirection = function (localAxis, mesh) {
  10478. if (mesh === void 0) { mesh = null; }
  10479. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10480. this.getDirectionToRef(localAxis, mesh, result);
  10481. return result;
  10482. };
  10483. /**
  10484. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  10485. * @param localAxis The local direction that is used to compute the world direction
  10486. * @param mesh The mesh that this bone is attached to
  10487. * @param result The vector3 that the world direction will be copied to
  10488. */
  10489. Bone.prototype.getDirectionToRef = function (localAxis, mesh, result) {
  10490. if (mesh === void 0) { mesh = null; }
  10491. var wm = null;
  10492. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10493. if (mesh) {
  10494. wm = mesh.getWorldMatrix();
  10495. }
  10496. this._skeleton.computeAbsoluteTransforms();
  10497. var mat = Bone._tmpMats[0];
  10498. mat.copyFrom(this.getAbsoluteTransform());
  10499. if (mesh && wm) {
  10500. mat.multiplyToRef(wm, mat);
  10501. }
  10502. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(localAxis, mat, result);
  10503. result.normalize();
  10504. };
  10505. /**
  10506. * Get the euler rotation of the bone in local or world space
  10507. * @param space The space that the rotation should be in
  10508. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10509. * @returns The euler rotation
  10510. */
  10511. Bone.prototype.getRotation = function (space, mesh) {
  10512. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10513. if (mesh === void 0) { mesh = null; }
  10514. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10515. this.getRotationToRef(space, mesh, result);
  10516. return result;
  10517. };
  10518. /**
  10519. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  10520. * @param space The space that the rotation should be in
  10521. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10522. * @param result The vector3 that the rotation should be copied to
  10523. */
  10524. Bone.prototype.getRotationToRef = function (space, mesh, result) {
  10525. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10526. if (mesh === void 0) { mesh = null; }
  10527. var quat = Bone._tmpQuat;
  10528. this.getRotationQuaternionToRef(space, mesh, quat);
  10529. quat.toEulerAnglesToRef(result);
  10530. };
  10531. /**
  10532. * Get the quaternion rotation of the bone in either local or world space
  10533. * @param space The space that the rotation should be in
  10534. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10535. * @returns The quaternion rotation
  10536. */
  10537. Bone.prototype.getRotationQuaternion = function (space, mesh) {
  10538. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10539. if (mesh === void 0) { mesh = null; }
  10540. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10541. this.getRotationQuaternionToRef(space, mesh, result);
  10542. return result;
  10543. };
  10544. /**
  10545. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  10546. * @param space The space that the rotation should be in
  10547. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10548. * @param result The quaternion that the rotation should be copied to
  10549. */
  10550. Bone.prototype.getRotationQuaternionToRef = function (space, mesh, result) {
  10551. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10552. if (mesh === void 0) { mesh = null; }
  10553. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10554. this._decompose();
  10555. result.copyFrom(this._localRotation);
  10556. }
  10557. else {
  10558. var mat = Bone._tmpMats[0];
  10559. var amat = this.getAbsoluteTransform();
  10560. if (mesh) {
  10561. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10562. }
  10563. else {
  10564. mat.copyFrom(amat);
  10565. }
  10566. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10567. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10568. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10569. mat.decompose(undefined, result, undefined);
  10570. }
  10571. };
  10572. /**
  10573. * Get the rotation matrix of the bone in local or world space
  10574. * @param space The space that the rotation should be in
  10575. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10576. * @returns The rotation matrix
  10577. */
  10578. Bone.prototype.getRotationMatrix = function (space, mesh) {
  10579. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10580. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  10581. this.getRotationMatrixToRef(space, mesh, result);
  10582. return result;
  10583. };
  10584. /**
  10585. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  10586. * @param space The space that the rotation should be in
  10587. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10588. * @param result The quaternion that the rotation should be copied to
  10589. */
  10590. Bone.prototype.getRotationMatrixToRef = function (space, mesh, result) {
  10591. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10592. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10593. this.getLocalMatrix().getRotationMatrixToRef(result);
  10594. }
  10595. else {
  10596. var mat = Bone._tmpMats[0];
  10597. var amat = this.getAbsoluteTransform();
  10598. if (mesh) {
  10599. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10600. }
  10601. else {
  10602. mat.copyFrom(amat);
  10603. }
  10604. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10605. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10606. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10607. mat.getRotationMatrixToRef(result);
  10608. }
  10609. };
  10610. /**
  10611. * Get the world position of a point that is in the local space of the bone
  10612. * @param position The local position
  10613. * @param mesh The mesh that this bone is attached to
  10614. * @returns The world position
  10615. */
  10616. Bone.prototype.getAbsolutePositionFromLocal = function (position, mesh) {
  10617. if (mesh === void 0) { mesh = null; }
  10618. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10619. this.getAbsolutePositionFromLocalToRef(position, mesh, result);
  10620. return result;
  10621. };
  10622. /**
  10623. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  10624. * @param position The local position
  10625. * @param mesh The mesh that this bone is attached to
  10626. * @param result The vector3 that the world position should be copied to
  10627. */
  10628. Bone.prototype.getAbsolutePositionFromLocalToRef = function (position, mesh, result) {
  10629. if (mesh === void 0) { mesh = null; }
  10630. var wm = null;
  10631. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10632. if (mesh) {
  10633. wm = mesh.getWorldMatrix();
  10634. }
  10635. this._skeleton.computeAbsoluteTransforms();
  10636. var tmat = Bone._tmpMats[0];
  10637. if (mesh && wm) {
  10638. tmat.copyFrom(this.getAbsoluteTransform());
  10639. tmat.multiplyToRef(wm, tmat);
  10640. }
  10641. else {
  10642. tmat = this.getAbsoluteTransform();
  10643. }
  10644. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10645. };
  10646. /**
  10647. * Get the local position of a point that is in world space
  10648. * @param position The world position
  10649. * @param mesh The mesh that this bone is attached to
  10650. * @returns The local position
  10651. */
  10652. Bone.prototype.getLocalPositionFromAbsolute = function (position, mesh) {
  10653. if (mesh === void 0) { mesh = null; }
  10654. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10655. this.getLocalPositionFromAbsoluteToRef(position, mesh, result);
  10656. return result;
  10657. };
  10658. /**
  10659. * Get the local position of a point that is in world space and copy it to the result param
  10660. * @param position The world position
  10661. * @param mesh The mesh that this bone is attached to
  10662. * @param result The vector3 that the local position should be copied to
  10663. */
  10664. Bone.prototype.getLocalPositionFromAbsoluteToRef = function (position, mesh, result) {
  10665. if (mesh === void 0) { mesh = null; }
  10666. var wm = null;
  10667. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10668. if (mesh) {
  10669. wm = mesh.getWorldMatrix();
  10670. }
  10671. this._skeleton.computeAbsoluteTransforms();
  10672. var tmat = Bone._tmpMats[0];
  10673. tmat.copyFrom(this.getAbsoluteTransform());
  10674. if (mesh && wm) {
  10675. tmat.multiplyToRef(wm, tmat);
  10676. }
  10677. tmat.invert();
  10678. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10679. };
  10680. Bone._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  10681. Bone._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10682. Bone._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  10683. return Bone;
  10684. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  10685. /***/ }),
  10686. /***/ "./Bones/boneIKController.ts":
  10687. /*!***********************************!*\
  10688. !*** ./Bones/boneIKController.ts ***!
  10689. \***********************************/
  10690. /*! exports provided: BoneIKController */
  10691. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10692. "use strict";
  10693. __webpack_require__.r(__webpack_exports__);
  10694. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return BoneIKController; });
  10695. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10696. /**
  10697. * Class used to apply inverse kinematics to bones
  10698. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  10699. */
  10700. var BoneIKController = /** @class */ (function () {
  10701. /**
  10702. * Creates a new BoneIKController
  10703. * @param mesh defines the mesh to control
  10704. * @param bone defines the bone to control
  10705. * @param options defines options to set up the controller
  10706. */
  10707. function BoneIKController(mesh, bone, options) {
  10708. /**
  10709. * Gets or sets the target position
  10710. */
  10711. this.targetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10712. /**
  10713. * Gets or sets the pole target position
  10714. */
  10715. this.poleTargetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10716. /**
  10717. * Gets or sets the pole target local offset
  10718. */
  10719. this.poleTargetLocalOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10720. /**
  10721. * Gets or sets the pole angle
  10722. */
  10723. this.poleAngle = 0;
  10724. /**
  10725. * 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)
  10726. */
  10727. this.slerpAmount = 1;
  10728. this._bone1Quat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10729. this._bone1Mat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  10730. this._bone2Ang = Math.PI;
  10731. this._maxAngle = Math.PI;
  10732. this._rightHandedSystem = false;
  10733. this._bendAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right();
  10734. this._slerping = false;
  10735. this._adjustRoll = 0;
  10736. this._bone2 = bone;
  10737. this._bone1 = bone.getParent();
  10738. if (!this._bone1) {
  10739. return;
  10740. }
  10741. this.mesh = mesh;
  10742. var bonePos = bone.getPosition();
  10743. if (bone.getAbsoluteTransform().determinant() > 0) {
  10744. this._rightHandedSystem = true;
  10745. this._bendAxis.x = 0;
  10746. this._bendAxis.y = 0;
  10747. this._bendAxis.z = -1;
  10748. if (bonePos.x > bonePos.y && bonePos.x > bonePos.z) {
  10749. this._adjustRoll = Math.PI * .5;
  10750. this._bendAxis.z = 1;
  10751. }
  10752. }
  10753. if (this._bone1.length) {
  10754. var boneScale1 = this._bone1.getScale();
  10755. var boneScale2 = this._bone2.getScale();
  10756. this._bone1Length = this._bone1.length * boneScale1.y * this.mesh.scaling.y;
  10757. this._bone2Length = this._bone2.length * boneScale2.y * this.mesh.scaling.y;
  10758. }
  10759. else if (this._bone1.children[0]) {
  10760. mesh.computeWorldMatrix(true);
  10761. var pos1 = this._bone2.children[0].getAbsolutePosition(mesh);
  10762. var pos2 = this._bone2.getAbsolutePosition(mesh);
  10763. var pos3 = this._bone1.getAbsolutePosition(mesh);
  10764. this._bone1Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos1, pos2);
  10765. this._bone2Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos2, pos3);
  10766. }
  10767. this._bone1.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, mesh, this._bone1Mat);
  10768. this.maxAngle = Math.PI;
  10769. if (options) {
  10770. if (options.targetMesh) {
  10771. this.targetMesh = options.targetMesh;
  10772. this.targetMesh.computeWorldMatrix(true);
  10773. }
  10774. if (options.poleTargetMesh) {
  10775. this.poleTargetMesh = options.poleTargetMesh;
  10776. this.poleTargetMesh.computeWorldMatrix(true);
  10777. }
  10778. else if (options.poleTargetBone) {
  10779. this.poleTargetBone = options.poleTargetBone;
  10780. }
  10781. else if (this._bone1.getParent()) {
  10782. this.poleTargetBone = this._bone1.getParent();
  10783. }
  10784. if (options.poleTargetLocalOffset) {
  10785. this.poleTargetLocalOffset.copyFrom(options.poleTargetLocalOffset);
  10786. }
  10787. if (options.poleAngle) {
  10788. this.poleAngle = options.poleAngle;
  10789. }
  10790. if (options.bendAxis) {
  10791. this._bendAxis.copyFrom(options.bendAxis);
  10792. }
  10793. if (options.maxAngle) {
  10794. this.maxAngle = options.maxAngle;
  10795. }
  10796. if (options.slerpAmount) {
  10797. this.slerpAmount = options.slerpAmount;
  10798. }
  10799. }
  10800. }
  10801. Object.defineProperty(BoneIKController.prototype, "maxAngle", {
  10802. /**
  10803. * Gets or sets maximum allowed angle
  10804. */
  10805. get: function () {
  10806. return this._maxAngle;
  10807. },
  10808. set: function (value) {
  10809. this._setMaxAngle(value);
  10810. },
  10811. enumerable: true,
  10812. configurable: true
  10813. });
  10814. BoneIKController.prototype._setMaxAngle = function (ang) {
  10815. if (ang < 0) {
  10816. ang = 0;
  10817. }
  10818. if (ang > Math.PI || ang == undefined) {
  10819. ang = Math.PI;
  10820. }
  10821. this._maxAngle = ang;
  10822. var a = this._bone1Length;
  10823. var b = this._bone2Length;
  10824. this._maxReach = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(ang));
  10825. };
  10826. /**
  10827. * Force the controller to update the bones
  10828. */
  10829. BoneIKController.prototype.update = function () {
  10830. var bone1 = this._bone1;
  10831. if (!bone1) {
  10832. return;
  10833. }
  10834. var target = this.targetPosition;
  10835. var poleTarget = this.poleTargetPosition;
  10836. var mat1 = BoneIKController._tmpMats[0];
  10837. var mat2 = BoneIKController._tmpMats[1];
  10838. if (this.targetMesh) {
  10839. target.copyFrom(this.targetMesh.getAbsolutePosition());
  10840. }
  10841. if (this.poleTargetBone) {
  10842. this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset, this.mesh, poleTarget);
  10843. }
  10844. else if (this.poleTargetMesh) {
  10845. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this.poleTargetLocalOffset, this.poleTargetMesh.getWorldMatrix(), poleTarget);
  10846. }
  10847. var bonePos = BoneIKController._tmpVecs[0];
  10848. var zaxis = BoneIKController._tmpVecs[1];
  10849. var xaxis = BoneIKController._tmpVecs[2];
  10850. var yaxis = BoneIKController._tmpVecs[3];
  10851. var upAxis = BoneIKController._tmpVecs[4];
  10852. var _tmpQuat = BoneIKController._tmpQuat;
  10853. bone1.getAbsolutePositionToRef(this.mesh, bonePos);
  10854. poleTarget.subtractToRef(bonePos, upAxis);
  10855. if (upAxis.x == 0 && upAxis.y == 0 && upAxis.z == 0) {
  10856. upAxis.y = 1;
  10857. }
  10858. else {
  10859. upAxis.normalize();
  10860. }
  10861. target.subtractToRef(bonePos, yaxis);
  10862. yaxis.normalize();
  10863. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, upAxis, zaxis);
  10864. zaxis.normalize();
  10865. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, zaxis, xaxis);
  10866. xaxis.normalize();
  10867. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, mat1);
  10868. var a = this._bone1Length;
  10869. var b = this._bone2Length;
  10870. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(bonePos, target);
  10871. if (this._maxReach > 0) {
  10872. c = Math.min(this._maxReach, c);
  10873. }
  10874. var acosa = (b * b + c * c - a * a) / (2 * b * c);
  10875. var acosb = (c * c + a * a - b * b) / (2 * c * a);
  10876. if (acosa > 1) {
  10877. acosa = 1;
  10878. }
  10879. if (acosb > 1) {
  10880. acosb = 1;
  10881. }
  10882. if (acosa < -1) {
  10883. acosa = -1;
  10884. }
  10885. if (acosb < -1) {
  10886. acosb = -1;
  10887. }
  10888. var angA = Math.acos(acosa);
  10889. var angB = Math.acos(acosb);
  10890. var angC = -angA - angB;
  10891. if (this._rightHandedSystem) {
  10892. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationYawPitchRollToRef(0, 0, this._adjustRoll, mat2);
  10893. mat2.multiplyToRef(mat1, mat1);
  10894. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(this._bendAxis, angB, mat2);
  10895. mat2.multiplyToRef(mat1, mat1);
  10896. }
  10897. else {
  10898. var _tmpVec = BoneIKController._tmpVecs[5];
  10899. _tmpVec.copyFrom(this._bendAxis);
  10900. _tmpVec.x *= -1;
  10901. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(_tmpVec, -angB, mat2);
  10902. mat2.multiplyToRef(mat1, mat1);
  10903. }
  10904. if (this.poleAngle) {
  10905. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(yaxis, this.poleAngle, mat2);
  10906. mat1.multiplyToRef(mat2, mat1);
  10907. }
  10908. if (this._bone1) {
  10909. if (this.slerpAmount < 1) {
  10910. if (!this._slerping) {
  10911. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._bone1Mat, this._bone1Quat);
  10912. }
  10913. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(mat1, _tmpQuat);
  10914. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].SlerpToRef(this._bone1Quat, _tmpQuat, this.slerpAmount, this._bone1Quat);
  10915. angC = this._bone2Ang * (1.0 - this.slerpAmount) + angC * this.slerpAmount;
  10916. this._bone1.setRotationQuaternion(this._bone1Quat, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10917. this._slerping = true;
  10918. }
  10919. else {
  10920. this._bone1.setRotationMatrix(mat1, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10921. this._bone1Mat.copyFrom(mat1);
  10922. this._slerping = false;
  10923. }
  10924. }
  10925. this._bone2.setAxisAngle(this._bendAxis, angC, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].LOCAL);
  10926. this._bone2Ang = angC;
  10927. };
  10928. 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()];
  10929. BoneIKController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10930. BoneIKController._tmpMats = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity()];
  10931. return BoneIKController;
  10932. }());
  10933. /***/ }),
  10934. /***/ "./Bones/boneLookController.ts":
  10935. /*!*************************************!*\
  10936. !*** ./Bones/boneLookController.ts ***!
  10937. \*************************************/
  10938. /*! exports provided: BoneLookController */
  10939. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10940. "use strict";
  10941. __webpack_require__.r(__webpack_exports__);
  10942. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return BoneLookController; });
  10943. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  10944. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10945. /**
  10946. * Class used to make a bone look toward a point in space
  10947. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  10948. */
  10949. var BoneLookController = /** @class */ (function () {
  10950. /**
  10951. * Create a BoneLookController
  10952. * @param mesh the mesh that the bone belongs to
  10953. * @param bone the bone that will be looking to the target
  10954. * @param target the target Vector3 to look at
  10955. * @param options optional settings:
  10956. * * maxYaw: the maximum angle the bone will yaw to
  10957. * * minYaw: the minimum angle the bone will yaw to
  10958. * * maxPitch: the maximum angle the bone will pitch to
  10959. * * minPitch: the minimum angle the bone will yaw to
  10960. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  10961. * * upAxis: the up axis of the coordinate system
  10962. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  10963. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  10964. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  10965. * * adjustYaw: used to make an adjustment to the yaw of the bone
  10966. * * adjustPitch: used to make an adjustment to the pitch of the bone
  10967. * * adjustRoll: used to make an adjustment to the roll of the bone
  10968. **/
  10969. function BoneLookController(mesh, bone, target, options) {
  10970. /**
  10971. * The up axis of the coordinate system that is used when the bone is rotated
  10972. */
  10973. this.upAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up();
  10974. /**
  10975. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  10976. */
  10977. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  10978. /**
  10979. * Used to make an adjustment to the yaw of the bone
  10980. */
  10981. this.adjustYaw = 0;
  10982. /**
  10983. * Used to make an adjustment to the pitch of the bone
  10984. */
  10985. this.adjustPitch = 0;
  10986. /**
  10987. * Used to make an adjustment to the roll of the bone
  10988. */
  10989. this.adjustRoll = 0;
  10990. /**
  10991. * 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)
  10992. */
  10993. this.slerpAmount = 1;
  10994. this._boneQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10995. this._slerping = false;
  10996. this._firstFrameSkipped = false;
  10997. this._fowardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Forward();
  10998. this.mesh = mesh;
  10999. this.bone = bone;
  11000. this.target = target;
  11001. if (options) {
  11002. if (options.adjustYaw) {
  11003. this.adjustYaw = options.adjustYaw;
  11004. }
  11005. if (options.adjustPitch) {
  11006. this.adjustPitch = options.adjustPitch;
  11007. }
  11008. if (options.adjustRoll) {
  11009. this.adjustRoll = options.adjustRoll;
  11010. }
  11011. if (options.maxYaw != null) {
  11012. this.maxYaw = options.maxYaw;
  11013. }
  11014. else {
  11015. this.maxYaw = Math.PI;
  11016. }
  11017. if (options.minYaw != null) {
  11018. this.minYaw = options.minYaw;
  11019. }
  11020. else {
  11021. this.minYaw = -Math.PI;
  11022. }
  11023. if (options.maxPitch != null) {
  11024. this.maxPitch = options.maxPitch;
  11025. }
  11026. else {
  11027. this.maxPitch = Math.PI;
  11028. }
  11029. if (options.minPitch != null) {
  11030. this.minPitch = options.minPitch;
  11031. }
  11032. else {
  11033. this.minPitch = -Math.PI;
  11034. }
  11035. if (options.slerpAmount != null) {
  11036. this.slerpAmount = options.slerpAmount;
  11037. }
  11038. if (options.upAxis != null) {
  11039. this.upAxis = options.upAxis;
  11040. }
  11041. if (options.upAxisSpace != null) {
  11042. this.upAxisSpace = options.upAxisSpace;
  11043. }
  11044. if (options.yawAxis != null || options.pitchAxis != null) {
  11045. var newYawAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y;
  11046. var newPitchAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].X;
  11047. if (options.yawAxis != null) {
  11048. newYawAxis = options.yawAxis.clone();
  11049. newYawAxis.normalize();
  11050. }
  11051. if (options.pitchAxis != null) {
  11052. newPitchAxis = options.pitchAxis.clone();
  11053. newPitchAxis.normalize();
  11054. }
  11055. var newRollAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(newPitchAxis, newYawAxis);
  11056. this._transformYawPitch = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  11057. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(newPitchAxis, newYawAxis, newRollAxis, this._transformYawPitch);
  11058. this._transformYawPitchInv = this._transformYawPitch.clone();
  11059. this._transformYawPitch.invert();
  11060. }
  11061. }
  11062. if (!bone.getParent() && this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE) {
  11063. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  11064. }
  11065. }
  11066. Object.defineProperty(BoneLookController.prototype, "minYaw", {
  11067. /**
  11068. * Gets or sets the minimum yaw angle that the bone can look to
  11069. */
  11070. get: function () {
  11071. return this._minYaw;
  11072. },
  11073. set: function (value) {
  11074. this._minYaw = value;
  11075. this._minYawSin = Math.sin(value);
  11076. this._minYawCos = Math.cos(value);
  11077. if (this._maxYaw != null) {
  11078. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11079. this._yawRange = this._maxYaw - this._minYaw;
  11080. }
  11081. },
  11082. enumerable: true,
  11083. configurable: true
  11084. });
  11085. Object.defineProperty(BoneLookController.prototype, "maxYaw", {
  11086. /**
  11087. * Gets or sets the maximum yaw angle that the bone can look to
  11088. */
  11089. get: function () {
  11090. return this._maxYaw;
  11091. },
  11092. set: function (value) {
  11093. this._maxYaw = value;
  11094. this._maxYawSin = Math.sin(value);
  11095. this._maxYawCos = Math.cos(value);
  11096. if (this._minYaw != null) {
  11097. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11098. this._yawRange = this._maxYaw - this._minYaw;
  11099. }
  11100. },
  11101. enumerable: true,
  11102. configurable: true
  11103. });
  11104. Object.defineProperty(BoneLookController.prototype, "minPitch", {
  11105. /**
  11106. * Gets or sets the minimum pitch angle that the bone can look to
  11107. */
  11108. get: function () {
  11109. return this._minPitch;
  11110. },
  11111. set: function (value) {
  11112. this._minPitch = value;
  11113. this._minPitchTan = Math.tan(value);
  11114. },
  11115. enumerable: true,
  11116. configurable: true
  11117. });
  11118. Object.defineProperty(BoneLookController.prototype, "maxPitch", {
  11119. /**
  11120. * Gets or sets the maximum pitch angle that the bone can look to
  11121. */
  11122. get: function () {
  11123. return this._maxPitch;
  11124. },
  11125. set: function (value) {
  11126. this._maxPitch = value;
  11127. this._maxPitchTan = Math.tan(value);
  11128. },
  11129. enumerable: true,
  11130. configurable: true
  11131. });
  11132. /**
  11133. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  11134. */
  11135. BoneLookController.prototype.update = function () {
  11136. //skip the first frame when slerping so that the mesh rotation is correct
  11137. if (this.slerpAmount < 1 && !this._firstFrameSkipped) {
  11138. this._firstFrameSkipped = true;
  11139. return;
  11140. }
  11141. var bone = this.bone;
  11142. var bonePos = BoneLookController._tmpVecs[0];
  11143. bone.getAbsolutePositionToRef(this.mesh, bonePos);
  11144. var target = this.target;
  11145. var _tmpMat1 = BoneLookController._tmpMats[0];
  11146. var _tmpMat2 = BoneLookController._tmpMats[1];
  11147. var mesh = this.mesh;
  11148. var parentBone = bone.getParent();
  11149. var upAxis = BoneLookController._tmpVecs[1];
  11150. upAxis.copyFrom(this.upAxis);
  11151. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && parentBone) {
  11152. if (this._transformYawPitch) {
  11153. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(upAxis, this._transformYawPitchInv, upAxis);
  11154. }
  11155. parentBone.getDirectionToRef(upAxis, this.mesh, upAxis);
  11156. }
  11157. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  11158. mesh.getDirectionToRef(upAxis, upAxis);
  11159. if (mesh.scaling.x != 1 || mesh.scaling.y != 1 || mesh.scaling.z != 1) {
  11160. upAxis.normalize();
  11161. }
  11162. }
  11163. var checkYaw = false;
  11164. var checkPitch = false;
  11165. if (this._maxYaw != Math.PI || this._minYaw != -Math.PI) {
  11166. checkYaw = true;
  11167. }
  11168. if (this._maxPitch != Math.PI || this._minPitch != -Math.PI) {
  11169. checkPitch = true;
  11170. }
  11171. if (checkYaw || checkPitch) {
  11172. var spaceMat = BoneLookController._tmpMats[2];
  11173. var spaceMatInv = BoneLookController._tmpMats[3];
  11174. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && upAxis.y == 1 && parentBone) {
  11175. parentBone.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, spaceMat);
  11176. }
  11177. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL && upAxis.y == 1 && !parentBone) {
  11178. spaceMat.copyFrom(mesh.getWorldMatrix());
  11179. }
  11180. else {
  11181. var forwardAxis = BoneLookController._tmpVecs[2];
  11182. forwardAxis.copyFrom(this._fowardAxis);
  11183. if (this._transformYawPitch) {
  11184. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(forwardAxis, this._transformYawPitchInv, forwardAxis);
  11185. }
  11186. if (parentBone) {
  11187. parentBone.getDirectionToRef(forwardAxis, this.mesh, forwardAxis);
  11188. }
  11189. else {
  11190. mesh.getDirectionToRef(forwardAxis, forwardAxis);
  11191. }
  11192. var rightAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(upAxis, forwardAxis);
  11193. rightAxis.normalize();
  11194. var forwardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(rightAxis, upAxis);
  11195. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(rightAxis, upAxis, forwardAxis, spaceMat);
  11196. }
  11197. spaceMat.invertToRef(spaceMatInv);
  11198. var xzlen = null;
  11199. if (checkPitch) {
  11200. var localTarget = BoneLookController._tmpVecs[3];
  11201. target.subtractToRef(bonePos, localTarget);
  11202. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11203. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11204. var pitch = Math.atan2(localTarget.y, xzlen);
  11205. var newPitch = pitch;
  11206. if (pitch > this._maxPitch) {
  11207. localTarget.y = this._maxPitchTan * xzlen;
  11208. newPitch = this._maxPitch;
  11209. }
  11210. else if (pitch < this._minPitch) {
  11211. localTarget.y = this._minPitchTan * xzlen;
  11212. newPitch = this._minPitch;
  11213. }
  11214. if (pitch != newPitch) {
  11215. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11216. localTarget.addInPlace(bonePos);
  11217. target = localTarget;
  11218. }
  11219. }
  11220. if (checkYaw) {
  11221. var localTarget = BoneLookController._tmpVecs[4];
  11222. target.subtractToRef(bonePos, localTarget);
  11223. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11224. var yaw = Math.atan2(localTarget.x, localTarget.z);
  11225. var newYaw = yaw;
  11226. if (yaw > this._maxYaw || yaw < this._minYaw) {
  11227. if (xzlen == null) {
  11228. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11229. }
  11230. if (this._yawRange > Math.PI) {
  11231. if (this._isAngleBetween(yaw, this._maxYaw, this._midYawConstraint)) {
  11232. localTarget.z = this._maxYawCos * xzlen;
  11233. localTarget.x = this._maxYawSin * xzlen;
  11234. newYaw = this._maxYaw;
  11235. }
  11236. else if (this._isAngleBetween(yaw, this._midYawConstraint, this._minYaw)) {
  11237. localTarget.z = this._minYawCos * xzlen;
  11238. localTarget.x = this._minYawSin * xzlen;
  11239. newYaw = this._minYaw;
  11240. }
  11241. }
  11242. else {
  11243. if (yaw > this._maxYaw) {
  11244. localTarget.z = this._maxYawCos * xzlen;
  11245. localTarget.x = this._maxYawSin * xzlen;
  11246. newYaw = this._maxYaw;
  11247. }
  11248. else if (yaw < this._minYaw) {
  11249. localTarget.z = this._minYawCos * xzlen;
  11250. localTarget.x = this._minYawSin * xzlen;
  11251. newYaw = this._minYaw;
  11252. }
  11253. }
  11254. }
  11255. if (this._slerping && this._yawRange > Math.PI) {
  11256. //are we going to be crossing into the min/max region?
  11257. var boneFwd = BoneLookController._tmpVecs[8];
  11258. boneFwd.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Z);
  11259. if (this._transformYawPitch) {
  11260. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, this._transformYawPitchInv, boneFwd);
  11261. }
  11262. var boneRotMat = BoneLookController._tmpMats[4];
  11263. this._boneQuat.toRotationMatrix(boneRotMat);
  11264. this.mesh.getWorldMatrix().multiplyToRef(boneRotMat, boneRotMat);
  11265. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, boneRotMat, boneFwd);
  11266. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, spaceMatInv, boneFwd);
  11267. var boneYaw = Math.atan2(boneFwd.x, boneFwd.z);
  11268. var angBtwTar = this._getAngleBetween(boneYaw, yaw);
  11269. var angBtwMidYaw = this._getAngleBetween(boneYaw, this._midYawConstraint);
  11270. if (angBtwTar > angBtwMidYaw) {
  11271. if (xzlen == null) {
  11272. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11273. }
  11274. var angBtwMax = this._getAngleBetween(boneYaw, this._maxYaw);
  11275. var angBtwMin = this._getAngleBetween(boneYaw, this._minYaw);
  11276. if (angBtwMin < angBtwMax) {
  11277. newYaw = boneYaw + Math.PI * .75;
  11278. localTarget.z = Math.cos(newYaw) * xzlen;
  11279. localTarget.x = Math.sin(newYaw) * xzlen;
  11280. }
  11281. else {
  11282. newYaw = boneYaw - Math.PI * .75;
  11283. localTarget.z = Math.cos(newYaw) * xzlen;
  11284. localTarget.x = Math.sin(newYaw) * xzlen;
  11285. }
  11286. }
  11287. }
  11288. if (yaw != newYaw) {
  11289. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11290. localTarget.addInPlace(bonePos);
  11291. target = localTarget;
  11292. }
  11293. }
  11294. }
  11295. var zaxis = BoneLookController._tmpVecs[5];
  11296. var xaxis = BoneLookController._tmpVecs[6];
  11297. var yaxis = BoneLookController._tmpVecs[7];
  11298. var _tmpQuat = BoneLookController._tmpQuat;
  11299. target.subtractToRef(bonePos, zaxis);
  11300. zaxis.normalize();
  11301. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(upAxis, zaxis, xaxis);
  11302. xaxis.normalize();
  11303. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(zaxis, xaxis, yaxis);
  11304. yaxis.normalize();
  11305. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, _tmpMat1);
  11306. if (xaxis.x === 0 && xaxis.y === 0 && xaxis.z === 0) {
  11307. return;
  11308. }
  11309. if (yaxis.x === 0 && yaxis.y === 0 && yaxis.z === 0) {
  11310. return;
  11311. }
  11312. if (zaxis.x === 0 && zaxis.y === 0 && zaxis.z === 0) {
  11313. return;
  11314. }
  11315. if (this.adjustYaw || this.adjustPitch || this.adjustRoll) {
  11316. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(this.adjustYaw, this.adjustPitch, this.adjustRoll, _tmpMat2);
  11317. _tmpMat2.multiplyToRef(_tmpMat1, _tmpMat1);
  11318. }
  11319. if (this.slerpAmount < 1) {
  11320. if (!this._slerping) {
  11321. this.bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, this._boneQuat);
  11322. }
  11323. if (this._transformYawPitch) {
  11324. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11325. }
  11326. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(_tmpMat1, _tmpQuat);
  11327. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].SlerpToRef(this._boneQuat, _tmpQuat, this.slerpAmount, this._boneQuat);
  11328. this.bone.setRotationQuaternion(this._boneQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11329. this._slerping = true;
  11330. }
  11331. else {
  11332. if (this._transformYawPitch) {
  11333. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11334. }
  11335. this.bone.setRotationMatrix(_tmpMat1, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11336. this._slerping = false;
  11337. }
  11338. };
  11339. BoneLookController.prototype._getAngleDiff = function (ang1, ang2) {
  11340. var angDiff = ang2 - ang1;
  11341. angDiff %= Math.PI * 2;
  11342. if (angDiff > Math.PI) {
  11343. angDiff -= Math.PI * 2;
  11344. }
  11345. else if (angDiff < -Math.PI) {
  11346. angDiff += Math.PI * 2;
  11347. }
  11348. return angDiff;
  11349. };
  11350. BoneLookController.prototype._getAngleBetween = function (ang1, ang2) {
  11351. ang1 %= (2 * Math.PI);
  11352. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11353. ang2 %= (2 * Math.PI);
  11354. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11355. var ab = 0;
  11356. if (ang1 < ang2) {
  11357. ab = ang2 - ang1;
  11358. }
  11359. else {
  11360. ab = ang1 - ang2;
  11361. }
  11362. if (ab > Math.PI) {
  11363. ab = Math.PI * 2 - ab;
  11364. }
  11365. return ab;
  11366. };
  11367. BoneLookController.prototype._isAngleBetween = function (ang, ang1, ang2) {
  11368. ang %= (2 * Math.PI);
  11369. ang = (ang < 0) ? ang + (2 * Math.PI) : ang;
  11370. ang1 %= (2 * Math.PI);
  11371. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11372. ang2 %= (2 * Math.PI);
  11373. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11374. if (ang1 < ang2) {
  11375. if (ang > ang1 && ang < ang2) {
  11376. return true;
  11377. }
  11378. }
  11379. else {
  11380. if (ang > ang2 && ang < ang1) {
  11381. return true;
  11382. }
  11383. }
  11384. return false;
  11385. };
  11386. BoneLookController._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(10, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  11387. BoneLookController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  11388. BoneLookController._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  11389. return BoneLookController;
  11390. }());
  11391. /***/ }),
  11392. /***/ "./Bones/index.ts":
  11393. /*!************************!*\
  11394. !*** ./Bones/index.ts ***!
  11395. \************************/
  11396. /*! exports provided: Bone, BoneIKController, BoneLookController, Skeleton */
  11397. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11398. "use strict";
  11399. __webpack_require__.r(__webpack_exports__);
  11400. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  11402. /* harmony import */ var _boneIKController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneIKController */ "./Bones/boneIKController.ts");
  11403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _boneIKController__WEBPACK_IMPORTED_MODULE_1__["BoneIKController"]; });
  11404. /* harmony import */ var _boneLookController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boneLookController */ "./Bones/boneLookController.ts");
  11405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _boneLookController__WEBPACK_IMPORTED_MODULE_2__["BoneLookController"]; });
  11406. /* harmony import */ var _skeleton__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./skeleton */ "./Bones/skeleton.ts");
  11407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _skeleton__WEBPACK_IMPORTED_MODULE_3__["Skeleton"]; });
  11408. /***/ }),
  11409. /***/ "./Bones/skeleton.ts":
  11410. /*!***************************!*\
  11411. !*** ./Bones/skeleton.ts ***!
  11412. \***************************/
  11413. /*! exports provided: Skeleton */
  11414. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11415. "use strict";
  11416. __webpack_require__.r(__webpack_exports__);
  11417. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return Skeleton; });
  11418. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11419. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  11420. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  11421. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  11422. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  11423. /* harmony import */ var _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animationRange */ "./Animations/animationRange.ts");
  11424. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  11425. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  11426. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  11427. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  11428. /**
  11429. * Class used to handle skinning animations
  11430. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  11431. */
  11432. var Skeleton = /** @class */ (function () {
  11433. /**
  11434. * Creates a new skeleton
  11435. * @param name defines the skeleton name
  11436. * @param id defines the skeleton Id
  11437. * @param scene defines the hosting scene
  11438. */
  11439. function Skeleton(
  11440. /** defines the skeleton name */
  11441. name,
  11442. /** defines the skeleton Id */
  11443. id, scene) {
  11444. this.name = name;
  11445. this.id = id;
  11446. /**
  11447. * Defines the list of child bones
  11448. */
  11449. this.bones = new Array();
  11450. /**
  11451. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  11452. */
  11453. this.needInitialSkinMatrix = false;
  11454. /**
  11455. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  11456. */
  11457. this.overrideMesh = null;
  11458. this._isDirty = true;
  11459. this._meshesWithPoseMatrix = new Array();
  11460. this._identity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  11461. this._ranges = {};
  11462. this._lastAbsoluteTransformsUpdateId = -1;
  11463. this._canUseTextureForBones = false;
  11464. this._uniqueId = 0;
  11465. /** @hidden */
  11466. this._numBonesWithLinkedTransformNode = 0;
  11467. /**
  11468. * Specifies if the skeleton should be serialized
  11469. */
  11470. this.doNotSerialize = false;
  11471. this._useTextureToStoreBoneMatrices = true;
  11472. this._animationPropertiesOverride = null;
  11473. // Events
  11474. /**
  11475. * An observable triggered before computing the skeleton's matrices
  11476. */
  11477. this.onBeforeComputeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11478. this.bones = [];
  11479. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  11480. this._uniqueId = this._scene.getUniqueId();
  11481. this._scene.addSkeleton(this);
  11482. //make sure it will recalculate the matrix next time prepare is called.
  11483. this._isDirty = true;
  11484. var engineCaps = this._scene.getEngine().getCaps();
  11485. this._canUseTextureForBones = engineCaps.textureFloat && engineCaps.maxVertexTextureImageUnits > 0;
  11486. }
  11487. Object.defineProperty(Skeleton.prototype, "useTextureToStoreBoneMatrices", {
  11488. /**
  11489. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  11490. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  11491. */
  11492. get: function () {
  11493. return this._useTextureToStoreBoneMatrices;
  11494. },
  11495. set: function (value) {
  11496. this._useTextureToStoreBoneMatrices = value;
  11497. this._markAsDirty();
  11498. },
  11499. enumerable: true,
  11500. configurable: true
  11501. });
  11502. Object.defineProperty(Skeleton.prototype, "animationPropertiesOverride", {
  11503. /**
  11504. * Gets or sets the animation properties override
  11505. */
  11506. get: function () {
  11507. if (!this._animationPropertiesOverride) {
  11508. return this._scene.animationPropertiesOverride;
  11509. }
  11510. return this._animationPropertiesOverride;
  11511. },
  11512. set: function (value) {
  11513. this._animationPropertiesOverride = value;
  11514. },
  11515. enumerable: true,
  11516. configurable: true
  11517. });
  11518. Object.defineProperty(Skeleton.prototype, "isUsingTextureForMatrices", {
  11519. /**
  11520. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  11521. */
  11522. get: function () {
  11523. return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones && !this.needInitialSkinMatrix;
  11524. },
  11525. enumerable: true,
  11526. configurable: true
  11527. });
  11528. Object.defineProperty(Skeleton.prototype, "uniqueId", {
  11529. /**
  11530. * Gets the unique ID of this skeleton
  11531. */
  11532. get: function () {
  11533. return this._uniqueId;
  11534. },
  11535. enumerable: true,
  11536. configurable: true
  11537. });
  11538. /**
  11539. * Gets the current object class name.
  11540. * @return the class name
  11541. */
  11542. Skeleton.prototype.getClassName = function () {
  11543. return "Skeleton";
  11544. };
  11545. /**
  11546. * Returns an array containing the root bones
  11547. * @returns an array containing the root bones
  11548. */
  11549. Skeleton.prototype.getChildren = function () {
  11550. return this.bones.filter(function (b) { return !b.getParent(); });
  11551. };
  11552. // Members
  11553. /**
  11554. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  11555. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  11556. * @returns a Float32Array containing matrices data
  11557. */
  11558. Skeleton.prototype.getTransformMatrices = function (mesh) {
  11559. if (this.needInitialSkinMatrix && mesh._bonesTransformMatrices) {
  11560. return mesh._bonesTransformMatrices;
  11561. }
  11562. if (!this._transformMatrices) {
  11563. this.prepare();
  11564. }
  11565. return this._transformMatrices;
  11566. };
  11567. /**
  11568. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  11569. * @returns a raw texture containing the data
  11570. */
  11571. Skeleton.prototype.getTransformMatrixTexture = function () {
  11572. return this._transformMatrixTexture;
  11573. };
  11574. /**
  11575. * Gets the current hosting scene
  11576. * @returns a scene object
  11577. */
  11578. Skeleton.prototype.getScene = function () {
  11579. return this._scene;
  11580. };
  11581. // Methods
  11582. /**
  11583. * Gets a string representing the current skeleton data
  11584. * @param fullDetails defines a boolean indicating if we want a verbose version
  11585. * @returns a string representing the current skeleton data
  11586. */
  11587. Skeleton.prototype.toString = function (fullDetails) {
  11588. var ret = "Name: " + this.name + ", nBones: " + this.bones.length;
  11589. ret += ", nAnimationRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  11590. if (fullDetails) {
  11591. ret += ", Ranges: {";
  11592. var first = true;
  11593. for (var name_1 in this._ranges) {
  11594. if (first) {
  11595. ret += ", ";
  11596. first = false;
  11597. }
  11598. ret += name_1;
  11599. }
  11600. ret += "}";
  11601. }
  11602. return ret;
  11603. };
  11604. /**
  11605. * Get bone's index searching by name
  11606. * @param name defines bone's name to search for
  11607. * @return the indice of the bone. Returns -1 if not found
  11608. */
  11609. Skeleton.prototype.getBoneIndexByName = function (name) {
  11610. for (var boneIndex = 0, cache = this.bones.length; boneIndex < cache; boneIndex++) {
  11611. if (this.bones[boneIndex].name === name) {
  11612. return boneIndex;
  11613. }
  11614. }
  11615. return -1;
  11616. };
  11617. /**
  11618. * Creater a new animation range
  11619. * @param name defines the name of the range
  11620. * @param from defines the start key
  11621. * @param to defines the end key
  11622. */
  11623. Skeleton.prototype.createAnimationRange = function (name, from, to) {
  11624. // check name not already in use
  11625. if (!this._ranges[name]) {
  11626. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  11627. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11628. if (this.bones[i].animations[0]) {
  11629. this.bones[i].animations[0].createRange(name, from, to);
  11630. }
  11631. }
  11632. }
  11633. };
  11634. /**
  11635. * Delete a specific animation range
  11636. * @param name defines the name of the range
  11637. * @param deleteFrames defines if frames must be removed as well
  11638. */
  11639. Skeleton.prototype.deleteAnimationRange = function (name, deleteFrames) {
  11640. if (deleteFrames === void 0) { deleteFrames = true; }
  11641. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11642. if (this.bones[i].animations[0]) {
  11643. this.bones[i].animations[0].deleteRange(name, deleteFrames);
  11644. }
  11645. }
  11646. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  11647. };
  11648. /**
  11649. * Gets a specific animation range
  11650. * @param name defines the name of the range to look for
  11651. * @returns the requested animation range or null if not found
  11652. */
  11653. Skeleton.prototype.getAnimationRange = function (name) {
  11654. return this._ranges[name];
  11655. };
  11656. /**
  11657. * Gets the list of all animation ranges defined on this skeleton
  11658. * @returns an array
  11659. */
  11660. Skeleton.prototype.getAnimationRanges = function () {
  11661. var animationRanges = [];
  11662. var name;
  11663. for (name in this._ranges) {
  11664. animationRanges.push(this._ranges[name]);
  11665. }
  11666. return animationRanges;
  11667. };
  11668. /**
  11669. * Copy animation range from a source skeleton.
  11670. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  11671. * @param source defines the source skeleton
  11672. * @param name defines the name of the range to copy
  11673. * @param rescaleAsRequired defines if rescaling must be applied if required
  11674. * @returns true if operation was successful
  11675. */
  11676. Skeleton.prototype.copyAnimationRange = function (source, name, rescaleAsRequired) {
  11677. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  11678. if (this._ranges[name] || !source.getAnimationRange(name)) {
  11679. return false;
  11680. }
  11681. var ret = true;
  11682. var frameOffset = this._getHighestAnimationFrame() + 1;
  11683. // make a dictionary of source skeleton's bones, so exact same order or doublely nested loop is not required
  11684. var boneDict = {};
  11685. var sourceBones = source.bones;
  11686. var nBones;
  11687. var i;
  11688. for (i = 0, nBones = sourceBones.length; i < nBones; i++) {
  11689. boneDict[sourceBones[i].name] = sourceBones[i];
  11690. }
  11691. if (this.bones.length !== sourceBones.length) {
  11692. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: this rig has " + this.bones.length + " bones, while source as " + sourceBones.length);
  11693. ret = false;
  11694. }
  11695. var skelDimensionsRatio = (rescaleAsRequired && this.dimensionsAtRest && source.dimensionsAtRest) ? this.dimensionsAtRest.divide(source.dimensionsAtRest) : null;
  11696. for (i = 0, nBones = this.bones.length; i < nBones; i++) {
  11697. var boneName = this.bones[i].name;
  11698. var sourceBone = boneDict[boneName];
  11699. if (sourceBone) {
  11700. ret = ret && this.bones[i].copyAnimationRange(sourceBone, name, frameOffset, rescaleAsRequired, skelDimensionsRatio);
  11701. }
  11702. else {
  11703. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: not same rig, missing source bone " + boneName);
  11704. ret = false;
  11705. }
  11706. }
  11707. // do not call createAnimationRange(), since it also is done to bones, which was already done
  11708. var range = source.getAnimationRange(name);
  11709. if (range) {
  11710. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, range.from + frameOffset, range.to + frameOffset);
  11711. }
  11712. return ret;
  11713. };
  11714. /**
  11715. * Forces the skeleton to go to rest pose
  11716. */
  11717. Skeleton.prototype.returnToRest = function () {
  11718. for (var index = 0; index < this.bones.length; index++) {
  11719. this.bones[index].returnToRest();
  11720. }
  11721. };
  11722. Skeleton.prototype._getHighestAnimationFrame = function () {
  11723. var ret = 0;
  11724. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11725. if (this.bones[i].animations[0]) {
  11726. var highest = this.bones[i].animations[0].getHighestFrame();
  11727. if (ret < highest) {
  11728. ret = highest;
  11729. }
  11730. }
  11731. }
  11732. return ret;
  11733. };
  11734. /**
  11735. * Begin a specific animation range
  11736. * @param name defines the name of the range to start
  11737. * @param loop defines if looping must be turned on (false by default)
  11738. * @param speedRatio defines the speed ratio to apply (1 by default)
  11739. * @param onAnimationEnd defines a callback which will be called when animation will end
  11740. * @returns a new animatable
  11741. */
  11742. Skeleton.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  11743. var range = this.getAnimationRange(name);
  11744. if (!range) {
  11745. return null;
  11746. }
  11747. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  11748. };
  11749. /** @hidden */
  11750. Skeleton.prototype._markAsDirty = function () {
  11751. this._isDirty = true;
  11752. };
  11753. /** @hidden */
  11754. Skeleton.prototype._registerMeshWithPoseMatrix = function (mesh) {
  11755. this._meshesWithPoseMatrix.push(mesh);
  11756. };
  11757. /** @hidden */
  11758. Skeleton.prototype._unregisterMeshWithPoseMatrix = function (mesh) {
  11759. var index = this._meshesWithPoseMatrix.indexOf(mesh);
  11760. if (index > -1) {
  11761. this._meshesWithPoseMatrix.splice(index, 1);
  11762. }
  11763. };
  11764. Skeleton.prototype._computeTransformMatrices = function (targetMatrix, initialSkinMatrix) {
  11765. this.onBeforeComputeObservable.notifyObservers(this);
  11766. for (var index = 0; index < this.bones.length; index++) {
  11767. var bone = this.bones[index];
  11768. var parentBone = bone.getParent();
  11769. if (parentBone) {
  11770. bone.getLocalMatrix().multiplyToRef(parentBone.getWorldMatrix(), bone.getWorldMatrix());
  11771. }
  11772. else {
  11773. if (initialSkinMatrix) {
  11774. bone.getLocalMatrix().multiplyToRef(initialSkinMatrix, bone.getWorldMatrix());
  11775. }
  11776. else {
  11777. bone.getWorldMatrix().copyFrom(bone.getLocalMatrix());
  11778. }
  11779. }
  11780. if (bone._index !== -1) {
  11781. var mappedIndex = bone._index === null ? index : bone._index;
  11782. bone.getInvertedAbsoluteTransform().multiplyToArray(bone.getWorldMatrix(), targetMatrix, mappedIndex * 16);
  11783. }
  11784. }
  11785. this._identity.copyToArray(targetMatrix, this.bones.length * 16);
  11786. };
  11787. /**
  11788. * Build all resources required to render a skeleton
  11789. */
  11790. Skeleton.prototype.prepare = function () {
  11791. // Update the local matrix of bones with linked transform nodes.
  11792. if (this._numBonesWithLinkedTransformNode > 0) {
  11793. for (var _i = 0, _a = this.bones; _i < _a.length; _i++) {
  11794. var bone_1 = _a[_i];
  11795. if (bone_1._linkedTransformNode) {
  11796. // Computing the world matrix also computes the local matrix.
  11797. bone_1._linkedTransformNode.computeWorldMatrix();
  11798. bone_1._matrix = bone_1._linkedTransformNode._localMatrix;
  11799. bone_1.markAsDirty();
  11800. }
  11801. }
  11802. }
  11803. if (!this._isDirty) {
  11804. return;
  11805. }
  11806. if (this.needInitialSkinMatrix) {
  11807. for (var index = 0; index < this._meshesWithPoseMatrix.length; index++) {
  11808. var mesh = this._meshesWithPoseMatrix[index];
  11809. var poseMatrix = mesh.getPoseMatrix();
  11810. if (!mesh._bonesTransformMatrices || mesh._bonesTransformMatrices.length !== 16 * (this.bones.length + 1)) {
  11811. mesh._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11812. }
  11813. if (this._synchronizedWithMesh !== mesh) {
  11814. this._synchronizedWithMesh = mesh;
  11815. // Prepare bones
  11816. for (var boneIndex = 0; boneIndex < this.bones.length; boneIndex++) {
  11817. var bone = this.bones[boneIndex];
  11818. if (!bone.getParent()) {
  11819. var matrix = bone.getBaseMatrix();
  11820. matrix.multiplyToRef(poseMatrix, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11821. bone._updateDifferenceMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11822. }
  11823. }
  11824. }
  11825. this._computeTransformMatrices(mesh._bonesTransformMatrices, poseMatrix);
  11826. }
  11827. }
  11828. else {
  11829. if (!this._transformMatrices || this._transformMatrices.length !== 16 * (this.bones.length + 1)) {
  11830. this._transformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11831. if (this.isUsingTextureForMatrices) {
  11832. if (this._transformMatrixTexture) {
  11833. this._transformMatrixTexture.dispose();
  11834. }
  11835. 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);
  11836. }
  11837. }
  11838. this._computeTransformMatrices(this._transformMatrices, null);
  11839. if (this.isUsingTextureForMatrices && this._transformMatrixTexture) {
  11840. this._transformMatrixTexture.update(this._transformMatrices);
  11841. }
  11842. }
  11843. this._isDirty = false;
  11844. this._scene._activeBones.addCount(this.bones.length, false);
  11845. };
  11846. /**
  11847. * Gets the list of animatables currently running for this skeleton
  11848. * @returns an array of animatables
  11849. */
  11850. Skeleton.prototype.getAnimatables = function () {
  11851. if (!this._animatables || this._animatables.length !== this.bones.length) {
  11852. this._animatables = [];
  11853. for (var index = 0; index < this.bones.length; index++) {
  11854. this._animatables.push(this.bones[index]);
  11855. }
  11856. }
  11857. return this._animatables;
  11858. };
  11859. /**
  11860. * Clone the current skeleton
  11861. * @param name defines the name of the new skeleton
  11862. * @param id defines the id of the enw skeleton
  11863. * @returns the new skeleton
  11864. */
  11865. Skeleton.prototype.clone = function (name, id) {
  11866. var result = new Skeleton(name, id || name, this._scene);
  11867. result.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11868. for (var index = 0; index < this.bones.length; index++) {
  11869. var source = this.bones[index];
  11870. var parentBone = null;
  11871. var parent_1 = source.getParent();
  11872. if (parent_1) {
  11873. var parentIndex = this.bones.indexOf(parent_1);
  11874. parentBone = result.bones[parentIndex];
  11875. }
  11876. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](source.name, result, parentBone, source.getBaseMatrix().clone(), source.getRestPose().clone());
  11877. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source.animations, bone.animations);
  11878. }
  11879. if (this._ranges) {
  11880. result._ranges = {};
  11881. for (var rangeName in this._ranges) {
  11882. var range = this._ranges[rangeName];
  11883. if (range) {
  11884. result._ranges[rangeName] = range.clone();
  11885. }
  11886. }
  11887. }
  11888. this._isDirty = true;
  11889. return result;
  11890. };
  11891. /**
  11892. * Enable animation blending for this skeleton
  11893. * @param blendingSpeed defines the blending speed to apply
  11894. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  11895. */
  11896. Skeleton.prototype.enableBlending = function (blendingSpeed) {
  11897. if (blendingSpeed === void 0) { blendingSpeed = 0.01; }
  11898. this.bones.forEach(function (bone) {
  11899. bone.animations.forEach(function (animation) {
  11900. animation.enableBlending = true;
  11901. animation.blendingSpeed = blendingSpeed;
  11902. });
  11903. });
  11904. };
  11905. /**
  11906. * Releases all resources associated with the current skeleton
  11907. */
  11908. Skeleton.prototype.dispose = function () {
  11909. this._meshesWithPoseMatrix = [];
  11910. // Animations
  11911. this.getScene().stopAnimation(this);
  11912. // Remove from scene
  11913. this.getScene().removeSkeleton(this);
  11914. if (this._transformMatrixTexture) {
  11915. this._transformMatrixTexture.dispose();
  11916. this._transformMatrixTexture = null;
  11917. }
  11918. };
  11919. /**
  11920. * Serialize the skeleton in a JSON object
  11921. * @returns a JSON object
  11922. */
  11923. Skeleton.prototype.serialize = function () {
  11924. var serializationObject = {};
  11925. serializationObject.name = this.name;
  11926. serializationObject.id = this.id;
  11927. if (this.dimensionsAtRest) {
  11928. serializationObject.dimensionsAtRest = this.dimensionsAtRest.asArray();
  11929. }
  11930. serializationObject.bones = [];
  11931. serializationObject.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11932. for (var index = 0; index < this.bones.length; index++) {
  11933. var bone = this.bones[index];
  11934. var parent_2 = bone.getParent();
  11935. var serializedBone = {
  11936. parentBoneIndex: parent_2 ? this.bones.indexOf(parent_2) : -1,
  11937. name: bone.name,
  11938. matrix: bone.getBaseMatrix().toArray(),
  11939. rest: bone.getRestPose().toArray()
  11940. };
  11941. serializationObject.bones.push(serializedBone);
  11942. if (bone.length) {
  11943. serializedBone.length = bone.length;
  11944. }
  11945. if (bone.metadata) {
  11946. serializedBone.metadata = bone.metadata;
  11947. }
  11948. if (bone.animations && bone.animations.length > 0) {
  11949. serializedBone.animation = bone.animations[0].serialize();
  11950. }
  11951. serializationObject.ranges = [];
  11952. for (var name in this._ranges) {
  11953. var source = this._ranges[name];
  11954. if (!source) {
  11955. continue;
  11956. }
  11957. var range = {};
  11958. range.name = name;
  11959. range.from = source.from;
  11960. range.to = source.to;
  11961. serializationObject.ranges.push(range);
  11962. }
  11963. }
  11964. return serializationObject;
  11965. };
  11966. /**
  11967. * Creates a new skeleton from serialized data
  11968. * @param parsedSkeleton defines the serialized data
  11969. * @param scene defines the hosting scene
  11970. * @returns a new skeleton
  11971. */
  11972. Skeleton.Parse = function (parsedSkeleton, scene) {
  11973. var skeleton = new Skeleton(parsedSkeleton.name, parsedSkeleton.id, scene);
  11974. if (parsedSkeleton.dimensionsAtRest) {
  11975. skeleton.dimensionsAtRest = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSkeleton.dimensionsAtRest);
  11976. }
  11977. skeleton.needInitialSkinMatrix = parsedSkeleton.needInitialSkinMatrix;
  11978. var index;
  11979. for (index = 0; index < parsedSkeleton.bones.length; index++) {
  11980. var parsedBone = parsedSkeleton.bones[index];
  11981. var parentBone = null;
  11982. if (parsedBone.parentBoneIndex > -1) {
  11983. parentBone = skeleton.bones[parsedBone.parentBoneIndex];
  11984. }
  11985. var rest = parsedBone.rest ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.rest) : null;
  11986. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](parsedBone.name, skeleton, parentBone, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.matrix), rest);
  11987. if (parsedBone.id !== undefined && parsedBone.id !== null) {
  11988. bone.id = parsedBone.id;
  11989. }
  11990. if (parsedBone.length) {
  11991. bone.length = parsedBone.length;
  11992. }
  11993. if (parsedBone.metadata) {
  11994. bone.metadata = parsedBone.metadata;
  11995. }
  11996. if (parsedBone.animation) {
  11997. bone.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].Parse(parsedBone.animation));
  11998. }
  11999. }
  12000. // placed after bones, so createAnimationRange can cascade down
  12001. if (parsedSkeleton.ranges) {
  12002. for (index = 0; index < parsedSkeleton.ranges.length; index++) {
  12003. var data = parsedSkeleton.ranges[index];
  12004. skeleton.createAnimationRange(data.name, data.from, data.to);
  12005. }
  12006. }
  12007. return skeleton;
  12008. };
  12009. /**
  12010. * Compute all node absolute transforms
  12011. * @param forceUpdate defines if computation must be done even if cache is up to date
  12012. */
  12013. Skeleton.prototype.computeAbsoluteTransforms = function (forceUpdate) {
  12014. if (forceUpdate === void 0) { forceUpdate = false; }
  12015. var renderId = this._scene.getRenderId();
  12016. if (this._lastAbsoluteTransformsUpdateId != renderId || forceUpdate) {
  12017. this.bones[0].computeAbsoluteTransforms();
  12018. this._lastAbsoluteTransformsUpdateId = renderId;
  12019. }
  12020. };
  12021. /**
  12022. * Gets the root pose matrix
  12023. * @returns a matrix
  12024. */
  12025. Skeleton.prototype.getPoseMatrix = function () {
  12026. var poseMatrix = null;
  12027. if (this._meshesWithPoseMatrix.length > 0) {
  12028. poseMatrix = this._meshesWithPoseMatrix[0].getPoseMatrix();
  12029. }
  12030. return poseMatrix;
  12031. };
  12032. /**
  12033. * Sorts bones per internal index
  12034. */
  12035. Skeleton.prototype.sortBones = function () {
  12036. var bones = new Array();
  12037. var visited = new Array(this.bones.length);
  12038. for (var index = 0; index < this.bones.length; index++) {
  12039. this._sortBones(index, bones, visited);
  12040. }
  12041. this.bones = bones;
  12042. };
  12043. Skeleton.prototype._sortBones = function (index, bones, visited) {
  12044. if (visited[index]) {
  12045. return;
  12046. }
  12047. visited[index] = true;
  12048. var bone = this.bones[index];
  12049. if (bone._index === undefined) {
  12050. bone._index = index;
  12051. }
  12052. var parentBone = bone.getParent();
  12053. if (parentBone) {
  12054. this._sortBones(this.bones.indexOf(parentBone), bones, visited);
  12055. }
  12056. bones.push(bone);
  12057. };
  12058. return Skeleton;
  12059. }());
  12060. /***/ }),
  12061. /***/ "./Cameras/Inputs/BaseCameraPointersInput.ts":
  12062. /*!***************************************************!*\
  12063. !*** ./Cameras/Inputs/BaseCameraPointersInput.ts ***!
  12064. \***************************************************/
  12065. /*! exports provided: BaseCameraPointersInput */
  12066. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12067. "use strict";
  12068. __webpack_require__.r(__webpack_exports__);
  12069. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseCameraPointersInput", function() { return BaseCameraPointersInput; });
  12070. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12071. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12072. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  12073. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12074. /**
  12075. * Base class for Camera Pointer Inputs.
  12076. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  12077. * for example usage.
  12078. */
  12079. var BaseCameraPointersInput = /** @class */ (function () {
  12080. function BaseCameraPointersInput() {
  12081. /**
  12082. * Defines the buttons associated with the input to handle camera move.
  12083. */
  12084. this.buttons = [0, 1, 2];
  12085. }
  12086. /**
  12087. * Attach the input controls to a specific dom element to get the input from.
  12088. * @param element Defines the element the controls should be listened from
  12089. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12090. */
  12091. BaseCameraPointersInput.prototype.attachControl = function (element, noPreventDefault) {
  12092. var _this = this;
  12093. var engine = this.camera.getEngine();
  12094. var previousPinchSquaredDistance = 0;
  12095. var previousMultiTouchPanPosition = null;
  12096. this.pointA = null;
  12097. this.pointB = null;
  12098. this._altKey = false;
  12099. this._ctrlKey = false;
  12100. this._metaKey = false;
  12101. this._shiftKey = false;
  12102. this._buttonsPressed = 0;
  12103. this._pointerInput = function (p, s) {
  12104. var evt = p.event;
  12105. var isTouch = evt.pointerType === "touch";
  12106. if (engine.isInVRExclusivePointerMode) {
  12107. return;
  12108. }
  12109. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE &&
  12110. _this.buttons.indexOf(evt.button) === -1) {
  12111. return;
  12112. }
  12113. var srcElement = (evt.srcElement || evt.target);
  12114. _this._altKey = evt.altKey;
  12115. _this._ctrlKey = evt.ctrlKey;
  12116. _this._metaKey = evt.metaKey;
  12117. _this._shiftKey = evt.shiftKey;
  12118. _this._buttonsPressed = evt.buttons;
  12119. if (engine.isPointerLock) {
  12120. var offsetX = evt.movementX ||
  12121. evt.mozMovementX ||
  12122. evt.webkitMovementX ||
  12123. evt.msMovementX ||
  12124. 0;
  12125. var offsetY = evt.movementY ||
  12126. evt.mozMovementY ||
  12127. evt.webkitMovementY ||
  12128. evt.msMovementY ||
  12129. 0;
  12130. _this.onTouch(null, offsetX, offsetY);
  12131. _this.pointA = null;
  12132. _this.pointB = null;
  12133. }
  12134. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  12135. try {
  12136. srcElement.setPointerCapture(evt.pointerId);
  12137. }
  12138. catch (e) {
  12139. //Nothing to do with the error. Execution will continue.
  12140. }
  12141. if (_this.pointA === null) {
  12142. _this.pointA = { x: evt.clientX,
  12143. y: evt.clientY,
  12144. pointerId: evt.pointerId,
  12145. type: evt.pointerType };
  12146. }
  12147. else if (_this.pointB === null) {
  12148. _this.pointB = { x: evt.clientX,
  12149. y: evt.clientY,
  12150. pointerId: evt.pointerId,
  12151. type: evt.pointerType };
  12152. }
  12153. _this.onButtonDown(evt);
  12154. if (!noPreventDefault) {
  12155. evt.preventDefault();
  12156. element.focus();
  12157. }
  12158. }
  12159. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOUBLETAP) {
  12160. _this.onDoubleTap(evt.pointerType);
  12161. }
  12162. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  12163. try {
  12164. srcElement.releasePointerCapture(evt.pointerId);
  12165. }
  12166. catch (e) {
  12167. //Nothing to do with the error.
  12168. }
  12169. if (!isTouch) {
  12170. _this.pointB = null; // Mouse and pen are mono pointer
  12171. }
  12172. //would be better to use pointers.remove(evt.pointerId) for multitouch gestures,
  12173. //but emptying completely pointers collection is required to fix a bug on iPhone :
  12174. //when changing orientation while pinching camera,
  12175. //one pointer stay pressed forever if we don't release all pointers
  12176. //will be ok to put back pointers.remove(evt.pointerId); when iPhone bug corrected
  12177. if (engine._badOS) {
  12178. _this.pointA = _this.pointB = null;
  12179. }
  12180. else {
  12181. //only remove the impacted pointer in case of multitouch allowing on most
  12182. //platforms switching from rotate to zoom and pan seamlessly.
  12183. if (_this.pointB && _this.pointA && _this.pointA.pointerId == evt.pointerId) {
  12184. _this.pointA = _this.pointB;
  12185. _this.pointB = null;
  12186. }
  12187. else if (_this.pointA && _this.pointB &&
  12188. _this.pointB.pointerId == evt.pointerId) {
  12189. _this.pointB = null;
  12190. }
  12191. else {
  12192. _this.pointA = _this.pointB = null;
  12193. }
  12194. }
  12195. if (previousPinchSquaredDistance !== 0 || previousMultiTouchPanPosition) {
  12196. // Previous pinch data is populated but a button has been lifted
  12197. // so pinch has ended.
  12198. _this.onMultiTouch(_this.pointA, _this.pointB, previousPinchSquaredDistance, 0, // pinchSquaredDistance
  12199. previousMultiTouchPanPosition, null // multiTouchPanPosition
  12200. );
  12201. previousPinchSquaredDistance = 0;
  12202. previousMultiTouchPanPosition = null;
  12203. }
  12204. _this.onButtonUp(evt);
  12205. if (!noPreventDefault) {
  12206. evt.preventDefault();
  12207. }
  12208. }
  12209. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  12210. if (!noPreventDefault) {
  12211. evt.preventDefault();
  12212. }
  12213. // One button down
  12214. if (_this.pointA && _this.pointB === null) {
  12215. var offsetX = evt.clientX - _this.pointA.x;
  12216. var offsetY = evt.clientY - _this.pointA.y;
  12217. _this.onTouch(_this.pointA, offsetX, offsetY);
  12218. _this.pointA.x = evt.clientX;
  12219. _this.pointA.y = evt.clientY;
  12220. }
  12221. // Two buttons down: pinch
  12222. else if (_this.pointA && _this.pointB) {
  12223. var ed = (_this.pointA.pointerId === evt.pointerId) ?
  12224. _this.pointA : _this.pointB;
  12225. ed.x = evt.clientX;
  12226. ed.y = evt.clientY;
  12227. var distX = _this.pointA.x - _this.pointB.x;
  12228. var distY = _this.pointA.y - _this.pointB.y;
  12229. var pinchSquaredDistance = (distX * distX) + (distY * distY);
  12230. var multiTouchPanPosition = { x: (_this.pointA.x + _this.pointB.x) / 2,
  12231. y: (_this.pointA.y + _this.pointB.y) / 2,
  12232. pointerId: evt.pointerId,
  12233. type: p.type };
  12234. _this.onMultiTouch(_this.pointA, _this.pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition);
  12235. previousMultiTouchPanPosition = multiTouchPanPosition;
  12236. previousPinchSquaredDistance = pinchSquaredDistance;
  12237. }
  12238. }
  12239. };
  12240. 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 |
  12241. _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  12242. this._onLostFocus = function () {
  12243. _this.pointA = _this.pointB = null;
  12244. previousPinchSquaredDistance = 0;
  12245. previousMultiTouchPanPosition = null;
  12246. _this.onLostFocus();
  12247. };
  12248. element.addEventListener("contextmenu", this.onContextMenu.bind(this), false);
  12249. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RegisterTopRootEvents([
  12250. { name: "blur", handler: this._onLostFocus }
  12251. ]);
  12252. };
  12253. /**
  12254. * Detach the current controls from the specified dom element.
  12255. * @param element Defines the element to stop listening the inputs from
  12256. */
  12257. BaseCameraPointersInput.prototype.detachControl = function (element) {
  12258. if (this._onLostFocus) {
  12259. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].UnregisterTopRootEvents([
  12260. { name: "blur", handler: this._onLostFocus }
  12261. ]);
  12262. }
  12263. if (element && this._observer) {
  12264. this.camera.getScene().onPointerObservable.remove(this._observer);
  12265. this._observer = null;
  12266. if (this.onContextMenu) {
  12267. element.removeEventListener("contextmenu", this.onContextMenu);
  12268. }
  12269. this._onLostFocus = null;
  12270. }
  12271. this._altKey = false;
  12272. this._ctrlKey = false;
  12273. this._metaKey = false;
  12274. this._shiftKey = false;
  12275. this._buttonsPressed = 0;
  12276. };
  12277. /**
  12278. * Gets the class name of the current input.
  12279. * @returns the class name
  12280. */
  12281. BaseCameraPointersInput.prototype.getClassName = function () {
  12282. return "BaseCameraPointersInput";
  12283. };
  12284. /**
  12285. * Get the friendly name associated with the input class.
  12286. * @returns the input friendly name
  12287. */
  12288. BaseCameraPointersInput.prototype.getSimpleName = function () {
  12289. return "pointers";
  12290. };
  12291. /**
  12292. * Called on pointer POINTERDOUBLETAP event.
  12293. * Override this method to provide functionality on POINTERDOUBLETAP event.
  12294. */
  12295. BaseCameraPointersInput.prototype.onDoubleTap = function (type) {
  12296. };
  12297. /**
  12298. * Called on pointer POINTERMOVE event if only a single touch is active.
  12299. * Override this method to provide functionality.
  12300. */
  12301. BaseCameraPointersInput.prototype.onTouch = function (point, offsetX, offsetY) {
  12302. };
  12303. /**
  12304. * Called on pointer POINTERMOVE event if multiple touches are active.
  12305. * Override this method to provide functionality.
  12306. */
  12307. BaseCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  12308. };
  12309. /**
  12310. * Called on JS contextmenu event.
  12311. * Override this method to provide functionality.
  12312. */
  12313. BaseCameraPointersInput.prototype.onContextMenu = function (evt) {
  12314. evt.preventDefault();
  12315. };
  12316. /**
  12317. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  12318. * press.
  12319. * Override this method to provide functionality.
  12320. */
  12321. BaseCameraPointersInput.prototype.onButtonDown = function (evt) {
  12322. };
  12323. /**
  12324. * Called each time a new POINTERUP event occurs. Ie, for each button
  12325. * release.
  12326. * Override this method to provide functionality.
  12327. */
  12328. BaseCameraPointersInput.prototype.onButtonUp = function (evt) {
  12329. };
  12330. /**
  12331. * Called when window becomes inactive.
  12332. * Override this method to provide functionality.
  12333. */
  12334. BaseCameraPointersInput.prototype.onLostFocus = function () {
  12335. };
  12336. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12337. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12338. ], BaseCameraPointersInput.prototype, "buttons", void 0);
  12339. return BaseCameraPointersInput;
  12340. }());
  12341. /***/ }),
  12342. /***/ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts":
  12343. /*!*******************************************************!*\
  12344. !*** ./Cameras/Inputs/arcRotateCameraGamepadInput.ts ***!
  12345. \*******************************************************/
  12346. /*! exports provided: ArcRotateCameraGamepadInput */
  12347. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12348. "use strict";
  12349. __webpack_require__.r(__webpack_exports__);
  12350. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return ArcRotateCameraGamepadInput; });
  12351. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12352. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12353. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12354. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  12355. /**
  12356. * Manage the gamepad inputs to control an arc rotate camera.
  12357. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12358. */
  12359. var ArcRotateCameraGamepadInput = /** @class */ (function () {
  12360. function ArcRotateCameraGamepadInput() {
  12361. /**
  12362. * Defines the gamepad rotation sensiblity.
  12363. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  12364. */
  12365. this.gamepadRotationSensibility = 80;
  12366. /**
  12367. * Defines the gamepad move sensiblity.
  12368. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  12369. */
  12370. this.gamepadMoveSensibility = 40;
  12371. }
  12372. /**
  12373. * Attach the input controls to a specific dom element to get the input from.
  12374. * @param element Defines the element the controls should be listened from
  12375. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12376. */
  12377. ArcRotateCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  12378. var _this = this;
  12379. var manager = this.camera.getScene().gamepadManager;
  12380. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  12381. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].POSE_ENABLED) {
  12382. // prioritize XBOX gamepads.
  12383. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX) {
  12384. _this.gamepad = gamepad;
  12385. }
  12386. }
  12387. });
  12388. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  12389. if (_this.gamepad === gamepad) {
  12390. _this.gamepad = null;
  12391. }
  12392. });
  12393. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX);
  12394. };
  12395. /**
  12396. * Detach the current controls from the specified dom element.
  12397. * @param element Defines the element to stop listening the inputs from
  12398. */
  12399. ArcRotateCameraGamepadInput.prototype.detachControl = function (element) {
  12400. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  12401. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  12402. this.gamepad = null;
  12403. };
  12404. /**
  12405. * Update the current camera state depending on the inputs that have been used this frame.
  12406. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12407. */
  12408. ArcRotateCameraGamepadInput.prototype.checkInputs = function () {
  12409. if (this.gamepad) {
  12410. var camera = this.camera;
  12411. var RSValues = this.gamepad.rightStick;
  12412. if (RSValues) {
  12413. if (RSValues.x != 0) {
  12414. var normalizedRX = RSValues.x / this.gamepadRotationSensibility;
  12415. if (normalizedRX != 0 && Math.abs(normalizedRX) > 0.005) {
  12416. camera.inertialAlphaOffset += normalizedRX;
  12417. }
  12418. }
  12419. if (RSValues.y != 0) {
  12420. var normalizedRY = RSValues.y / this.gamepadRotationSensibility;
  12421. if (normalizedRY != 0 && Math.abs(normalizedRY) > 0.005) {
  12422. camera.inertialBetaOffset += normalizedRY;
  12423. }
  12424. }
  12425. }
  12426. var LSValues = this.gamepad.leftStick;
  12427. if (LSValues && LSValues.y != 0) {
  12428. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  12429. if (normalizedLY != 0 && Math.abs(normalizedLY) > 0.005) {
  12430. this.camera.inertialRadiusOffset -= normalizedLY;
  12431. }
  12432. }
  12433. }
  12434. };
  12435. /**
  12436. * Gets the class name of the current intput.
  12437. * @returns the class name
  12438. */
  12439. ArcRotateCameraGamepadInput.prototype.getClassName = function () {
  12440. return "ArcRotateCameraGamepadInput";
  12441. };
  12442. /**
  12443. * Get the friendly name associated with the input class.
  12444. * @returns the input friendly name
  12445. */
  12446. ArcRotateCameraGamepadInput.prototype.getSimpleName = function () {
  12447. return "gamepad";
  12448. };
  12449. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12450. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12451. ], ArcRotateCameraGamepadInput.prototype, "gamepadRotationSensibility", void 0);
  12452. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12453. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12454. ], ArcRotateCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  12455. return ArcRotateCameraGamepadInput;
  12456. }());
  12457. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraGamepadInput"] = ArcRotateCameraGamepadInput;
  12458. /***/ }),
  12459. /***/ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts":
  12460. /*!************************************************************!*\
  12461. !*** ./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts ***!
  12462. \************************************************************/
  12463. /*! exports provided: ArcRotateCameraKeyboardMoveInput */
  12464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12465. "use strict";
  12466. __webpack_require__.r(__webpack_exports__);
  12467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return ArcRotateCameraKeyboardMoveInput; });
  12468. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12469. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12470. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12471. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  12472. /**
  12473. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  12474. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12475. */
  12476. var ArcRotateCameraKeyboardMoveInput = /** @class */ (function () {
  12477. function ArcRotateCameraKeyboardMoveInput() {
  12478. /**
  12479. * Defines the list of key codes associated with the up action (increase alpha)
  12480. */
  12481. this.keysUp = [38];
  12482. /**
  12483. * Defines the list of key codes associated with the down action (decrease alpha)
  12484. */
  12485. this.keysDown = [40];
  12486. /**
  12487. * Defines the list of key codes associated with the left action (increase beta)
  12488. */
  12489. this.keysLeft = [37];
  12490. /**
  12491. * Defines the list of key codes associated with the right action (decrease beta)
  12492. */
  12493. this.keysRight = [39];
  12494. /**
  12495. * Defines the list of key codes associated with the reset action.
  12496. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  12497. */
  12498. this.keysReset = [220];
  12499. /**
  12500. * Defines the panning sensibility of the inputs.
  12501. * (How fast is the camera paning)
  12502. */
  12503. this.panningSensibility = 50.0;
  12504. /**
  12505. * Defines the zooming sensibility of the inputs.
  12506. * (How fast is the camera zooming)
  12507. */
  12508. this.zoomingSensibility = 25.0;
  12509. /**
  12510. * Defines wether maintaining the alt key down switch the movement mode from
  12511. * orientation to zoom.
  12512. */
  12513. this.useAltToZoom = true;
  12514. /**
  12515. * Rotation speed of the camera
  12516. */
  12517. this.angularSpeed = 0.01;
  12518. this._keys = new Array();
  12519. }
  12520. /**
  12521. * Attach the input controls to a specific dom element to get the input from.
  12522. * @param element Defines the element the controls should be listened from
  12523. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12524. */
  12525. ArcRotateCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  12526. var _this = this;
  12527. if (this._onCanvasBlurObserver) {
  12528. return;
  12529. }
  12530. this._scene = this.camera.getScene();
  12531. this._engine = this._scene.getEngine();
  12532. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  12533. _this._keys = [];
  12534. });
  12535. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  12536. var evt = info.event;
  12537. if (!evt.metaKey) {
  12538. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  12539. _this._ctrlPressed = evt.ctrlKey;
  12540. _this._altPressed = evt.altKey;
  12541. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12542. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12543. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12544. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12545. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12546. var index = _this._keys.indexOf(evt.keyCode);
  12547. if (index === -1) {
  12548. _this._keys.push(evt.keyCode);
  12549. }
  12550. if (evt.preventDefault) {
  12551. if (!noPreventDefault) {
  12552. evt.preventDefault();
  12553. }
  12554. }
  12555. }
  12556. }
  12557. else {
  12558. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12559. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12560. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12561. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12562. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12563. var index = _this._keys.indexOf(evt.keyCode);
  12564. if (index >= 0) {
  12565. _this._keys.splice(index, 1);
  12566. }
  12567. if (evt.preventDefault) {
  12568. if (!noPreventDefault) {
  12569. evt.preventDefault();
  12570. }
  12571. }
  12572. }
  12573. }
  12574. }
  12575. });
  12576. };
  12577. /**
  12578. * Detach the current controls from the specified dom element.
  12579. * @param element Defines the element to stop listening the inputs from
  12580. */
  12581. ArcRotateCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  12582. if (this._scene) {
  12583. if (this._onKeyboardObserver) {
  12584. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  12585. }
  12586. if (this._onCanvasBlurObserver) {
  12587. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  12588. }
  12589. this._onKeyboardObserver = null;
  12590. this._onCanvasBlurObserver = null;
  12591. }
  12592. this._keys = [];
  12593. };
  12594. /**
  12595. * Update the current camera state depending on the inputs that have been used this frame.
  12596. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12597. */
  12598. ArcRotateCameraKeyboardMoveInput.prototype.checkInputs = function () {
  12599. if (this._onKeyboardObserver) {
  12600. var camera = this.camera;
  12601. for (var index = 0; index < this._keys.length; index++) {
  12602. var keyCode = this._keys[index];
  12603. if (this.keysLeft.indexOf(keyCode) !== -1) {
  12604. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12605. camera.inertialPanningX -= 1 / this.panningSensibility;
  12606. }
  12607. else {
  12608. camera.inertialAlphaOffset -= this.angularSpeed;
  12609. }
  12610. }
  12611. else if (this.keysUp.indexOf(keyCode) !== -1) {
  12612. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12613. camera.inertialPanningY += 1 / this.panningSensibility;
  12614. }
  12615. else if (this._altPressed && this.useAltToZoom) {
  12616. camera.inertialRadiusOffset += 1 / this.zoomingSensibility;
  12617. }
  12618. else {
  12619. camera.inertialBetaOffset -= this.angularSpeed;
  12620. }
  12621. }
  12622. else if (this.keysRight.indexOf(keyCode) !== -1) {
  12623. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12624. camera.inertialPanningX += 1 / this.panningSensibility;
  12625. }
  12626. else {
  12627. camera.inertialAlphaOffset += this.angularSpeed;
  12628. }
  12629. }
  12630. else if (this.keysDown.indexOf(keyCode) !== -1) {
  12631. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12632. camera.inertialPanningY -= 1 / this.panningSensibility;
  12633. }
  12634. else if (this._altPressed && this.useAltToZoom) {
  12635. camera.inertialRadiusOffset -= 1 / this.zoomingSensibility;
  12636. }
  12637. else {
  12638. camera.inertialBetaOffset += this.angularSpeed;
  12639. }
  12640. }
  12641. else if (this.keysReset.indexOf(keyCode) !== -1) {
  12642. if (camera.useInputToRestoreState) {
  12643. camera.restoreState();
  12644. }
  12645. }
  12646. }
  12647. }
  12648. };
  12649. /**
  12650. * Gets the class name of the current intput.
  12651. * @returns the class name
  12652. */
  12653. ArcRotateCameraKeyboardMoveInput.prototype.getClassName = function () {
  12654. return "ArcRotateCameraKeyboardMoveInput";
  12655. };
  12656. /**
  12657. * Get the friendly name associated with the input class.
  12658. * @returns the input friendly name
  12659. */
  12660. ArcRotateCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  12661. return "keyboard";
  12662. };
  12663. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12664. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12665. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  12666. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12667. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12668. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  12669. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12670. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12671. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  12672. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12673. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12674. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  12675. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12676. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12677. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysReset", void 0);
  12678. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12679. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12680. ], ArcRotateCameraKeyboardMoveInput.prototype, "panningSensibility", void 0);
  12681. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12682. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12683. ], ArcRotateCameraKeyboardMoveInput.prototype, "zoomingSensibility", void 0);
  12684. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12685. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12686. ], ArcRotateCameraKeyboardMoveInput.prototype, "useAltToZoom", void 0);
  12687. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12688. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12689. ], ArcRotateCameraKeyboardMoveInput.prototype, "angularSpeed", void 0);
  12690. return ArcRotateCameraKeyboardMoveInput;
  12691. }());
  12692. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraKeyboardMoveInput"] = ArcRotateCameraKeyboardMoveInput;
  12693. /***/ }),
  12694. /***/ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts":
  12695. /*!**********************************************************!*\
  12696. !*** ./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts ***!
  12697. \**********************************************************/
  12698. /*! exports provided: ArcRotateCameraMouseWheelInput */
  12699. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12700. "use strict";
  12701. __webpack_require__.r(__webpack_exports__);
  12702. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return ArcRotateCameraMouseWheelInput; });
  12703. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12704. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12705. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12706. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12707. /**
  12708. * Manage the mouse wheel inputs to control an arc rotate camera.
  12709. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12710. */
  12711. var ArcRotateCameraMouseWheelInput = /** @class */ (function () {
  12712. function ArcRotateCameraMouseWheelInput() {
  12713. /**
  12714. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  12715. */
  12716. this.wheelPrecision = 3.0;
  12717. /**
  12718. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  12719. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  12720. */
  12721. this.wheelDeltaPercentage = 0;
  12722. }
  12723. /**
  12724. * Attach the input controls to a specific dom element to get the input from.
  12725. * @param element Defines the element the controls should be listened from
  12726. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12727. */
  12728. ArcRotateCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  12729. var _this = this;
  12730. this._wheel = function (p, s) {
  12731. //sanity check - this should be a PointerWheel event.
  12732. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  12733. return;
  12734. }
  12735. var event = p.event;
  12736. var delta = 0;
  12737. var mouseWheelLegacyEvent = event;
  12738. if (mouseWheelLegacyEvent.wheelDelta) {
  12739. if (_this.wheelDeltaPercentage) {
  12740. var wheelDelta = (mouseWheelLegacyEvent.wheelDelta * 0.01 * _this.wheelDeltaPercentage) * _this.camera.radius;
  12741. if (mouseWheelLegacyEvent.wheelDelta > 0) {
  12742. delta = wheelDelta / (1.0 + _this.wheelDeltaPercentage);
  12743. }
  12744. else {
  12745. delta = wheelDelta * (1.0 + _this.wheelDeltaPercentage);
  12746. }
  12747. }
  12748. else {
  12749. delta = mouseWheelLegacyEvent.wheelDelta / (_this.wheelPrecision * 40);
  12750. }
  12751. }
  12752. else {
  12753. var deltaValue = event.deltaY || event.detail;
  12754. delta = -deltaValue / _this.wheelPrecision;
  12755. }
  12756. if (delta) {
  12757. _this.camera.inertialRadiusOffset += delta;
  12758. }
  12759. if (event.preventDefault) {
  12760. if (!noPreventDefault) {
  12761. event.preventDefault();
  12762. }
  12763. }
  12764. };
  12765. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  12766. };
  12767. /**
  12768. * Detach the current controls from the specified dom element.
  12769. * @param element Defines the element to stop listening the inputs from
  12770. */
  12771. ArcRotateCameraMouseWheelInput.prototype.detachControl = function (element) {
  12772. if (this._observer && element) {
  12773. this.camera.getScene().onPointerObservable.remove(this._observer);
  12774. this._observer = null;
  12775. this._wheel = null;
  12776. }
  12777. };
  12778. /**
  12779. * Gets the class name of the current intput.
  12780. * @returns the class name
  12781. */
  12782. ArcRotateCameraMouseWheelInput.prototype.getClassName = function () {
  12783. return "ArcRotateCameraMouseWheelInput";
  12784. };
  12785. /**
  12786. * Get the friendly name associated with the input class.
  12787. * @returns the input friendly name
  12788. */
  12789. ArcRotateCameraMouseWheelInput.prototype.getSimpleName = function () {
  12790. return "mousewheel";
  12791. };
  12792. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12793. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12794. ], ArcRotateCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  12795. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12796. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12797. ], ArcRotateCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  12798. return ArcRotateCameraMouseWheelInput;
  12799. }());
  12800. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraMouseWheelInput"] = ArcRotateCameraMouseWheelInput;
  12801. /***/ }),
  12802. /***/ "./Cameras/Inputs/arcRotateCameraPointersInput.ts":
  12803. /*!********************************************************!*\
  12804. !*** ./Cameras/Inputs/arcRotateCameraPointersInput.ts ***!
  12805. \********************************************************/
  12806. /*! exports provided: ArcRotateCameraPointersInput */
  12807. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12808. "use strict";
  12809. __webpack_require__.r(__webpack_exports__);
  12810. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return ArcRotateCameraPointersInput; });
  12811. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12812. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12813. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12814. /* harmony import */ var _Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/Inputs/BaseCameraPointersInput */ "./Cameras/Inputs/BaseCameraPointersInput.ts");
  12815. /**
  12816. * Manage the pointers inputs to control an arc rotate camera.
  12817. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12818. */
  12819. var ArcRotateCameraPointersInput = /** @class */ (function (_super) {
  12820. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraPointersInput, _super);
  12821. function ArcRotateCameraPointersInput() {
  12822. var _this = _super !== null && _super.apply(this, arguments) || this;
  12823. /**
  12824. * Defines the buttons associated with the input to handle camera move.
  12825. */
  12826. _this.buttons = [0, 1, 2];
  12827. /**
  12828. * Defines the pointer angular sensibility along the X axis or how fast is
  12829. * the camera rotating.
  12830. */
  12831. _this.angularSensibilityX = 1000.0;
  12832. /**
  12833. * Defines the pointer angular sensibility along the Y axis or how fast is
  12834. * the camera rotating.
  12835. */
  12836. _this.angularSensibilityY = 1000.0;
  12837. /**
  12838. * Defines the pointer pinch precision or how fast is the camera zooming.
  12839. */
  12840. _this.pinchPrecision = 12.0;
  12841. /**
  12842. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  12843. * from 0.
  12844. * It defines the percentage of current camera.radius to use as delta when
  12845. * pinch zoom is used.
  12846. */
  12847. _this.pinchDeltaPercentage = 0;
  12848. /**
  12849. * Defines the pointer panning sensibility or how fast is the camera moving.
  12850. */
  12851. _this.panningSensibility = 1000.0;
  12852. /**
  12853. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  12854. */
  12855. _this.multiTouchPanning = true;
  12856. /**
  12857. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  12858. * zoom (pinch) through multitouch.
  12859. */
  12860. _this.multiTouchPanAndZoom = true;
  12861. /**
  12862. * Revers pinch action direction.
  12863. */
  12864. _this.pinchInwards = true;
  12865. _this._isPanClick = false;
  12866. _this._twoFingerActivityCount = 0;
  12867. _this._isPinching = false;
  12868. return _this;
  12869. }
  12870. /**
  12871. * Gets the class name of the current input.
  12872. * @returns the class name
  12873. */
  12874. ArcRotateCameraPointersInput.prototype.getClassName = function () {
  12875. return "ArcRotateCameraPointersInput";
  12876. };
  12877. /**
  12878. * Called on pointer POINTERMOVE event if only a single touch is active.
  12879. */
  12880. ArcRotateCameraPointersInput.prototype.onTouch = function (point, offsetX, offsetY) {
  12881. if (this.panningSensibility !== 0 &&
  12882. ((this._ctrlKey && this.camera._useCtrlForPanning) || this._isPanClick)) {
  12883. this.camera.inertialPanningX += -offsetX / this.panningSensibility;
  12884. this.camera.inertialPanningY += offsetY / this.panningSensibility;
  12885. }
  12886. else {
  12887. this.camera.inertialAlphaOffset -= offsetX / this.angularSensibilityX;
  12888. this.camera.inertialBetaOffset -= offsetY / this.angularSensibilityY;
  12889. }
  12890. };
  12891. /**
  12892. * Called on pointer POINTERDOUBLETAP event.
  12893. */
  12894. ArcRotateCameraPointersInput.prototype.onDoubleTap = function (type) {
  12895. if (this.camera.useInputToRestoreState) {
  12896. this.camera.restoreState();
  12897. }
  12898. };
  12899. /**
  12900. * Called on pointer POINTERMOVE event if multiple touches are active.
  12901. */
  12902. ArcRotateCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  12903. if (previousPinchSquaredDistance === 0 && previousMultiTouchPanPosition === null) {
  12904. // First time this method is called for new pinch.
  12905. // Next time this is called there will be a
  12906. // previousPinchSquaredDistance and pinchSquaredDistance to compare.
  12907. return;
  12908. }
  12909. if (pinchSquaredDistance === 0 && multiTouchPanPosition === null) {
  12910. // Last time this method is called at the end of a pinch.
  12911. return;
  12912. }
  12913. var direction = this.pinchInwards ? 1 : -1;
  12914. if (this.multiTouchPanAndZoom) {
  12915. if (this.pinchDeltaPercentage) {
  12916. this.camera.inertialRadiusOffset +=
  12917. (pinchSquaredDistance - previousPinchSquaredDistance) * 0.001 *
  12918. this.camera.radius * this.pinchDeltaPercentage;
  12919. }
  12920. else {
  12921. this.camera.inertialRadiusOffset +=
  12922. (pinchSquaredDistance - previousPinchSquaredDistance) /
  12923. (this.pinchPrecision * direction *
  12924. (this.angularSensibilityX + this.angularSensibilityY) / 2);
  12925. }
  12926. if (this.panningSensibility !== 0 &&
  12927. previousMultiTouchPanPosition && multiTouchPanPosition) {
  12928. var moveDeltaX = multiTouchPanPosition.x - previousMultiTouchPanPosition.x;
  12929. var moveDeltaY = multiTouchPanPosition.y - previousMultiTouchPanPosition.y;
  12930. this.camera.inertialPanningX += -moveDeltaX / this.panningSensibility;
  12931. this.camera.inertialPanningY += moveDeltaY / this.panningSensibility;
  12932. }
  12933. }
  12934. else {
  12935. this._twoFingerActivityCount++;
  12936. var previousPinchDistance = Math.sqrt(previousPinchSquaredDistance);
  12937. var pinchDistance = Math.sqrt(pinchSquaredDistance);
  12938. if (this._isPinching ||
  12939. (this._twoFingerActivityCount < 20 &&
  12940. Math.abs(pinchDistance - previousPinchDistance) >
  12941. this.camera.pinchToPanMaxDistance)) {
  12942. // Since pinch has not been active long, assume we intend to zoom.
  12943. if (this.pinchDeltaPercentage) {
  12944. this.camera.inertialRadiusOffset +=
  12945. (pinchSquaredDistance - previousPinchSquaredDistance) * 0.001 *
  12946. this.camera.radius * this.pinchDeltaPercentage;
  12947. }
  12948. else {
  12949. this.camera.inertialRadiusOffset +=
  12950. (pinchSquaredDistance - previousPinchSquaredDistance) /
  12951. (this.pinchPrecision * direction *
  12952. (this.angularSensibilityX + this.angularSensibilityY) / 2);
  12953. }
  12954. // Since we are pinching, remain pinching on next iteration.
  12955. this._isPinching = true;
  12956. }
  12957. else {
  12958. // Pause between pinch starting and moving implies not a zoom event.
  12959. // Pan instead.
  12960. if (this.panningSensibility !== 0 && this.multiTouchPanning &&
  12961. multiTouchPanPosition && previousMultiTouchPanPosition) {
  12962. var moveDeltaX = multiTouchPanPosition.x - previousMultiTouchPanPosition.x;
  12963. var moveDeltaY = multiTouchPanPosition.y - previousMultiTouchPanPosition.y;
  12964. this.camera.inertialPanningX += -moveDeltaX / this.panningSensibility;
  12965. this.camera.inertialPanningY += moveDeltaY / this.panningSensibility;
  12966. }
  12967. }
  12968. }
  12969. };
  12970. /**
  12971. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  12972. * press.
  12973. */
  12974. ArcRotateCameraPointersInput.prototype.onButtonDown = function (evt) {
  12975. this._isPanClick = evt.button === this.camera._panningMouseButton;
  12976. };
  12977. /**
  12978. * Called each time a new POINTERUP event occurs. Ie, for each button
  12979. * release.
  12980. */
  12981. ArcRotateCameraPointersInput.prototype.onButtonUp = function (evt) {
  12982. this._twoFingerActivityCount = 0;
  12983. this._isPinching = false;
  12984. };
  12985. /**
  12986. * Called when window becomes inactive.
  12987. */
  12988. ArcRotateCameraPointersInput.prototype.onLostFocus = function () {
  12989. this._isPanClick = false;
  12990. this._twoFingerActivityCount = 0;
  12991. this._isPinching = false;
  12992. };
  12993. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12994. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12995. ], ArcRotateCameraPointersInput.prototype, "buttons", void 0);
  12996. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12997. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12998. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityX", void 0);
  12999. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13000. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13001. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityY", void 0);
  13002. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13003. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13004. ], ArcRotateCameraPointersInput.prototype, "pinchPrecision", void 0);
  13005. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13006. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13007. ], ArcRotateCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  13008. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13009. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13010. ], ArcRotateCameraPointersInput.prototype, "panningSensibility", void 0);
  13011. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13012. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13013. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanning", void 0);
  13014. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13015. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13016. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanAndZoom", void 0);
  13017. return ArcRotateCameraPointersInput;
  13018. }(_Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["BaseCameraPointersInput"]));
  13019. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraPointersInput"] =
  13020. ArcRotateCameraPointersInput;
  13021. /***/ }),
  13022. /***/ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts":
  13023. /*!*******************************************************************!*\
  13024. !*** ./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts ***!
  13025. \*******************************************************************/
  13026. /*! exports provided: ArcRotateCameraVRDeviceOrientationInput */
  13027. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13028. "use strict";
  13029. __webpack_require__.r(__webpack_exports__);
  13030. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return ArcRotateCameraVRDeviceOrientationInput; });
  13031. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13032. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  13033. /**
  13034. * Add orientation input support to the input manager.
  13035. * @returns the current input manager
  13036. */
  13037. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraInputsManager"].prototype.addVRDeviceOrientation = function () {
  13038. this.add(new ArcRotateCameraVRDeviceOrientationInput());
  13039. return this;
  13040. };
  13041. /**
  13042. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  13043. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13044. */
  13045. var ArcRotateCameraVRDeviceOrientationInput = /** @class */ (function () {
  13046. /**
  13047. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  13048. */
  13049. function ArcRotateCameraVRDeviceOrientationInput() {
  13050. /**
  13051. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  13052. */
  13053. this.alphaCorrection = 1;
  13054. /**
  13055. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  13056. */
  13057. this.gammaCorrection = 1;
  13058. this._alpha = 0;
  13059. this._gamma = 0;
  13060. this._dirty = false;
  13061. this._deviceOrientationHandler = this._onOrientationEvent.bind(this);
  13062. }
  13063. /**
  13064. * Attach the input controls to a specific dom element to get the input from.
  13065. * @param element Defines the element the controls should be listened from
  13066. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13067. */
  13068. ArcRotateCameraVRDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  13069. this.camera.attachControl(element, noPreventDefault);
  13070. window.addEventListener("deviceorientation", this._deviceOrientationHandler);
  13071. };
  13072. /** @hidden */
  13073. ArcRotateCameraVRDeviceOrientationInput.prototype._onOrientationEvent = function (evt) {
  13074. if (evt.alpha !== null) {
  13075. this._alpha = (+evt.alpha | 0) * this.alphaCorrection;
  13076. }
  13077. if (evt.gamma !== null) {
  13078. this._gamma = (+evt.gamma | 0) * this.gammaCorrection;
  13079. }
  13080. this._dirty = true;
  13081. };
  13082. /**
  13083. * Update the current camera state depending on the inputs that have been used this frame.
  13084. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13085. */
  13086. ArcRotateCameraVRDeviceOrientationInput.prototype.checkInputs = function () {
  13087. if (this._dirty) {
  13088. this._dirty = false;
  13089. if (this._gamma < 0) {
  13090. this._gamma = 180 + this._gamma;
  13091. }
  13092. this.camera.alpha = (-this._alpha / 180.0 * Math.PI) % Math.PI * 2;
  13093. this.camera.beta = (this._gamma / 180.0 * Math.PI);
  13094. }
  13095. };
  13096. /**
  13097. * Detach the current controls from the specified dom element.
  13098. * @param element Defines the element to stop listening the inputs from
  13099. */
  13100. ArcRotateCameraVRDeviceOrientationInput.prototype.detachControl = function (element) {
  13101. window.removeEventListener("deviceorientation", this._deviceOrientationHandler);
  13102. };
  13103. /**
  13104. * Gets the class name of the current intput.
  13105. * @returns the class name
  13106. */
  13107. ArcRotateCameraVRDeviceOrientationInput.prototype.getClassName = function () {
  13108. return "ArcRotateCameraVRDeviceOrientationInput";
  13109. };
  13110. /**
  13111. * Get the friendly name associated with the input class.
  13112. * @returns the input friendly name
  13113. */
  13114. ArcRotateCameraVRDeviceOrientationInput.prototype.getSimpleName = function () {
  13115. return "VRDeviceOrientation";
  13116. };
  13117. return ArcRotateCameraVRDeviceOrientationInput;
  13118. }());
  13119. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["ArcRotateCameraVRDeviceOrientationInput"] = ArcRotateCameraVRDeviceOrientationInput;
  13120. /***/ }),
  13121. /***/ "./Cameras/Inputs/flyCameraKeyboardInput.ts":
  13122. /*!**************************************************!*\
  13123. !*** ./Cameras/Inputs/flyCameraKeyboardInput.ts ***!
  13124. \**************************************************/
  13125. /*! exports provided: FlyCameraKeyboardInput */
  13126. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13127. "use strict";
  13128. __webpack_require__.r(__webpack_exports__);
  13129. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return FlyCameraKeyboardInput; });
  13130. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13131. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13132. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13133. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13134. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13135. /**
  13136. * Listen to keyboard events to control the camera.
  13137. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13138. */
  13139. var FlyCameraKeyboardInput = /** @class */ (function () {
  13140. function FlyCameraKeyboardInput() {
  13141. /**
  13142. * The list of keyboard keys used to control the forward move of the camera.
  13143. */
  13144. this.keysForward = [87];
  13145. /**
  13146. * The list of keyboard keys used to control the backward move of the camera.
  13147. */
  13148. this.keysBackward = [83];
  13149. /**
  13150. * The list of keyboard keys used to control the forward move of the camera.
  13151. */
  13152. this.keysUp = [69];
  13153. /**
  13154. * The list of keyboard keys used to control the backward move of the camera.
  13155. */
  13156. this.keysDown = [81];
  13157. /**
  13158. * The list of keyboard keys used to control the right strafe move of the camera.
  13159. */
  13160. this.keysRight = [68];
  13161. /**
  13162. * The list of keyboard keys used to control the left strafe move of the camera.
  13163. */
  13164. this.keysLeft = [65];
  13165. this._keys = new Array();
  13166. }
  13167. /**
  13168. * Attach the input controls to a specific dom element to get the input from.
  13169. * @param element Defines the element the controls should be listened from
  13170. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13171. */
  13172. FlyCameraKeyboardInput.prototype.attachControl = function (element, noPreventDefault) {
  13173. var _this = this;
  13174. if (this._onCanvasBlurObserver) {
  13175. return;
  13176. }
  13177. this._scene = this.camera.getScene();
  13178. this._engine = this._scene.getEngine();
  13179. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13180. _this._keys = [];
  13181. });
  13182. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13183. var evt = info.event;
  13184. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13185. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13186. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13187. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13188. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13189. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13190. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13191. var index = _this._keys.indexOf(evt.keyCode);
  13192. if (index === -1) {
  13193. _this._keys.push(evt.keyCode);
  13194. }
  13195. if (!noPreventDefault) {
  13196. evt.preventDefault();
  13197. }
  13198. }
  13199. }
  13200. else {
  13201. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13202. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13203. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13204. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13205. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13206. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13207. var index = _this._keys.indexOf(evt.keyCode);
  13208. if (index >= 0) {
  13209. _this._keys.splice(index, 1);
  13210. }
  13211. if (!noPreventDefault) {
  13212. evt.preventDefault();
  13213. }
  13214. }
  13215. }
  13216. });
  13217. };
  13218. /**
  13219. * Detach the current controls from the specified dom element.
  13220. * @param element Defines the element to stop listening the inputs from
  13221. */
  13222. FlyCameraKeyboardInput.prototype.detachControl = function (element) {
  13223. if (this._scene) {
  13224. if (this._onKeyboardObserver) {
  13225. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13226. }
  13227. if (this._onCanvasBlurObserver) {
  13228. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13229. }
  13230. this._onKeyboardObserver = null;
  13231. this._onCanvasBlurObserver = null;
  13232. }
  13233. this._keys = [];
  13234. };
  13235. /**
  13236. * Gets the class name of the current intput.
  13237. * @returns the class name
  13238. */
  13239. FlyCameraKeyboardInput.prototype.getClassName = function () {
  13240. return "FlyCameraKeyboardInput";
  13241. };
  13242. /** @hidden */
  13243. FlyCameraKeyboardInput.prototype._onLostFocus = function (e) {
  13244. this._keys = [];
  13245. };
  13246. /**
  13247. * Get the friendly name associated with the input class.
  13248. * @returns the input friendly name
  13249. */
  13250. FlyCameraKeyboardInput.prototype.getSimpleName = function () {
  13251. return "keyboard";
  13252. };
  13253. /**
  13254. * Update the current camera state depending on the inputs that have been used this frame.
  13255. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13256. */
  13257. FlyCameraKeyboardInput.prototype.checkInputs = function () {
  13258. if (this._onKeyboardObserver) {
  13259. var camera = this.camera;
  13260. // Keyboard
  13261. for (var index = 0; index < this._keys.length; index++) {
  13262. var keyCode = this._keys[index];
  13263. var speed = camera._computeLocalCameraSpeed();
  13264. if (this.keysForward.indexOf(keyCode) !== -1) {
  13265. camera._localDirection.copyFromFloats(0, 0, speed);
  13266. }
  13267. else if (this.keysBackward.indexOf(keyCode) !== -1) {
  13268. camera._localDirection.copyFromFloats(0, 0, -speed);
  13269. }
  13270. else if (this.keysUp.indexOf(keyCode) !== -1) {
  13271. camera._localDirection.copyFromFloats(0, speed, 0);
  13272. }
  13273. else if (this.keysDown.indexOf(keyCode) !== -1) {
  13274. camera._localDirection.copyFromFloats(0, -speed, 0);
  13275. }
  13276. else if (this.keysRight.indexOf(keyCode) !== -1) {
  13277. camera._localDirection.copyFromFloats(speed, 0, 0);
  13278. }
  13279. else if (this.keysLeft.indexOf(keyCode) !== -1) {
  13280. camera._localDirection.copyFromFloats(-speed, 0, 0);
  13281. }
  13282. if (camera.getScene().useRightHandedSystem) {
  13283. camera._localDirection.z *= -1;
  13284. }
  13285. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  13286. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  13287. camera.cameraDirection.addInPlace(camera._transformedDirection);
  13288. }
  13289. }
  13290. };
  13291. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13292. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13293. ], FlyCameraKeyboardInput.prototype, "keysForward", void 0);
  13294. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13295. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13296. ], FlyCameraKeyboardInput.prototype, "keysBackward", void 0);
  13297. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13298. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13299. ], FlyCameraKeyboardInput.prototype, "keysUp", void 0);
  13300. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13301. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13302. ], FlyCameraKeyboardInput.prototype, "keysDown", void 0);
  13303. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13304. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13305. ], FlyCameraKeyboardInput.prototype, "keysRight", void 0);
  13306. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13307. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13308. ], FlyCameraKeyboardInput.prototype, "keysLeft", void 0);
  13309. return FlyCameraKeyboardInput;
  13310. }());
  13311. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraKeyboardInput"] = FlyCameraKeyboardInput;
  13312. /***/ }),
  13313. /***/ "./Cameras/Inputs/flyCameraMouseInput.ts":
  13314. /*!***********************************************!*\
  13315. !*** ./Cameras/Inputs/flyCameraMouseInput.ts ***!
  13316. \***********************************************/
  13317. /*! exports provided: FlyCameraMouseInput */
  13318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13319. "use strict";
  13320. __webpack_require__.r(__webpack_exports__);
  13321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return FlyCameraMouseInput; });
  13322. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13323. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13324. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13325. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13326. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13327. /**
  13328. * Listen to mouse events to control the camera.
  13329. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13330. */
  13331. var FlyCameraMouseInput = /** @class */ (function () {
  13332. /**
  13333. * Listen to mouse events to control the camera.
  13334. * @param touchEnabled Define if touch is enabled. (Default is true.)
  13335. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13336. */
  13337. function FlyCameraMouseInput(touchEnabled) {
  13338. if (touchEnabled === void 0) { touchEnabled = true; }
  13339. /**
  13340. * Defines the buttons associated with the input to handle camera rotation.
  13341. */
  13342. this.buttons = [0, 1, 2];
  13343. /**
  13344. * Assign buttons for Yaw control.
  13345. */
  13346. this.buttonsYaw = [-1, 0, 1];
  13347. /**
  13348. * Assign buttons for Pitch control.
  13349. */
  13350. this.buttonsPitch = [-1, 0, 1];
  13351. /**
  13352. * Assign buttons for Roll control.
  13353. */
  13354. this.buttonsRoll = [2];
  13355. /**
  13356. * Detect if any button is being pressed while mouse is moved.
  13357. * -1 = Mouse locked.
  13358. * 0 = Left button.
  13359. * 1 = Middle Button.
  13360. * 2 = Right Button.
  13361. */
  13362. this.activeButton = -1;
  13363. /**
  13364. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  13365. * Higher values reduce its sensitivity.
  13366. */
  13367. this.angularSensibility = 1000.0;
  13368. this.previousPosition = null;
  13369. }
  13370. /**
  13371. * Attach the mouse control to the HTML DOM element.
  13372. * @param element Defines the element that listens to the input events.
  13373. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  13374. */
  13375. FlyCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  13376. var _this = this;
  13377. this.element = element;
  13378. this.noPreventDefault = noPreventDefault;
  13379. this._observer = this.camera.getScene().onPointerObservable.add(function (p, s) {
  13380. _this._pointerInput(p, s);
  13381. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  13382. // Correct Roll by rate, if enabled.
  13383. this._rollObserver = this.camera.getScene().onBeforeRenderObservable.add(function () {
  13384. if (_this.camera.rollCorrect) {
  13385. _this.camera.restoreRoll(_this.camera.rollCorrect);
  13386. }
  13387. });
  13388. // Helper function to keep 'this'.
  13389. this._mousemoveCallback = function (e) {
  13390. _this._onMouseMove(e);
  13391. };
  13392. element.addEventListener("mousemove", this._mousemoveCallback, false);
  13393. };
  13394. /**
  13395. * Detach the current controls from the specified dom element.
  13396. * @param element Defines the element to stop listening the inputs from
  13397. */
  13398. FlyCameraMouseInput.prototype.detachControl = function (element) {
  13399. if (this._observer && element) {
  13400. this.camera.getScene().onPointerObservable.remove(this._observer);
  13401. this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver);
  13402. if (this._mousemoveCallback) {
  13403. element.removeEventListener("mousemove", this._mousemoveCallback);
  13404. }
  13405. this._observer = null;
  13406. this._rollObserver = null;
  13407. this.previousPosition = null;
  13408. this.noPreventDefault = undefined;
  13409. }
  13410. };
  13411. /**
  13412. * Gets the class name of the current input.
  13413. * @returns the class name.
  13414. */
  13415. FlyCameraMouseInput.prototype.getClassName = function () {
  13416. return "FlyCameraMouseInput";
  13417. };
  13418. /**
  13419. * Get the friendly name associated with the input class.
  13420. * @returns the input's friendly name.
  13421. */
  13422. FlyCameraMouseInput.prototype.getSimpleName = function () {
  13423. return "mouse";
  13424. };
  13425. // Track mouse movement, when the pointer is not locked.
  13426. FlyCameraMouseInput.prototype._pointerInput = function (p, s) {
  13427. var e = p.event;
  13428. var camera = this.camera;
  13429. var engine = camera.getEngine();
  13430. if (engine.isInVRExclusivePointerMode) {
  13431. return;
  13432. }
  13433. if (!this.touchEnabled && e.pointerType === "touch") {
  13434. return;
  13435. }
  13436. // Mouse is moved but an unknown mouse button is pressed.
  13437. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && this.buttons.indexOf(e.button) === -1) {
  13438. return;
  13439. }
  13440. var srcElement = (e.srcElement || e.target);
  13441. // Mouse down.
  13442. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  13443. try {
  13444. srcElement.setPointerCapture(e.pointerId);
  13445. }
  13446. catch (e) {
  13447. // Nothing to do with the error. Execution continues.
  13448. }
  13449. this.previousPosition = {
  13450. x: e.clientX,
  13451. y: e.clientY
  13452. };
  13453. this.activeButton = e.button;
  13454. if (!this.noPreventDefault) {
  13455. e.preventDefault();
  13456. this.element.focus();
  13457. }
  13458. }
  13459. else
  13460. // Mouse up.
  13461. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  13462. try {
  13463. srcElement.releasePointerCapture(e.pointerId);
  13464. }
  13465. catch (e) {
  13466. // Nothing to do with the error. Execution continues.
  13467. }
  13468. this.activeButton = -1;
  13469. this.previousPosition = null;
  13470. if (!this.noPreventDefault) {
  13471. e.preventDefault();
  13472. }
  13473. }
  13474. else
  13475. // Mouse move.
  13476. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  13477. if (!this.previousPosition || engine.isPointerLock) {
  13478. return;
  13479. }
  13480. var offsetX = e.clientX - this.previousPosition.x;
  13481. var offsetY = e.clientY - this.previousPosition.y;
  13482. this.rotateCamera(offsetX, offsetY);
  13483. this.previousPosition = {
  13484. x: e.clientX,
  13485. y: e.clientY
  13486. };
  13487. if (!this.noPreventDefault) {
  13488. e.preventDefault();
  13489. }
  13490. }
  13491. };
  13492. // Track mouse movement, when pointer is locked.
  13493. FlyCameraMouseInput.prototype._onMouseMove = function (e) {
  13494. var camera = this.camera;
  13495. var engine = camera.getEngine();
  13496. if (!engine.isPointerLock || engine.isInVRExclusivePointerMode) {
  13497. return;
  13498. }
  13499. var offsetX = e.movementX || e.mozMovementX || e.webkitMovementX || e.msMovementX || 0;
  13500. var offsetY = e.movementY || e.mozMovementY || e.webkitMovementY || e.msMovementY || 0;
  13501. this.rotateCamera(offsetX, offsetY);
  13502. this.previousPosition = null;
  13503. if (!this.noPreventDefault) {
  13504. e.preventDefault();
  13505. }
  13506. };
  13507. /**
  13508. * Rotate camera by mouse offset.
  13509. */
  13510. FlyCameraMouseInput.prototype.rotateCamera = function (offsetX, offsetY) {
  13511. var _this = this;
  13512. var camera = this.camera;
  13513. var scene = this.camera.getScene();
  13514. if (scene.useRightHandedSystem) {
  13515. offsetX *= -1;
  13516. }
  13517. if (camera.parent && camera.parent._getWorldMatrixDeterminant() < 0) {
  13518. offsetX *= -1;
  13519. }
  13520. var x = offsetX / this.angularSensibility;
  13521. var y = offsetY / this.angularSensibility;
  13522. // Initialize to current rotation.
  13523. var currentRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, camera.rotation.z);
  13524. var rotationChange;
  13525. // Pitch.
  13526. if (this.buttonsPitch.some(function (v) { return v === _this.activeButton; })) {
  13527. // Apply change in Radians to vector Angle.
  13528. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].X, y);
  13529. // Apply Pitch to quaternion.
  13530. currentRotation.multiplyInPlace(rotationChange);
  13531. }
  13532. // Yaw.
  13533. if (this.buttonsYaw.some(function (v) { return v === _this.activeButton; })) {
  13534. // Apply change in Radians to vector Angle.
  13535. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Y, x);
  13536. // Apply Yaw to quaternion.
  13537. currentRotation.multiplyInPlace(rotationChange);
  13538. // Add Roll, if banked turning is enabled, within Roll limit.
  13539. var limit = (camera.bankedTurnLimit) + camera._trackRoll; // Defaults to 90° plus manual roll.
  13540. if (camera.bankedTurn && -limit < camera.rotation.z && camera.rotation.z < limit) {
  13541. var bankingDelta = camera.bankedTurnMultiplier * -x;
  13542. // Apply change in Radians to vector Angle.
  13543. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, bankingDelta);
  13544. // Apply Yaw to quaternion.
  13545. currentRotation.multiplyInPlace(rotationChange);
  13546. }
  13547. }
  13548. // Roll.
  13549. if (this.buttonsRoll.some(function (v) { return v === _this.activeButton; })) {
  13550. // Apply change in Radians to vector Angle.
  13551. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, -x);
  13552. // Track Rolling.
  13553. camera._trackRoll -= x;
  13554. // Apply Pitch to quaternion.
  13555. currentRotation.multiplyInPlace(rotationChange);
  13556. }
  13557. // Apply rotationQuaternion to Euler camera.rotation.
  13558. currentRotation.toEulerAnglesToRef(camera.rotation);
  13559. };
  13560. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13561. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13562. ], FlyCameraMouseInput.prototype, "buttons", void 0);
  13563. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13564. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13565. ], FlyCameraMouseInput.prototype, "angularSensibility", void 0);
  13566. return FlyCameraMouseInput;
  13567. }());
  13568. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraMouseInput"] = FlyCameraMouseInput;
  13569. /***/ }),
  13570. /***/ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts":
  13571. /*!*********************************************************!*\
  13572. !*** ./Cameras/Inputs/followCameraKeyboardMoveInput.ts ***!
  13573. \*********************************************************/
  13574. /*! exports provided: FollowCameraKeyboardMoveInput */
  13575. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13576. "use strict";
  13577. __webpack_require__.r(__webpack_exports__);
  13578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return FollowCameraKeyboardMoveInput; });
  13579. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13580. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13581. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13582. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13583. /**
  13584. * Manage the keyboard inputs to control the movement of a follow camera.
  13585. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13586. */
  13587. var FollowCameraKeyboardMoveInput = /** @class */ (function () {
  13588. function FollowCameraKeyboardMoveInput() {
  13589. /**
  13590. * Defines the list of key codes associated with the up action (increase heightOffset)
  13591. */
  13592. this.keysHeightOffsetIncr = [38];
  13593. /**
  13594. * Defines the list of key codes associated with the down action (decrease heightOffset)
  13595. */
  13596. this.keysHeightOffsetDecr = [40];
  13597. /**
  13598. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  13599. */
  13600. this.keysHeightOffsetModifierAlt = false;
  13601. /**
  13602. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  13603. */
  13604. this.keysHeightOffsetModifierCtrl = false;
  13605. /**
  13606. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  13607. */
  13608. this.keysHeightOffsetModifierShift = false;
  13609. /**
  13610. * Defines the list of key codes associated with the left action (increase rotationOffset)
  13611. */
  13612. this.keysRotationOffsetIncr = [37];
  13613. /**
  13614. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  13615. */
  13616. this.keysRotationOffsetDecr = [39];
  13617. /**
  13618. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  13619. */
  13620. this.keysRotationOffsetModifierAlt = false;
  13621. /**
  13622. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  13623. */
  13624. this.keysRotationOffsetModifierCtrl = false;
  13625. /**
  13626. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  13627. */
  13628. this.keysRotationOffsetModifierShift = false;
  13629. /**
  13630. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  13631. */
  13632. this.keysRadiusIncr = [40];
  13633. /**
  13634. * Defines the list of key codes associated with the zoom-out action (increase radius)
  13635. */
  13636. this.keysRadiusDecr = [38];
  13637. /**
  13638. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  13639. */
  13640. this.keysRadiusModifierAlt = true;
  13641. /**
  13642. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  13643. */
  13644. this.keysRadiusModifierCtrl = false;
  13645. /**
  13646. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  13647. */
  13648. this.keysRadiusModifierShift = false;
  13649. /**
  13650. * Defines the rate of change of heightOffset.
  13651. */
  13652. this.heightSensibility = 1;
  13653. /**
  13654. * Defines the rate of change of rotationOffset.
  13655. */
  13656. this.rotationSensibility = 1;
  13657. /**
  13658. * Defines the rate of change of radius.
  13659. */
  13660. this.radiusSensibility = 1;
  13661. this._keys = new Array();
  13662. }
  13663. /**
  13664. * Attach the input controls to a specific dom element to get the input from.
  13665. * @param element Defines the element the controls should be listened from
  13666. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13667. */
  13668. FollowCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  13669. var _this = this;
  13670. if (this._onCanvasBlurObserver) {
  13671. return;
  13672. }
  13673. this._scene = this.camera.getScene();
  13674. this._engine = this._scene.getEngine();
  13675. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13676. _this._keys = [];
  13677. });
  13678. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13679. var evt = info.event;
  13680. if (!evt.metaKey) {
  13681. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13682. _this._ctrlPressed = evt.ctrlKey;
  13683. _this._altPressed = evt.altKey;
  13684. _this._shiftPressed = evt.shiftKey;
  13685. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13686. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13687. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13688. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13689. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13690. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13691. var index = _this._keys.indexOf(evt.keyCode);
  13692. if (index === -1) {
  13693. _this._keys.push(evt.keyCode);
  13694. }
  13695. if (evt.preventDefault) {
  13696. if (!noPreventDefault) {
  13697. evt.preventDefault();
  13698. }
  13699. }
  13700. }
  13701. }
  13702. else {
  13703. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13704. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13705. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13706. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13707. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13708. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13709. var index = _this._keys.indexOf(evt.keyCode);
  13710. if (index >= 0) {
  13711. _this._keys.splice(index, 1);
  13712. }
  13713. if (evt.preventDefault) {
  13714. if (!noPreventDefault) {
  13715. evt.preventDefault();
  13716. }
  13717. }
  13718. }
  13719. }
  13720. }
  13721. });
  13722. };
  13723. /**
  13724. * Detach the current controls from the specified dom element.
  13725. * @param element Defines the element to stop listening the inputs from
  13726. */
  13727. FollowCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  13728. if (this._scene) {
  13729. if (this._onKeyboardObserver) {
  13730. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13731. }
  13732. if (this._onCanvasBlurObserver) {
  13733. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13734. }
  13735. this._onKeyboardObserver = null;
  13736. this._onCanvasBlurObserver = null;
  13737. }
  13738. this._keys = [];
  13739. };
  13740. /**
  13741. * Update the current camera state depending on the inputs that have been used this frame.
  13742. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13743. */
  13744. FollowCameraKeyboardMoveInput.prototype.checkInputs = function () {
  13745. var _this = this;
  13746. if (this._onKeyboardObserver) {
  13747. this._keys.forEach(function (keyCode) {
  13748. if (_this.keysHeightOffsetIncr.indexOf(keyCode) !== -1 &&
  13749. _this._modifierHeightOffset()) {
  13750. _this.camera.heightOffset += _this.heightSensibility;
  13751. }
  13752. else if (_this.keysHeightOffsetDecr.indexOf(keyCode) !== -1 &&
  13753. _this._modifierHeightOffset()) {
  13754. _this.camera.heightOffset -= _this.heightSensibility;
  13755. }
  13756. else if (_this.keysRotationOffsetIncr.indexOf(keyCode) !== -1 &&
  13757. _this._modifierRotationOffset()) {
  13758. _this.camera.rotationOffset += _this.rotationSensibility;
  13759. _this.camera.rotationOffset %= 360;
  13760. }
  13761. else if (_this.keysRotationOffsetDecr.indexOf(keyCode) !== -1 &&
  13762. _this._modifierRotationOffset()) {
  13763. _this.camera.rotationOffset -= _this.rotationSensibility;
  13764. _this.camera.rotationOffset %= 360;
  13765. }
  13766. else if (_this.keysRadiusIncr.indexOf(keyCode) !== -1 &&
  13767. _this._modifierRadius()) {
  13768. _this.camera.radius += _this.radiusSensibility;
  13769. }
  13770. else if (_this.keysRadiusDecr.indexOf(keyCode) !== -1 &&
  13771. _this._modifierRadius()) {
  13772. _this.camera.radius -= _this.radiusSensibility;
  13773. }
  13774. });
  13775. }
  13776. };
  13777. /**
  13778. * Gets the class name of the current input.
  13779. * @returns the class name
  13780. */
  13781. FollowCameraKeyboardMoveInput.prototype.getClassName = function () {
  13782. return "FollowCameraKeyboardMoveInput";
  13783. };
  13784. /**
  13785. * Get the friendly name associated with the input class.
  13786. * @returns the input friendly name
  13787. */
  13788. FollowCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  13789. return "keyboard";
  13790. };
  13791. /**
  13792. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13793. * allow modification of the heightOffset value.
  13794. */
  13795. FollowCameraKeyboardMoveInput.prototype._modifierHeightOffset = function () {
  13796. return (this.keysHeightOffsetModifierAlt === this._altPressed &&
  13797. this.keysHeightOffsetModifierCtrl === this._ctrlPressed &&
  13798. this.keysHeightOffsetModifierShift === this._shiftPressed);
  13799. };
  13800. /**
  13801. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13802. * allow modification of the rotationOffset value.
  13803. */
  13804. FollowCameraKeyboardMoveInput.prototype._modifierRotationOffset = function () {
  13805. return (this.keysRotationOffsetModifierAlt === this._altPressed &&
  13806. this.keysRotationOffsetModifierCtrl === this._ctrlPressed &&
  13807. this.keysRotationOffsetModifierShift === this._shiftPressed);
  13808. };
  13809. /**
  13810. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13811. * allow modification of the radius value.
  13812. */
  13813. FollowCameraKeyboardMoveInput.prototype._modifierRadius = function () {
  13814. return (this.keysRadiusModifierAlt === this._altPressed &&
  13815. this.keysRadiusModifierCtrl === this._ctrlPressed &&
  13816. this.keysRadiusModifierShift === this._shiftPressed);
  13817. };
  13818. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13819. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13820. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetIncr", void 0);
  13821. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13822. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13823. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetDecr", void 0);
  13824. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13825. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13826. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierAlt", void 0);
  13827. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13828. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13829. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierCtrl", void 0);
  13830. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13831. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13832. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierShift", void 0);
  13833. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13834. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13835. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetIncr", void 0);
  13836. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13837. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13838. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetDecr", void 0);
  13839. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13840. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13841. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierAlt", void 0);
  13842. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13843. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13844. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierCtrl", void 0);
  13845. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13846. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13847. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierShift", void 0);
  13848. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13849. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13850. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusIncr", void 0);
  13851. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13852. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13853. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusDecr", void 0);
  13854. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13855. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13856. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierAlt", void 0);
  13857. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13858. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13859. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierCtrl", void 0);
  13860. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13861. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13862. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierShift", void 0);
  13863. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13864. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13865. ], FollowCameraKeyboardMoveInput.prototype, "heightSensibility", void 0);
  13866. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13867. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13868. ], FollowCameraKeyboardMoveInput.prototype, "rotationSensibility", void 0);
  13869. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13870. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13871. ], FollowCameraKeyboardMoveInput.prototype, "radiusSensibility", void 0);
  13872. return FollowCameraKeyboardMoveInput;
  13873. }());
  13874. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FollowCameraKeyboardMoveInput"] = FollowCameraKeyboardMoveInput;
  13875. /***/ }),
  13876. /***/ "./Cameras/Inputs/followCameraMouseWheelInput.ts":
  13877. /*!*******************************************************!*\
  13878. !*** ./Cameras/Inputs/followCameraMouseWheelInput.ts ***!
  13879. \*******************************************************/
  13880. /*! exports provided: FollowCameraMouseWheelInput */
  13881. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13882. "use strict";
  13883. __webpack_require__.r(__webpack_exports__);
  13884. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return FollowCameraMouseWheelInput; });
  13885. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13886. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13887. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13888. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13889. /**
  13890. * Manage the mouse wheel inputs to control a follow camera.
  13891. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13892. */
  13893. var FollowCameraMouseWheelInput = /** @class */ (function () {
  13894. function FollowCameraMouseWheelInput() {
  13895. /**
  13896. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  13897. */
  13898. this.axisControlRadius = true;
  13899. /**
  13900. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  13901. */
  13902. this.axisControlHeight = false;
  13903. /**
  13904. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  13905. */
  13906. this.axisControlRotation = false;
  13907. /**
  13908. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  13909. * relation to mouseWheel events.
  13910. */
  13911. this.wheelPrecision = 3.0;
  13912. /**
  13913. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  13914. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  13915. */
  13916. this.wheelDeltaPercentage = 0;
  13917. }
  13918. /**
  13919. * Attach the input controls to a specific dom element to get the input from.
  13920. * @param element Defines the element the controls should be listened from
  13921. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13922. */
  13923. FollowCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  13924. var _this = this;
  13925. this._wheel = function (p, s) {
  13926. // sanity check - this should be a PointerWheel event.
  13927. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  13928. return;
  13929. }
  13930. var event = p.event;
  13931. var delta = 0;
  13932. // Chrome, Safari: event.deltaY
  13933. // IE: event.wheelDelta
  13934. // Firefox: event.detail (inverted)
  13935. var wheelDelta = Math.max(-1, Math.min(1, (event.deltaY || event.wheelDelta || -event.detail)));
  13936. if (_this.wheelDeltaPercentage) {
  13937. console.assert((_this.axisControlRadius +
  13938. _this.axisControlHeight +
  13939. _this.axisControlRotation) <= 1, "wheelDeltaPercentage only usable when mouse wheel " +
  13940. "controlls ONE axis. " +
  13941. "Currently enabled: " +
  13942. "axisControlRadius: " + _this.axisControlRadius +
  13943. ", axisControlHeightOffset: " + _this.axisControlHeight +
  13944. ", axisControlRotationOffset: " + _this.axisControlRotation);
  13945. if (_this.axisControlRadius) {
  13946. delta =
  13947. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13948. _this.camera.radius;
  13949. }
  13950. else if (_this.axisControlHeight) {
  13951. delta =
  13952. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13953. _this.camera.heightOffset;
  13954. }
  13955. else if (_this.axisControlRotation) {
  13956. delta =
  13957. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13958. _this.camera.rotationOffset;
  13959. }
  13960. }
  13961. else {
  13962. delta = wheelDelta * _this.wheelPrecision;
  13963. }
  13964. if (delta) {
  13965. if (_this.axisControlRadius) {
  13966. _this.camera.radius += delta;
  13967. }
  13968. else if (_this.axisControlHeight) {
  13969. _this.camera.heightOffset -= delta;
  13970. }
  13971. else if (_this.axisControlRotation) {
  13972. _this.camera.rotationOffset -= delta;
  13973. }
  13974. }
  13975. if (event.preventDefault) {
  13976. if (!noPreventDefault) {
  13977. event.preventDefault();
  13978. }
  13979. }
  13980. };
  13981. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  13982. };
  13983. /**
  13984. * Detach the current controls from the specified dom element.
  13985. * @param element Defines the element to stop listening the inputs from
  13986. */
  13987. FollowCameraMouseWheelInput.prototype.detachControl = function (element) {
  13988. if (this._observer && element) {
  13989. this.camera.getScene().onPointerObservable.remove(this._observer);
  13990. this._observer = null;
  13991. this._wheel = null;
  13992. }
  13993. };
  13994. /**
  13995. * Gets the class name of the current intput.
  13996. * @returns the class name
  13997. */
  13998. FollowCameraMouseWheelInput.prototype.getClassName = function () {
  13999. return "ArcRotateCameraMouseWheelInput";
  14000. };
  14001. /**
  14002. * Get the friendly name associated with the input class.
  14003. * @returns the input friendly name
  14004. */
  14005. FollowCameraMouseWheelInput.prototype.getSimpleName = function () {
  14006. return "mousewheel";
  14007. };
  14008. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14009. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14010. ], FollowCameraMouseWheelInput.prototype, "axisControlRadius", void 0);
  14011. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14012. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14013. ], FollowCameraMouseWheelInput.prototype, "axisControlHeight", void 0);
  14014. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14015. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14016. ], FollowCameraMouseWheelInput.prototype, "axisControlRotation", void 0);
  14017. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14018. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14019. ], FollowCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  14020. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14021. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14022. ], FollowCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  14023. return FollowCameraMouseWheelInput;
  14024. }());
  14025. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FollowCameraMouseWheelInput"] = FollowCameraMouseWheelInput;
  14026. /***/ }),
  14027. /***/ "./Cameras/Inputs/followCameraPointersInput.ts":
  14028. /*!*****************************************************!*\
  14029. !*** ./Cameras/Inputs/followCameraPointersInput.ts ***!
  14030. \*****************************************************/
  14031. /*! exports provided: FollowCameraPointersInput */
  14032. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14033. "use strict";
  14034. __webpack_require__.r(__webpack_exports__);
  14035. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return FollowCameraPointersInput; });
  14036. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14037. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14038. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14039. /* harmony import */ var _Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/Inputs/BaseCameraPointersInput */ "./Cameras/Inputs/BaseCameraPointersInput.ts");
  14040. /**
  14041. * Manage the pointers inputs to control an follow camera.
  14042. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14043. */
  14044. var FollowCameraPointersInput = /** @class */ (function (_super) {
  14045. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraPointersInput, _super);
  14046. function FollowCameraPointersInput() {
  14047. var _this = _super !== null && _super.apply(this, arguments) || this;
  14048. /**
  14049. * Defines the pointer angular sensibility along the X axis or how fast is
  14050. * the camera rotating.
  14051. * A negative number will reverse the axis direction.
  14052. */
  14053. _this.angularSensibilityX = 1;
  14054. /**
  14055. * Defines the pointer angular sensibility along the Y axis or how fast is
  14056. * the camera rotating.
  14057. * A negative number will reverse the axis direction.
  14058. */
  14059. _this.angularSensibilityY = 1;
  14060. /**
  14061. * Defines the pointer pinch precision or how fast is the camera zooming.
  14062. * A negative number will reverse the axis direction.
  14063. */
  14064. _this.pinchPrecision = 10000.0;
  14065. /**
  14066. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  14067. * from 0.
  14068. * It defines the percentage of current camera.radius to use as delta when
  14069. * pinch zoom is used.
  14070. */
  14071. _this.pinchDeltaPercentage = 0;
  14072. /**
  14073. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  14074. */
  14075. _this.axisXControlRadius = false;
  14076. /**
  14077. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  14078. */
  14079. _this.axisXControlHeight = false;
  14080. /**
  14081. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  14082. */
  14083. _this.axisXControlRotation = true;
  14084. /**
  14085. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  14086. */
  14087. _this.axisYControlRadius = false;
  14088. /**
  14089. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  14090. */
  14091. _this.axisYControlHeight = true;
  14092. /**
  14093. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  14094. */
  14095. _this.axisYControlRotation = false;
  14096. /**
  14097. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  14098. */
  14099. _this.axisPinchControlRadius = true;
  14100. /**
  14101. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  14102. */
  14103. _this.axisPinchControlHeight = false;
  14104. /**
  14105. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  14106. */
  14107. _this.axisPinchControlRotation = false;
  14108. /**
  14109. * Log error messages if basic misconfiguration has occurred.
  14110. */
  14111. _this.warningEnable = true;
  14112. /* Check for obvious misconfiguration. */
  14113. _this._warningCounter = 0;
  14114. return _this;
  14115. }
  14116. /**
  14117. * Gets the class name of the current input.
  14118. * @returns the class name
  14119. */
  14120. FollowCameraPointersInput.prototype.getClassName = function () {
  14121. return "FollowCameraPointersInput";
  14122. };
  14123. FollowCameraPointersInput.prototype.onTouch = function (pointA, offsetX, offsetY) {
  14124. this._warning();
  14125. if (this.axisXControlRotation) {
  14126. this.camera.rotationOffset += offsetX / this.angularSensibilityX;
  14127. }
  14128. else if (this.axisYControlRotation) {
  14129. this.camera.rotationOffset += offsetY / this.angularSensibilityX;
  14130. }
  14131. if (this.axisXControlHeight) {
  14132. this.camera.heightOffset += offsetX / this.angularSensibilityY;
  14133. }
  14134. else if (this.axisYControlHeight) {
  14135. this.camera.heightOffset += offsetY / this.angularSensibilityY;
  14136. }
  14137. if (this.axisXControlRadius) {
  14138. this.camera.radius -= offsetX / this.angularSensibilityY;
  14139. }
  14140. else if (this.axisYControlRadius) {
  14141. this.camera.radius -= offsetY / this.angularSensibilityY;
  14142. }
  14143. };
  14144. FollowCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  14145. if (previousPinchSquaredDistance === 0 && previousMultiTouchPanPosition === null) {
  14146. // First time this method is called for new pinch.
  14147. // Next time this is called there will be a
  14148. // previousPinchSquaredDistance and pinchSquaredDistance to compare.
  14149. return;
  14150. }
  14151. if (pinchSquaredDistance === 0 && multiTouchPanPosition === null) {
  14152. // Last time this method is called at the end of a pinch.
  14153. return;
  14154. }
  14155. var pinchDelta = (pinchSquaredDistance - previousPinchSquaredDistance) /
  14156. (this.pinchPrecision * (this.angularSensibilityX + this.angularSensibilityY) / 2);
  14157. if (this.pinchDeltaPercentage) {
  14158. pinchDelta *= 0.01 * this.pinchDeltaPercentage;
  14159. if (this.axisPinchControlRotation) {
  14160. this.camera.rotationOffset += pinchDelta * this.camera.rotationOffset;
  14161. }
  14162. if (this.axisPinchControlHeight) {
  14163. this.camera.heightOffset += pinchDelta * this.camera.heightOffset;
  14164. }
  14165. if (this.axisPinchControlRadius) {
  14166. this.camera.radius -= pinchDelta * this.camera.radius;
  14167. }
  14168. }
  14169. else {
  14170. if (this.axisPinchControlRotation) {
  14171. this.camera.rotationOffset += pinchDelta;
  14172. }
  14173. if (this.axisPinchControlHeight) {
  14174. this.camera.heightOffset += pinchDelta;
  14175. }
  14176. if (this.axisPinchControlRadius) {
  14177. this.camera.radius -= pinchDelta;
  14178. }
  14179. }
  14180. };
  14181. FollowCameraPointersInput.prototype._warning = function () {
  14182. if (!this.warningEnable || this._warningCounter++ % 100 !== 0) {
  14183. return;
  14184. }
  14185. var warn = "It probably only makes sense to control ONE camera " +
  14186. "property with each pointer axis. Set 'warningEnable = false' " +
  14187. "if you are sure. Currently enabled: ";
  14188. console.assert((this.axisXControlRotation +
  14189. this.axisXControlHeight +
  14190. this.axisXControlRadius) <= 1, warn +
  14191. "axisXControlRotation: " + this.axisXControlRotation +
  14192. ", axisXControlHeight: " + this.axisXControlHeight +
  14193. ", axisXControlRadius: " + this.axisXControlRadius);
  14194. console.assert((this.axisYControlRotation +
  14195. this.axisYControlHeight +
  14196. this.axisYControlRadius) <= 1, warn +
  14197. "axisYControlRotation: " + this.axisYControlRotation +
  14198. ", axisYControlHeight: " + this.axisYControlHeight +
  14199. ", axisYControlRadius: " + this.axisYControlRadius);
  14200. console.assert((this.axisPinchControlRotation +
  14201. this.axisPinchControlHeight +
  14202. this.axisPinchControlRadius) <= 1, warn +
  14203. "axisPinchControlRotation: " + this.axisPinchControlRotation +
  14204. ", axisPinchControlHeight: " + this.axisPinchControlHeight +
  14205. ", axisPinchControlRadius: " + this.axisPinchControlRadius);
  14206. };
  14207. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14208. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14209. ], FollowCameraPointersInput.prototype, "angularSensibilityX", void 0);
  14210. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14211. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14212. ], FollowCameraPointersInput.prototype, "angularSensibilityY", void 0);
  14213. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14214. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14215. ], FollowCameraPointersInput.prototype, "pinchPrecision", void 0);
  14216. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14217. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14218. ], FollowCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  14219. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14220. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14221. ], FollowCameraPointersInput.prototype, "axisXControlRadius", void 0);
  14222. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14223. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14224. ], FollowCameraPointersInput.prototype, "axisXControlHeight", void 0);
  14225. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14226. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14227. ], FollowCameraPointersInput.prototype, "axisXControlRotation", void 0);
  14228. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14229. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14230. ], FollowCameraPointersInput.prototype, "axisYControlRadius", void 0);
  14231. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14232. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14233. ], FollowCameraPointersInput.prototype, "axisYControlHeight", void 0);
  14234. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14235. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14236. ], FollowCameraPointersInput.prototype, "axisYControlRotation", void 0);
  14237. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14238. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14239. ], FollowCameraPointersInput.prototype, "axisPinchControlRadius", void 0);
  14240. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14241. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14242. ], FollowCameraPointersInput.prototype, "axisPinchControlHeight", void 0);
  14243. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14244. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14245. ], FollowCameraPointersInput.prototype, "axisPinchControlRotation", void 0);
  14246. return FollowCameraPointersInput;
  14247. }(_Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["BaseCameraPointersInput"]));
  14248. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FollowCameraPointersInput"] = FollowCameraPointersInput;
  14249. /***/ }),
  14250. /***/ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts":
  14251. /*!************************************************************!*\
  14252. !*** ./Cameras/Inputs/freeCameraDeviceOrientationInput.ts ***!
  14253. \************************************************************/
  14254. /*! exports provided: FreeCameraDeviceOrientationInput */
  14255. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14256. "use strict";
  14257. __webpack_require__.r(__webpack_exports__);
  14258. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return FreeCameraDeviceOrientationInput; });
  14259. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14260. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14261. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  14262. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  14263. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  14264. /**
  14265. * Add orientation input support to the input manager.
  14266. * @returns the current input manager
  14267. */
  14268. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addDeviceOrientation = function () {
  14269. if (!this._deviceOrientationInput) {
  14270. this._deviceOrientationInput = new FreeCameraDeviceOrientationInput();
  14271. this.add(this._deviceOrientationInput);
  14272. }
  14273. return this;
  14274. };
  14275. /**
  14276. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  14277. * Screen rotation is taken into account.
  14278. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14279. */
  14280. var FreeCameraDeviceOrientationInput = /** @class */ (function () {
  14281. /**
  14282. * Instantiates a new input
  14283. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14284. */
  14285. function FreeCameraDeviceOrientationInput() {
  14286. var _this = this;
  14287. this._screenOrientationAngle = 0;
  14288. this._screenQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  14289. this._alpha = 0;
  14290. this._beta = 0;
  14291. this._gamma = 0;
  14292. /**
  14293. * @hidden
  14294. */
  14295. this._onDeviceOrientationChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  14296. this._orientationChanged = function () {
  14297. _this._screenOrientationAngle = (window.orientation !== undefined ? +window.orientation : (window.screen.orientation && (window.screen.orientation)['angle'] ? (window.screen.orientation).angle : 0));
  14298. _this._screenOrientationAngle = -_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(_this._screenOrientationAngle / 2);
  14299. _this._screenQuaternion.copyFromFloats(0, Math.sin(_this._screenOrientationAngle), 0, Math.cos(_this._screenOrientationAngle));
  14300. };
  14301. this._deviceOrientation = function (evt) {
  14302. _this._alpha = evt.alpha !== null ? evt.alpha : 0;
  14303. _this._beta = evt.beta !== null ? evt.beta : 0;
  14304. _this._gamma = evt.gamma !== null ? evt.gamma : 0;
  14305. if (evt.alpha !== null) {
  14306. _this._onDeviceOrientationChangedObservable.notifyObservers();
  14307. }
  14308. };
  14309. this._constantTranform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-Math.sqrt(0.5), 0, 0, Math.sqrt(0.5));
  14310. this._orientationChanged();
  14311. }
  14312. Object.defineProperty(FreeCameraDeviceOrientationInput.prototype, "camera", {
  14313. /**
  14314. * Define the camera controlled by the input.
  14315. */
  14316. get: function () {
  14317. return this._camera;
  14318. },
  14319. set: function (camera) {
  14320. var _this = this;
  14321. this._camera = camera;
  14322. if (this._camera != null && !this._camera.rotationQuaternion) {
  14323. this._camera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  14324. }
  14325. if (this._camera) {
  14326. this._camera.onDisposeObservable.add(function () {
  14327. _this._onDeviceOrientationChangedObservable.clear();
  14328. });
  14329. }
  14330. },
  14331. enumerable: true,
  14332. configurable: true
  14333. });
  14334. /**
  14335. * Attach the input controls to a specific dom element to get the input from.
  14336. * @param element Defines the element the controls should be listened from
  14337. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14338. */
  14339. FreeCameraDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  14340. window.addEventListener("orientationchange", this._orientationChanged);
  14341. window.addEventListener("deviceorientation", this._deviceOrientation);
  14342. //In certain cases, the attach control is called AFTER orientation was changed,
  14343. //So this is needed.
  14344. this._orientationChanged();
  14345. };
  14346. /**
  14347. * Detach the current controls from the specified dom element.
  14348. * @param element Defines the element to stop listening the inputs from
  14349. */
  14350. FreeCameraDeviceOrientationInput.prototype.detachControl = function (element) {
  14351. window.removeEventListener("orientationchange", this._orientationChanged);
  14352. window.removeEventListener("deviceorientation", this._deviceOrientation);
  14353. this._alpha = 0;
  14354. };
  14355. /**
  14356. * Update the current camera state depending on the inputs that have been used this frame.
  14357. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14358. */
  14359. FreeCameraDeviceOrientationInput.prototype.checkInputs = function () {
  14360. //if no device orientation provided, don't update the rotation.
  14361. //Only testing against alpha under the assumption thatnorientation will never be so exact when set.
  14362. if (!this._alpha) {
  14363. return;
  14364. }
  14365. _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);
  14366. this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion);
  14367. this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform);
  14368. //Mirror on XY Plane
  14369. this._camera.rotationQuaternion.z *= -1;
  14370. this._camera.rotationQuaternion.w *= -1;
  14371. };
  14372. /**
  14373. * Gets the class name of the current intput.
  14374. * @returns the class name
  14375. */
  14376. FreeCameraDeviceOrientationInput.prototype.getClassName = function () {
  14377. return "FreeCameraDeviceOrientationInput";
  14378. };
  14379. /**
  14380. * Get the friendly name associated with the input class.
  14381. * @returns the input friendly name
  14382. */
  14383. FreeCameraDeviceOrientationInput.prototype.getSimpleName = function () {
  14384. return "deviceOrientation";
  14385. };
  14386. return FreeCameraDeviceOrientationInput;
  14387. }());
  14388. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["FreeCameraDeviceOrientationInput"] = FreeCameraDeviceOrientationInput;
  14389. /***/ }),
  14390. /***/ "./Cameras/Inputs/freeCameraGamepadInput.ts":
  14391. /*!**************************************************!*\
  14392. !*** ./Cameras/Inputs/freeCameraGamepadInput.ts ***!
  14393. \**************************************************/
  14394. /*! exports provided: FreeCameraGamepadInput */
  14395. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14396. "use strict";
  14397. __webpack_require__.r(__webpack_exports__);
  14398. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return FreeCameraGamepadInput; });
  14399. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14400. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14401. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14402. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14403. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  14404. /**
  14405. * Manage the gamepad inputs to control a free camera.
  14406. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14407. */
  14408. var FreeCameraGamepadInput = /** @class */ (function () {
  14409. function FreeCameraGamepadInput() {
  14410. /**
  14411. * Defines the gamepad rotation sensiblity.
  14412. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  14413. */
  14414. this.gamepadAngularSensibility = 200;
  14415. /**
  14416. * Defines the gamepad move sensiblity.
  14417. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  14418. */
  14419. this.gamepadMoveSensibility = 40;
  14420. this._cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  14421. this._deltaTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  14422. this._vector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  14423. this._vector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  14424. }
  14425. /**
  14426. * Attach the input controls to a specific dom element to get the input from.
  14427. * @param element Defines the element the controls should be listened from
  14428. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14429. */
  14430. FreeCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  14431. var _this = this;
  14432. var manager = this.camera.getScene().gamepadManager;
  14433. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  14434. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].POSE_ENABLED) {
  14435. // prioritize XBOX gamepads.
  14436. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX) {
  14437. _this.gamepad = gamepad;
  14438. }
  14439. }
  14440. });
  14441. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  14442. if (_this.gamepad === gamepad) {
  14443. _this.gamepad = null;
  14444. }
  14445. });
  14446. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX);
  14447. };
  14448. /**
  14449. * Detach the current controls from the specified dom element.
  14450. * @param element Defines the element to stop listening the inputs from
  14451. */
  14452. FreeCameraGamepadInput.prototype.detachControl = function (element) {
  14453. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  14454. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  14455. this.gamepad = null;
  14456. };
  14457. /**
  14458. * Update the current camera state depending on the inputs that have been used this frame.
  14459. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14460. */
  14461. FreeCameraGamepadInput.prototype.checkInputs = function () {
  14462. if (this.gamepad && this.gamepad.leftStick) {
  14463. var camera = this.camera;
  14464. var LSValues = this.gamepad.leftStick;
  14465. var normalizedLX = LSValues.x / this.gamepadMoveSensibility;
  14466. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  14467. LSValues.x = Math.abs(normalizedLX) > 0.005 ? 0 + normalizedLX : 0;
  14468. LSValues.y = Math.abs(normalizedLY) > 0.005 ? 0 + normalizedLY : 0;
  14469. var RSValues = this.gamepad.rightStick;
  14470. if (RSValues) {
  14471. var normalizedRX = RSValues.x / this.gamepadAngularSensibility;
  14472. var normalizedRY = RSValues.y / this.gamepadAngularSensibility;
  14473. RSValues.x = Math.abs(normalizedRX) > 0.001 ? 0 + normalizedRX : 0;
  14474. RSValues.y = Math.abs(normalizedRY) > 0.001 ? 0 + normalizedRY : 0;
  14475. }
  14476. else {
  14477. RSValues = { x: 0, y: 0 };
  14478. }
  14479. if (!camera.rotationQuaternion) {
  14480. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, this._cameraTransform);
  14481. }
  14482. else {
  14483. camera.rotationQuaternion.toRotationMatrix(this._cameraTransform);
  14484. }
  14485. var speed = camera._computeLocalCameraSpeed() * 50.0;
  14486. this._vector3.copyFromFloats(LSValues.x * speed, 0, -LSValues.y * speed);
  14487. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._vector3, this._cameraTransform, this._deltaTransform);
  14488. camera.cameraDirection.addInPlace(this._deltaTransform);
  14489. this._vector2.copyFromFloats(RSValues.y, RSValues.x);
  14490. camera.cameraRotation.addInPlace(this._vector2);
  14491. }
  14492. };
  14493. /**
  14494. * Gets the class name of the current intput.
  14495. * @returns the class name
  14496. */
  14497. FreeCameraGamepadInput.prototype.getClassName = function () {
  14498. return "FreeCameraGamepadInput";
  14499. };
  14500. /**
  14501. * Get the friendly name associated with the input class.
  14502. * @returns the input friendly name
  14503. */
  14504. FreeCameraGamepadInput.prototype.getSimpleName = function () {
  14505. return "gamepad";
  14506. };
  14507. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14508. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14509. ], FreeCameraGamepadInput.prototype, "gamepadAngularSensibility", void 0);
  14510. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14511. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14512. ], FreeCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  14513. return FreeCameraGamepadInput;
  14514. }());
  14515. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraGamepadInput"] = FreeCameraGamepadInput;
  14516. /***/ }),
  14517. /***/ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts":
  14518. /*!*******************************************************!*\
  14519. !*** ./Cameras/Inputs/freeCameraKeyboardMoveInput.ts ***!
  14520. \*******************************************************/
  14521. /*! exports provided: FreeCameraKeyboardMoveInput */
  14522. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14523. "use strict";
  14524. __webpack_require__.r(__webpack_exports__);
  14525. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return FreeCameraKeyboardMoveInput; });
  14526. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14527. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14528. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14529. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  14530. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14531. /**
  14532. * Manage the keyboard inputs to control the movement of a free camera.
  14533. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14534. */
  14535. var FreeCameraKeyboardMoveInput = /** @class */ (function () {
  14536. function FreeCameraKeyboardMoveInput() {
  14537. /**
  14538. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  14539. */
  14540. this.keysUp = [38];
  14541. /**
  14542. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  14543. */
  14544. this.keysDown = [40];
  14545. /**
  14546. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  14547. */
  14548. this.keysLeft = [37];
  14549. /**
  14550. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  14551. */
  14552. this.keysRight = [39];
  14553. this._keys = new Array();
  14554. }
  14555. /**
  14556. * Attach the input controls to a specific dom element to get the input from.
  14557. * @param element Defines the element the controls should be listened from
  14558. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14559. */
  14560. FreeCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  14561. var _this = this;
  14562. if (this._onCanvasBlurObserver) {
  14563. return;
  14564. }
  14565. this._scene = this.camera.getScene();
  14566. this._engine = this._scene.getEngine();
  14567. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  14568. _this._keys = [];
  14569. });
  14570. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  14571. var evt = info.event;
  14572. if (!evt.metaKey) {
  14573. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  14574. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14575. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14576. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14577. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14578. var index = _this._keys.indexOf(evt.keyCode);
  14579. if (index === -1) {
  14580. _this._keys.push(evt.keyCode);
  14581. }
  14582. if (!noPreventDefault) {
  14583. evt.preventDefault();
  14584. }
  14585. }
  14586. }
  14587. else {
  14588. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14589. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14590. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14591. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14592. var index = _this._keys.indexOf(evt.keyCode);
  14593. if (index >= 0) {
  14594. _this._keys.splice(index, 1);
  14595. }
  14596. if (!noPreventDefault) {
  14597. evt.preventDefault();
  14598. }
  14599. }
  14600. }
  14601. }
  14602. });
  14603. };
  14604. /**
  14605. * Detach the current controls from the specified dom element.
  14606. * @param element Defines the element to stop listening the inputs from
  14607. */
  14608. FreeCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  14609. if (this._scene) {
  14610. if (this._onKeyboardObserver) {
  14611. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  14612. }
  14613. if (this._onCanvasBlurObserver) {
  14614. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  14615. }
  14616. this._onKeyboardObserver = null;
  14617. this._onCanvasBlurObserver = null;
  14618. }
  14619. this._keys = [];
  14620. };
  14621. /**
  14622. * Update the current camera state depending on the inputs that have been used this frame.
  14623. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14624. */
  14625. FreeCameraKeyboardMoveInput.prototype.checkInputs = function () {
  14626. if (this._onKeyboardObserver) {
  14627. var camera = this.camera;
  14628. // Keyboard
  14629. for (var index = 0; index < this._keys.length; index++) {
  14630. var keyCode = this._keys[index];
  14631. var speed = camera._computeLocalCameraSpeed();
  14632. if (this.keysLeft.indexOf(keyCode) !== -1) {
  14633. camera._localDirection.copyFromFloats(-speed, 0, 0);
  14634. }
  14635. else if (this.keysUp.indexOf(keyCode) !== -1) {
  14636. camera._localDirection.copyFromFloats(0, 0, speed);
  14637. }
  14638. else if (this.keysRight.indexOf(keyCode) !== -1) {
  14639. camera._localDirection.copyFromFloats(speed, 0, 0);
  14640. }
  14641. else if (this.keysDown.indexOf(keyCode) !== -1) {
  14642. camera._localDirection.copyFromFloats(0, 0, -speed);
  14643. }
  14644. if (camera.getScene().useRightHandedSystem) {
  14645. camera._localDirection.z *= -1;
  14646. }
  14647. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  14648. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  14649. camera.cameraDirection.addInPlace(camera._transformedDirection);
  14650. }
  14651. }
  14652. };
  14653. /**
  14654. * Gets the class name of the current intput.
  14655. * @returns the class name
  14656. */
  14657. FreeCameraKeyboardMoveInput.prototype.getClassName = function () {
  14658. return "FreeCameraKeyboardMoveInput";
  14659. };
  14660. /** @hidden */
  14661. FreeCameraKeyboardMoveInput.prototype._onLostFocus = function () {
  14662. this._keys = [];
  14663. };
  14664. /**
  14665. * Get the friendly name associated with the input class.
  14666. * @returns the input friendly name
  14667. */
  14668. FreeCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  14669. return "keyboard";
  14670. };
  14671. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14672. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14673. ], FreeCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  14674. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14675. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14676. ], FreeCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  14677. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14678. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14679. ], FreeCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  14680. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14681. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14682. ], FreeCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  14683. return FreeCameraKeyboardMoveInput;
  14684. }());
  14685. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraKeyboardMoveInput"] = FreeCameraKeyboardMoveInput;
  14686. /***/ }),
  14687. /***/ "./Cameras/Inputs/freeCameraMouseInput.ts":
  14688. /*!************************************************!*\
  14689. !*** ./Cameras/Inputs/freeCameraMouseInput.ts ***!
  14690. \************************************************/
  14691. /*! exports provided: FreeCameraMouseInput */
  14692. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14693. "use strict";
  14694. __webpack_require__.r(__webpack_exports__);
  14695. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return FreeCameraMouseInput; });
  14696. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14697. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  14698. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14699. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14700. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14701. /**
  14702. * Manage the mouse inputs to control the movement of a free camera.
  14703. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14704. */
  14705. var FreeCameraMouseInput = /** @class */ (function () {
  14706. /**
  14707. * Manage the mouse inputs to control the movement of a free camera.
  14708. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14709. * @param touchEnabled Defines if touch is enabled or not
  14710. */
  14711. function FreeCameraMouseInput(
  14712. /**
  14713. * Define if touch is enabled in the mouse input
  14714. */
  14715. touchEnabled) {
  14716. if (touchEnabled === void 0) { touchEnabled = true; }
  14717. this.touchEnabled = touchEnabled;
  14718. /**
  14719. * Defines the buttons associated with the input to handle camera move.
  14720. */
  14721. this.buttons = [0, 1, 2];
  14722. /**
  14723. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  14724. */
  14725. this.angularSensibility = 2000.0;
  14726. this.previousPosition = null;
  14727. /**
  14728. * Observable for when a pointer move event occurs containing the move offset
  14729. */
  14730. this.onPointerMovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  14731. /**
  14732. * @hidden
  14733. * If the camera should be rotated automatically based on pointer movement
  14734. */
  14735. this._allowCameraRotation = true;
  14736. }
  14737. /**
  14738. * Attach the input controls to a specific dom element to get the input from.
  14739. * @param element Defines the element the controls should be listened from
  14740. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14741. */
  14742. FreeCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  14743. var _this = this;
  14744. var engine = this.camera.getEngine();
  14745. if (!this._pointerInput) {
  14746. this._pointerInput = function (p) {
  14747. var evt = p.event;
  14748. if (engine.isInVRExclusivePointerMode) {
  14749. return;
  14750. }
  14751. if (!_this.touchEnabled && evt.pointerType === "touch") {
  14752. return;
  14753. }
  14754. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  14755. return;
  14756. }
  14757. var srcElement = (evt.srcElement || evt.target);
  14758. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN && srcElement) {
  14759. try {
  14760. srcElement.setPointerCapture(evt.pointerId);
  14761. }
  14762. catch (e) {
  14763. //Nothing to do with the error. Execution will continue.
  14764. }
  14765. _this.previousPosition = {
  14766. x: evt.clientX,
  14767. y: evt.clientY
  14768. };
  14769. if (!noPreventDefault) {
  14770. evt.preventDefault();
  14771. element.focus();
  14772. }
  14773. }
  14774. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP && srcElement) {
  14775. try {
  14776. srcElement.releasePointerCapture(evt.pointerId);
  14777. }
  14778. catch (e) {
  14779. //Nothing to do with the error.
  14780. }
  14781. _this.previousPosition = null;
  14782. if (!noPreventDefault) {
  14783. evt.preventDefault();
  14784. }
  14785. }
  14786. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  14787. if (!_this.previousPosition || engine.isPointerLock) {
  14788. return;
  14789. }
  14790. var offsetX = evt.clientX - _this.previousPosition.x;
  14791. var offsetY = evt.clientY - _this.previousPosition.y;
  14792. if (_this.camera.getScene().useRightHandedSystem) {
  14793. offsetX *= -1;
  14794. }
  14795. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14796. offsetX *= -1;
  14797. }
  14798. if (_this._allowCameraRotation) {
  14799. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14800. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14801. }
  14802. _this.onPointerMovedObservable.notifyObservers({ offsetX: offsetX, offsetY: offsetY });
  14803. _this.previousPosition = {
  14804. x: evt.clientX,
  14805. y: evt.clientY
  14806. };
  14807. if (!noPreventDefault) {
  14808. evt.preventDefault();
  14809. }
  14810. }
  14811. };
  14812. }
  14813. this._onMouseMove = function (evt) {
  14814. if (!engine.isPointerLock) {
  14815. return;
  14816. }
  14817. if (engine.isInVRExclusivePointerMode) {
  14818. return;
  14819. }
  14820. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  14821. if (_this.camera.getScene().useRightHandedSystem) {
  14822. offsetX *= -1;
  14823. }
  14824. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14825. offsetX *= -1;
  14826. }
  14827. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14828. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  14829. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14830. _this.previousPosition = null;
  14831. if (!noPreventDefault) {
  14832. evt.preventDefault();
  14833. }
  14834. };
  14835. this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE);
  14836. element.addEventListener("mousemove", this._onMouseMove, false);
  14837. element.addEventListener("contextmenu", this.onContextMenu.bind(this), false);
  14838. };
  14839. /**
  14840. * Called on JS contextmenu event.
  14841. * Override this method to provide functionality.
  14842. */
  14843. FreeCameraMouseInput.prototype.onContextMenu = function (evt) {
  14844. evt.preventDefault();
  14845. };
  14846. /**
  14847. * Detach the current controls from the specified dom element.
  14848. * @param element Defines the element to stop listening the inputs from
  14849. */
  14850. FreeCameraMouseInput.prototype.detachControl = function (element) {
  14851. if (this._observer && element) {
  14852. this.camera.getScene().onPointerObservable.remove(this._observer);
  14853. if (this._onMouseMove) {
  14854. element.removeEventListener("mousemove", this._onMouseMove);
  14855. }
  14856. if (this.onContextMenu) {
  14857. element.removeEventListener("contextmenu", this.onContextMenu);
  14858. }
  14859. if (this.onPointerMovedObservable) {
  14860. this.onPointerMovedObservable.clear();
  14861. }
  14862. this._observer = null;
  14863. this._onMouseMove = null;
  14864. this.previousPosition = null;
  14865. }
  14866. };
  14867. /**
  14868. * Gets the class name of the current intput.
  14869. * @returns the class name
  14870. */
  14871. FreeCameraMouseInput.prototype.getClassName = function () {
  14872. return "FreeCameraMouseInput";
  14873. };
  14874. /**
  14875. * Get the friendly name associated with the input class.
  14876. * @returns the input friendly name
  14877. */
  14878. FreeCameraMouseInput.prototype.getSimpleName = function () {
  14879. return "mouse";
  14880. };
  14881. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14882. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14883. ], FreeCameraMouseInput.prototype, "buttons", void 0);
  14884. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14885. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14886. ], FreeCameraMouseInput.prototype, "angularSensibility", void 0);
  14887. return FreeCameraMouseInput;
  14888. }());
  14889. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["CameraInputTypes"]["FreeCameraMouseInput"] = FreeCameraMouseInput;
  14890. /***/ }),
  14891. /***/ "./Cameras/Inputs/freeCameraTouchInput.ts":
  14892. /*!************************************************!*\
  14893. !*** ./Cameras/Inputs/freeCameraTouchInput.ts ***!
  14894. \************************************************/
  14895. /*! exports provided: FreeCameraTouchInput */
  14896. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14897. "use strict";
  14898. __webpack_require__.r(__webpack_exports__);
  14899. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return FreeCameraTouchInput; });
  14900. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14901. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14902. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14903. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14904. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14905. /**
  14906. * Manage the touch inputs to control the movement of a free camera.
  14907. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14908. */
  14909. var FreeCameraTouchInput = /** @class */ (function () {
  14910. function FreeCameraTouchInput() {
  14911. /**
  14912. * Defines the touch sensibility for rotation.
  14913. * The higher the faster.
  14914. */
  14915. this.touchAngularSensibility = 200000.0;
  14916. /**
  14917. * Defines the touch sensibility for move.
  14918. * The higher the faster.
  14919. */
  14920. this.touchMoveSensibility = 250.0;
  14921. this._offsetX = null;
  14922. this._offsetY = null;
  14923. this._pointerPressed = new Array();
  14924. }
  14925. /**
  14926. * Attach the input controls to a specific dom element to get the input from.
  14927. * @param element Defines the element the controls should be listened from
  14928. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14929. */
  14930. FreeCameraTouchInput.prototype.attachControl = function (element, noPreventDefault) {
  14931. var _this = this;
  14932. var previousPosition = null;
  14933. if (this._pointerInput === undefined) {
  14934. this._onLostFocus = function () {
  14935. _this._offsetX = null;
  14936. _this._offsetY = null;
  14937. };
  14938. this._pointerInput = function (p) {
  14939. var evt = p.event;
  14940. if (evt.pointerType === "mouse") {
  14941. return;
  14942. }
  14943. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN) {
  14944. if (!noPreventDefault) {
  14945. evt.preventDefault();
  14946. }
  14947. _this._pointerPressed.push(evt.pointerId);
  14948. if (_this._pointerPressed.length !== 1) {
  14949. return;
  14950. }
  14951. previousPosition = {
  14952. x: evt.clientX,
  14953. y: evt.clientY
  14954. };
  14955. }
  14956. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP) {
  14957. if (!noPreventDefault) {
  14958. evt.preventDefault();
  14959. }
  14960. var index = _this._pointerPressed.indexOf(evt.pointerId);
  14961. if (index === -1) {
  14962. return;
  14963. }
  14964. _this._pointerPressed.splice(index, 1);
  14965. if (index != 0) {
  14966. return;
  14967. }
  14968. previousPosition = null;
  14969. _this._offsetX = null;
  14970. _this._offsetY = null;
  14971. }
  14972. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  14973. if (!noPreventDefault) {
  14974. evt.preventDefault();
  14975. }
  14976. if (!previousPosition) {
  14977. return;
  14978. }
  14979. var index = _this._pointerPressed.indexOf(evt.pointerId);
  14980. if (index != 0) {
  14981. return;
  14982. }
  14983. _this._offsetX = evt.clientX - previousPosition.x;
  14984. _this._offsetY = -(evt.clientY - previousPosition.y);
  14985. }
  14986. };
  14987. }
  14988. 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);
  14989. if (this._onLostFocus) {
  14990. element.addEventListener("blur", this._onLostFocus);
  14991. }
  14992. };
  14993. /**
  14994. * Detach the current controls from the specified dom element.
  14995. * @param element Defines the element to stop listening the inputs from
  14996. */
  14997. FreeCameraTouchInput.prototype.detachControl = function (element) {
  14998. if (this._pointerInput && element) {
  14999. if (this._observer) {
  15000. this.camera.getScene().onPointerObservable.remove(this._observer);
  15001. this._observer = null;
  15002. }
  15003. if (this._onLostFocus) {
  15004. element.removeEventListener("blur", this._onLostFocus);
  15005. this._onLostFocus = null;
  15006. }
  15007. this._pointerPressed = [];
  15008. this._offsetX = null;
  15009. this._offsetY = null;
  15010. }
  15011. };
  15012. /**
  15013. * Update the current camera state depending on the inputs that have been used this frame.
  15014. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  15015. */
  15016. FreeCameraTouchInput.prototype.checkInputs = function () {
  15017. if (this._offsetX && this._offsetY) {
  15018. var camera = this.camera;
  15019. camera.cameraRotation.y += this._offsetX / this.touchAngularSensibility;
  15020. if (this._pointerPressed.length > 1) {
  15021. camera.cameraRotation.x += -this._offsetY / this.touchAngularSensibility;
  15022. }
  15023. else {
  15024. var speed = camera._computeLocalCameraSpeed();
  15025. var direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, speed * this._offsetY / this.touchMoveSensibility);
  15026. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, camera._cameraRotationMatrix);
  15027. camera.cameraDirection.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(direction, camera._cameraRotationMatrix));
  15028. }
  15029. }
  15030. };
  15031. /**
  15032. * Gets the class name of the current intput.
  15033. * @returns the class name
  15034. */
  15035. FreeCameraTouchInput.prototype.getClassName = function () {
  15036. return "FreeCameraTouchInput";
  15037. };
  15038. /**
  15039. * Get the friendly name associated with the input class.
  15040. * @returns the input friendly name
  15041. */
  15042. FreeCameraTouchInput.prototype.getSimpleName = function () {
  15043. return "touch";
  15044. };
  15045. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15046. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15047. ], FreeCameraTouchInput.prototype, "touchAngularSensibility", void 0);
  15048. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15049. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15050. ], FreeCameraTouchInput.prototype, "touchMoveSensibility", void 0);
  15051. return FreeCameraTouchInput;
  15052. }());
  15053. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraTouchInput"] = FreeCameraTouchInput;
  15054. /***/ }),
  15055. /***/ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts":
  15056. /*!**********************************************************!*\
  15057. !*** ./Cameras/Inputs/freeCameraVirtualJoystickInput.ts ***!
  15058. \**********************************************************/
  15059. /*! exports provided: FreeCameraVirtualJoystickInput */
  15060. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15061. "use strict";
  15062. __webpack_require__.r(__webpack_exports__);
  15063. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return FreeCameraVirtualJoystickInput; });
  15064. /* harmony import */ var _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/virtualJoystick */ "./Misc/virtualJoystick.ts");
  15065. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  15066. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15067. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  15068. /**
  15069. * Add virtual joystick input support to the input manager.
  15070. * @returns the current input manager
  15071. */
  15072. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addVirtualJoystick = function () {
  15073. this.add(new FreeCameraVirtualJoystickInput());
  15074. return this;
  15075. };
  15076. /**
  15077. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  15078. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  15079. */
  15080. var FreeCameraVirtualJoystickInput = /** @class */ (function () {
  15081. function FreeCameraVirtualJoystickInput() {
  15082. }
  15083. /**
  15084. * Gets the left stick of the virtual joystick.
  15085. * @returns The virtual Joystick
  15086. */
  15087. FreeCameraVirtualJoystickInput.prototype.getLeftJoystick = function () {
  15088. return this._leftjoystick;
  15089. };
  15090. /**
  15091. * Gets the right stick of the virtual joystick.
  15092. * @returns The virtual Joystick
  15093. */
  15094. FreeCameraVirtualJoystickInput.prototype.getRightJoystick = function () {
  15095. return this._rightjoystick;
  15096. };
  15097. /**
  15098. * Update the current camera state depending on the inputs that have been used this frame.
  15099. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  15100. */
  15101. FreeCameraVirtualJoystickInput.prototype.checkInputs = function () {
  15102. if (this._leftjoystick) {
  15103. var camera = this.camera;
  15104. var speed = camera._computeLocalCameraSpeed() * 50;
  15105. var cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, 0);
  15106. 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);
  15107. camera.cameraDirection = camera.cameraDirection.add(deltaTransform);
  15108. camera.cameraRotation = camera.cameraRotation.addVector3(this._rightjoystick.deltaPosition);
  15109. if (!this._leftjoystick.pressed) {
  15110. this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(0.9);
  15111. }
  15112. if (!this._rightjoystick.pressed) {
  15113. this._rightjoystick.deltaPosition = this._rightjoystick.deltaPosition.scale(0.9);
  15114. }
  15115. }
  15116. };
  15117. /**
  15118. * Attach the input controls to a specific dom element to get the input from.
  15119. * @param element Defines the element the controls should be listened from
  15120. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  15121. */
  15122. FreeCameraVirtualJoystickInput.prototype.attachControl = function (element, noPreventDefault) {
  15123. this._leftjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](true);
  15124. this._leftjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Z);
  15125. this._leftjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  15126. this._leftjoystick.setJoystickSensibility(0.15);
  15127. this._rightjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](false);
  15128. this._rightjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  15129. this._rightjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Y);
  15130. this._rightjoystick.reverseUpDown = true;
  15131. this._rightjoystick.setJoystickSensibility(0.05);
  15132. this._rightjoystick.setJoystickColor("yellow");
  15133. };
  15134. /**
  15135. * Detach the current controls from the specified dom element.
  15136. * @param element Defines the element to stop listening the inputs from
  15137. */
  15138. FreeCameraVirtualJoystickInput.prototype.detachControl = function (element) {
  15139. this._leftjoystick.releaseCanvas();
  15140. this._rightjoystick.releaseCanvas();
  15141. };
  15142. /**
  15143. * Gets the class name of the current intput.
  15144. * @returns the class name
  15145. */
  15146. FreeCameraVirtualJoystickInput.prototype.getClassName = function () {
  15147. return "FreeCameraVirtualJoystickInput";
  15148. };
  15149. /**
  15150. * Get the friendly name associated with the input class.
  15151. * @returns the input friendly name
  15152. */
  15153. FreeCameraVirtualJoystickInput.prototype.getSimpleName = function () {
  15154. return "virtualJoystick";
  15155. };
  15156. return FreeCameraVirtualJoystickInput;
  15157. }());
  15158. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FreeCameraVirtualJoystickInput"] = FreeCameraVirtualJoystickInput;
  15159. /***/ }),
  15160. /***/ "./Cameras/Inputs/index.ts":
  15161. /*!*********************************!*\
  15162. !*** ./Cameras/Inputs/index.ts ***!
  15163. \*********************************/
  15164. /*! exports provided: ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput */
  15165. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15166. "use strict";
  15167. __webpack_require__.r(__webpack_exports__);
  15168. /* harmony import */ var _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  15169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  15170. /* harmony import */ var _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  15171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraKeyboardMoveInput"]; });
  15172. /* harmony import */ var _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  15173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraMouseWheelInput"]; });
  15174. /* harmony import */ var _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  15175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraPointersInput"]; });
  15176. /* harmony import */ var _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  15177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__["ArcRotateCameraVRDeviceOrientationInput"]; });
  15178. /* harmony import */ var _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  15179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__["FlyCameraKeyboardInput"]; });
  15180. /* harmony import */ var _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  15181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__["FlyCameraMouseInput"]; });
  15182. /* harmony import */ var _followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  15183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_7__["FollowCameraKeyboardMoveInput"]; });
  15184. /* harmony import */ var _followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./followCameraMouseWheelInput */ "./Cameras/Inputs/followCameraMouseWheelInput.ts");
  15185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_8__["FollowCameraMouseWheelInput"]; });
  15186. /* harmony import */ var _followCameraPointersInput__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./followCameraPointersInput */ "./Cameras/Inputs/followCameraPointersInput.ts");
  15187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _followCameraPointersInput__WEBPACK_IMPORTED_MODULE_9__["FollowCameraPointersInput"]; });
  15188. /* harmony import */ var _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  15189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_10__["FreeCameraDeviceOrientationInput"]; });
  15190. /* harmony import */ var _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  15191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_11__["FreeCameraGamepadInput"]; });
  15192. /* harmony import */ var _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  15193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_12__["FreeCameraKeyboardMoveInput"]; });
  15194. /* harmony import */ var _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  15195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_13__["FreeCameraMouseInput"]; });
  15196. /* harmony import */ var _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  15197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_14__["FreeCameraTouchInput"]; });
  15198. /* harmony import */ var _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  15199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_15__["FreeCameraVirtualJoystickInput"]; });
  15200. /***/ }),
  15201. /***/ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts":
  15202. /*!*********************************************************!*\
  15203. !*** ./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts ***!
  15204. \*********************************************************/
  15205. /*! no exports provided */
  15206. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15207. "use strict";
  15208. __webpack_require__.r(__webpack_exports__);
  15209. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15210. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  15211. /* harmony import */ var _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  15212. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicAnaglyphRigMode = function (camera) {
  15213. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  15214. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__["AnaglyphPostProcess"](camera.name + "_anaglyph", 1.0, camera._rigCameras);
  15215. };
  15216. /***/ }),
  15217. /***/ "./Cameras/RigModes/stereoscopicRigMode.ts":
  15218. /*!*************************************************!*\
  15219. !*** ./Cameras/RigModes/stereoscopicRigMode.ts ***!
  15220. \*************************************************/
  15221. /*! no exports provided */
  15222. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15223. "use strict";
  15224. __webpack_require__.r(__webpack_exports__);
  15225. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15226. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  15227. /* harmony import */ var _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  15228. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicRigMode = function (camera) {
  15229. 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;
  15230. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  15231. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__["StereoscopicInterlacePostProcess"](camera.name + "_stereoInterlace", camera._rigCameras, isStereoscopicHoriz);
  15232. };
  15233. /***/ }),
  15234. /***/ "./Cameras/RigModes/vrRigMode.ts":
  15235. /*!***************************************!*\
  15236. !*** ./Cameras/RigModes/vrRigMode.ts ***!
  15237. \***************************************/
  15238. /*! no exports provided */
  15239. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15240. "use strict";
  15241. __webpack_require__.r(__webpack_exports__);
  15242. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15243. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15244. /* harmony import */ var _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  15245. /* harmony import */ var _PostProcesses_vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../PostProcesses/vrMultiviewToSingleviewPostProcess */ "./PostProcesses/vrMultiviewToSingleviewPostProcess.ts");
  15246. /* harmony import */ var _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../VR/vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15247. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  15248. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setVRRigMode = function (camera, rigParams) {
  15249. var metrics = rigParams.vrCameraMetrics || _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_4__["VRCameraMetrics"].GetDefault();
  15250. camera._rigCameras[0]._cameraRigParams.vrMetrics = metrics;
  15251. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  15252. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15253. camera._rigCameras[0]._cameraRigParams.vrHMatrix = metrics.leftHMatrix;
  15254. camera._rigCameras[0]._cameraRigParams.vrPreViewMatrix = metrics.leftPreViewMatrix;
  15255. camera._rigCameras[0].getProjectionMatrix = camera._rigCameras[0]._getVRProjectionMatrix;
  15256. camera._rigCameras[1]._cameraRigParams.vrMetrics = metrics;
  15257. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  15258. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15259. camera._rigCameras[1]._cameraRigParams.vrHMatrix = metrics.rightHMatrix;
  15260. camera._rigCameras[1]._cameraRigParams.vrPreViewMatrix = metrics.rightPreViewMatrix;
  15261. camera._rigCameras[1].getProjectionMatrix = camera._rigCameras[1]._getVRProjectionMatrix;
  15262. // For multiview on a webVR camera
  15263. // First multiview will be rendered to camera._multiviewTexture
  15264. // Then this postprocess will run on each eye to copy the right texture to each eye
  15265. if (metrics.multiviewEnabled) {
  15266. if (!camera.getScene().getEngine().getCaps().multiview) {
  15267. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Warn("Multiview is not supported, falling back to standard rendering");
  15268. metrics.multiviewEnabled = false;
  15269. }
  15270. else {
  15271. camera._useMultiviewToSingleView = true;
  15272. camera._rigPostProcess = new _PostProcesses_vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_3__["VRMultiviewToSingleviewPostProcess"]("VRMultiviewToSingleview", camera, metrics.postProcessScaleFactor);
  15273. }
  15274. }
  15275. if (metrics.compensateDistortion) {
  15276. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Left", camera._rigCameras[0], false, metrics);
  15277. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Right", camera._rigCameras[1], true, metrics);
  15278. }
  15279. };
  15280. /***/ }),
  15281. /***/ "./Cameras/RigModes/webVRRigMode.ts":
  15282. /*!******************************************!*\
  15283. !*** ./Cameras/RigModes/webVRRigMode.ts ***!
  15284. \******************************************/
  15285. /*! no exports provided */
  15286. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15287. "use strict";
  15288. __webpack_require__.r(__webpack_exports__);
  15289. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15290. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15291. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setWebVRRigMode = function (camera, rigParams) {
  15292. if (rigParams.vrDisplay) {
  15293. var leftEye = rigParams.vrDisplay.getEyeParameters('left');
  15294. var rightEye = rigParams.vrDisplay.getEyeParameters('right');
  15295. //Left eye
  15296. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  15297. camera._rigCameras[0].setCameraRigParameter("left", true);
  15298. //leaving this for future reference
  15299. camera._rigCameras[0].setCameraRigParameter("specs", rigParams.specs);
  15300. camera._rigCameras[0].setCameraRigParameter("eyeParameters", leftEye);
  15301. camera._rigCameras[0].setCameraRigParameter("frameData", rigParams.frameData);
  15302. camera._rigCameras[0].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  15303. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15304. camera._rigCameras[0].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  15305. camera._rigCameras[0].parent = camera;
  15306. camera._rigCameras[0]._getViewMatrix = camera._getWebVRViewMatrix;
  15307. //Right eye
  15308. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  15309. camera._rigCameras[1].setCameraRigParameter('eyeParameters', rightEye);
  15310. camera._rigCameras[1].setCameraRigParameter("specs", rigParams.specs);
  15311. camera._rigCameras[1].setCameraRigParameter("frameData", rigParams.frameData);
  15312. camera._rigCameras[1].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  15313. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15314. camera._rigCameras[1].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  15315. camera._rigCameras[1].parent = camera;
  15316. camera._rigCameras[1]._getViewMatrix = camera._getWebVRViewMatrix;
  15317. }
  15318. };
  15319. /***/ }),
  15320. /***/ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts":
  15321. /*!*********************************************************!*\
  15322. !*** ./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts ***!
  15323. \*********************************************************/
  15324. /*! exports provided: AnaglyphArcRotateCamera */
  15325. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15326. "use strict";
  15327. __webpack_require__.r(__webpack_exports__);
  15328. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return AnaglyphArcRotateCamera; });
  15329. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15330. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15331. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15332. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15333. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15334. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15335. // Side effect import to define the stereoscopic mode.
  15336. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphArcRotateCamera", function (name, scene, options) {
  15337. return function () { return new AnaglyphArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15338. });
  15339. /**
  15340. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  15341. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15342. */
  15343. var AnaglyphArcRotateCamera = /** @class */ (function (_super) {
  15344. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphArcRotateCamera, _super);
  15345. /**
  15346. * Creates a new AnaglyphArcRotateCamera
  15347. * @param name defines camera name
  15348. * @param alpha defines alpha angle (in radians)
  15349. * @param beta defines beta angle (in radians)
  15350. * @param radius defines radius
  15351. * @param target defines camera target
  15352. * @param interaxialDistance defines distance between each color axis
  15353. * @param scene defines the hosting scene
  15354. */
  15355. function AnaglyphArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, scene) {
  15356. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15357. _this.interaxialDistance = interaxialDistance;
  15358. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15359. return _this;
  15360. }
  15361. /**
  15362. * Gets camera class name
  15363. * @returns AnaglyphArcRotateCamera
  15364. */
  15365. AnaglyphArcRotateCamera.prototype.getClassName = function () {
  15366. return "AnaglyphArcRotateCamera";
  15367. };
  15368. return AnaglyphArcRotateCamera;
  15369. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15370. /***/ }),
  15371. /***/ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts":
  15372. /*!****************************************************!*\
  15373. !*** ./Cameras/Stereoscopic/anaglyphFreeCamera.ts ***!
  15374. \****************************************************/
  15375. /*! exports provided: AnaglyphFreeCamera */
  15376. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15377. "use strict";
  15378. __webpack_require__.r(__webpack_exports__);
  15379. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return AnaglyphFreeCamera; });
  15380. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15381. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15382. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15383. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15384. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15385. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15386. // Side effect import to define the stereoscopic mode.
  15387. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphFreeCamera", function (name, scene, options) {
  15388. return function () { return new AnaglyphFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15389. });
  15390. /**
  15391. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  15392. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15393. */
  15394. var AnaglyphFreeCamera = /** @class */ (function (_super) {
  15395. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphFreeCamera, _super);
  15396. /**
  15397. * Creates a new AnaglyphFreeCamera
  15398. * @param name defines camera name
  15399. * @param position defines initial position
  15400. * @param interaxialDistance defines distance between each color axis
  15401. * @param scene defines the hosting scene
  15402. */
  15403. function AnaglyphFreeCamera(name, position, interaxialDistance, scene) {
  15404. var _this = _super.call(this, name, position, scene) || this;
  15405. _this.interaxialDistance = interaxialDistance;
  15406. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15407. return _this;
  15408. }
  15409. /**
  15410. * Gets camera class name
  15411. * @returns AnaglyphFreeCamera
  15412. */
  15413. AnaglyphFreeCamera.prototype.getClassName = function () {
  15414. return "AnaglyphFreeCamera";
  15415. };
  15416. return AnaglyphFreeCamera;
  15417. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  15418. /***/ }),
  15419. /***/ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts":
  15420. /*!*******************************************************!*\
  15421. !*** ./Cameras/Stereoscopic/anaglyphGamepadCamera.ts ***!
  15422. \*******************************************************/
  15423. /*! exports provided: AnaglyphGamepadCamera */
  15424. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15425. "use strict";
  15426. __webpack_require__.r(__webpack_exports__);
  15427. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return AnaglyphGamepadCamera; });
  15428. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15429. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15430. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  15431. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15432. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15433. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15434. // Side effect import to define the stereoscopic mode.
  15435. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphGamepadCamera", function (name, scene, options) {
  15436. return function () { return new AnaglyphGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15437. });
  15438. /**
  15439. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  15440. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15441. */
  15442. var AnaglyphGamepadCamera = /** @class */ (function (_super) {
  15443. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphGamepadCamera, _super);
  15444. /**
  15445. * Creates a new AnaglyphGamepadCamera
  15446. * @param name defines camera name
  15447. * @param position defines initial position
  15448. * @param interaxialDistance defines distance between each color axis
  15449. * @param scene defines the hosting scene
  15450. */
  15451. function AnaglyphGamepadCamera(name, position, interaxialDistance, scene) {
  15452. var _this = _super.call(this, name, position, scene) || this;
  15453. _this.interaxialDistance = interaxialDistance;
  15454. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15455. return _this;
  15456. }
  15457. /**
  15458. * Gets camera class name
  15459. * @returns AnaglyphGamepadCamera
  15460. */
  15461. AnaglyphGamepadCamera.prototype.getClassName = function () {
  15462. return "AnaglyphGamepadCamera";
  15463. };
  15464. return AnaglyphGamepadCamera;
  15465. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15466. /***/ }),
  15467. /***/ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts":
  15468. /*!*********************************************************!*\
  15469. !*** ./Cameras/Stereoscopic/anaglyphUniversalCamera.ts ***!
  15470. \*********************************************************/
  15471. /*! exports provided: AnaglyphUniversalCamera */
  15472. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15473. "use strict";
  15474. __webpack_require__.r(__webpack_exports__);
  15475. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return AnaglyphUniversalCamera; });
  15476. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15477. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15478. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15479. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15480. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15481. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15482. // Side effect import to define the stereoscopic mode.
  15483. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphUniversalCamera", function (name, scene, options) {
  15484. return function () { return new AnaglyphUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15485. });
  15486. /**
  15487. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  15488. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15489. */
  15490. var AnaglyphUniversalCamera = /** @class */ (function (_super) {
  15491. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphUniversalCamera, _super);
  15492. /**
  15493. * Creates a new AnaglyphUniversalCamera
  15494. * @param name defines camera name
  15495. * @param position defines initial position
  15496. * @param interaxialDistance defines distance between each color axis
  15497. * @param scene defines the hosting scene
  15498. */
  15499. function AnaglyphUniversalCamera(name, position, interaxialDistance, scene) {
  15500. var _this = _super.call(this, name, position, scene) || this;
  15501. _this.interaxialDistance = interaxialDistance;
  15502. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15503. return _this;
  15504. }
  15505. /**
  15506. * Gets camera class name
  15507. * @returns AnaglyphUniversalCamera
  15508. */
  15509. AnaglyphUniversalCamera.prototype.getClassName = function () {
  15510. return "AnaglyphUniversalCamera";
  15511. };
  15512. return AnaglyphUniversalCamera;
  15513. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15514. /***/ }),
  15515. /***/ "./Cameras/Stereoscopic/index.ts":
  15516. /*!***************************************!*\
  15517. !*** ./Cameras/Stereoscopic/index.ts ***!
  15518. \***************************************/
  15519. /*! exports provided: AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera */
  15520. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15521. "use strict";
  15522. __webpack_require__.r(__webpack_exports__);
  15523. /* harmony import */ var _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphArcRotateCamera */ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts");
  15524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  15525. /* harmony import */ var _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./anaglyphFreeCamera */ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts");
  15526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__["AnaglyphFreeCamera"]; });
  15527. /* harmony import */ var _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./anaglyphGamepadCamera */ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts");
  15528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__["AnaglyphGamepadCamera"]; });
  15529. /* harmony import */ var _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./anaglyphUniversalCamera */ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts");
  15530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__["AnaglyphUniversalCamera"]; });
  15531. /* harmony import */ var _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./stereoscopicArcRotateCamera */ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts");
  15532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__["StereoscopicArcRotateCamera"]; });
  15533. /* harmony import */ var _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./stereoscopicFreeCamera */ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts");
  15534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__["StereoscopicFreeCamera"]; });
  15535. /* harmony import */ var _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./stereoscopicGamepadCamera */ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts");
  15536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__["StereoscopicGamepadCamera"]; });
  15537. /* harmony import */ var _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./stereoscopicUniversalCamera */ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts");
  15538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  15539. /***/ }),
  15540. /***/ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts":
  15541. /*!*************************************************************!*\
  15542. !*** ./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts ***!
  15543. \*************************************************************/
  15544. /*! exports provided: StereoscopicArcRotateCamera */
  15545. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15546. "use strict";
  15547. __webpack_require__.r(__webpack_exports__);
  15548. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return StereoscopicArcRotateCamera; });
  15549. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15550. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15551. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15552. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15553. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15554. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15555. // Side effect import to define the stereoscopic mode.
  15556. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicArcRotateCamera", function (name, scene, options) {
  15557. return function () { return new StereoscopicArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15558. });
  15559. /**
  15560. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  15561. * @see http://doc.babylonjs.com/features/cameras
  15562. */
  15563. var StereoscopicArcRotateCamera = /** @class */ (function (_super) {
  15564. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicArcRotateCamera, _super);
  15565. /**
  15566. * Creates a new StereoscopicArcRotateCamera
  15567. * @param name defines camera name
  15568. * @param alpha defines alpha angle (in radians)
  15569. * @param beta defines beta angle (in radians)
  15570. * @param radius defines radius
  15571. * @param target defines camera target
  15572. * @param interaxialDistance defines distance between each color axis
  15573. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15574. * @param scene defines the hosting scene
  15575. */
  15576. function StereoscopicArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, isStereoscopicSideBySide, scene) {
  15577. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15578. _this.interaxialDistance = interaxialDistance;
  15579. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15580. _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 });
  15581. return _this;
  15582. }
  15583. /**
  15584. * Gets camera class name
  15585. * @returns StereoscopicArcRotateCamera
  15586. */
  15587. StereoscopicArcRotateCamera.prototype.getClassName = function () {
  15588. return "StereoscopicArcRotateCamera";
  15589. };
  15590. return StereoscopicArcRotateCamera;
  15591. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15592. /***/ }),
  15593. /***/ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts":
  15594. /*!********************************************************!*\
  15595. !*** ./Cameras/Stereoscopic/stereoscopicFreeCamera.ts ***!
  15596. \********************************************************/
  15597. /*! exports provided: StereoscopicFreeCamera */
  15598. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15599. "use strict";
  15600. __webpack_require__.r(__webpack_exports__);
  15601. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return StereoscopicFreeCamera; });
  15602. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15603. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15604. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15605. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15606. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15607. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15608. // Side effect import to define the stereoscopic mode.
  15609. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15610. return function () { return new StereoscopicFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15611. });
  15612. /**
  15613. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  15614. * @see http://doc.babylonjs.com/features/cameras
  15615. */
  15616. var StereoscopicFreeCamera = /** @class */ (function (_super) {
  15617. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicFreeCamera, _super);
  15618. /**
  15619. * Creates a new StereoscopicFreeCamera
  15620. * @param name defines camera name
  15621. * @param position defines initial position
  15622. * @param interaxialDistance defines distance between each color axis
  15623. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15624. * @param scene defines the hosting scene
  15625. */
  15626. function StereoscopicFreeCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15627. var _this = _super.call(this, name, position, scene) || this;
  15628. _this.interaxialDistance = interaxialDistance;
  15629. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15630. _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 });
  15631. return _this;
  15632. }
  15633. /**
  15634. * Gets camera class name
  15635. * @returns StereoscopicFreeCamera
  15636. */
  15637. StereoscopicFreeCamera.prototype.getClassName = function () {
  15638. return "StereoscopicFreeCamera";
  15639. };
  15640. return StereoscopicFreeCamera;
  15641. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  15642. /***/ }),
  15643. /***/ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts":
  15644. /*!***********************************************************!*\
  15645. !*** ./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts ***!
  15646. \***********************************************************/
  15647. /*! exports provided: StereoscopicGamepadCamera */
  15648. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15649. "use strict";
  15650. __webpack_require__.r(__webpack_exports__);
  15651. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return StereoscopicGamepadCamera; });
  15652. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15653. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15654. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  15655. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15656. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15657. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15658. // Side effect import to define the stereoscopic mode.
  15659. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicGamepadCamera", function (name, scene, options) {
  15660. return function () { return new StereoscopicGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15661. });
  15662. /**
  15663. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  15664. * @see http://doc.babylonjs.com/features/cameras
  15665. */
  15666. var StereoscopicGamepadCamera = /** @class */ (function (_super) {
  15667. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicGamepadCamera, _super);
  15668. /**
  15669. * Creates a new StereoscopicGamepadCamera
  15670. * @param name defines camera name
  15671. * @param position defines initial position
  15672. * @param interaxialDistance defines distance between each color axis
  15673. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15674. * @param scene defines the hosting scene
  15675. */
  15676. function StereoscopicGamepadCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15677. var _this = _super.call(this, name, position, scene) || this;
  15678. _this.interaxialDistance = interaxialDistance;
  15679. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15680. _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 });
  15681. return _this;
  15682. }
  15683. /**
  15684. * Gets camera class name
  15685. * @returns StereoscopicGamepadCamera
  15686. */
  15687. StereoscopicGamepadCamera.prototype.getClassName = function () {
  15688. return "StereoscopicGamepadCamera";
  15689. };
  15690. return StereoscopicGamepadCamera;
  15691. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15692. /***/ }),
  15693. /***/ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts":
  15694. /*!*************************************************************!*\
  15695. !*** ./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts ***!
  15696. \*************************************************************/
  15697. /*! exports provided: StereoscopicUniversalCamera */
  15698. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15699. "use strict";
  15700. __webpack_require__.r(__webpack_exports__);
  15701. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return StereoscopicUniversalCamera; });
  15702. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15703. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15704. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15705. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15706. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15707. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15708. // Side effect import to define the stereoscopic mode.
  15709. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15710. return function () { return new StereoscopicUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15711. });
  15712. /**
  15713. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  15714. * @see http://doc.babylonjs.com/features/cameras
  15715. */
  15716. var StereoscopicUniversalCamera = /** @class */ (function (_super) {
  15717. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicUniversalCamera, _super);
  15718. /**
  15719. * Creates a new StereoscopicUniversalCamera
  15720. * @param name defines camera name
  15721. * @param position defines initial position
  15722. * @param interaxialDistance defines distance between each color axis
  15723. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15724. * @param scene defines the hosting scene
  15725. */
  15726. function StereoscopicUniversalCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15727. var _this = _super.call(this, name, position, scene) || this;
  15728. _this.interaxialDistance = interaxialDistance;
  15729. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15730. _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 });
  15731. return _this;
  15732. }
  15733. /**
  15734. * Gets camera class name
  15735. * @returns StereoscopicUniversalCamera
  15736. */
  15737. StereoscopicUniversalCamera.prototype.getClassName = function () {
  15738. return "StereoscopicUniversalCamera";
  15739. };
  15740. return StereoscopicUniversalCamera;
  15741. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15742. /***/ }),
  15743. /***/ "./Cameras/VR/index.ts":
  15744. /*!*****************************!*\
  15745. !*** ./Cameras/VR/index.ts ***!
  15746. \*****************************/
  15747. /*! exports provided: VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera */
  15748. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15749. "use strict";
  15750. __webpack_require__.r(__webpack_exports__);
  15751. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  15753. /* harmony import */ var _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationArcRotateCamera */ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts");
  15754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationArcRotateCamera"]; });
  15755. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__["VRDeviceOrientationFreeCamera"]; });
  15757. /* harmony import */ var _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrDeviceOrientationGamepadCamera */ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts");
  15758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__["VRDeviceOrientationGamepadCamera"]; });
  15759. /* harmony import */ var _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  15760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["OnAfterEnteringVRObservableEvent"]; });
  15761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["VRExperienceHelper"]; });
  15762. /* harmony import */ var _webVRCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  15763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _webVRCamera__WEBPACK_IMPORTED_MODULE_5__["WebVRFreeCamera"]; });
  15764. /***/ }),
  15765. /***/ "./Cameras/VR/vrCameraMetrics.ts":
  15766. /*!***************************************!*\
  15767. !*** ./Cameras/VR/vrCameraMetrics.ts ***!
  15768. \***************************************/
  15769. /*! exports provided: VRCameraMetrics */
  15770. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15771. "use strict";
  15772. __webpack_require__.r(__webpack_exports__);
  15773. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return VRCameraMetrics; });
  15774. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15775. /**
  15776. * This represents all the required metrics to create a VR camera.
  15777. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  15778. */
  15779. var VRCameraMetrics = /** @class */ (function () {
  15780. function VRCameraMetrics() {
  15781. /**
  15782. * Define if the current vr camera should compensate the distortion of the lense or not.
  15783. */
  15784. this.compensateDistortion = true;
  15785. /**
  15786. * Defines if multiview should be enabled when rendering (Default: false)
  15787. */
  15788. this.multiviewEnabled = false;
  15789. }
  15790. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatio", {
  15791. /**
  15792. * Gets the rendering aspect ratio based on the provided resolutions.
  15793. */
  15794. get: function () {
  15795. return this.hResolution / (2 * this.vResolution);
  15796. },
  15797. enumerable: true,
  15798. configurable: true
  15799. });
  15800. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatioFov", {
  15801. /**
  15802. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  15803. */
  15804. get: function () {
  15805. return (2 * Math.atan((this.postProcessScaleFactor * this.vScreenSize) / (2 * this.eyeToScreenDistance)));
  15806. },
  15807. enumerable: true,
  15808. configurable: true
  15809. });
  15810. Object.defineProperty(VRCameraMetrics.prototype, "leftHMatrix", {
  15811. /**
  15812. * @hidden
  15813. */
  15814. get: function () {
  15815. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15816. var h = (4 * meters) / this.hScreenSize;
  15817. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(h, 0, 0);
  15818. },
  15819. enumerable: true,
  15820. configurable: true
  15821. });
  15822. Object.defineProperty(VRCameraMetrics.prototype, "rightHMatrix", {
  15823. /**
  15824. * @hidden
  15825. */
  15826. get: function () {
  15827. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15828. var h = (4 * meters) / this.hScreenSize;
  15829. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-h, 0, 0);
  15830. },
  15831. enumerable: true,
  15832. configurable: true
  15833. });
  15834. Object.defineProperty(VRCameraMetrics.prototype, "leftPreViewMatrix", {
  15835. /**
  15836. * @hidden
  15837. */
  15838. get: function () {
  15839. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(0.5 * this.interpupillaryDistance, 0, 0);
  15840. },
  15841. enumerable: true,
  15842. configurable: true
  15843. });
  15844. Object.defineProperty(VRCameraMetrics.prototype, "rightPreViewMatrix", {
  15845. /**
  15846. * @hidden
  15847. */
  15848. get: function () {
  15849. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-0.5 * this.interpupillaryDistance, 0, 0);
  15850. },
  15851. enumerable: true,
  15852. configurable: true
  15853. });
  15854. /**
  15855. * Get the default VRMetrics based on the most generic setup.
  15856. * @returns the default vr metrics
  15857. */
  15858. VRCameraMetrics.GetDefault = function () {
  15859. var result = new VRCameraMetrics();
  15860. result.hResolution = 1280;
  15861. result.vResolution = 800;
  15862. result.hScreenSize = 0.149759993;
  15863. result.vScreenSize = 0.0935999975;
  15864. result.vScreenCenter = 0.0467999987;
  15865. result.eyeToScreenDistance = 0.0410000011;
  15866. result.lensSeparationDistance = 0.0635000020;
  15867. result.interpupillaryDistance = 0.0640000030;
  15868. result.distortionK = [1.0, 0.219999999, 0.239999995, 0.0];
  15869. result.chromaAbCorrection = [0.995999992, -0.00400000019, 1.01400006, 0.0];
  15870. result.postProcessScaleFactor = 1.714605507808412;
  15871. result.lensCenterOffset = 0.151976421;
  15872. return result;
  15873. };
  15874. return VRCameraMetrics;
  15875. }());
  15876. /***/ }),
  15877. /***/ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts":
  15878. /*!**********************************************************!*\
  15879. !*** ./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts ***!
  15880. \**********************************************************/
  15881. /*! exports provided: VRDeviceOrientationArcRotateCamera */
  15882. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15883. "use strict";
  15884. __webpack_require__.r(__webpack_exports__);
  15885. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return VRDeviceOrientationArcRotateCamera; });
  15886. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15887. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15888. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15889. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15890. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15891. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15892. /* harmony import */ var _Inputs_arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Inputs/arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  15893. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15894. // Side effect import to define the stereoscopic mode.
  15895. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15896. return function () { return new VRDeviceOrientationArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15897. });
  15898. /**
  15899. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  15900. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15901. */
  15902. var VRDeviceOrientationArcRotateCamera = /** @class */ (function (_super) {
  15903. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationArcRotateCamera, _super);
  15904. /**
  15905. * Creates a new VRDeviceOrientationArcRotateCamera
  15906. * @param name defines camera name
  15907. * @param alpha defines the camera rotation along the logitudinal axis
  15908. * @param beta defines the camera rotation along the latitudinal axis
  15909. * @param radius defines the camera distance from its target
  15910. * @param target defines the camera target
  15911. * @param scene defines the scene the camera belongs to
  15912. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15913. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15914. */
  15915. function VRDeviceOrientationArcRotateCamera(name, alpha, beta, radius, target, scene, compensateDistortion, vrCameraMetrics) {
  15916. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15917. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  15918. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15919. vrCameraMetrics.compensateDistortion = compensateDistortion;
  15920. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  15921. _this.inputs.addVRDeviceOrientation();
  15922. return _this;
  15923. }
  15924. /**
  15925. * Gets camera class name
  15926. * @returns VRDeviceOrientationArcRotateCamera
  15927. */
  15928. VRDeviceOrientationArcRotateCamera.prototype.getClassName = function () {
  15929. return "VRDeviceOrientationArcRotateCamera";
  15930. };
  15931. return VRDeviceOrientationArcRotateCamera;
  15932. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15933. /***/ }),
  15934. /***/ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts":
  15935. /*!*****************************************************!*\
  15936. !*** ./Cameras/VR/vrDeviceOrientationFreeCamera.ts ***!
  15937. \*****************************************************/
  15938. /*! exports provided: VRDeviceOrientationFreeCamera */
  15939. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15940. "use strict";
  15941. __webpack_require__.r(__webpack_exports__);
  15942. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return VRDeviceOrientationFreeCamera; });
  15943. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15944. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15945. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  15946. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15947. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15948. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15949. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15950. // Side effect import to define the stereoscopic mode.
  15951. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15952. return function () { return new VRDeviceOrientationFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15953. });
  15954. /**
  15955. * Camera used to simulate VR rendering (based on FreeCamera)
  15956. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15957. */
  15958. var VRDeviceOrientationFreeCamera = /** @class */ (function (_super) {
  15959. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationFreeCamera, _super);
  15960. /**
  15961. * Creates a new VRDeviceOrientationFreeCamera
  15962. * @param name defines camera name
  15963. * @param position defines the start position of the camera
  15964. * @param scene defines the scene the camera belongs to
  15965. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15966. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15967. */
  15968. function VRDeviceOrientationFreeCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  15969. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15970. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  15971. var _this = _super.call(this, name, position, scene) || this;
  15972. vrCameraMetrics.compensateDistortion = compensateDistortion;
  15973. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  15974. return _this;
  15975. }
  15976. /**
  15977. * Gets camera class name
  15978. * @returns VRDeviceOrientationFreeCamera
  15979. */
  15980. VRDeviceOrientationFreeCamera.prototype.getClassName = function () {
  15981. return "VRDeviceOrientationFreeCamera";
  15982. };
  15983. return VRDeviceOrientationFreeCamera;
  15984. }(_Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__["DeviceOrientationCamera"]));
  15985. /***/ }),
  15986. /***/ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts":
  15987. /*!********************************************************!*\
  15988. !*** ./Cameras/VR/vrDeviceOrientationGamepadCamera.ts ***!
  15989. \********************************************************/
  15990. /*! exports provided: VRDeviceOrientationGamepadCamera */
  15991. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15992. "use strict";
  15993. __webpack_require__.r(__webpack_exports__);
  15994. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return VRDeviceOrientationGamepadCamera; });
  15995. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15996. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15997. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15998. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15999. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  16000. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("VRDeviceOrientationGamepadCamera", function (name, scene) {
  16001. return function () { return new VRDeviceOrientationGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  16002. });
  16003. /**
  16004. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  16005. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  16006. */
  16007. var VRDeviceOrientationGamepadCamera = /** @class */ (function (_super) {
  16008. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationGamepadCamera, _super);
  16009. /**
  16010. * Creates a new VRDeviceOrientationGamepadCamera
  16011. * @param name defines camera name
  16012. * @param position defines the start position of the camera
  16013. * @param scene defines the scene the camera belongs to
  16014. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  16015. * @param vrCameraMetrics defines the vr metrics associated to the camera
  16016. */
  16017. function VRDeviceOrientationGamepadCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  16018. if (compensateDistortion === void 0) { compensateDistortion = true; }
  16019. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__["VRCameraMetrics"].GetDefault(); }
  16020. var _this = _super.call(this, name, position, scene, compensateDistortion, vrCameraMetrics) || this;
  16021. _this.inputs.addGamepad();
  16022. return _this;
  16023. }
  16024. /**
  16025. * Gets camera class name
  16026. * @returns VRDeviceOrientationGamepadCamera
  16027. */
  16028. VRDeviceOrientationGamepadCamera.prototype.getClassName = function () {
  16029. return "VRDeviceOrientationGamepadCamera";
  16030. };
  16031. return VRDeviceOrientationGamepadCamera;
  16032. }(_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationFreeCamera"]));
  16033. /***/ }),
  16034. /***/ "./Cameras/VR/vrExperienceHelper.ts":
  16035. /*!******************************************!*\
  16036. !*** ./Cameras/VR/vrExperienceHelper.ts ***!
  16037. \******************************************/
  16038. /*! exports provided: OnAfterEnteringVRObservableEvent, VRExperienceHelper */
  16039. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16040. "use strict";
  16041. __webpack_require__.r(__webpack_exports__);
  16042. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return OnAfterEnteringVRObservableEvent; });
  16043. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return VRExperienceHelper; });
  16044. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  16045. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  16046. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  16047. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  16048. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  16049. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  16050. /* harmony import */ var _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Cameras/VR/vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  16051. /* harmony import */ var _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Cameras/VR/webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  16052. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  16053. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  16054. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  16055. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  16056. /* harmony import */ var _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Gamepads/Controllers/webVRController */ "./Gamepads/Controllers/webVRController.ts");
  16057. /* harmony import */ var _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Gamepads/xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  16058. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  16059. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  16060. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  16061. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  16062. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  16063. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  16064. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  16065. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  16066. /* harmony import */ var _Cameras_VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Cameras/VR/vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  16067. /* harmony import */ var _Meshes_Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../../Meshes/Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  16068. /* harmony import */ var _Meshes_Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../../Meshes/Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  16069. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ../../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  16070. /* harmony import */ var _Gamepads_gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../../Gamepads/gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  16071. /* harmony import */ var _Animations_animatable__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ../../Animations/animatable */ "./Animations/animatable.ts");
  16072. var VRExperienceHelperGazer = /** @class */ (function () {
  16073. function VRExperienceHelperGazer(scene, gazeTrackerToClone) {
  16074. if (gazeTrackerToClone === void 0) { gazeTrackerToClone = null; }
  16075. this.scene = scene;
  16076. /** @hidden */
  16077. this._pointerDownOnMeshAsked = false;
  16078. /** @hidden */
  16079. this._isActionableMesh = false;
  16080. /** @hidden */
  16081. this._teleportationRequestInitiated = false;
  16082. /** @hidden */
  16083. this._teleportationBackRequestInitiated = false;
  16084. /** @hidden */
  16085. this._rotationRightAsked = false;
  16086. /** @hidden */
  16087. this._rotationLeftAsked = false;
  16088. /** @hidden */
  16089. this._dpadPressed = true;
  16090. /** @hidden */
  16091. this._activePointer = false;
  16092. this._id = VRExperienceHelperGazer._idCounter++;
  16093. // Gaze tracker
  16094. if (!gazeTrackerToClone) {
  16095. this._gazeTracker = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("gazeTracker", 0.0035, 0.0025, 20, scene, false);
  16096. this._gazeTracker.bakeCurrentTransformIntoVertices();
  16097. this._gazeTracker.isPickable = false;
  16098. this._gazeTracker.isVisible = false;
  16099. var targetMat = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("targetMat", scene);
  16100. targetMat.specularColor = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"].Black();
  16101. targetMat.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  16102. targetMat.backFaceCulling = false;
  16103. this._gazeTracker.material = targetMat;
  16104. }
  16105. else {
  16106. this._gazeTracker = gazeTrackerToClone.clone("gazeTracker");
  16107. }
  16108. }
  16109. /** @hidden */
  16110. VRExperienceHelperGazer.prototype._getForwardRay = function (length) {
  16111. 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));
  16112. };
  16113. /** @hidden */
  16114. VRExperienceHelperGazer.prototype._selectionPointerDown = function () {
  16115. this._pointerDownOnMeshAsked = true;
  16116. if (this._currentHit) {
  16117. this.scene.simulatePointerDown(this._currentHit, { pointerId: this._id });
  16118. }
  16119. };
  16120. /** @hidden */
  16121. VRExperienceHelperGazer.prototype._selectionPointerUp = function () {
  16122. if (this._currentHit) {
  16123. this.scene.simulatePointerUp(this._currentHit, { pointerId: this._id });
  16124. }
  16125. this._pointerDownOnMeshAsked = false;
  16126. };
  16127. /** @hidden */
  16128. VRExperienceHelperGazer.prototype._activatePointer = function () {
  16129. this._activePointer = true;
  16130. };
  16131. /** @hidden */
  16132. VRExperienceHelperGazer.prototype._deactivatePointer = function () {
  16133. this._activePointer = false;
  16134. };
  16135. /** @hidden */
  16136. VRExperienceHelperGazer.prototype._updatePointerDistance = function (distance) {
  16137. if (distance === void 0) { distance = 100; }
  16138. };
  16139. VRExperienceHelperGazer.prototype.dispose = function () {
  16140. this._interactionsEnabled = false;
  16141. this._teleportationEnabled = false;
  16142. if (this._gazeTracker) {
  16143. this._gazeTracker.dispose();
  16144. }
  16145. };
  16146. VRExperienceHelperGazer._idCounter = 0;
  16147. return VRExperienceHelperGazer;
  16148. }());
  16149. var VRExperienceHelperControllerGazer = /** @class */ (function (_super) {
  16150. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperControllerGazer, _super);
  16151. function VRExperienceHelperControllerGazer(webVRController, scene, gazeTrackerToClone) {
  16152. var _this = _super.call(this, scene, gazeTrackerToClone) || this;
  16153. _this.webVRController = webVRController;
  16154. // Laser pointer
  16155. _this._laserPointer = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateCylinder("laserPointer", 1, 0.004, 0.0002, 20, 1, scene, false);
  16156. var laserPointerMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("laserPointerMat", scene);
  16157. laserPointerMaterial.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  16158. laserPointerMaterial.alpha = 0.6;
  16159. _this._laserPointer.material = laserPointerMaterial;
  16160. _this._laserPointer.rotation.x = Math.PI / 2;
  16161. _this._laserPointer.position.z = -0.5;
  16162. _this._laserPointer.isVisible = false;
  16163. _this._laserPointer.isPickable = false;
  16164. if (!webVRController.mesh) {
  16165. // Create an empty mesh that is used prior to loading the high quality model
  16166. var preloadMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"]("preloadControllerMesh", scene);
  16167. var preloadPointerPose = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"](_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE, scene);
  16168. preloadPointerPose.rotation.x = -0.7;
  16169. preloadMesh.addChild(preloadPointerPose);
  16170. webVRController.attachToMesh(preloadMesh);
  16171. }
  16172. _this._setLaserPointerParent(webVRController.mesh);
  16173. _this._meshAttachedObserver = webVRController._meshAttachedObservable.add(function (mesh) {
  16174. _this._setLaserPointerParent(mesh);
  16175. });
  16176. return _this;
  16177. }
  16178. VRExperienceHelperControllerGazer.prototype._getForwardRay = function (length) {
  16179. return this.webVRController.getForwardRay(length);
  16180. };
  16181. /** @hidden */
  16182. VRExperienceHelperControllerGazer.prototype._activatePointer = function () {
  16183. _super.prototype._activatePointer.call(this);
  16184. this._laserPointer.isVisible = true;
  16185. };
  16186. /** @hidden */
  16187. VRExperienceHelperControllerGazer.prototype._deactivatePointer = function () {
  16188. _super.prototype._deactivatePointer.call(this);
  16189. this._laserPointer.isVisible = false;
  16190. };
  16191. /** @hidden */
  16192. VRExperienceHelperControllerGazer.prototype._setLaserPointerColor = function (color) {
  16193. this._laserPointer.material.emissiveColor = color;
  16194. };
  16195. /** @hidden */
  16196. VRExperienceHelperControllerGazer.prototype._setLaserPointerParent = function (mesh) {
  16197. var makeNotPick = function (root) {
  16198. root.isPickable = false;
  16199. root.getChildMeshes().forEach(function (c) {
  16200. makeNotPick(c);
  16201. });
  16202. };
  16203. makeNotPick(mesh);
  16204. var meshChildren = mesh.getChildren(undefined, false);
  16205. var laserParent = mesh;
  16206. this.webVRController._pointingPoseNode = null;
  16207. for (var i = 0; i < meshChildren.length; i++) {
  16208. if (meshChildren[i].name && meshChildren[i].name.indexOf(_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE) >= 0) {
  16209. laserParent = meshChildren[i];
  16210. this.webVRController._pointingPoseNode = laserParent;
  16211. break;
  16212. }
  16213. }
  16214. this._laserPointer.parent = laserParent;
  16215. };
  16216. VRExperienceHelperControllerGazer.prototype._updatePointerDistance = function (distance) {
  16217. if (distance === void 0) { distance = 100; }
  16218. this._laserPointer.scaling.y = distance;
  16219. this._laserPointer.position.z = -distance / 2;
  16220. };
  16221. VRExperienceHelperControllerGazer.prototype.dispose = function () {
  16222. _super.prototype.dispose.call(this);
  16223. this._laserPointer.dispose();
  16224. if (this._meshAttachedObserver) {
  16225. this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver);
  16226. }
  16227. };
  16228. return VRExperienceHelperControllerGazer;
  16229. }(VRExperienceHelperGazer));
  16230. var VRExperienceHelperCameraGazer = /** @class */ (function (_super) {
  16231. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperCameraGazer, _super);
  16232. function VRExperienceHelperCameraGazer(getCamera, scene) {
  16233. var _this = _super.call(this, scene) || this;
  16234. _this.getCamera = getCamera;
  16235. return _this;
  16236. }
  16237. VRExperienceHelperCameraGazer.prototype._getForwardRay = function (length) {
  16238. var camera = this.getCamera();
  16239. if (camera) {
  16240. return camera.getForwardRay(length);
  16241. }
  16242. else {
  16243. 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());
  16244. }
  16245. };
  16246. return VRExperienceHelperCameraGazer;
  16247. }(VRExperienceHelperGazer));
  16248. /**
  16249. * Event containing information after VR has been entered
  16250. */
  16251. var OnAfterEnteringVRObservableEvent = /** @class */ (function () {
  16252. function OnAfterEnteringVRObservableEvent() {
  16253. }
  16254. return OnAfterEnteringVRObservableEvent;
  16255. }());
  16256. /**
  16257. * Helps to quickly add VR support to an existing scene.
  16258. * See http://doc.babylonjs.com/how_to/webvr_helper
  16259. */
  16260. var VRExperienceHelper = /** @class */ (function () {
  16261. /**
  16262. * Instantiates a VRExperienceHelper.
  16263. * Helps to quickly add VR support to an existing scene.
  16264. * @param scene The scene the VRExperienceHelper belongs to.
  16265. * @param webVROptions Options to modify the vr experience helper's behavior.
  16266. */
  16267. function VRExperienceHelper(scene,
  16268. /** Options to modify the vr experience helper's behavior. */
  16269. webVROptions) {
  16270. if (webVROptions === void 0) { webVROptions = {}; }
  16271. var _this = this;
  16272. this.webVROptions = webVROptions;
  16273. // Can the system support WebVR, even if a headset isn't plugged in?
  16274. this._webVRsupported = false;
  16275. // If WebVR is supported, is a headset plugged in and are we ready to present?
  16276. this._webVRready = false;
  16277. // Are we waiting for the requestPresent callback to complete?
  16278. this._webVRrequesting = false;
  16279. // Are we presenting to the headset right now? (this is the vrDevice state)
  16280. this._webVRpresenting = false;
  16281. // Are we presenting in the fullscreen fallback?
  16282. this._fullscreenVRpresenting = false;
  16283. /**
  16284. * Observable raised right before entering VR.
  16285. */
  16286. this.onEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16287. /**
  16288. * Observable raised when entering VR has completed.
  16289. */
  16290. this.onAfterEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16291. /**
  16292. * Observable raised when exiting VR.
  16293. */
  16294. this.onExitingVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16295. /**
  16296. * Observable raised when controller mesh is loaded.
  16297. */
  16298. this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16299. this._useCustomVRButton = false;
  16300. this._teleportationRequested = false;
  16301. this._teleportActive = false;
  16302. this._floorMeshesCollection = [];
  16303. this._rotationAllowed = true;
  16304. this._teleportBackwardsVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, -1, -1);
  16305. this._isDefaultTeleportationTarget = true;
  16306. this._teleportationFillColor = "#444444";
  16307. this._teleportationBorderColor = "#FFFFFF";
  16308. this._rotationAngle = 0;
  16309. this._haloCenter = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, 0, 0);
  16310. this._padSensibilityUp = 0.65;
  16311. this._padSensibilityDown = 0.35;
  16312. this._leftController = null;
  16313. this._rightController = null;
  16314. /**
  16315. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  16316. */
  16317. this.onNewMeshSelected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16318. /**
  16319. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  16320. */
  16321. this.onNewMeshPicked = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16322. /**
  16323. * Observable raised before camera teleportation
  16324. */
  16325. this.onBeforeCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16326. /**
  16327. * Observable raised after camera teleportation
  16328. */
  16329. this.onAfterCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16330. /**
  16331. * Observable raised when current selected mesh gets unselected
  16332. */
  16333. this.onSelectedMeshUnselected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16334. /**
  16335. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  16336. */
  16337. this.teleportationEnabled = true;
  16338. this._teleportationInitialized = false;
  16339. this._interactionsEnabled = false;
  16340. this._interactionsRequested = false;
  16341. this._displayGaze = true;
  16342. this._displayLaserPointer = true;
  16343. /**
  16344. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  16345. */
  16346. this.updateGazeTrackerScale = true;
  16347. /**
  16348. * If the gaze trackers color should be updated when selecting meshes
  16349. */
  16350. this.updateGazeTrackerColor = true;
  16351. /**
  16352. * Defines wether or not Pointer lock should be requested when switching to
  16353. * full screen.
  16354. */
  16355. this.requestPointerLockOnFullScreen = true;
  16356. this._onResize = function () {
  16357. _this.moveButtonToBottomRight();
  16358. if (_this._fullscreenVRpresenting && _this._webVRready) {
  16359. _this.exitVR();
  16360. }
  16361. };
  16362. this._onFullscreenChange = function () {
  16363. var anyDoc = document;
  16364. if (anyDoc.fullscreen !== undefined) {
  16365. _this._fullscreenVRpresenting = document.fullscreen;
  16366. }
  16367. else if (anyDoc.mozFullScreen !== undefined) {
  16368. _this._fullscreenVRpresenting = anyDoc.mozFullScreen;
  16369. }
  16370. else if (anyDoc.webkitIsFullScreen !== undefined) {
  16371. _this._fullscreenVRpresenting = anyDoc.webkitIsFullScreen;
  16372. }
  16373. else if (anyDoc.msIsFullScreen !== undefined) {
  16374. _this._fullscreenVRpresenting = anyDoc.msIsFullScreen;
  16375. }
  16376. else if (document.msFullscreenElement !== undefined) {
  16377. _this._fullscreenVRpresenting = document.msFullscreenElement;
  16378. }
  16379. if (!_this._fullscreenVRpresenting && _this._canvas) {
  16380. _this.exitVR();
  16381. if (!_this._useCustomVRButton) {
  16382. _this._btnVR.style.top = _this._canvas.offsetTop + _this._canvas.offsetHeight - 70 + "px";
  16383. _this._btnVR.style.left = _this._canvas.offsetLeft + _this._canvas.offsetWidth - 100 + "px";
  16384. }
  16385. }
  16386. };
  16387. this._cachedAngularSensibility = { angularSensibilityX: null, angularSensibilityY: null, angularSensibility: null };
  16388. this.beforeRender = function () {
  16389. if (_this._leftController && _this._leftController._activePointer) {
  16390. _this._castRayAndSelectObject(_this._leftController);
  16391. }
  16392. if (_this._rightController && _this._rightController._activePointer) {
  16393. _this._castRayAndSelectObject(_this._rightController);
  16394. }
  16395. if (_this._noControllerIsActive) {
  16396. _this._castRayAndSelectObject(_this._cameraGazer);
  16397. }
  16398. else {
  16399. _this._cameraGazer._gazeTracker.isVisible = false;
  16400. }
  16401. };
  16402. this._onNewGamepadConnected = function (gamepad) {
  16403. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].POSE_ENABLED) {
  16404. if (gamepad.leftStick) {
  16405. gamepad.onleftstickchanged(function (stickValues) {
  16406. if (_this._teleportationInitialized && _this.teleportationEnabled) {
  16407. // Listening to classic/xbox gamepad only if no VR controller is active
  16408. if ((!_this._leftController && !_this._rightController) ||
  16409. ((_this._leftController && !_this._leftController._activePointer) &&
  16410. (_this._rightController && !_this._rightController._activePointer))) {
  16411. _this._checkTeleportWithRay(stickValues, _this._cameraGazer);
  16412. _this._checkTeleportBackwards(stickValues, _this._cameraGazer);
  16413. }
  16414. }
  16415. });
  16416. }
  16417. if (gamepad.rightStick) {
  16418. gamepad.onrightstickchanged(function (stickValues) {
  16419. if (_this._teleportationInitialized) {
  16420. _this._checkRotate(stickValues, _this._cameraGazer);
  16421. }
  16422. });
  16423. }
  16424. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].XBOX) {
  16425. gamepad.onbuttondown(function (buttonPressed) {
  16426. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  16427. _this._cameraGazer._selectionPointerDown();
  16428. }
  16429. });
  16430. gamepad.onbuttonup(function (buttonPressed) {
  16431. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  16432. _this._cameraGazer._selectionPointerUp();
  16433. }
  16434. });
  16435. }
  16436. }
  16437. else {
  16438. var webVRController = gamepad;
  16439. var controller = new VRExperienceHelperControllerGazer(webVRController, _this._scene, _this._cameraGazer._gazeTracker);
  16440. if (webVRController.hand === "right" || (_this._leftController && _this._leftController.webVRController != webVRController)) {
  16441. _this._rightController = controller;
  16442. }
  16443. else {
  16444. _this._leftController = controller;
  16445. }
  16446. _this._tryEnableInteractionOnController(controller);
  16447. }
  16448. };
  16449. // 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
  16450. this._tryEnableInteractionOnController = function (controller) {
  16451. if (_this._interactionsRequested && !controller._interactionsEnabled) {
  16452. _this._enableInteractionOnController(controller);
  16453. }
  16454. if (_this._teleportationRequested && !controller._teleportationEnabled) {
  16455. _this._enableTeleportationOnController(controller);
  16456. }
  16457. };
  16458. this._onNewGamepadDisconnected = function (gamepad) {
  16459. if (gamepad instanceof _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__["WebVRController"]) {
  16460. if (gamepad.hand === "left" && _this._leftController != null) {
  16461. _this._leftController.dispose();
  16462. _this._leftController = null;
  16463. }
  16464. if (gamepad.hand === "right" && _this._rightController != null) {
  16465. _this._rightController.dispose();
  16466. _this._rightController = null;
  16467. }
  16468. }
  16469. };
  16470. this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Zero();
  16471. this._workingQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].Identity();
  16472. this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].Identity();
  16473. this._scene = scene;
  16474. this._canvas = scene.getEngine().getRenderingCanvas();
  16475. // Parse options
  16476. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera === undefined) {
  16477. webVROptions.createFallbackVRDeviceOrientationFreeCamera = true;
  16478. }
  16479. if (webVROptions.createDeviceOrientationCamera === undefined) {
  16480. webVROptions.createDeviceOrientationCamera = true;
  16481. }
  16482. if (webVROptions.laserToggle === undefined) {
  16483. webVROptions.laserToggle = true;
  16484. }
  16485. if (webVROptions.defaultHeight === undefined) {
  16486. webVROptions.defaultHeight = 1.7;
  16487. }
  16488. if (webVROptions.useCustomVRButton) {
  16489. this._useCustomVRButton = true;
  16490. if (webVROptions.customVRButton) {
  16491. this._btnVR = webVROptions.customVRButton;
  16492. }
  16493. }
  16494. if (webVROptions.rayLength) {
  16495. this._rayLength = webVROptions.rayLength;
  16496. }
  16497. this._defaultHeight = webVROptions.defaultHeight;
  16498. if (webVROptions.positionScale) {
  16499. this._rayLength *= webVROptions.positionScale;
  16500. this._defaultHeight *= webVROptions.positionScale;
  16501. }
  16502. this._hasEnteredVR = false;
  16503. // Set position
  16504. if (this._scene.activeCamera) {
  16505. this._position = this._scene.activeCamera.position.clone();
  16506. }
  16507. else {
  16508. this._position = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, this._defaultHeight, 0);
  16509. }
  16510. // Set non-vr camera
  16511. if (webVROptions.createDeviceOrientationCamera || !this._scene.activeCamera) {
  16512. this._deviceOrientationCamera = new _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__["DeviceOrientationCamera"]("deviceOrientationVRHelper", this._position.clone(), scene);
  16513. // Copy data from existing camera
  16514. if (this._scene.activeCamera) {
  16515. this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  16516. this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
  16517. // Set rotation from previous camera
  16518. if (this._scene.activeCamera instanceof _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"] && this._scene.activeCamera.rotation) {
  16519. var targetCamera = this._scene.activeCamera;
  16520. if (targetCamera.rotationQuaternion) {
  16521. this._deviceOrientationCamera.rotationQuaternion.copyFrom(targetCamera.rotationQuaternion);
  16522. }
  16523. else {
  16524. this._deviceOrientationCamera.rotationQuaternion.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRoll(targetCamera.rotation.y, targetCamera.rotation.x, targetCamera.rotation.z));
  16525. }
  16526. this._deviceOrientationCamera.rotation = targetCamera.rotation.clone();
  16527. }
  16528. }
  16529. this._scene.activeCamera = this._deviceOrientationCamera;
  16530. if (this._canvas) {
  16531. this._scene.activeCamera.attachControl(this._canvas);
  16532. }
  16533. }
  16534. else {
  16535. this._existingCamera = this._scene.activeCamera;
  16536. }
  16537. // Create VR cameras
  16538. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16539. if (webVROptions.useMultiview) {
  16540. if (!webVROptions.vrDeviceOrientationCameraMetrics) {
  16541. webVROptions.vrDeviceOrientationCameraMetrics = _Cameras_VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_22__["VRCameraMetrics"].GetDefault();
  16542. }
  16543. webVROptions.vrDeviceOrientationCameraMetrics.multiviewEnabled = true;
  16544. }
  16545. this._vrDeviceOrientationCamera = new _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__["VRDeviceOrientationFreeCamera"]("VRDeviceOrientationVRHelper", this._position, this._scene, true, webVROptions.vrDeviceOrientationCameraMetrics);
  16546. this._vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  16547. }
  16548. this._webVRCamera = new _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]("WebVRHelper", this._position, this._scene, webVROptions);
  16549. this._webVRCamera.useStandingMatrix();
  16550. this._cameraGazer = new VRExperienceHelperCameraGazer(function () { return _this.currentVRCamera; }, scene);
  16551. // Create default button
  16552. if (!this._useCustomVRButton) {
  16553. this._btnVR = document.createElement("BUTTON");
  16554. this._btnVR.className = "babylonVRicon";
  16555. this._btnVR.id = "babylonVRiconbtn";
  16556. this._btnVR.title = "Click to switch to VR";
  16557. 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) }";
  16558. css += ".babylonVRicon.vrdisplaypresenting { display: none; }";
  16559. // TODO: Add user feedback so that they know what state the VRDisplay is in (disconnected, connected, entering-VR)
  16560. // css += ".babylonVRicon.vrdisplaysupported { }";
  16561. // css += ".babylonVRicon.vrdisplayready { }";
  16562. // css += ".babylonVRicon.vrdisplayrequesting { }";
  16563. var style = document.createElement('style');
  16564. style.appendChild(document.createTextNode(css));
  16565. document.getElementsByTagName('head')[0].appendChild(style);
  16566. this.moveButtonToBottomRight();
  16567. }
  16568. // VR button click event
  16569. if (this._btnVR) {
  16570. this._btnVR.addEventListener("click", function () {
  16571. if (!_this.isInVRMode) {
  16572. _this.enterVR();
  16573. }
  16574. else {
  16575. _this.exitVR();
  16576. }
  16577. });
  16578. }
  16579. // Window events
  16580. window.addEventListener("resize", this._onResize);
  16581. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  16582. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  16583. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  16584. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  16585. document.onmsfullscreenchange = this._onFullscreenChange;
  16586. // Display vr button when headset is connected
  16587. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16588. this.displayVRButton();
  16589. }
  16590. else {
  16591. this._scene.getEngine().onVRDisplayChangedObservable.add(function (e) {
  16592. if (e.vrDisplay) {
  16593. _this.displayVRButton();
  16594. }
  16595. });
  16596. }
  16597. // Exiting VR mode using 'ESC' key on desktop
  16598. this._onKeyDown = function (event) {
  16599. if (event.keyCode === 27 && _this.isInVRMode) {
  16600. _this.exitVR();
  16601. }
  16602. };
  16603. document.addEventListener("keydown", this._onKeyDown);
  16604. // Exiting VR mode double tapping the touch screen
  16605. this._scene.onPrePointerObservable.add(function () {
  16606. if (_this.isInVRMode) {
  16607. _this.exitVR();
  16608. if (_this._fullscreenVRpresenting) {
  16609. _this._scene.getEngine().exitFullscreen();
  16610. }
  16611. }
  16612. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__["PointerEventTypes"].POINTERDOUBLETAP, false);
  16613. // Listen for WebVR display changes
  16614. this._onVRDisplayChanged = function (eventArgs) { return _this.onVRDisplayChanged(eventArgs); };
  16615. this._onVrDisplayPresentChange = function () { return _this.onVrDisplayPresentChange(); };
  16616. this._onVRRequestPresentStart = function () {
  16617. _this._webVRrequesting = true;
  16618. _this.updateButtonVisibility();
  16619. };
  16620. this._onVRRequestPresentComplete = function () {
  16621. _this._webVRrequesting = false;
  16622. _this.updateButtonVisibility();
  16623. };
  16624. scene.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged);
  16625. scene.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart);
  16626. scene.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete);
  16627. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  16628. scene.onDisposeObservable.add(function () {
  16629. _this.dispose();
  16630. });
  16631. // Gamepad connection events
  16632. this._webVRCamera.onControllerMeshLoadedObservable.add(function (webVRController) { return _this._onDefaultMeshLoaded(webVRController); });
  16633. this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected);
  16634. this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected);
  16635. this.updateButtonVisibility();
  16636. //create easing functions
  16637. this._circleEase = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["CircleEase"]();
  16638. this._circleEase.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  16639. if (this.webVROptions.floorMeshes) {
  16640. this.enableTeleportation({ floorMeshes: this.webVROptions.floorMeshes });
  16641. }
  16642. }
  16643. Object.defineProperty(VRExperienceHelper.prototype, "onEnteringVR", {
  16644. /** Return this.onEnteringVRObservable
  16645. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  16646. */
  16647. get: function () {
  16648. return this.onEnteringVRObservable;
  16649. },
  16650. enumerable: true,
  16651. configurable: true
  16652. });
  16653. Object.defineProperty(VRExperienceHelper.prototype, "onExitingVR", {
  16654. /** Return this.onExitingVRObservable
  16655. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  16656. */
  16657. get: function () {
  16658. return this.onExitingVRObservable;
  16659. },
  16660. enumerable: true,
  16661. configurable: true
  16662. });
  16663. Object.defineProperty(VRExperienceHelper.prototype, "onControllerMeshLoaded", {
  16664. /** Return this.onControllerMeshLoadedObservable
  16665. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  16666. */
  16667. get: function () {
  16668. return this.onControllerMeshLoadedObservable;
  16669. },
  16670. enumerable: true,
  16671. configurable: true
  16672. });
  16673. Object.defineProperty(VRExperienceHelper.prototype, "teleportationTarget", {
  16674. /**
  16675. * The mesh used to display where the user is going to teleport.
  16676. */
  16677. get: function () {
  16678. return this._teleportationTarget;
  16679. },
  16680. /**
  16681. * Sets the mesh to be used to display where the user is going to teleport.
  16682. */
  16683. set: function (value) {
  16684. if (value) {
  16685. value.name = "teleportationTarget";
  16686. this._isDefaultTeleportationTarget = false;
  16687. this._teleportationTarget = value;
  16688. }
  16689. },
  16690. enumerable: true,
  16691. configurable: true
  16692. });
  16693. Object.defineProperty(VRExperienceHelper.prototype, "gazeTrackerMesh", {
  16694. /**
  16695. * 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
  16696. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  16697. * See http://doc.babylonjs.com/resources/baking_transformations
  16698. */
  16699. get: function () {
  16700. return this._cameraGazer._gazeTracker;
  16701. },
  16702. set: function (value) {
  16703. if (value) {
  16704. // Dispose of existing meshes
  16705. if (this._cameraGazer._gazeTracker) {
  16706. this._cameraGazer._gazeTracker.dispose();
  16707. }
  16708. if (this._leftController && this._leftController._gazeTracker) {
  16709. this._leftController._gazeTracker.dispose();
  16710. }
  16711. if (this._rightController && this._rightController._gazeTracker) {
  16712. this._rightController._gazeTracker.dispose();
  16713. }
  16714. // Set and create gaze trackers on head and controllers
  16715. this._cameraGazer._gazeTracker = value;
  16716. this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices();
  16717. this._cameraGazer._gazeTracker.isPickable = false;
  16718. this._cameraGazer._gazeTracker.isVisible = false;
  16719. this._cameraGazer._gazeTracker.name = "gazeTracker";
  16720. if (this._leftController) {
  16721. this._leftController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16722. }
  16723. if (this._rightController) {
  16724. this._rightController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16725. }
  16726. }
  16727. },
  16728. enumerable: true,
  16729. configurable: true
  16730. });
  16731. Object.defineProperty(VRExperienceHelper.prototype, "leftControllerGazeTrackerMesh", {
  16732. /**
  16733. * The gaze tracking mesh corresponding to the left controller
  16734. */
  16735. get: function () {
  16736. if (this._leftController) {
  16737. return this._leftController._gazeTracker;
  16738. }
  16739. return null;
  16740. },
  16741. enumerable: true,
  16742. configurable: true
  16743. });
  16744. Object.defineProperty(VRExperienceHelper.prototype, "rightControllerGazeTrackerMesh", {
  16745. /**
  16746. * The gaze tracking mesh corresponding to the right controller
  16747. */
  16748. get: function () {
  16749. if (this._rightController) {
  16750. return this._rightController._gazeTracker;
  16751. }
  16752. return null;
  16753. },
  16754. enumerable: true,
  16755. configurable: true
  16756. });
  16757. Object.defineProperty(VRExperienceHelper.prototype, "displayGaze", {
  16758. /**
  16759. * If the ray of the gaze should be displayed.
  16760. */
  16761. get: function () {
  16762. return this._displayGaze;
  16763. },
  16764. /**
  16765. * Sets if the ray of the gaze should be displayed.
  16766. */
  16767. set: function (value) {
  16768. this._displayGaze = value;
  16769. if (!value) {
  16770. this._cameraGazer._gazeTracker.isVisible = false;
  16771. if (this._leftController) {
  16772. this._leftController._gazeTracker.isVisible = false;
  16773. }
  16774. if (this._rightController) {
  16775. this._rightController._gazeTracker.isVisible = false;
  16776. }
  16777. }
  16778. },
  16779. enumerable: true,
  16780. configurable: true
  16781. });
  16782. Object.defineProperty(VRExperienceHelper.prototype, "displayLaserPointer", {
  16783. /**
  16784. * If the ray of the LaserPointer should be displayed.
  16785. */
  16786. get: function () {
  16787. return this._displayLaserPointer;
  16788. },
  16789. /**
  16790. * Sets if the ray of the LaserPointer should be displayed.
  16791. */
  16792. set: function (value) {
  16793. this._displayLaserPointer = value;
  16794. if (!value) {
  16795. if (this._rightController) {
  16796. this._rightController._deactivatePointer();
  16797. this._rightController._gazeTracker.isVisible = false;
  16798. }
  16799. if (this._leftController) {
  16800. this._leftController._deactivatePointer();
  16801. this._leftController._gazeTracker.isVisible = false;
  16802. }
  16803. }
  16804. else {
  16805. if (this._rightController) {
  16806. this._rightController._activatePointer();
  16807. }
  16808. if (this._leftController) {
  16809. this._leftController._activatePointer();
  16810. }
  16811. }
  16812. },
  16813. enumerable: true,
  16814. configurable: true
  16815. });
  16816. Object.defineProperty(VRExperienceHelper.prototype, "deviceOrientationCamera", {
  16817. /**
  16818. * The deviceOrientationCamera used as the camera when not in VR.
  16819. */
  16820. get: function () {
  16821. return this._deviceOrientationCamera;
  16822. },
  16823. enumerable: true,
  16824. configurable: true
  16825. });
  16826. Object.defineProperty(VRExperienceHelper.prototype, "currentVRCamera", {
  16827. /**
  16828. * Based on the current WebVR support, returns the current VR camera used.
  16829. */
  16830. get: function () {
  16831. if (this._webVRready) {
  16832. return this._webVRCamera;
  16833. }
  16834. else {
  16835. return this._scene.activeCamera;
  16836. }
  16837. },
  16838. enumerable: true,
  16839. configurable: true
  16840. });
  16841. Object.defineProperty(VRExperienceHelper.prototype, "webVRCamera", {
  16842. /**
  16843. * The webVRCamera which is used when in VR.
  16844. */
  16845. get: function () {
  16846. return this._webVRCamera;
  16847. },
  16848. enumerable: true,
  16849. configurable: true
  16850. });
  16851. Object.defineProperty(VRExperienceHelper.prototype, "vrDeviceOrientationCamera", {
  16852. /**
  16853. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  16854. */
  16855. get: function () {
  16856. return this._vrDeviceOrientationCamera;
  16857. },
  16858. enumerable: true,
  16859. configurable: true
  16860. });
  16861. Object.defineProperty(VRExperienceHelper.prototype, "_teleportationRequestInitiated", {
  16862. get: function () {
  16863. var result = this._cameraGazer._teleportationRequestInitiated
  16864. || (this._leftController !== null && this._leftController._teleportationRequestInitiated)
  16865. || (this._rightController !== null && this._rightController._teleportationRequestInitiated);
  16866. return result;
  16867. },
  16868. enumerable: true,
  16869. configurable: true
  16870. });
  16871. // Raised when one of the controller has loaded successfully its associated default mesh
  16872. VRExperienceHelper.prototype._onDefaultMeshLoaded = function (webVRController) {
  16873. if (this._leftController && this._leftController.webVRController == webVRController) {
  16874. if (webVRController.mesh) {
  16875. this._leftController._setLaserPointerParent(webVRController.mesh);
  16876. }
  16877. }
  16878. if (this._rightController && this._rightController.webVRController == webVRController) {
  16879. if (webVRController.mesh) {
  16880. this._rightController._setLaserPointerParent(webVRController.mesh);
  16881. }
  16882. }
  16883. try {
  16884. this.onControllerMeshLoadedObservable.notifyObservers(webVRController);
  16885. }
  16886. catch (err) {
  16887. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onControllerMeshLoaded: " + err);
  16888. }
  16889. };
  16890. Object.defineProperty(VRExperienceHelper.prototype, "isInVRMode", {
  16891. /**
  16892. * Gets a value indicating if we are currently in VR mode.
  16893. */
  16894. get: function () {
  16895. return this._webVRpresenting || this._fullscreenVRpresenting;
  16896. },
  16897. enumerable: true,
  16898. configurable: true
  16899. });
  16900. VRExperienceHelper.prototype.onVrDisplayPresentChange = function () {
  16901. var vrDisplay = this._scene.getEngine().getVRDevice();
  16902. if (vrDisplay) {
  16903. var wasPresenting = this._webVRpresenting;
  16904. this._webVRpresenting = vrDisplay.isPresenting;
  16905. if (wasPresenting && !this._webVRpresenting) {
  16906. this.exitVR();
  16907. }
  16908. }
  16909. else {
  16910. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?');
  16911. }
  16912. this.updateButtonVisibility();
  16913. };
  16914. VRExperienceHelper.prototype.onVRDisplayChanged = function (eventArgs) {
  16915. this._webVRsupported = eventArgs.vrSupported;
  16916. this._webVRready = !!eventArgs.vrDisplay;
  16917. this._webVRpresenting = eventArgs.vrDisplay && eventArgs.vrDisplay.isPresenting;
  16918. this.updateButtonVisibility();
  16919. };
  16920. VRExperienceHelper.prototype.moveButtonToBottomRight = function () {
  16921. if (this._canvas && !this._useCustomVRButton) {
  16922. this._btnVR.style.top = this._canvas.offsetTop + this._canvas.offsetHeight - 70 + "px";
  16923. this._btnVR.style.left = this._canvas.offsetLeft + this._canvas.offsetWidth - 100 + "px";
  16924. }
  16925. };
  16926. VRExperienceHelper.prototype.displayVRButton = function () {
  16927. if (!this._useCustomVRButton && !this._btnVRDisplayed) {
  16928. document.body.appendChild(this._btnVR);
  16929. this._btnVRDisplayed = true;
  16930. }
  16931. };
  16932. VRExperienceHelper.prototype.updateButtonVisibility = function () {
  16933. if (!this._btnVR || this._useCustomVRButton) {
  16934. return;
  16935. }
  16936. this._btnVR.className = "babylonVRicon";
  16937. if (this.isInVRMode) {
  16938. this._btnVR.className += " vrdisplaypresenting";
  16939. }
  16940. else {
  16941. if (this._webVRready) {
  16942. this._btnVR.className += " vrdisplayready";
  16943. }
  16944. if (this._webVRsupported) {
  16945. this._btnVR.className += " vrdisplaysupported";
  16946. }
  16947. if (this._webVRrequesting) {
  16948. this._btnVR.className += " vrdisplayrequesting";
  16949. }
  16950. }
  16951. };
  16952. /**
  16953. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  16954. * Otherwise, will use the fullscreen API.
  16955. */
  16956. VRExperienceHelper.prototype.enterVR = function () {
  16957. var _this = this;
  16958. if (this.onEnteringVRObservable) {
  16959. try {
  16960. this.onEnteringVRObservable.notifyObservers(this);
  16961. }
  16962. catch (err) {
  16963. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onEnteringVR: " + err);
  16964. }
  16965. }
  16966. if (this._scene.activeCamera) {
  16967. this._position = this._scene.activeCamera.position.clone();
  16968. if (this.vrDeviceOrientationCamera) {
  16969. this.vrDeviceOrientationCamera.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles();
  16970. this.vrDeviceOrientationCamera.angularSensibility = 2000;
  16971. }
  16972. if (this.webVRCamera) {
  16973. var currentYRotation = this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y;
  16974. var desiredYRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y;
  16975. var delta = desiredYRotation - currentYRotation;
  16976. var currentGlobalRotation = this.webVRCamera.rotationQuaternion.toEulerAngles().y;
  16977. this.webVRCamera.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromEulerAngles(0, currentGlobalRotation + delta, 0);
  16978. }
  16979. // make sure that we return to the last active camera
  16980. this._existingCamera = this._scene.activeCamera;
  16981. // Remove and cache angular sensability to avoid camera rotation when in VR
  16982. if (this._existingCamera.angularSensibilityX) {
  16983. this._cachedAngularSensibility.angularSensibilityX = this._existingCamera.angularSensibilityX;
  16984. this._existingCamera.angularSensibilityX = Number.MAX_VALUE;
  16985. }
  16986. if (this._existingCamera.angularSensibilityY) {
  16987. this._cachedAngularSensibility.angularSensibilityY = this._existingCamera.angularSensibilityY;
  16988. this._existingCamera.angularSensibilityY = Number.MAX_VALUE;
  16989. }
  16990. if (this._existingCamera.angularSensibility) {
  16991. this._cachedAngularSensibility.angularSensibility = this._existingCamera.angularSensibility;
  16992. this._existingCamera.angularSensibility = Number.MAX_VALUE;
  16993. }
  16994. }
  16995. if (this._webVRrequesting) {
  16996. return;
  16997. }
  16998. // If WebVR is supported and a headset is connected
  16999. if (this._webVRready) {
  17000. if (!this._webVRpresenting) {
  17001. this._scene.getEngine().onVRRequestPresentComplete.addOnce(function (result) {
  17002. _this.onAfterEnteringVRObservable.notifyObservers({ success: result });
  17003. });
  17004. this._webVRCamera.position = this._position;
  17005. this._scene.activeCamera = this._webVRCamera;
  17006. }
  17007. }
  17008. else if (this._vrDeviceOrientationCamera) {
  17009. this._vrDeviceOrientationCamera.position = this._position;
  17010. if (this._scene.activeCamera) {
  17011. this._vrDeviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  17012. }
  17013. this._scene.activeCamera = this._vrDeviceOrientationCamera;
  17014. this._scene.getEngine().enterFullscreen(this.requestPointerLockOnFullScreen);
  17015. this.updateButtonVisibility();
  17016. this._vrDeviceOrientationCamera.onViewMatrixChangedObservable.addOnce(function () {
  17017. _this.onAfterEnteringVRObservable.notifyObservers({ success: true });
  17018. });
  17019. }
  17020. if (this._scene.activeCamera && this._canvas) {
  17021. this._scene.activeCamera.attachControl(this._canvas);
  17022. }
  17023. if (this._interactionsEnabled) {
  17024. this._scene.registerBeforeRender(this.beforeRender);
  17025. }
  17026. if (this._displayLaserPointer) {
  17027. [this._leftController, this._rightController].forEach(function (controller) {
  17028. if (controller) {
  17029. controller._activatePointer();
  17030. }
  17031. });
  17032. }
  17033. this._hasEnteredVR = true;
  17034. };
  17035. /**
  17036. * Attempt to exit VR, or fullscreen.
  17037. */
  17038. VRExperienceHelper.prototype.exitVR = function () {
  17039. if (this._hasEnteredVR) {
  17040. if (this.onExitingVRObservable) {
  17041. try {
  17042. this.onExitingVRObservable.notifyObservers(this);
  17043. }
  17044. catch (err) {
  17045. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onExitingVR: " + err);
  17046. }
  17047. }
  17048. if (this._webVRpresenting) {
  17049. this._scene.getEngine().disableVR();
  17050. }
  17051. if (this._scene.activeCamera) {
  17052. this._position = this._scene.activeCamera.position.clone();
  17053. }
  17054. if (this.vrDeviceOrientationCamera) {
  17055. this.vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  17056. }
  17057. if (this._deviceOrientationCamera) {
  17058. this._deviceOrientationCamera.position = this._position;
  17059. this._scene.activeCamera = this._deviceOrientationCamera;
  17060. if (this._canvas) {
  17061. this._scene.activeCamera.attachControl(this._canvas);
  17062. }
  17063. // Restore angular sensibility
  17064. if (this._cachedAngularSensibility.angularSensibilityX) {
  17065. this._deviceOrientationCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  17066. this._cachedAngularSensibility.angularSensibilityX = null;
  17067. }
  17068. if (this._cachedAngularSensibility.angularSensibilityY) {
  17069. this._deviceOrientationCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  17070. this._cachedAngularSensibility.angularSensibilityY = null;
  17071. }
  17072. if (this._cachedAngularSensibility.angularSensibility) {
  17073. this._deviceOrientationCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  17074. this._cachedAngularSensibility.angularSensibility = null;
  17075. }
  17076. }
  17077. else if (this._existingCamera) {
  17078. this._existingCamera.position = this._position;
  17079. this._scene.activeCamera = this._existingCamera;
  17080. // Restore angular sensibility
  17081. if (this._cachedAngularSensibility.angularSensibilityX) {
  17082. this._existingCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  17083. this._cachedAngularSensibility.angularSensibilityX = null;
  17084. }
  17085. if (this._cachedAngularSensibility.angularSensibilityY) {
  17086. this._existingCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  17087. this._cachedAngularSensibility.angularSensibilityY = null;
  17088. }
  17089. if (this._cachedAngularSensibility.angularSensibility) {
  17090. this._existingCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  17091. this._cachedAngularSensibility.angularSensibility = null;
  17092. }
  17093. }
  17094. this.updateButtonVisibility();
  17095. if (this._interactionsEnabled) {
  17096. this._scene.unregisterBeforeRender(this.beforeRender);
  17097. this._cameraGazer._gazeTracker.isVisible = false;
  17098. if (this._leftController) {
  17099. this._leftController._gazeTracker.isVisible = false;
  17100. }
  17101. if (this._rightController) {
  17102. this._rightController._gazeTracker.isVisible = false;
  17103. }
  17104. }
  17105. // resize to update width and height when exiting vr exits fullscreen
  17106. this._scene.getEngine().resize();
  17107. [this._leftController, this._rightController].forEach(function (controller) {
  17108. if (controller) {
  17109. controller._deactivatePointer();
  17110. }
  17111. });
  17112. this._hasEnteredVR = false;
  17113. }
  17114. };
  17115. Object.defineProperty(VRExperienceHelper.prototype, "position", {
  17116. /**
  17117. * The position of the vr experience helper.
  17118. */
  17119. get: function () {
  17120. return this._position;
  17121. },
  17122. /**
  17123. * Sets the position of the vr experience helper.
  17124. */
  17125. set: function (value) {
  17126. this._position = value;
  17127. if (this._scene.activeCamera) {
  17128. this._scene.activeCamera.position = value;
  17129. }
  17130. },
  17131. enumerable: true,
  17132. configurable: true
  17133. });
  17134. /**
  17135. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  17136. */
  17137. VRExperienceHelper.prototype.enableInteractions = function () {
  17138. var _this = this;
  17139. if (!this._interactionsEnabled) {
  17140. this._interactionsRequested = true;
  17141. if (this._leftController) {
  17142. this._enableInteractionOnController(this._leftController);
  17143. }
  17144. if (this._rightController) {
  17145. this._enableInteractionOnController(this._rightController);
  17146. }
  17147. this.raySelectionPredicate = function (mesh) {
  17148. return mesh.isVisible && (mesh.isPickable || mesh.name === _this._floorMeshName);
  17149. };
  17150. this.meshSelectionPredicate = function () {
  17151. return true;
  17152. };
  17153. this._raySelectionPredicate = function (mesh) {
  17154. if (_this._isTeleportationFloor(mesh) || (mesh.name.indexOf("gazeTracker") === -1
  17155. && mesh.name.indexOf("teleportationTarget") === -1
  17156. && mesh.name.indexOf("torusTeleportation") === -1)) {
  17157. return _this.raySelectionPredicate(mesh);
  17158. }
  17159. return false;
  17160. };
  17161. this._interactionsEnabled = true;
  17162. }
  17163. };
  17164. Object.defineProperty(VRExperienceHelper.prototype, "_noControllerIsActive", {
  17165. get: function () {
  17166. return !(this._leftController && this._leftController._activePointer) && !(this._rightController && this._rightController._activePointer);
  17167. },
  17168. enumerable: true,
  17169. configurable: true
  17170. });
  17171. VRExperienceHelper.prototype._isTeleportationFloor = function (mesh) {
  17172. for (var i = 0; i < this._floorMeshesCollection.length; i++) {
  17173. if (this._floorMeshesCollection[i].id === mesh.id) {
  17174. return true;
  17175. }
  17176. }
  17177. if (this._floorMeshName && mesh.name === this._floorMeshName) {
  17178. return true;
  17179. }
  17180. return false;
  17181. };
  17182. /**
  17183. * Adds a floor mesh to be used for teleportation.
  17184. * @param floorMesh the mesh to be used for teleportation.
  17185. */
  17186. VRExperienceHelper.prototype.addFloorMesh = function (floorMesh) {
  17187. if (!this._floorMeshesCollection) {
  17188. return;
  17189. }
  17190. if (this._floorMeshesCollection.indexOf(floorMesh) > -1) {
  17191. return;
  17192. }
  17193. this._floorMeshesCollection.push(floorMesh);
  17194. };
  17195. /**
  17196. * Removes a floor mesh from being used for teleportation.
  17197. * @param floorMesh the mesh to be removed.
  17198. */
  17199. VRExperienceHelper.prototype.removeFloorMesh = function (floorMesh) {
  17200. if (!this._floorMeshesCollection) {
  17201. return;
  17202. }
  17203. var meshIndex = this._floorMeshesCollection.indexOf(floorMesh);
  17204. if (meshIndex !== -1) {
  17205. this._floorMeshesCollection.splice(meshIndex, 1);
  17206. }
  17207. };
  17208. /**
  17209. * Enables interactions and teleportation using the VR controllers and gaze.
  17210. * @param vrTeleportationOptions options to modify teleportation behavior.
  17211. */
  17212. VRExperienceHelper.prototype.enableTeleportation = function (vrTeleportationOptions) {
  17213. if (vrTeleportationOptions === void 0) { vrTeleportationOptions = {}; }
  17214. if (!this._teleportationInitialized) {
  17215. this._teleportationRequested = true;
  17216. this.enableInteractions();
  17217. if (vrTeleportationOptions.floorMeshName) {
  17218. this._floorMeshName = vrTeleportationOptions.floorMeshName;
  17219. }
  17220. if (vrTeleportationOptions.floorMeshes) {
  17221. this._floorMeshesCollection = vrTeleportationOptions.floorMeshes;
  17222. }
  17223. if (this._leftController != null) {
  17224. this._enableTeleportationOnController(this._leftController);
  17225. }
  17226. if (this._rightController != null) {
  17227. this._enableTeleportationOnController(this._rightController);
  17228. }
  17229. // Creates an image processing post process for the vignette not relying
  17230. // on the main scene configuration for image processing to reduce setup and spaces
  17231. // (gamma/linear) conflicts.
  17232. var imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__["ImageProcessingConfiguration"]();
  17233. imageProcessingConfiguration.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color4"](0, 0, 0, 0);
  17234. imageProcessingConfiguration.vignetteEnabled = true;
  17235. this._postProcessMove = new _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__["ImageProcessingPostProcess"]("postProcessMove", 1.0, this._webVRCamera, undefined, undefined, undefined, undefined, imageProcessingConfiguration);
  17236. this._webVRCamera.detachPostProcess(this._postProcessMove);
  17237. this._teleportationInitialized = true;
  17238. if (this._isDefaultTeleportationTarget) {
  17239. this._createTeleportationCircles();
  17240. this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor);
  17241. }
  17242. }
  17243. };
  17244. VRExperienceHelper.prototype._enableInteractionOnController = function (controller) {
  17245. var _this = this;
  17246. var controllerMesh = controller.webVRController.mesh;
  17247. if (controllerMesh) {
  17248. controller._interactionsEnabled = true;
  17249. if (this.isInVRMode && this._displayLaserPointer) {
  17250. controller._activatePointer();
  17251. }
  17252. if (this.webVROptions.laserToggle) {
  17253. controller.webVRController.onMainButtonStateChangedObservable.add(function (stateObject) {
  17254. // Enabling / disabling laserPointer
  17255. if (_this._displayLaserPointer && stateObject.value === 1) {
  17256. if (controller._activePointer) {
  17257. controller._deactivatePointer();
  17258. }
  17259. else {
  17260. controller._activatePointer();
  17261. }
  17262. if (_this.displayGaze) {
  17263. controller._gazeTracker.isVisible = controller._activePointer;
  17264. }
  17265. }
  17266. });
  17267. }
  17268. controller.webVRController.onTriggerStateChangedObservable.add(function (stateObject) {
  17269. var gazer = controller;
  17270. if (_this._noControllerIsActive) {
  17271. gazer = _this._cameraGazer;
  17272. }
  17273. if (!gazer._pointerDownOnMeshAsked) {
  17274. if (stateObject.value > _this._padSensibilityUp) {
  17275. gazer._selectionPointerDown();
  17276. }
  17277. }
  17278. else if (stateObject.value < _this._padSensibilityDown) {
  17279. gazer._selectionPointerUp();
  17280. }
  17281. });
  17282. }
  17283. };
  17284. VRExperienceHelper.prototype._checkTeleportWithRay = function (stateObject, gazer) {
  17285. // Dont teleport if another gaze already requested teleportation
  17286. if (this._teleportationRequestInitiated && !gazer._teleportationRequestInitiated) {
  17287. return;
  17288. }
  17289. if (!gazer._teleportationRequestInitiated) {
  17290. if (stateObject.y < -this._padSensibilityUp && gazer._dpadPressed) {
  17291. gazer._activatePointer();
  17292. gazer._teleportationRequestInitiated = true;
  17293. }
  17294. }
  17295. else {
  17296. // Listening to the proper controller values changes to confirm teleportation
  17297. if (Math.sqrt(stateObject.y * stateObject.y + stateObject.x * stateObject.x) < this._padSensibilityDown) {
  17298. if (this._teleportActive) {
  17299. this.teleportCamera(this._haloCenter);
  17300. }
  17301. gazer._teleportationRequestInitiated = false;
  17302. }
  17303. }
  17304. };
  17305. VRExperienceHelper.prototype._checkRotate = function (stateObject, gazer) {
  17306. // Only rotate when user is not currently selecting a teleportation location
  17307. if (gazer._teleportationRequestInitiated) {
  17308. return;
  17309. }
  17310. if (!gazer._rotationLeftAsked) {
  17311. if (stateObject.x < -this._padSensibilityUp && gazer._dpadPressed) {
  17312. gazer._rotationLeftAsked = true;
  17313. if (this._rotationAllowed) {
  17314. this._rotateCamera(false);
  17315. }
  17316. }
  17317. }
  17318. else {
  17319. if (stateObject.x > -this._padSensibilityDown) {
  17320. gazer._rotationLeftAsked = false;
  17321. }
  17322. }
  17323. if (!gazer._rotationRightAsked) {
  17324. if (stateObject.x > this._padSensibilityUp && gazer._dpadPressed) {
  17325. gazer._rotationRightAsked = true;
  17326. if (this._rotationAllowed) {
  17327. this._rotateCamera(true);
  17328. }
  17329. }
  17330. }
  17331. else {
  17332. if (stateObject.x < this._padSensibilityDown) {
  17333. gazer._rotationRightAsked = false;
  17334. }
  17335. }
  17336. };
  17337. VRExperienceHelper.prototype._checkTeleportBackwards = function (stateObject, gazer) {
  17338. // Only teleport backwards when user is not currently selecting a teleportation location
  17339. if (gazer._teleportationRequestInitiated) {
  17340. return;
  17341. }
  17342. // Teleport backwards
  17343. if (stateObject.y > this._padSensibilityUp && gazer._dpadPressed) {
  17344. if (!gazer._teleportationBackRequestInitiated) {
  17345. if (!this.currentVRCamera) {
  17346. return;
  17347. }
  17348. // Get rotation and position of the current camera
  17349. var rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix());
  17350. var position = this.currentVRCamera.position;
  17351. // If the camera has device position, use that instead
  17352. if (this.currentVRCamera.devicePosition && this.currentVRCamera.deviceRotationQuaternion) {
  17353. rotation = this.currentVRCamera.deviceRotationQuaternion;
  17354. position = this.currentVRCamera.devicePosition;
  17355. }
  17356. // Get matrix with only the y rotation of the device rotation
  17357. rotation.toEulerAnglesToRef(this._workingVector);
  17358. this._workingVector.z = 0;
  17359. this._workingVector.x = 0;
  17360. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRollToRef(this._workingVector.y, this._workingVector.x, this._workingVector.z, this._workingQuaternion);
  17361. this._workingQuaternion.toRotationMatrix(this._workingMatrix);
  17362. // Rotate backwards ray by device rotation to cast at the ground behind the user
  17363. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].TransformCoordinatesToRef(this._teleportBackwardsVector, this._workingMatrix, this._workingVector);
  17364. // Teleport if ray hit the ground and is not to far away eg. backwards off a cliff
  17365. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_15__["Ray"](position, this._workingVector);
  17366. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  17367. if (hit && hit.pickedPoint && hit.pickedMesh && this._isTeleportationFloor(hit.pickedMesh) && hit.distance < 5) {
  17368. this.teleportCamera(hit.pickedPoint);
  17369. }
  17370. gazer._teleportationBackRequestInitiated = true;
  17371. }
  17372. }
  17373. else {
  17374. gazer._teleportationBackRequestInitiated = false;
  17375. }
  17376. };
  17377. VRExperienceHelper.prototype._enableTeleportationOnController = function (controller) {
  17378. var _this = this;
  17379. var controllerMesh = controller.webVRController.mesh;
  17380. if (controllerMesh) {
  17381. if (!controller._interactionsEnabled) {
  17382. this._enableInteractionOnController(controller);
  17383. }
  17384. controller._interactionsEnabled = true;
  17385. controller._teleportationEnabled = true;
  17386. if (controller.webVRController.controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledControllerType"].VIVE) {
  17387. controller._dpadPressed = false;
  17388. controller.webVRController.onPadStateChangedObservable.add(function (stateObject) {
  17389. controller._dpadPressed = stateObject.pressed;
  17390. if (!controller._dpadPressed) {
  17391. controller._rotationLeftAsked = false;
  17392. controller._rotationRightAsked = false;
  17393. controller._teleportationBackRequestInitiated = false;
  17394. }
  17395. });
  17396. }
  17397. controller.webVRController.onPadValuesChangedObservable.add(function (stateObject) {
  17398. if (_this.teleportationEnabled) {
  17399. _this._checkTeleportBackwards(stateObject, controller);
  17400. _this._checkTeleportWithRay(stateObject, controller);
  17401. }
  17402. _this._checkRotate(stateObject, controller);
  17403. });
  17404. }
  17405. };
  17406. VRExperienceHelper.prototype._createTeleportationCircles = function () {
  17407. this._teleportationTarget = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateGround("teleportationTarget", 2, 2, 2, this._scene);
  17408. this._teleportationTarget.isPickable = false;
  17409. var length = 512;
  17410. var dynamicTexture = new _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__["DynamicTexture"]("DynamicTexture", length, this._scene, true);
  17411. dynamicTexture.hasAlpha = true;
  17412. var context = dynamicTexture.getContext();
  17413. var centerX = length / 2;
  17414. var centerY = length / 2;
  17415. var radius = 200;
  17416. context.beginPath();
  17417. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  17418. context.fillStyle = this._teleportationFillColor;
  17419. context.fill();
  17420. context.lineWidth = 10;
  17421. context.strokeStyle = this._teleportationBorderColor;
  17422. context.stroke();
  17423. context.closePath();
  17424. dynamicTexture.update();
  17425. var teleportationCircleMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("TextPlaneMaterial", this._scene);
  17426. teleportationCircleMaterial.diffuseTexture = dynamicTexture;
  17427. this._teleportationTarget.material = teleportationCircleMaterial;
  17428. var torus = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("torusTeleportation", 0.75, 0.1, 25, this._scene, false);
  17429. torus.isPickable = false;
  17430. torus.parent = this._teleportationTarget;
  17431. 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);
  17432. var keys = [];
  17433. keys.push({
  17434. frame: 0,
  17435. value: 0
  17436. });
  17437. keys.push({
  17438. frame: 30,
  17439. value: 0.4
  17440. });
  17441. keys.push({
  17442. frame: 60,
  17443. value: 0
  17444. });
  17445. animationInnerCircle.setKeys(keys);
  17446. var easingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["SineEase"]();
  17447. easingFunction.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  17448. animationInnerCircle.setEasingFunction(easingFunction);
  17449. torus.animations = [];
  17450. torus.animations.push(animationInnerCircle);
  17451. this._scene.beginAnimation(torus, 0, 60, true);
  17452. this._hideTeleportationTarget();
  17453. };
  17454. VRExperienceHelper.prototype._displayTeleportationTarget = function () {
  17455. this._teleportActive = true;
  17456. if (this._teleportationInitialized) {
  17457. this._teleportationTarget.isVisible = true;
  17458. if (this._isDefaultTeleportationTarget) {
  17459. this._teleportationTarget.getChildren()[0].isVisible = true;
  17460. }
  17461. }
  17462. };
  17463. VRExperienceHelper.prototype._hideTeleportationTarget = function () {
  17464. this._teleportActive = false;
  17465. if (this._teleportationInitialized) {
  17466. this._teleportationTarget.isVisible = false;
  17467. if (this._isDefaultTeleportationTarget) {
  17468. this._teleportationTarget.getChildren()[0].isVisible = false;
  17469. }
  17470. }
  17471. };
  17472. VRExperienceHelper.prototype._rotateCamera = function (right) {
  17473. var _this = this;
  17474. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17475. return;
  17476. }
  17477. if (right) {
  17478. this._rotationAngle++;
  17479. }
  17480. else {
  17481. this._rotationAngle--;
  17482. }
  17483. this.currentVRCamera.animations = [];
  17484. var target = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].RotationY(Math.PI / 4 * this._rotationAngle));
  17485. 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);
  17486. var animationRotationKeys = [];
  17487. animationRotationKeys.push({
  17488. frame: 0,
  17489. value: this.currentVRCamera.rotationQuaternion
  17490. });
  17491. animationRotationKeys.push({
  17492. frame: 6,
  17493. value: target
  17494. });
  17495. animationRotation.setKeys(animationRotationKeys);
  17496. animationRotation.setEasingFunction(this._circleEase);
  17497. this.currentVRCamera.animations.push(animationRotation);
  17498. this._postProcessMove.animations = [];
  17499. 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);
  17500. var vignetteWeightKeys = [];
  17501. vignetteWeightKeys.push({
  17502. frame: 0,
  17503. value: 0
  17504. });
  17505. vignetteWeightKeys.push({
  17506. frame: 3,
  17507. value: 4
  17508. });
  17509. vignetteWeightKeys.push({
  17510. frame: 6,
  17511. value: 0
  17512. });
  17513. animationPP.setKeys(vignetteWeightKeys);
  17514. animationPP.setEasingFunction(this._circleEase);
  17515. this._postProcessMove.animations.push(animationPP);
  17516. 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);
  17517. var vignetteStretchKeys = [];
  17518. vignetteStretchKeys.push({
  17519. frame: 0,
  17520. value: 0
  17521. });
  17522. vignetteStretchKeys.push({
  17523. frame: 3,
  17524. value: 10
  17525. });
  17526. vignetteStretchKeys.push({
  17527. frame: 6,
  17528. value: 0
  17529. });
  17530. animationPP2.setKeys(vignetteStretchKeys);
  17531. animationPP2.setEasingFunction(this._circleEase);
  17532. this._postProcessMove.animations.push(animationPP2);
  17533. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17534. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17535. this._postProcessMove.samples = 4;
  17536. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17537. this._scene.beginAnimation(this._postProcessMove, 0, 6, false, 1, function () {
  17538. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17539. });
  17540. this._scene.beginAnimation(this.currentVRCamera, 0, 6, false, 1);
  17541. };
  17542. VRExperienceHelper.prototype._moveTeleportationSelectorTo = function (hit, gazer, ray) {
  17543. if (hit.pickedPoint) {
  17544. if (gazer._teleportationRequestInitiated) {
  17545. this._displayTeleportationTarget();
  17546. this._haloCenter.copyFrom(hit.pickedPoint);
  17547. this._teleportationTarget.position.copyFrom(hit.pickedPoint);
  17548. }
  17549. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(true, false), ray);
  17550. if (pickNormal) {
  17551. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17552. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17553. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, this._teleportationTarget.rotation);
  17554. }
  17555. this._teleportationTarget.position.y += 0.1;
  17556. }
  17557. };
  17558. /**
  17559. * Teleports the users feet to the desired location
  17560. * @param location The location where the user's feet should be placed
  17561. */
  17562. VRExperienceHelper.prototype.teleportCamera = function (location) {
  17563. var _this = this;
  17564. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17565. return;
  17566. }
  17567. // Teleport the hmd to where the user is looking by moving the anchor to where they are looking minus the
  17568. // offset of the headset from the anchor.
  17569. if (this.webVRCamera.leftCamera) {
  17570. this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition);
  17571. this._workingVector.subtractInPlace(this.webVRCamera.position);
  17572. location.subtractToRef(this._workingVector, this._workingVector);
  17573. }
  17574. else {
  17575. this._workingVector.copyFrom(location);
  17576. }
  17577. // Add height to account for user's height offset
  17578. if (this.isInVRMode) {
  17579. this._workingVector.y += this.webVRCamera.deviceDistanceToRoomGround() * this._webVRCamera.deviceScaleFactor;
  17580. }
  17581. else {
  17582. this._workingVector.y += this._defaultHeight;
  17583. }
  17584. this.onBeforeCameraTeleport.notifyObservers(this._workingVector);
  17585. // Create animation from the camera's position to the new location
  17586. this.currentVRCamera.animations = [];
  17587. 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);
  17588. var animationCameraTeleportationKeys = [{
  17589. frame: 0,
  17590. value: this.currentVRCamera.position
  17591. },
  17592. {
  17593. frame: 11,
  17594. value: this._workingVector
  17595. }
  17596. ];
  17597. animationCameraTeleportation.setKeys(animationCameraTeleportationKeys);
  17598. animationCameraTeleportation.setEasingFunction(this._circleEase);
  17599. this.currentVRCamera.animations.push(animationCameraTeleportation);
  17600. this._postProcessMove.animations = [];
  17601. 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);
  17602. var vignetteWeightKeys = [];
  17603. vignetteWeightKeys.push({
  17604. frame: 0,
  17605. value: 0
  17606. });
  17607. vignetteWeightKeys.push({
  17608. frame: 5,
  17609. value: 8
  17610. });
  17611. vignetteWeightKeys.push({
  17612. frame: 11,
  17613. value: 0
  17614. });
  17615. animationPP.setKeys(vignetteWeightKeys);
  17616. this._postProcessMove.animations.push(animationPP);
  17617. 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);
  17618. var vignetteStretchKeys = [];
  17619. vignetteStretchKeys.push({
  17620. frame: 0,
  17621. value: 0
  17622. });
  17623. vignetteStretchKeys.push({
  17624. frame: 5,
  17625. value: 10
  17626. });
  17627. vignetteStretchKeys.push({
  17628. frame: 11,
  17629. value: 0
  17630. });
  17631. animationPP2.setKeys(vignetteStretchKeys);
  17632. this._postProcessMove.animations.push(animationPP2);
  17633. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17634. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17635. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17636. this._scene.beginAnimation(this._postProcessMove, 0, 11, false, 1, function () {
  17637. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17638. });
  17639. this._scene.beginAnimation(this.currentVRCamera, 0, 11, false, 1, function () {
  17640. _this.onAfterCameraTeleport.notifyObservers(_this._workingVector);
  17641. });
  17642. this._hideTeleportationTarget();
  17643. };
  17644. VRExperienceHelper.prototype._convertNormalToDirectionOfRay = function (normal, ray) {
  17645. if (normal) {
  17646. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Dot(normal, ray.direction));
  17647. if (angle < Math.PI / 2) {
  17648. normal.scaleInPlace(-1);
  17649. }
  17650. }
  17651. return normal;
  17652. };
  17653. VRExperienceHelper.prototype._castRayAndSelectObject = function (gazer) {
  17654. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17655. return;
  17656. }
  17657. var ray = gazer._getForwardRay(this._rayLength);
  17658. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  17659. if (hit) {
  17660. // Populate the contrllers mesh that can be used for drag/drop
  17661. if (gazer._laserPointer) {
  17662. hit.originMesh = gazer._laserPointer.parent;
  17663. }
  17664. this._scene.simulatePointerMove(hit, { pointerId: gazer._id });
  17665. }
  17666. gazer._currentHit = hit;
  17667. // Moving the gazeTracker on the mesh face targetted
  17668. if (hit && hit.pickedPoint) {
  17669. if (this._displayGaze) {
  17670. var multiplier = 1;
  17671. gazer._gazeTracker.isVisible = true;
  17672. if (gazer._isActionableMesh) {
  17673. multiplier = 3;
  17674. }
  17675. if (this.updateGazeTrackerScale) {
  17676. gazer._gazeTracker.scaling.x = hit.distance * multiplier;
  17677. gazer._gazeTracker.scaling.y = hit.distance * multiplier;
  17678. gazer._gazeTracker.scaling.z = hit.distance * multiplier;
  17679. }
  17680. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(), ray);
  17681. // To avoid z-fighting
  17682. var deltaFighting = 0.002;
  17683. if (pickNormal) {
  17684. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17685. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17686. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, gazer._gazeTracker.rotation);
  17687. }
  17688. gazer._gazeTracker.position.copyFrom(hit.pickedPoint);
  17689. if (gazer._gazeTracker.position.x < 0) {
  17690. gazer._gazeTracker.position.x += deltaFighting;
  17691. }
  17692. else {
  17693. gazer._gazeTracker.position.x -= deltaFighting;
  17694. }
  17695. if (gazer._gazeTracker.position.y < 0) {
  17696. gazer._gazeTracker.position.y += deltaFighting;
  17697. }
  17698. else {
  17699. gazer._gazeTracker.position.y -= deltaFighting;
  17700. }
  17701. if (gazer._gazeTracker.position.z < 0) {
  17702. gazer._gazeTracker.position.z += deltaFighting;
  17703. }
  17704. else {
  17705. gazer._gazeTracker.position.z -= deltaFighting;
  17706. }
  17707. }
  17708. // Changing the size of the laser pointer based on the distance from the targetted point
  17709. gazer._updatePointerDistance(hit.distance);
  17710. }
  17711. else {
  17712. gazer._updatePointerDistance();
  17713. gazer._gazeTracker.isVisible = false;
  17714. }
  17715. if (hit && hit.pickedMesh) {
  17716. // The object selected is the floor, we're in a teleportation scenario
  17717. if (this._teleportationInitialized && this._isTeleportationFloor(hit.pickedMesh) && hit.pickedPoint) {
  17718. // Moving the teleportation area to this targetted point
  17719. //Raise onSelectedMeshUnselected observable if ray collided floor mesh/meshes and a non floor mesh was previously selected
  17720. if (gazer._currentMeshSelected && !this._isTeleportationFloor(gazer._currentMeshSelected)) {
  17721. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17722. }
  17723. gazer._currentMeshSelected = null;
  17724. if (gazer._teleportationRequestInitiated) {
  17725. this._moveTeleportationSelectorTo(hit, gazer, ray);
  17726. }
  17727. return;
  17728. }
  17729. // If not, we're in a selection scenario
  17730. //this._teleportationAllowed = false;
  17731. if (hit.pickedMesh !== gazer._currentMeshSelected) {
  17732. if (this.meshSelectionPredicate(hit.pickedMesh)) {
  17733. this.onNewMeshPicked.notifyObservers(hit);
  17734. gazer._currentMeshSelected = hit.pickedMesh;
  17735. if (hit.pickedMesh.isPickable && hit.pickedMesh.actionManager) {
  17736. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0, 0, 1));
  17737. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.2, 0.2, 1));
  17738. gazer._isActionableMesh = true;
  17739. }
  17740. else {
  17741. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17742. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17743. gazer._isActionableMesh = false;
  17744. }
  17745. try {
  17746. this.onNewMeshSelected.notifyObservers(hit.pickedMesh);
  17747. }
  17748. catch (err) {
  17749. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onNewMeshSelected: " + err);
  17750. }
  17751. }
  17752. else {
  17753. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17754. gazer._currentMeshSelected = null;
  17755. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17756. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17757. }
  17758. }
  17759. }
  17760. else {
  17761. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17762. gazer._currentMeshSelected = null;
  17763. //this._teleportationAllowed = false;
  17764. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17765. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17766. }
  17767. };
  17768. VRExperienceHelper.prototype._notifySelectedMeshUnselected = function (mesh) {
  17769. if (mesh) {
  17770. this.onSelectedMeshUnselected.notifyObservers(mesh);
  17771. }
  17772. };
  17773. /**
  17774. * Sets the color of the laser ray from the vr controllers.
  17775. * @param color new color for the ray.
  17776. */
  17777. VRExperienceHelper.prototype.changeLaserColor = function (color) {
  17778. if (this._leftController) {
  17779. this._leftController._setLaserPointerColor(color);
  17780. }
  17781. if (this._rightController) {
  17782. this._rightController._setLaserPointerColor(color);
  17783. }
  17784. };
  17785. /**
  17786. * Sets the color of the ray from the vr headsets gaze.
  17787. * @param color new color for the ray.
  17788. */
  17789. VRExperienceHelper.prototype.changeGazeColor = function (color) {
  17790. if (!this.updateGazeTrackerColor) {
  17791. return;
  17792. }
  17793. if (!this._cameraGazer._gazeTracker.material) {
  17794. return;
  17795. }
  17796. this._cameraGazer._gazeTracker.material.emissiveColor = color;
  17797. if (this._leftController) {
  17798. this._leftController._gazeTracker.material.emissiveColor = color;
  17799. }
  17800. if (this._rightController) {
  17801. this._rightController._gazeTracker.material.emissiveColor = color;
  17802. }
  17803. };
  17804. /**
  17805. * Exits VR and disposes of the vr experience helper
  17806. */
  17807. VRExperienceHelper.prototype.dispose = function () {
  17808. if (this.isInVRMode) {
  17809. this.exitVR();
  17810. }
  17811. if (this._postProcessMove) {
  17812. this._postProcessMove.dispose();
  17813. }
  17814. if (this._webVRCamera) {
  17815. this._webVRCamera.dispose();
  17816. }
  17817. if (this._vrDeviceOrientationCamera) {
  17818. this._vrDeviceOrientationCamera.dispose();
  17819. }
  17820. if (!this._useCustomVRButton && this._btnVR.parentNode) {
  17821. document.body.removeChild(this._btnVR);
  17822. }
  17823. if (this._deviceOrientationCamera && (this._scene.activeCamera != this._deviceOrientationCamera)) {
  17824. this._deviceOrientationCamera.dispose();
  17825. }
  17826. if (this._cameraGazer) {
  17827. this._cameraGazer.dispose();
  17828. }
  17829. if (this._leftController) {
  17830. this._leftController.dispose();
  17831. }
  17832. if (this._rightController) {
  17833. this._rightController.dispose();
  17834. }
  17835. if (this._teleportationTarget) {
  17836. this._teleportationTarget.dispose();
  17837. }
  17838. this._floorMeshesCollection = [];
  17839. document.removeEventListener("keydown", this._onKeyDown);
  17840. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17841. window.removeEventListener("resize", this._onResize);
  17842. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  17843. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  17844. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  17845. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  17846. document.onmsfullscreenchange = null;
  17847. this._scene.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChanged);
  17848. this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart);
  17849. this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete);
  17850. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17851. this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected);
  17852. this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected);
  17853. this._scene.unregisterBeforeRender(this.beforeRender);
  17854. };
  17855. /**
  17856. * Gets the name of the VRExperienceHelper class
  17857. * @returns "VRExperienceHelper"
  17858. */
  17859. VRExperienceHelper.prototype.getClassName = function () {
  17860. return "VRExperienceHelper";
  17861. };
  17862. return VRExperienceHelper;
  17863. }());
  17864. /***/ }),
  17865. /***/ "./Cameras/VR/webVRCamera.ts":
  17866. /*!***********************************!*\
  17867. !*** ./Cameras/VR/webVRCamera.ts ***!
  17868. \***********************************/
  17869. /*! exports provided: WebVRFreeCamera */
  17870. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17871. "use strict";
  17872. __webpack_require__.r(__webpack_exports__);
  17873. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return WebVRFreeCamera; });
  17874. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  17875. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  17876. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  17877. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  17878. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  17879. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  17880. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  17881. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../node */ "./node.ts");
  17882. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  17883. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  17884. /* harmony import */ var _PostProcesses_vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../PostProcesses/vrMultiviewToSingleviewPostProcess */ "./PostProcesses/vrMultiviewToSingleviewPostProcess.ts");
  17885. /* harmony import */ var _RigModes_webVRRigMode__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../RigModes/webVRRigMode */ "./Cameras/RigModes/webVRRigMode.ts");
  17886. // Side effect import to define the stereoscopic mode.
  17887. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRFreeCamera", function (name, scene) {
  17888. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17889. });
  17890. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRGamepadCamera", function (name, scene) {
  17891. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17892. });
  17893. /**
  17894. * This represents a WebVR camera.
  17895. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  17896. * @example http://doc.babylonjs.com/how_to/webvr_camera
  17897. */
  17898. var WebVRFreeCamera = /** @class */ (function (_super) {
  17899. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRFreeCamera, _super);
  17900. /**
  17901. * Instantiates a WebVRFreeCamera.
  17902. * @param name The name of the WebVRFreeCamera
  17903. * @param position The starting anchor position for the camera
  17904. * @param scene The scene the camera belongs to
  17905. * @param webVROptions a set of customizable options for the webVRCamera
  17906. */
  17907. function WebVRFreeCamera(name, position, scene, webVROptions) {
  17908. if (webVROptions === void 0) { webVROptions = {}; }
  17909. var _this = _super.call(this, name, position, scene) || this;
  17910. _this.webVROptions = webVROptions;
  17911. /**
  17912. * @hidden
  17913. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  17914. */
  17915. _this._vrDevice = null;
  17916. /**
  17917. * The rawPose of the vrDevice.
  17918. */
  17919. _this.rawPose = null;
  17920. _this._specsVersion = "1.1";
  17921. _this._attached = false;
  17922. _this._descendants = [];
  17923. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  17924. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17925. /** @hidden */
  17926. _this._deviceRoomRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17927. _this._standingMatrix = null;
  17928. /**
  17929. * Represents device position in babylon space.
  17930. */
  17931. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17932. /**
  17933. * Represents device rotation in babylon space.
  17934. */
  17935. _this.deviceRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17936. /**
  17937. * The scale of the device to be used when translating from device space to babylon space.
  17938. */
  17939. _this.deviceScaleFactor = 1;
  17940. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17941. _this._worldToDevice = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17942. /**
  17943. * References to the webVR controllers for the vrDevice.
  17944. */
  17945. _this.controllers = [];
  17946. /**
  17947. * Emits an event when a controller is attached.
  17948. */
  17949. _this.onControllersAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17950. /**
  17951. * Emits an event when a controller's mesh has been loaded;
  17952. */
  17953. _this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17954. /**
  17955. * Emits an event when the HMD's pose has been updated.
  17956. */
  17957. _this.onPoseUpdatedFromDeviceObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17958. _this._poseSet = false;
  17959. /**
  17960. * If the rig cameras be used as parent instead of this camera.
  17961. */
  17962. _this.rigParenting = true;
  17963. _this._defaultHeight = undefined;
  17964. _this._htmlElementAttached = null;
  17965. _this._detachIfAttached = function () {
  17966. var vrDisplay = _this.getEngine().getVRDevice();
  17967. if (vrDisplay && !vrDisplay.isPresenting && _this._htmlElementAttached) {
  17968. _this.detachControl(_this._htmlElementAttached);
  17969. }
  17970. };
  17971. _this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17972. _this._oneVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].One();
  17973. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17974. _this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  17975. _this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17976. if (webVROptions.defaultHeight) {
  17977. _this._defaultHeight = webVROptions.defaultHeight;
  17978. _this.position.y = _this._defaultHeight;
  17979. }
  17980. _this.minZ = 0.1;
  17981. //legacy support - the compensation boolean was removed.
  17982. if (arguments.length === 5) {
  17983. _this.webVROptions = arguments[4];
  17984. }
  17985. // default webVR options
  17986. if (_this.webVROptions.trackPosition == undefined) {
  17987. _this.webVROptions.trackPosition = true;
  17988. }
  17989. if (_this.webVROptions.controllerMeshes == undefined) {
  17990. _this.webVROptions.controllerMeshes = true;
  17991. }
  17992. if (_this.webVROptions.defaultLightingOnControllers == undefined) {
  17993. _this.webVROptions.defaultLightingOnControllers = true;
  17994. }
  17995. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]();
  17996. if (_this.webVROptions && _this.webVROptions.positionScale) {
  17997. _this.deviceScaleFactor = _this.webVROptions.positionScale;
  17998. }
  17999. //enable VR
  18000. var engine = _this.getEngine();
  18001. _this._onVREnabled = function (success) { if (success) {
  18002. _this.initControllers();
  18003. } };
  18004. engine.onVRRequestPresentComplete.add(_this._onVREnabled);
  18005. engine.initWebVR().add(function (event) {
  18006. if (!event.vrDisplay || _this._vrDevice === event.vrDisplay) {
  18007. return;
  18008. }
  18009. _this._vrDevice = event.vrDisplay;
  18010. //reset the rig parameters.
  18011. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].RIG_MODE_WEBVR, { parentCamera: _this, vrDisplay: _this._vrDevice, frameData: _this._frameData, specs: _this._specsVersion });
  18012. if (_this._attached) {
  18013. _this.getEngine().enableVR();
  18014. }
  18015. });
  18016. if (typeof (VRFrameData) !== "undefined") {
  18017. _this._frameData = new VRFrameData();
  18018. }
  18019. if (webVROptions.useMultiview) {
  18020. if (!_this.getScene().getEngine().getCaps().multiview) {
  18021. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn("Multiview is not supported, falling back to standard rendering");
  18022. _this._useMultiviewToSingleView = false;
  18023. }
  18024. else {
  18025. _this._useMultiviewToSingleView = true;
  18026. _this._rigPostProcess = new _PostProcesses_vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_10__["VRMultiviewToSingleviewPostProcess"]("VRMultiviewToSingleview", _this, 1.0);
  18027. }
  18028. }
  18029. /**
  18030. * The idea behind the following lines:
  18031. * objects that have the camera as parent should actually have the rig cameras as a parent.
  18032. * BUT, each of those cameras has a different view matrix, which means that if we set the parent to the first rig camera,
  18033. * the second will not show it correctly.
  18034. *
  18035. * To solve this - each object that has the camera as parent will be added to a protected array.
  18036. * When the rig camera renders, it will take this array and set all of those to be its children.
  18037. * This way, the right camera will be used as a parent, and the mesh will be rendered correctly.
  18038. * Amazing!
  18039. */
  18040. scene.onBeforeCameraRenderObservable.add(function (camera) {
  18041. if (camera.parent === _this && _this.rigParenting) {
  18042. _this._descendants = _this.getDescendants(true, function (n) {
  18043. // don't take the cameras or the controllers!
  18044. var isController = _this.controllers.some(function (controller) { return controller._mesh === n; });
  18045. var isRigCamera = _this._rigCameras.indexOf(n) !== -1;
  18046. return !isController && !isRigCamera;
  18047. });
  18048. _this._descendants.forEach(function (node) {
  18049. node.parent = camera;
  18050. });
  18051. }
  18052. });
  18053. scene.onAfterCameraRenderObservable.add(function (camera) {
  18054. if (camera.parent === _this && _this.rigParenting) {
  18055. _this._descendants.forEach(function (node) {
  18056. node.parent = _this;
  18057. });
  18058. }
  18059. });
  18060. return _this;
  18061. }
  18062. /**
  18063. * Gets the device distance from the ground in meters.
  18064. * @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.
  18065. */
  18066. WebVRFreeCamera.prototype.deviceDistanceToRoomGround = function () {
  18067. if (this._standingMatrix) {
  18068. // Add standing matrix offset to get real offset from ground in room
  18069. this._standingMatrix.getTranslationToRef(this._workingVector);
  18070. return this._deviceRoomPosition.y + this._workingVector.y;
  18071. }
  18072. //If VRDisplay does not inform stage parameters and no default height is set we fallback to zero.
  18073. return this._defaultHeight || 0;
  18074. };
  18075. /**
  18076. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18077. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  18078. */
  18079. WebVRFreeCamera.prototype.useStandingMatrix = function (callback) {
  18080. var _this = this;
  18081. if (callback === void 0) { callback = function (bool) { }; }
  18082. // Use standing matrix if available
  18083. this.getEngine().initWebVRAsync().then(function (result) {
  18084. if (!result.vrDisplay || !result.vrDisplay.stageParameters || !result.vrDisplay.stageParameters.sittingToStandingTransform || !_this.webVROptions.trackPosition) {
  18085. callback(false);
  18086. }
  18087. else {
  18088. _this._standingMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  18089. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromFloat32ArrayToRefScaled(result.vrDisplay.stageParameters.sittingToStandingTransform, 0, 1, _this._standingMatrix);
  18090. if (!_this.getScene().useRightHandedSystem) {
  18091. if (_this._standingMatrix) {
  18092. _this._standingMatrix.toggleModelMatrixHandInPlace();
  18093. }
  18094. }
  18095. callback(true);
  18096. }
  18097. });
  18098. };
  18099. /**
  18100. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18101. * @returns A promise with a boolean set to if the standing matrix is supported.
  18102. */
  18103. WebVRFreeCamera.prototype.useStandingMatrixAsync = function () {
  18104. var _this = this;
  18105. return new Promise(function (res) {
  18106. _this.useStandingMatrix(function (supported) {
  18107. res(supported);
  18108. });
  18109. });
  18110. };
  18111. /**
  18112. * Disposes the camera
  18113. */
  18114. WebVRFreeCamera.prototype.dispose = function () {
  18115. this._detachIfAttached();
  18116. this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled);
  18117. if (this._updateCacheWhenTrackingDisabledObserver) {
  18118. this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver);
  18119. }
  18120. _super.prototype.dispose.call(this);
  18121. };
  18122. /**
  18123. * Gets a vrController by name.
  18124. * @param name The name of the controller to retreive
  18125. * @returns the controller matching the name specified or null if not found
  18126. */
  18127. WebVRFreeCamera.prototype.getControllerByName = function (name) {
  18128. for (var _i = 0, _a = this.controllers; _i < _a.length; _i++) {
  18129. var gp = _a[_i];
  18130. if (gp.hand === name) {
  18131. return gp;
  18132. }
  18133. }
  18134. return null;
  18135. };
  18136. Object.defineProperty(WebVRFreeCamera.prototype, "leftController", {
  18137. /**
  18138. * The controller corrisponding to the users left hand.
  18139. */
  18140. get: function () {
  18141. if (!this._leftController) {
  18142. this._leftController = this.getControllerByName("left");
  18143. }
  18144. return this._leftController;
  18145. },
  18146. enumerable: true,
  18147. configurable: true
  18148. });
  18149. Object.defineProperty(WebVRFreeCamera.prototype, "rightController", {
  18150. /**
  18151. * The controller corrisponding to the users right hand.
  18152. */
  18153. get: function () {
  18154. if (!this._rightController) {
  18155. this._rightController = this.getControllerByName("right");
  18156. }
  18157. return this._rightController;
  18158. },
  18159. enumerable: true,
  18160. configurable: true
  18161. });
  18162. /**
  18163. * Casts a ray forward from the vrCamera's gaze.
  18164. * @param length Length of the ray (default: 100)
  18165. * @returns the ray corrisponding to the gaze
  18166. */
  18167. WebVRFreeCamera.prototype.getForwardRay = function (length) {
  18168. if (length === void 0) { length = 100; }
  18169. if (this.leftCamera) {
  18170. // Use left eye to avoid computation to compute center on every call
  18171. return _super.prototype.getForwardRay.call(this, length, this.leftCamera.getWorldMatrix(), this.leftCamera.globalPosition); // Need the actual rendered camera
  18172. }
  18173. else {
  18174. return _super.prototype.getForwardRay.call(this, length);
  18175. }
  18176. };
  18177. /**
  18178. * @hidden
  18179. * Updates the camera based on device's frame data
  18180. */
  18181. WebVRFreeCamera.prototype._checkInputs = function () {
  18182. if (this._vrDevice && this._vrDevice.isPresenting) {
  18183. this._vrDevice.getFrameData(this._frameData);
  18184. this.updateFromDevice(this._frameData.pose);
  18185. }
  18186. _super.prototype._checkInputs.call(this);
  18187. };
  18188. /**
  18189. * Updates the poseControlled values based on the input device pose.
  18190. * @param poseData Pose coming from the device
  18191. */
  18192. WebVRFreeCamera.prototype.updateFromDevice = function (poseData) {
  18193. if (poseData && poseData.orientation) {
  18194. this.rawPose = poseData;
  18195. this._deviceRoomRotationQuaternion.copyFromFloats(poseData.orientation[0], poseData.orientation[1], -poseData.orientation[2], -poseData.orientation[3]);
  18196. if (this.getScene().useRightHandedSystem) {
  18197. this._deviceRoomRotationQuaternion.z *= -1;
  18198. this._deviceRoomRotationQuaternion.w *= -1;
  18199. }
  18200. if (this.webVROptions.trackPosition && this.rawPose.position) {
  18201. this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2]);
  18202. if (this.getScene().useRightHandedSystem) {
  18203. this._deviceRoomPosition.z *= -1;
  18204. }
  18205. }
  18206. this._poseSet = true;
  18207. }
  18208. };
  18209. /**
  18210. * WebVR's attach control will start broadcasting frames to the device.
  18211. * Note that in certain browsers (chrome for example) this function must be called
  18212. * within a user-interaction callback. Example:
  18213. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  18214. *
  18215. * @param element html element to attach the vrDevice to
  18216. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  18217. */
  18218. WebVRFreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  18219. _super.prototype.attachControl.call(this, element, noPreventDefault);
  18220. this._attached = true;
  18221. this._htmlElementAttached = element;
  18222. noPreventDefault = _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  18223. if (this._vrDevice) {
  18224. this.getEngine().enableVR();
  18225. }
  18226. window.addEventListener('vrdisplaypresentchange', this._detachIfAttached);
  18227. };
  18228. /**
  18229. * Detaches the camera from the html element and disables VR
  18230. *
  18231. * @param element html element to detach from
  18232. */
  18233. WebVRFreeCamera.prototype.detachControl = function (element) {
  18234. this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  18235. this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  18236. _super.prototype.detachControl.call(this, element);
  18237. this._attached = false;
  18238. this.getEngine().disableVR();
  18239. window.removeEventListener('vrdisplaypresentchange', this._detachIfAttached);
  18240. };
  18241. /**
  18242. * @returns the name of this class
  18243. */
  18244. WebVRFreeCamera.prototype.getClassName = function () {
  18245. return "WebVRFreeCamera";
  18246. };
  18247. /**
  18248. * Calls resetPose on the vrDisplay
  18249. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  18250. */
  18251. WebVRFreeCamera.prototype.resetToCurrentRotation = function () {
  18252. //uses the vrDisplay's "resetPose()".
  18253. //pitch and roll won't be affected.
  18254. this._vrDevice.resetPose();
  18255. };
  18256. /**
  18257. * @hidden
  18258. * Updates the rig cameras (left and right eye)
  18259. */
  18260. WebVRFreeCamera.prototype._updateRigCameras = function () {
  18261. var camLeft = this._rigCameras[0];
  18262. var camRight = this._rigCameras[1];
  18263. camLeft.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  18264. camRight.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  18265. camLeft.position.copyFrom(this._deviceRoomPosition);
  18266. camRight.position.copyFrom(this._deviceRoomPosition);
  18267. };
  18268. // Remove translation from 6dof headset if trackposition is set to false
  18269. WebVRFreeCamera.prototype._correctPositionIfNotTrackPosition = function (matrix, isViewMatrix) {
  18270. if (isViewMatrix === void 0) { isViewMatrix = false; }
  18271. if (this.rawPose && this.rawPose.position && !this.webVROptions.trackPosition) {
  18272. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2], this._tmpMatrix);
  18273. if (!isViewMatrix) {
  18274. this._tmpMatrix.invert();
  18275. }
  18276. this._tmpMatrix.multiplyToRef(matrix, matrix);
  18277. }
  18278. };
  18279. /**
  18280. * @hidden
  18281. * Updates the cached values of the camera
  18282. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  18283. */
  18284. WebVRFreeCamera.prototype._updateCache = function (ignoreParentClass) {
  18285. var _this = this;
  18286. if (!this.rotationQuaternion.equals(this._cache.rotationQuaternion) || !this.position.equals(this._cache.position)) {
  18287. // Update to ensure devicePosition is up to date with most recent _deviceRoomPosition
  18288. if (!this.updateCacheCalled) {
  18289. // make sure it is only called once per loop. this.update() might cause an infinite loop.
  18290. this.updateCacheCalled = true;
  18291. this.update();
  18292. }
  18293. // Set working vector to the device position in room space rotated by the new rotation
  18294. this.rotationQuaternion.toRotationMatrix(this._workingMatrix);
  18295. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._workingMatrix, this._workingVector);
  18296. // Subtract this vector from the current device position in world to get the translation for the device world matrix
  18297. this.devicePosition.subtractToRef(this._workingVector, this._workingVector);
  18298. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(this._oneVector, this.rotationQuaternion, this._workingVector, this._deviceToWorld);
  18299. // Add translation from anchor position
  18300. this._deviceToWorld.getTranslationToRef(this._workingVector);
  18301. this._workingVector.addInPlace(this.position);
  18302. this._workingVector.subtractInPlace(this._cache.position);
  18303. this._deviceToWorld.setTranslation(this._workingVector);
  18304. // Set an inverted matrix to be used when updating the camera
  18305. this._deviceToWorld.invertToRef(this._worldToDevice);
  18306. // Update the gamepad to ensure the mesh is updated on the same frame as camera
  18307. this.controllers.forEach(function (controller) {
  18308. controller._deviceToWorld.copyFrom(_this._deviceToWorld);
  18309. _this._correctPositionIfNotTrackPosition(controller._deviceToWorld);
  18310. controller.update();
  18311. });
  18312. }
  18313. if (!ignoreParentClass) {
  18314. _super.prototype._updateCache.call(this);
  18315. }
  18316. this.updateCacheCalled = false;
  18317. };
  18318. /**
  18319. * @hidden
  18320. * Get current device position in babylon world
  18321. */
  18322. WebVRFreeCamera.prototype._computeDevicePosition = function () {
  18323. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition);
  18324. };
  18325. /**
  18326. * Updates the current device position and rotation in the babylon world
  18327. */
  18328. WebVRFreeCamera.prototype.update = function () {
  18329. this._computeDevicePosition();
  18330. // Get current device rotation in babylon world
  18331. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix);
  18332. this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix);
  18333. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  18334. if (this._poseSet) {
  18335. this.onPoseUpdatedFromDeviceObservable.notifyObservers(null);
  18336. }
  18337. _super.prototype.update.call(this);
  18338. };
  18339. /**
  18340. * @hidden
  18341. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  18342. * @returns an identity matrix
  18343. */
  18344. WebVRFreeCamera.prototype._getViewMatrix = function () {
  18345. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18346. };
  18347. /**
  18348. * This function is called by the two RIG cameras.
  18349. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  18350. * @hidden
  18351. */
  18352. WebVRFreeCamera.prototype._getWebVRViewMatrix = function () {
  18353. // Update the parent camera prior to using a child camera to avoid desynchronization
  18354. var parentCamera = this._cameraRigParams["parentCamera"];
  18355. parentCamera._updateCache();
  18356. //WebVR 1.1
  18357. var viewArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftViewMatrix : this._cameraRigParams["frameData"].rightViewMatrix;
  18358. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(viewArray, 0, this._webvrViewMatrix);
  18359. if (!this.getScene().useRightHandedSystem) {
  18360. this._webvrViewMatrix.toggleModelMatrixHandInPlace();
  18361. }
  18362. // update the camera rotation matrix
  18363. this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix);
  18364. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  18365. // Computing target and final matrix
  18366. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  18367. // should the view matrix be updated with scale and position offset?
  18368. if (parentCamera.deviceScaleFactor !== 1) {
  18369. this._webvrViewMatrix.invert();
  18370. // scale the position, if set
  18371. if (parentCamera.deviceScaleFactor) {
  18372. this._webvrViewMatrix.multiplyAtIndex(12, parentCamera.deviceScaleFactor);
  18373. this._webvrViewMatrix.multiplyAtIndex(13, parentCamera.deviceScaleFactor);
  18374. this._webvrViewMatrix.multiplyAtIndex(14, parentCamera.deviceScaleFactor);
  18375. }
  18376. this._webvrViewMatrix.invert();
  18377. }
  18378. // Remove translation from 6dof headset if trackposition is set to false
  18379. parentCamera._correctPositionIfNotTrackPosition(this._webvrViewMatrix, true);
  18380. parentCamera._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
  18381. // Compute global position
  18382. this._workingMatrix = this._workingMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18383. this._webvrViewMatrix.invertToRef(this._workingMatrix);
  18384. this._workingMatrix.multiplyToRef(parentCamera.getWorldMatrix(), this._workingMatrix);
  18385. this._workingMatrix.getTranslationToRef(this._globalPosition);
  18386. this._markSyncedWithParent();
  18387. return this._webvrViewMatrix;
  18388. };
  18389. /** @hidden */
  18390. WebVRFreeCamera.prototype._getWebVRProjectionMatrix = function () {
  18391. var parentCamera = this.parent;
  18392. parentCamera._vrDevice.depthNear = parentCamera.minZ;
  18393. parentCamera._vrDevice.depthFar = parentCamera.maxZ;
  18394. var projectionArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftProjectionMatrix : this._cameraRigParams["frameData"].rightProjectionMatrix;
  18395. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(projectionArray, 0, this._projectionMatrix);
  18396. //babylon compatible matrix
  18397. if (!this.getScene().useRightHandedSystem) {
  18398. this._projectionMatrix.toggleProjectionMatrixHandInPlace();
  18399. }
  18400. return this._projectionMatrix;
  18401. };
  18402. /**
  18403. * Initializes the controllers and their meshes
  18404. */
  18405. WebVRFreeCamera.prototype.initControllers = function () {
  18406. var _this = this;
  18407. this.controllers = [];
  18408. var manager = this.getScene().gamepadManager;
  18409. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  18410. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  18411. var webVrController = gamepad;
  18412. if (webVrController.defaultModel) {
  18413. webVrController.defaultModel.setEnabled(false);
  18414. }
  18415. if (webVrController.hand === "right") {
  18416. _this._rightController = null;
  18417. }
  18418. if (webVrController.hand === "left") {
  18419. _this._leftController = null;
  18420. }
  18421. var controllerIndex = _this.controllers.indexOf(webVrController);
  18422. if (controllerIndex !== -1) {
  18423. _this.controllers.splice(controllerIndex, 1);
  18424. }
  18425. }
  18426. });
  18427. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  18428. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  18429. var webVrController_1 = gamepad;
  18430. if (!_this.webVROptions.trackPosition) {
  18431. webVrController_1._disableTrackPosition(new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](webVrController_1.hand == "left" ? -0.15 : 0.15, -0.5, 0.25));
  18432. // Cache must be updated before rendering controllers to avoid them being one frame behind
  18433. if (!_this._updateCacheWhenTrackingDisabledObserver) {
  18434. _this._updateCacheWhenTrackingDisabledObserver = _this._scene.onBeforeRenderObservable.add(function () {
  18435. _this._updateCache();
  18436. });
  18437. }
  18438. }
  18439. webVrController_1.deviceScaleFactor = _this.deviceScaleFactor;
  18440. webVrController_1._deviceToWorld.copyFrom(_this._deviceToWorld);
  18441. _this._correctPositionIfNotTrackPosition(webVrController_1._deviceToWorld);
  18442. if (_this.webVROptions.controllerMeshes) {
  18443. if (webVrController_1.defaultModel) {
  18444. webVrController_1.defaultModel.setEnabled(true);
  18445. }
  18446. else {
  18447. // Load the meshes
  18448. webVrController_1.initControllerMesh(_this.getScene(), function (loadedMesh) {
  18449. loadedMesh.scaling.scaleInPlace(_this.deviceScaleFactor);
  18450. _this.onControllerMeshLoadedObservable.notifyObservers(webVrController_1);
  18451. if (_this.webVROptions.defaultLightingOnControllers) {
  18452. if (!_this._lightOnControllers) {
  18453. _this._lightOnControllers = new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__["HemisphericLight"]("vrControllersLight", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 1, 0), _this.getScene());
  18454. }
  18455. var activateLightOnSubMeshes_1 = function (mesh, light) {
  18456. var children = mesh.getChildren();
  18457. if (children && children.length !== 0) {
  18458. children.forEach(function (mesh) {
  18459. light.includedOnlyMeshes.push(mesh);
  18460. activateLightOnSubMeshes_1(mesh, light);
  18461. });
  18462. }
  18463. };
  18464. _this._lightOnControllers.includedOnlyMeshes.push(loadedMesh);
  18465. activateLightOnSubMeshes_1(loadedMesh, _this._lightOnControllers);
  18466. }
  18467. });
  18468. }
  18469. }
  18470. webVrController_1.attachToPoseControlledCamera(_this);
  18471. // since this is async - sanity check. Is the controller already stored?
  18472. if (_this.controllers.indexOf(webVrController_1) === -1) {
  18473. //add to the controllers array
  18474. _this.controllers.push(webVrController_1);
  18475. // Forced to add some control code for Vive as it doesn't always fill properly the "hand" property
  18476. // Sometimes, both controllers are set correctly (left and right), sometimes none, sometimes only one of them...
  18477. // So we're overriding setting left & right manually to be sure
  18478. var firstViveWandDetected = false;
  18479. for (var i = 0; i < _this.controllers.length; i++) {
  18480. if (_this.controllers[i].controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__["PoseEnabledControllerType"].VIVE) {
  18481. if (!firstViveWandDetected) {
  18482. firstViveWandDetected = true;
  18483. _this.controllers[i].hand = "left";
  18484. }
  18485. else {
  18486. _this.controllers[i].hand = "right";
  18487. }
  18488. }
  18489. }
  18490. //did we find enough controllers? Great! let the developer know.
  18491. if (_this.controllers.length >= 2) {
  18492. _this.onControllersAttachedObservable.notifyObservers(_this.controllers);
  18493. }
  18494. }
  18495. }
  18496. });
  18497. };
  18498. return WebVRFreeCamera;
  18499. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  18500. /***/ }),
  18501. /***/ "./Cameras/XR/index.ts":
  18502. /*!*****************************!*\
  18503. !*** ./Cameras/XR/index.ts ***!
  18504. \*****************************/
  18505. /*! exports provided: WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  18506. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18507. "use strict";
  18508. __webpack_require__.r(__webpack_exports__);
  18509. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  18510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _webXRCamera__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  18511. /* harmony import */ var _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  18512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIButton"]; });
  18513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIOptions"]; });
  18514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUI"]; });
  18515. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"]; });
  18517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRExperienceHelper"]; });
  18518. /* harmony import */ var _webXRInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRInput */ "./Cameras/XR/webXRInput.ts");
  18519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRController"]; });
  18520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRInput"]; });
  18521. /* harmony import */ var _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  18522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__["WebXRManagedOutputCanvas"]; });
  18523. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__["WebXRSessionManager"]; });
  18525. /***/ }),
  18526. /***/ "./Cameras/XR/webXRCamera.ts":
  18527. /*!***********************************!*\
  18528. !*** ./Cameras/XR/webXRCamera.ts ***!
  18529. \***********************************/
  18530. /*! exports provided: WebXRCamera */
  18531. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18532. "use strict";
  18533. __webpack_require__.r(__webpack_exports__);
  18534. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return WebXRCamera; });
  18535. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18536. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18537. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  18538. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  18539. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  18540. /**
  18541. * WebXR Camera which holds the views for the xrSession
  18542. * @see https://doc.babylonjs.com/how_to/webxr
  18543. */
  18544. var WebXRCamera = /** @class */ (function (_super) {
  18545. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebXRCamera, _super);
  18546. /**
  18547. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  18548. * @param name the name of the camera
  18549. * @param scene the scene to add the camera to
  18550. */
  18551. function WebXRCamera(name, scene) {
  18552. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), scene) || this;
  18553. // Initial camera configuration
  18554. _this.minZ = 0;
  18555. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18556. _this.cameraRigMode = _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_CUSTOM;
  18557. _this.updateUpVectorFromRotation = true;
  18558. _this._updateNumberOfRigCameras(1);
  18559. return _this;
  18560. }
  18561. WebXRCamera.prototype._updateNumberOfRigCameras = function (viewCount) {
  18562. if (viewCount === void 0) { viewCount = 1; }
  18563. while (this.rigCameras.length < viewCount) {
  18564. var newCamera = new _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]("view: " + this.rigCameras.length, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), this.getScene());
  18565. newCamera.minZ = 0;
  18566. newCamera.parent = this;
  18567. newCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18568. newCamera.updateUpVectorFromRotation = true;
  18569. this.rigCameras.push(newCamera);
  18570. }
  18571. while (this.rigCameras.length > viewCount) {
  18572. var removedCamera = this.rigCameras.pop();
  18573. if (removedCamera) {
  18574. removedCamera.dispose();
  18575. }
  18576. }
  18577. };
  18578. /** @hidden */
  18579. WebXRCamera.prototype._updateForDualEyeDebugging = function (pupilDistance) {
  18580. if (pupilDistance === void 0) { pupilDistance = 0.01; }
  18581. // Create initial camera rigs
  18582. this._updateNumberOfRigCameras(2);
  18583. this.rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  18584. this.rigCameras[0].position.x = -pupilDistance / 2;
  18585. this.rigCameras[0].outputRenderTarget = null;
  18586. this.rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  18587. this.rigCameras[1].position.x = pupilDistance / 2;
  18588. this.rigCameras[1].outputRenderTarget = null;
  18589. };
  18590. /**
  18591. * Updates the cameras position from the current pose information of the XR session
  18592. * @param xrSessionManager the session containing pose information
  18593. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  18594. */
  18595. WebXRCamera.prototype.updateFromXRSessionManager = function (xrSessionManager) {
  18596. var _this = this;
  18597. // Ensure all frame data is available
  18598. if (!xrSessionManager._currentXRFrame || !xrSessionManager._currentXRFrame.getDevicePose) {
  18599. return false;
  18600. }
  18601. var pose = xrSessionManager._currentXRFrame.getDevicePose(xrSessionManager._frameOfReference);
  18602. if (!pose || !pose.poseModelMatrix) {
  18603. return false;
  18604. }
  18605. // Update the parent cameras matrix
  18606. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.poseModelMatrix, 0, 1, WebXRCamera._TmpMatrix);
  18607. if (!this._scene.useRightHandedSystem) {
  18608. WebXRCamera._TmpMatrix.toggleModelMatrixHandInPlace();
  18609. }
  18610. WebXRCamera._TmpMatrix.getTranslationToRef(this.position);
  18611. WebXRCamera._TmpMatrix.getRotationMatrixToRef(WebXRCamera._TmpMatrix);
  18612. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(WebXRCamera._TmpMatrix, this.rotationQuaternion);
  18613. this.computeWorldMatrix();
  18614. // Update camera rigs
  18615. this._updateNumberOfRigCameras(xrSessionManager._currentXRFrame.views.length);
  18616. xrSessionManager._currentXRFrame.views.forEach(function (view, i) {
  18617. // Update view/projection matrix
  18618. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.getViewMatrix(view), 0, 1, _this.rigCameras[i]._computedViewMatrix);
  18619. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(view.projectionMatrix, 0, 1, _this.rigCameras[i]._projectionMatrix);
  18620. if (!_this._scene.useRightHandedSystem) {
  18621. _this.rigCameras[i]._computedViewMatrix.toggleModelMatrixHandInPlace();
  18622. _this.rigCameras[i]._projectionMatrix.toggleProjectionMatrixHandInPlace();
  18623. }
  18624. // Update viewport
  18625. var viewport = xrSessionManager._xrSession.baseLayer.getViewport(view);
  18626. var width = xrSessionManager._xrSession.baseLayer.framebufferWidth;
  18627. var height = xrSessionManager._xrSession.baseLayer.framebufferHeight;
  18628. _this.rigCameras[i].viewport.width = viewport.width / width;
  18629. _this.rigCameras[i].viewport.height = viewport.height / height;
  18630. _this.rigCameras[i].viewport.x = viewport.x / width;
  18631. _this.rigCameras[i].viewport.y = viewport.y / height;
  18632. // Set cameras to render to the session's render target
  18633. _this.rigCameras[i].outputRenderTarget = xrSessionManager._sessionRenderTargetTexture;
  18634. });
  18635. return true;
  18636. };
  18637. WebXRCamera._TmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  18638. return WebXRCamera;
  18639. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"]));
  18640. /***/ }),
  18641. /***/ "./Cameras/XR/webXREnterExitUI.ts":
  18642. /*!****************************************!*\
  18643. !*** ./Cameras/XR/webXREnterExitUI.ts ***!
  18644. \****************************************/
  18645. /*! exports provided: WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI */
  18646. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18647. "use strict";
  18648. __webpack_require__.r(__webpack_exports__);
  18649. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return WebXREnterExitUIButton; });
  18650. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return WebXREnterExitUIOptions; });
  18651. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return WebXREnterExitUI; });
  18652. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18653. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18654. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18655. /**
  18656. * Button which can be used to enter a different mode of XR
  18657. */
  18658. var WebXREnterExitUIButton = /** @class */ (function () {
  18659. /**
  18660. * Creates a WebXREnterExitUIButton
  18661. * @param element button element
  18662. * @param initializationOptions XR initialization options for the button
  18663. */
  18664. function WebXREnterExitUIButton(
  18665. /** button element */
  18666. element,
  18667. /** XR initialization options for the button */
  18668. initializationOptions) {
  18669. this.element = element;
  18670. this.initializationOptions = initializationOptions;
  18671. }
  18672. /**
  18673. * Overwritable function which can be used to update the button's visuals when the state changes
  18674. * @param activeButton the current active button in the UI
  18675. */
  18676. WebXREnterExitUIButton.prototype.update = function (activeButton) {
  18677. };
  18678. return WebXREnterExitUIButton;
  18679. }());
  18680. /**
  18681. * Options to create the webXR UI
  18682. */
  18683. var WebXREnterExitUIOptions = /** @class */ (function () {
  18684. function WebXREnterExitUIOptions() {
  18685. }
  18686. return WebXREnterExitUIOptions;
  18687. }());
  18688. /**
  18689. * UI to allow the user to enter/exit XR mode
  18690. */
  18691. var WebXREnterExitUI = /** @class */ (function () {
  18692. function WebXREnterExitUI(scene, options) {
  18693. var _this = this;
  18694. this.scene = scene;
  18695. this._buttons = [];
  18696. this._activeButton = null;
  18697. /**
  18698. * Fired every time the active button is changed.
  18699. *
  18700. * When xr is entered via a button that launches xr that button will be the callback parameter
  18701. *
  18702. * When exiting xr the callback parameter will be null)
  18703. */
  18704. this.activeButtonChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18705. this._overlay = document.createElement("div");
  18706. this._overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;";
  18707. if (options.customButtons) {
  18708. this._buttons = options.customButtons;
  18709. }
  18710. else {
  18711. var hmdBtn = document.createElement("button");
  18712. 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;";
  18713. hmdBtn.innerText = "HMD";
  18714. this._buttons.push(new WebXREnterExitUIButton(hmdBtn, { immersive: true, outputContext: options.outputCanvasContext }));
  18715. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18716. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18717. this.element.innerText = activeButton === this ? "EXIT" : "HMD";
  18718. };
  18719. var windowBtn = document.createElement("button");
  18720. windowBtn.style.cssText = hmdBtn.style.cssText;
  18721. windowBtn.innerText = "Window";
  18722. this._buttons.push(new WebXREnterExitUIButton(windowBtn, { immersive: false, environmentIntegration: true, outputContext: options.outputCanvasContext }));
  18723. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18724. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18725. this.element.innerText = activeButton === this ? "EXIT" : "Window";
  18726. };
  18727. this._updateButtons(null);
  18728. }
  18729. var renderCanvas = scene.getEngine().getRenderingCanvas();
  18730. if (renderCanvas && renderCanvas.parentNode) {
  18731. renderCanvas.parentNode.appendChild(this._overlay);
  18732. scene.onDisposeObservable.addOnce(function () {
  18733. _this.dispose();
  18734. });
  18735. }
  18736. }
  18737. /**
  18738. * Creates UI to allow the user to enter/exit XR mode
  18739. * @param scene the scene to add the ui to
  18740. * @param helper the xr experience helper to enter/exit xr with
  18741. * @param options options to configure the UI
  18742. * @returns the created ui
  18743. */
  18744. WebXREnterExitUI.CreateAsync = function (scene, helper, options) {
  18745. var _this = this;
  18746. var ui = new WebXREnterExitUI(scene, options);
  18747. var supportedPromises = ui._buttons.map(function (btn) {
  18748. return helper.supportsSessionAsync(btn.initializationOptions);
  18749. });
  18750. helper.onStateChangedObservable.add(function (state) {
  18751. if (state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR) {
  18752. ui._updateButtons(null);
  18753. }
  18754. });
  18755. return Promise.all(supportedPromises).then(function (results) {
  18756. results.forEach(function (supported, i) {
  18757. if (supported) {
  18758. ui._overlay.appendChild(ui._buttons[i].element);
  18759. ui._buttons[i].element.onclick = function () { return tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"](_this, void 0, void 0, function () {
  18760. return tslib__WEBPACK_IMPORTED_MODULE_0__["__generator"](this, function (_a) {
  18761. switch (_a.label) {
  18762. case 0:
  18763. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].IN_XR)) return [3 /*break*/, 2];
  18764. ui._updateButtons(null);
  18765. return [4 /*yield*/, helper.exitXRAsync()];
  18766. case 1:
  18767. _a.sent();
  18768. return [2 /*return*/];
  18769. case 2:
  18770. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR)) return [3 /*break*/, 4];
  18771. ui._updateButtons(ui._buttons[i]);
  18772. return [4 /*yield*/, helper.enterXRAsync(ui._buttons[i].initializationOptions, "eye-level")];
  18773. case 3:
  18774. _a.sent();
  18775. _a.label = 4;
  18776. case 4: return [2 /*return*/];
  18777. }
  18778. });
  18779. }); };
  18780. }
  18781. });
  18782. return ui;
  18783. });
  18784. };
  18785. WebXREnterExitUI.prototype._updateButtons = function (activeButton) {
  18786. var _this = this;
  18787. this._activeButton = activeButton;
  18788. this._buttons.forEach(function (b) {
  18789. b.update(_this._activeButton);
  18790. });
  18791. this.activeButtonChangedObservable.notifyObservers(this._activeButton);
  18792. };
  18793. /**
  18794. * Disposes of the object
  18795. */
  18796. WebXREnterExitUI.prototype.dispose = function () {
  18797. var renderCanvas = this.scene.getEngine().getRenderingCanvas();
  18798. if (renderCanvas && renderCanvas.parentNode && renderCanvas.parentNode.contains(this._overlay)) {
  18799. renderCanvas.parentNode.removeChild(this._overlay);
  18800. }
  18801. this.activeButtonChangedObservable.clear();
  18802. };
  18803. return WebXREnterExitUI;
  18804. }());
  18805. /***/ }),
  18806. /***/ "./Cameras/XR/webXRExperienceHelper.ts":
  18807. /*!*********************************************!*\
  18808. !*** ./Cameras/XR/webXRExperienceHelper.ts ***!
  18809. \*********************************************/
  18810. /*! exports provided: WebXRState, WebXRExperienceHelper */
  18811. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18812. "use strict";
  18813. __webpack_require__.r(__webpack_exports__);
  18814. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return WebXRState; });
  18815. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return WebXRExperienceHelper; });
  18816. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18817. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18818. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18819. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18820. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  18821. /**
  18822. * States of the webXR experience
  18823. */
  18824. var WebXRState;
  18825. (function (WebXRState) {
  18826. /**
  18827. * Transitioning to being in XR mode
  18828. */
  18829. WebXRState[WebXRState["ENTERING_XR"] = 0] = "ENTERING_XR";
  18830. /**
  18831. * Transitioning to non XR mode
  18832. */
  18833. WebXRState[WebXRState["EXITING_XR"] = 1] = "EXITING_XR";
  18834. /**
  18835. * In XR mode and presenting
  18836. */
  18837. WebXRState[WebXRState["IN_XR"] = 2] = "IN_XR";
  18838. /**
  18839. * Not entered XR mode
  18840. */
  18841. WebXRState[WebXRState["NOT_IN_XR"] = 3] = "NOT_IN_XR";
  18842. })(WebXRState || (WebXRState = {}));
  18843. /**
  18844. * Helper class used to enable XR
  18845. * @see https://doc.babylonjs.com/how_to/webxr
  18846. */
  18847. var WebXRExperienceHelper = /** @class */ (function () {
  18848. /**
  18849. * Creates a WebXRExperienceHelper
  18850. * @param scene The scene the helper should be created in
  18851. */
  18852. function WebXRExperienceHelper(scene) {
  18853. this.scene = scene;
  18854. /**
  18855. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  18856. */
  18857. this.state = WebXRState.NOT_IN_XR;
  18858. /**
  18859. * Fires when the state of the experience helper has changed
  18860. */
  18861. this.onStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  18862. this._nonVRCamera = null;
  18863. this._originalSceneAutoClear = true;
  18864. this._supported = false;
  18865. this.camera = new _webXRCamera__WEBPACK_IMPORTED_MODULE_4__["WebXRCamera"]("", scene);
  18866. this._sessionManager = new _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__["WebXRSessionManager"](scene);
  18867. this.container = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", scene);
  18868. this.camera.parent = this.container;
  18869. }
  18870. WebXRExperienceHelper.prototype._setState = function (val) {
  18871. this.state = val;
  18872. this.onStateChangedObservable.notifyObservers(this.state);
  18873. };
  18874. /**
  18875. * Creates the experience helper
  18876. * @param scene the scene to attach the experience helper to
  18877. * @returns a promise for the experience helper
  18878. */
  18879. WebXRExperienceHelper.CreateAsync = function (scene) {
  18880. var helper = new WebXRExperienceHelper(scene);
  18881. return helper._sessionManager.initializeAsync().then(function () {
  18882. helper._supported = true;
  18883. return helper;
  18884. }).catch(function () {
  18885. return helper;
  18886. });
  18887. };
  18888. /**
  18889. * Exits XR mode and returns the scene to its original state
  18890. * @returns promise that resolves after xr mode has exited
  18891. */
  18892. WebXRExperienceHelper.prototype.exitXRAsync = function () {
  18893. this._setState(WebXRState.EXITING_XR);
  18894. return this._sessionManager.exitXRAsync();
  18895. };
  18896. /**
  18897. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  18898. * @param sessionCreationOptions options for the XR session
  18899. * @param frameOfReference frame of reference of the XR session
  18900. * @returns promise that resolves after xr mode has entered
  18901. */
  18902. WebXRExperienceHelper.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReference) {
  18903. var _this = this;
  18904. if (!this._supported) {
  18905. throw "XR session not supported by this browser";
  18906. }
  18907. this._setState(WebXRState.ENTERING_XR);
  18908. return this._sessionManager.enterXRAsync(sessionCreationOptions, frameOfReference).then(function () {
  18909. // Cache pre xr scene settings
  18910. _this._originalSceneAutoClear = _this.scene.autoClear;
  18911. _this._nonVRCamera = _this.scene.activeCamera;
  18912. // Overwrite current scene settings
  18913. _this.scene.autoClear = false;
  18914. _this.scene.activeCamera = _this.camera;
  18915. _this._sessionManager.onXRFrameObservable.add(function () {
  18916. _this.camera.updateFromXRSessionManager(_this._sessionManager);
  18917. });
  18918. _this._sessionManager.onXRSessionEnded.addOnce(function () {
  18919. // Reset camera rigs output render target to ensure sessions render target is not drawn after it ends
  18920. _this.camera.rigCameras.forEach(function (c) {
  18921. c.outputRenderTarget = null;
  18922. });
  18923. // Restore scene settings
  18924. _this.scene.autoClear = _this._originalSceneAutoClear;
  18925. _this.scene.activeCamera = _this._nonVRCamera;
  18926. _this._sessionManager.onXRFrameObservable.clear();
  18927. _this._setState(WebXRState.NOT_IN_XR);
  18928. });
  18929. _this._setState(WebXRState.IN_XR);
  18930. });
  18931. };
  18932. /**
  18933. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  18934. * @param ray ray to cast into the environment
  18935. * @returns Promise which resolves with a collision point in the environment if it exists
  18936. */
  18937. WebXRExperienceHelper.prototype.environmentPointHitTestAsync = function (ray) {
  18938. return this._sessionManager.environmentPointHitTestAsync(ray);
  18939. };
  18940. /**
  18941. * Updates the global position of the camera by moving the camera's container
  18942. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  18943. * @param position The desired global position of the camera
  18944. */
  18945. WebXRExperienceHelper.prototype.setPositionOfCameraUsingContainer = function (position) {
  18946. this.camera.globalPosition.subtractToRef(position, WebXRExperienceHelper._TmpVector);
  18947. this.container.position.subtractInPlace(WebXRExperienceHelper._TmpVector);
  18948. };
  18949. /**
  18950. * Rotates the xr camera by rotating the camera's container around the camera's position
  18951. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  18952. * @param rotation the desired quaternion rotation to apply to the camera
  18953. */
  18954. WebXRExperienceHelper.prototype.rotateCameraByQuaternionUsingContainer = function (rotation) {
  18955. if (!this.container.rotationQuaternion) {
  18956. this.container.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromEulerVector(this.container.rotation);
  18957. }
  18958. this.container.rotationQuaternion.multiplyInPlace(rotation);
  18959. this.container.position.rotateByQuaternionAroundPointToRef(rotation, this.camera.globalPosition, this.container.position);
  18960. };
  18961. /**
  18962. * Checks if the creation options are supported by the xr session
  18963. * @param options creation options
  18964. * @returns true if supported
  18965. */
  18966. WebXRExperienceHelper.prototype.supportsSessionAsync = function (options) {
  18967. if (!this._supported) {
  18968. return Promise.resolve(false);
  18969. }
  18970. return this._sessionManager.supportsSessionAsync(options);
  18971. };
  18972. /**
  18973. * Disposes of the experience helper
  18974. */
  18975. WebXRExperienceHelper.prototype.dispose = function () {
  18976. this.camera.dispose();
  18977. this.container.dispose();
  18978. this.onStateChangedObservable.clear();
  18979. this._sessionManager.dispose();
  18980. };
  18981. WebXRExperienceHelper._TmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]();
  18982. return WebXRExperienceHelper;
  18983. }());
  18984. /***/ }),
  18985. /***/ "./Cameras/XR/webXRInput.ts":
  18986. /*!**********************************!*\
  18987. !*** ./Cameras/XR/webXRInput.ts ***!
  18988. \**********************************/
  18989. /*! exports provided: WebXRController, WebXRInput */
  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__, "WebXRController", function() { return WebXRController; });
  18994. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return WebXRInput; });
  18995. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18996. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18997. /**
  18998. * Represents an XR input
  18999. */
  19000. var WebXRController = /** @class */ (function () {
  19001. /**
  19002. * Creates the controller
  19003. * @see https://doc.babylonjs.com/how_to/webxr
  19004. * @param scene the scene which the controller should be associated to
  19005. */
  19006. function WebXRController(scene) {
  19007. this.pointer = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerPointer", scene);
  19008. }
  19009. /**
  19010. * Disposes of the object
  19011. */
  19012. WebXRController.prototype.dispose = function () {
  19013. if (this.grip) {
  19014. this.grip.dispose();
  19015. }
  19016. this.pointer.dispose();
  19017. };
  19018. return WebXRController;
  19019. }());
  19020. /**
  19021. * XR input used to track XR inputs such as controllers/rays
  19022. */
  19023. var WebXRInput = /** @class */ (function () {
  19024. /**
  19025. * Initializes the WebXRInput
  19026. * @param helper experience helper which the input should be created for
  19027. */
  19028. function WebXRInput(helper) {
  19029. var _this = this;
  19030. this.helper = helper;
  19031. /**
  19032. * XR controllers being tracked
  19033. */
  19034. this.controllers = [];
  19035. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  19036. this._frameObserver = helper._sessionManager.onXRFrameObservable.add(function () {
  19037. if (!helper._sessionManager._currentXRFrame || !helper._sessionManager._currentXRFrame.getDevicePose) {
  19038. return;
  19039. }
  19040. var xrFrame = helper._sessionManager._currentXRFrame;
  19041. var inputSources = helper._sessionManager._xrSession.getInputSources();
  19042. inputSources.forEach(function (input, i) {
  19043. var inputPose = xrFrame.getInputPose(input, helper._sessionManager._frameOfReference);
  19044. if (inputPose) {
  19045. if (_this.controllers.length <= i) {
  19046. _this.controllers.push(new WebXRController(helper.container.getScene()));
  19047. }
  19048. var controller = _this.controllers[i];
  19049. // Manage the grip if it exists
  19050. if (inputPose.gripMatrix) {
  19051. if (!controller.grip) {
  19052. controller.grip = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerGrip", helper.container.getScene());
  19053. }
  19054. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.gripMatrix, 0, 1, _this._tmpMatrix);
  19055. if (!controller.grip.getScene().useRightHandedSystem) {
  19056. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  19057. }
  19058. if (!controller.grip.rotationQuaternion) {
  19059. controller.grip.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  19060. }
  19061. _this._tmpMatrix.decompose(controller.grip.scaling, controller.grip.rotationQuaternion, controller.grip.position);
  19062. }
  19063. // Manager pointer of controller
  19064. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.targetRay.transformMatrix, 0, 1, _this._tmpMatrix);
  19065. if (!controller.pointer.getScene().useRightHandedSystem) {
  19066. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  19067. }
  19068. if (!controller.pointer.rotationQuaternion) {
  19069. controller.pointer.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  19070. }
  19071. _this._tmpMatrix.decompose(controller.pointer.scaling, controller.pointer.rotationQuaternion, controller.pointer.position);
  19072. }
  19073. });
  19074. });
  19075. }
  19076. /**
  19077. * Disposes of the object
  19078. */
  19079. WebXRInput.prototype.dispose = function () {
  19080. this.controllers.forEach(function (c) {
  19081. c.dispose();
  19082. });
  19083. this.helper._sessionManager.onXRFrameObservable.remove(this._frameObserver);
  19084. };
  19085. return WebXRInput;
  19086. }());
  19087. /***/ }),
  19088. /***/ "./Cameras/XR/webXRManagedOutputCanvas.ts":
  19089. /*!************************************************!*\
  19090. !*** ./Cameras/XR/webXRManagedOutputCanvas.ts ***!
  19091. \************************************************/
  19092. /*! exports provided: WebXRManagedOutputCanvas */
  19093. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19094. "use strict";
  19095. __webpack_require__.r(__webpack_exports__);
  19096. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return WebXRManagedOutputCanvas; });
  19097. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  19098. /**
  19099. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  19100. */
  19101. var WebXRManagedOutputCanvas = /** @class */ (function () {
  19102. /**
  19103. * Initializes the canvas to be added/removed upon entering/exiting xr
  19104. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  19105. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  19106. */
  19107. function WebXRManagedOutputCanvas(helper, canvas) {
  19108. var _this = this;
  19109. this._canvas = null;
  19110. /**
  19111. * xrpresent context of the canvas which can be used to display/mirror xr content
  19112. */
  19113. this.canvasContext = null;
  19114. if (!canvas) {
  19115. canvas = document.createElement('canvas');
  19116. canvas.style.cssText = "position:absolute; bottom:0px;right:0px;z-index:10;width:100%;height:100%;background-color: #000000;";
  19117. }
  19118. this._setManagedOutputCanvas(canvas);
  19119. helper.onStateChangedObservable.add(function (stateInfo) {
  19120. if (stateInfo == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].ENTERING_XR) {
  19121. // 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
  19122. _this._addCanvas();
  19123. }
  19124. else if (helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].NOT_IN_XR) {
  19125. _this._removeCanvas();
  19126. }
  19127. });
  19128. }
  19129. /**
  19130. * Disposes of the object
  19131. */
  19132. WebXRManagedOutputCanvas.prototype.dispose = function () {
  19133. this._removeCanvas();
  19134. this._setManagedOutputCanvas(null);
  19135. };
  19136. WebXRManagedOutputCanvas.prototype._setManagedOutputCanvas = function (canvas) {
  19137. this._removeCanvas();
  19138. if (!canvas) {
  19139. this._canvas = null;
  19140. this.canvasContext = null;
  19141. }
  19142. else {
  19143. this._canvas = canvas;
  19144. this.canvasContext = this._canvas.getContext('xrpresent');
  19145. }
  19146. };
  19147. WebXRManagedOutputCanvas.prototype._addCanvas = function () {
  19148. if (this._canvas) {
  19149. document.body.appendChild(this._canvas);
  19150. }
  19151. };
  19152. WebXRManagedOutputCanvas.prototype._removeCanvas = function () {
  19153. if (this._canvas && document.body.contains(this._canvas)) {
  19154. document.body.removeChild(this._canvas);
  19155. }
  19156. };
  19157. return WebXRManagedOutputCanvas;
  19158. }());
  19159. /***/ }),
  19160. /***/ "./Cameras/XR/webXRSessionManager.ts":
  19161. /*!*******************************************!*\
  19162. !*** ./Cameras/XR/webXRSessionManager.ts ***!
  19163. \*******************************************/
  19164. /*! exports provided: WebXRSessionManager */
  19165. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19166. "use strict";
  19167. __webpack_require__.r(__webpack_exports__);
  19168. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return WebXRSessionManager; });
  19169. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  19170. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  19171. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  19172. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  19173. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  19174. /**
  19175. * Manages an XRSession
  19176. * @see https://doc.babylonjs.com/how_to/webxr
  19177. */
  19178. var WebXRSessionManager = /** @class */ (function () {
  19179. /**
  19180. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  19181. * @param scene The scene which the session should be created for
  19182. */
  19183. function WebXRSessionManager(scene) {
  19184. this.scene = scene;
  19185. /**
  19186. * Fires every time a new xrFrame arrives which can be used to update the camera
  19187. */
  19188. this.onXRFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  19189. /**
  19190. * Fires when the xr session is ended either by the device or manually done
  19191. */
  19192. this.onXRSessionEnded = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  19193. /** @hidden */
  19194. this._sessionRenderTargetTexture = null;
  19195. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  19196. }
  19197. /**
  19198. * Initializes the manager
  19199. * After initialization enterXR can be called to start an XR session
  19200. * @returns Promise which resolves after it is initialized
  19201. */
  19202. WebXRSessionManager.prototype.initializeAsync = function () {
  19203. var _this = this;
  19204. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("The WebXR APIs are still under development and are subject to change in the future.");
  19205. // Check if the browser supports webXR
  19206. this._xrNavigator = navigator;
  19207. if (!this._xrNavigator.xr) {
  19208. return Promise.reject("webXR not supported by this browser");
  19209. }
  19210. // Request the webXR device
  19211. return this._xrNavigator.xr.requestDevice().then(function (device) {
  19212. _this._xrDevice = device;
  19213. return _this.scene.getEngine()._gl.setCompatibleXRDevice(_this._xrDevice);
  19214. });
  19215. };
  19216. /**
  19217. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  19218. * @param sessionCreationOptions xr options to create the session with
  19219. * @param frameOfReferenceType option to configure how the xr pose is expressed
  19220. * @returns Promise which resolves after it enters XR
  19221. */
  19222. WebXRSessionManager.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReferenceType) {
  19223. var _this = this;
  19224. // initialize session
  19225. return this._xrDevice.requestSession(sessionCreationOptions).then(function (session) {
  19226. _this._xrSession = session;
  19227. // handle when the session is ended (By calling session.end or device ends its own session eg. pressing home button on phone)
  19228. _this._xrSession.addEventListener("end", function () {
  19229. // Remove render target texture and notify frame obervers
  19230. _this._sessionRenderTargetTexture = null;
  19231. // Restore frame buffer to avoid clear on xr framebuffer after session end
  19232. _this.scene.getEngine().restoreDefaultFramebuffer();
  19233. // Need to restart render loop as after the session is ended the last request for new frame will never call callback
  19234. _this.scene.getEngine().customAnimationFrameRequester = null;
  19235. _this.onXRSessionEnded.notifyObservers(null);
  19236. _this.scene.getEngine()._renderLoop();
  19237. }, { once: true });
  19238. _this._xrSession.baseLayer = new XRWebGLLayer(_this._xrSession, _this.scene.getEngine()._gl);
  19239. return _this._xrSession.requestFrameOfReference(frameOfReferenceType);
  19240. }).then(function (frameOfRef) {
  19241. _this._frameOfReference = frameOfRef;
  19242. // Tell the engine's render loop to be driven by the xr session's refresh rate and provide xr pose information
  19243. _this.scene.getEngine().customAnimationFrameRequester = {
  19244. requestAnimationFrame: _this._xrSession.requestAnimationFrame.bind(_this._xrSession),
  19245. renderFunction: function (timestamp, xrFrame) {
  19246. // Store the XR frame in the manager to be consumed by the XR camera to update pose
  19247. _this._currentXRFrame = xrFrame;
  19248. _this.onXRFrameObservable.notifyObservers(null);
  19249. _this.scene.getEngine()._renderLoop();
  19250. }
  19251. };
  19252. // Create render target texture from xr's webgl render target
  19253. _this._sessionRenderTargetTexture = WebXRSessionManager._CreateRenderTargetTextureFromSession(_this._xrSession, _this.scene);
  19254. // Stop window's animation frame and trigger sessions animation frame
  19255. window.cancelAnimationFrame(_this.scene.getEngine()._frameHandler);
  19256. _this.scene.getEngine()._renderLoop();
  19257. });
  19258. };
  19259. /**
  19260. * Stops the xrSession and restores the renderloop
  19261. * @returns Promise which resolves after it exits XR
  19262. */
  19263. WebXRSessionManager.prototype.exitXRAsync = function () {
  19264. return this._xrSession.end();
  19265. };
  19266. /**
  19267. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  19268. * @param ray ray to cast into the environment
  19269. * @returns Promise which resolves with a collision point in the environment if it exists
  19270. */
  19271. WebXRSessionManager.prototype.environmentPointHitTestAsync = function (ray) {
  19272. var _this = this;
  19273. return new Promise(function (res) {
  19274. // Compute left handed inputs to request hit test
  19275. var origin = new Float32Array([ray.origin.x, ray.origin.y, ray.origin.z]);
  19276. var direction = new Float32Array([ray.direction.x, ray.direction.y, ray.direction.z]);
  19277. if (!_this.scene.useRightHandedSystem) {
  19278. origin[2] *= -1;
  19279. direction[2] *= -1;
  19280. }
  19281. // Fire hittest
  19282. _this._xrSession.requestHitTest(origin, direction, _this._frameOfReference)
  19283. .then(function (hits) {
  19284. if (hits.length > 0) {
  19285. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromFloat32ArrayToRefScaled(hits[0].hitMatrix, 0, 1.0, _this._tmpMatrix);
  19286. var hitPoint = _this._tmpMatrix.getTranslation();
  19287. if (!_this.scene.useRightHandedSystem) {
  19288. hitPoint.z *= -1;
  19289. }
  19290. res(hitPoint);
  19291. }
  19292. else {
  19293. res(null);
  19294. }
  19295. }).catch(function () {
  19296. res(null);
  19297. });
  19298. });
  19299. };
  19300. /**
  19301. * Checks if a session would be supported for the creation options specified
  19302. * @param options creation options to check if they are supported
  19303. * @returns true if supported
  19304. */
  19305. WebXRSessionManager.prototype.supportsSessionAsync = function (options) {
  19306. return this._xrDevice.supportsSession(options).then(function () {
  19307. return true;
  19308. }).catch(function () {
  19309. return false;
  19310. });
  19311. };
  19312. /**
  19313. * @hidden
  19314. * Converts the render layer of xrSession to a render target
  19315. * @param session session to create render target for
  19316. * @param scene scene the new render target should be created for
  19317. */
  19318. WebXRSessionManager._CreateRenderTargetTextureFromSession = function (session, scene) {
  19319. // Create internal texture
  19320. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"](scene.getEngine(), _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_UNKNOWN, true);
  19321. internalTexture.width = session.baseLayer.framebufferWidth;
  19322. internalTexture.height = session.baseLayer.framebufferHeight;
  19323. internalTexture._framebuffer = session.baseLayer.framebuffer;
  19324. // Create render target texture from the internal texture
  19325. 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);
  19326. renderTargetTexture._texture = internalTexture;
  19327. return renderTargetTexture;
  19328. };
  19329. /**
  19330. * Disposes of the session manager
  19331. */
  19332. WebXRSessionManager.prototype.dispose = function () {
  19333. this.onXRFrameObservable.clear();
  19334. this.onXRSessionEnded.clear();
  19335. };
  19336. return WebXRSessionManager;
  19337. }());
  19338. /***/ }),
  19339. /***/ "./Cameras/arcRotateCamera.ts":
  19340. /*!************************************!*\
  19341. !*** ./Cameras/arcRotateCamera.ts ***!
  19342. \************************************/
  19343. /*! exports provided: ArcRotateCamera */
  19344. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19345. "use strict";
  19346. __webpack_require__.r(__webpack_exports__);
  19347. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return ArcRotateCamera; });
  19348. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19349. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  19350. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  19351. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  19352. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  19353. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  19354. /* harmony import */ var _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Cameras/autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  19355. /* harmony import */ var _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Cameras/bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  19356. /* harmony import */ var _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Behaviors/Cameras/framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  19357. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  19358. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  19359. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  19360. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("ArcRotateCamera", function (name, scene) {
  19361. return function () { return new ArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  19362. });
  19363. /**
  19364. * This represents an orbital type of camera.
  19365. *
  19366. * 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.
  19367. * 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.
  19368. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  19369. */
  19370. var ArcRotateCamera = /** @class */ (function (_super) {
  19371. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCamera, _super);
  19372. /**
  19373. * Instantiates a new ArcRotateCamera in a given scene
  19374. * @param name Defines the name of the camera
  19375. * @param alpha Defines the camera rotation along the logitudinal axis
  19376. * @param beta Defines the camera rotation along the latitudinal axis
  19377. * @param radius Defines the camera distance from its target
  19378. * @param target Defines the camera target
  19379. * @param scene Defines the scene the camera belongs to
  19380. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19381. */
  19382. function ArcRotateCamera(name, alpha, beta, radius, target, scene, setActiveOnSceneIfNoneActive) {
  19383. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  19384. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene, setActiveOnSceneIfNoneActive) || this;
  19385. /**
  19386. * Current inertia value on the longitudinal axis.
  19387. * The bigger this number the longer it will take for the camera to stop.
  19388. */
  19389. _this.inertialAlphaOffset = 0;
  19390. /**
  19391. * Current inertia value on the latitudinal axis.
  19392. * The bigger this number the longer it will take for the camera to stop.
  19393. */
  19394. _this.inertialBetaOffset = 0;
  19395. /**
  19396. * Current inertia value on the radius axis.
  19397. * The bigger this number the longer it will take for the camera to stop.
  19398. */
  19399. _this.inertialRadiusOffset = 0;
  19400. /**
  19401. * Minimum allowed angle on the longitudinal axis.
  19402. * This can help limiting how the Camera is able to move in the scene.
  19403. */
  19404. _this.lowerAlphaLimit = null;
  19405. /**
  19406. * Maximum allowed angle on the longitudinal axis.
  19407. * This can help limiting how the Camera is able to move in the scene.
  19408. */
  19409. _this.upperAlphaLimit = null;
  19410. /**
  19411. * Minimum allowed angle on the latitudinal axis.
  19412. * This can help limiting how the Camera is able to move in the scene.
  19413. */
  19414. _this.lowerBetaLimit = 0.01;
  19415. /**
  19416. * Maximum allowed angle on the latitudinal axis.
  19417. * This can help limiting how the Camera is able to move in the scene.
  19418. */
  19419. _this.upperBetaLimit = Math.PI - 0.01;
  19420. /**
  19421. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  19422. * This can help limiting how the Camera is able to move in the scene.
  19423. */
  19424. _this.lowerRadiusLimit = null;
  19425. /**
  19426. * Maximum allowed distance of the camera to the target (The camera can not get further).
  19427. * This can help limiting how the Camera is able to move in the scene.
  19428. */
  19429. _this.upperRadiusLimit = null;
  19430. /**
  19431. * Defines the current inertia value used during panning of the camera along the X axis.
  19432. */
  19433. _this.inertialPanningX = 0;
  19434. /**
  19435. * Defines the current inertia value used during panning of the camera along the Y axis.
  19436. */
  19437. _this.inertialPanningY = 0;
  19438. /**
  19439. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  19440. * Basically if your fingers moves away from more than this distance you will be considered
  19441. * in pinch mode.
  19442. */
  19443. _this.pinchToPanMaxDistance = 20;
  19444. /**
  19445. * Defines the maximum distance the camera can pan.
  19446. * This could help keeping the cammera always in your scene.
  19447. */
  19448. _this.panningDistanceLimit = null;
  19449. /**
  19450. * Defines the target of the camera before paning.
  19451. */
  19452. _this.panningOriginTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19453. /**
  19454. * Defines the value of the inertia used during panning.
  19455. * 0 would mean stop inertia and one would mean no decelleration at all.
  19456. */
  19457. _this.panningInertia = 0.9;
  19458. //-- end properties for backward compatibility for inputs
  19459. /**
  19460. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  19461. */
  19462. _this.zoomOnFactor = 1;
  19463. /**
  19464. * Defines a screen offset for the camera position.
  19465. */
  19466. _this.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  19467. /**
  19468. * Allows the camera to be completely reversed.
  19469. * If false the camera can not arrive upside down.
  19470. */
  19471. _this.allowUpsideDown = true;
  19472. /**
  19473. * Define if double tap/click is used to restore the previously saved state of the camera.
  19474. */
  19475. _this.useInputToRestoreState = true;
  19476. /** @hidden */
  19477. _this._viewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  19478. /**
  19479. * Defines the allowed panning axis.
  19480. */
  19481. _this.panningAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 0);
  19482. /**
  19483. * Observable triggered when the mesh target has been changed on the camera.
  19484. */
  19485. _this.onMeshTargetChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  19486. /**
  19487. * Defines whether the camera should check collision with the objects oh the scene.
  19488. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  19489. */
  19490. _this.checkCollisions = false;
  19491. /**
  19492. * Defines the collision radius of the camera.
  19493. * This simulates a sphere around the camera.
  19494. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19495. */
  19496. _this.collisionRadius = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 0.5, 0.5);
  19497. _this._previousPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19498. _this._collisionVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19499. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19500. _this._computationVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19501. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  19502. if (collidedMesh === void 0) { collidedMesh = null; }
  19503. if (!collidedMesh) {
  19504. _this._previousPosition.copyFrom(_this._position);
  19505. }
  19506. else {
  19507. _this.setPosition(newPosition);
  19508. if (_this.onCollide) {
  19509. _this.onCollide(collidedMesh);
  19510. }
  19511. }
  19512. // Recompute because of constraints
  19513. var cosa = Math.cos(_this.alpha);
  19514. var sina = Math.sin(_this.alpha);
  19515. var cosb = Math.cos(_this.beta);
  19516. var sinb = Math.sin(_this.beta);
  19517. if (sinb === 0) {
  19518. sinb = 0.0001;
  19519. }
  19520. var target = _this._getTargetPosition();
  19521. _this._computationVector.copyFromFloats(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb);
  19522. target.addToRef(_this._computationVector, _this._newPosition);
  19523. _this._position.copyFrom(_this._newPosition);
  19524. var up = _this.upVector;
  19525. if (_this.allowUpsideDown && _this.beta < 0) {
  19526. up = up.clone();
  19527. up = up.negate();
  19528. }
  19529. _this._computeViewMatrix(_this._position, target, up);
  19530. _this._viewMatrix.addAtIndex(12, _this.targetScreenOffset.x);
  19531. _this._viewMatrix.addAtIndex(13, _this.targetScreenOffset.y);
  19532. _this._collisionTriggered = false;
  19533. };
  19534. _this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19535. if (target) {
  19536. _this.setTarget(target);
  19537. }
  19538. _this.alpha = alpha;
  19539. _this.beta = beta;
  19540. _this.radius = radius;
  19541. _this.getViewMatrix();
  19542. _this.inputs = new _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["ArcRotateCameraInputsManager"](_this);
  19543. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  19544. return _this;
  19545. }
  19546. Object.defineProperty(ArcRotateCamera.prototype, "target", {
  19547. /**
  19548. * Defines the target point of the camera.
  19549. * The camera looks towards it form the radius distance.
  19550. */
  19551. get: function () {
  19552. return this._target;
  19553. },
  19554. set: function (value) {
  19555. this.setTarget(value);
  19556. },
  19557. enumerable: true,
  19558. configurable: true
  19559. });
  19560. Object.defineProperty(ArcRotateCamera.prototype, "position", {
  19561. /**
  19562. * Define the current local position of the camera in the scene
  19563. */
  19564. get: function () {
  19565. return this._position;
  19566. },
  19567. set: function (newPosition) {
  19568. this.setPosition(newPosition);
  19569. },
  19570. enumerable: true,
  19571. configurable: true
  19572. });
  19573. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityX", {
  19574. //-- begin properties for backward compatibility for inputs
  19575. /**
  19576. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  19577. */
  19578. get: function () {
  19579. var pointers = this.inputs.attached["pointers"];
  19580. if (pointers) {
  19581. return pointers.angularSensibilityX;
  19582. }
  19583. return 0;
  19584. },
  19585. set: function (value) {
  19586. var pointers = this.inputs.attached["pointers"];
  19587. if (pointers) {
  19588. pointers.angularSensibilityX = value;
  19589. }
  19590. },
  19591. enumerable: true,
  19592. configurable: true
  19593. });
  19594. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityY", {
  19595. /**
  19596. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  19597. */
  19598. get: function () {
  19599. var pointers = this.inputs.attached["pointers"];
  19600. if (pointers) {
  19601. return pointers.angularSensibilityY;
  19602. }
  19603. return 0;
  19604. },
  19605. set: function (value) {
  19606. var pointers = this.inputs.attached["pointers"];
  19607. if (pointers) {
  19608. pointers.angularSensibilityY = value;
  19609. }
  19610. },
  19611. enumerable: true,
  19612. configurable: true
  19613. });
  19614. Object.defineProperty(ArcRotateCamera.prototype, "pinchPrecision", {
  19615. /**
  19616. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  19617. */
  19618. get: function () {
  19619. var pointers = this.inputs.attached["pointers"];
  19620. if (pointers) {
  19621. return pointers.pinchPrecision;
  19622. }
  19623. return 0;
  19624. },
  19625. set: function (value) {
  19626. var pointers = this.inputs.attached["pointers"];
  19627. if (pointers) {
  19628. pointers.pinchPrecision = value;
  19629. }
  19630. },
  19631. enumerable: true,
  19632. configurable: true
  19633. });
  19634. Object.defineProperty(ArcRotateCamera.prototype, "pinchDeltaPercentage", {
  19635. /**
  19636. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  19637. * It will be used instead of pinchDeltaPrecision if different from 0.
  19638. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19639. */
  19640. get: function () {
  19641. var pointers = this.inputs.attached["pointers"];
  19642. if (pointers) {
  19643. return pointers.pinchDeltaPercentage;
  19644. }
  19645. return 0;
  19646. },
  19647. set: function (value) {
  19648. var pointers = this.inputs.attached["pointers"];
  19649. if (pointers) {
  19650. pointers.pinchDeltaPercentage = value;
  19651. }
  19652. },
  19653. enumerable: true,
  19654. configurable: true
  19655. });
  19656. Object.defineProperty(ArcRotateCamera.prototype, "panningSensibility", {
  19657. /**
  19658. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  19659. */
  19660. get: function () {
  19661. var pointers = this.inputs.attached["pointers"];
  19662. if (pointers) {
  19663. return pointers.panningSensibility;
  19664. }
  19665. return 0;
  19666. },
  19667. set: function (value) {
  19668. var pointers = this.inputs.attached["pointers"];
  19669. if (pointers) {
  19670. pointers.panningSensibility = value;
  19671. }
  19672. },
  19673. enumerable: true,
  19674. configurable: true
  19675. });
  19676. Object.defineProperty(ArcRotateCamera.prototype, "keysUp", {
  19677. /**
  19678. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  19679. */
  19680. get: function () {
  19681. var keyboard = this.inputs.attached["keyboard"];
  19682. if (keyboard) {
  19683. return keyboard.keysUp;
  19684. }
  19685. return [];
  19686. },
  19687. set: function (value) {
  19688. var keyboard = this.inputs.attached["keyboard"];
  19689. if (keyboard) {
  19690. keyboard.keysUp = value;
  19691. }
  19692. },
  19693. enumerable: true,
  19694. configurable: true
  19695. });
  19696. Object.defineProperty(ArcRotateCamera.prototype, "keysDown", {
  19697. /**
  19698. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  19699. */
  19700. get: function () {
  19701. var keyboard = this.inputs.attached["keyboard"];
  19702. if (keyboard) {
  19703. return keyboard.keysDown;
  19704. }
  19705. return [];
  19706. },
  19707. set: function (value) {
  19708. var keyboard = this.inputs.attached["keyboard"];
  19709. if (keyboard) {
  19710. keyboard.keysDown = value;
  19711. }
  19712. },
  19713. enumerable: true,
  19714. configurable: true
  19715. });
  19716. Object.defineProperty(ArcRotateCamera.prototype, "keysLeft", {
  19717. /**
  19718. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  19719. */
  19720. get: function () {
  19721. var keyboard = this.inputs.attached["keyboard"];
  19722. if (keyboard) {
  19723. return keyboard.keysLeft;
  19724. }
  19725. return [];
  19726. },
  19727. set: function (value) {
  19728. var keyboard = this.inputs.attached["keyboard"];
  19729. if (keyboard) {
  19730. keyboard.keysLeft = value;
  19731. }
  19732. },
  19733. enumerable: true,
  19734. configurable: true
  19735. });
  19736. Object.defineProperty(ArcRotateCamera.prototype, "keysRight", {
  19737. /**
  19738. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  19739. */
  19740. get: function () {
  19741. var keyboard = this.inputs.attached["keyboard"];
  19742. if (keyboard) {
  19743. return keyboard.keysRight;
  19744. }
  19745. return [];
  19746. },
  19747. set: function (value) {
  19748. var keyboard = this.inputs.attached["keyboard"];
  19749. if (keyboard) {
  19750. keyboard.keysRight = value;
  19751. }
  19752. },
  19753. enumerable: true,
  19754. configurable: true
  19755. });
  19756. Object.defineProperty(ArcRotateCamera.prototype, "wheelPrecision", {
  19757. /**
  19758. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  19759. */
  19760. get: function () {
  19761. var mousewheel = this.inputs.attached["mousewheel"];
  19762. if (mousewheel) {
  19763. return mousewheel.wheelPrecision;
  19764. }
  19765. return 0;
  19766. },
  19767. set: function (value) {
  19768. var mousewheel = this.inputs.attached["mousewheel"];
  19769. if (mousewheel) {
  19770. mousewheel.wheelPrecision = value;
  19771. }
  19772. },
  19773. enumerable: true,
  19774. configurable: true
  19775. });
  19776. Object.defineProperty(ArcRotateCamera.prototype, "wheelDeltaPercentage", {
  19777. /**
  19778. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  19779. * It will be used instead of pinchDeltaPrecision if different from 0.
  19780. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19781. */
  19782. get: function () {
  19783. var mousewheel = this.inputs.attached["mousewheel"];
  19784. if (mousewheel) {
  19785. return mousewheel.wheelDeltaPercentage;
  19786. }
  19787. return 0;
  19788. },
  19789. set: function (value) {
  19790. var mousewheel = this.inputs.attached["mousewheel"];
  19791. if (mousewheel) {
  19792. mousewheel.wheelDeltaPercentage = value;
  19793. }
  19794. },
  19795. enumerable: true,
  19796. configurable: true
  19797. });
  19798. Object.defineProperty(ArcRotateCamera.prototype, "bouncingBehavior", {
  19799. /**
  19800. * Gets the bouncing behavior of the camera if it has been enabled.
  19801. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19802. */
  19803. get: function () {
  19804. return this._bouncingBehavior;
  19805. },
  19806. enumerable: true,
  19807. configurable: true
  19808. });
  19809. Object.defineProperty(ArcRotateCamera.prototype, "useBouncingBehavior", {
  19810. /**
  19811. * Defines if the bouncing behavior of the camera is enabled on the camera.
  19812. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19813. */
  19814. get: function () {
  19815. return this._bouncingBehavior != null;
  19816. },
  19817. set: function (value) {
  19818. if (value === this.useBouncingBehavior) {
  19819. return;
  19820. }
  19821. if (value) {
  19822. this._bouncingBehavior = new _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__["BouncingBehavior"]();
  19823. this.addBehavior(this._bouncingBehavior);
  19824. }
  19825. else if (this._bouncingBehavior) {
  19826. this.removeBehavior(this._bouncingBehavior);
  19827. this._bouncingBehavior = null;
  19828. }
  19829. },
  19830. enumerable: true,
  19831. configurable: true
  19832. });
  19833. Object.defineProperty(ArcRotateCamera.prototype, "framingBehavior", {
  19834. /**
  19835. * Gets the framing behavior of the camera if it has been enabled.
  19836. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19837. */
  19838. get: function () {
  19839. return this._framingBehavior;
  19840. },
  19841. enumerable: true,
  19842. configurable: true
  19843. });
  19844. Object.defineProperty(ArcRotateCamera.prototype, "useFramingBehavior", {
  19845. /**
  19846. * Defines if the framing behavior of the camera is enabled on the camera.
  19847. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19848. */
  19849. get: function () {
  19850. return this._framingBehavior != null;
  19851. },
  19852. set: function (value) {
  19853. if (value === this.useFramingBehavior) {
  19854. return;
  19855. }
  19856. if (value) {
  19857. this._framingBehavior = new _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__["FramingBehavior"]();
  19858. this.addBehavior(this._framingBehavior);
  19859. }
  19860. else if (this._framingBehavior) {
  19861. this.removeBehavior(this._framingBehavior);
  19862. this._framingBehavior = null;
  19863. }
  19864. },
  19865. enumerable: true,
  19866. configurable: true
  19867. });
  19868. Object.defineProperty(ArcRotateCamera.prototype, "autoRotationBehavior", {
  19869. /**
  19870. * Gets the auto rotation behavior of the camera if it has been enabled.
  19871. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19872. */
  19873. get: function () {
  19874. return this._autoRotationBehavior;
  19875. },
  19876. enumerable: true,
  19877. configurable: true
  19878. });
  19879. Object.defineProperty(ArcRotateCamera.prototype, "useAutoRotationBehavior", {
  19880. /**
  19881. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  19882. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19883. */
  19884. get: function () {
  19885. return this._autoRotationBehavior != null;
  19886. },
  19887. set: function (value) {
  19888. if (value === this.useAutoRotationBehavior) {
  19889. return;
  19890. }
  19891. if (value) {
  19892. this._autoRotationBehavior = new _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__["AutoRotationBehavior"]();
  19893. this.addBehavior(this._autoRotationBehavior);
  19894. }
  19895. else if (this._autoRotationBehavior) {
  19896. this.removeBehavior(this._autoRotationBehavior);
  19897. this._autoRotationBehavior = null;
  19898. }
  19899. },
  19900. enumerable: true,
  19901. configurable: true
  19902. });
  19903. // Cache
  19904. /** @hidden */
  19905. ArcRotateCamera.prototype._initCache = function () {
  19906. _super.prototype._initCache.call(this);
  19907. this._cache._target = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  19908. this._cache.alpha = undefined;
  19909. this._cache.beta = undefined;
  19910. this._cache.radius = undefined;
  19911. this._cache.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  19912. };
  19913. /** @hidden */
  19914. ArcRotateCamera.prototype._updateCache = function (ignoreParentClass) {
  19915. if (!ignoreParentClass) {
  19916. _super.prototype._updateCache.call(this);
  19917. }
  19918. this._cache._target.copyFrom(this._getTargetPosition());
  19919. this._cache.alpha = this.alpha;
  19920. this._cache.beta = this.beta;
  19921. this._cache.radius = this.radius;
  19922. this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset);
  19923. };
  19924. ArcRotateCamera.prototype._getTargetPosition = function () {
  19925. if (this._targetHost && this._targetHost.getAbsolutePosition) {
  19926. var pos = this._targetHost.absolutePosition;
  19927. if (this._targetBoundingCenter) {
  19928. pos.addToRef(this._targetBoundingCenter, this._target);
  19929. }
  19930. else {
  19931. this._target.copyFrom(pos);
  19932. }
  19933. }
  19934. var lockedTargetPosition = this._getLockedTargetPosition();
  19935. if (lockedTargetPosition) {
  19936. return lockedTargetPosition;
  19937. }
  19938. return this._target;
  19939. };
  19940. /**
  19941. * Stores the current state of the camera (alpha, beta, radius and target)
  19942. * @returns the camera itself
  19943. */
  19944. ArcRotateCamera.prototype.storeState = function () {
  19945. this._storedAlpha = this.alpha;
  19946. this._storedBeta = this.beta;
  19947. this._storedRadius = this.radius;
  19948. this._storedTarget = this._getTargetPosition().clone();
  19949. return _super.prototype.storeState.call(this);
  19950. };
  19951. /**
  19952. * @hidden
  19953. * Restored camera state. You must call storeState() first
  19954. */
  19955. ArcRotateCamera.prototype._restoreStateValues = function () {
  19956. if (!_super.prototype._restoreStateValues.call(this)) {
  19957. return false;
  19958. }
  19959. this.alpha = this._storedAlpha;
  19960. this.beta = this._storedBeta;
  19961. this.radius = this._storedRadius;
  19962. this.setTarget(this._storedTarget.clone());
  19963. this.inertialAlphaOffset = 0;
  19964. this.inertialBetaOffset = 0;
  19965. this.inertialRadiusOffset = 0;
  19966. this.inertialPanningX = 0;
  19967. this.inertialPanningY = 0;
  19968. return true;
  19969. };
  19970. // Synchronized
  19971. /** @hidden */
  19972. ArcRotateCamera.prototype._isSynchronizedViewMatrix = function () {
  19973. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  19974. return false;
  19975. }
  19976. return this._cache._target.equals(this._getTargetPosition())
  19977. && this._cache.alpha === this.alpha
  19978. && this._cache.beta === this.beta
  19979. && this._cache.radius === this.radius
  19980. && this._cache.targetScreenOffset.equals(this.targetScreenOffset);
  19981. };
  19982. /**
  19983. * Attached controls to the current camera.
  19984. * @param element Defines the element the controls should be listened from
  19985. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19986. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  19987. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  19988. */
  19989. ArcRotateCamera.prototype.attachControl = function (element, noPreventDefault, useCtrlForPanning, panningMouseButton) {
  19990. var _this = this;
  19991. if (useCtrlForPanning === void 0) { useCtrlForPanning = true; }
  19992. if (panningMouseButton === void 0) { panningMouseButton = 2; }
  19993. this._useCtrlForPanning = useCtrlForPanning;
  19994. this._panningMouseButton = panningMouseButton;
  19995. this.inputs.attachElement(element, noPreventDefault);
  19996. this._reset = function () {
  19997. _this.inertialAlphaOffset = 0;
  19998. _this.inertialBetaOffset = 0;
  19999. _this.inertialRadiusOffset = 0;
  20000. _this.inertialPanningX = 0;
  20001. _this.inertialPanningY = 0;
  20002. };
  20003. };
  20004. /**
  20005. * Detach the current controls from the camera.
  20006. * The camera will stop reacting to inputs.
  20007. * @param element Defines the element to stop listening the inputs from
  20008. */
  20009. ArcRotateCamera.prototype.detachControl = function (element) {
  20010. this.inputs.detachElement(element);
  20011. if (this._reset) {
  20012. this._reset();
  20013. }
  20014. };
  20015. /** @hidden */
  20016. ArcRotateCamera.prototype._checkInputs = function () {
  20017. //if (async) collision inspection was triggered, don't update the camera's position - until the collision callback was called.
  20018. if (this._collisionTriggered) {
  20019. return;
  20020. }
  20021. this.inputs.checkInputs();
  20022. // Inertia
  20023. if (this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
  20024. var inertialAlphaOffset = this.inertialAlphaOffset;
  20025. if (this.beta <= 0) {
  20026. inertialAlphaOffset *= -1;
  20027. }
  20028. if (this.getScene().useRightHandedSystem) {
  20029. inertialAlphaOffset *= -1;
  20030. }
  20031. if (this.parent && this.parent._getWorldMatrixDeterminant() < 0) {
  20032. inertialAlphaOffset *= -1;
  20033. }
  20034. this.alpha += inertialAlphaOffset;
  20035. this.beta += this.inertialBetaOffset;
  20036. this.radius -= this.inertialRadiusOffset;
  20037. this.inertialAlphaOffset *= this.inertia;
  20038. this.inertialBetaOffset *= this.inertia;
  20039. this.inertialRadiusOffset *= this.inertia;
  20040. if (Math.abs(this.inertialAlphaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20041. this.inertialAlphaOffset = 0;
  20042. }
  20043. if (Math.abs(this.inertialBetaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20044. this.inertialBetaOffset = 0;
  20045. }
  20046. if (Math.abs(this.inertialRadiusOffset) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20047. this.inertialRadiusOffset = 0;
  20048. }
  20049. }
  20050. // Panning inertia
  20051. if (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) {
  20052. if (!this._localDirection) {
  20053. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  20054. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  20055. }
  20056. this._localDirection.copyFromFloats(this.inertialPanningX, this.inertialPanningY, this.inertialPanningY);
  20057. this._localDirection.multiplyInPlace(this.panningAxis);
  20058. this._viewMatrix.invertToRef(this._cameraTransformMatrix);
  20059. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
  20060. //Eliminate y if map panning is enabled (panningAxis == 1,0,1)
  20061. if (!this.panningAxis.y) {
  20062. this._transformedDirection.y = 0;
  20063. }
  20064. if (!this._targetHost) {
  20065. if (this.panningDistanceLimit) {
  20066. this._transformedDirection.addInPlace(this._target);
  20067. var distanceSquared = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].DistanceSquared(this._transformedDirection, this.panningOriginTarget);
  20068. if (distanceSquared <= (this.panningDistanceLimit * this.panningDistanceLimit)) {
  20069. this._target.copyFrom(this._transformedDirection);
  20070. }
  20071. }
  20072. else {
  20073. this._target.addInPlace(this._transformedDirection);
  20074. }
  20075. }
  20076. this.inertialPanningX *= this.panningInertia;
  20077. this.inertialPanningY *= this.panningInertia;
  20078. if (Math.abs(this.inertialPanningX) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20079. this.inertialPanningX = 0;
  20080. }
  20081. if (Math.abs(this.inertialPanningY) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20082. this.inertialPanningY = 0;
  20083. }
  20084. }
  20085. // Limits
  20086. this._checkLimits();
  20087. _super.prototype._checkInputs.call(this);
  20088. };
  20089. ArcRotateCamera.prototype._checkLimits = function () {
  20090. if (this.lowerBetaLimit === null || this.lowerBetaLimit === undefined) {
  20091. if (this.allowUpsideDown && this.beta > Math.PI) {
  20092. this.beta = this.beta - (2 * Math.PI);
  20093. }
  20094. }
  20095. else {
  20096. if (this.beta < this.lowerBetaLimit) {
  20097. this.beta = this.lowerBetaLimit;
  20098. }
  20099. }
  20100. if (this.upperBetaLimit === null || this.upperBetaLimit === undefined) {
  20101. if (this.allowUpsideDown && this.beta < -Math.PI) {
  20102. this.beta = this.beta + (2 * Math.PI);
  20103. }
  20104. }
  20105. else {
  20106. if (this.beta > this.upperBetaLimit) {
  20107. this.beta = this.upperBetaLimit;
  20108. }
  20109. }
  20110. if (this.lowerAlphaLimit !== null && this.alpha < this.lowerAlphaLimit) {
  20111. this.alpha = this.lowerAlphaLimit;
  20112. }
  20113. if (this.upperAlphaLimit !== null && this.alpha > this.upperAlphaLimit) {
  20114. this.alpha = this.upperAlphaLimit;
  20115. }
  20116. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  20117. this.radius = this.lowerRadiusLimit;
  20118. this.inertialRadiusOffset = 0;
  20119. }
  20120. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  20121. this.radius = this.upperRadiusLimit;
  20122. this.inertialRadiusOffset = 0;
  20123. }
  20124. };
  20125. /**
  20126. * Rebuilds angles (alpha, beta) and radius from the give position and target
  20127. */
  20128. ArcRotateCamera.prototype.rebuildAnglesAndRadius = function () {
  20129. this._position.subtractToRef(this._getTargetPosition(), this._computationVector);
  20130. this.radius = this._computationVector.length();
  20131. if (this.radius === 0) {
  20132. this.radius = 0.0001; // Just to avoid division by zero
  20133. }
  20134. // Alpha
  20135. this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2)));
  20136. if (this._computationVector.z < 0) {
  20137. this.alpha = 2 * Math.PI - this.alpha;
  20138. }
  20139. // Beta
  20140. this.beta = Math.acos(this._computationVector.y / this.radius);
  20141. this._checkLimits();
  20142. };
  20143. /**
  20144. * Use a position to define the current camera related information like aplha, beta and radius
  20145. * @param position Defines the position to set the camera at
  20146. */
  20147. ArcRotateCamera.prototype.setPosition = function (position) {
  20148. if (this._position.equals(position)) {
  20149. return;
  20150. }
  20151. this._position.copyFrom(position);
  20152. this.rebuildAnglesAndRadius();
  20153. };
  20154. /**
  20155. * Defines the target the camera should look at.
  20156. * This will automatically adapt alpha beta and radius to fit within the new target.
  20157. * @param target Defines the new target as a Vector or a mesh
  20158. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  20159. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  20160. */
  20161. ArcRotateCamera.prototype.setTarget = function (target, toBoundingCenter, allowSamePosition) {
  20162. if (toBoundingCenter === void 0) { toBoundingCenter = false; }
  20163. if (allowSamePosition === void 0) { allowSamePosition = false; }
  20164. if (target.getBoundingInfo) {
  20165. if (toBoundingCenter) {
  20166. this._targetBoundingCenter = target.getBoundingInfo().boundingBox.centerWorld.clone();
  20167. }
  20168. else {
  20169. this._targetBoundingCenter = null;
  20170. }
  20171. target.computeWorldMatrix();
  20172. this._targetHost = target;
  20173. this._target = this._getTargetPosition();
  20174. this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
  20175. }
  20176. else {
  20177. var newTarget = target;
  20178. var currentTarget = this._getTargetPosition();
  20179. if (currentTarget && !allowSamePosition && currentTarget.equals(newTarget)) {
  20180. return;
  20181. }
  20182. this._targetHost = null;
  20183. this._target = newTarget;
  20184. this._targetBoundingCenter = null;
  20185. this.onMeshTargetChangedObservable.notifyObservers(null);
  20186. }
  20187. this.rebuildAnglesAndRadius();
  20188. };
  20189. /** @hidden */
  20190. ArcRotateCamera.prototype._getViewMatrix = function () {
  20191. // Compute
  20192. var cosa = Math.cos(this.alpha);
  20193. var sina = Math.sin(this.alpha);
  20194. var cosb = Math.cos(this.beta);
  20195. var sinb = Math.sin(this.beta);
  20196. if (sinb === 0) {
  20197. sinb = 0.0001;
  20198. }
  20199. var target = this._getTargetPosition();
  20200. this._computationVector.copyFromFloats(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb);
  20201. // Rotate according to up vector
  20202. if (this.upVector.x !== 0 || this.upVector.y !== 1.0 || this.upVector.z !== 0) {
  20203. if (!this._tempAxisVector) {
  20204. this._tempAxisVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  20205. this._tempAxisRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  20206. }
  20207. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), this.upVector, this._tempAxisVector);
  20208. this._tempAxisVector.normalize();
  20209. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].UpReadOnly, this.upVector));
  20210. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(this._tempAxisVector, angle, this._tempAxisRotationMatrix);
  20211. this._tempAxisVector.copyFrom(this._computationVector);
  20212. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._tempAxisVector, this._tempAxisRotationMatrix, this._computationVector);
  20213. }
  20214. target.addToRef(this._computationVector, this._newPosition);
  20215. if (this.getScene().collisionsEnabled && this.checkCollisions) {
  20216. var coordinator = this.getScene().collisionCoordinator;
  20217. if (!this._collider) {
  20218. this._collider = coordinator.createCollider();
  20219. }
  20220. this._collider._radius = this.collisionRadius;
  20221. this._newPosition.subtractToRef(this._position, this._collisionVelocity);
  20222. this._collisionTriggered = true;
  20223. coordinator.getNewPosition(this._position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  20224. }
  20225. else {
  20226. this._position.copyFrom(this._newPosition);
  20227. var up = this.upVector;
  20228. if (this.allowUpsideDown && sinb < 0) {
  20229. up = up.clone();
  20230. up = up.negate();
  20231. }
  20232. this._computeViewMatrix(this._position, target, up);
  20233. this._viewMatrix.addAtIndex(12, this.targetScreenOffset.x);
  20234. this._viewMatrix.addAtIndex(13, this.targetScreenOffset.y);
  20235. }
  20236. this._currentTarget = target;
  20237. return this._viewMatrix;
  20238. };
  20239. /**
  20240. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  20241. * @param meshes Defines the mesh to zoom on
  20242. * @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)
  20243. */
  20244. ArcRotateCamera.prototype.zoomOn = function (meshes, doNotUpdateMaxZ) {
  20245. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  20246. meshes = meshes || this.getScene().meshes;
  20247. var minMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  20248. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(minMaxVector.min, minMaxVector.max);
  20249. this.radius = distance * this.zoomOnFactor;
  20250. this.focusOn({ min: minMaxVector.min, max: minMaxVector.max, distance: distance }, doNotUpdateMaxZ);
  20251. };
  20252. /**
  20253. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  20254. * The target will be changed but the radius
  20255. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  20256. * @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)
  20257. */
  20258. ArcRotateCamera.prototype.focusOn = function (meshesOrMinMaxVectorAndDistance, doNotUpdateMaxZ) {
  20259. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  20260. var meshesOrMinMaxVector;
  20261. var distance;
  20262. if (meshesOrMinMaxVectorAndDistance.min === undefined) { // meshes
  20263. var meshes = meshesOrMinMaxVectorAndDistance || this.getScene().meshes;
  20264. meshesOrMinMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  20265. distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(meshesOrMinMaxVector.min, meshesOrMinMaxVector.max);
  20266. }
  20267. else { //minMaxVector and distance
  20268. var minMaxVectorAndDistance = meshesOrMinMaxVectorAndDistance;
  20269. meshesOrMinMaxVector = minMaxVectorAndDistance;
  20270. distance = minMaxVectorAndDistance.distance;
  20271. }
  20272. this._target = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].Center(meshesOrMinMaxVector);
  20273. if (!doNotUpdateMaxZ) {
  20274. this.maxZ = distance * 2;
  20275. }
  20276. };
  20277. /**
  20278. * @override
  20279. * Override Camera.createRigCamera
  20280. */
  20281. ArcRotateCamera.prototype.createRigCamera = function (name, cameraIndex) {
  20282. var alphaShift = 0;
  20283. switch (this.cameraRigMode) {
  20284. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  20285. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  20286. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  20287. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  20288. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? 1 : -1);
  20289. break;
  20290. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  20291. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? -1 : 1);
  20292. break;
  20293. }
  20294. var rigCam = new ArcRotateCamera(name, this.alpha + alphaShift, this.beta, this.radius, this._target, this.getScene());
  20295. rigCam._cameraRigParams = {};
  20296. return rigCam;
  20297. };
  20298. /**
  20299. * @hidden
  20300. * @override
  20301. * Override Camera._updateRigCameras
  20302. */
  20303. ArcRotateCamera.prototype._updateRigCameras = function () {
  20304. var camLeft = this._rigCameras[0];
  20305. var camRight = this._rigCameras[1];
  20306. camLeft.beta = camRight.beta = this.beta;
  20307. switch (this.cameraRigMode) {
  20308. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  20309. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  20310. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  20311. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  20312. camLeft.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  20313. camRight.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  20314. break;
  20315. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  20316. camLeft.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  20317. camRight.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  20318. break;
  20319. }
  20320. _super.prototype._updateRigCameras.call(this);
  20321. };
  20322. /**
  20323. * Destroy the camera and release the current resources hold by it.
  20324. */
  20325. ArcRotateCamera.prototype.dispose = function () {
  20326. this.inputs.clear();
  20327. _super.prototype.dispose.call(this);
  20328. };
  20329. /**
  20330. * Gets the current object class name.
  20331. * @return the class name
  20332. */
  20333. ArcRotateCamera.prototype.getClassName = function () {
  20334. return "ArcRotateCamera";
  20335. };
  20336. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20337. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20338. ], ArcRotateCamera.prototype, "alpha", void 0);
  20339. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20340. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20341. ], ArcRotateCamera.prototype, "beta", void 0);
  20342. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20343. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20344. ], ArcRotateCamera.prototype, "radius", void 0);
  20345. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20346. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("target")
  20347. ], ArcRotateCamera.prototype, "_target", void 0);
  20348. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20349. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20350. ], ArcRotateCamera.prototype, "inertialAlphaOffset", void 0);
  20351. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20352. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20353. ], ArcRotateCamera.prototype, "inertialBetaOffset", void 0);
  20354. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20355. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20356. ], ArcRotateCamera.prototype, "inertialRadiusOffset", void 0);
  20357. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20358. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20359. ], ArcRotateCamera.prototype, "lowerAlphaLimit", void 0);
  20360. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20361. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20362. ], ArcRotateCamera.prototype, "upperAlphaLimit", void 0);
  20363. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20364. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20365. ], ArcRotateCamera.prototype, "lowerBetaLimit", void 0);
  20366. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20367. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20368. ], ArcRotateCamera.prototype, "upperBetaLimit", void 0);
  20369. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20370. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20371. ], ArcRotateCamera.prototype, "lowerRadiusLimit", void 0);
  20372. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20373. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20374. ], ArcRotateCamera.prototype, "upperRadiusLimit", void 0);
  20375. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20376. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20377. ], ArcRotateCamera.prototype, "inertialPanningX", void 0);
  20378. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20379. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20380. ], ArcRotateCamera.prototype, "inertialPanningY", void 0);
  20381. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20382. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20383. ], ArcRotateCamera.prototype, "pinchToPanMaxDistance", void 0);
  20384. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20385. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20386. ], ArcRotateCamera.prototype, "panningDistanceLimit", void 0);
  20387. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20388. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  20389. ], ArcRotateCamera.prototype, "panningOriginTarget", void 0);
  20390. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20391. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20392. ], ArcRotateCamera.prototype, "panningInertia", void 0);
  20393. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20394. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20395. ], ArcRotateCamera.prototype, "zoomOnFactor", void 0);
  20396. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20397. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20398. ], ArcRotateCamera.prototype, "targetScreenOffset", void 0);
  20399. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20400. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20401. ], ArcRotateCamera.prototype, "allowUpsideDown", void 0);
  20402. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20403. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20404. ], ArcRotateCamera.prototype, "useInputToRestoreState", void 0);
  20405. return ArcRotateCamera;
  20406. }(_targetCamera__WEBPACK_IMPORTED_MODULE_10__["TargetCamera"]));
  20407. /***/ }),
  20408. /***/ "./Cameras/arcRotateCameraInputsManager.ts":
  20409. /*!*************************************************!*\
  20410. !*** ./Cameras/arcRotateCameraInputsManager.ts ***!
  20411. \*************************************************/
  20412. /*! exports provided: ArcRotateCameraInputsManager */
  20413. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20414. "use strict";
  20415. __webpack_require__.r(__webpack_exports__);
  20416. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return ArcRotateCameraInputsManager; });
  20417. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  20418. /* harmony import */ var _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  20419. /* harmony import */ var _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  20420. /* harmony import */ var _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  20421. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  20422. /**
  20423. * Default Inputs manager for the ArcRotateCamera.
  20424. * It groups all the default supported inputs for ease of use.
  20425. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  20426. */
  20427. var ArcRotateCameraInputsManager = /** @class */ (function (_super) {
  20428. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraInputsManager, _super);
  20429. /**
  20430. * Instantiates a new ArcRotateCameraInputsManager.
  20431. * @param camera Defines the camera the inputs belong to
  20432. */
  20433. function ArcRotateCameraInputsManager(camera) {
  20434. return _super.call(this, camera) || this;
  20435. }
  20436. /**
  20437. * Add mouse wheel input support to the input manager.
  20438. * @returns the current input manager
  20439. */
  20440. ArcRotateCameraInputsManager.prototype.addMouseWheel = function () {
  20441. this.add(new _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraMouseWheelInput"]());
  20442. return this;
  20443. };
  20444. /**
  20445. * Add pointers input support to the input manager.
  20446. * @returns the current input manager
  20447. */
  20448. ArcRotateCameraInputsManager.prototype.addPointers = function () {
  20449. this.add(new _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraPointersInput"]());
  20450. return this;
  20451. };
  20452. /**
  20453. * Add keyboard input support to the input manager.
  20454. * @returns the current input manager
  20455. */
  20456. ArcRotateCameraInputsManager.prototype.addKeyboard = function () {
  20457. this.add(new _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraKeyboardMoveInput"]());
  20458. return this;
  20459. };
  20460. return ArcRotateCameraInputsManager;
  20461. }(_Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__["CameraInputsManager"]));
  20462. /***/ }),
  20463. /***/ "./Cameras/camera.ts":
  20464. /*!***************************!*\
  20465. !*** ./Cameras/camera.ts ***!
  20466. \***************************/
  20467. /*! exports provided: Camera */
  20468. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20469. "use strict";
  20470. __webpack_require__.r(__webpack_exports__);
  20471. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return Camera; });
  20472. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  20473. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  20474. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  20475. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  20476. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  20477. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  20478. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  20479. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  20480. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  20481. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  20482. /**
  20483. * This is the base class of all the camera used in the application.
  20484. * @see http://doc.babylonjs.com/features/cameras
  20485. */
  20486. var Camera = /** @class */ (function (_super) {
  20487. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Camera, _super);
  20488. /**
  20489. * Instantiates a new camera object.
  20490. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  20491. * @see http://doc.babylonjs.com/features/cameras
  20492. * @param name Defines the name of the camera in the scene
  20493. * @param position Defines the position of the camera
  20494. * @param scene Defines the scene the camera belongs too
  20495. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  20496. */
  20497. function Camera(name, position, scene, setActiveOnSceneIfNoneActive) {
  20498. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  20499. var _this = _super.call(this, name, scene) || this;
  20500. /** @hidden */
  20501. _this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20502. /**
  20503. * The vector the camera should consider as up.
  20504. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  20505. */
  20506. _this.upVector = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Up();
  20507. /**
  20508. * Define the current limit on the left side for an orthographic camera
  20509. * In scene unit
  20510. */
  20511. _this.orthoLeft = null;
  20512. /**
  20513. * Define the current limit on the right side for an orthographic camera
  20514. * In scene unit
  20515. */
  20516. _this.orthoRight = null;
  20517. /**
  20518. * Define the current limit on the bottom side for an orthographic camera
  20519. * In scene unit
  20520. */
  20521. _this.orthoBottom = null;
  20522. /**
  20523. * Define the current limit on the top side for an orthographic camera
  20524. * In scene unit
  20525. */
  20526. _this.orthoTop = null;
  20527. /**
  20528. * Field Of View is set in Radians. (default is 0.8)
  20529. */
  20530. _this.fov = 0.8;
  20531. /**
  20532. * Define the minimum distance the camera can see from.
  20533. * This is important to note that the depth buffer are not infinite and the closer it starts
  20534. * the more your scene might encounter depth fighting issue.
  20535. */
  20536. _this.minZ = 1;
  20537. /**
  20538. * Define the maximum distance the camera can see to.
  20539. * This is important to note that the depth buffer are not infinite and the further it end
  20540. * the more your scene might encounter depth fighting issue.
  20541. */
  20542. _this.maxZ = 10000.0;
  20543. /**
  20544. * Define the default inertia of the camera.
  20545. * This helps giving a smooth feeling to the camera movement.
  20546. */
  20547. _this.inertia = 0.9;
  20548. /**
  20549. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  20550. */
  20551. _this.mode = Camera.PERSPECTIVE_CAMERA;
  20552. /**
  20553. * Define wether the camera is intermediate.
  20554. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  20555. */
  20556. _this.isIntermediate = false;
  20557. /**
  20558. * Define the viewport of the camera.
  20559. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  20560. */
  20561. _this.viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Viewport"](0, 0, 1.0, 1.0);
  20562. /**
  20563. * Restricts the camera to viewing objects with the same layerMask.
  20564. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  20565. */
  20566. _this.layerMask = 0x0FFFFFFF;
  20567. /**
  20568. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  20569. */
  20570. _this.fovMode = Camera.FOVMODE_VERTICAL_FIXED;
  20571. /**
  20572. * Rig mode of the camera.
  20573. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  20574. * This is normally controlled byt the camera themselves as internal use.
  20575. */
  20576. _this.cameraRigMode = Camera.RIG_MODE_NONE;
  20577. /**
  20578. * 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
  20579. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  20580. * else in the scene.
  20581. */
  20582. _this.customRenderTargets = new Array();
  20583. /**
  20584. * When set, the camera will render to this render target instead of the default canvas
  20585. */
  20586. _this.outputRenderTarget = null;
  20587. /**
  20588. * Observable triggered when the camera view matrix has changed.
  20589. */
  20590. _this.onViewMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20591. /**
  20592. * Observable triggered when the camera Projection matrix has changed.
  20593. */
  20594. _this.onProjectionMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20595. /**
  20596. * Observable triggered when the inputs have been processed.
  20597. */
  20598. _this.onAfterCheckInputsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20599. /**
  20600. * Observable triggered when reset has been called and applied to the camera.
  20601. */
  20602. _this.onRestoreStateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20603. /** @hidden */
  20604. _this._rigCameras = new Array();
  20605. _this._webvrViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20606. /** @hidden */
  20607. _this._skipRendering = false;
  20608. /** @hidden */
  20609. _this._projectionMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  20610. /** @hidden */
  20611. _this._postProcesses = new Array();
  20612. /** @hidden */
  20613. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](256);
  20614. _this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20615. /** hidden */
  20616. _this._computedViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20617. _this._doNotComputeProjectionMatrix = false;
  20618. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Zero();
  20619. _this._refreshFrustumPlanes = true;
  20620. /** @hidden */
  20621. _this._isCamera = true;
  20622. /** @hidden */
  20623. _this._isLeftCamera = false;
  20624. /** @hidden */
  20625. _this._isRightCamera = true;
  20626. _this.getScene().addCamera(_this);
  20627. if (setActiveOnSceneIfNoneActive && !_this.getScene().activeCamera) {
  20628. _this.getScene().activeCamera = _this;
  20629. }
  20630. _this.position = position;
  20631. return _this;
  20632. }
  20633. Object.defineProperty(Camera.prototype, "position", {
  20634. /**
  20635. * Define the current local position of the camera in the scene
  20636. */
  20637. get: function () {
  20638. return this._position;
  20639. },
  20640. set: function (newPosition) {
  20641. this._position = newPosition;
  20642. },
  20643. enumerable: true,
  20644. configurable: true
  20645. });
  20646. /**
  20647. * Store current camera state (fov, position, etc..)
  20648. * @returns the camera
  20649. */
  20650. Camera.prototype.storeState = function () {
  20651. this._stateStored = true;
  20652. this._storedFov = this.fov;
  20653. return this;
  20654. };
  20655. /**
  20656. * Restores the camera state values if it has been stored. You must call storeState() first
  20657. */
  20658. Camera.prototype._restoreStateValues = function () {
  20659. if (!this._stateStored) {
  20660. return false;
  20661. }
  20662. this.fov = this._storedFov;
  20663. return true;
  20664. };
  20665. /**
  20666. * Restored camera state. You must call storeState() first.
  20667. * @returns true if restored and false otherwise
  20668. */
  20669. Camera.prototype.restoreState = function () {
  20670. if (this._restoreStateValues()) {
  20671. this.onRestoreStateObservable.notifyObservers(this);
  20672. return true;
  20673. }
  20674. return false;
  20675. };
  20676. /**
  20677. * Gets the class name of the camera.
  20678. * @returns the class name
  20679. */
  20680. Camera.prototype.getClassName = function () {
  20681. return "Camera";
  20682. };
  20683. /**
  20684. * Gets a string representation of the camera useful for debug purpose.
  20685. * @param fullDetails Defines that a more verboe level of logging is required
  20686. * @returns the string representation
  20687. */
  20688. Camera.prototype.toString = function (fullDetails) {
  20689. var ret = "Name: " + this.name;
  20690. ret += ", type: " + this.getClassName();
  20691. if (this.animations) {
  20692. for (var i = 0; i < this.animations.length; i++) {
  20693. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  20694. }
  20695. }
  20696. if (fullDetails) {
  20697. }
  20698. return ret;
  20699. };
  20700. Object.defineProperty(Camera.prototype, "globalPosition", {
  20701. /**
  20702. * Gets the current world space position of the camera.
  20703. */
  20704. get: function () {
  20705. return this._globalPosition;
  20706. },
  20707. enumerable: true,
  20708. configurable: true
  20709. });
  20710. /**
  20711. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  20712. * @returns the active meshe list
  20713. */
  20714. Camera.prototype.getActiveMeshes = function () {
  20715. return this._activeMeshes;
  20716. };
  20717. /**
  20718. * Check wether a mesh is part of the current active mesh list of the camera
  20719. * @param mesh Defines the mesh to check
  20720. * @returns true if active, false otherwise
  20721. */
  20722. Camera.prototype.isActiveMesh = function (mesh) {
  20723. return (this._activeMeshes.indexOf(mesh) !== -1);
  20724. };
  20725. /**
  20726. * Is this camera ready to be used/rendered
  20727. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  20728. * @return true if the camera is ready
  20729. */
  20730. Camera.prototype.isReady = function (completeCheck) {
  20731. if (completeCheck === void 0) { completeCheck = false; }
  20732. if (completeCheck) {
  20733. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  20734. var pp = _a[_i];
  20735. if (pp && !pp.isReady()) {
  20736. return false;
  20737. }
  20738. }
  20739. }
  20740. return _super.prototype.isReady.call(this, completeCheck);
  20741. };
  20742. /** @hidden */
  20743. Camera.prototype._initCache = function () {
  20744. _super.prototype._initCache.call(this);
  20745. this._cache.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20746. this._cache.upVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20747. this._cache.mode = undefined;
  20748. this._cache.minZ = undefined;
  20749. this._cache.maxZ = undefined;
  20750. this._cache.fov = undefined;
  20751. this._cache.fovMode = undefined;
  20752. this._cache.aspectRatio = undefined;
  20753. this._cache.orthoLeft = undefined;
  20754. this._cache.orthoRight = undefined;
  20755. this._cache.orthoBottom = undefined;
  20756. this._cache.orthoTop = undefined;
  20757. this._cache.renderWidth = undefined;
  20758. this._cache.renderHeight = undefined;
  20759. };
  20760. /** @hidden */
  20761. Camera.prototype._updateCache = function (ignoreParentClass) {
  20762. if (!ignoreParentClass) {
  20763. _super.prototype._updateCache.call(this);
  20764. }
  20765. this._cache.position.copyFrom(this.position);
  20766. this._cache.upVector.copyFrom(this.upVector);
  20767. };
  20768. /** @hidden */
  20769. Camera.prototype._isSynchronized = function () {
  20770. return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix();
  20771. };
  20772. /** @hidden */
  20773. Camera.prototype._isSynchronizedViewMatrix = function () {
  20774. if (!_super.prototype._isSynchronized.call(this)) {
  20775. return false;
  20776. }
  20777. return this._cache.position.equals(this.position)
  20778. && this._cache.upVector.equals(this.upVector)
  20779. && this.isSynchronizedWithParent();
  20780. };
  20781. /** @hidden */
  20782. Camera.prototype._isSynchronizedProjectionMatrix = function () {
  20783. var check = this._cache.mode === this.mode
  20784. && this._cache.minZ === this.minZ
  20785. && this._cache.maxZ === this.maxZ;
  20786. if (!check) {
  20787. return false;
  20788. }
  20789. var engine = this.getEngine();
  20790. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  20791. check = this._cache.fov === this.fov
  20792. && this._cache.fovMode === this.fovMode
  20793. && this._cache.aspectRatio === engine.getAspectRatio(this);
  20794. }
  20795. else {
  20796. check = this._cache.orthoLeft === this.orthoLeft
  20797. && this._cache.orthoRight === this.orthoRight
  20798. && this._cache.orthoBottom === this.orthoBottom
  20799. && this._cache.orthoTop === this.orthoTop
  20800. && this._cache.renderWidth === engine.getRenderWidth()
  20801. && this._cache.renderHeight === engine.getRenderHeight();
  20802. }
  20803. return check;
  20804. };
  20805. /**
  20806. * Attach the input controls to a specific dom element to get the input from.
  20807. * @param element Defines the element the controls should be listened from
  20808. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  20809. */
  20810. Camera.prototype.attachControl = function (element, noPreventDefault) {
  20811. };
  20812. /**
  20813. * Detach the current controls from the specified dom element.
  20814. * @param element Defines the element to stop listening the inputs from
  20815. */
  20816. Camera.prototype.detachControl = function (element) {
  20817. };
  20818. /**
  20819. * Update the camera state according to the different inputs gathered during the frame.
  20820. */
  20821. Camera.prototype.update = function () {
  20822. this._checkInputs();
  20823. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20824. this._updateRigCameras();
  20825. }
  20826. };
  20827. /** @hidden */
  20828. Camera.prototype._checkInputs = function () {
  20829. this.onAfterCheckInputsObservable.notifyObservers(this);
  20830. };
  20831. Object.defineProperty(Camera.prototype, "rigCameras", {
  20832. /** @hidden */
  20833. get: function () {
  20834. return this._rigCameras;
  20835. },
  20836. enumerable: true,
  20837. configurable: true
  20838. });
  20839. Object.defineProperty(Camera.prototype, "rigPostProcess", {
  20840. /**
  20841. * Gets the post process used by the rig cameras
  20842. */
  20843. get: function () {
  20844. return this._rigPostProcess;
  20845. },
  20846. enumerable: true,
  20847. configurable: true
  20848. });
  20849. /**
  20850. * Internal, gets the first post proces.
  20851. * @returns the first post process to be run on this camera.
  20852. */
  20853. Camera.prototype._getFirstPostProcess = function () {
  20854. for (var ppIndex = 0; ppIndex < this._postProcesses.length; ppIndex++) {
  20855. if (this._postProcesses[ppIndex] !== null) {
  20856. return this._postProcesses[ppIndex];
  20857. }
  20858. }
  20859. return null;
  20860. };
  20861. Camera.prototype._cascadePostProcessesToRigCams = function () {
  20862. // invalidate framebuffer
  20863. var firstPostProcess = this._getFirstPostProcess();
  20864. if (firstPostProcess) {
  20865. firstPostProcess.markTextureDirty();
  20866. }
  20867. // glue the rigPostProcess to the end of the user postprocesses & assign to each sub-camera
  20868. for (var i = 0, len = this._rigCameras.length; i < len; i++) {
  20869. var cam = this._rigCameras[i];
  20870. var rigPostProcess = cam._rigPostProcess;
  20871. // for VR rig, there does not have to be a post process
  20872. if (rigPostProcess) {
  20873. var isPass = rigPostProcess.getEffectName() === "pass";
  20874. if (isPass) {
  20875. // any rig which has a PassPostProcess for rig[0], cannot be isIntermediate when there are also user postProcesses
  20876. cam.isIntermediate = this._postProcesses.length === 0;
  20877. }
  20878. cam._postProcesses = this._postProcesses.slice(0).concat(rigPostProcess);
  20879. rigPostProcess.markTextureDirty();
  20880. }
  20881. else {
  20882. cam._postProcesses = this._postProcesses.slice(0);
  20883. }
  20884. }
  20885. };
  20886. /**
  20887. * Attach a post process to the camera.
  20888. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20889. * @param postProcess The post process to attach to the camera
  20890. * @param insertAt The position of the post process in case several of them are in use in the scene
  20891. * @returns the position the post process has been inserted at
  20892. */
  20893. Camera.prototype.attachPostProcess = function (postProcess, insertAt) {
  20894. if (insertAt === void 0) { insertAt = null; }
  20895. if (!postProcess.isReusable() && this._postProcesses.indexOf(postProcess) > -1) {
  20896. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("You're trying to reuse a post process not defined as reusable.");
  20897. return 0;
  20898. }
  20899. if (insertAt == null || insertAt < 0) {
  20900. this._postProcesses.push(postProcess);
  20901. }
  20902. else if (this._postProcesses[insertAt] === null) {
  20903. this._postProcesses[insertAt] = postProcess;
  20904. }
  20905. else {
  20906. this._postProcesses.splice(insertAt, 0, postProcess);
  20907. }
  20908. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  20909. return this._postProcesses.indexOf(postProcess);
  20910. };
  20911. /**
  20912. * Detach a post process to the camera.
  20913. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20914. * @param postProcess The post process to detach from the camera
  20915. */
  20916. Camera.prototype.detachPostProcess = function (postProcess) {
  20917. var idx = this._postProcesses.indexOf(postProcess);
  20918. if (idx !== -1) {
  20919. this._postProcesses[idx] = null;
  20920. }
  20921. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  20922. };
  20923. /**
  20924. * Gets the current world matrix of the camera
  20925. */
  20926. Camera.prototype.getWorldMatrix = function () {
  20927. if (this._isSynchronizedViewMatrix()) {
  20928. return this._worldMatrix;
  20929. }
  20930. // Getting the the view matrix will also compute the world matrix.
  20931. this.getViewMatrix();
  20932. return this._worldMatrix;
  20933. };
  20934. /** @hidden */
  20935. Camera.prototype._getViewMatrix = function () {
  20936. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20937. };
  20938. /**
  20939. * Gets the current view matrix of the camera.
  20940. * @param force forces the camera to recompute the matrix without looking at the cached state
  20941. * @returns the view matrix
  20942. */
  20943. Camera.prototype.getViewMatrix = function (force) {
  20944. if (!force && this._isSynchronizedViewMatrix()) {
  20945. return this._computedViewMatrix;
  20946. }
  20947. this.updateCache();
  20948. this._computedViewMatrix = this._getViewMatrix();
  20949. this._currentRenderId = this.getScene().getRenderId();
  20950. this._childUpdateId++;
  20951. this._refreshFrustumPlanes = true;
  20952. if (this._cameraRigParams && this._cameraRigParams.vrPreViewMatrix) {
  20953. this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix, this._computedViewMatrix);
  20954. }
  20955. this.onViewMatrixChangedObservable.notifyObservers(this);
  20956. this._computedViewMatrix.invertToRef(this._worldMatrix);
  20957. return this._computedViewMatrix;
  20958. };
  20959. /**
  20960. * Freeze the projection matrix.
  20961. * It will prevent the cache check of the camera projection compute and can speed up perf
  20962. * if no parameter of the camera are meant to change
  20963. * @param projection Defines manually a projection if necessary
  20964. */
  20965. Camera.prototype.freezeProjectionMatrix = function (projection) {
  20966. this._doNotComputeProjectionMatrix = true;
  20967. if (projection !== undefined) {
  20968. this._projectionMatrix = projection;
  20969. }
  20970. };
  20971. /**
  20972. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  20973. */
  20974. Camera.prototype.unfreezeProjectionMatrix = function () {
  20975. this._doNotComputeProjectionMatrix = false;
  20976. };
  20977. /**
  20978. * Gets the current projection matrix of the camera.
  20979. * @param force forces the camera to recompute the matrix without looking at the cached state
  20980. * @returns the projection matrix
  20981. */
  20982. Camera.prototype.getProjectionMatrix = function (force) {
  20983. if (this._doNotComputeProjectionMatrix || (!force && this._isSynchronizedProjectionMatrix())) {
  20984. return this._projectionMatrix;
  20985. }
  20986. // Cache
  20987. this._cache.mode = this.mode;
  20988. this._cache.minZ = this.minZ;
  20989. this._cache.maxZ = this.maxZ;
  20990. // Matrix
  20991. this._refreshFrustumPlanes = true;
  20992. var engine = this.getEngine();
  20993. var scene = this.getScene();
  20994. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  20995. this._cache.fov = this.fov;
  20996. this._cache.fovMode = this.fovMode;
  20997. this._cache.aspectRatio = engine.getAspectRatio(this);
  20998. if (this.minZ <= 0) {
  20999. this.minZ = 0.1;
  21000. }
  21001. if (scene.useRightHandedSystem) {
  21002. _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);
  21003. }
  21004. else {
  21005. _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);
  21006. }
  21007. }
  21008. else {
  21009. var halfWidth = engine.getRenderWidth() / 2.0;
  21010. var halfHeight = engine.getRenderHeight() / 2.0;
  21011. if (scene.useRightHandedSystem) {
  21012. _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);
  21013. }
  21014. else {
  21015. _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);
  21016. }
  21017. this._cache.orthoLeft = this.orthoLeft;
  21018. this._cache.orthoRight = this.orthoRight;
  21019. this._cache.orthoBottom = this.orthoBottom;
  21020. this._cache.orthoTop = this.orthoTop;
  21021. this._cache.renderWidth = engine.getRenderWidth();
  21022. this._cache.renderHeight = engine.getRenderHeight();
  21023. }
  21024. this.onProjectionMatrixChangedObservable.notifyObservers(this);
  21025. return this._projectionMatrix;
  21026. };
  21027. /**
  21028. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  21029. * @returns a Matrix
  21030. */
  21031. Camera.prototype.getTransformationMatrix = function () {
  21032. this._computedViewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  21033. return this._transformMatrix;
  21034. };
  21035. Camera.prototype._updateFrustumPlanes = function () {
  21036. if (!this._refreshFrustumPlanes) {
  21037. return;
  21038. }
  21039. this.getTransformationMatrix();
  21040. if (!this._frustumPlanes) {
  21041. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanes(this._transformMatrix);
  21042. }
  21043. else {
  21044. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  21045. }
  21046. this._refreshFrustumPlanes = false;
  21047. };
  21048. /**
  21049. * Checks if a cullable object (mesh...) is in the camera frustum
  21050. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  21051. * @param target The object to check
  21052. * @returns true if the object is in frustum otherwise false
  21053. */
  21054. Camera.prototype.isInFrustum = function (target) {
  21055. this._updateFrustumPlanes();
  21056. return target.isInFrustum(this._frustumPlanes);
  21057. };
  21058. /**
  21059. * Checks if a cullable object (mesh...) is in the camera frustum
  21060. * Unlike isInFrustum this cheks the full bounding box
  21061. * @param target The object to check
  21062. * @returns true if the object is in frustum otherwise false
  21063. */
  21064. Camera.prototype.isCompletelyInFrustum = function (target) {
  21065. this._updateFrustumPlanes();
  21066. return target.isCompletelyInFrustum(this._frustumPlanes);
  21067. };
  21068. /**
  21069. * Gets a ray in the forward direction from the camera.
  21070. * @param length Defines the length of the ray to create
  21071. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  21072. * @param origin Defines the start point of the ray which defaults to the camera position
  21073. * @returns the forward ray
  21074. */
  21075. Camera.prototype.getForwardRay = function (length, transform, origin) {
  21076. if (length === void 0) { length = 100; }
  21077. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("Ray");
  21078. };
  21079. /**
  21080. * Releases resources associated with this node.
  21081. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21082. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21083. */
  21084. Camera.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  21085. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  21086. // Observables
  21087. this.onViewMatrixChangedObservable.clear();
  21088. this.onProjectionMatrixChangedObservable.clear();
  21089. this.onAfterCheckInputsObservable.clear();
  21090. this.onRestoreStateObservable.clear();
  21091. // Inputs
  21092. if (this.inputs) {
  21093. this.inputs.clear();
  21094. }
  21095. // Animations
  21096. this.getScene().stopAnimation(this);
  21097. // Remove from scene
  21098. this.getScene().removeCamera(this);
  21099. while (this._rigCameras.length > 0) {
  21100. var camera = this._rigCameras.pop();
  21101. if (camera) {
  21102. camera.dispose();
  21103. }
  21104. }
  21105. // Postprocesses
  21106. if (this._rigPostProcess) {
  21107. this._rigPostProcess.dispose(this);
  21108. this._rigPostProcess = null;
  21109. this._postProcesses = [];
  21110. }
  21111. else if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  21112. this._rigPostProcess = null;
  21113. this._postProcesses = [];
  21114. }
  21115. else {
  21116. var i = this._postProcesses.length;
  21117. while (--i >= 0) {
  21118. var postProcess = this._postProcesses[i];
  21119. if (postProcess) {
  21120. postProcess.dispose(this);
  21121. }
  21122. }
  21123. }
  21124. // Render targets
  21125. var i = this.customRenderTargets.length;
  21126. while (--i >= 0) {
  21127. this.customRenderTargets[i].dispose();
  21128. }
  21129. this.customRenderTargets = [];
  21130. // Active Meshes
  21131. this._activeMeshes.dispose();
  21132. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  21133. };
  21134. Object.defineProperty(Camera.prototype, "isLeftCamera", {
  21135. /**
  21136. * Gets the left camera of a rig setup in case of Rigged Camera
  21137. */
  21138. get: function () {
  21139. return this._isLeftCamera;
  21140. },
  21141. enumerable: true,
  21142. configurable: true
  21143. });
  21144. Object.defineProperty(Camera.prototype, "isRightCamera", {
  21145. /**
  21146. * Gets the right camera of a rig setup in case of Rigged Camera
  21147. */
  21148. get: function () {
  21149. return this._isRightCamera;
  21150. },
  21151. enumerable: true,
  21152. configurable: true
  21153. });
  21154. Object.defineProperty(Camera.prototype, "leftCamera", {
  21155. /**
  21156. * Gets the left camera of a rig setup in case of Rigged Camera
  21157. */
  21158. get: function () {
  21159. if (this._rigCameras.length < 1) {
  21160. return null;
  21161. }
  21162. return this._rigCameras[0];
  21163. },
  21164. enumerable: true,
  21165. configurable: true
  21166. });
  21167. Object.defineProperty(Camera.prototype, "rightCamera", {
  21168. /**
  21169. * Gets the right camera of a rig setup in case of Rigged Camera
  21170. */
  21171. get: function () {
  21172. if (this._rigCameras.length < 2) {
  21173. return null;
  21174. }
  21175. return this._rigCameras[1];
  21176. },
  21177. enumerable: true,
  21178. configurable: true
  21179. });
  21180. /**
  21181. * Gets the left camera target of a rig setup in case of Rigged Camera
  21182. * @returns the target position
  21183. */
  21184. Camera.prototype.getLeftTarget = function () {
  21185. if (this._rigCameras.length < 1) {
  21186. return null;
  21187. }
  21188. return this._rigCameras[0].getTarget();
  21189. };
  21190. /**
  21191. * Gets the right camera target of a rig setup in case of Rigged Camera
  21192. * @returns the target position
  21193. */
  21194. Camera.prototype.getRightTarget = function () {
  21195. if (this._rigCameras.length < 2) {
  21196. return null;
  21197. }
  21198. return this._rigCameras[1].getTarget();
  21199. };
  21200. /**
  21201. * @hidden
  21202. */
  21203. Camera.prototype.setCameraRigMode = function (mode, rigParams) {
  21204. if (this.cameraRigMode === mode) {
  21205. return;
  21206. }
  21207. while (this._rigCameras.length > 0) {
  21208. var camera = this._rigCameras.pop();
  21209. if (camera) {
  21210. camera.dispose();
  21211. }
  21212. }
  21213. this.cameraRigMode = mode;
  21214. this._cameraRigParams = {};
  21215. //we have to implement stereo camera calcultating left and right viewpoints from interaxialDistance and target,
  21216. //not from a given angle as it is now, but until that complete code rewriting provisional stereoHalfAngle value is introduced
  21217. this._cameraRigParams.interaxialDistance = rigParams.interaxialDistance || 0.0637;
  21218. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(this._cameraRigParams.interaxialDistance / 0.0637);
  21219. // create the rig cameras, unless none
  21220. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  21221. var leftCamera = this.createRigCamera(this.name + "_L", 0);
  21222. if (leftCamera) {
  21223. leftCamera._isLeftCamera = true;
  21224. }
  21225. var rightCamera = this.createRigCamera(this.name + "_R", 1);
  21226. if (rightCamera) {
  21227. rightCamera._isRightCamera = true;
  21228. }
  21229. if (leftCamera && rightCamera) {
  21230. this._rigCameras.push(leftCamera);
  21231. this._rigCameras.push(rightCamera);
  21232. }
  21233. }
  21234. switch (this.cameraRigMode) {
  21235. case Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  21236. Camera._setStereoscopicAnaglyphRigMode(this);
  21237. break;
  21238. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  21239. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  21240. case Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  21241. Camera._setStereoscopicRigMode(this);
  21242. break;
  21243. case Camera.RIG_MODE_VR:
  21244. Camera._setVRRigMode(this, rigParams);
  21245. break;
  21246. case Camera.RIG_MODE_WEBVR:
  21247. Camera._setWebVRRigMode(this, rigParams);
  21248. break;
  21249. }
  21250. this._cascadePostProcessesToRigCams();
  21251. this.update();
  21252. };
  21253. /** @hidden */
  21254. Camera._setStereoscopicRigMode = function (camera) {
  21255. throw "Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode";
  21256. };
  21257. /** @hidden */
  21258. Camera._setStereoscopicAnaglyphRigMode = function (camera) {
  21259. throw "Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode";
  21260. };
  21261. /** @hidden */
  21262. Camera._setVRRigMode = function (camera, rigParams) {
  21263. throw "Import Cameras/RigModes/vrRigMode before using VR rig mode";
  21264. };
  21265. /** @hidden */
  21266. Camera._setWebVRRigMode = function (camera, rigParams) {
  21267. throw "Import Cameras/RigModes/WebVRRigMode before using Web VR rig mode";
  21268. };
  21269. /** @hidden */
  21270. Camera.prototype._getVRProjectionMatrix = function () {
  21271. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov, this._cameraRigParams.vrMetrics.aspectRatio, this.minZ, this.maxZ, this._cameraRigParams.vrWorkMatrix);
  21272. this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix, this._projectionMatrix);
  21273. return this._projectionMatrix;
  21274. };
  21275. Camera.prototype._updateCameraRotationMatrix = function () {
  21276. //Here for WebVR
  21277. };
  21278. Camera.prototype._updateWebVRCameraRotationMatrix = function () {
  21279. //Here for WebVR
  21280. };
  21281. /**
  21282. * This function MUST be overwritten by the different WebVR cameras available.
  21283. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  21284. * @hidden
  21285. */
  21286. Camera.prototype._getWebVRProjectionMatrix = function () {
  21287. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  21288. };
  21289. /**
  21290. * This function MUST be overwritten by the different WebVR cameras available.
  21291. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  21292. * @hidden
  21293. */
  21294. Camera.prototype._getWebVRViewMatrix = function () {
  21295. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  21296. };
  21297. /** @hidden */
  21298. Camera.prototype.setCameraRigParameter = function (name, value) {
  21299. if (!this._cameraRigParams) {
  21300. this._cameraRigParams = {};
  21301. }
  21302. this._cameraRigParams[name] = value;
  21303. //provisionnally:
  21304. if (name === "interaxialDistance") {
  21305. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(value / 0.0637);
  21306. }
  21307. };
  21308. /**
  21309. * needs to be overridden by children so sub has required properties to be copied
  21310. * @hidden
  21311. */
  21312. Camera.prototype.createRigCamera = function (name, cameraIndex) {
  21313. return null;
  21314. };
  21315. /**
  21316. * May need to be overridden by children
  21317. * @hidden
  21318. */
  21319. Camera.prototype._updateRigCameras = function () {
  21320. for (var i = 0; i < this._rigCameras.length; i++) {
  21321. this._rigCameras[i].minZ = this.minZ;
  21322. this._rigCameras[i].maxZ = this.maxZ;
  21323. this._rigCameras[i].fov = this.fov;
  21324. this._rigCameras[i].upVector.copyFrom(this.upVector);
  21325. }
  21326. // only update viewport when ANAGLYPH
  21327. if (this.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH) {
  21328. this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport;
  21329. }
  21330. };
  21331. /** @hidden */
  21332. Camera.prototype._setupInputs = function () {
  21333. };
  21334. /**
  21335. * Serialiaze the camera setup to a json represention
  21336. * @returns the JSON representation
  21337. */
  21338. Camera.prototype.serialize = function () {
  21339. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  21340. // Type
  21341. serializationObject.type = this.getClassName();
  21342. // Parent
  21343. if (this.parent) {
  21344. serializationObject.parentId = this.parent.id;
  21345. }
  21346. if (this.inputs) {
  21347. this.inputs.serialize(serializationObject);
  21348. }
  21349. // Animations
  21350. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  21351. serializationObject.ranges = this.serializeAnimationRanges();
  21352. return serializationObject;
  21353. };
  21354. /**
  21355. * Clones the current camera.
  21356. * @param name The cloned camera name
  21357. * @returns the cloned camera
  21358. */
  21359. Camera.prototype.clone = function (name) {
  21360. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(Camera.GetConstructorFromName(this.getClassName(), name, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
  21361. };
  21362. /**
  21363. * Gets the direction of the camera relative to a given local axis.
  21364. * @param localAxis Defines the reference axis to provide a relative direction.
  21365. * @return the direction
  21366. */
  21367. Camera.prototype.getDirection = function (localAxis) {
  21368. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  21369. this.getDirectionToRef(localAxis, result);
  21370. return result;
  21371. };
  21372. /**
  21373. * Gets the direction of the camera relative to a given local axis into a passed vector.
  21374. * @param localAxis Defines the reference axis to provide a relative direction.
  21375. * @param result Defines the vector to store the result in
  21376. */
  21377. Camera.prototype.getDirectionToRef = function (localAxis, result) {
  21378. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  21379. };
  21380. /**
  21381. * Gets a camera constructor for a given camera type
  21382. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  21383. * @param name The name of the camera the result will be able to instantiate
  21384. * @param scene The scene the result will construct the camera in
  21385. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  21386. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  21387. * @returns a factory method to construc the camera
  21388. */
  21389. Camera.GetConstructorFromName = function (type, name, scene, interaxial_distance, isStereoscopicSideBySide) {
  21390. if (interaxial_distance === void 0) { interaxial_distance = 0; }
  21391. if (isStereoscopicSideBySide === void 0) { isStereoscopicSideBySide = true; }
  21392. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_6__["Node"].Construct(type, name, scene, {
  21393. interaxial_distance: interaxial_distance,
  21394. isStereoscopicSideBySide: isStereoscopicSideBySide
  21395. });
  21396. if (constructorFunc) {
  21397. return constructorFunc;
  21398. }
  21399. // Default to universal camera
  21400. return function () { return Camera._createDefaultParsedCamera(name, scene); };
  21401. };
  21402. /**
  21403. * Compute the world matrix of the camera.
  21404. * @returns the camera workd matrix
  21405. */
  21406. Camera.prototype.computeWorldMatrix = function () {
  21407. return this.getWorldMatrix();
  21408. };
  21409. /**
  21410. * Parse a JSON and creates the camera from the parsed information
  21411. * @param parsedCamera The JSON to parse
  21412. * @param scene The scene to instantiate the camera in
  21413. * @returns the newly constructed camera
  21414. */
  21415. Camera.Parse = function (parsedCamera, scene) {
  21416. var type = parsedCamera.type;
  21417. var construct = Camera.GetConstructorFromName(type, parsedCamera.name, scene, parsedCamera.interaxial_distance, parsedCamera.isStereoscopicSideBySide);
  21418. var camera = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(construct, parsedCamera, scene);
  21419. // Parent
  21420. if (parsedCamera.parentId) {
  21421. camera._waitingParentId = parsedCamera.parentId;
  21422. }
  21423. //If camera has an input manager, let it parse inputs settings
  21424. if (camera.inputs) {
  21425. camera.inputs.parse(parsedCamera);
  21426. camera._setupInputs();
  21427. }
  21428. if (camera.setPosition) { // need to force position
  21429. camera.position.copyFromFloats(0, 0, 0);
  21430. camera.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.position));
  21431. }
  21432. // Target
  21433. if (parsedCamera.target) {
  21434. if (camera.setTarget) {
  21435. camera.setTarget(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.target));
  21436. }
  21437. }
  21438. // Apply 3d rig, when found
  21439. if (parsedCamera.cameraRigMode) {
  21440. var rigParams = (parsedCamera.interaxial_distance) ? { interaxialDistance: parsedCamera.interaxial_distance } : {};
  21441. camera.setCameraRigMode(parsedCamera.cameraRigMode, rigParams);
  21442. }
  21443. // Animations
  21444. if (parsedCamera.animations) {
  21445. for (var animationIndex = 0; animationIndex < parsedCamera.animations.length; animationIndex++) {
  21446. var parsedAnimation = parsedCamera.animations[animationIndex];
  21447. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON.Animation");
  21448. if (internalClass) {
  21449. camera.animations.push(internalClass.Parse(parsedAnimation));
  21450. }
  21451. }
  21452. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(camera, parsedCamera, scene);
  21453. }
  21454. if (parsedCamera.autoAnimate) {
  21455. scene.beginAnimation(camera, parsedCamera.autoAnimateFrom, parsedCamera.autoAnimateTo, parsedCamera.autoAnimateLoop, parsedCamera.autoAnimateSpeed || 1.0);
  21456. }
  21457. return camera;
  21458. };
  21459. /** @hidden */
  21460. Camera._createDefaultParsedCamera = function (name, scene) {
  21461. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("UniversalCamera");
  21462. };
  21463. /**
  21464. * This is the default projection mode used by the cameras.
  21465. * It helps recreating a feeling of perspective and better appreciate depth.
  21466. * This is the best way to simulate real life cameras.
  21467. */
  21468. Camera.PERSPECTIVE_CAMERA = 0;
  21469. /**
  21470. * This helps creating camera with an orthographic mode.
  21471. * 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.
  21472. */
  21473. Camera.ORTHOGRAPHIC_CAMERA = 1;
  21474. /**
  21475. * This is the default FOV mode for perspective cameras.
  21476. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  21477. */
  21478. Camera.FOVMODE_VERTICAL_FIXED = 0;
  21479. /**
  21480. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  21481. */
  21482. Camera.FOVMODE_HORIZONTAL_FIXED = 1;
  21483. /**
  21484. * This specifies ther is no need for a camera rig.
  21485. * Basically only one eye is rendered corresponding to the camera.
  21486. */
  21487. Camera.RIG_MODE_NONE = 0;
  21488. /**
  21489. * Simulates a camera Rig with one blue eye and one red eye.
  21490. * This can be use with 3d blue and red glasses.
  21491. */
  21492. Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10;
  21493. /**
  21494. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  21495. */
  21496. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11;
  21497. /**
  21498. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  21499. */
  21500. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12;
  21501. /**
  21502. * Defines that both eyes of the camera will be rendered over under each other.
  21503. */
  21504. Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER = 13;
  21505. /**
  21506. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  21507. */
  21508. Camera.RIG_MODE_VR = 20;
  21509. /**
  21510. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  21511. */
  21512. Camera.RIG_MODE_WEBVR = 21;
  21513. /**
  21514. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  21515. */
  21516. Camera.RIG_MODE_CUSTOM = 22;
  21517. /**
  21518. * Defines if by default attaching controls should prevent the default javascript event to continue.
  21519. */
  21520. Camera.ForceAttachControlToAlwaysPreventDefault = false;
  21521. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21522. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  21523. ], Camera.prototype, "_position", void 0);
  21524. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21525. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21526. ], Camera.prototype, "upVector", void 0);
  21527. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21528. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21529. ], Camera.prototype, "orthoLeft", void 0);
  21530. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21531. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21532. ], Camera.prototype, "orthoRight", void 0);
  21533. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21534. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21535. ], Camera.prototype, "orthoBottom", void 0);
  21536. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21537. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21538. ], Camera.prototype, "orthoTop", void 0);
  21539. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21540. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21541. ], Camera.prototype, "fov", void 0);
  21542. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21543. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21544. ], Camera.prototype, "minZ", void 0);
  21545. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21546. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21547. ], Camera.prototype, "maxZ", void 0);
  21548. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21549. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21550. ], Camera.prototype, "inertia", void 0);
  21551. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21552. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21553. ], Camera.prototype, "mode", void 0);
  21554. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21555. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21556. ], Camera.prototype, "layerMask", void 0);
  21557. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21558. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21559. ], Camera.prototype, "fovMode", void 0);
  21560. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21561. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21562. ], Camera.prototype, "cameraRigMode", void 0);
  21563. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21564. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21565. ], Camera.prototype, "interaxialDistance", void 0);
  21566. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21567. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21568. ], Camera.prototype, "isStereoscopicSideBySide", void 0);
  21569. return Camera;
  21570. }(_node__WEBPACK_IMPORTED_MODULE_6__["Node"]));
  21571. /***/ }),
  21572. /***/ "./Cameras/cameraInputsManager.ts":
  21573. /*!****************************************!*\
  21574. !*** ./Cameras/cameraInputsManager.ts ***!
  21575. \****************************************/
  21576. /*! exports provided: CameraInputTypes, CameraInputsManager */
  21577. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21578. "use strict";
  21579. __webpack_require__.r(__webpack_exports__);
  21580. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return CameraInputTypes; });
  21581. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return CameraInputsManager; });
  21582. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  21583. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21584. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  21585. /**
  21586. * @ignore
  21587. * This is a list of all the different input types that are available in the application.
  21588. * Fo instance: ArcRotateCameraGamepadInput...
  21589. */
  21590. var CameraInputTypes = {};
  21591. /**
  21592. * This represents the input manager used within a camera.
  21593. * It helps dealing with all the different kind of input attached to a camera.
  21594. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21595. */
  21596. var CameraInputsManager = /** @class */ (function () {
  21597. /**
  21598. * Instantiate a new Camera Input Manager.
  21599. * @param camera Defines the camera the input manager blongs to
  21600. */
  21601. function CameraInputsManager(camera) {
  21602. this.attached = {};
  21603. this.camera = camera;
  21604. this.checkInputs = function () { };
  21605. }
  21606. /**
  21607. * Add an input method to a camera
  21608. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21609. * @param input camera input method
  21610. */
  21611. CameraInputsManager.prototype.add = function (input) {
  21612. var type = input.getSimpleName();
  21613. if (this.attached[type]) {
  21614. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("camera input of type " + type + " already exists on camera");
  21615. return;
  21616. }
  21617. this.attached[type] = input;
  21618. input.camera = this.camera;
  21619. //for checkInputs, we are dynamically creating a function
  21620. //the goal is to avoid the performance penalty of looping for inputs in the render loop
  21621. if (input.checkInputs) {
  21622. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21623. }
  21624. if (this.attachedElement) {
  21625. input.attachControl(this.attachedElement);
  21626. }
  21627. };
  21628. /**
  21629. * Remove a specific input method from a camera
  21630. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  21631. * @param inputToRemove camera input method
  21632. */
  21633. CameraInputsManager.prototype.remove = function (inputToRemove) {
  21634. for (var cam in this.attached) {
  21635. var input = this.attached[cam];
  21636. if (input === inputToRemove) {
  21637. input.detachControl(this.attachedElement);
  21638. input.camera = null;
  21639. delete this.attached[cam];
  21640. this.rebuildInputCheck();
  21641. }
  21642. }
  21643. };
  21644. /**
  21645. * Remove a specific input type from a camera
  21646. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  21647. * @param inputType the type of the input to remove
  21648. */
  21649. CameraInputsManager.prototype.removeByType = function (inputType) {
  21650. for (var cam in this.attached) {
  21651. var input = this.attached[cam];
  21652. if (input.getClassName() === inputType) {
  21653. input.detachControl(this.attachedElement);
  21654. input.camera = null;
  21655. delete this.attached[cam];
  21656. this.rebuildInputCheck();
  21657. }
  21658. }
  21659. };
  21660. CameraInputsManager.prototype._addCheckInputs = function (fn) {
  21661. var current = this.checkInputs;
  21662. return function () {
  21663. current();
  21664. fn();
  21665. };
  21666. };
  21667. /**
  21668. * Attach the input controls to the currently attached dom element to listen the events from.
  21669. * @param input Defines the input to attach
  21670. */
  21671. CameraInputsManager.prototype.attachInput = function (input) {
  21672. if (this.attachedElement) {
  21673. input.attachControl(this.attachedElement, this.noPreventDefault);
  21674. }
  21675. };
  21676. /**
  21677. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  21678. * @param element Defines the dom element to collect the events from
  21679. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21680. */
  21681. CameraInputsManager.prototype.attachElement = function (element, noPreventDefault) {
  21682. if (noPreventDefault === void 0) { noPreventDefault = false; }
  21683. if (this.attachedElement) {
  21684. return;
  21685. }
  21686. noPreventDefault = _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  21687. this.attachedElement = element;
  21688. this.noPreventDefault = noPreventDefault;
  21689. for (var cam in this.attached) {
  21690. this.attached[cam].attachControl(element, noPreventDefault);
  21691. }
  21692. };
  21693. /**
  21694. * Detach the current manager inputs controls from a specific dom element.
  21695. * @param element Defines the dom element to collect the events from
  21696. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  21697. */
  21698. CameraInputsManager.prototype.detachElement = function (element, disconnect) {
  21699. if (disconnect === void 0) { disconnect = false; }
  21700. if (this.attachedElement !== element) {
  21701. return;
  21702. }
  21703. for (var cam in this.attached) {
  21704. this.attached[cam].detachControl(element);
  21705. if (disconnect) {
  21706. this.attached[cam].camera = null;
  21707. }
  21708. }
  21709. this.attachedElement = null;
  21710. };
  21711. /**
  21712. * Rebuild the dynamic inputCheck function from the current list of
  21713. * defined inputs in the manager.
  21714. */
  21715. CameraInputsManager.prototype.rebuildInputCheck = function () {
  21716. this.checkInputs = function () { };
  21717. for (var cam in this.attached) {
  21718. var input = this.attached[cam];
  21719. if (input.checkInputs) {
  21720. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21721. }
  21722. }
  21723. };
  21724. /**
  21725. * Remove all attached input methods from a camera
  21726. */
  21727. CameraInputsManager.prototype.clear = function () {
  21728. if (this.attachedElement) {
  21729. this.detachElement(this.attachedElement, true);
  21730. }
  21731. this.attached = {};
  21732. this.attachedElement = null;
  21733. this.checkInputs = function () { };
  21734. };
  21735. /**
  21736. * Serialize the current input manager attached to a camera.
  21737. * This ensures than once parsed,
  21738. * the input associated to the camera will be identical to the current ones
  21739. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  21740. */
  21741. CameraInputsManager.prototype.serialize = function (serializedCamera) {
  21742. var inputs = {};
  21743. for (var cam in this.attached) {
  21744. var input = this.attached[cam];
  21745. var res = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(input);
  21746. inputs[input.getClassName()] = res;
  21747. }
  21748. serializedCamera.inputsmgr = inputs;
  21749. };
  21750. /**
  21751. * Parses an input manager serialized JSON to restore the previous list of inputs
  21752. * and states associated to a camera.
  21753. * @param parsedCamera Defines the JSON to parse
  21754. */
  21755. CameraInputsManager.prototype.parse = function (parsedCamera) {
  21756. var parsedInputs = parsedCamera.inputsmgr;
  21757. if (parsedInputs) {
  21758. this.clear();
  21759. for (var n in parsedInputs) {
  21760. var construct = CameraInputTypes[n];
  21761. if (construct) {
  21762. var parsedinput = parsedInputs[n];
  21763. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedinput, null);
  21764. this.add(input);
  21765. }
  21766. }
  21767. }
  21768. else {
  21769. //2016-03-08 this part is for managing backward compatibility
  21770. for (var n in this.attached) {
  21771. var construct = CameraInputTypes[this.attached[n].getClassName()];
  21772. if (construct) {
  21773. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedCamera, null);
  21774. this.remove(this.attached[n]);
  21775. this.add(input);
  21776. }
  21777. }
  21778. }
  21779. };
  21780. return CameraInputsManager;
  21781. }());
  21782. /***/ }),
  21783. /***/ "./Cameras/deviceOrientationCamera.ts":
  21784. /*!********************************************!*\
  21785. !*** ./Cameras/deviceOrientationCamera.ts ***!
  21786. \********************************************/
  21787. /*! exports provided: DeviceOrientationCamera */
  21788. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21789. "use strict";
  21790. __webpack_require__.r(__webpack_exports__);
  21791. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return DeviceOrientationCamera; });
  21792. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21793. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  21794. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21795. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  21796. /* harmony import */ var _Inputs_freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  21797. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("DeviceOrientationCamera", function (name, scene) {
  21798. return function () { return new DeviceOrientationCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  21799. });
  21800. // We're mainly based on the logic defined into the FreeCamera code
  21801. /**
  21802. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  21803. * being tilted forward or back and left or right.
  21804. */
  21805. var DeviceOrientationCamera = /** @class */ (function (_super) {
  21806. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DeviceOrientationCamera, _super);
  21807. /**
  21808. * Creates a new device orientation camera
  21809. * @param name The name of the camera
  21810. * @param position The start position camera
  21811. * @param scene The scene the camera belongs to
  21812. */
  21813. function DeviceOrientationCamera(name, position, scene) {
  21814. var _this = _super.call(this, name, position, scene) || this;
  21815. _this._tmpDragQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21816. /**
  21817. * Disabled pointer input on first orientation sensor update (Default: true)
  21818. */
  21819. _this.disablePointerInputWhenUsingDeviceOrientation = true;
  21820. _this._dragFactor = 0;
  21821. _this._quaternionCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21822. _this.inputs.addDeviceOrientation();
  21823. // When the orientation sensor fires it's first event, disable mouse input
  21824. if (_this.inputs._deviceOrientationInput) {
  21825. _this.inputs._deviceOrientationInput._onDeviceOrientationChangedObservable.addOnce(function () {
  21826. if (_this.disablePointerInputWhenUsingDeviceOrientation) {
  21827. if (_this.inputs._mouseInput) {
  21828. _this.inputs._mouseInput._allowCameraRotation = false;
  21829. _this.inputs._mouseInput.onPointerMovedObservable.add(function (e) {
  21830. if (_this._dragFactor != 0) {
  21831. if (!_this._initialQuaternion) {
  21832. _this._initialQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21833. }
  21834. // Rotate the initial space around the y axis to allow users to "turn around" via touch/mouse
  21835. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].FromEulerAnglesToRef(0, e.offsetX * _this._dragFactor, 0, _this._tmpDragQuaternion);
  21836. _this._initialQuaternion.multiplyToRef(_this._tmpDragQuaternion, _this._initialQuaternion);
  21837. }
  21838. });
  21839. }
  21840. }
  21841. });
  21842. }
  21843. return _this;
  21844. }
  21845. /**
  21846. * Enabled turning on the y axis when the orientation sensor is active
  21847. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  21848. */
  21849. DeviceOrientationCamera.prototype.enableHorizontalDragging = function (dragFactor) {
  21850. if (dragFactor === void 0) { dragFactor = 1 / 300; }
  21851. this._dragFactor = dragFactor;
  21852. };
  21853. /**
  21854. * Gets the current instance class name ("DeviceOrientationCamera").
  21855. * This helps avoiding instanceof at run time.
  21856. * @returns the class name
  21857. */
  21858. DeviceOrientationCamera.prototype.getClassName = function () {
  21859. return "DeviceOrientationCamera";
  21860. };
  21861. /**
  21862. * @hidden
  21863. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  21864. */
  21865. DeviceOrientationCamera.prototype._checkInputs = function () {
  21866. _super.prototype._checkInputs.call(this);
  21867. this._quaternionCache.copyFrom(this.rotationQuaternion);
  21868. if (this._initialQuaternion) {
  21869. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21870. }
  21871. };
  21872. /**
  21873. * Reset the camera to its default orientation on the specified axis only.
  21874. * @param axis The axis to reset
  21875. */
  21876. DeviceOrientationCamera.prototype.resetToCurrentRotation = function (axis) {
  21877. var _this = this;
  21878. if (axis === void 0) { axis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y; }
  21879. //can only work if this camera has a rotation quaternion already.
  21880. if (!this.rotationQuaternion) {
  21881. return;
  21882. }
  21883. if (!this._initialQuaternion) {
  21884. this._initialQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21885. }
  21886. this._initialQuaternion.copyFrom(this._quaternionCache || this.rotationQuaternion);
  21887. ['x', 'y', 'z'].forEach(function (axisName) {
  21888. if (!axis[axisName]) {
  21889. _this._initialQuaternion[axisName] = 0;
  21890. }
  21891. else {
  21892. _this._initialQuaternion[axisName] *= -1;
  21893. }
  21894. });
  21895. this._initialQuaternion.normalize();
  21896. //force rotation update
  21897. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21898. };
  21899. return DeviceOrientationCamera;
  21900. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  21901. /***/ }),
  21902. /***/ "./Cameras/flyCamera.ts":
  21903. /*!******************************!*\
  21904. !*** ./Cameras/flyCamera.ts ***!
  21905. \******************************/
  21906. /*! exports provided: FlyCamera */
  21907. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21908. "use strict";
  21909. __webpack_require__.r(__webpack_exports__);
  21910. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return FlyCamera; });
  21911. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21912. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21913. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21914. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  21915. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21916. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  21917. /**
  21918. * This is a flying camera, designed for 3D movement and rotation in all directions,
  21919. * such as in a 3D Space Shooter or a Flight Simulator.
  21920. */
  21921. var FlyCamera = /** @class */ (function (_super) {
  21922. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCamera, _super);
  21923. /**
  21924. * Instantiates a FlyCamera.
  21925. * This is a flying camera, designed for 3D movement and rotation in all directions,
  21926. * such as in a 3D Space Shooter or a Flight Simulator.
  21927. * @param name Define the name of the camera in the scene.
  21928. * @param position Define the starting position of the camera in the scene.
  21929. * @param scene Define the scene the camera belongs to.
  21930. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  21931. */
  21932. function FlyCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  21933. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  21934. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  21935. /**
  21936. * Define the collision ellipsoid of the camera.
  21937. * This is helpful for simulating a camera body, like a player's body.
  21938. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  21939. */
  21940. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  21941. /**
  21942. * Define an offset for the position of the ellipsoid around the camera.
  21943. * This can be helpful if the camera is attached away from the player's body center,
  21944. * such as at its head.
  21945. */
  21946. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  21947. /**
  21948. * Enable or disable collisions of the camera with the rest of the scene objects.
  21949. */
  21950. _this.checkCollisions = false;
  21951. /**
  21952. * Enable or disable gravity on the camera.
  21953. */
  21954. _this.applyGravity = false;
  21955. /**
  21956. * Define the current direction the camera is moving to.
  21957. */
  21958. _this.cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21959. /**
  21960. * Track Roll to maintain the wanted Rolling when looking around.
  21961. */
  21962. _this._trackRoll = 0;
  21963. /**
  21964. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  21965. */
  21966. _this.rollCorrect = 100;
  21967. /**
  21968. * Mimic a banked turn, Rolling the camera when Yawing.
  21969. * It's recommended to use rollCorrect = 10 for faster banking correction.
  21970. */
  21971. _this.bankedTurn = false;
  21972. /**
  21973. * Limit in radians for how much Roll banking will add. (Default: 90°)
  21974. */
  21975. _this.bankedTurnLimit = Math.PI / 2;
  21976. /**
  21977. * Value of 0 disables the banked Roll.
  21978. * Value of 1 is equal to the Yaw angle in radians.
  21979. */
  21980. _this.bankedTurnMultiplier = 1;
  21981. _this._needMoveForGravity = false;
  21982. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21983. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21984. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21985. // Collisions.
  21986. _this._collisionMask = -1;
  21987. /** @hidden */
  21988. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  21989. if (collidedMesh === void 0) { collidedMesh = null; }
  21990. var updatePosition = function (newPos) {
  21991. _this._newPosition.copyFrom(newPos);
  21992. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  21993. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  21994. _this.position.addInPlace(_this._diffPosition);
  21995. if (_this.onCollide && collidedMesh) {
  21996. _this.onCollide(collidedMesh);
  21997. }
  21998. }
  21999. };
  22000. updatePosition(newPosition);
  22001. };
  22002. _this.inputs = new _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FlyCameraInputsManager"](_this);
  22003. _this.inputs.addKeyboard().addMouse();
  22004. return _this;
  22005. }
  22006. Object.defineProperty(FlyCamera.prototype, "angularSensibility", {
  22007. /**
  22008. * Gets the input sensibility for mouse input.
  22009. * Higher values reduce sensitivity.
  22010. */
  22011. get: function () {
  22012. var mouse = this.inputs.attached["mouse"];
  22013. if (mouse) {
  22014. return mouse.angularSensibility;
  22015. }
  22016. return 0;
  22017. },
  22018. /**
  22019. * Sets the input sensibility for a mouse input.
  22020. * Higher values reduce sensitivity.
  22021. */
  22022. set: function (value) {
  22023. var mouse = this.inputs.attached["mouse"];
  22024. if (mouse) {
  22025. mouse.angularSensibility = value;
  22026. }
  22027. },
  22028. enumerable: true,
  22029. configurable: true
  22030. });
  22031. Object.defineProperty(FlyCamera.prototype, "keysForward", {
  22032. /**
  22033. * Get the keys for camera movement forward.
  22034. */
  22035. get: function () {
  22036. var keyboard = this.inputs.attached["keyboard"];
  22037. if (keyboard) {
  22038. return keyboard.keysForward;
  22039. }
  22040. return [];
  22041. },
  22042. /**
  22043. * Set the keys for camera movement forward.
  22044. */
  22045. set: function (value) {
  22046. var keyboard = this.inputs.attached["keyboard"];
  22047. if (keyboard) {
  22048. keyboard.keysForward = value;
  22049. }
  22050. },
  22051. enumerable: true,
  22052. configurable: true
  22053. });
  22054. Object.defineProperty(FlyCamera.prototype, "keysBackward", {
  22055. /**
  22056. * Get the keys for camera movement backward.
  22057. */
  22058. get: function () {
  22059. var keyboard = this.inputs.attached["keyboard"];
  22060. if (keyboard) {
  22061. return keyboard.keysBackward;
  22062. }
  22063. return [];
  22064. },
  22065. set: function (value) {
  22066. var keyboard = this.inputs.attached["keyboard"];
  22067. if (keyboard) {
  22068. keyboard.keysBackward = value;
  22069. }
  22070. },
  22071. enumerable: true,
  22072. configurable: true
  22073. });
  22074. Object.defineProperty(FlyCamera.prototype, "keysUp", {
  22075. /**
  22076. * Get the keys for camera movement up.
  22077. */
  22078. get: function () {
  22079. var keyboard = this.inputs.attached["keyboard"];
  22080. if (keyboard) {
  22081. return keyboard.keysUp;
  22082. }
  22083. return [];
  22084. },
  22085. /**
  22086. * Set the keys for camera movement up.
  22087. */
  22088. set: function (value) {
  22089. var keyboard = this.inputs.attached["keyboard"];
  22090. if (keyboard) {
  22091. keyboard.keysUp = value;
  22092. }
  22093. },
  22094. enumerable: true,
  22095. configurable: true
  22096. });
  22097. Object.defineProperty(FlyCamera.prototype, "keysDown", {
  22098. /**
  22099. * Get the keys for camera movement down.
  22100. */
  22101. get: function () {
  22102. var keyboard = this.inputs.attached["keyboard"];
  22103. if (keyboard) {
  22104. return keyboard.keysDown;
  22105. }
  22106. return [];
  22107. },
  22108. /**
  22109. * Set the keys for camera movement down.
  22110. */
  22111. set: function (value) {
  22112. var keyboard = this.inputs.attached["keyboard"];
  22113. if (keyboard) {
  22114. keyboard.keysDown = value;
  22115. }
  22116. },
  22117. enumerable: true,
  22118. configurable: true
  22119. });
  22120. Object.defineProperty(FlyCamera.prototype, "keysLeft", {
  22121. /**
  22122. * Get the keys for camera movement left.
  22123. */
  22124. get: function () {
  22125. var keyboard = this.inputs.attached["keyboard"];
  22126. if (keyboard) {
  22127. return keyboard.keysLeft;
  22128. }
  22129. return [];
  22130. },
  22131. /**
  22132. * Set the keys for camera movement left.
  22133. */
  22134. set: function (value) {
  22135. var keyboard = this.inputs.attached["keyboard"];
  22136. if (keyboard) {
  22137. keyboard.keysLeft = value;
  22138. }
  22139. },
  22140. enumerable: true,
  22141. configurable: true
  22142. });
  22143. Object.defineProperty(FlyCamera.prototype, "keysRight", {
  22144. /**
  22145. * Set the keys for camera movement right.
  22146. */
  22147. get: function () {
  22148. var keyboard = this.inputs.attached["keyboard"];
  22149. if (keyboard) {
  22150. return keyboard.keysRight;
  22151. }
  22152. return [];
  22153. },
  22154. /**
  22155. * Set the keys for camera movement right.
  22156. */
  22157. set: function (value) {
  22158. var keyboard = this.inputs.attached["keyboard"];
  22159. if (keyboard) {
  22160. keyboard.keysRight = value;
  22161. }
  22162. },
  22163. enumerable: true,
  22164. configurable: true
  22165. });
  22166. /**
  22167. * Attach a control to the HTML DOM element.
  22168. * @param element Defines the element that listens to the input events.
  22169. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  22170. */
  22171. FlyCamera.prototype.attachControl = function (element, noPreventDefault) {
  22172. this.inputs.attachElement(element, noPreventDefault);
  22173. };
  22174. /**
  22175. * Detach a control from the HTML DOM element.
  22176. * The camera will stop reacting to that input.
  22177. * @param element Defines the element that listens to the input events.
  22178. */
  22179. FlyCamera.prototype.detachControl = function (element) {
  22180. this.inputs.detachElement(element);
  22181. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22182. };
  22183. Object.defineProperty(FlyCamera.prototype, "collisionMask", {
  22184. /**
  22185. * Get the mask that the camera ignores in collision events.
  22186. */
  22187. get: function () {
  22188. return this._collisionMask;
  22189. },
  22190. /**
  22191. * Set the mask that the camera ignores in collision events.
  22192. */
  22193. set: function (mask) {
  22194. this._collisionMask = !isNaN(mask) ? mask : -1;
  22195. },
  22196. enumerable: true,
  22197. configurable: true
  22198. });
  22199. /** @hidden */
  22200. FlyCamera.prototype._collideWithWorld = function (displacement) {
  22201. var globalPosition;
  22202. if (this.parent) {
  22203. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  22204. }
  22205. else {
  22206. globalPosition = this.position;
  22207. }
  22208. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  22209. this._oldPosition.addInPlace(this.ellipsoidOffset);
  22210. var coordinator = this.getScene().collisionCoordinator;
  22211. if (!this._collider) {
  22212. this._collider = coordinator.createCollider();
  22213. }
  22214. this._collider._radius = this.ellipsoid;
  22215. this._collider.collisionMask = this._collisionMask;
  22216. // No need for clone, as long as gravity is not on.
  22217. var actualDisplacement = displacement;
  22218. // Add gravity to direction to prevent dual-collision checking.
  22219. if (this.applyGravity) {
  22220. // This prevents mending with cameraDirection, a global variable of the fly camera class.
  22221. actualDisplacement = displacement.add(this.getScene().gravity);
  22222. }
  22223. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  22224. };
  22225. /** @hidden */
  22226. FlyCamera.prototype._checkInputs = function () {
  22227. if (!this._localDirection) {
  22228. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22229. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22230. }
  22231. this.inputs.checkInputs();
  22232. _super.prototype._checkInputs.call(this);
  22233. };
  22234. /** @hidden */
  22235. FlyCamera.prototype._decideIfNeedsToMove = function () {
  22236. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22237. };
  22238. /** @hidden */
  22239. FlyCamera.prototype._updatePosition = function () {
  22240. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  22241. this._collideWithWorld(this.cameraDirection);
  22242. }
  22243. else {
  22244. _super.prototype._updatePosition.call(this);
  22245. }
  22246. };
  22247. /**
  22248. * Restore the Roll to its target value at the rate specified.
  22249. * @param rate - Higher means slower restoring.
  22250. * @hidden
  22251. */
  22252. FlyCamera.prototype.restoreRoll = function (rate) {
  22253. var limit = this._trackRoll; // Target Roll.
  22254. var z = this.rotation.z; // Current Roll.
  22255. var delta = limit - z; // Difference in Roll.
  22256. var minRad = 0.001; // Tenth of a radian is a barely noticable difference.
  22257. // If the difference is noticable, restore the Roll.
  22258. if (Math.abs(delta) >= minRad) {
  22259. // Change Z rotation towards the target Roll.
  22260. this.rotation.z += delta / rate;
  22261. // Match when near enough.
  22262. if (Math.abs(limit - this.rotation.z) <= minRad) {
  22263. this.rotation.z = limit;
  22264. }
  22265. }
  22266. };
  22267. /**
  22268. * Destroy the camera and release the current resources held by it.
  22269. */
  22270. FlyCamera.prototype.dispose = function () {
  22271. this.inputs.clear();
  22272. _super.prototype.dispose.call(this);
  22273. };
  22274. /**
  22275. * Get the current object class name.
  22276. * @returns the class name.
  22277. */
  22278. FlyCamera.prototype.getClassName = function () {
  22279. return "FlyCamera";
  22280. };
  22281. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22282. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22283. ], FlyCamera.prototype, "ellipsoid", void 0);
  22284. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22285. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22286. ], FlyCamera.prototype, "ellipsoidOffset", void 0);
  22287. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22288. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22289. ], FlyCamera.prototype, "checkCollisions", void 0);
  22290. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22291. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22292. ], FlyCamera.prototype, "applyGravity", void 0);
  22293. return FlyCamera;
  22294. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  22295. /***/ }),
  22296. /***/ "./Cameras/flyCameraInputsManager.ts":
  22297. /*!*******************************************!*\
  22298. !*** ./Cameras/flyCameraInputsManager.ts ***!
  22299. \*******************************************/
  22300. /*! exports provided: FlyCameraInputsManager */
  22301. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22302. "use strict";
  22303. __webpack_require__.r(__webpack_exports__);
  22304. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return FlyCameraInputsManager; });
  22305. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22306. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22307. /* harmony import */ var _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  22308. /* harmony import */ var _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  22309. /**
  22310. * Default Inputs manager for the FlyCamera.
  22311. * It groups all the default supported inputs for ease of use.
  22312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22313. */
  22314. var FlyCameraInputsManager = /** @class */ (function (_super) {
  22315. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCameraInputsManager, _super);
  22316. /**
  22317. * Instantiates a new FlyCameraInputsManager.
  22318. * @param camera Defines the camera the inputs belong to.
  22319. */
  22320. function FlyCameraInputsManager(camera) {
  22321. return _super.call(this, camera) || this;
  22322. }
  22323. /**
  22324. * Add keyboard input support to the input manager.
  22325. * @returns the new FlyCameraKeyboardMoveInput().
  22326. */
  22327. FlyCameraInputsManager.prototype.addKeyboard = function () {
  22328. this.add(new _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__["FlyCameraKeyboardInput"]());
  22329. return this;
  22330. };
  22331. /**
  22332. * Add mouse input support to the input manager.
  22333. * @param touchEnabled Enable touch screen support.
  22334. * @returns the new FlyCameraMouseInput().
  22335. */
  22336. FlyCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  22337. if (touchEnabled === void 0) { touchEnabled = true; }
  22338. this.add(new _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__["FlyCameraMouseInput"](touchEnabled));
  22339. return this;
  22340. };
  22341. return FlyCameraInputsManager;
  22342. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22343. /***/ }),
  22344. /***/ "./Cameras/followCamera.ts":
  22345. /*!*********************************!*\
  22346. !*** ./Cameras/followCamera.ts ***!
  22347. \*********************************/
  22348. /*! exports provided: FollowCamera, ArcFollowCamera */
  22349. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22350. "use strict";
  22351. __webpack_require__.r(__webpack_exports__);
  22352. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return FollowCamera; });
  22353. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return ArcFollowCamera; });
  22354. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22355. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22356. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  22357. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22358. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22359. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../node */ "./node.ts");
  22360. /* harmony import */ var _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./followCameraInputsManager */ "./Cameras/followCameraInputsManager.ts");
  22361. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("FollowCamera", function (name, scene) {
  22362. return function () { return new FollowCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  22363. });
  22364. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("ArcFollowCamera", function (name, scene) {
  22365. return function () { return new ArcFollowCamera(name, 0, 0, 1.0, null, scene); };
  22366. });
  22367. /**
  22368. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  22369. * an arc rotate version arcFollowCamera are available.
  22370. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22371. */
  22372. var FollowCamera = /** @class */ (function (_super) {
  22373. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCamera, _super);
  22374. /**
  22375. * Instantiates the follow camera.
  22376. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22377. * @param name Define the name of the camera in the scene
  22378. * @param position Define the position of the camera
  22379. * @param scene Define the scene the camera belong to
  22380. * @param lockedTarget Define the target of the camera
  22381. */
  22382. function FollowCamera(name, position, scene, lockedTarget) {
  22383. if (lockedTarget === void 0) { lockedTarget = null; }
  22384. var _this = _super.call(this, name, position, scene) || this;
  22385. /**
  22386. * Distance the follow camera should follow an object at
  22387. */
  22388. _this.radius = 12;
  22389. /**
  22390. * Minimum allowed distance of the camera to the axis of rotation
  22391. * (The camera can not get closer).
  22392. * This can help limiting how the Camera is able to move in the scene.
  22393. */
  22394. _this.lowerRadiusLimit = null;
  22395. /**
  22396. * Maximum allowed distance of the camera to the axis of rotation
  22397. * (The camera can not get further).
  22398. * This can help limiting how the Camera is able to move in the scene.
  22399. */
  22400. _this.upperRadiusLimit = null;
  22401. /**
  22402. * Define a rotation offset between the camera and the object it follows
  22403. */
  22404. _this.rotationOffset = 0;
  22405. /**
  22406. * Minimum allowed angle to camera position relative to target object.
  22407. * This can help limiting how the Camera is able to move in the scene.
  22408. */
  22409. _this.lowerRotationOffsetLimit = null;
  22410. /**
  22411. * Maximum allowed angle to camera position relative to target object.
  22412. * This can help limiting how the Camera is able to move in the scene.
  22413. */
  22414. _this.upperRotationOffsetLimit = null;
  22415. /**
  22416. * Define a height offset between the camera and the object it follows.
  22417. * It can help following an object from the top (like a car chaing a plane)
  22418. */
  22419. _this.heightOffset = 4;
  22420. /**
  22421. * Minimum allowed height of camera position relative to target object.
  22422. * This can help limiting how the Camera is able to move in the scene.
  22423. */
  22424. _this.lowerHeightOffsetLimit = null;
  22425. /**
  22426. * Maximum allowed height of camera position relative to target object.
  22427. * This can help limiting how the Camera is able to move in the scene.
  22428. */
  22429. _this.upperHeightOffsetLimit = null;
  22430. /**
  22431. * Define how fast the camera can accelerate to follow it s target.
  22432. */
  22433. _this.cameraAcceleration = 0.05;
  22434. /**
  22435. * Define the speed limit of the camera following an object.
  22436. */
  22437. _this.maxCameraSpeed = 20;
  22438. _this.lockedTarget = lockedTarget;
  22439. _this.inputs = new _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__["FollowCameraInputsManager"](_this);
  22440. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  22441. return _this;
  22442. // Uncomment the following line when the relevant handlers have been implemented.
  22443. // this.inputs.addKeyboard().addMouseWheel().addPointers().addVRDeviceOrientation();
  22444. }
  22445. FollowCamera.prototype._follow = function (cameraTarget) {
  22446. if (!cameraTarget) {
  22447. return;
  22448. }
  22449. var yRotation;
  22450. if (cameraTarget.rotationQuaternion) {
  22451. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  22452. cameraTarget.rotationQuaternion.toRotationMatrix(rotMatrix);
  22453. yRotation = Math.atan2(rotMatrix.m[8], rotMatrix.m[10]);
  22454. }
  22455. else {
  22456. yRotation = cameraTarget.rotation.y;
  22457. }
  22458. var radians = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this.rotationOffset) + yRotation;
  22459. var targetPosition = cameraTarget.getAbsolutePosition();
  22460. var targetX = targetPosition.x + Math.sin(radians) * this.radius;
  22461. var targetZ = targetPosition.z + Math.cos(radians) * this.radius;
  22462. var dx = targetX - this.position.x;
  22463. var dy = (targetPosition.y + this.heightOffset) - this.position.y;
  22464. var dz = (targetZ) - this.position.z;
  22465. var vx = dx * this.cameraAcceleration * 2; //this is set to .05
  22466. var vy = dy * this.cameraAcceleration;
  22467. var vz = dz * this.cameraAcceleration * 2;
  22468. if (vx > this.maxCameraSpeed || vx < -this.maxCameraSpeed) {
  22469. vx = vx < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  22470. }
  22471. if (vy > this.maxCameraSpeed || vy < -this.maxCameraSpeed) {
  22472. vy = vy < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  22473. }
  22474. if (vz > this.maxCameraSpeed || vz < -this.maxCameraSpeed) {
  22475. vz = vz < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  22476. }
  22477. this.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](this.position.x + vx, this.position.y + vy, this.position.z + vz);
  22478. this.setTarget(targetPosition);
  22479. };
  22480. /**
  22481. * Attached controls to the current camera.
  22482. * @param element Defines the element the controls should be listened from
  22483. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  22484. */
  22485. FollowCamera.prototype.attachControl = function (element, noPreventDefault) {
  22486. this.inputs.attachElement(element, noPreventDefault);
  22487. this._reset = function () {
  22488. };
  22489. };
  22490. /**
  22491. * Detach the current controls from the camera.
  22492. * The camera will stop reacting to inputs.
  22493. * @param element Defines the element to stop listening the inputs from
  22494. */
  22495. FollowCamera.prototype.detachControl = function (element) {
  22496. this.inputs.detachElement(element);
  22497. if (this._reset) {
  22498. this._reset();
  22499. }
  22500. };
  22501. /** @hidden */
  22502. FollowCamera.prototype._checkInputs = function () {
  22503. this.inputs.checkInputs();
  22504. this._checkLimits();
  22505. _super.prototype._checkInputs.call(this);
  22506. if (this.lockedTarget) {
  22507. this._follow(this.lockedTarget);
  22508. }
  22509. };
  22510. FollowCamera.prototype._checkLimits = function () {
  22511. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  22512. this.radius = this.lowerRadiusLimit;
  22513. }
  22514. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  22515. this.radius = this.upperRadiusLimit;
  22516. }
  22517. if (this.lowerHeightOffsetLimit !== null &&
  22518. this.heightOffset < this.lowerHeightOffsetLimit) {
  22519. this.heightOffset = this.lowerHeightOffsetLimit;
  22520. }
  22521. if (this.upperHeightOffsetLimit !== null &&
  22522. this.heightOffset > this.upperHeightOffsetLimit) {
  22523. this.heightOffset = this.upperHeightOffsetLimit;
  22524. }
  22525. if (this.lowerRotationOffsetLimit !== null &&
  22526. this.rotationOffset < this.lowerRotationOffsetLimit) {
  22527. this.rotationOffset = this.lowerRotationOffsetLimit;
  22528. }
  22529. if (this.upperRotationOffsetLimit !== null &&
  22530. this.rotationOffset > this.upperRotationOffsetLimit) {
  22531. this.rotationOffset = this.upperRotationOffsetLimit;
  22532. }
  22533. };
  22534. /**
  22535. * Gets the camera class name.
  22536. * @returns the class name
  22537. */
  22538. FollowCamera.prototype.getClassName = function () {
  22539. return "FollowCamera";
  22540. };
  22541. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22542. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22543. ], FollowCamera.prototype, "radius", void 0);
  22544. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22545. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22546. ], FollowCamera.prototype, "lowerRadiusLimit", void 0);
  22547. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22548. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22549. ], FollowCamera.prototype, "upperRadiusLimit", void 0);
  22550. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22551. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22552. ], FollowCamera.prototype, "rotationOffset", void 0);
  22553. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22554. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22555. ], FollowCamera.prototype, "lowerRotationOffsetLimit", void 0);
  22556. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22557. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22558. ], FollowCamera.prototype, "upperRotationOffsetLimit", void 0);
  22559. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22560. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22561. ], FollowCamera.prototype, "heightOffset", void 0);
  22562. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22563. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22564. ], FollowCamera.prototype, "lowerHeightOffsetLimit", void 0);
  22565. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22566. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22567. ], FollowCamera.prototype, "upperHeightOffsetLimit", void 0);
  22568. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22569. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22570. ], FollowCamera.prototype, "cameraAcceleration", void 0);
  22571. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22572. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22573. ], FollowCamera.prototype, "maxCameraSpeed", void 0);
  22574. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22575. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  22576. ], FollowCamera.prototype, "lockedTarget", void 0);
  22577. return FollowCamera;
  22578. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  22579. /**
  22580. * Arc Rotate version of the follow camera.
  22581. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  22582. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22583. */
  22584. var ArcFollowCamera = /** @class */ (function (_super) {
  22585. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcFollowCamera, _super);
  22586. /**
  22587. * Instantiates a new ArcFollowCamera
  22588. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22589. * @param name Define the name of the camera
  22590. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  22591. * @param beta Define the rotation angle of the camera around the elevation axis
  22592. * @param radius Define the radius of the camera from its target point
  22593. * @param target Define the target of the camera
  22594. * @param scene Define the scene the camera belongs to
  22595. */
  22596. function ArcFollowCamera(name,
  22597. /** The longitudinal angle of the camera */
  22598. alpha,
  22599. /** The latitudinal angle of the camera */
  22600. beta,
  22601. /** The radius of the camera from its target */
  22602. radius,
  22603. /** Define the camera target (the messh it should follow) */
  22604. target, scene) {
  22605. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene) || this;
  22606. _this.alpha = alpha;
  22607. _this.beta = beta;
  22608. _this.radius = radius;
  22609. _this.target = target;
  22610. _this._cartesianCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  22611. _this._follow();
  22612. return _this;
  22613. }
  22614. ArcFollowCamera.prototype._follow = function () {
  22615. if (!this.target) {
  22616. return;
  22617. }
  22618. this._cartesianCoordinates.x = this.radius * Math.cos(this.alpha) * Math.cos(this.beta);
  22619. this._cartesianCoordinates.y = this.radius * Math.sin(this.beta);
  22620. this._cartesianCoordinates.z = this.radius * Math.sin(this.alpha) * Math.cos(this.beta);
  22621. var targetPosition = this.target.getAbsolutePosition();
  22622. this.position = targetPosition.add(this._cartesianCoordinates);
  22623. this.setTarget(targetPosition);
  22624. };
  22625. /** @hidden */
  22626. ArcFollowCamera.prototype._checkInputs = function () {
  22627. _super.prototype._checkInputs.call(this);
  22628. this._follow();
  22629. };
  22630. /**
  22631. * Returns the class name of the object.
  22632. * It is mostly used internally for serialization purposes.
  22633. */
  22634. ArcFollowCamera.prototype.getClassName = function () {
  22635. return "ArcFollowCamera";
  22636. };
  22637. return ArcFollowCamera;
  22638. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  22639. /***/ }),
  22640. /***/ "./Cameras/followCameraInputsManager.ts":
  22641. /*!**********************************************!*\
  22642. !*** ./Cameras/followCameraInputsManager.ts ***!
  22643. \**********************************************/
  22644. /*! exports provided: FollowCameraInputsManager */
  22645. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22646. "use strict";
  22647. __webpack_require__.r(__webpack_exports__);
  22648. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraInputsManager", function() { return FollowCameraInputsManager; });
  22649. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22650. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22651. /* harmony import */ var _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Inputs/followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  22652. /* harmony import */ var _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Inputs/followCameraMouseWheelInput */ "./Cameras/Inputs/followCameraMouseWheelInput.ts");
  22653. /* harmony import */ var _Inputs_followCameraPointersInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/followCameraPointersInput */ "./Cameras/Inputs/followCameraPointersInput.ts");
  22654. /**
  22655. * Default Inputs manager for the FollowCamera.
  22656. * It groups all the default supported inputs for ease of use.
  22657. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22658. */
  22659. var FollowCameraInputsManager = /** @class */ (function (_super) {
  22660. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraInputsManager, _super);
  22661. /**
  22662. * Instantiates a new FollowCameraInputsManager.
  22663. * @param camera Defines the camera the inputs belong to
  22664. */
  22665. function FollowCameraInputsManager(camera) {
  22666. return _super.call(this, camera) || this;
  22667. }
  22668. /**
  22669. * Add keyboard input support to the input manager.
  22670. * @returns the current input manager
  22671. */
  22672. FollowCameraInputsManager.prototype.addKeyboard = function () {
  22673. this.add(new _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FollowCameraKeyboardMoveInput"]());
  22674. return this;
  22675. };
  22676. /**
  22677. * Add mouse wheel input support to the input manager.
  22678. * @returns the current input manager
  22679. */
  22680. FollowCameraInputsManager.prototype.addMouseWheel = function () {
  22681. this.add(new _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["FollowCameraMouseWheelInput"]());
  22682. return this;
  22683. };
  22684. /**
  22685. * Add pointers input support to the input manager.
  22686. * @returns the current input manager
  22687. */
  22688. FollowCameraInputsManager.prototype.addPointers = function () {
  22689. this.add(new _Inputs_followCameraPointersInput__WEBPACK_IMPORTED_MODULE_4__["FollowCameraPointersInput"]());
  22690. return this;
  22691. };
  22692. /**
  22693. * Add orientation input support to the input manager.
  22694. * @returns the current input manager
  22695. */
  22696. FollowCameraInputsManager.prototype.addVRDeviceOrientation = function () {
  22697. console.warn("DeviceOrientation support not yet implemented for FollowCamera.");
  22698. return this;
  22699. };
  22700. return FollowCameraInputsManager;
  22701. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22702. /***/ }),
  22703. /***/ "./Cameras/freeCamera.ts":
  22704. /*!*******************************!*\
  22705. !*** ./Cameras/freeCamera.ts ***!
  22706. \*******************************/
  22707. /*! exports provided: FreeCamera */
  22708. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22709. "use strict";
  22710. __webpack_require__.r(__webpack_exports__);
  22711. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return FreeCamera; });
  22712. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22713. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22714. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22715. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  22716. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22717. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  22718. /**
  22719. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22720. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  22721. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22722. */
  22723. var FreeCamera = /** @class */ (function (_super) {
  22724. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCamera, _super);
  22725. /**
  22726. * Instantiates a Free Camera.
  22727. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22728. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  22729. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22730. * @param name Define the name of the camera in the scene
  22731. * @param position Define the start position of the camera in the scene
  22732. * @param scene Define the scene the camera belongs to
  22733. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  22734. */
  22735. function FreeCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  22736. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  22737. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  22738. /**
  22739. * Define the collision ellipsoid of the camera.
  22740. * This is helpful to simulate a camera body like the player body around the camera
  22741. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  22742. */
  22743. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.5, 1, 0.5);
  22744. /**
  22745. * Define an offset for the position of the ellipsoid around the camera.
  22746. * This can be helpful to determine the center of the body near the gravity center of the body
  22747. * instead of its head.
  22748. */
  22749. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22750. /**
  22751. * Enable or disable collisions of the camera with the rest of the scene objects.
  22752. */
  22753. _this.checkCollisions = false;
  22754. /**
  22755. * Enable or disable gravity on the camera.
  22756. */
  22757. _this.applyGravity = false;
  22758. _this._needMoveForGravity = false;
  22759. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22760. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22761. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22762. // Collisions
  22763. _this._collisionMask = -1;
  22764. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  22765. if (collidedMesh === void 0) { collidedMesh = null; }
  22766. var updatePosition = function (newPos) {
  22767. _this._newPosition.copyFrom(newPos);
  22768. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  22769. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  22770. _this.position.addInPlace(_this._diffPosition);
  22771. if (_this.onCollide && collidedMesh) {
  22772. _this.onCollide(collidedMesh);
  22773. }
  22774. }
  22775. };
  22776. updatePosition(newPosition);
  22777. };
  22778. _this.inputs = new _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"](_this);
  22779. _this.inputs.addKeyboard().addMouse();
  22780. return _this;
  22781. }
  22782. Object.defineProperty(FreeCamera.prototype, "angularSensibility", {
  22783. /**
  22784. * Gets the input sensibility for a mouse input. (default is 2000.0)
  22785. * Higher values reduce sensitivity.
  22786. */
  22787. get: function () {
  22788. var mouse = this.inputs.attached["mouse"];
  22789. if (mouse) {
  22790. return mouse.angularSensibility;
  22791. }
  22792. return 0;
  22793. },
  22794. /**
  22795. * Sets the input sensibility for a mouse input. (default is 2000.0)
  22796. * Higher values reduce sensitivity.
  22797. */
  22798. set: function (value) {
  22799. var mouse = this.inputs.attached["mouse"];
  22800. if (mouse) {
  22801. mouse.angularSensibility = value;
  22802. }
  22803. },
  22804. enumerable: true,
  22805. configurable: true
  22806. });
  22807. Object.defineProperty(FreeCamera.prototype, "keysUp", {
  22808. /**
  22809. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  22810. */
  22811. get: function () {
  22812. var keyboard = this.inputs.attached["keyboard"];
  22813. if (keyboard) {
  22814. return keyboard.keysUp;
  22815. }
  22816. return [];
  22817. },
  22818. set: function (value) {
  22819. var keyboard = this.inputs.attached["keyboard"];
  22820. if (keyboard) {
  22821. keyboard.keysUp = value;
  22822. }
  22823. },
  22824. enumerable: true,
  22825. configurable: true
  22826. });
  22827. Object.defineProperty(FreeCamera.prototype, "keysDown", {
  22828. /**
  22829. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  22830. */
  22831. get: function () {
  22832. var keyboard = this.inputs.attached["keyboard"];
  22833. if (keyboard) {
  22834. return keyboard.keysDown;
  22835. }
  22836. return [];
  22837. },
  22838. set: function (value) {
  22839. var keyboard = this.inputs.attached["keyboard"];
  22840. if (keyboard) {
  22841. keyboard.keysDown = value;
  22842. }
  22843. },
  22844. enumerable: true,
  22845. configurable: true
  22846. });
  22847. Object.defineProperty(FreeCamera.prototype, "keysLeft", {
  22848. /**
  22849. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  22850. */
  22851. get: function () {
  22852. var keyboard = this.inputs.attached["keyboard"];
  22853. if (keyboard) {
  22854. return keyboard.keysLeft;
  22855. }
  22856. return [];
  22857. },
  22858. set: function (value) {
  22859. var keyboard = this.inputs.attached["keyboard"];
  22860. if (keyboard) {
  22861. keyboard.keysLeft = value;
  22862. }
  22863. },
  22864. enumerable: true,
  22865. configurable: true
  22866. });
  22867. Object.defineProperty(FreeCamera.prototype, "keysRight", {
  22868. /**
  22869. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  22870. */
  22871. get: function () {
  22872. var keyboard = this.inputs.attached["keyboard"];
  22873. if (keyboard) {
  22874. return keyboard.keysRight;
  22875. }
  22876. return [];
  22877. },
  22878. set: function (value) {
  22879. var keyboard = this.inputs.attached["keyboard"];
  22880. if (keyboard) {
  22881. keyboard.keysRight = value;
  22882. }
  22883. },
  22884. enumerable: true,
  22885. configurable: true
  22886. });
  22887. /**
  22888. * Attached controls to the current camera.
  22889. * @param element Defines the element the controls should be listened from
  22890. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  22891. */
  22892. FreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  22893. this.inputs.attachElement(element, noPreventDefault);
  22894. };
  22895. /**
  22896. * Detach the current controls from the camera.
  22897. * The camera will stop reacting to inputs.
  22898. * @param element Defines the element to stop listening the inputs from
  22899. */
  22900. FreeCamera.prototype.detachControl = function (element) {
  22901. this.inputs.detachElement(element);
  22902. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22903. this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](0, 0);
  22904. };
  22905. Object.defineProperty(FreeCamera.prototype, "collisionMask", {
  22906. /**
  22907. * Define a collision mask to limit the list of object the camera can collide with
  22908. */
  22909. get: function () {
  22910. return this._collisionMask;
  22911. },
  22912. set: function (mask) {
  22913. this._collisionMask = !isNaN(mask) ? mask : -1;
  22914. },
  22915. enumerable: true,
  22916. configurable: true
  22917. });
  22918. /** @hidden */
  22919. FreeCamera.prototype._collideWithWorld = function (displacement) {
  22920. var globalPosition;
  22921. if (this.parent) {
  22922. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  22923. }
  22924. else {
  22925. globalPosition = this.position;
  22926. }
  22927. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  22928. this._oldPosition.addInPlace(this.ellipsoidOffset);
  22929. var coordinator = this.getScene().collisionCoordinator;
  22930. if (!this._collider) {
  22931. this._collider = coordinator.createCollider();
  22932. }
  22933. this._collider._radius = this.ellipsoid;
  22934. this._collider.collisionMask = this._collisionMask;
  22935. //no need for clone, as long as gravity is not on.
  22936. var actualDisplacement = displacement;
  22937. //add gravity to the direction to prevent the dual-collision checking
  22938. if (this.applyGravity) {
  22939. //this prevents mending with cameraDirection, a global variable of the free camera class.
  22940. actualDisplacement = displacement.add(this.getScene().gravity);
  22941. }
  22942. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  22943. };
  22944. /** @hidden */
  22945. FreeCamera.prototype._checkInputs = function () {
  22946. if (!this._localDirection) {
  22947. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22948. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22949. }
  22950. this.inputs.checkInputs();
  22951. _super.prototype._checkInputs.call(this);
  22952. };
  22953. /** @hidden */
  22954. FreeCamera.prototype._decideIfNeedsToMove = function () {
  22955. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22956. };
  22957. /** @hidden */
  22958. FreeCamera.prototype._updatePosition = function () {
  22959. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  22960. this._collideWithWorld(this.cameraDirection);
  22961. }
  22962. else {
  22963. _super.prototype._updatePosition.call(this);
  22964. }
  22965. };
  22966. /**
  22967. * Destroy the camera and release the current resources hold by it.
  22968. */
  22969. FreeCamera.prototype.dispose = function () {
  22970. this.inputs.clear();
  22971. _super.prototype.dispose.call(this);
  22972. };
  22973. /**
  22974. * Gets the current object class name.
  22975. * @return the class name
  22976. */
  22977. FreeCamera.prototype.getClassName = function () {
  22978. return "FreeCamera";
  22979. };
  22980. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22981. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22982. ], FreeCamera.prototype, "ellipsoid", void 0);
  22983. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22984. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22985. ], FreeCamera.prototype, "ellipsoidOffset", void 0);
  22986. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22987. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22988. ], FreeCamera.prototype, "checkCollisions", void 0);
  22989. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22990. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22991. ], FreeCamera.prototype, "applyGravity", void 0);
  22992. return FreeCamera;
  22993. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  22994. /***/ }),
  22995. /***/ "./Cameras/freeCameraInputsManager.ts":
  22996. /*!********************************************!*\
  22997. !*** ./Cameras/freeCameraInputsManager.ts ***!
  22998. \********************************************/
  22999. /*! exports provided: FreeCameraInputsManager */
  23000. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23001. "use strict";
  23002. __webpack_require__.r(__webpack_exports__);
  23003. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return FreeCameraInputsManager; });
  23004. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23005. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  23006. /* harmony import */ var _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  23007. /* harmony import */ var _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  23008. /* harmony import */ var _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  23009. /**
  23010. * Default Inputs manager for the FreeCamera.
  23011. * It groups all the default supported inputs for ease of use.
  23012. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  23013. */
  23014. var FreeCameraInputsManager = /** @class */ (function (_super) {
  23015. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCameraInputsManager, _super);
  23016. /**
  23017. * Instantiates a new FreeCameraInputsManager.
  23018. * @param camera Defines the camera the inputs belong to
  23019. */
  23020. function FreeCameraInputsManager(camera) {
  23021. var _this = _super.call(this, camera) || this;
  23022. /**
  23023. * @hidden
  23024. */
  23025. _this._keyboardInput = null;
  23026. /**
  23027. * @hidden
  23028. */
  23029. _this._mouseInput = null;
  23030. return _this;
  23031. }
  23032. /**
  23033. * Add keyboard input support to the input manager.
  23034. * @returns the current input manager
  23035. */
  23036. FreeCameraInputsManager.prototype.addKeyboard = function () {
  23037. this.add(new _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FreeCameraKeyboardMoveInput"]());
  23038. return this;
  23039. };
  23040. /**
  23041. * Add mouse input support to the input manager.
  23042. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  23043. * @returns the current input manager
  23044. */
  23045. FreeCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  23046. if (touchEnabled === void 0) { touchEnabled = true; }
  23047. if (!this._mouseInput) {
  23048. this._mouseInput = new _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__["FreeCameraMouseInput"](touchEnabled);
  23049. this.add(this._mouseInput);
  23050. }
  23051. return this;
  23052. };
  23053. /**
  23054. * Removes the mouse input support from the manager
  23055. * @returns the current input manager
  23056. */
  23057. FreeCameraInputsManager.prototype.removeMouse = function () {
  23058. if (this._mouseInput) {
  23059. this.remove(this._mouseInput);
  23060. }
  23061. return this;
  23062. };
  23063. /**
  23064. * Add touch input support to the input manager.
  23065. * @returns the current input manager
  23066. */
  23067. FreeCameraInputsManager.prototype.addTouch = function () {
  23068. this.add(new _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraTouchInput"]());
  23069. return this;
  23070. };
  23071. return FreeCameraInputsManager;
  23072. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  23073. /***/ }),
  23074. /***/ "./Cameras/gamepadCamera.ts":
  23075. /*!**********************************!*\
  23076. !*** ./Cameras/gamepadCamera.ts ***!
  23077. \**********************************/
  23078. /*! exports provided: GamepadCamera */
  23079. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23080. "use strict";
  23081. __webpack_require__.r(__webpack_exports__);
  23082. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return GamepadCamera; });
  23083. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23084. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  23085. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23086. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23087. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("GamepadCamera", function (name, scene) {
  23088. return function () { return new GamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23089. });
  23090. /**
  23091. * This represents a FPS type of camera. This is only here for back compat purpose.
  23092. * Please use the UniversalCamera instead as both are identical.
  23093. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23094. */
  23095. var GamepadCamera = /** @class */ (function (_super) {
  23096. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GamepadCamera, _super);
  23097. /**
  23098. * Instantiates a new Gamepad Camera
  23099. * This represents a FPS type of camera. This is only here for back compat purpose.
  23100. * Please use the UniversalCamera instead as both are identical.
  23101. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23102. * @param name Define the name of the camera in the scene
  23103. * @param position Define the start position of the camera in the scene
  23104. * @param scene Define the scene the camera belongs to
  23105. */
  23106. function GamepadCamera(name, position, scene) {
  23107. return _super.call(this, name, position, scene) || this;
  23108. }
  23109. /**
  23110. * Gets the current object class name.
  23111. * @return the class name
  23112. */
  23113. GamepadCamera.prototype.getClassName = function () {
  23114. return "GamepadCamera";
  23115. };
  23116. return GamepadCamera;
  23117. }(_universalCamera__WEBPACK_IMPORTED_MODULE_1__["UniversalCamera"]));
  23118. /***/ }),
  23119. /***/ "./Cameras/index.ts":
  23120. /*!**************************!*\
  23121. !*** ./Cameras/index.ts ***!
  23122. \**************************/
  23123. /*! 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 */
  23124. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23125. "use strict";
  23126. __webpack_require__.r(__webpack_exports__);
  23127. /* harmony import */ var _Inputs_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Inputs/index */ "./Cameras/Inputs/index.ts");
  23128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  23129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  23130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  23131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  23132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  23133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  23134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  23135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraKeyboardMoveInput"]; });
  23136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraMouseWheelInput"]; });
  23137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraPointersInput"]; });
  23138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  23139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  23140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  23141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  23142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  23143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  23144. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  23145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]; });
  23146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]; });
  23147. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]; });
  23149. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  23150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]; });
  23151. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _freeCamera__WEBPACK_IMPORTED_MODULE_4__["FreeCamera"]; });
  23153. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  23154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"]; });
  23155. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  23156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _touchCamera__WEBPACK_IMPORTED_MODULE_6__["TouchCamera"]; });
  23157. /* harmony import */ var _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  23158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  23159. /* harmony import */ var _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  23160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__["ArcRotateCameraInputsManager"]; });
  23161. /* harmony import */ var _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  23162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__["DeviceOrientationCamera"]; });
  23163. /* harmony import */ var _flyCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./flyCamera */ "./Cameras/flyCamera.ts");
  23164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _flyCamera__WEBPACK_IMPORTED_MODULE_10__["FlyCamera"]; });
  23165. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  23166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["FlyCameraInputsManager"]; });
  23167. /* harmony import */ var _followCamera__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./followCamera */ "./Cameras/followCamera.ts");
  23168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["FollowCamera"]; });
  23169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["ArcFollowCamera"]; });
  23170. /* harmony import */ var _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./gamepadCamera */ "./Cameras/gamepadCamera.ts");
  23171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__["GamepadCamera"]; });
  23172. /* harmony import */ var _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Stereoscopic/index */ "./Cameras/Stereoscopic/index.ts");
  23173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphArcRotateCamera"]; });
  23174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphFreeCamera"]; });
  23175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphGamepadCamera"]; });
  23176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphUniversalCamera"]; });
  23177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicArcRotateCamera"]; });
  23178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicFreeCamera"]; });
  23179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicGamepadCamera"]; });
  23180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicUniversalCamera"]; });
  23181. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  23182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _universalCamera__WEBPACK_IMPORTED_MODULE_15__["UniversalCamera"]; });
  23183. /* harmony import */ var _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./virtualJoysticksCamera */ "./Cameras/virtualJoysticksCamera.ts");
  23184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__["VirtualJoysticksCamera"]; });
  23185. /* harmony import */ var _VR_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./VR/index */ "./Cameras/VR/index.ts");
  23186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRCameraMetrics"]; });
  23187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationArcRotateCamera"]; });
  23188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationFreeCamera"]; });
  23189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationGamepadCamera"]; });
  23190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["OnAfterEnteringVRObservableEvent"]; });
  23191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRExperienceHelper"]; });
  23192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["WebVRFreeCamera"]; });
  23193. /* harmony import */ var _XR_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./XR/index */ "./Cameras/XR/index.ts");
  23194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRCamera"]; });
  23195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIButton"]; });
  23196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIOptions"]; });
  23197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUI"]; });
  23198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRState"]; });
  23199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRExperienceHelper"]; });
  23200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRController"]; });
  23201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRInput"]; });
  23202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRManagedOutputCanvas"]; });
  23203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRSessionManager"]; });
  23204. /***/ }),
  23205. /***/ "./Cameras/targetCamera.ts":
  23206. /*!*********************************!*\
  23207. !*** ./Cameras/targetCamera.ts ***!
  23208. \*********************************/
  23209. /*! exports provided: TargetCamera */
  23210. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23211. "use strict";
  23212. __webpack_require__.r(__webpack_exports__);
  23213. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return TargetCamera; });
  23214. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23215. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  23216. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23217. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23218. /**
  23219. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  23220. * This is the base of the follow, arc rotate cameras and Free camera
  23221. * @see http://doc.babylonjs.com/features/cameras
  23222. */
  23223. var TargetCamera = /** @class */ (function (_super) {
  23224. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TargetCamera, _super);
  23225. /**
  23226. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  23227. * This is the base of the follow, arc rotate cameras and Free camera
  23228. * @see http://doc.babylonjs.com/features/cameras
  23229. * @param name Defines the name of the camera in the scene
  23230. * @param position Defines the start position of the camera in the scene
  23231. * @param scene Defines the scene the camera belongs to
  23232. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  23233. */
  23234. function TargetCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  23235. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  23236. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  23237. /**
  23238. * Define the current direction the camera is moving to
  23239. */
  23240. _this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  23241. /**
  23242. * Define the current rotation the camera is rotating to
  23243. */
  23244. _this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  23245. /**
  23246. * When set, the up vector of the camera will be updated by the rotation of the camera
  23247. */
  23248. _this.updateUpVectorFromRotation = false;
  23249. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  23250. /**
  23251. * Define the current rotation of the camera
  23252. */
  23253. _this.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  23254. /**
  23255. * Define the current speed of the camera
  23256. */
  23257. _this.speed = 2.0;
  23258. /**
  23259. * Add cconstraint to the camera to prevent it to move freely in all directions and
  23260. * around all axis.
  23261. */
  23262. _this.noRotationConstraint = false;
  23263. /**
  23264. * Define the current target of the camera as an object or a position.
  23265. */
  23266. _this.lockedTarget = null;
  23267. /** @hidden */
  23268. _this._currentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23269. /** @hidden */
  23270. _this._initialFocalDistance = 1;
  23271. /** @hidden */
  23272. _this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23273. /** @hidden */
  23274. _this._camMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23275. /** @hidden */
  23276. _this._cameraTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23277. /** @hidden */
  23278. _this._cameraRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23279. /** @hidden */
  23280. _this._referencePoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  23281. /** @hidden */
  23282. _this._transformedReferencePoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23283. _this._globalCurrentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23284. _this._globalCurrentUpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23285. _this._defaultUp = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up();
  23286. _this._cachedRotationZ = 0;
  23287. _this._cachedQuaternionRotationZ = 0;
  23288. return _this;
  23289. }
  23290. /**
  23291. * Gets the position in front of the camera at a given distance.
  23292. * @param distance The distance from the camera we want the position to be
  23293. * @returns the position
  23294. */
  23295. TargetCamera.prototype.getFrontPosition = function (distance) {
  23296. this.getWorldMatrix();
  23297. var direction = this.getTarget().subtract(this.position);
  23298. direction.normalize();
  23299. direction.scaleInPlace(distance);
  23300. return this.globalPosition.add(direction);
  23301. };
  23302. /** @hidden */
  23303. TargetCamera.prototype._getLockedTargetPosition = function () {
  23304. if (!this.lockedTarget) {
  23305. return null;
  23306. }
  23307. if (this.lockedTarget.absolutePosition) {
  23308. this.lockedTarget.computeWorldMatrix();
  23309. }
  23310. return this.lockedTarget.absolutePosition || this.lockedTarget;
  23311. };
  23312. /**
  23313. * Store current camera state of the camera (fov, position, rotation, etc..)
  23314. * @returns the camera
  23315. */
  23316. TargetCamera.prototype.storeState = function () {
  23317. this._storedPosition = this.position.clone();
  23318. this._storedRotation = this.rotation.clone();
  23319. if (this.rotationQuaternion) {
  23320. this._storedRotationQuaternion = this.rotationQuaternion.clone();
  23321. }
  23322. return _super.prototype.storeState.call(this);
  23323. };
  23324. /**
  23325. * Restored camera state. You must call storeState() first
  23326. * @returns whether it was successful or not
  23327. * @hidden
  23328. */
  23329. TargetCamera.prototype._restoreStateValues = function () {
  23330. if (!_super.prototype._restoreStateValues.call(this)) {
  23331. return false;
  23332. }
  23333. this.position = this._storedPosition.clone();
  23334. this.rotation = this._storedRotation.clone();
  23335. if (this.rotationQuaternion) {
  23336. this.rotationQuaternion = this._storedRotationQuaternion.clone();
  23337. }
  23338. this.cameraDirection.copyFromFloats(0, 0, 0);
  23339. this.cameraRotation.copyFromFloats(0, 0);
  23340. return true;
  23341. };
  23342. /** @hidden */
  23343. TargetCamera.prototype._initCache = function () {
  23344. _super.prototype._initCache.call(this);
  23345. this._cache.lockedTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  23346. this._cache.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  23347. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  23348. };
  23349. /** @hidden */
  23350. TargetCamera.prototype._updateCache = function (ignoreParentClass) {
  23351. if (!ignoreParentClass) {
  23352. _super.prototype._updateCache.call(this);
  23353. }
  23354. var lockedTargetPosition = this._getLockedTargetPosition();
  23355. if (!lockedTargetPosition) {
  23356. this._cache.lockedTarget = null;
  23357. }
  23358. else {
  23359. if (!this._cache.lockedTarget) {
  23360. this._cache.lockedTarget = lockedTargetPosition.clone();
  23361. }
  23362. else {
  23363. this._cache.lockedTarget.copyFrom(lockedTargetPosition);
  23364. }
  23365. }
  23366. this._cache.rotation.copyFrom(this.rotation);
  23367. if (this.rotationQuaternion) {
  23368. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  23369. }
  23370. };
  23371. // Synchronized
  23372. /** @hidden */
  23373. TargetCamera.prototype._isSynchronizedViewMatrix = function () {
  23374. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  23375. return false;
  23376. }
  23377. var lockedTargetPosition = this._getLockedTargetPosition();
  23378. return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(lockedTargetPosition) : !lockedTargetPosition)
  23379. && (this.rotationQuaternion ? this.rotationQuaternion.equals(this._cache.rotationQuaternion) : this._cache.rotation.equals(this.rotation));
  23380. };
  23381. // Methods
  23382. /** @hidden */
  23383. TargetCamera.prototype._computeLocalCameraSpeed = function () {
  23384. var engine = this.getEngine();
  23385. return this.speed * Math.sqrt((engine.getDeltaTime() / (engine.getFps() * 100.0)));
  23386. };
  23387. // Target
  23388. /**
  23389. * Defines the target the camera should look at.
  23390. * This will automatically adapt alpha beta and radius to fit within the new target.
  23391. * @param target Defines the new target as a Vector or a mesh
  23392. */
  23393. TargetCamera.prototype.setTarget = function (target) {
  23394. this.upVector.normalize();
  23395. this._initialFocalDistance = target.subtract(this.position).length();
  23396. if (this.position.z === target.z) {
  23397. this.position.z += _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  23398. }
  23399. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this.position, target, this._defaultUp, this._camMatrix);
  23400. this._camMatrix.invert();
  23401. this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]);
  23402. var vDir = target.subtract(this.position);
  23403. if (vDir.x >= 0.0) {
  23404. this.rotation.y = (-Math.atan(vDir.z / vDir.x) + Math.PI / 2.0);
  23405. }
  23406. else {
  23407. this.rotation.y = (-Math.atan(vDir.z / vDir.x) - Math.PI / 2.0);
  23408. }
  23409. this.rotation.z = 0;
  23410. if (isNaN(this.rotation.x)) {
  23411. this.rotation.x = 0;
  23412. }
  23413. if (isNaN(this.rotation.y)) {
  23414. this.rotation.y = 0;
  23415. }
  23416. if (isNaN(this.rotation.z)) {
  23417. this.rotation.z = 0;
  23418. }
  23419. if (this.rotationQuaternion) {
  23420. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  23421. }
  23422. };
  23423. /**
  23424. * Return the current target position of the camera. This value is expressed in local space.
  23425. * @returns the target position
  23426. */
  23427. TargetCamera.prototype.getTarget = function () {
  23428. return this._currentTarget;
  23429. };
  23430. /** @hidden */
  23431. TargetCamera.prototype._decideIfNeedsToMove = function () {
  23432. return Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  23433. };
  23434. /** @hidden */
  23435. TargetCamera.prototype._updatePosition = function () {
  23436. if (this.parent) {
  23437. this.parent.getWorldMatrix().invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  23438. _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]);
  23439. this.position.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0]);
  23440. return;
  23441. }
  23442. this.position.addInPlace(this.cameraDirection);
  23443. };
  23444. /** @hidden */
  23445. TargetCamera.prototype._checkInputs = function () {
  23446. var needToMove = this._decideIfNeedsToMove();
  23447. var needToRotate = Math.abs(this.cameraRotation.x) > 0 || Math.abs(this.cameraRotation.y) > 0;
  23448. // Move
  23449. if (needToMove) {
  23450. this._updatePosition();
  23451. }
  23452. // Rotate
  23453. if (needToRotate) {
  23454. this.rotation.x += this.cameraRotation.x;
  23455. this.rotation.y += this.cameraRotation.y;
  23456. //rotate, if quaternion is set and rotation was used
  23457. if (this.rotationQuaternion) {
  23458. var len = this.rotation.lengthSquared();
  23459. if (len) {
  23460. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  23461. }
  23462. }
  23463. if (!this.noRotationConstraint) {
  23464. var limit = (Math.PI / 2) * 0.95;
  23465. if (this.rotation.x > limit) {
  23466. this.rotation.x = limit;
  23467. }
  23468. if (this.rotation.x < -limit) {
  23469. this.rotation.x = -limit;
  23470. }
  23471. }
  23472. }
  23473. // Inertia
  23474. if (needToMove) {
  23475. if (Math.abs(this.cameraDirection.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23476. this.cameraDirection.x = 0;
  23477. }
  23478. if (Math.abs(this.cameraDirection.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23479. this.cameraDirection.y = 0;
  23480. }
  23481. if (Math.abs(this.cameraDirection.z) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23482. this.cameraDirection.z = 0;
  23483. }
  23484. this.cameraDirection.scaleInPlace(this.inertia);
  23485. }
  23486. if (needToRotate) {
  23487. if (Math.abs(this.cameraRotation.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23488. this.cameraRotation.x = 0;
  23489. }
  23490. if (Math.abs(this.cameraRotation.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23491. this.cameraRotation.y = 0;
  23492. }
  23493. this.cameraRotation.scaleInPlace(this.inertia);
  23494. }
  23495. _super.prototype._checkInputs.call(this);
  23496. };
  23497. TargetCamera.prototype._updateCameraRotationMatrix = function () {
  23498. if (this.rotationQuaternion) {
  23499. this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix);
  23500. }
  23501. else {
  23502. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
  23503. }
  23504. };
  23505. /**
  23506. * 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)
  23507. * @returns the current camera
  23508. */
  23509. TargetCamera.prototype._rotateUpVectorWithCameraRotationMatrix = function () {
  23510. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._defaultUp, this._cameraRotationMatrix, this.upVector);
  23511. return this;
  23512. };
  23513. /** @hidden */
  23514. TargetCamera.prototype._getViewMatrix = function () {
  23515. if (this.lockedTarget) {
  23516. this.setTarget(this._getLockedTargetPosition());
  23517. }
  23518. // Compute
  23519. this._updateCameraRotationMatrix();
  23520. // Apply the changed rotation to the upVector
  23521. if (this.rotationQuaternion && this._cachedQuaternionRotationZ != this.rotationQuaternion.z) {
  23522. this._rotateUpVectorWithCameraRotationMatrix();
  23523. this._cachedQuaternionRotationZ = this.rotationQuaternion.z;
  23524. }
  23525. else if (this._cachedRotationZ != this.rotation.z) {
  23526. this._rotateUpVectorWithCameraRotationMatrix();
  23527. this._cachedRotationZ = this.rotation.z;
  23528. }
  23529. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  23530. // Computing target and final matrix
  23531. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  23532. if (this.updateUpVectorFromRotation) {
  23533. if (this.rotationQuaternion) {
  23534. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector);
  23535. }
  23536. else {
  23537. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, this._tmpQuaternion);
  23538. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector);
  23539. }
  23540. }
  23541. this._computeViewMatrix(this.position, this._currentTarget, this.upVector);
  23542. return this._viewMatrix;
  23543. };
  23544. TargetCamera.prototype._computeViewMatrix = function (position, target, up) {
  23545. if (this.parent) {
  23546. var parentWorldMatrix = this.parent.getWorldMatrix();
  23547. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(position, parentWorldMatrix, this._globalPosition);
  23548. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(target, parentWorldMatrix, this._globalCurrentTarget);
  23549. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(up, parentWorldMatrix, this._globalCurrentUpVector);
  23550. this._markSyncedWithParent();
  23551. }
  23552. else {
  23553. this._globalPosition.copyFrom(position);
  23554. this._globalCurrentTarget.copyFrom(target);
  23555. this._globalCurrentUpVector.copyFrom(up);
  23556. }
  23557. if (this.getScene().useRightHandedSystem) {
  23558. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtRHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  23559. }
  23560. else {
  23561. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  23562. }
  23563. };
  23564. /**
  23565. * @hidden
  23566. */
  23567. TargetCamera.prototype.createRigCamera = function (name, cameraIndex) {
  23568. if (this.cameraRigMode !== _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_NONE) {
  23569. var rigCamera = new TargetCamera(name, this.position.clone(), this.getScene());
  23570. if (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR || this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_WEBVR) {
  23571. if (!this.rotationQuaternion) {
  23572. this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  23573. }
  23574. rigCamera._cameraRigParams = {};
  23575. rigCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  23576. }
  23577. return rigCamera;
  23578. }
  23579. return null;
  23580. };
  23581. /**
  23582. * @hidden
  23583. */
  23584. TargetCamera.prototype._updateRigCameras = function () {
  23585. var camLeft = this._rigCameras[0];
  23586. var camRight = this._rigCameras[1];
  23587. this.computeWorldMatrix();
  23588. switch (this.cameraRigMode) {
  23589. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  23590. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  23591. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  23592. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  23593. //provisionnaly using _cameraRigParams.stereoHalfAngle instead of calculations based on _cameraRigParams.interaxialDistance:
  23594. var leftSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? 1 : -1;
  23595. var rightSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? -1 : 1;
  23596. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * leftSign, camLeft);
  23597. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * rightSign, camRight);
  23598. break;
  23599. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR:
  23600. if (camLeft.rotationQuaternion) {
  23601. camLeft.rotationQuaternion.copyFrom(this.rotationQuaternion);
  23602. camRight.rotationQuaternion.copyFrom(this.rotationQuaternion);
  23603. }
  23604. else {
  23605. camLeft.rotation.copyFrom(this.rotation);
  23606. camRight.rotation.copyFrom(this.rotation);
  23607. }
  23608. camLeft.position.copyFrom(this.position);
  23609. camRight.position.copyFrom(this.position);
  23610. break;
  23611. }
  23612. _super.prototype._updateRigCameras.call(this);
  23613. };
  23614. TargetCamera.prototype._getRigCamPositionAndTarget = function (halfSpace, rigCamera) {
  23615. var target = this.getTarget();
  23616. target.subtractToRef(this.position, TargetCamera._TargetFocalPoint);
  23617. TargetCamera._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);
  23618. var newFocalTarget = TargetCamera._TargetFocalPoint.addInPlace(this.position);
  23619. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-newFocalTarget.x, -newFocalTarget.y, -newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  23620. TargetCamera._TargetTransformMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(halfSpace), TargetCamera._RigCamTransformMatrix);
  23621. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(newFocalTarget.x, newFocalTarget.y, newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  23622. TargetCamera._RigCamTransformMatrix.multiplyToRef(TargetCamera._TargetTransformMatrix, TargetCamera._RigCamTransformMatrix);
  23623. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, TargetCamera._RigCamTransformMatrix, rigCamera.position);
  23624. rigCamera.setTarget(newFocalTarget);
  23625. };
  23626. /**
  23627. * Gets the current object class name.
  23628. * @return the class name
  23629. */
  23630. TargetCamera.prototype.getClassName = function () {
  23631. return "TargetCamera";
  23632. };
  23633. TargetCamera._RigCamTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  23634. TargetCamera._TargetTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  23635. TargetCamera._TargetFocalPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  23636. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23637. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  23638. ], TargetCamera.prototype, "rotation", void 0);
  23639. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23640. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23641. ], TargetCamera.prototype, "speed", void 0);
  23642. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23643. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  23644. ], TargetCamera.prototype, "lockedTarget", void 0);
  23645. return TargetCamera;
  23646. }(_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]));
  23647. /***/ }),
  23648. /***/ "./Cameras/touchCamera.ts":
  23649. /*!********************************!*\
  23650. !*** ./Cameras/touchCamera.ts ***!
  23651. \********************************/
  23652. /*! exports provided: TouchCamera */
  23653. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23654. "use strict";
  23655. __webpack_require__.r(__webpack_exports__);
  23656. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return TouchCamera; });
  23657. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23658. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23659. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23660. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23661. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("TouchCamera", function (name, scene) {
  23662. return function () { return new TouchCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23663. });
  23664. /**
  23665. * This represents a FPS type of camera controlled by touch.
  23666. * This is like a universal camera minus the Gamepad controls.
  23667. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23668. */
  23669. var TouchCamera = /** @class */ (function (_super) {
  23670. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TouchCamera, _super);
  23671. /**
  23672. * Instantiates a new touch camera.
  23673. * This represents a FPS type of camera controlled by touch.
  23674. * This is like a universal camera minus the Gamepad controls.
  23675. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23676. * @param name Define the name of the camera in the scene
  23677. * @param position Define the start position of the camera in the scene
  23678. * @param scene Define the scene the camera belongs to
  23679. */
  23680. function TouchCamera(name, position, scene) {
  23681. var _this = _super.call(this, name, position, scene) || this;
  23682. _this.inputs.addTouch();
  23683. _this._setupInputs();
  23684. return _this;
  23685. }
  23686. Object.defineProperty(TouchCamera.prototype, "touchAngularSensibility", {
  23687. /**
  23688. * Defines the touch sensibility for rotation.
  23689. * The higher the faster.
  23690. */
  23691. get: function () {
  23692. var touch = this.inputs.attached["touch"];
  23693. if (touch) {
  23694. return touch.touchAngularSensibility;
  23695. }
  23696. return 0;
  23697. },
  23698. set: function (value) {
  23699. var touch = this.inputs.attached["touch"];
  23700. if (touch) {
  23701. touch.touchAngularSensibility = value;
  23702. }
  23703. },
  23704. enumerable: true,
  23705. configurable: true
  23706. });
  23707. Object.defineProperty(TouchCamera.prototype, "touchMoveSensibility", {
  23708. /**
  23709. * Defines the touch sensibility for move.
  23710. * The higher the faster.
  23711. */
  23712. get: function () {
  23713. var touch = this.inputs.attached["touch"];
  23714. if (touch) {
  23715. return touch.touchMoveSensibility;
  23716. }
  23717. return 0;
  23718. },
  23719. set: function (value) {
  23720. var touch = this.inputs.attached["touch"];
  23721. if (touch) {
  23722. touch.touchMoveSensibility = value;
  23723. }
  23724. },
  23725. enumerable: true,
  23726. configurable: true
  23727. });
  23728. /**
  23729. * Gets the current object class name.
  23730. * @return the class name
  23731. */
  23732. TouchCamera.prototype.getClassName = function () {
  23733. return "TouchCamera";
  23734. };
  23735. /** @hidden */
  23736. TouchCamera.prototype._setupInputs = function () {
  23737. var mouse = this.inputs.attached["mouse"];
  23738. if (mouse) {
  23739. mouse.touchEnabled = false;
  23740. }
  23741. };
  23742. return TouchCamera;
  23743. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23744. /***/ }),
  23745. /***/ "./Cameras/universalCamera.ts":
  23746. /*!************************************!*\
  23747. !*** ./Cameras/universalCamera.ts ***!
  23748. \************************************/
  23749. /*! exports provided: UniversalCamera */
  23750. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23751. "use strict";
  23752. __webpack_require__.r(__webpack_exports__);
  23753. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return UniversalCamera; });
  23754. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23755. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  23756. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../node */ "./node.ts");
  23757. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23758. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23759. _node__WEBPACK_IMPORTED_MODULE_2__["Node"].AddNodeConstructor("FreeCamera", function (name, scene) {
  23760. // Forcing to use the Universal camera
  23761. return function () { return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  23762. });
  23763. /**
  23764. * 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,
  23765. * which still works and will still be found in many Playgrounds.
  23766. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23767. */
  23768. var UniversalCamera = /** @class */ (function (_super) {
  23769. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](UniversalCamera, _super);
  23770. /**
  23771. * 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,
  23772. * which still works and will still be found in many Playgrounds.
  23773. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23774. * @param name Define the name of the camera in the scene
  23775. * @param position Define the start position of the camera in the scene
  23776. * @param scene Define the scene the camera belongs to
  23777. */
  23778. function UniversalCamera(name, position, scene) {
  23779. var _this = _super.call(this, name, position, scene) || this;
  23780. _this.inputs.addGamepad();
  23781. return _this;
  23782. }
  23783. Object.defineProperty(UniversalCamera.prototype, "gamepadAngularSensibility", {
  23784. /**
  23785. * Defines the gamepad rotation sensiblity.
  23786. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  23787. */
  23788. get: function () {
  23789. var gamepad = this.inputs.attached["gamepad"];
  23790. if (gamepad) {
  23791. return gamepad.gamepadAngularSensibility;
  23792. }
  23793. return 0;
  23794. },
  23795. set: function (value) {
  23796. var gamepad = this.inputs.attached["gamepad"];
  23797. if (gamepad) {
  23798. gamepad.gamepadAngularSensibility = value;
  23799. }
  23800. },
  23801. enumerable: true,
  23802. configurable: true
  23803. });
  23804. Object.defineProperty(UniversalCamera.prototype, "gamepadMoveSensibility", {
  23805. /**
  23806. * Defines the gamepad move sensiblity.
  23807. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  23808. */
  23809. get: function () {
  23810. var gamepad = this.inputs.attached["gamepad"];
  23811. if (gamepad) {
  23812. return gamepad.gamepadMoveSensibility;
  23813. }
  23814. return 0;
  23815. },
  23816. set: function (value) {
  23817. var gamepad = this.inputs.attached["gamepad"];
  23818. if (gamepad) {
  23819. gamepad.gamepadMoveSensibility = value;
  23820. }
  23821. },
  23822. enumerable: true,
  23823. configurable: true
  23824. });
  23825. /**
  23826. * Gets the current object class name.
  23827. * @return the class name
  23828. */
  23829. UniversalCamera.prototype.getClassName = function () {
  23830. return "UniversalCamera";
  23831. };
  23832. return UniversalCamera;
  23833. }(_touchCamera__WEBPACK_IMPORTED_MODULE_1__["TouchCamera"]));
  23834. _camera__WEBPACK_IMPORTED_MODULE_4__["Camera"]._createDefaultParsedCamera = function (name, scene) {
  23835. return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene);
  23836. };
  23837. /***/ }),
  23838. /***/ "./Cameras/virtualJoysticksCamera.ts":
  23839. /*!*******************************************!*\
  23840. !*** ./Cameras/virtualJoysticksCamera.ts ***!
  23841. \*******************************************/
  23842. /*! exports provided: VirtualJoysticksCamera */
  23843. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23844. "use strict";
  23845. __webpack_require__.r(__webpack_exports__);
  23846. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return VirtualJoysticksCamera; });
  23847. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23848. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23849. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23850. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23851. /* harmony import */ var _Inputs_freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  23852. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("VirtualJoysticksCamera", function (name, scene) {
  23853. return function () { return new VirtualJoysticksCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23854. });
  23855. /**
  23856. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  23857. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23858. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23859. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23860. */
  23861. var VirtualJoysticksCamera = /** @class */ (function (_super) {
  23862. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualJoysticksCamera, _super);
  23863. /**
  23864. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  23865. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23866. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23867. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23868. * @param name Define the name of the camera in the scene
  23869. * @param position Define the start position of the camera in the scene
  23870. * @param scene Define the scene the camera belongs to
  23871. */
  23872. function VirtualJoysticksCamera(name, position, scene) {
  23873. var _this = _super.call(this, name, position, scene) || this;
  23874. _this.inputs.addVirtualJoystick();
  23875. return _this;
  23876. }
  23877. /**
  23878. * Gets the current object class name.
  23879. * @return the class name
  23880. */
  23881. VirtualJoysticksCamera.prototype.getClassName = function () {
  23882. return "VirtualJoysticksCamera";
  23883. };
  23884. return VirtualJoysticksCamera;
  23885. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23886. /***/ }),
  23887. /***/ "./Collisions/collider.ts":
  23888. /*!********************************!*\
  23889. !*** ./Collisions/collider.ts ***!
  23890. \********************************/
  23891. /*! exports provided: Collider */
  23892. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23893. "use strict";
  23894. __webpack_require__.r(__webpack_exports__);
  23895. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return Collider; });
  23896. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23897. var intersectBoxAASphere = function (boxMin, boxMax, sphereCenter, sphereRadius) {
  23898. if (boxMin.x > sphereCenter.x + sphereRadius) {
  23899. return false;
  23900. }
  23901. if (sphereCenter.x - sphereRadius > boxMax.x) {
  23902. return false;
  23903. }
  23904. if (boxMin.y > sphereCenter.y + sphereRadius) {
  23905. return false;
  23906. }
  23907. if (sphereCenter.y - sphereRadius > boxMax.y) {
  23908. return false;
  23909. }
  23910. if (boxMin.z > sphereCenter.z + sphereRadius) {
  23911. return false;
  23912. }
  23913. if (sphereCenter.z - sphereRadius > boxMax.z) {
  23914. return false;
  23915. }
  23916. return true;
  23917. };
  23918. var getLowestRoot = (function () {
  23919. var result = { root: 0, found: false };
  23920. return function (a, b, c, maxR) {
  23921. result.root = 0;
  23922. result.found = false;
  23923. var determinant = b * b - 4.0 * a * c;
  23924. if (determinant < 0) {
  23925. return result;
  23926. }
  23927. var sqrtD = Math.sqrt(determinant);
  23928. var r1 = (-b - sqrtD) / (2.0 * a);
  23929. var r2 = (-b + sqrtD) / (2.0 * a);
  23930. if (r1 > r2) {
  23931. var temp = r2;
  23932. r2 = r1;
  23933. r1 = temp;
  23934. }
  23935. if (r1 > 0 && r1 < maxR) {
  23936. result.root = r1;
  23937. result.found = true;
  23938. return result;
  23939. }
  23940. if (r2 > 0 && r2 < maxR) {
  23941. result.root = r2;
  23942. result.found = true;
  23943. return result;
  23944. }
  23945. return result;
  23946. };
  23947. })();
  23948. /** @hidden */
  23949. var Collider = /** @class */ (function () {
  23950. function Collider() {
  23951. this._collisionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23952. this._planeIntersectionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23953. this._tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23954. this._tempVector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23955. this._tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23956. this._tempVector4 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23957. this._edge = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23958. this._baseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23959. this._destinationPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23960. this._slidePlaneNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23961. this._displacementVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23962. /** @hidden */
  23963. this._radius = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  23964. /** @hidden */
  23965. this._retry = 0;
  23966. /** @hidden */
  23967. this._basePointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23968. this._velocityWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23969. this._normalizedVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23970. this._collisionMask = -1;
  23971. }
  23972. Object.defineProperty(Collider.prototype, "collisionMask", {
  23973. get: function () {
  23974. return this._collisionMask;
  23975. },
  23976. set: function (mask) {
  23977. this._collisionMask = !isNaN(mask) ? mask : -1;
  23978. },
  23979. enumerable: true,
  23980. configurable: true
  23981. });
  23982. Object.defineProperty(Collider.prototype, "slidePlaneNormal", {
  23983. /**
  23984. * Gets the plane normal used to compute the sliding response (in local space)
  23985. */
  23986. get: function () {
  23987. return this._slidePlaneNormal;
  23988. },
  23989. enumerable: true,
  23990. configurable: true
  23991. });
  23992. // Methods
  23993. /** @hidden */
  23994. Collider.prototype._initialize = function (source, dir, e) {
  23995. this._velocity = dir;
  23996. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].NormalizeToRef(dir, this._normalizedVelocity);
  23997. this._basePoint = source;
  23998. source.multiplyToRef(this._radius, this._basePointWorld);
  23999. dir.multiplyToRef(this._radius, this._velocityWorld);
  24000. this._velocityWorldLength = this._velocityWorld.length();
  24001. this._epsilon = e;
  24002. this.collisionFound = false;
  24003. };
  24004. /** @hidden */
  24005. Collider.prototype._checkPointInTriangle = function (point, pa, pb, pc, n) {
  24006. pa.subtractToRef(point, this._tempVector);
  24007. pb.subtractToRef(point, this._tempVector2);
  24008. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector, this._tempVector2, this._tempVector4);
  24009. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  24010. if (d < 0) {
  24011. return false;
  24012. }
  24013. pc.subtractToRef(point, this._tempVector3);
  24014. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector2, this._tempVector3, this._tempVector4);
  24015. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  24016. if (d < 0) {
  24017. return false;
  24018. }
  24019. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector3, this._tempVector, this._tempVector4);
  24020. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  24021. return d >= 0;
  24022. };
  24023. /** @hidden */
  24024. Collider.prototype._canDoCollision = function (sphereCenter, sphereRadius, vecMin, vecMax) {
  24025. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(this._basePointWorld, sphereCenter);
  24026. var max = Math.max(this._radius.x, this._radius.y, this._radius.z);
  24027. if (distance > this._velocityWorldLength + max + sphereRadius) {
  24028. return false;
  24029. }
  24030. if (!intersectBoxAASphere(vecMin, vecMax, this._basePointWorld, this._velocityWorldLength + max)) {
  24031. return false;
  24032. }
  24033. return true;
  24034. };
  24035. /** @hidden */
  24036. Collider.prototype._testTriangle = function (faceIndex, trianglePlaneArray, p1, p2, p3, hasMaterial) {
  24037. var t0;
  24038. var embeddedInPlane = false;
  24039. //defensive programming, actually not needed.
  24040. if (!trianglePlaneArray) {
  24041. trianglePlaneArray = [];
  24042. }
  24043. if (!trianglePlaneArray[faceIndex]) {
  24044. trianglePlaneArray[faceIndex] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"](0, 0, 0, 0);
  24045. trianglePlaneArray[faceIndex].copyFromPoints(p1, p2, p3);
  24046. }
  24047. var trianglePlane = trianglePlaneArray[faceIndex];
  24048. if ((!hasMaterial) && !trianglePlane.isFrontFacingTo(this._normalizedVelocity, 0)) {
  24049. return;
  24050. }
  24051. var signedDistToTrianglePlane = trianglePlane.signedDistanceTo(this._basePoint);
  24052. var normalDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(trianglePlane.normal, this._velocity);
  24053. if (normalDotVelocity == 0) {
  24054. if (Math.abs(signedDistToTrianglePlane) >= 1.0) {
  24055. return;
  24056. }
  24057. embeddedInPlane = true;
  24058. t0 = 0;
  24059. }
  24060. else {
  24061. t0 = (-1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  24062. var t1 = (1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  24063. if (t0 > t1) {
  24064. var temp = t1;
  24065. t1 = t0;
  24066. t0 = temp;
  24067. }
  24068. if (t0 > 1.0 || t1 < 0.0) {
  24069. return;
  24070. }
  24071. if (t0 < 0) {
  24072. t0 = 0;
  24073. }
  24074. if (t0 > 1.0) {
  24075. t0 = 1.0;
  24076. }
  24077. }
  24078. this._collisionPoint.copyFromFloats(0, 0, 0);
  24079. var found = false;
  24080. var t = 1.0;
  24081. if (!embeddedInPlane) {
  24082. this._basePoint.subtractToRef(trianglePlane.normal, this._planeIntersectionPoint);
  24083. this._velocity.scaleToRef(t0, this._tempVector);
  24084. this._planeIntersectionPoint.addInPlace(this._tempVector);
  24085. if (this._checkPointInTriangle(this._planeIntersectionPoint, p1, p2, p3, trianglePlane.normal)) {
  24086. found = true;
  24087. t = t0;
  24088. this._collisionPoint.copyFrom(this._planeIntersectionPoint);
  24089. }
  24090. }
  24091. if (!found) {
  24092. var velocitySquaredLength = this._velocity.lengthSquared();
  24093. var a = velocitySquaredLength;
  24094. this._basePoint.subtractToRef(p1, this._tempVector);
  24095. var b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  24096. var c = this._tempVector.lengthSquared() - 1.0;
  24097. var lowestRoot = getLowestRoot(a, b, c, t);
  24098. if (lowestRoot.found) {
  24099. t = lowestRoot.root;
  24100. found = true;
  24101. this._collisionPoint.copyFrom(p1);
  24102. }
  24103. this._basePoint.subtractToRef(p2, this._tempVector);
  24104. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  24105. c = this._tempVector.lengthSquared() - 1.0;
  24106. lowestRoot = getLowestRoot(a, b, c, t);
  24107. if (lowestRoot.found) {
  24108. t = lowestRoot.root;
  24109. found = true;
  24110. this._collisionPoint.copyFrom(p2);
  24111. }
  24112. this._basePoint.subtractToRef(p3, this._tempVector);
  24113. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  24114. c = this._tempVector.lengthSquared() - 1.0;
  24115. lowestRoot = getLowestRoot(a, b, c, t);
  24116. if (lowestRoot.found) {
  24117. t = lowestRoot.root;
  24118. found = true;
  24119. this._collisionPoint.copyFrom(p3);
  24120. }
  24121. p2.subtractToRef(p1, this._edge);
  24122. p1.subtractToRef(this._basePoint, this._baseToVertex);
  24123. var edgeSquaredLength = this._edge.lengthSquared();
  24124. var edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  24125. var edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  24126. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  24127. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  24128. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  24129. lowestRoot = getLowestRoot(a, b, c, t);
  24130. if (lowestRoot.found) {
  24131. var f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  24132. if (f >= 0.0 && f <= 1.0) {
  24133. t = lowestRoot.root;
  24134. found = true;
  24135. this._edge.scaleInPlace(f);
  24136. p1.addToRef(this._edge, this._collisionPoint);
  24137. }
  24138. }
  24139. p3.subtractToRef(p2, this._edge);
  24140. p2.subtractToRef(this._basePoint, this._baseToVertex);
  24141. edgeSquaredLength = this._edge.lengthSquared();
  24142. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  24143. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  24144. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  24145. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  24146. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  24147. lowestRoot = getLowestRoot(a, b, c, t);
  24148. if (lowestRoot.found) {
  24149. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  24150. if (f >= 0.0 && f <= 1.0) {
  24151. t = lowestRoot.root;
  24152. found = true;
  24153. this._edge.scaleInPlace(f);
  24154. p2.addToRef(this._edge, this._collisionPoint);
  24155. }
  24156. }
  24157. p1.subtractToRef(p3, this._edge);
  24158. p3.subtractToRef(this._basePoint, this._baseToVertex);
  24159. edgeSquaredLength = this._edge.lengthSquared();
  24160. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  24161. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  24162. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  24163. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  24164. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  24165. lowestRoot = getLowestRoot(a, b, c, t);
  24166. if (lowestRoot.found) {
  24167. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  24168. if (f >= 0.0 && f <= 1.0) {
  24169. t = lowestRoot.root;
  24170. found = true;
  24171. this._edge.scaleInPlace(f);
  24172. p3.addToRef(this._edge, this._collisionPoint);
  24173. }
  24174. }
  24175. }
  24176. if (found) {
  24177. var distToCollision = t * this._velocity.length();
  24178. if (!this.collisionFound || distToCollision < this._nearestDistance) {
  24179. if (!this.intersectionPoint) {
  24180. this.intersectionPoint = this._collisionPoint.clone();
  24181. }
  24182. else {
  24183. this.intersectionPoint.copyFrom(this._collisionPoint);
  24184. }
  24185. this._nearestDistance = distToCollision;
  24186. this.collisionFound = true;
  24187. }
  24188. }
  24189. };
  24190. /** @hidden */
  24191. Collider.prototype._collide = function (trianglePlaneArray, pts, indices, indexStart, indexEnd, decal, hasMaterial) {
  24192. for (var i = indexStart; i < indexEnd; i += 3) {
  24193. var p1 = pts[indices[i] - decal];
  24194. var p2 = pts[indices[i + 1] - decal];
  24195. var p3 = pts[indices[i + 2] - decal];
  24196. this._testTriangle(i, trianglePlaneArray, p3, p2, p1, hasMaterial);
  24197. }
  24198. };
  24199. /** @hidden */
  24200. Collider.prototype._getResponse = function (pos, vel) {
  24201. pos.addToRef(vel, this._destinationPoint);
  24202. vel.scaleInPlace((this._nearestDistance / vel.length()));
  24203. this._basePoint.addToRef(vel, pos);
  24204. pos.subtractToRef(this.intersectionPoint, this._slidePlaneNormal);
  24205. this._slidePlaneNormal.normalize();
  24206. this._slidePlaneNormal.scaleToRef(this._epsilon, this._displacementVector);
  24207. pos.addInPlace(this._displacementVector);
  24208. this.intersectionPoint.addInPlace(this._displacementVector);
  24209. this._slidePlaneNormal.scaleInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"].SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint, this._slidePlaneNormal, this._destinationPoint));
  24210. this._destinationPoint.subtractInPlace(this._slidePlaneNormal);
  24211. this._destinationPoint.subtractToRef(this.intersectionPoint, vel);
  24212. };
  24213. return Collider;
  24214. }());
  24215. /***/ }),
  24216. /***/ "./Collisions/collisionCoordinator.ts":
  24217. /*!********************************************!*\
  24218. !*** ./Collisions/collisionCoordinator.ts ***!
  24219. \********************************************/
  24220. /*! exports provided: DefaultCollisionCoordinator */
  24221. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24222. "use strict";
  24223. __webpack_require__.r(__webpack_exports__);
  24224. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return DefaultCollisionCoordinator; });
  24225. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  24226. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24227. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  24228. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  24229. /** @hidden */
  24230. var DefaultCollisionCoordinator = /** @class */ (function () {
  24231. function DefaultCollisionCoordinator() {
  24232. this._scaledPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24233. this._scaledVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24234. this._finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24235. }
  24236. DefaultCollisionCoordinator.prototype.getNewPosition = function (position, displacement, collider, maximumRetry, excludedMesh, onNewPosition, collisionIndex) {
  24237. position.divideToRef(collider._radius, this._scaledPosition);
  24238. displacement.divideToRef(collider._radius, this._scaledVelocity);
  24239. collider.collidedMesh = null;
  24240. collider._retry = 0;
  24241. collider._initialVelocity = this._scaledVelocity;
  24242. collider._initialPosition = this._scaledPosition;
  24243. this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, this._finalPosition, excludedMesh);
  24244. this._finalPosition.multiplyInPlace(collider._radius);
  24245. //run the callback
  24246. onNewPosition(collisionIndex, this._finalPosition, collider.collidedMesh);
  24247. };
  24248. DefaultCollisionCoordinator.prototype.createCollider = function () {
  24249. return new _collider__WEBPACK_IMPORTED_MODULE_3__["Collider"]();
  24250. };
  24251. DefaultCollisionCoordinator.prototype.init = function (scene) {
  24252. this._scene = scene;
  24253. };
  24254. DefaultCollisionCoordinator.prototype._collideWithWorld = function (position, velocity, collider, maximumRetry, finalPosition, excludedMesh) {
  24255. if (excludedMesh === void 0) { excludedMesh = null; }
  24256. var closeDistance = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].CollisionsEpsilon * 10.0;
  24257. if (collider._retry >= maximumRetry) {
  24258. finalPosition.copyFrom(position);
  24259. return;
  24260. }
  24261. // Check if this is a mesh else camera or -1
  24262. var collisionMask = (excludedMesh ? excludedMesh.collisionMask : collider.collisionMask);
  24263. collider._initialize(position, velocity, closeDistance);
  24264. // Check all meshes
  24265. for (var index = 0; index < this._scene.meshes.length; index++) {
  24266. var mesh = this._scene.meshes[index];
  24267. if (mesh.isEnabled() && mesh.checkCollisions && mesh.subMeshes && mesh !== excludedMesh && ((collisionMask & mesh.collisionGroup) !== 0)) {
  24268. mesh._checkCollision(collider);
  24269. }
  24270. }
  24271. if (!collider.collisionFound) {
  24272. position.addToRef(velocity, finalPosition);
  24273. return;
  24274. }
  24275. if (velocity.x !== 0 || velocity.y !== 0 || velocity.z !== 0) {
  24276. collider._getResponse(position, velocity);
  24277. }
  24278. if (velocity.length() <= closeDistance) {
  24279. finalPosition.copyFrom(position);
  24280. return;
  24281. }
  24282. collider._retry++;
  24283. this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh);
  24284. };
  24285. return DefaultCollisionCoordinator;
  24286. }());
  24287. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].CollisionCoordinatorFactory = function () {
  24288. return new DefaultCollisionCoordinator();
  24289. };
  24290. /***/ }),
  24291. /***/ "./Collisions/index.ts":
  24292. /*!*****************************!*\
  24293. !*** ./Collisions/index.ts ***!
  24294. \*****************************/
  24295. /*! exports provided: Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo */
  24296. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24297. "use strict";
  24298. __webpack_require__.r(__webpack_exports__);
  24299. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  24300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _collider__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  24301. /* harmony import */ var _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./collisionCoordinator */ "./Collisions/collisionCoordinator.ts");
  24302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__["DefaultCollisionCoordinator"]; });
  24303. /* harmony import */ var _pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pickingInfo */ "./Collisions/pickingInfo.ts");
  24304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]; });
  24305. /* harmony import */ var _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./intersectionInfo */ "./Collisions/intersectionInfo.ts");
  24306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"]; });
  24307. /***/ }),
  24308. /***/ "./Collisions/intersectionInfo.ts":
  24309. /*!****************************************!*\
  24310. !*** ./Collisions/intersectionInfo.ts ***!
  24311. \****************************************/
  24312. /*! exports provided: IntersectionInfo */
  24313. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24314. "use strict";
  24315. __webpack_require__.r(__webpack_exports__);
  24316. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return IntersectionInfo; });
  24317. /**
  24318. * @hidden
  24319. */
  24320. var IntersectionInfo = /** @class */ (function () {
  24321. function IntersectionInfo(bu, bv, distance) {
  24322. this.bu = bu;
  24323. this.bv = bv;
  24324. this.distance = distance;
  24325. this.faceId = 0;
  24326. this.subMeshId = 0;
  24327. }
  24328. return IntersectionInfo;
  24329. }());
  24330. /***/ }),
  24331. /***/ "./Collisions/pickingInfo.ts":
  24332. /*!***********************************!*\
  24333. !*** ./Collisions/pickingInfo.ts ***!
  24334. \***********************************/
  24335. /*! exports provided: PickingInfo */
  24336. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24337. "use strict";
  24338. __webpack_require__.r(__webpack_exports__);
  24339. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return PickingInfo; });
  24340. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24341. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  24342. /**
  24343. * Information about the result of picking within a scene
  24344. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24345. */
  24346. var PickingInfo = /** @class */ (function () {
  24347. function PickingInfo() {
  24348. /** @hidden */
  24349. this._pickingUnavailable = false;
  24350. /**
  24351. * If the pick collided with an object
  24352. */
  24353. this.hit = false;
  24354. /**
  24355. * Distance away where the pick collided
  24356. */
  24357. this.distance = 0;
  24358. /**
  24359. * The location of pick collision
  24360. */
  24361. this.pickedPoint = null;
  24362. /**
  24363. * The mesh corresponding the the pick collision
  24364. */
  24365. this.pickedMesh = null;
  24366. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  24367. this.bu = 0;
  24368. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  24369. this.bv = 0;
  24370. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24371. this.faceId = -1;
  24372. /** Id of the the submesh that was picked */
  24373. this.subMeshId = 0;
  24374. /** If a sprite was picked, this will be the sprite the pick collided with */
  24375. this.pickedSprite = null;
  24376. /**
  24377. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24378. */
  24379. this.originMesh = null;
  24380. /**
  24381. * The ray that was used to perform the picking.
  24382. */
  24383. this.ray = null;
  24384. }
  24385. /**
  24386. * Gets the normal correspodning to the face the pick collided with
  24387. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24388. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24389. * @returns The normal correspodning to the face the pick collided with
  24390. */
  24391. PickingInfo.prototype.getNormal = function (useWorldCoordinates, useVerticesNormals) {
  24392. if (useWorldCoordinates === void 0) { useWorldCoordinates = false; }
  24393. if (useVerticesNormals === void 0) { useVerticesNormals = true; }
  24394. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  24395. return null;
  24396. }
  24397. var indices = this.pickedMesh.getIndices();
  24398. if (!indices) {
  24399. return null;
  24400. }
  24401. var result;
  24402. if (useVerticesNormals) {
  24403. var normals = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  24404. var normal0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3] * 3);
  24405. var normal1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 1] * 3);
  24406. var normal2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 2] * 3);
  24407. normal0 = normal0.scale(this.bu);
  24408. normal1 = normal1.scale(this.bv);
  24409. normal2 = normal2.scale(1.0 - this.bu - this.bv);
  24410. 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);
  24411. }
  24412. else {
  24413. var positions = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  24414. var vertex1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3] * 3);
  24415. var vertex2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 1] * 3);
  24416. var vertex3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 2] * 3);
  24417. var p1p2 = vertex1.subtract(vertex2);
  24418. var p3p2 = vertex3.subtract(vertex2);
  24419. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(p1p2, p3p2);
  24420. }
  24421. if (useWorldCoordinates) {
  24422. var wm = this.pickedMesh.getWorldMatrix();
  24423. if (this.pickedMesh.nonUniformScaling) {
  24424. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0].copyFrom(wm);
  24425. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  24426. wm.setTranslationFromFloats(0, 0, 0);
  24427. wm.invert();
  24428. wm.transposeToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1]);
  24429. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  24430. }
  24431. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result, wm);
  24432. }
  24433. result.normalize();
  24434. return result;
  24435. };
  24436. /**
  24437. * Gets the texture coordinates of where the pick occured
  24438. * @returns the vector containing the coordnates of the texture
  24439. */
  24440. PickingInfo.prototype.getTextureCoordinates = function () {
  24441. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  24442. return null;
  24443. }
  24444. var indices = this.pickedMesh.getIndices();
  24445. if (!indices) {
  24446. return null;
  24447. }
  24448. var uvs = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  24449. if (!uvs) {
  24450. return null;
  24451. }
  24452. var uv0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3] * 2);
  24453. var uv1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 1] * 2);
  24454. var uv2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 2] * 2);
  24455. uv0 = uv0.scale(1.0 - this.bu - this.bv);
  24456. uv1 = uv1.scale(this.bu);
  24457. uv2 = uv2.scale(this.bv);
  24458. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);
  24459. };
  24460. return PickingInfo;
  24461. }());
  24462. /***/ }),
  24463. /***/ "./Culling/Octrees/index.ts":
  24464. /*!**********************************!*\
  24465. !*** ./Culling/Octrees/index.ts ***!
  24466. \**********************************/
  24467. /*! exports provided: Octree, OctreeBlock, OctreeSceneComponent */
  24468. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24469. "use strict";
  24470. __webpack_require__.r(__webpack_exports__);
  24471. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  24472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _octree__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  24473. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  24474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]; });
  24475. /* harmony import */ var _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./octreeSceneComponent */ "./Culling/Octrees/octreeSceneComponent.ts");
  24476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__["OctreeSceneComponent"]; });
  24477. /***/ }),
  24478. /***/ "./Culling/Octrees/octree.ts":
  24479. /*!***********************************!*\
  24480. !*** ./Culling/Octrees/octree.ts ***!
  24481. \***********************************/
  24482. /*! exports provided: Octree */
  24483. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24484. "use strict";
  24485. __webpack_require__.r(__webpack_exports__);
  24486. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return Octree; });
  24487. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  24488. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  24489. /**
  24490. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  24491. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24492. */
  24493. var Octree = /** @class */ (function () {
  24494. /**
  24495. * Creates a octree
  24496. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24497. * @param creationFunc function to be used to instatiate the octree
  24498. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  24499. * @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.)
  24500. */
  24501. function Octree(creationFunc, maxBlockCapacity,
  24502. /** 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.) */
  24503. maxDepth) {
  24504. if (maxDepth === void 0) { maxDepth = 2; }
  24505. this.maxDepth = maxDepth;
  24506. /**
  24507. * Content stored in the octree
  24508. */
  24509. this.dynamicContent = new Array();
  24510. this._maxBlockCapacity = maxBlockCapacity || 64;
  24511. this._selectionContent = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"](1024);
  24512. this._creationFunc = creationFunc;
  24513. }
  24514. // Methods
  24515. /**
  24516. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  24517. * @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);
  24518. * @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);
  24519. * @param entries meshes to be added to the octree blocks
  24520. */
  24521. Octree.prototype.update = function (worldMin, worldMax, entries) {
  24522. _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]._CreateBlocks(worldMin, worldMax, entries, this._maxBlockCapacity, 0, this.maxDepth, this, this._creationFunc);
  24523. };
  24524. /**
  24525. * Adds a mesh to the octree
  24526. * @param entry Mesh to add to the octree
  24527. */
  24528. Octree.prototype.addMesh = function (entry) {
  24529. for (var index = 0; index < this.blocks.length; index++) {
  24530. var block = this.blocks[index];
  24531. block.addEntry(entry);
  24532. }
  24533. };
  24534. /**
  24535. * Remove an element from the octree
  24536. * @param entry defines the element to remove
  24537. */
  24538. Octree.prototype.removeMesh = function (entry) {
  24539. for (var index = 0; index < this.blocks.length; index++) {
  24540. var block = this.blocks[index];
  24541. block.removeEntry(entry);
  24542. }
  24543. };
  24544. /**
  24545. * Selects an array of meshes within the frustum
  24546. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  24547. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  24548. * @returns array of meshes within the frustum
  24549. */
  24550. Octree.prototype.select = function (frustumPlanes, allowDuplicate) {
  24551. this._selectionContent.reset();
  24552. for (var index = 0; index < this.blocks.length; index++) {
  24553. var block = this.blocks[index];
  24554. block.select(frustumPlanes, this._selectionContent, allowDuplicate);
  24555. }
  24556. if (allowDuplicate) {
  24557. this._selectionContent.concat(this.dynamicContent);
  24558. }
  24559. else {
  24560. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  24561. }
  24562. return this._selectionContent;
  24563. };
  24564. /**
  24565. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  24566. * @param sphereCenter defines the bounding sphere center
  24567. * @param sphereRadius defines the bounding sphere radius
  24568. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24569. * @returns an array of objects that intersect the sphere
  24570. */
  24571. Octree.prototype.intersects = function (sphereCenter, sphereRadius, allowDuplicate) {
  24572. this._selectionContent.reset();
  24573. for (var index = 0; index < this.blocks.length; index++) {
  24574. var block = this.blocks[index];
  24575. block.intersects(sphereCenter, sphereRadius, this._selectionContent, allowDuplicate);
  24576. }
  24577. if (allowDuplicate) {
  24578. this._selectionContent.concat(this.dynamicContent);
  24579. }
  24580. else {
  24581. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  24582. }
  24583. return this._selectionContent;
  24584. };
  24585. /**
  24586. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  24587. * @param ray defines the ray to test with
  24588. * @returns array of intersected objects
  24589. */
  24590. Octree.prototype.intersectsRay = function (ray) {
  24591. this._selectionContent.reset();
  24592. for (var index = 0; index < this.blocks.length; index++) {
  24593. var block = this.blocks[index];
  24594. block.intersectsRay(ray, this._selectionContent);
  24595. }
  24596. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  24597. return this._selectionContent;
  24598. };
  24599. /**
  24600. * Adds a mesh into the octree block if it intersects the block
  24601. */
  24602. Octree.CreationFuncForMeshes = function (entry, block) {
  24603. var boundingInfo = entry.getBoundingInfo();
  24604. if (!entry.isBlocked && boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  24605. block.entries.push(entry);
  24606. }
  24607. };
  24608. /**
  24609. * Adds a submesh into the octree block if it intersects the block
  24610. */
  24611. Octree.CreationFuncForSubMeshes = function (entry, block) {
  24612. var boundingInfo = entry.getBoundingInfo();
  24613. if (boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  24614. block.entries.push(entry);
  24615. }
  24616. };
  24617. return Octree;
  24618. }());
  24619. /***/ }),
  24620. /***/ "./Culling/Octrees/octreeBlock.ts":
  24621. /*!****************************************!*\
  24622. !*** ./Culling/Octrees/octreeBlock.ts ***!
  24623. \****************************************/
  24624. /*! exports provided: OctreeBlock */
  24625. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24626. "use strict";
  24627. __webpack_require__.r(__webpack_exports__);
  24628. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return OctreeBlock; });
  24629. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  24630. /* harmony import */ var _Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Culling/boundingBox */ "./Culling/boundingBox.ts");
  24631. /**
  24632. * Class used to store a cell in an octree
  24633. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24634. */
  24635. var OctreeBlock = /** @class */ (function () {
  24636. /**
  24637. * Creates a new block
  24638. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  24639. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  24640. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24641. * @param depth defines the current depth of this block in the octree
  24642. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  24643. * @param creationFunc defines a callback to call when an element is added to the block
  24644. */
  24645. function OctreeBlock(minPoint, maxPoint, capacity, depth, maxDepth, creationFunc) {
  24646. /**
  24647. * Gets the content of the current block
  24648. */
  24649. this.entries = new Array();
  24650. this._boundingVectors = new Array();
  24651. this._capacity = capacity;
  24652. this._depth = depth;
  24653. this._maxDepth = maxDepth;
  24654. this._creationFunc = creationFunc;
  24655. this._minPoint = minPoint;
  24656. this._maxPoint = maxPoint;
  24657. this._boundingVectors.push(minPoint.clone());
  24658. this._boundingVectors.push(maxPoint.clone());
  24659. this._boundingVectors.push(minPoint.clone());
  24660. this._boundingVectors[2].x = maxPoint.x;
  24661. this._boundingVectors.push(minPoint.clone());
  24662. this._boundingVectors[3].y = maxPoint.y;
  24663. this._boundingVectors.push(minPoint.clone());
  24664. this._boundingVectors[4].z = maxPoint.z;
  24665. this._boundingVectors.push(maxPoint.clone());
  24666. this._boundingVectors[5].z = minPoint.z;
  24667. this._boundingVectors.push(maxPoint.clone());
  24668. this._boundingVectors[6].x = minPoint.x;
  24669. this._boundingVectors.push(maxPoint.clone());
  24670. this._boundingVectors[7].y = minPoint.y;
  24671. }
  24672. Object.defineProperty(OctreeBlock.prototype, "capacity", {
  24673. // Property
  24674. /**
  24675. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24676. */
  24677. get: function () {
  24678. return this._capacity;
  24679. },
  24680. enumerable: true,
  24681. configurable: true
  24682. });
  24683. Object.defineProperty(OctreeBlock.prototype, "minPoint", {
  24684. /**
  24685. * Gets the minimum vector (in world space) of the block's bounding box
  24686. */
  24687. get: function () {
  24688. return this._minPoint;
  24689. },
  24690. enumerable: true,
  24691. configurable: true
  24692. });
  24693. Object.defineProperty(OctreeBlock.prototype, "maxPoint", {
  24694. /**
  24695. * Gets the maximum vector (in world space) of the block's bounding box
  24696. */
  24697. get: function () {
  24698. return this._maxPoint;
  24699. },
  24700. enumerable: true,
  24701. configurable: true
  24702. });
  24703. // Methods
  24704. /**
  24705. * Add a new element to this block
  24706. * @param entry defines the element to add
  24707. */
  24708. OctreeBlock.prototype.addEntry = function (entry) {
  24709. if (this.blocks) {
  24710. for (var index = 0; index < this.blocks.length; index++) {
  24711. var block = this.blocks[index];
  24712. block.addEntry(entry);
  24713. }
  24714. return;
  24715. }
  24716. this._creationFunc(entry, this);
  24717. if (this.entries.length > this.capacity && this._depth < this._maxDepth) {
  24718. this.createInnerBlocks();
  24719. }
  24720. };
  24721. /**
  24722. * Remove an element from this block
  24723. * @param entry defines the element to remove
  24724. */
  24725. OctreeBlock.prototype.removeEntry = function (entry) {
  24726. if (this.blocks) {
  24727. for (var index = 0; index < this.blocks.length; index++) {
  24728. var block = this.blocks[index];
  24729. block.removeEntry(entry);
  24730. }
  24731. return;
  24732. }
  24733. var entryIndex = this.entries.indexOf(entry);
  24734. if (entryIndex > -1) {
  24735. this.entries.splice(entryIndex, 1);
  24736. }
  24737. };
  24738. /**
  24739. * Add an array of elements to this block
  24740. * @param entries defines the array of elements to add
  24741. */
  24742. OctreeBlock.prototype.addEntries = function (entries) {
  24743. for (var index = 0; index < entries.length; index++) {
  24744. var mesh = entries[index];
  24745. this.addEntry(mesh);
  24746. }
  24747. };
  24748. /**
  24749. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  24750. * @param frustumPlanes defines the frustum planes to test
  24751. * @param selection defines the array to store current content if selection is positive
  24752. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24753. */
  24754. OctreeBlock.prototype.select = function (frustumPlanes, selection, allowDuplicate) {
  24755. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IsInFrustum(this._boundingVectors, frustumPlanes)) {
  24756. if (this.blocks) {
  24757. for (var index = 0; index < this.blocks.length; index++) {
  24758. var block = this.blocks[index];
  24759. block.select(frustumPlanes, selection, allowDuplicate);
  24760. }
  24761. return;
  24762. }
  24763. if (allowDuplicate) {
  24764. selection.concat(this.entries);
  24765. }
  24766. else {
  24767. selection.concatWithNoDuplicate(this.entries);
  24768. }
  24769. }
  24770. };
  24771. /**
  24772. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  24773. * @param sphereCenter defines the bounding sphere center
  24774. * @param sphereRadius defines the bounding sphere radius
  24775. * @param selection defines the array to store current content if selection is positive
  24776. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24777. */
  24778. OctreeBlock.prototype.intersects = function (sphereCenter, sphereRadius, selection, allowDuplicate) {
  24779. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IntersectsSphere(this._minPoint, this._maxPoint, sphereCenter, sphereRadius)) {
  24780. if (this.blocks) {
  24781. for (var index = 0; index < this.blocks.length; index++) {
  24782. var block = this.blocks[index];
  24783. block.intersects(sphereCenter, sphereRadius, selection, allowDuplicate);
  24784. }
  24785. return;
  24786. }
  24787. if (allowDuplicate) {
  24788. selection.concat(this.entries);
  24789. }
  24790. else {
  24791. selection.concatWithNoDuplicate(this.entries);
  24792. }
  24793. }
  24794. };
  24795. /**
  24796. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  24797. * @param ray defines the ray to test with
  24798. * @param selection defines the array to store current content if selection is positive
  24799. */
  24800. OctreeBlock.prototype.intersectsRay = function (ray, selection) {
  24801. if (ray.intersectsBoxMinMax(this._minPoint, this._maxPoint)) {
  24802. if (this.blocks) {
  24803. for (var index = 0; index < this.blocks.length; index++) {
  24804. var block = this.blocks[index];
  24805. block.intersectsRay(ray, selection);
  24806. }
  24807. return;
  24808. }
  24809. selection.concatWithNoDuplicate(this.entries);
  24810. }
  24811. };
  24812. /**
  24813. * Subdivide the content into child blocks (this block will then be empty)
  24814. */
  24815. OctreeBlock.prototype.createInnerBlocks = function () {
  24816. OctreeBlock._CreateBlocks(this._minPoint, this._maxPoint, this.entries, this._capacity, this._depth, this._maxDepth, this, this._creationFunc);
  24817. };
  24818. /**
  24819. * @hidden
  24820. */
  24821. OctreeBlock._CreateBlocks = function (worldMin, worldMax, entries, maxBlockCapacity, currentDepth, maxDepth, target, creationFunc) {
  24822. target.blocks = new Array();
  24823. 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);
  24824. // Segmenting space
  24825. for (var x = 0; x < 2; x++) {
  24826. for (var y = 0; y < 2; y++) {
  24827. for (var z = 0; z < 2; z++) {
  24828. var localMin = worldMin.add(blockSize.multiplyByFloats(x, y, z));
  24829. var localMax = worldMin.add(blockSize.multiplyByFloats(x + 1, y + 1, z + 1));
  24830. var block = new OctreeBlock(localMin, localMax, maxBlockCapacity, currentDepth + 1, maxDepth, creationFunc);
  24831. block.addEntries(entries);
  24832. target.blocks.push(block);
  24833. }
  24834. }
  24835. }
  24836. };
  24837. return OctreeBlock;
  24838. }());
  24839. /***/ }),
  24840. /***/ "./Culling/Octrees/octreeSceneComponent.ts":
  24841. /*!*************************************************!*\
  24842. !*** ./Culling/Octrees/octreeSceneComponent.ts ***!
  24843. \*************************************************/
  24844. /*! exports provided: OctreeSceneComponent */
  24845. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24846. "use strict";
  24847. __webpack_require__.r(__webpack_exports__);
  24848. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return OctreeSceneComponent; });
  24849. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  24850. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  24851. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  24852. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  24853. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  24854. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  24855. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.createOrUpdateSelectionOctree = function (maxCapacity, maxDepth) {
  24856. if (maxCapacity === void 0) { maxCapacity = 64; }
  24857. if (maxDepth === void 0) { maxDepth = 2; }
  24858. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24859. if (!component) {
  24860. component = new OctreeSceneComponent(this);
  24861. this._addComponent(component);
  24862. }
  24863. if (!this._selectionOctree) {
  24864. this._selectionOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForMeshes, maxCapacity, maxDepth);
  24865. }
  24866. var worldExtends = this.getWorldExtends();
  24867. // Update octree
  24868. this._selectionOctree.update(worldExtends.min, worldExtends.max, this.meshes);
  24869. return this._selectionOctree;
  24870. };
  24871. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "selectionOctree", {
  24872. get: function () {
  24873. return this._selectionOctree;
  24874. },
  24875. enumerable: true,
  24876. configurable: true
  24877. });
  24878. /**
  24879. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  24880. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  24881. * @param maxCapacity defines the maximum size of each block (64 by default)
  24882. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  24883. * @returns the new octree
  24884. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  24885. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24886. */
  24887. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.createOrUpdateSubmeshesOctree = function (maxCapacity, maxDepth) {
  24888. if (maxCapacity === void 0) { maxCapacity = 64; }
  24889. if (maxDepth === void 0) { maxDepth = 2; }
  24890. var scene = this.getScene();
  24891. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24892. if (!component) {
  24893. component = new OctreeSceneComponent(scene);
  24894. scene._addComponent(component);
  24895. }
  24896. if (!this._submeshesOctree) {
  24897. this._submeshesOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForSubMeshes, maxCapacity, maxDepth);
  24898. }
  24899. this.computeWorldMatrix(true);
  24900. var boundingInfo = this.getBoundingInfo();
  24901. // Update octree
  24902. var bbox = boundingInfo.boundingBox;
  24903. this._submeshesOctree.update(bbox.minimumWorld, bbox.maximumWorld, this.subMeshes);
  24904. return this._submeshesOctree;
  24905. };
  24906. /**
  24907. * Defines the octree scene component responsible to manage any octrees
  24908. * in a given scene.
  24909. */
  24910. var OctreeSceneComponent = /** @class */ (function () {
  24911. /**
  24912. * Creates a new instance of the component for the given scene
  24913. * @param scene Defines the scene to register the component in
  24914. */
  24915. function OctreeSceneComponent(scene) {
  24916. /**
  24917. * The component name helpfull to identify the component in the list of scene components.
  24918. */
  24919. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE;
  24920. /**
  24921. * Indicates if the meshes have been checked to make sure they are isEnabled()
  24922. */
  24923. this.checksIsEnabled = true;
  24924. 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));
  24925. this.scene = scene;
  24926. this.scene.getActiveMeshCandidates = this.getActiveMeshCandidates.bind(this);
  24927. this.scene.getActiveSubMeshCandidates = this.getActiveSubMeshCandidates.bind(this);
  24928. this.scene.getCollidingSubMeshCandidates = this.getCollidingSubMeshCandidates.bind(this);
  24929. this.scene.getIntersectingSubMeshCandidates = this.getIntersectingSubMeshCandidates.bind(this);
  24930. }
  24931. /**
  24932. * Registers the component in a given scene
  24933. */
  24934. OctreeSceneComponent.prototype.register = function () {
  24935. var _this = this;
  24936. this.scene.onMeshRemovedObservable.add(function (mesh) {
  24937. var sceneOctree = _this.scene.selectionOctree;
  24938. if (sceneOctree !== undefined && sceneOctree !== null) {
  24939. var index = sceneOctree.dynamicContent.indexOf(mesh);
  24940. if (index !== -1) {
  24941. sceneOctree.dynamicContent.splice(index, 1);
  24942. }
  24943. }
  24944. });
  24945. this.scene.onMeshImportedObservable.add(function (mesh) {
  24946. var sceneOctree = _this.scene.selectionOctree;
  24947. if (sceneOctree !== undefined && sceneOctree !== null) {
  24948. sceneOctree.addMesh(mesh);
  24949. }
  24950. });
  24951. };
  24952. /**
  24953. * Return the list of active meshes
  24954. * @returns the list of active meshes
  24955. */
  24956. OctreeSceneComponent.prototype.getActiveMeshCandidates = function () {
  24957. if (this.scene._selectionOctree) {
  24958. var selection = this.scene._selectionOctree.select(this.scene.frustumPlanes);
  24959. return selection;
  24960. }
  24961. return this.scene._getDefaultMeshCandidates();
  24962. };
  24963. /**
  24964. * Return the list of active sub meshes
  24965. * @param mesh The mesh to get the candidates sub meshes from
  24966. * @returns the list of active sub meshes
  24967. */
  24968. OctreeSceneComponent.prototype.getActiveSubMeshCandidates = function (mesh) {
  24969. if (mesh._submeshesOctree && mesh.useOctreeForRenderingSelection) {
  24970. var intersections = mesh._submeshesOctree.select(this.scene.frustumPlanes);
  24971. return intersections;
  24972. }
  24973. return this.scene._getDefaultSubMeshCandidates(mesh);
  24974. };
  24975. /**
  24976. * Return the list of sub meshes intersecting with a given local ray
  24977. * @param mesh defines the mesh to find the submesh for
  24978. * @param localRay defines the ray in local space
  24979. * @returns the list of intersecting sub meshes
  24980. */
  24981. OctreeSceneComponent.prototype.getIntersectingSubMeshCandidates = function (mesh, localRay) {
  24982. if (mesh._submeshesOctree && mesh.useOctreeForPicking) {
  24983. _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"].TransformToRef(localRay, mesh.getWorldMatrix(), this._tempRay);
  24984. var intersections = mesh._submeshesOctree.intersectsRay(this._tempRay);
  24985. return intersections;
  24986. }
  24987. return this.scene._getDefaultSubMeshCandidates(mesh);
  24988. };
  24989. /**
  24990. * Return the list of sub meshes colliding with a collider
  24991. * @param mesh defines the mesh to find the submesh for
  24992. * @param collider defines the collider to evaluate the collision against
  24993. * @returns the list of colliding sub meshes
  24994. */
  24995. OctreeSceneComponent.prototype.getCollidingSubMeshCandidates = function (mesh, collider) {
  24996. if (mesh._submeshesOctree && mesh.useOctreeForCollisions) {
  24997. var radius = collider._velocityWorldLength + Math.max(collider._radius.x, collider._radius.y, collider._radius.z);
  24998. var intersections = mesh._submeshesOctree.intersects(collider._basePointWorld, radius);
  24999. return intersections;
  25000. }
  25001. return this.scene._getDefaultSubMeshCandidates(mesh);
  25002. };
  25003. /**
  25004. * Rebuilds the elements related to this component in case of
  25005. * context lost for instance.
  25006. */
  25007. OctreeSceneComponent.prototype.rebuild = function () {
  25008. // Nothing to do here.
  25009. };
  25010. /**
  25011. * Disposes the component and the associated ressources.
  25012. */
  25013. OctreeSceneComponent.prototype.dispose = function () {
  25014. // Nothing to do here.
  25015. };
  25016. return OctreeSceneComponent;
  25017. }());
  25018. /***/ }),
  25019. /***/ "./Culling/boundingBox.ts":
  25020. /*!********************************!*\
  25021. !*** ./Culling/boundingBox.ts ***!
  25022. \********************************/
  25023. /*! exports provided: BoundingBox */
  25024. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25025. "use strict";
  25026. __webpack_require__.r(__webpack_exports__);
  25027. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return BoundingBox; });
  25028. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25029. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25030. /**
  25031. * Class used to store bounding box information
  25032. */
  25033. var BoundingBox = /** @class */ (function () {
  25034. /**
  25035. * Creates a new bounding box
  25036. * @param min defines the minimum vector (in local space)
  25037. * @param max defines the maximum vector (in local space)
  25038. * @param worldMatrix defines the new world matrix
  25039. */
  25040. function BoundingBox(min, max, worldMatrix) {
  25041. /**
  25042. * Gets the 8 vectors representing the bounding box in local space
  25043. */
  25044. this.vectors = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25045. /**
  25046. * Gets the center of the bounding box in local space
  25047. */
  25048. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25049. /**
  25050. * Gets the center of the bounding box in world space
  25051. */
  25052. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25053. /**
  25054. * Gets the extend size in local space
  25055. */
  25056. this.extendSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25057. /**
  25058. * Gets the extend size in world space
  25059. */
  25060. this.extendSizeWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25061. /**
  25062. * Gets the OBB (object bounding box) directions
  25063. */
  25064. this.directions = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25065. /**
  25066. * Gets the 8 vectors representing the bounding box in world space
  25067. */
  25068. this.vectorsWorld = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25069. /**
  25070. * Gets the minimum vector in world space
  25071. */
  25072. this.minimumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25073. /**
  25074. * Gets the maximum vector in world space
  25075. */
  25076. this.maximumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25077. /**
  25078. * Gets the minimum vector in local space
  25079. */
  25080. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25081. /**
  25082. * Gets the maximum vector in local space
  25083. */
  25084. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25085. this.reConstruct(min, max, worldMatrix);
  25086. }
  25087. // Methods
  25088. /**
  25089. * Recreates the entire bounding box from scratch as if we call the constructor in place
  25090. * @param min defines the new minimum vector (in local space)
  25091. * @param max defines the new maximum vector (in local space)
  25092. * @param worldMatrix defines the new world matrix
  25093. */
  25094. BoundingBox.prototype.reConstruct = function (min, max, worldMatrix) {
  25095. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  25096. var vectors = this.vectors;
  25097. this.minimum.copyFromFloats(minX, minY, minZ);
  25098. this.maximum.copyFromFloats(maxX, maxY, maxZ);
  25099. vectors[0].copyFromFloats(minX, minY, minZ);
  25100. vectors[1].copyFromFloats(maxX, maxY, maxZ);
  25101. vectors[2].copyFromFloats(maxX, minY, minZ);
  25102. vectors[3].copyFromFloats(minX, maxY, minZ);
  25103. vectors[4].copyFromFloats(minX, minY, maxZ);
  25104. vectors[5].copyFromFloats(maxX, maxY, minZ);
  25105. vectors[6].copyFromFloats(minX, maxY, maxZ);
  25106. vectors[7].copyFromFloats(maxX, minY, maxZ);
  25107. // OBB
  25108. max.addToRef(min, this.center).scaleInPlace(0.5);
  25109. max.subtractToRef(min, this.extendSize).scaleInPlace(0.5);
  25110. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  25111. };
  25112. /**
  25113. * Scale the current bounding box by applying a scale factor
  25114. * @param factor defines the scale factor to apply
  25115. * @returns the current bounding box
  25116. */
  25117. BoundingBox.prototype.scale = function (factor) {
  25118. var tmpVectors = BoundingBox.TmpVector3;
  25119. var diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);
  25120. var len = diff.length();
  25121. diff.normalizeFromLength(len);
  25122. var distance = len * factor;
  25123. var newRadius = diff.scaleInPlace(distance * 0.5);
  25124. var min = this.center.subtractToRef(newRadius, tmpVectors[1]);
  25125. var max = this.center.addToRef(newRadius, tmpVectors[2]);
  25126. this.reConstruct(min, max, this._worldMatrix);
  25127. return this;
  25128. };
  25129. /**
  25130. * Gets the world matrix of the bounding box
  25131. * @returns a matrix
  25132. */
  25133. BoundingBox.prototype.getWorldMatrix = function () {
  25134. return this._worldMatrix;
  25135. };
  25136. /** @hidden */
  25137. BoundingBox.prototype._update = function (world) {
  25138. var minWorld = this.minimumWorld;
  25139. var maxWorld = this.maximumWorld;
  25140. var directions = this.directions;
  25141. var vectorsWorld = this.vectorsWorld;
  25142. var vectors = this.vectors;
  25143. if (!world.isIdentity()) {
  25144. minWorld.setAll(Number.MAX_VALUE);
  25145. maxWorld.setAll(-Number.MAX_VALUE);
  25146. for (var index = 0; index < 8; ++index) {
  25147. var v = vectorsWorld[index];
  25148. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vectors[index], world, v);
  25149. minWorld.minimizeInPlace(v);
  25150. maxWorld.maximizeInPlace(v);
  25151. }
  25152. // Extend
  25153. maxWorld.subtractToRef(minWorld, this.extendSizeWorld).scaleInPlace(0.5);
  25154. maxWorld.addToRef(minWorld, this.centerWorld).scaleInPlace(0.5);
  25155. }
  25156. else {
  25157. minWorld.copyFrom(this.minimum);
  25158. maxWorld.copyFrom(this.maximum);
  25159. for (var index = 0; index < 8; ++index) {
  25160. vectorsWorld[index].copyFrom(vectors[index]);
  25161. }
  25162. // Extend
  25163. this.extendSizeWorld.copyFrom(this.extendSize);
  25164. this.centerWorld.copyFrom(this.center);
  25165. }
  25166. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 0, directions[0]);
  25167. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 4, directions[1]);
  25168. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 8, directions[2]);
  25169. this._worldMatrix = world;
  25170. };
  25171. /**
  25172. * Tests if the bounding box is intersecting the frustum planes
  25173. * @param frustumPlanes defines the frustum planes to test
  25174. * @returns true if there is an intersection
  25175. */
  25176. BoundingBox.prototype.isInFrustum = function (frustumPlanes) {
  25177. return BoundingBox.IsInFrustum(this.vectorsWorld, frustumPlanes);
  25178. };
  25179. /**
  25180. * Tests if the bounding box is entirely inside the frustum planes
  25181. * @param frustumPlanes defines the frustum planes to test
  25182. * @returns true if there is an inclusion
  25183. */
  25184. BoundingBox.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  25185. return BoundingBox.IsCompletelyInFrustum(this.vectorsWorld, frustumPlanes);
  25186. };
  25187. /**
  25188. * Tests if a point is inside the bounding box
  25189. * @param point defines the point to test
  25190. * @returns true if the point is inside the bounding box
  25191. */
  25192. BoundingBox.prototype.intersectsPoint = function (point) {
  25193. var min = this.minimumWorld;
  25194. var max = this.maximumWorld;
  25195. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  25196. var pointX = point.x, pointY = point.y, pointZ = point.z;
  25197. var delta = -_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"];
  25198. if (maxX - pointX < delta || delta > pointX - minX) {
  25199. return false;
  25200. }
  25201. if (maxY - pointY < delta || delta > pointY - minY) {
  25202. return false;
  25203. }
  25204. if (maxZ - pointZ < delta || delta > pointZ - minZ) {
  25205. return false;
  25206. }
  25207. return true;
  25208. };
  25209. /**
  25210. * Tests if the bounding box intersects with a bounding sphere
  25211. * @param sphere defines the sphere to test
  25212. * @returns true if there is an intersection
  25213. */
  25214. BoundingBox.prototype.intersectsSphere = function (sphere) {
  25215. return BoundingBox.IntersectsSphere(this.minimumWorld, this.maximumWorld, sphere.centerWorld, sphere.radiusWorld);
  25216. };
  25217. /**
  25218. * Tests if the bounding box intersects with a box defined by a min and max vectors
  25219. * @param min defines the min vector to use
  25220. * @param max defines the max vector to use
  25221. * @returns true if there is an intersection
  25222. */
  25223. BoundingBox.prototype.intersectsMinMax = function (min, max) {
  25224. var myMin = this.minimumWorld;
  25225. var myMax = this.maximumWorld;
  25226. var myMinX = myMin.x, myMinY = myMin.y, myMinZ = myMin.z, myMaxX = myMax.x, myMaxY = myMax.y, myMaxZ = myMax.z;
  25227. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  25228. if (myMaxX < minX || myMinX > maxX) {
  25229. return false;
  25230. }
  25231. if (myMaxY < minY || myMinY > maxY) {
  25232. return false;
  25233. }
  25234. if (myMaxZ < minZ || myMinZ > maxZ) {
  25235. return false;
  25236. }
  25237. return true;
  25238. };
  25239. // Statics
  25240. /**
  25241. * Tests if two bounding boxes are intersections
  25242. * @param box0 defines the first box to test
  25243. * @param box1 defines the second box to test
  25244. * @returns true if there is an intersection
  25245. */
  25246. BoundingBox.Intersects = function (box0, box1) {
  25247. return box0.intersectsMinMax(box1.minimumWorld, box1.maximumWorld);
  25248. };
  25249. /**
  25250. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  25251. * @param minPoint defines the minimum vector of the bounding box
  25252. * @param maxPoint defines the maximum vector of the bounding box
  25253. * @param sphereCenter defines the sphere center
  25254. * @param sphereRadius defines the sphere radius
  25255. * @returns true if there is an intersection
  25256. */
  25257. BoundingBox.IntersectsSphere = function (minPoint, maxPoint, sphereCenter, sphereRadius) {
  25258. var vector = BoundingBox.TmpVector3[0];
  25259. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ClampToRef(sphereCenter, minPoint, maxPoint, vector);
  25260. var num = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphereCenter, vector);
  25261. return (num <= (sphereRadius * sphereRadius));
  25262. };
  25263. /**
  25264. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  25265. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  25266. * @param frustumPlanes defines the frustum planes to test
  25267. * @return true if there is an inclusion
  25268. */
  25269. BoundingBox.IsCompletelyInFrustum = function (boundingVectors, frustumPlanes) {
  25270. for (var p = 0; p < 6; ++p) {
  25271. var frustumPlane = frustumPlanes[p];
  25272. for (var i = 0; i < 8; ++i) {
  25273. if (frustumPlane.dotCoordinate(boundingVectors[i]) < 0) {
  25274. return false;
  25275. }
  25276. }
  25277. }
  25278. return true;
  25279. };
  25280. /**
  25281. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  25282. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  25283. * @param frustumPlanes defines the frustum planes to test
  25284. * @return true if there is an intersection
  25285. */
  25286. BoundingBox.IsInFrustum = function (boundingVectors, frustumPlanes) {
  25287. for (var p = 0; p < 6; ++p) {
  25288. var canReturnFalse = true;
  25289. var frustumPlane = frustumPlanes[p];
  25290. for (var i = 0; i < 8; ++i) {
  25291. if (frustumPlane.dotCoordinate(boundingVectors[i]) >= 0) {
  25292. canReturnFalse = false;
  25293. break;
  25294. }
  25295. }
  25296. if (canReturnFalse) {
  25297. return false;
  25298. }
  25299. }
  25300. return true;
  25301. };
  25302. BoundingBox.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25303. return BoundingBox;
  25304. }());
  25305. /***/ }),
  25306. /***/ "./Culling/boundingInfo.ts":
  25307. /*!*********************************!*\
  25308. !*** ./Culling/boundingInfo.ts ***!
  25309. \*********************************/
  25310. /*! exports provided: BoundingInfo */
  25311. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25312. "use strict";
  25313. __webpack_require__.r(__webpack_exports__);
  25314. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return BoundingInfo; });
  25315. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25316. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25317. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  25318. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  25319. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  25320. var _result0 = { min: 0, max: 0 };
  25321. var _result1 = { min: 0, max: 0 };
  25322. var computeBoxExtents = function (axis, box, result) {
  25323. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.centerWorld, axis);
  25324. var r0 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[0], axis)) * box.extendSize.x;
  25325. var r1 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[1], axis)) * box.extendSize.y;
  25326. var r2 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[2], axis)) * box.extendSize.z;
  25327. var r = r0 + r1 + r2;
  25328. result.min = p - r;
  25329. result.max = p + r;
  25330. };
  25331. var axisOverlap = function (axis, box0, box1) {
  25332. computeBoxExtents(axis, box0, _result0);
  25333. computeBoxExtents(axis, box1, _result1);
  25334. return !(_result0.min > _result1.max || _result1.min > _result0.max);
  25335. };
  25336. /**
  25337. * Info for a bounding data of a mesh
  25338. */
  25339. var BoundingInfo = /** @class */ (function () {
  25340. /**
  25341. * Constructs bounding info
  25342. * @param minimum min vector of the bounding box/sphere
  25343. * @param maximum max vector of the bounding box/sphere
  25344. * @param worldMatrix defines the new world matrix
  25345. */
  25346. function BoundingInfo(minimum, maximum, worldMatrix) {
  25347. this._isLocked = false;
  25348. this.boundingBox = new _boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"](minimum, maximum, worldMatrix);
  25349. this.boundingSphere = new _boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"](minimum, maximum, worldMatrix);
  25350. }
  25351. /**
  25352. * Recreates the entire bounding info from scratch as if we call the constructor in place
  25353. * @param min defines the new minimum vector (in local space)
  25354. * @param max defines the new maximum vector (in local space)
  25355. * @param worldMatrix defines the new world matrix
  25356. */
  25357. BoundingInfo.prototype.reConstruct = function (min, max, worldMatrix) {
  25358. this.boundingBox.reConstruct(min, max, worldMatrix);
  25359. this.boundingSphere.reConstruct(min, max, worldMatrix);
  25360. };
  25361. Object.defineProperty(BoundingInfo.prototype, "minimum", {
  25362. /**
  25363. * min vector of the bounding box/sphere
  25364. */
  25365. get: function () {
  25366. return this.boundingBox.minimum;
  25367. },
  25368. enumerable: true,
  25369. configurable: true
  25370. });
  25371. Object.defineProperty(BoundingInfo.prototype, "maximum", {
  25372. /**
  25373. * max vector of the bounding box/sphere
  25374. */
  25375. get: function () {
  25376. return this.boundingBox.maximum;
  25377. },
  25378. enumerable: true,
  25379. configurable: true
  25380. });
  25381. Object.defineProperty(BoundingInfo.prototype, "isLocked", {
  25382. /**
  25383. * If the info is locked and won't be updated to avoid perf overhead
  25384. */
  25385. get: function () {
  25386. return this._isLocked;
  25387. },
  25388. set: function (value) {
  25389. this._isLocked = value;
  25390. },
  25391. enumerable: true,
  25392. configurable: true
  25393. });
  25394. // Methods
  25395. /**
  25396. * Updates the bounding sphere and box
  25397. * @param world world matrix to be used to update
  25398. */
  25399. BoundingInfo.prototype.update = function (world) {
  25400. if (this._isLocked) {
  25401. return;
  25402. }
  25403. this.boundingBox._update(world);
  25404. this.boundingSphere._update(world);
  25405. };
  25406. /**
  25407. * Recreate the bounding info to be centered around a specific point given a specific extend.
  25408. * @param center New center of the bounding info
  25409. * @param extend New extend of the bounding info
  25410. * @returns the current bounding info
  25411. */
  25412. BoundingInfo.prototype.centerOn = function (center, extend) {
  25413. var minimum = BoundingInfo.TmpVector3[0].copyFrom(center).subtractInPlace(extend);
  25414. var maximum = BoundingInfo.TmpVector3[1].copyFrom(center).addInPlace(extend);
  25415. this.boundingBox.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  25416. this.boundingSphere.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  25417. return this;
  25418. };
  25419. /**
  25420. * Scale the current bounding info by applying a scale factor
  25421. * @param factor defines the scale factor to apply
  25422. * @returns the current bounding info
  25423. */
  25424. BoundingInfo.prototype.scale = function (factor) {
  25425. this.boundingBox.scale(factor);
  25426. this.boundingSphere.scale(factor);
  25427. return this;
  25428. };
  25429. /**
  25430. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  25431. * @param frustumPlanes defines the frustum to test
  25432. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  25433. * @returns true if the bounding info is in the frustum planes
  25434. */
  25435. BoundingInfo.prototype.isInFrustum = function (frustumPlanes, strategy) {
  25436. if (strategy === void 0) { strategy = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD; }
  25437. 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);
  25438. if (inclusionTest) {
  25439. if (this.boundingSphere.isCenterInFrustum(frustumPlanes)) {
  25440. return true;
  25441. }
  25442. }
  25443. if (!this.boundingSphere.isInFrustum(frustumPlanes)) {
  25444. return false;
  25445. }
  25446. 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);
  25447. if (bSphereOnlyTest) {
  25448. return true;
  25449. }
  25450. return this.boundingBox.isInFrustum(frustumPlanes);
  25451. };
  25452. Object.defineProperty(BoundingInfo.prototype, "diagonalLength", {
  25453. /**
  25454. * Gets the world distance between the min and max points of the bounding box
  25455. */
  25456. get: function () {
  25457. var boundingBox = this.boundingBox;
  25458. var diag = boundingBox.maximumWorld.subtractToRef(boundingBox.minimumWorld, BoundingInfo.TmpVector3[0]);
  25459. return diag.length();
  25460. },
  25461. enumerable: true,
  25462. configurable: true
  25463. });
  25464. /**
  25465. * Checks if a cullable object (mesh...) is in the camera frustum
  25466. * Unlike isInFrustum this cheks the full bounding box
  25467. * @param frustumPlanes Camera near/planes
  25468. * @returns true if the object is in frustum otherwise false
  25469. */
  25470. BoundingInfo.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  25471. return this.boundingBox.isCompletelyInFrustum(frustumPlanes);
  25472. };
  25473. /** @hidden */
  25474. BoundingInfo.prototype._checkCollision = function (collider) {
  25475. return collider._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);
  25476. };
  25477. /**
  25478. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  25479. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25480. * @param point the point to check intersection with
  25481. * @returns if the point intersects
  25482. */
  25483. BoundingInfo.prototype.intersectsPoint = function (point) {
  25484. if (!this.boundingSphere.centerWorld) {
  25485. return false;
  25486. }
  25487. if (!this.boundingSphere.intersectsPoint(point)) {
  25488. return false;
  25489. }
  25490. if (!this.boundingBox.intersectsPoint(point)) {
  25491. return false;
  25492. }
  25493. return true;
  25494. };
  25495. /**
  25496. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  25497. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25498. * @param boundingInfo the bounding info to check intersection with
  25499. * @param precise if the intersection should be done using OBB
  25500. * @returns if the bounding info intersects
  25501. */
  25502. BoundingInfo.prototype.intersects = function (boundingInfo, precise) {
  25503. if (!_boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"].Intersects(this.boundingSphere, boundingInfo.boundingSphere)) {
  25504. return false;
  25505. }
  25506. if (!_boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"].Intersects(this.boundingBox, boundingInfo.boundingBox)) {
  25507. return false;
  25508. }
  25509. if (!precise) {
  25510. return true;
  25511. }
  25512. var box0 = this.boundingBox;
  25513. var box1 = boundingInfo.boundingBox;
  25514. if (!axisOverlap(box0.directions[0], box0, box1)) {
  25515. return false;
  25516. }
  25517. if (!axisOverlap(box0.directions[1], box0, box1)) {
  25518. return false;
  25519. }
  25520. if (!axisOverlap(box0.directions[2], box0, box1)) {
  25521. return false;
  25522. }
  25523. if (!axisOverlap(box1.directions[0], box0, box1)) {
  25524. return false;
  25525. }
  25526. if (!axisOverlap(box1.directions[1], box0, box1)) {
  25527. return false;
  25528. }
  25529. if (!axisOverlap(box1.directions[2], box0, box1)) {
  25530. return false;
  25531. }
  25532. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[0]), box0, box1)) {
  25533. return false;
  25534. }
  25535. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[1]), box0, box1)) {
  25536. return false;
  25537. }
  25538. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[2]), box0, box1)) {
  25539. return false;
  25540. }
  25541. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[0]), box0, box1)) {
  25542. return false;
  25543. }
  25544. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[1]), box0, box1)) {
  25545. return false;
  25546. }
  25547. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[2]), box0, box1)) {
  25548. return false;
  25549. }
  25550. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[0]), box0, box1)) {
  25551. return false;
  25552. }
  25553. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[1]), box0, box1)) {
  25554. return false;
  25555. }
  25556. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[2]), box0, box1)) {
  25557. return false;
  25558. }
  25559. return true;
  25560. };
  25561. BoundingInfo.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25562. return BoundingInfo;
  25563. }());
  25564. /***/ }),
  25565. /***/ "./Culling/boundingSphere.ts":
  25566. /*!***********************************!*\
  25567. !*** ./Culling/boundingSphere.ts ***!
  25568. \***********************************/
  25569. /*! exports provided: BoundingSphere */
  25570. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25571. "use strict";
  25572. __webpack_require__.r(__webpack_exports__);
  25573. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return BoundingSphere; });
  25574. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25575. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25576. /**
  25577. * Class used to store bounding sphere information
  25578. */
  25579. var BoundingSphere = /** @class */ (function () {
  25580. /**
  25581. * Creates a new bounding sphere
  25582. * @param min defines the minimum vector (in local space)
  25583. * @param max defines the maximum vector (in local space)
  25584. * @param worldMatrix defines the new world matrix
  25585. */
  25586. function BoundingSphere(min, max, worldMatrix) {
  25587. /**
  25588. * Gets the center of the bounding sphere in local space
  25589. */
  25590. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25591. /**
  25592. * Gets the center of the bounding sphere in world space
  25593. */
  25594. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25595. /**
  25596. * Gets the minimum vector in local space
  25597. */
  25598. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25599. /**
  25600. * Gets the maximum vector in local space
  25601. */
  25602. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25603. this.reConstruct(min, max, worldMatrix);
  25604. }
  25605. /**
  25606. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  25607. * @param min defines the new minimum vector (in local space)
  25608. * @param max defines the new maximum vector (in local space)
  25609. * @param worldMatrix defines the new world matrix
  25610. */
  25611. BoundingSphere.prototype.reConstruct = function (min, max, worldMatrix) {
  25612. this.minimum.copyFrom(min);
  25613. this.maximum.copyFrom(max);
  25614. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(min, max);
  25615. max.addToRef(min, this.center).scaleInPlace(0.5);
  25616. this.radius = distance * 0.5;
  25617. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  25618. };
  25619. /**
  25620. * Scale the current bounding sphere by applying a scale factor
  25621. * @param factor defines the scale factor to apply
  25622. * @returns the current bounding box
  25623. */
  25624. BoundingSphere.prototype.scale = function (factor) {
  25625. var newRadius = this.radius * factor;
  25626. var tmpVectors = BoundingSphere.TmpVector3;
  25627. var tempRadiusVector = tmpVectors[0].setAll(newRadius);
  25628. var min = this.center.subtractToRef(tempRadiusVector, tmpVectors[1]);
  25629. var max = this.center.addToRef(tempRadiusVector, tmpVectors[2]);
  25630. this.reConstruct(min, max, this._worldMatrix);
  25631. return this;
  25632. };
  25633. /**
  25634. * Gets the world matrix of the bounding box
  25635. * @returns a matrix
  25636. */
  25637. BoundingSphere.prototype.getWorldMatrix = function () {
  25638. return this._worldMatrix;
  25639. };
  25640. // Methods
  25641. /** @hidden */
  25642. BoundingSphere.prototype._update = function (worldMatrix) {
  25643. if (!worldMatrix.isIdentity()) {
  25644. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(this.center, worldMatrix, this.centerWorld);
  25645. var tempVector = BoundingSphere.TmpVector3[0];
  25646. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, worldMatrix, tempVector);
  25647. this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;
  25648. }
  25649. else {
  25650. this.centerWorld.copyFrom(this.center);
  25651. this.radiusWorld = this.radius;
  25652. }
  25653. };
  25654. /**
  25655. * Tests if the bounding sphere is intersecting the frustum planes
  25656. * @param frustumPlanes defines the frustum planes to test
  25657. * @returns true if there is an intersection
  25658. */
  25659. BoundingSphere.prototype.isInFrustum = function (frustumPlanes) {
  25660. var center = this.centerWorld;
  25661. var radius = this.radiusWorld;
  25662. for (var i = 0; i < 6; i++) {
  25663. if (frustumPlanes[i].dotCoordinate(center) <= -radius) {
  25664. return false;
  25665. }
  25666. }
  25667. return true;
  25668. };
  25669. /**
  25670. * Tests if the bounding sphere center is in between the frustum planes.
  25671. * Used for optimistic fast inclusion.
  25672. * @param frustumPlanes defines the frustum planes to test
  25673. * @returns true if the sphere center is in between the frustum planes
  25674. */
  25675. BoundingSphere.prototype.isCenterInFrustum = function (frustumPlanes) {
  25676. var center = this.centerWorld;
  25677. for (var i = 0; i < 6; i++) {
  25678. if (frustumPlanes[i].dotCoordinate(center) < 0) {
  25679. return false;
  25680. }
  25681. }
  25682. return true;
  25683. };
  25684. /**
  25685. * Tests if a point is inside the bounding sphere
  25686. * @param point defines the point to test
  25687. * @returns true if the point is inside the bounding sphere
  25688. */
  25689. BoundingSphere.prototype.intersectsPoint = function (point) {
  25690. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(this.centerWorld, point);
  25691. if (this.radiusWorld * this.radiusWorld < squareDistance) {
  25692. return false;
  25693. }
  25694. return true;
  25695. };
  25696. // Statics
  25697. /**
  25698. * Checks if two sphere intersct
  25699. * @param sphere0 sphere 0
  25700. * @param sphere1 sphere 1
  25701. * @returns true if the speres intersect
  25702. */
  25703. BoundingSphere.Intersects = function (sphere0, sphere1) {
  25704. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphere0.centerWorld, sphere1.centerWorld);
  25705. var radiusSum = sphere0.radiusWorld + sphere1.radiusWorld;
  25706. if (radiusSum * radiusSum < squareDistance) {
  25707. return false;
  25708. }
  25709. return true;
  25710. };
  25711. BoundingSphere.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25712. return BoundingSphere;
  25713. }());
  25714. /***/ }),
  25715. /***/ "./Culling/index.ts":
  25716. /*!**************************!*\
  25717. !*** ./Culling/index.ts ***!
  25718. \**************************/
  25719. /*! exports provided: BoundingBox, BoundingInfo, BoundingSphere, Ray, Octree, OctreeBlock, OctreeSceneComponent */
  25720. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25721. "use strict";
  25722. __webpack_require__.r(__webpack_exports__);
  25723. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  25724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _boundingBox__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  25725. /* harmony import */ var _boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boundingInfo */ "./Culling/boundingInfo.ts");
  25726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"]; });
  25727. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  25728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"]; });
  25729. /* harmony import */ var _Octrees_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Octrees/index */ "./Culling/Octrees/index.ts");
  25730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["Octree"]; });
  25731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeBlock"]; });
  25732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeSceneComponent"]; });
  25733. /* harmony import */ var _ray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ray */ "./Culling/ray.ts");
  25734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _ray__WEBPACK_IMPORTED_MODULE_4__["Ray"]; });
  25735. /***/ }),
  25736. /***/ "./Culling/ray.ts":
  25737. /*!************************!*\
  25738. !*** ./Culling/ray.ts ***!
  25739. \************************/
  25740. /*! exports provided: Ray */
  25741. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25742. "use strict";
  25743. __webpack_require__.r(__webpack_exports__);
  25744. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return Ray; });
  25745. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25746. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25747. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  25748. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  25749. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  25750. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  25751. /**
  25752. * Class representing a ray with position and direction
  25753. */
  25754. var Ray = /** @class */ (function () {
  25755. /**
  25756. * Creates a new ray
  25757. * @param origin origin point
  25758. * @param direction direction
  25759. * @param length length of the ray
  25760. */
  25761. function Ray(
  25762. /** origin point */
  25763. origin,
  25764. /** direction */
  25765. direction,
  25766. /** length of the ray */
  25767. length) {
  25768. if (length === void 0) { length = Number.MAX_VALUE; }
  25769. this.origin = origin;
  25770. this.direction = direction;
  25771. this.length = length;
  25772. }
  25773. // Methods
  25774. /**
  25775. * Checks if the ray intersects a box
  25776. * @param minimum bound of the box
  25777. * @param maximum bound of the box
  25778. * @param intersectionTreshold extra extend to be added to the box in all direction
  25779. * @returns if the box was hit
  25780. */
  25781. Ray.prototype.intersectsBoxMinMax = function (minimum, maximum, intersectionTreshold) {
  25782. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25783. var newMinimum = Ray.TmpVector3[0].copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);
  25784. var newMaximum = Ray.TmpVector3[1].copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);
  25785. var d = 0.0;
  25786. var maxValue = Number.MAX_VALUE;
  25787. var inv;
  25788. var min;
  25789. var max;
  25790. var temp;
  25791. if (Math.abs(this.direction.x) < 0.0000001) {
  25792. if (this.origin.x < newMinimum.x || this.origin.x > newMaximum.x) {
  25793. return false;
  25794. }
  25795. }
  25796. else {
  25797. inv = 1.0 / this.direction.x;
  25798. min = (newMinimum.x - this.origin.x) * inv;
  25799. max = (newMaximum.x - this.origin.x) * inv;
  25800. if (max === -Infinity) {
  25801. max = Infinity;
  25802. }
  25803. if (min > max) {
  25804. temp = min;
  25805. min = max;
  25806. max = temp;
  25807. }
  25808. d = Math.max(min, d);
  25809. maxValue = Math.min(max, maxValue);
  25810. if (d > maxValue) {
  25811. return false;
  25812. }
  25813. }
  25814. if (Math.abs(this.direction.y) < 0.0000001) {
  25815. if (this.origin.y < newMinimum.y || this.origin.y > newMaximum.y) {
  25816. return false;
  25817. }
  25818. }
  25819. else {
  25820. inv = 1.0 / this.direction.y;
  25821. min = (newMinimum.y - this.origin.y) * inv;
  25822. max = (newMaximum.y - this.origin.y) * inv;
  25823. if (max === -Infinity) {
  25824. max = Infinity;
  25825. }
  25826. if (min > max) {
  25827. temp = min;
  25828. min = max;
  25829. max = temp;
  25830. }
  25831. d = Math.max(min, d);
  25832. maxValue = Math.min(max, maxValue);
  25833. if (d > maxValue) {
  25834. return false;
  25835. }
  25836. }
  25837. if (Math.abs(this.direction.z) < 0.0000001) {
  25838. if (this.origin.z < newMinimum.z || this.origin.z > newMaximum.z) {
  25839. return false;
  25840. }
  25841. }
  25842. else {
  25843. inv = 1.0 / this.direction.z;
  25844. min = (newMinimum.z - this.origin.z) * inv;
  25845. max = (newMaximum.z - this.origin.z) * inv;
  25846. if (max === -Infinity) {
  25847. max = Infinity;
  25848. }
  25849. if (min > max) {
  25850. temp = min;
  25851. min = max;
  25852. max = temp;
  25853. }
  25854. d = Math.max(min, d);
  25855. maxValue = Math.min(max, maxValue);
  25856. if (d > maxValue) {
  25857. return false;
  25858. }
  25859. }
  25860. return true;
  25861. };
  25862. /**
  25863. * Checks if the ray intersects a box
  25864. * @param box the bounding box to check
  25865. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  25866. * @returns if the box was hit
  25867. */
  25868. Ray.prototype.intersectsBox = function (box, intersectionTreshold) {
  25869. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25870. return this.intersectsBoxMinMax(box.minimum, box.maximum, intersectionTreshold);
  25871. };
  25872. /**
  25873. * If the ray hits a sphere
  25874. * @param sphere the bounding sphere to check
  25875. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  25876. * @returns true if it hits the sphere
  25877. */
  25878. Ray.prototype.intersectsSphere = function (sphere, intersectionTreshold) {
  25879. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25880. var x = sphere.center.x - this.origin.x;
  25881. var y = sphere.center.y - this.origin.y;
  25882. var z = sphere.center.z - this.origin.z;
  25883. var pyth = (x * x) + (y * y) + (z * z);
  25884. var radius = sphere.radius + intersectionTreshold;
  25885. var rr = radius * radius;
  25886. if (pyth <= rr) {
  25887. return true;
  25888. }
  25889. var dot = (x * this.direction.x) + (y * this.direction.y) + (z * this.direction.z);
  25890. if (dot < 0.0) {
  25891. return false;
  25892. }
  25893. var temp = pyth - (dot * dot);
  25894. return temp <= rr;
  25895. };
  25896. /**
  25897. * If the ray hits a triange
  25898. * @param vertex0 triangle vertex
  25899. * @param vertex1 triangle vertex
  25900. * @param vertex2 triangle vertex
  25901. * @returns intersection information if hit
  25902. */
  25903. Ray.prototype.intersectsTriangle = function (vertex0, vertex1, vertex2) {
  25904. var edge1 = Ray.TmpVector3[0];
  25905. var edge2 = Ray.TmpVector3[1];
  25906. var pvec = Ray.TmpVector3[2];
  25907. var tvec = Ray.TmpVector3[3];
  25908. var qvec = Ray.TmpVector3[4];
  25909. vertex1.subtractToRef(vertex0, edge1);
  25910. vertex2.subtractToRef(vertex0, edge2);
  25911. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(this.direction, edge2, pvec);
  25912. var det = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge1, pvec);
  25913. if (det === 0) {
  25914. return null;
  25915. }
  25916. var invdet = 1 / det;
  25917. this.origin.subtractToRef(vertex0, tvec);
  25918. var bu = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(tvec, pvec) * invdet;
  25919. if (bu < 0 || bu > 1.0) {
  25920. return null;
  25921. }
  25922. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(tvec, edge1, qvec);
  25923. var bv = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this.direction, qvec) * invdet;
  25924. if (bv < 0 || bu + bv > 1.0) {
  25925. return null;
  25926. }
  25927. //check if the distance is longer than the predefined length.
  25928. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge2, qvec) * invdet;
  25929. if (distance > this.length) {
  25930. return null;
  25931. }
  25932. return new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](bu, bv, distance);
  25933. };
  25934. /**
  25935. * Checks if ray intersects a plane
  25936. * @param plane the plane to check
  25937. * @returns the distance away it was hit
  25938. */
  25939. Ray.prototype.intersectsPlane = function (plane) {
  25940. var distance;
  25941. var result1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.direction);
  25942. if (Math.abs(result1) < 9.99999997475243E-07) {
  25943. return null;
  25944. }
  25945. else {
  25946. var result2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.origin);
  25947. distance = (-plane.d - result2) / result1;
  25948. if (distance < 0.0) {
  25949. if (distance < -9.99999997475243E-07) {
  25950. return null;
  25951. }
  25952. else {
  25953. return 0;
  25954. }
  25955. }
  25956. return distance;
  25957. }
  25958. };
  25959. /**
  25960. * Checks if ray intersects a mesh
  25961. * @param mesh the mesh to check
  25962. * @param fastCheck if only the bounding box should checked
  25963. * @returns picking info of the intersecton
  25964. */
  25965. Ray.prototype.intersectsMesh = function (mesh, fastCheck) {
  25966. var tm = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  25967. mesh.getWorldMatrix().invertToRef(tm);
  25968. if (this._tmpRay) {
  25969. Ray.TransformToRef(this, tm, this._tmpRay);
  25970. }
  25971. else {
  25972. this._tmpRay = Ray.Transform(this, tm);
  25973. }
  25974. return mesh.intersects(this._tmpRay, fastCheck);
  25975. };
  25976. /**
  25977. * Checks if ray intersects a mesh
  25978. * @param meshes the meshes to check
  25979. * @param fastCheck if only the bounding box should checked
  25980. * @param results array to store result in
  25981. * @returns Array of picking infos
  25982. */
  25983. Ray.prototype.intersectsMeshes = function (meshes, fastCheck, results) {
  25984. if (results) {
  25985. results.length = 0;
  25986. }
  25987. else {
  25988. results = [];
  25989. }
  25990. for (var i = 0; i < meshes.length; i++) {
  25991. var pickInfo = this.intersectsMesh(meshes[i], fastCheck);
  25992. if (pickInfo.hit) {
  25993. results.push(pickInfo);
  25994. }
  25995. }
  25996. results.sort(this._comparePickingInfo);
  25997. return results;
  25998. };
  25999. Ray.prototype._comparePickingInfo = function (pickingInfoA, pickingInfoB) {
  26000. if (pickingInfoA.distance < pickingInfoB.distance) {
  26001. return -1;
  26002. }
  26003. else if (pickingInfoA.distance > pickingInfoB.distance) {
  26004. return 1;
  26005. }
  26006. else {
  26007. return 0;
  26008. }
  26009. };
  26010. /**
  26011. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  26012. * @param sega the first point of the segment to test the intersection against
  26013. * @param segb the second point of the segment to test the intersection against
  26014. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  26015. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  26016. */
  26017. Ray.prototype.intersectionSegment = function (sega, segb, threshold) {
  26018. var o = this.origin;
  26019. var u = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  26020. var rsegb = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  26021. var v = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  26022. var w = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  26023. segb.subtractToRef(sega, u);
  26024. this.direction.scaleToRef(Ray.rayl, v);
  26025. o.addToRef(v, rsegb);
  26026. sega.subtractToRef(o, w);
  26027. var a = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, u); // always >= 0
  26028. var b = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, v);
  26029. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, v); // always >= 0
  26030. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, w);
  26031. var e = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, w);
  26032. var D = a * c - b * b; // always >= 0
  26033. var sc, sN, sD = D; // sc = sN / sD, default sD = D >= 0
  26034. var tc, tN, tD = D; // tc = tN / tD, default tD = D >= 0
  26035. // compute the line parameters of the two closest points
  26036. if (D < Ray.smallnum) { // the lines are almost parallel
  26037. sN = 0.0; // force using point P0 on segment S1
  26038. sD = 1.0; // to prevent possible division by 0.0 later
  26039. tN = e;
  26040. tD = c;
  26041. }
  26042. else { // get the closest points on the infinite lines
  26043. sN = (b * e - c * d);
  26044. tN = (a * e - b * d);
  26045. if (sN < 0.0) { // sc < 0 => the s=0 edge is visible
  26046. sN = 0.0;
  26047. tN = e;
  26048. tD = c;
  26049. }
  26050. else if (sN > sD) { // sc > 1 => the s=1 edge is visible
  26051. sN = sD;
  26052. tN = e + b;
  26053. tD = c;
  26054. }
  26055. }
  26056. if (tN < 0.0) { // tc < 0 => the t=0 edge is visible
  26057. tN = 0.0;
  26058. // recompute sc for this edge
  26059. if (-d < 0.0) {
  26060. sN = 0.0;
  26061. }
  26062. else if (-d > a) {
  26063. sN = sD;
  26064. }
  26065. else {
  26066. sN = -d;
  26067. sD = a;
  26068. }
  26069. }
  26070. else if (tN > tD) { // tc > 1 => the t=1 edge is visible
  26071. tN = tD;
  26072. // recompute sc for this edge
  26073. if ((-d + b) < 0.0) {
  26074. sN = 0;
  26075. }
  26076. else if ((-d + b) > a) {
  26077. sN = sD;
  26078. }
  26079. else {
  26080. sN = (-d + b);
  26081. sD = a;
  26082. }
  26083. }
  26084. // finally do the division to get sc and tc
  26085. sc = (Math.abs(sN) < Ray.smallnum ? 0.0 : sN / sD);
  26086. tc = (Math.abs(tN) < Ray.smallnum ? 0.0 : tN / tD);
  26087. // get the difference of the two closest points
  26088. var qtc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  26089. v.scaleToRef(tc, qtc);
  26090. var qsc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  26091. u.scaleToRef(sc, qsc);
  26092. qsc.addInPlace(w);
  26093. var dP = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  26094. qsc.subtractToRef(qtc, dP); // = S1(sc) - S2(tc)
  26095. var isIntersected = (tc > 0) && (tc <= this.length) && (dP.lengthSquared() < (threshold * threshold)); // return intersection result
  26096. if (isIntersected) {
  26097. return qsc.length();
  26098. }
  26099. return -1;
  26100. };
  26101. /**
  26102. * Update the ray from viewport position
  26103. * @param x position
  26104. * @param y y position
  26105. * @param viewportWidth viewport width
  26106. * @param viewportHeight viewport height
  26107. * @param world world matrix
  26108. * @param view view matrix
  26109. * @param projection projection matrix
  26110. * @returns this ray updated
  26111. */
  26112. Ray.prototype.update = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  26113. this.unprojectRayToRef(x, y, viewportWidth, viewportHeight, world, view, projection);
  26114. return this;
  26115. };
  26116. // Statics
  26117. /**
  26118. * Creates a ray with origin and direction of 0,0,0
  26119. * @returns the new ray
  26120. */
  26121. Ray.Zero = function () {
  26122. return new Ray(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero());
  26123. };
  26124. /**
  26125. * Creates a new ray from screen space and viewport
  26126. * @param x position
  26127. * @param y y position
  26128. * @param viewportWidth viewport width
  26129. * @param viewportHeight viewport height
  26130. * @param world world matrix
  26131. * @param view view matrix
  26132. * @param projection projection matrix
  26133. * @returns new ray
  26134. */
  26135. Ray.CreateNew = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  26136. var result = Ray.Zero();
  26137. return result.update(x, y, viewportWidth, viewportHeight, world, view, projection);
  26138. };
  26139. /**
  26140. * 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
  26141. * transformed to the given world matrix.
  26142. * @param origin The origin point
  26143. * @param end The end point
  26144. * @param world a matrix to transform the ray to. Default is the identity matrix.
  26145. * @returns the new ray
  26146. */
  26147. Ray.CreateNewFromTo = function (origin, end, world) {
  26148. if (world === void 0) { world = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly; }
  26149. var direction = end.subtract(origin);
  26150. var length = Math.sqrt((direction.x * direction.x) + (direction.y * direction.y) + (direction.z * direction.z));
  26151. direction.normalize();
  26152. return Ray.Transform(new Ray(origin, direction, length), world);
  26153. };
  26154. /**
  26155. * Transforms a ray by a matrix
  26156. * @param ray ray to transform
  26157. * @param matrix matrix to apply
  26158. * @returns the resulting new ray
  26159. */
  26160. Ray.Transform = function (ray, matrix) {
  26161. 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));
  26162. Ray.TransformToRef(ray, matrix, result);
  26163. return result;
  26164. };
  26165. /**
  26166. * Transforms a ray by a matrix
  26167. * @param ray ray to transform
  26168. * @param matrix matrix to apply
  26169. * @param result ray to store result in
  26170. */
  26171. Ray.TransformToRef = function (ray, matrix, result) {
  26172. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(ray.origin, matrix, result.origin);
  26173. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(ray.direction, matrix, result.direction);
  26174. result.length = ray.length;
  26175. var dir = result.direction;
  26176. var len = dir.length();
  26177. if (!(len === 0 || len === 1)) {
  26178. var num = 1.0 / len;
  26179. dir.x *= num;
  26180. dir.y *= num;
  26181. dir.z *= num;
  26182. result.length *= len;
  26183. }
  26184. };
  26185. /**
  26186. * Unproject a ray from screen space to object space
  26187. * @param sourceX defines the screen space x coordinate to use
  26188. * @param sourceY defines the screen space y coordinate to use
  26189. * @param viewportWidth defines the current width of the viewport
  26190. * @param viewportHeight defines the current height of the viewport
  26191. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  26192. * @param view defines the view matrix to use
  26193. * @param projection defines the projection matrix to use
  26194. */
  26195. Ray.prototype.unprojectRayToRef = function (sourceX, sourceY, viewportWidth, viewportHeight, world, view, projection) {
  26196. var matrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  26197. world.multiplyToRef(view, matrix);
  26198. matrix.multiplyToRef(projection, matrix);
  26199. matrix.invert();
  26200. var nearScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  26201. nearScreenSource.x = sourceX / viewportWidth * 2 - 1;
  26202. nearScreenSource.y = -(sourceY / viewportHeight * 2 - 1);
  26203. nearScreenSource.z = -1.0;
  26204. var farScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1].copyFromFloats(nearScreenSource.x, nearScreenSource.y, 1.0);
  26205. var nearVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  26206. var farVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  26207. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(nearScreenSource, matrix, nearVec3);
  26208. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(farScreenSource, matrix, farVec3);
  26209. this.origin.copyFrom(nearVec3);
  26210. farVec3.subtractToRef(nearVec3, this.direction);
  26211. this.direction.normalize();
  26212. };
  26213. Ray.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  26214. Ray.smallnum = 0.00000001;
  26215. Ray.rayl = 10e8;
  26216. return Ray;
  26217. }());
  26218. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  26219. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  26220. var result = Ray.Zero();
  26221. this.createPickingRayToRef(x, y, world, result, camera, cameraViewSpace);
  26222. return result;
  26223. };
  26224. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  26225. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  26226. var engine = this.getEngine();
  26227. if (!camera) {
  26228. if (!this.activeCamera) {
  26229. throw new Error("Active camera not set");
  26230. }
  26231. camera = this.activeCamera;
  26232. }
  26233. var cameraViewport = camera.viewport;
  26234. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  26235. // Moving coordinates to local viewport world
  26236. x = x / engine.getHardwareScalingLevel() - viewport.x;
  26237. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  26238. 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());
  26239. return this;
  26240. };
  26241. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  26242. var result = Ray.Zero();
  26243. this.createPickingRayInCameraSpaceToRef(x, y, result, camera);
  26244. return result;
  26245. };
  26246. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  26247. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26248. return this;
  26249. }
  26250. var engine = this.getEngine();
  26251. if (!camera) {
  26252. if (!this.activeCamera) {
  26253. throw new Error("Active camera not set");
  26254. }
  26255. camera = this.activeCamera;
  26256. }
  26257. var cameraViewport = camera.viewport;
  26258. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  26259. var identity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  26260. // Moving coordinates to local viewport world
  26261. x = x / engine.getHardwareScalingLevel() - viewport.x;
  26262. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  26263. result.update(x, y, viewport.width, viewport.height, identity, identity, camera.getProjectionMatrix());
  26264. return this;
  26265. };
  26266. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalPick = function (rayFunction, predicate, fastCheck, trianglePredicate) {
  26267. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26268. return null;
  26269. }
  26270. var pickingInfo = null;
  26271. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  26272. var mesh = this.meshes[meshIndex];
  26273. if (predicate) {
  26274. if (!predicate(mesh)) {
  26275. continue;
  26276. }
  26277. }
  26278. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  26279. continue;
  26280. }
  26281. var world = mesh.getWorldMatrix();
  26282. var ray = rayFunction(world);
  26283. var result = mesh.intersects(ray, fastCheck, trianglePredicate);
  26284. if (!result || !result.hit) {
  26285. continue;
  26286. }
  26287. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  26288. continue;
  26289. }
  26290. pickingInfo = result;
  26291. if (fastCheck) {
  26292. break;
  26293. }
  26294. }
  26295. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]();
  26296. };
  26297. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalMultiPick = function (rayFunction, predicate, trianglePredicate) {
  26298. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26299. return null;
  26300. }
  26301. var pickingInfos = new Array();
  26302. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  26303. var mesh = this.meshes[meshIndex];
  26304. if (predicate) {
  26305. if (!predicate(mesh)) {
  26306. continue;
  26307. }
  26308. }
  26309. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  26310. continue;
  26311. }
  26312. var world = mesh.getWorldMatrix();
  26313. var ray = rayFunction(world);
  26314. var result = mesh.intersects(ray, false, trianglePredicate);
  26315. if (!result || !result.hit) {
  26316. continue;
  26317. }
  26318. pickingInfos.push(result);
  26319. }
  26320. return pickingInfos;
  26321. };
  26322. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pick = function (x, y, predicate, fastCheck, camera, trianglePredicate) {
  26323. var _this = this;
  26324. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26325. return null;
  26326. }
  26327. var result = this._internalPick(function (world) {
  26328. if (!_this._tempPickingRay) {
  26329. _this._tempPickingRay = Ray.Zero();
  26330. }
  26331. _this.createPickingRayToRef(x, y, world, _this._tempPickingRay, camera || null);
  26332. return _this._tempPickingRay;
  26333. }, predicate, fastCheck, trianglePredicate);
  26334. if (result) {
  26335. result.ray = this.createPickingRay(x, y, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), camera || null);
  26336. }
  26337. return result;
  26338. };
  26339. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pickWithRay = function (ray, predicate, fastCheck, trianglePredicate) {
  26340. var _this = this;
  26341. var result = this._internalPick(function (world) {
  26342. if (!_this._pickWithRayInverseMatrix) {
  26343. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  26344. }
  26345. world.invertToRef(_this._pickWithRayInverseMatrix);
  26346. if (!_this._cachedRayForTransform) {
  26347. _this._cachedRayForTransform = Ray.Zero();
  26348. }
  26349. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  26350. return _this._cachedRayForTransform;
  26351. }, predicate, fastCheck, trianglePredicate);
  26352. if (result) {
  26353. result.ray = ray;
  26354. }
  26355. return result;
  26356. };
  26357. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPick = function (x, y, predicate, camera, trianglePredicate) {
  26358. var _this = this;
  26359. return this._internalMultiPick(function (world) { return _this.createPickingRay(x, y, world, camera || null); }, predicate, trianglePredicate);
  26360. };
  26361. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPickWithRay = function (ray, predicate, trianglePredicate) {
  26362. var _this = this;
  26363. return this._internalMultiPick(function (world) {
  26364. if (!_this._pickWithRayInverseMatrix) {
  26365. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  26366. }
  26367. world.invertToRef(_this._pickWithRayInverseMatrix);
  26368. if (!_this._cachedRayForTransform) {
  26369. _this._cachedRayForTransform = Ray.Zero();
  26370. }
  26371. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  26372. return _this._cachedRayForTransform;
  26373. }, predicate, trianglePredicate);
  26374. };
  26375. _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].prototype.getForwardRay = function (length, transform, origin) {
  26376. if (length === void 0) { length = 100; }
  26377. if (!transform) {
  26378. transform = this.getWorldMatrix();
  26379. }
  26380. if (!origin) {
  26381. origin = this.position;
  26382. }
  26383. 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);
  26384. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(forward, transform);
  26385. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Normalize(forwardWorld);
  26386. return new Ray(origin, direction, length);
  26387. };
  26388. /***/ }),
  26389. /***/ "./Debug/axesViewer.ts":
  26390. /*!*****************************!*\
  26391. !*** ./Debug/axesViewer.ts ***!
  26392. \*****************************/
  26393. /*! exports provided: AxesViewer */
  26394. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26395. "use strict";
  26396. __webpack_require__.r(__webpack_exports__);
  26397. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return AxesViewer; });
  26398. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26399. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  26400. /* harmony import */ var _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gizmos/axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  26401. /**
  26402. * The Axes viewer will show 3 axes in a specific point in space
  26403. */
  26404. var AxesViewer = /** @class */ (function () {
  26405. /**
  26406. * Creates a new AxesViewer
  26407. * @param scene defines the hosting scene
  26408. * @param scaleLines defines a number used to scale line length (1 by default)
  26409. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  26410. * @param xAxis defines the node hierarchy used to render the x-axis
  26411. * @param yAxis defines the node hierarchy used to render the y-axis
  26412. * @param zAxis defines the node hierarchy used to render the z-axis
  26413. */
  26414. function AxesViewer(scene, scaleLines, renderingGroupId, xAxis, yAxis, zAxis) {
  26415. if (scaleLines === void 0) { scaleLines = 1; }
  26416. if (renderingGroupId === void 0) { renderingGroupId = 2; }
  26417. this._scaleLinesFactor = 4;
  26418. this._instanced = false;
  26419. /**
  26420. * Gets or sets a number used to scale line length
  26421. */
  26422. this.scaleLines = 1;
  26423. this.scaleLines = scaleLines;
  26424. if (!xAxis) {
  26425. var redColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  26426. redColoredMaterial.disableLighting = true;
  26427. redColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Red().scale(0.5);
  26428. xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, redColoredMaterial);
  26429. }
  26430. if (!yAxis) {
  26431. var greenColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  26432. greenColoredMaterial.disableLighting = true;
  26433. greenColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Green().scale(0.5);
  26434. yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, greenColoredMaterial);
  26435. }
  26436. if (!zAxis) {
  26437. var blueColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  26438. blueColoredMaterial.disableLighting = true;
  26439. blueColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Blue().scale(0.5);
  26440. zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, blueColoredMaterial);
  26441. }
  26442. this._xAxis = xAxis;
  26443. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26444. this._yAxis = yAxis;
  26445. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26446. this._zAxis = zAxis;
  26447. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26448. if (renderingGroupId != null) {
  26449. AxesViewer._SetRenderingGroupId(this._xAxis, renderingGroupId);
  26450. AxesViewer._SetRenderingGroupId(this._yAxis, renderingGroupId);
  26451. AxesViewer._SetRenderingGroupId(this._zAxis, renderingGroupId);
  26452. }
  26453. this.scene = scene;
  26454. 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());
  26455. }
  26456. Object.defineProperty(AxesViewer.prototype, "xAxis", {
  26457. /** Gets the node hierarchy used to render x-axis */
  26458. get: function () {
  26459. return this._xAxis;
  26460. },
  26461. enumerable: true,
  26462. configurable: true
  26463. });
  26464. Object.defineProperty(AxesViewer.prototype, "yAxis", {
  26465. /** Gets the node hierarchy used to render y-axis */
  26466. get: function () {
  26467. return this._yAxis;
  26468. },
  26469. enumerable: true,
  26470. configurable: true
  26471. });
  26472. Object.defineProperty(AxesViewer.prototype, "zAxis", {
  26473. /** Gets the node hierarchy used to render z-axis */
  26474. get: function () {
  26475. return this._zAxis;
  26476. },
  26477. enumerable: true,
  26478. configurable: true
  26479. });
  26480. /**
  26481. * Force the viewer to update
  26482. * @param position defines the position of the viewer
  26483. * @param xaxis defines the x axis of the viewer
  26484. * @param yaxis defines the y axis of the viewer
  26485. * @param zaxis defines the z axis of the viewer
  26486. */
  26487. AxesViewer.prototype.update = function (position, xaxis, yaxis, zaxis) {
  26488. this._xAxis.position.copyFrom(position);
  26489. this._xAxis.setDirection(xaxis);
  26490. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26491. this._yAxis.position.copyFrom(position);
  26492. this._yAxis.setDirection(yaxis);
  26493. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26494. this._zAxis.position.copyFrom(position);
  26495. this._zAxis.setDirection(zaxis);
  26496. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26497. };
  26498. /**
  26499. * Creates an instance of this axes viewer.
  26500. * @returns a new axes viewer with instanced meshes
  26501. */
  26502. AxesViewer.prototype.createInstance = function () {
  26503. var xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._xAxis);
  26504. var yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._yAxis);
  26505. var zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._zAxis);
  26506. var axesViewer = new AxesViewer(this.scene, this.scaleLines, null, xAxis, yAxis, zAxis);
  26507. axesViewer._instanced = true;
  26508. return axesViewer;
  26509. };
  26510. /** Releases resources */
  26511. AxesViewer.prototype.dispose = function () {
  26512. if (this._xAxis) {
  26513. this._xAxis.dispose(false, !this._instanced);
  26514. delete this._xAxis;
  26515. }
  26516. if (this._yAxis) {
  26517. this._yAxis.dispose(false, !this._instanced);
  26518. delete this._yAxis;
  26519. }
  26520. if (this._zAxis) {
  26521. this._zAxis.dispose(false, !this._instanced);
  26522. delete this._zAxis;
  26523. }
  26524. delete this.scene;
  26525. };
  26526. AxesViewer._SetRenderingGroupId = function (node, id) {
  26527. node.getChildMeshes().forEach(function (mesh) {
  26528. mesh.renderingGroupId = id;
  26529. });
  26530. };
  26531. return AxesViewer;
  26532. }());
  26533. /***/ }),
  26534. /***/ "./Debug/boneAxesViewer.ts":
  26535. /*!*********************************!*\
  26536. !*** ./Debug/boneAxesViewer.ts ***!
  26537. \*********************************/
  26538. /*! exports provided: BoneAxesViewer */
  26539. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26540. "use strict";
  26541. __webpack_require__.r(__webpack_exports__);
  26542. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return BoneAxesViewer; });
  26543. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  26544. /* harmony import */ var _Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/axesViewer */ "./Debug/axesViewer.ts");
  26545. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26546. /**
  26547. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  26548. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  26549. */
  26550. var BoneAxesViewer = /** @class */ (function (_super) {
  26551. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoneAxesViewer, _super);
  26552. /**
  26553. * Creates a new BoneAxesViewer
  26554. * @param scene defines the hosting scene
  26555. * @param bone defines the target bone
  26556. * @param mesh defines the target mesh
  26557. * @param scaleLines defines a scaling factor for line length (1 by default)
  26558. */
  26559. function BoneAxesViewer(scene, bone, mesh, scaleLines) {
  26560. if (scaleLines === void 0) { scaleLines = 1; }
  26561. var _this = _super.call(this, scene, scaleLines) || this;
  26562. /** Gets current position */
  26563. _this.pos = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26564. /** Gets direction of X axis */
  26565. _this.xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26566. /** Gets direction of Y axis */
  26567. _this.yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26568. /** Gets direction of Z axis */
  26569. _this.zaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26570. _this.mesh = mesh;
  26571. _this.bone = bone;
  26572. return _this;
  26573. }
  26574. /**
  26575. * Force the viewer to update
  26576. */
  26577. BoneAxesViewer.prototype.update = function () {
  26578. if (!this.mesh || !this.bone) {
  26579. return;
  26580. }
  26581. var bone = this.bone;
  26582. bone.getAbsolutePositionToRef(this.mesh, this.pos);
  26583. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].X, this.mesh, this.xaxis);
  26584. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y, this.mesh, this.yaxis);
  26585. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Z, this.mesh, this.zaxis);
  26586. _super.prototype.update.call(this, this.pos, this.xaxis, this.yaxis, this.zaxis);
  26587. };
  26588. /** Releases resources */
  26589. BoneAxesViewer.prototype.dispose = function () {
  26590. if (this.mesh) {
  26591. this.mesh = null;
  26592. this.bone = null;
  26593. _super.prototype.dispose.call(this);
  26594. }
  26595. };
  26596. return BoneAxesViewer;
  26597. }(_Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"]));
  26598. /***/ }),
  26599. /***/ "./Debug/debugLayer.ts":
  26600. /*!*****************************!*\
  26601. !*** ./Debug/debugLayer.ts ***!
  26602. \*****************************/
  26603. /*! exports provided: DebugLayer */
  26604. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26605. "use strict";
  26606. __webpack_require__.r(__webpack_exports__);
  26607. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return DebugLayer; });
  26608. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  26609. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  26610. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  26611. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  26612. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  26613. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype, "debugLayer", {
  26614. get: function () {
  26615. if (!this._debugLayer) {
  26616. this._debugLayer = new DebugLayer(this);
  26617. }
  26618. return this._debugLayer;
  26619. },
  26620. enumerable: true,
  26621. configurable: true
  26622. });
  26623. /**
  26624. * The debug layer (aka Inspector) is the go to tool in order to better understand
  26625. * what is happening in your scene
  26626. * @see http://doc.babylonjs.com/features/playground_debuglayer
  26627. */
  26628. var DebugLayer = /** @class */ (function () {
  26629. /**
  26630. * Instantiates a new debug layer.
  26631. * The debug layer (aka Inspector) is the go to tool in order to better understand
  26632. * what is happening in your scene
  26633. * @see http://doc.babylonjs.com/features/playground_debuglayer
  26634. * @param scene Defines the scene to inspect
  26635. */
  26636. function DebugLayer(scene) {
  26637. var _this = this;
  26638. this.BJSINSPECTOR = this._getGlobalInspector();
  26639. /**
  26640. * Observable triggered when a property is changed through the inspector.
  26641. */
  26642. this.onPropertyChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  26643. this._scene = scene;
  26644. this._scene.onDisposeObservable.add(function () {
  26645. // Debug layer
  26646. if (_this._scene._debugLayer) {
  26647. _this._scene._debugLayer.hide();
  26648. }
  26649. });
  26650. }
  26651. /** Creates the inspector window. */
  26652. DebugLayer.prototype._createInspector = function (config) {
  26653. if (this.isVisible()) {
  26654. return;
  26655. }
  26656. var userOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ overlay: false, showExplorer: true, showInspector: true, embedMode: false, handleResize: true, enablePopup: true }, config);
  26657. this.BJSINSPECTOR = this.BJSINSPECTOR || this._getGlobalInspector();
  26658. this.BJSINSPECTOR.Inspector.Show(this._scene, userOptions);
  26659. };
  26660. /**
  26661. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  26662. * @param entity defines the entity to select
  26663. * @param lineContainerTitle defines the specific block to highlight
  26664. */
  26665. DebugLayer.prototype.select = function (entity, lineContainerTitle) {
  26666. if (this.BJSINSPECTOR) {
  26667. this.BJSINSPECTOR.Inspector.MarkLineContainerTitleForHighlighting(lineContainerTitle);
  26668. this.BJSINSPECTOR.Inspector.OnSelectionChangeObservable.notifyObservers(entity);
  26669. }
  26670. };
  26671. /** Get the inspector from bundle or global */
  26672. DebugLayer.prototype._getGlobalInspector = function () {
  26673. // UMD Global name detection from Webpack Bundle UMD Name.
  26674. if (typeof INSPECTOR !== 'undefined') {
  26675. return INSPECTOR;
  26676. }
  26677. // In case of module let s check the global emitted from the Inspector entry point.
  26678. if (typeof BABYLON !== 'undefined' && typeof BABYLON.Inspector !== 'undefined') {
  26679. return BABYLON;
  26680. }
  26681. return undefined;
  26682. };
  26683. /**
  26684. * Get if the inspector is visible or not.
  26685. * @returns true if visible otherwise, false
  26686. */
  26687. DebugLayer.prototype.isVisible = function () {
  26688. return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.IsVisible;
  26689. };
  26690. /**
  26691. * Hide the inspector and close its window.
  26692. */
  26693. DebugLayer.prototype.hide = function () {
  26694. if (this.BJSINSPECTOR) {
  26695. this.BJSINSPECTOR.Inspector.Hide();
  26696. }
  26697. };
  26698. /**
  26699. * Launch the debugLayer.
  26700. * @param config Define the configuration of the inspector
  26701. * @return a promise fulfilled when the debug layer is visible
  26702. */
  26703. DebugLayer.prototype.show = function (config) {
  26704. var _this = this;
  26705. return new Promise(function (resolve, reject) {
  26706. if (typeof _this.BJSINSPECTOR == 'undefined') {
  26707. var inspectorUrl = config && config.inspectorURL ? config.inspectorURL : DebugLayer.InspectorURL;
  26708. // Load inspector and add it to the DOM
  26709. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadScript(inspectorUrl, function () {
  26710. _this._createInspector(config);
  26711. resolve(_this);
  26712. });
  26713. }
  26714. else {
  26715. // Otherwise creates the inspector
  26716. _this._createInspector(config);
  26717. resolve(_this);
  26718. }
  26719. });
  26720. };
  26721. /**
  26722. * Define the url to get the inspector script from.
  26723. * By default it uses the babylonjs CDN.
  26724. * @ignoreNaming
  26725. */
  26726. DebugLayer.InspectorURL = "https://unpkg.com/babylonjs-inspector@" + _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].Version + "/babylon.inspector.bundle.js";
  26727. return DebugLayer;
  26728. }());
  26729. /***/ }),
  26730. /***/ "./Debug/index.ts":
  26731. /*!************************!*\
  26732. !*** ./Debug/index.ts ***!
  26733. \************************/
  26734. /*! exports provided: AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer */
  26735. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26736. "use strict";
  26737. __webpack_require__.r(__webpack_exports__);
  26738. /* harmony import */ var _axesViewer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axesViewer */ "./Debug/axesViewer.ts");
  26739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _axesViewer__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  26740. /* harmony import */ var _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneAxesViewer */ "./Debug/boneAxesViewer.ts");
  26741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"]; });
  26742. /* harmony import */ var _debugLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./debugLayer */ "./Debug/debugLayer.ts");
  26743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _debugLayer__WEBPACK_IMPORTED_MODULE_2__["DebugLayer"]; });
  26744. /* harmony import */ var _physicsViewer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsViewer */ "./Debug/physicsViewer.ts");
  26745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _physicsViewer__WEBPACK_IMPORTED_MODULE_3__["PhysicsViewer"]; });
  26746. /* harmony import */ var _rayHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rayHelper */ "./Debug/rayHelper.ts");
  26747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _rayHelper__WEBPACK_IMPORTED_MODULE_4__["RayHelper"]; });
  26748. /* harmony import */ var _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./skeletonViewer */ "./Debug/skeletonViewer.ts");
  26749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__["SkeletonViewer"]; });
  26750. /***/ }),
  26751. /***/ "./Debug/physicsViewer.ts":
  26752. /*!********************************!*\
  26753. !*** ./Debug/physicsViewer.ts ***!
  26754. \********************************/
  26755. /*! exports provided: PhysicsViewer */
  26756. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26757. "use strict";
  26758. __webpack_require__.r(__webpack_exports__);
  26759. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return PhysicsViewer; });
  26760. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  26761. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  26762. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  26763. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26764. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  26765. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  26766. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  26767. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  26768. /**
  26769. * Used to show the physics impostor around the specific mesh
  26770. */
  26771. var PhysicsViewer = /** @class */ (function () {
  26772. /**
  26773. * Creates a new PhysicsViewer
  26774. * @param scene defines the hosting scene
  26775. */
  26776. function PhysicsViewer(scene) {
  26777. /** @hidden */
  26778. this._impostors = [];
  26779. /** @hidden */
  26780. this._meshes = [];
  26781. /** @hidden */
  26782. this._numMeshes = 0;
  26783. this._debugMeshMeshes = new Array();
  26784. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene;
  26785. var physicEngine = this._scene.getPhysicsEngine();
  26786. if (physicEngine) {
  26787. this._physicsEnginePlugin = physicEngine.getPhysicsPlugin();
  26788. }
  26789. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"](this._scene, false);
  26790. this._utilityLayer.pickUtilitySceneFirst = false;
  26791. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  26792. }
  26793. /** @hidden */
  26794. PhysicsViewer.prototype._updateDebugMeshes = function () {
  26795. var plugin = this._physicsEnginePlugin;
  26796. for (var i = 0; i < this._numMeshes; i++) {
  26797. var impostor = this._impostors[i];
  26798. if (!impostor) {
  26799. continue;
  26800. }
  26801. if (impostor.isDisposed) {
  26802. this.hideImpostor(this._impostors[i--]);
  26803. }
  26804. else {
  26805. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].MeshImpostor) {
  26806. continue;
  26807. }
  26808. var mesh = this._meshes[i];
  26809. if (mesh && plugin) {
  26810. plugin.syncMeshWithImpostor(mesh, impostor);
  26811. }
  26812. }
  26813. }
  26814. };
  26815. /**
  26816. * Renders a specified physic impostor
  26817. * @param impostor defines the impostor to render
  26818. * @param targetMesh defines the mesh represented by the impostor
  26819. * @returns the new debug mesh used to render the impostor
  26820. */
  26821. PhysicsViewer.prototype.showImpostor = function (impostor, targetMesh) {
  26822. if (!this._scene) {
  26823. return null;
  26824. }
  26825. for (var i = 0; i < this._numMeshes; i++) {
  26826. if (this._impostors[i] == impostor) {
  26827. return null;
  26828. }
  26829. }
  26830. var debugMesh = this._getDebugMesh(impostor, targetMesh);
  26831. if (debugMesh) {
  26832. this._impostors[this._numMeshes] = impostor;
  26833. this._meshes[this._numMeshes] = debugMesh;
  26834. if (this._numMeshes === 0) {
  26835. this._renderFunction = this._updateDebugMeshes.bind(this);
  26836. this._scene.registerBeforeRender(this._renderFunction);
  26837. }
  26838. this._numMeshes++;
  26839. }
  26840. return debugMesh;
  26841. };
  26842. /**
  26843. * Hides a specified physic impostor
  26844. * @param impostor defines the impostor to hide
  26845. */
  26846. PhysicsViewer.prototype.hideImpostor = function (impostor) {
  26847. if (!impostor || !this._scene || !this._utilityLayer) {
  26848. return;
  26849. }
  26850. var removed = false;
  26851. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  26852. for (var i = 0; i < this._numMeshes; i++) {
  26853. if (this._impostors[i] == impostor) {
  26854. var mesh = this._meshes[i];
  26855. if (!mesh) {
  26856. continue;
  26857. }
  26858. utilityLayerScene.removeMesh(mesh);
  26859. mesh.dispose();
  26860. var index = this._debugMeshMeshes.indexOf(mesh);
  26861. if (index > -1) {
  26862. this._debugMeshMeshes.splice(index, 1);
  26863. }
  26864. this._numMeshes--;
  26865. if (this._numMeshes > 0) {
  26866. this._meshes[i] = this._meshes[this._numMeshes];
  26867. this._impostors[i] = this._impostors[this._numMeshes];
  26868. this._meshes[this._numMeshes] = null;
  26869. this._impostors[this._numMeshes] = null;
  26870. }
  26871. else {
  26872. this._meshes[0] = null;
  26873. this._impostors[0] = null;
  26874. }
  26875. removed = true;
  26876. break;
  26877. }
  26878. }
  26879. if (removed && this._numMeshes === 0) {
  26880. this._scene.unregisterBeforeRender(this._renderFunction);
  26881. }
  26882. };
  26883. PhysicsViewer.prototype._getDebugMaterial = function (scene) {
  26884. if (!this._debugMaterial) {
  26885. this._debugMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]('', scene);
  26886. this._debugMaterial.wireframe = true;
  26887. this._debugMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].White();
  26888. this._debugMaterial.disableLighting = true;
  26889. }
  26890. return this._debugMaterial;
  26891. };
  26892. PhysicsViewer.prototype._getDebugBoxMesh = function (scene) {
  26893. if (!this._debugBoxMesh) {
  26894. this._debugBoxMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox('physicsBodyBoxViewMesh', { size: 1 }, scene);
  26895. this._debugBoxMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].Identity();
  26896. this._debugBoxMesh.material = this._getDebugMaterial(scene);
  26897. this._debugBoxMesh.setEnabled(false);
  26898. }
  26899. return this._debugBoxMesh.createInstance('physicsBodyBoxViewInstance');
  26900. };
  26901. PhysicsViewer.prototype._getDebugSphereMesh = function (scene) {
  26902. if (!this._debugSphereMesh) {
  26903. this._debugSphereMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__["SphereBuilder"].CreateSphere('physicsBodySphereViewMesh', { diameter: 1 }, scene);
  26904. this._debugSphereMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].Identity();
  26905. this._debugSphereMesh.material = this._getDebugMaterial(scene);
  26906. this._debugSphereMesh.setEnabled(false);
  26907. }
  26908. return this._debugSphereMesh.createInstance('physicsBodyBoxViewInstance');
  26909. };
  26910. PhysicsViewer.prototype._getDebugMeshMesh = function (mesh, scene) {
  26911. var wireframeOver = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](mesh.name, scene, null, mesh);
  26912. wireframeOver.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  26913. wireframeOver.setParent(mesh);
  26914. wireframeOver.material = this._getDebugMaterial(scene);
  26915. this._debugMeshMeshes.push(wireframeOver);
  26916. return wireframeOver;
  26917. };
  26918. PhysicsViewer.prototype._getDebugMesh = function (impostor, targetMesh) {
  26919. if (!this._utilityLayer) {
  26920. return null;
  26921. }
  26922. var mesh = null;
  26923. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  26924. switch (impostor.type) {
  26925. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].BoxImpostor:
  26926. mesh = this._getDebugBoxMesh(utilityLayerScene);
  26927. impostor.getBoxSizeToRef(mesh.scaling);
  26928. break;
  26929. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].SphereImpostor:
  26930. mesh = this._getDebugSphereMesh(utilityLayerScene);
  26931. var radius = impostor.getRadius();
  26932. mesh.scaling.x = radius * 2;
  26933. mesh.scaling.y = radius * 2;
  26934. mesh.scaling.z = radius * 2;
  26935. break;
  26936. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].MeshImpostor:
  26937. if (targetMesh) {
  26938. mesh = this._getDebugMeshMesh(targetMesh, utilityLayerScene);
  26939. }
  26940. break;
  26941. }
  26942. return mesh;
  26943. };
  26944. /** Releases all resources */
  26945. PhysicsViewer.prototype.dispose = function () {
  26946. var count = this._numMeshes;
  26947. for (var index = 0; index < count; index++) {
  26948. this.hideImpostor(this._impostors[0]);
  26949. }
  26950. if (this._debugBoxMesh) {
  26951. this._debugBoxMesh.dispose();
  26952. }
  26953. if (this._debugSphereMesh) {
  26954. this._debugSphereMesh.dispose();
  26955. }
  26956. if (this._debugMaterial) {
  26957. this._debugMaterial.dispose();
  26958. }
  26959. this._impostors.length = 0;
  26960. this._scene = null;
  26961. this._physicsEnginePlugin = null;
  26962. if (this._utilityLayer) {
  26963. this._utilityLayer.dispose();
  26964. this._utilityLayer = null;
  26965. }
  26966. };
  26967. return PhysicsViewer;
  26968. }());
  26969. /***/ }),
  26970. /***/ "./Debug/rayHelper.ts":
  26971. /*!****************************!*\
  26972. !*** ./Debug/rayHelper.ts ***!
  26973. \****************************/
  26974. /*! exports provided: RayHelper */
  26975. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26976. "use strict";
  26977. __webpack_require__.r(__webpack_exports__);
  26978. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return RayHelper; });
  26979. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26980. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  26981. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  26982. /**
  26983. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  26984. * in order to better appreciate the issue one might have.
  26985. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  26986. */
  26987. var RayHelper = /** @class */ (function () {
  26988. /**
  26989. * Instantiate a new ray helper.
  26990. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  26991. * in order to better appreciate the issue one might have.
  26992. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  26993. * @param ray Defines the ray we are currently tryin to visualize
  26994. */
  26995. function RayHelper(ray) {
  26996. this.ray = ray;
  26997. }
  26998. /**
  26999. * Helper function to create a colored helper in a scene in one line.
  27000. * @param ray Defines the ray we are currently tryin to visualize
  27001. * @param scene Defines the scene the ray is used in
  27002. * @param color Defines the color we want to see the ray in
  27003. * @returns The newly created ray helper.
  27004. */
  27005. RayHelper.CreateAndShow = function (ray, scene, color) {
  27006. var helper = new RayHelper(ray);
  27007. helper.show(scene, color);
  27008. return helper;
  27009. };
  27010. /**
  27011. * Shows the ray we are willing to debug.
  27012. * @param scene Defines the scene the ray needs to be rendered in
  27013. * @param color Defines the color the ray needs to be rendered in
  27014. */
  27015. RayHelper.prototype.show = function (scene, color) {
  27016. if (!this._renderFunction && this.ray) {
  27017. var ray = this.ray;
  27018. this._renderFunction = this._render.bind(this);
  27019. this._scene = scene;
  27020. this._renderPoints = [ray.origin, ray.origin.add(ray.direction.scale(ray.length))];
  27021. this._renderLine = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, scene, true);
  27022. if (this._renderFunction) {
  27023. this._scene.registerBeforeRender(this._renderFunction);
  27024. }
  27025. }
  27026. if (color && this._renderLine) {
  27027. this._renderLine.color.copyFrom(color);
  27028. }
  27029. };
  27030. /**
  27031. * Hides the ray we are debugging.
  27032. */
  27033. RayHelper.prototype.hide = function () {
  27034. if (this._renderFunction && this._scene) {
  27035. this._scene.unregisterBeforeRender(this._renderFunction);
  27036. this._scene = null;
  27037. this._renderFunction = null;
  27038. if (this._renderLine) {
  27039. this._renderLine.dispose();
  27040. this._renderLine = null;
  27041. }
  27042. this._renderPoints = [];
  27043. }
  27044. };
  27045. RayHelper.prototype._render = function () {
  27046. var ray = this.ray;
  27047. if (!ray) {
  27048. return;
  27049. }
  27050. var point = this._renderPoints[1];
  27051. var len = Math.min(ray.length, 1000000);
  27052. point.copyFrom(ray.direction);
  27053. point.scaleInPlace(len);
  27054. point.addInPlace(ray.origin);
  27055. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, this._scene, true, this._renderLine);
  27056. };
  27057. /**
  27058. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  27059. * @param mesh Defines the mesh we want the helper attached to
  27060. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  27061. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  27062. * @param length Defines the length of the ray
  27063. */
  27064. RayHelper.prototype.attachToMesh = function (mesh, meshSpaceDirection, meshSpaceOrigin, length) {
  27065. this._attachedToMesh = mesh;
  27066. var ray = this.ray;
  27067. if (!ray) {
  27068. return;
  27069. }
  27070. if (!ray.direction) {
  27071. ray.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  27072. }
  27073. if (!ray.origin) {
  27074. ray.origin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  27075. }
  27076. if (length) {
  27077. ray.length = length;
  27078. }
  27079. if (!meshSpaceOrigin) {
  27080. meshSpaceOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  27081. }
  27082. if (!meshSpaceDirection) {
  27083. // -1 so that this will work with Mesh.lookAt
  27084. meshSpaceDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1);
  27085. }
  27086. if (!this._meshSpaceDirection) {
  27087. this._meshSpaceDirection = meshSpaceDirection.clone();
  27088. this._meshSpaceOrigin = meshSpaceOrigin.clone();
  27089. }
  27090. else {
  27091. this._meshSpaceDirection.copyFrom(meshSpaceDirection);
  27092. this._meshSpaceOrigin.copyFrom(meshSpaceOrigin);
  27093. }
  27094. if (!this._updateToMeshFunction) {
  27095. this._updateToMeshFunction = this._updateToMesh.bind(this);
  27096. this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction);
  27097. }
  27098. this._updateToMesh();
  27099. };
  27100. /**
  27101. * Detach the ray helper from the mesh it has previously been attached to.
  27102. */
  27103. RayHelper.prototype.detachFromMesh = function () {
  27104. if (this._attachedToMesh) {
  27105. if (this._updateToMeshFunction) {
  27106. this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction);
  27107. }
  27108. this._attachedToMesh = null;
  27109. this._updateToMeshFunction = null;
  27110. }
  27111. };
  27112. RayHelper.prototype._updateToMesh = function () {
  27113. var ray = this.ray;
  27114. if (!this._attachedToMesh || !ray) {
  27115. return;
  27116. }
  27117. if (this._attachedToMesh._isDisposed) {
  27118. this.detachFromMesh();
  27119. return;
  27120. }
  27121. this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection, ray.direction);
  27122. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._meshSpaceOrigin, this._attachedToMesh.getWorldMatrix(), ray.origin);
  27123. };
  27124. /**
  27125. * Dispose the helper and release its associated resources.
  27126. */
  27127. RayHelper.prototype.dispose = function () {
  27128. this.hide();
  27129. this.detachFromMesh();
  27130. this.ray = null;
  27131. };
  27132. return RayHelper;
  27133. }());
  27134. /***/ }),
  27135. /***/ "./Debug/skeletonViewer.ts":
  27136. /*!*********************************!*\
  27137. !*** ./Debug/skeletonViewer.ts ***!
  27138. \*********************************/
  27139. /*! exports provided: SkeletonViewer */
  27140. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27141. "use strict";
  27142. __webpack_require__.r(__webpack_exports__);
  27143. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return SkeletonViewer; });
  27144. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  27145. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  27146. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  27147. /**
  27148. * Class used to render a debug view of a given skeleton
  27149. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  27150. */
  27151. var SkeletonViewer = /** @class */ (function () {
  27152. /**
  27153. * Creates a new SkeletonViewer
  27154. * @param skeleton defines the skeleton to render
  27155. * @param mesh defines the mesh attached to the skeleton
  27156. * @param scene defines the hosting scene
  27157. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  27158. * @param renderingGroupId defines the rendering group id to use with the viewer
  27159. */
  27160. function SkeletonViewer(
  27161. /** defines the skeleton to render */
  27162. skeleton,
  27163. /** defines the mesh attached to the skeleton */
  27164. mesh, scene,
  27165. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  27166. autoUpdateBonesMatrices,
  27167. /** defines the rendering group id to use with the viewer */
  27168. renderingGroupId) {
  27169. if (autoUpdateBonesMatrices === void 0) { autoUpdateBonesMatrices = true; }
  27170. if (renderingGroupId === void 0) { renderingGroupId = 1; }
  27171. this.skeleton = skeleton;
  27172. this.mesh = mesh;
  27173. this.autoUpdateBonesMatrices = autoUpdateBonesMatrices;
  27174. this.renderingGroupId = renderingGroupId;
  27175. /** Gets or sets the color used to render the skeleton */
  27176. this.color = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
  27177. this._debugLines = new Array();
  27178. this._isEnabled = false;
  27179. this._scene = scene;
  27180. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"](this._scene, false);
  27181. this._utilityLayer.pickUtilitySceneFirst = false;
  27182. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  27183. this.update();
  27184. this._renderFunction = this.update.bind(this);
  27185. }
  27186. Object.defineProperty(SkeletonViewer.prototype, "debugMesh", {
  27187. /**
  27188. * Returns the mesh used to render the bones
  27189. */
  27190. get: function () {
  27191. return this._debugMesh;
  27192. },
  27193. enumerable: true,
  27194. configurable: true
  27195. });
  27196. Object.defineProperty(SkeletonViewer.prototype, "isEnabled", {
  27197. get: function () {
  27198. return this._isEnabled;
  27199. },
  27200. /** Gets or sets a boolean indicating if the viewer is enabled */
  27201. set: function (value) {
  27202. if (this._isEnabled === value) {
  27203. return;
  27204. }
  27205. this._isEnabled = value;
  27206. if (value) {
  27207. this._scene.registerBeforeRender(this._renderFunction);
  27208. }
  27209. else {
  27210. this._scene.unregisterBeforeRender(this._renderFunction);
  27211. }
  27212. },
  27213. enumerable: true,
  27214. configurable: true
  27215. });
  27216. SkeletonViewer.prototype._getBonePosition = function (position, bone, meshMat, x, y, z) {
  27217. if (x === void 0) { x = 0; }
  27218. if (y === void 0) { y = 0; }
  27219. if (z === void 0) { z = 0; }
  27220. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  27221. var parentBone = bone.getParent();
  27222. tmat.copyFrom(bone.getLocalMatrix());
  27223. if (x !== 0 || y !== 0 || z !== 0) {
  27224. var tmat2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  27225. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(tmat2);
  27226. tmat2.setTranslationFromFloats(x, y, z);
  27227. tmat2.multiplyToRef(tmat, tmat);
  27228. }
  27229. if (parentBone) {
  27230. tmat.multiplyToRef(parentBone.getAbsoluteTransform(), tmat);
  27231. }
  27232. tmat.multiplyToRef(meshMat, tmat);
  27233. position.x = tmat.m[12];
  27234. position.y = tmat.m[13];
  27235. position.z = tmat.m[14];
  27236. };
  27237. SkeletonViewer.prototype._getLinesForBonesWithLength = function (bones, meshMat) {
  27238. var len = bones.length;
  27239. var mesh = this.mesh._effectiveMesh;
  27240. var meshPos = mesh.position;
  27241. for (var i = 0; i < len; i++) {
  27242. var bone = bones[i];
  27243. var points = this._debugLines[i];
  27244. if (!points) {
  27245. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  27246. this._debugLines[i] = points;
  27247. }
  27248. this._getBonePosition(points[0], bone, meshMat);
  27249. this._getBonePosition(points[1], bone, meshMat, 0, bone.length, 0);
  27250. points[0].subtractInPlace(meshPos);
  27251. points[1].subtractInPlace(meshPos);
  27252. }
  27253. };
  27254. SkeletonViewer.prototype._getLinesForBonesNoLength = function (bones, meshMat) {
  27255. var len = bones.length;
  27256. var boneNum = 0;
  27257. var mesh = this.mesh._effectiveMesh;
  27258. var meshPos = mesh.position;
  27259. for (var i = len - 1; i >= 0; i--) {
  27260. var childBone = bones[i];
  27261. var parentBone = childBone.getParent();
  27262. if (!parentBone) {
  27263. continue;
  27264. }
  27265. var points = this._debugLines[boneNum];
  27266. if (!points) {
  27267. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  27268. this._debugLines[boneNum] = points;
  27269. }
  27270. childBone.getAbsolutePositionToRef(mesh, points[0]);
  27271. parentBone.getAbsolutePositionToRef(mesh, points[1]);
  27272. points[0].subtractInPlace(meshPos);
  27273. points[1].subtractInPlace(meshPos);
  27274. boneNum++;
  27275. }
  27276. };
  27277. /** Update the viewer to sync with current skeleton state */
  27278. SkeletonViewer.prototype.update = function () {
  27279. if (!this._utilityLayer) {
  27280. return;
  27281. }
  27282. if (this.autoUpdateBonesMatrices) {
  27283. this.skeleton.computeAbsoluteTransforms();
  27284. }
  27285. var mesh = this.mesh._effectiveMesh;
  27286. if (this.skeleton.bones[0].length === undefined) {
  27287. this._getLinesForBonesNoLength(this.skeleton.bones, mesh.getWorldMatrix());
  27288. }
  27289. else {
  27290. this._getLinesForBonesWithLength(this.skeleton.bones, mesh.getWorldMatrix());
  27291. }
  27292. var targetScene = this._utilityLayer.utilityLayerScene;
  27293. if (!this._debugMesh) {
  27294. this._debugMesh = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: null }, targetScene);
  27295. this._debugMesh.renderingGroupId = this.renderingGroupId;
  27296. }
  27297. else {
  27298. _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: this._debugMesh }, targetScene);
  27299. }
  27300. this._debugMesh.position.copyFrom(this.mesh.position);
  27301. this._debugMesh.color = this.color;
  27302. };
  27303. /** Release associated resources */
  27304. SkeletonViewer.prototype.dispose = function () {
  27305. this.isEnabled = false;
  27306. if (this._debugMesh) {
  27307. this.isEnabled = false;
  27308. this._debugMesh.dispose();
  27309. this._debugMesh = null;
  27310. }
  27311. if (this._utilityLayer) {
  27312. this._utilityLayer.dispose();
  27313. this._utilityLayer = null;
  27314. }
  27315. };
  27316. return SkeletonViewer;
  27317. }());
  27318. /***/ }),
  27319. /***/ "./Engines/Extensions/engine.multiview.ts":
  27320. /*!************************************************!*\
  27321. !*** ./Engines/Extensions/engine.multiview.ts ***!
  27322. \************************************************/
  27323. /*! no exports provided */
  27324. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27325. "use strict";
  27326. __webpack_require__.r(__webpack_exports__);
  27327. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  27328. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  27329. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  27330. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  27331. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  27332. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  27333. /* harmony import */ var _Materials_Textures_MultiviewRenderTarget__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/Textures/MultiviewRenderTarget */ "./Materials/Textures/MultiviewRenderTarget.ts");
  27334. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].prototype.createMultiviewRenderTargetTexture = function (width, height) {
  27335. var gl = this._gl;
  27336. if (!this.getCaps().multiview) {
  27337. throw "Multiview is not supported";
  27338. }
  27339. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_UNKNOWN, true);
  27340. internalTexture.width = width;
  27341. internalTexture.height = height;
  27342. internalTexture._framebuffer = gl.createFramebuffer();
  27343. internalTexture._colorTextureArray = gl.createTexture();
  27344. gl.bindTexture(gl.TEXTURE_2D_ARRAY, internalTexture._colorTextureArray);
  27345. gl.texStorage3D(gl.TEXTURE_2D_ARRAY, 1, gl.RGBA8, width, height, 2);
  27346. internalTexture._depthStencilTextureArray = gl.createTexture();
  27347. gl.bindTexture(gl.TEXTURE_2D_ARRAY, internalTexture._depthStencilTextureArray);
  27348. gl.texStorage3D(gl.TEXTURE_2D_ARRAY, 1, gl.DEPTH32F_STENCIL8, width, height, 2);
  27349. internalTexture.isReady = true;
  27350. return internalTexture;
  27351. };
  27352. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].prototype.bindMultiviewFramebuffer = function (multiviewTexture) {
  27353. var gl = this._gl;
  27354. var ext = this.getCaps().multiview;
  27355. this.bindFramebuffer(multiviewTexture, undefined, undefined, undefined, true);
  27356. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, multiviewTexture._framebuffer);
  27357. if (multiviewTexture._colorTextureArray && multiviewTexture._depthStencilTextureArray) {
  27358. ext.framebufferTextureMultiviewWEBGL(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, multiviewTexture._colorTextureArray, 0, 0, 2);
  27359. ext.framebufferTextureMultiviewWEBGL(gl.DRAW_FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, multiviewTexture._depthStencilTextureArray, 0, 0, 2);
  27360. }
  27361. else {
  27362. throw "Invalid multiview frame buffer";
  27363. }
  27364. };
  27365. _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].prototype._useMultiviewToSingleView = false;
  27366. _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].prototype._multiviewTexture = null;
  27367. _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].prototype._resizeOrCreateMultiviewTexture = function (width, height) {
  27368. if (!this._multiviewTexture) {
  27369. this._multiviewTexture = new _Materials_Textures_MultiviewRenderTarget__WEBPACK_IMPORTED_MODULE_6__["MultiviewRenderTarget"](this.getScene(), { width: width, height: height });
  27370. }
  27371. else if (this._multiviewTexture.getRenderWidth() != width || this._multiviewTexture.getRenderHeight() != height) {
  27372. this._multiviewTexture.dispose();
  27373. this._multiviewTexture = new _Materials_Textures_MultiviewRenderTarget__WEBPACK_IMPORTED_MODULE_6__["MultiviewRenderTarget"](this.getScene(), { width: width, height: height });
  27374. }
  27375. };
  27376. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._transformMatrixR = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  27377. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._multiviewSceneUbo = null;
  27378. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._createMultiviewUbo = function () {
  27379. this._multiviewSceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_5__["UniformBuffer"](this.getEngine(), undefined, true);
  27380. this._multiviewSceneUbo.addUniform("viewProjection", 16);
  27381. this._multiviewSceneUbo.addUniform("viewProjectionR", 16);
  27382. this._multiviewSceneUbo.addUniform("view", 16);
  27383. };
  27384. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._updateMultiviewUbo = function (viewR, projectionR) {
  27385. if (viewR && projectionR) {
  27386. viewR.multiplyToRef(projectionR, this._transformMatrixR);
  27387. }
  27388. if (viewR && projectionR) {
  27389. viewR.multiplyToRef(projectionR, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0]);
  27390. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Frustum"].GetRightPlaneToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0], this._frustumPlanes[3]); // Replace right plane by second camera right plane
  27391. }
  27392. if (this._multiviewSceneUbo) {
  27393. this._multiviewSceneUbo.updateMatrix("viewProjection", this.getTransformMatrix());
  27394. this._multiviewSceneUbo.updateMatrix("viewProjectionR", this._transformMatrixR);
  27395. this._multiviewSceneUbo.updateMatrix("view", this._viewMatrix);
  27396. this._multiviewSceneUbo.update();
  27397. }
  27398. };
  27399. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._renderMultiviewToSingleView = function (camera) {
  27400. // Multiview is only able to be displayed directly for API's such as webXR
  27401. // This displays a multiview image by rendering to the multiview image and then
  27402. // copying the result into the sub cameras instead of rendering them and proceeding as normal from there
  27403. // Render to a multiview texture
  27404. camera._resizeOrCreateMultiviewTexture((camera._rigPostProcess && camera._rigPostProcess && camera._rigPostProcess.width > 0) ? camera._rigPostProcess.width / 2 : this.getEngine().getRenderWidth(true) / 2, (camera._rigPostProcess && camera._rigPostProcess && camera._rigPostProcess.height > 0) ? camera._rigPostProcess.height : this.getEngine().getRenderHeight(true));
  27405. if (!this._multiviewSceneUbo) {
  27406. this._createMultiviewUbo();
  27407. }
  27408. camera.outputRenderTarget = camera._multiviewTexture;
  27409. this._renderForCamera(camera);
  27410. camera.outputRenderTarget = null;
  27411. // Consume the multiview texture through a shader for each eye
  27412. for (var index = 0; index < camera._rigCameras.length; index++) {
  27413. var engine = this.getEngine();
  27414. this._activeCamera = camera._rigCameras[index];
  27415. engine.setViewport(this._activeCamera.viewport);
  27416. if (this.postProcessManager) {
  27417. this.postProcessManager._prepareFrame();
  27418. this.postProcessManager._finalizeFrame(this._activeCamera.isIntermediate);
  27419. }
  27420. }
  27421. };
  27422. /***/ }),
  27423. /***/ "./Engines/Extensions/engine.occlusionQuery.ts":
  27424. /*!*****************************************************!*\
  27425. !*** ./Engines/Extensions/engine.occlusionQuery.ts ***!
  27426. \*****************************************************/
  27427. /*! exports provided: _OcclusionDataStorage */
  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__, "_OcclusionDataStorage", function() { return _OcclusionDataStorage; });
  27432. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  27433. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  27434. /* harmony import */ var _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Instrumentation/timeToken */ "./Instrumentation/timeToken.ts");
  27435. /** @hidden */
  27436. var _OcclusionDataStorage = /** @class */ (function () {
  27437. function _OcclusionDataStorage() {
  27438. /** @hidden */
  27439. this.occlusionInternalRetryCounter = 0;
  27440. /** @hidden */
  27441. this.isOcclusionQueryInProgress = false;
  27442. /** @hidden */
  27443. this.isOccluded = false;
  27444. /** @hidden */
  27445. this.occlusionRetryCount = -1;
  27446. /** @hidden */
  27447. this.occlusionType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE;
  27448. /** @hidden */
  27449. this.occlusionQueryAlgorithmType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE;
  27450. }
  27451. return _OcclusionDataStorage;
  27452. }());
  27453. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createQuery = function () {
  27454. return this._gl.createQuery();
  27455. };
  27456. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteQuery = function (query) {
  27457. this._gl.deleteQuery(query);
  27458. return this;
  27459. };
  27460. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.isQueryResultAvailable = function (query) {
  27461. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT_AVAILABLE);
  27462. };
  27463. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.getQueryResult = function (query) {
  27464. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT);
  27465. };
  27466. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginOcclusionQuery = function (algorithmType, query) {
  27467. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  27468. this._gl.beginQuery(glAlgorithm, query);
  27469. return this;
  27470. };
  27471. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endOcclusionQuery = function (algorithmType) {
  27472. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  27473. this._gl.endQuery(glAlgorithm);
  27474. return this;
  27475. };
  27476. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._createTimeQuery = function () {
  27477. var timerQuery = this.getCaps().timerQuery;
  27478. if (timerQuery.createQueryEXT) {
  27479. return timerQuery.createQueryEXT();
  27480. }
  27481. return this.createQuery();
  27482. };
  27483. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._deleteTimeQuery = function (query) {
  27484. var timerQuery = this.getCaps().timerQuery;
  27485. if (timerQuery.deleteQueryEXT) {
  27486. timerQuery.deleteQueryEXT(query);
  27487. return;
  27488. }
  27489. this.deleteQuery(query);
  27490. };
  27491. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryResult = function (query) {
  27492. var timerQuery = this.getCaps().timerQuery;
  27493. if (timerQuery.getQueryObjectEXT) {
  27494. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_EXT);
  27495. }
  27496. return this.getQueryResult(query);
  27497. };
  27498. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryAvailability = function (query) {
  27499. var timerQuery = this.getCaps().timerQuery;
  27500. if (timerQuery.getQueryObjectEXT) {
  27501. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_AVAILABLE_EXT);
  27502. }
  27503. return this.isQueryResultAvailable(query);
  27504. };
  27505. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.startTimeQuery = function () {
  27506. var caps = this.getCaps();
  27507. var timerQuery = caps.timerQuery;
  27508. if (!timerQuery) {
  27509. return null;
  27510. }
  27511. var token = new _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]();
  27512. this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  27513. if (caps.canUseTimestampForTimerQuery) {
  27514. token._startTimeQuery = this._createTimeQuery();
  27515. timerQuery.queryCounterEXT(token._startTimeQuery, timerQuery.TIMESTAMP_EXT);
  27516. }
  27517. else {
  27518. if (this._currentNonTimestampToken) {
  27519. return this._currentNonTimestampToken;
  27520. }
  27521. token._timeElapsedQuery = this._createTimeQuery();
  27522. if (timerQuery.beginQueryEXT) {
  27523. timerQuery.beginQueryEXT(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  27524. }
  27525. else {
  27526. this._gl.beginQuery(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  27527. }
  27528. this._currentNonTimestampToken = token;
  27529. }
  27530. return token;
  27531. };
  27532. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTimeQuery = function (token) {
  27533. var caps = this.getCaps();
  27534. var timerQuery = caps.timerQuery;
  27535. if (!timerQuery || !token) {
  27536. return -1;
  27537. }
  27538. if (caps.canUseTimestampForTimerQuery) {
  27539. if (!token._startTimeQuery) {
  27540. return -1;
  27541. }
  27542. if (!token._endTimeQuery) {
  27543. token._endTimeQuery = this._createTimeQuery();
  27544. timerQuery.queryCounterEXT(token._endTimeQuery, timerQuery.TIMESTAMP_EXT);
  27545. }
  27546. }
  27547. else if (!token._timeElapsedQueryEnded) {
  27548. if (!token._timeElapsedQuery) {
  27549. return -1;
  27550. }
  27551. if (timerQuery.endQueryEXT) {
  27552. timerQuery.endQueryEXT(timerQuery.TIME_ELAPSED_EXT);
  27553. }
  27554. else {
  27555. this._gl.endQuery(timerQuery.TIME_ELAPSED_EXT);
  27556. }
  27557. token._timeElapsedQueryEnded = true;
  27558. }
  27559. var disjoint = this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  27560. var available = false;
  27561. if (token._endTimeQuery) {
  27562. available = this._getTimeQueryAvailability(token._endTimeQuery);
  27563. }
  27564. else if (token._timeElapsedQuery) {
  27565. available = this._getTimeQueryAvailability(token._timeElapsedQuery);
  27566. }
  27567. if (available && !disjoint) {
  27568. var result = 0;
  27569. if (caps.canUseTimestampForTimerQuery) {
  27570. if (!token._startTimeQuery || !token._endTimeQuery) {
  27571. return -1;
  27572. }
  27573. var timeStart = this._getTimeQueryResult(token._startTimeQuery);
  27574. var timeEnd = this._getTimeQueryResult(token._endTimeQuery);
  27575. result = timeEnd - timeStart;
  27576. this._deleteTimeQuery(token._startTimeQuery);
  27577. this._deleteTimeQuery(token._endTimeQuery);
  27578. token._startTimeQuery = null;
  27579. token._endTimeQuery = null;
  27580. }
  27581. else {
  27582. if (!token._timeElapsedQuery) {
  27583. return -1;
  27584. }
  27585. result = this._getTimeQueryResult(token._timeElapsedQuery);
  27586. this._deleteTimeQuery(token._timeElapsedQuery);
  27587. token._timeElapsedQuery = null;
  27588. token._timeElapsedQueryEnded = false;
  27589. this._currentNonTimestampToken = null;
  27590. }
  27591. return result;
  27592. }
  27593. return -1;
  27594. };
  27595. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getGlAlgorithmType = function (algorithmType) {
  27596. return algorithmType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED;
  27597. };
  27598. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOcclusionQueryInProgress", {
  27599. get: function () {
  27600. return this._occlusionDataStorage.isOcclusionQueryInProgress;
  27601. },
  27602. enumerable: false,
  27603. configurable: true
  27604. });
  27605. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "_occlusionDataStorage", {
  27606. get: function () {
  27607. if (!this.__occlusionDataStorage) {
  27608. this.__occlusionDataStorage = new _OcclusionDataStorage();
  27609. }
  27610. return this.__occlusionDataStorage;
  27611. },
  27612. enumerable: false,
  27613. configurable: true
  27614. });
  27615. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOccluded", {
  27616. get: function () {
  27617. return this._occlusionDataStorage.isOccluded;
  27618. },
  27619. set: function (value) {
  27620. this._occlusionDataStorage.isOccluded = value;
  27621. },
  27622. enumerable: true,
  27623. configurable: true
  27624. });
  27625. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionQueryAlgorithmType", {
  27626. get: function () {
  27627. return this._occlusionDataStorage.occlusionQueryAlgorithmType;
  27628. },
  27629. set: function (value) {
  27630. this._occlusionDataStorage.occlusionQueryAlgorithmType = value;
  27631. },
  27632. enumerable: true,
  27633. configurable: true
  27634. });
  27635. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionType", {
  27636. get: function () {
  27637. return this._occlusionDataStorage.occlusionType;
  27638. },
  27639. set: function (value) {
  27640. this._occlusionDataStorage.occlusionType = value;
  27641. },
  27642. enumerable: true,
  27643. configurable: true
  27644. });
  27645. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionRetryCount", {
  27646. get: function () {
  27647. return this._occlusionDataStorage.occlusionRetryCount;
  27648. },
  27649. set: function (value) {
  27650. this._occlusionDataStorage.occlusionRetryCount = value;
  27651. },
  27652. enumerable: true,
  27653. configurable: true
  27654. });
  27655. // We also need to update AbstractMesh as there is a portion of the code there
  27656. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype._checkOcclusionQuery = function () {
  27657. var dataStorage = this._occlusionDataStorage;
  27658. if (dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE) {
  27659. dataStorage.isOccluded = false;
  27660. return false;
  27661. }
  27662. var engine = this.getEngine();
  27663. if (engine.webGLVersion < 2) {
  27664. dataStorage.isOccluded = false;
  27665. return false;
  27666. }
  27667. if (!engine.isQueryResultAvailable) { // Occlusion query where not referenced
  27668. dataStorage.isOccluded = false;
  27669. return false;
  27670. }
  27671. if (this.isOcclusionQueryInProgress && this._occlusionQuery) {
  27672. var isOcclusionQueryAvailable = engine.isQueryResultAvailable(this._occlusionQuery);
  27673. if (isOcclusionQueryAvailable) {
  27674. var occlusionQueryResult = engine.getQueryResult(this._occlusionQuery);
  27675. dataStorage.isOcclusionQueryInProgress = false;
  27676. dataStorage.occlusionInternalRetryCounter = 0;
  27677. dataStorage.isOccluded = occlusionQueryResult === 1 ? false : true;
  27678. }
  27679. else {
  27680. dataStorage.occlusionInternalRetryCounter++;
  27681. if (dataStorage.occlusionRetryCount !== -1 && dataStorage.occlusionInternalRetryCounter > dataStorage.occlusionRetryCount) {
  27682. dataStorage.isOcclusionQueryInProgress = false;
  27683. dataStorage.occlusionInternalRetryCounter = 0;
  27684. // if optimistic set isOccluded to false regardless of the status of isOccluded. (Render in the current render loop)
  27685. // if strict continue the last state of the object.
  27686. dataStorage.isOccluded = dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_OPTIMISTIC ? false : dataStorage.isOccluded;
  27687. }
  27688. else {
  27689. return false;
  27690. }
  27691. }
  27692. }
  27693. var scene = this.getScene();
  27694. if (scene.getBoundingBoxRenderer) {
  27695. var occlusionBoundingBoxRenderer = scene.getBoundingBoxRenderer();
  27696. if (!this._occlusionQuery) {
  27697. this._occlusionQuery = engine.createQuery();
  27698. }
  27699. engine.beginOcclusionQuery(dataStorage.occlusionQueryAlgorithmType, this._occlusionQuery);
  27700. occlusionBoundingBoxRenderer.renderOcclusionBoundingBox(this);
  27701. engine.endOcclusionQuery(dataStorage.occlusionQueryAlgorithmType);
  27702. this._occlusionDataStorage.isOcclusionQueryInProgress = true;
  27703. }
  27704. return dataStorage.isOccluded;
  27705. };
  27706. /***/ }),
  27707. /***/ "./Engines/Extensions/engine.transformFeedback.ts":
  27708. /*!********************************************************!*\
  27709. !*** ./Engines/Extensions/engine.transformFeedback.ts ***!
  27710. \********************************************************/
  27711. /*! exports provided: _forceTransformFeedbackToBundle */
  27712. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27713. "use strict";
  27714. __webpack_require__.r(__webpack_exports__);
  27715. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _forceTransformFeedbackToBundle; });
  27716. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  27717. /** @hidden */
  27718. var _forceTransformFeedbackToBundle = true;
  27719. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createTransformFeedback = function () {
  27720. return this._gl.createTransformFeedback();
  27721. };
  27722. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteTransformFeedback = function (value) {
  27723. this._gl.deleteTransformFeedback(value);
  27724. };
  27725. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedback = function (value) {
  27726. this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, value);
  27727. };
  27728. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginTransformFeedback = function (usePoints) {
  27729. if (usePoints === void 0) { usePoints = true; }
  27730. this._gl.beginTransformFeedback(usePoints ? this._gl.POINTS : this._gl.TRIANGLES);
  27731. };
  27732. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTransformFeedback = function () {
  27733. this._gl.endTransformFeedback();
  27734. };
  27735. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.setTranformFeedbackVaryings = function (program, value) {
  27736. this._gl.transformFeedbackVaryings(program, value, this._gl.INTERLEAVED_ATTRIBS);
  27737. };
  27738. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedbackBuffer = function (value) {
  27739. this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, value);
  27740. };
  27741. /***/ }),
  27742. /***/ "./Engines/Extensions/index.ts":
  27743. /*!*************************************!*\
  27744. !*** ./Engines/Extensions/index.ts ***!
  27745. \*************************************/
  27746. /*! exports provided: _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  27747. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27748. "use strict";
  27749. __webpack_require__.r(__webpack_exports__);
  27750. /* harmony import */ var _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.occlusionQuery */ "./Engines/Extensions/engine.occlusionQuery.ts");
  27751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  27752. /* harmony import */ var _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.transformFeedback */ "./Engines/Extensions/engine.transformFeedback.ts");
  27753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__["_forceTransformFeedbackToBundle"]; });
  27754. /***/ }),
  27755. /***/ "./Engines/constants.ts":
  27756. /*!******************************!*\
  27757. !*** ./Engines/constants.ts ***!
  27758. \******************************/
  27759. /*! exports provided: Constants */
  27760. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27761. "use strict";
  27762. __webpack_require__.r(__webpack_exports__);
  27763. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return Constants; });
  27764. /** Defines the cross module used constants to avoid circular dependncies */
  27765. var Constants = /** @class */ (function () {
  27766. function Constants() {
  27767. }
  27768. /** Defines that alpha blending is disabled */
  27769. Constants.ALPHA_DISABLE = 0;
  27770. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27771. Constants.ALPHA_ADD = 1;
  27772. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27773. Constants.ALPHA_COMBINE = 2;
  27774. /** Defines that alpha blending to DEST - SRC * DEST */
  27775. Constants.ALPHA_SUBTRACT = 3;
  27776. /** Defines that alpha blending to SRC * DEST */
  27777. Constants.ALPHA_MULTIPLY = 4;
  27778. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27779. Constants.ALPHA_MAXIMIZED = 5;
  27780. /** Defines that alpha blending to SRC + DEST */
  27781. Constants.ALPHA_ONEONE = 6;
  27782. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27783. Constants.ALPHA_PREMULTIPLIED = 7;
  27784. /**
  27785. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27786. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27787. */
  27788. Constants.ALPHA_PREMULTIPLIED_PORTERDUFF = 8;
  27789. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27790. Constants.ALPHA_INTERPOLATE = 9;
  27791. /**
  27792. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27793. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27794. */
  27795. Constants.ALPHA_SCREENMODE = 10;
  27796. /** Defines that the ressource is not delayed*/
  27797. Constants.DELAYLOADSTATE_NONE = 0;
  27798. /** Defines that the ressource was successfully delay loaded */
  27799. Constants.DELAYLOADSTATE_LOADED = 1;
  27800. /** Defines that the ressource is currently delay loading */
  27801. Constants.DELAYLOADSTATE_LOADING = 2;
  27802. /** Defines that the ressource is delayed and has not started loading */
  27803. Constants.DELAYLOADSTATE_NOTLOADED = 4;
  27804. // Depht or Stencil test Constants.
  27805. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27806. Constants.NEVER = 0x0200;
  27807. /** 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 */
  27808. Constants.ALWAYS = 0x0207;
  27809. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27810. Constants.LESS = 0x0201;
  27811. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27812. Constants.EQUAL = 0x0202;
  27813. /** 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 */
  27814. Constants.LEQUAL = 0x0203;
  27815. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27816. Constants.GREATER = 0x0204;
  27817. /** 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 */
  27818. Constants.GEQUAL = 0x0206;
  27819. /** 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 */
  27820. Constants.NOTEQUAL = 0x0205;
  27821. // Stencil Actions Constants.
  27822. /** Passed to stencilOperation to specify that stencil value must be kept */
  27823. Constants.KEEP = 0x1E00;
  27824. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27825. Constants.REPLACE = 0x1E01;
  27826. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27827. Constants.INCR = 0x1E02;
  27828. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27829. Constants.DECR = 0x1E03;
  27830. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27831. Constants.INVERT = 0x150A;
  27832. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27833. Constants.INCR_WRAP = 0x8507;
  27834. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27835. Constants.DECR_WRAP = 0x8508;
  27836. /** Texture is not repeating outside of 0..1 UVs */
  27837. Constants.TEXTURE_CLAMP_ADDRESSMODE = 0;
  27838. /** Texture is repeating outside of 0..1 UVs */
  27839. Constants.TEXTURE_WRAP_ADDRESSMODE = 1;
  27840. /** Texture is repeating and mirrored */
  27841. Constants.TEXTURE_MIRROR_ADDRESSMODE = 2;
  27842. /** ALPHA */
  27843. Constants.TEXTUREFORMAT_ALPHA = 0;
  27844. /** LUMINANCE */
  27845. Constants.TEXTUREFORMAT_LUMINANCE = 1;
  27846. /** LUMINANCE_ALPHA */
  27847. Constants.TEXTUREFORMAT_LUMINANCE_ALPHA = 2;
  27848. /** RGB */
  27849. Constants.TEXTUREFORMAT_RGB = 4;
  27850. /** RGBA */
  27851. Constants.TEXTUREFORMAT_RGBA = 5;
  27852. /** RED */
  27853. Constants.TEXTUREFORMAT_RED = 6;
  27854. /** RED (2nd reference) */
  27855. Constants.TEXTUREFORMAT_R = 6;
  27856. /** RG */
  27857. Constants.TEXTUREFORMAT_RG = 7;
  27858. /** RED_INTEGER */
  27859. Constants.TEXTUREFORMAT_RED_INTEGER = 8;
  27860. /** RED_INTEGER (2nd reference) */
  27861. Constants.TEXTUREFORMAT_R_INTEGER = 8;
  27862. /** RG_INTEGER */
  27863. Constants.TEXTUREFORMAT_RG_INTEGER = 9;
  27864. /** RGB_INTEGER */
  27865. Constants.TEXTUREFORMAT_RGB_INTEGER = 10;
  27866. /** RGBA_INTEGER */
  27867. Constants.TEXTUREFORMAT_RGBA_INTEGER = 11;
  27868. /** UNSIGNED_BYTE */
  27869. Constants.TEXTURETYPE_UNSIGNED_BYTE = 0;
  27870. /** UNSIGNED_BYTE (2nd reference) */
  27871. Constants.TEXTURETYPE_UNSIGNED_INT = 0;
  27872. /** FLOAT */
  27873. Constants.TEXTURETYPE_FLOAT = 1;
  27874. /** HALF_FLOAT */
  27875. Constants.TEXTURETYPE_HALF_FLOAT = 2;
  27876. /** BYTE */
  27877. Constants.TEXTURETYPE_BYTE = 3;
  27878. /** SHORT */
  27879. Constants.TEXTURETYPE_SHORT = 4;
  27880. /** UNSIGNED_SHORT */
  27881. Constants.TEXTURETYPE_UNSIGNED_SHORT = 5;
  27882. /** INT */
  27883. Constants.TEXTURETYPE_INT = 6;
  27884. /** UNSIGNED_INT */
  27885. Constants.TEXTURETYPE_UNSIGNED_INTEGER = 7;
  27886. /** UNSIGNED_SHORT_4_4_4_4 */
  27887. Constants.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8;
  27888. /** UNSIGNED_SHORT_5_5_5_1 */
  27889. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9;
  27890. /** UNSIGNED_SHORT_5_6_5 */
  27891. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10;
  27892. /** UNSIGNED_INT_2_10_10_10_REV */
  27893. Constants.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11;
  27894. /** UNSIGNED_INT_24_8 */
  27895. Constants.TEXTURETYPE_UNSIGNED_INT_24_8 = 12;
  27896. /** UNSIGNED_INT_10F_11F_11F_REV */
  27897. Constants.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13;
  27898. /** UNSIGNED_INT_5_9_9_9_REV */
  27899. Constants.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14;
  27900. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27901. Constants.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15;
  27902. /** nearest is mag = nearest and min = nearest and mip = linear */
  27903. Constants.TEXTURE_NEAREST_SAMPLINGMODE = 1;
  27904. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27905. Constants.TEXTURE_BILINEAR_SAMPLINGMODE = 2;
  27906. /** Trilinear is mag = linear and min = linear and mip = linear */
  27907. Constants.TEXTURE_TRILINEAR_SAMPLINGMODE = 3;
  27908. /** nearest is mag = nearest and min = nearest and mip = linear */
  27909. Constants.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 1;
  27910. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27911. Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 2;
  27912. /** Trilinear is mag = linear and min = linear and mip = linear */
  27913. Constants.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3;
  27914. /** mag = nearest and min = nearest and mip = nearest */
  27915. Constants.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4;
  27916. /** mag = nearest and min = linear and mip = nearest */
  27917. Constants.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5;
  27918. /** mag = nearest and min = linear and mip = linear */
  27919. Constants.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6;
  27920. /** mag = nearest and min = linear and mip = none */
  27921. Constants.TEXTURE_NEAREST_LINEAR = 7;
  27922. /** mag = nearest and min = nearest and mip = none */
  27923. Constants.TEXTURE_NEAREST_NEAREST = 8;
  27924. /** mag = linear and min = nearest and mip = nearest */
  27925. Constants.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9;
  27926. /** mag = linear and min = nearest and mip = linear */
  27927. Constants.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10;
  27928. /** mag = linear and min = linear and mip = none */
  27929. Constants.TEXTURE_LINEAR_LINEAR = 11;
  27930. /** mag = linear and min = nearest and mip = none */
  27931. Constants.TEXTURE_LINEAR_NEAREST = 12;
  27932. /** Explicit coordinates mode */
  27933. Constants.TEXTURE_EXPLICIT_MODE = 0;
  27934. /** Spherical coordinates mode */
  27935. Constants.TEXTURE_SPHERICAL_MODE = 1;
  27936. /** Planar coordinates mode */
  27937. Constants.TEXTURE_PLANAR_MODE = 2;
  27938. /** Cubic coordinates mode */
  27939. Constants.TEXTURE_CUBIC_MODE = 3;
  27940. /** Projection coordinates mode */
  27941. Constants.TEXTURE_PROJECTION_MODE = 4;
  27942. /** Skybox coordinates mode */
  27943. Constants.TEXTURE_SKYBOX_MODE = 5;
  27944. /** Inverse Cubic coordinates mode */
  27945. Constants.TEXTURE_INVCUBIC_MODE = 6;
  27946. /** Equirectangular coordinates mode */
  27947. Constants.TEXTURE_EQUIRECTANGULAR_MODE = 7;
  27948. /** Equirectangular Fixed coordinates mode */
  27949. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8;
  27950. /** Equirectangular Fixed Mirrored coordinates mode */
  27951. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9;
  27952. // Texture rescaling mode
  27953. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27954. Constants.SCALEMODE_FLOOR = 1;
  27955. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27956. Constants.SCALEMODE_NEAREST = 2;
  27957. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27958. Constants.SCALEMODE_CEILING = 3;
  27959. /**
  27960. * The dirty texture flag value
  27961. */
  27962. Constants.MATERIAL_TextureDirtyFlag = 1;
  27963. /**
  27964. * The dirty light flag value
  27965. */
  27966. Constants.MATERIAL_LightDirtyFlag = 2;
  27967. /**
  27968. * The dirty fresnel flag value
  27969. */
  27970. Constants.MATERIAL_FresnelDirtyFlag = 4;
  27971. /**
  27972. * The dirty attribute flag value
  27973. */
  27974. Constants.MATERIAL_AttributesDirtyFlag = 8;
  27975. /**
  27976. * The dirty misc flag value
  27977. */
  27978. Constants.MATERIAL_MiscDirtyFlag = 16;
  27979. /**
  27980. * The all dirty flag value
  27981. */
  27982. Constants.MATERIAL_AllDirtyFlag = 31;
  27983. /**
  27984. * Returns the triangle fill mode
  27985. */
  27986. Constants.MATERIAL_TriangleFillMode = 0;
  27987. /**
  27988. * Returns the wireframe mode
  27989. */
  27990. Constants.MATERIAL_WireFrameFillMode = 1;
  27991. /**
  27992. * Returns the point fill mode
  27993. */
  27994. Constants.MATERIAL_PointFillMode = 2;
  27995. /**
  27996. * Returns the point list draw mode
  27997. */
  27998. Constants.MATERIAL_PointListDrawMode = 3;
  27999. /**
  28000. * Returns the line list draw mode
  28001. */
  28002. Constants.MATERIAL_LineListDrawMode = 4;
  28003. /**
  28004. * Returns the line loop draw mode
  28005. */
  28006. Constants.MATERIAL_LineLoopDrawMode = 5;
  28007. /**
  28008. * Returns the line strip draw mode
  28009. */
  28010. Constants.MATERIAL_LineStripDrawMode = 6;
  28011. /**
  28012. * Returns the triangle strip draw mode
  28013. */
  28014. Constants.MATERIAL_TriangleStripDrawMode = 7;
  28015. /**
  28016. * Returns the triangle fan draw mode
  28017. */
  28018. Constants.MATERIAL_TriangleFanDrawMode = 8;
  28019. /**
  28020. * Stores the clock-wise side orientation
  28021. */
  28022. Constants.MATERIAL_ClockWiseSideOrientation = 0;
  28023. /**
  28024. * Stores the counter clock-wise side orientation
  28025. */
  28026. Constants.MATERIAL_CounterClockWiseSideOrientation = 1;
  28027. /**
  28028. * Nothing
  28029. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28030. */
  28031. Constants.ACTION_NothingTrigger = 0;
  28032. /**
  28033. * On pick
  28034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28035. */
  28036. Constants.ACTION_OnPickTrigger = 1;
  28037. /**
  28038. * On left pick
  28039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28040. */
  28041. Constants.ACTION_OnLeftPickTrigger = 2;
  28042. /**
  28043. * On right pick
  28044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28045. */
  28046. Constants.ACTION_OnRightPickTrigger = 3;
  28047. /**
  28048. * On center pick
  28049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28050. */
  28051. Constants.ACTION_OnCenterPickTrigger = 4;
  28052. /**
  28053. * On pick down
  28054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28055. */
  28056. Constants.ACTION_OnPickDownTrigger = 5;
  28057. /**
  28058. * On double pick
  28059. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28060. */
  28061. Constants.ACTION_OnDoublePickTrigger = 6;
  28062. /**
  28063. * On pick up
  28064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28065. */
  28066. Constants.ACTION_OnPickUpTrigger = 7;
  28067. /**
  28068. * On pick out.
  28069. * This trigger will only be raised if you also declared a OnPickDown
  28070. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28071. */
  28072. Constants.ACTION_OnPickOutTrigger = 16;
  28073. /**
  28074. * On long press
  28075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28076. */
  28077. Constants.ACTION_OnLongPressTrigger = 8;
  28078. /**
  28079. * On pointer over
  28080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28081. */
  28082. Constants.ACTION_OnPointerOverTrigger = 9;
  28083. /**
  28084. * On pointer out
  28085. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28086. */
  28087. Constants.ACTION_OnPointerOutTrigger = 10;
  28088. /**
  28089. * On every frame
  28090. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28091. */
  28092. Constants.ACTION_OnEveryFrameTrigger = 11;
  28093. /**
  28094. * On intersection enter
  28095. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28096. */
  28097. Constants.ACTION_OnIntersectionEnterTrigger = 12;
  28098. /**
  28099. * On intersection exit
  28100. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28101. */
  28102. Constants.ACTION_OnIntersectionExitTrigger = 13;
  28103. /**
  28104. * On key down
  28105. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28106. */
  28107. Constants.ACTION_OnKeyDownTrigger = 14;
  28108. /**
  28109. * On key up
  28110. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28111. */
  28112. Constants.ACTION_OnKeyUpTrigger = 15;
  28113. /**
  28114. * Billboard mode will only apply to Y axis
  28115. */
  28116. Constants.PARTICLES_BILLBOARDMODE_Y = 2;
  28117. /**
  28118. * Billboard mode will apply to all axes
  28119. */
  28120. Constants.PARTICLES_BILLBOARDMODE_ALL = 7;
  28121. /**
  28122. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  28123. */
  28124. Constants.PARTICLES_BILLBOARDMODE_STRETCHED = 8;
  28125. /**
  28126. * Gets or sets base Assets URL
  28127. */
  28128. Constants.PARTICLES_BaseAssetsUrl = "https://assets.babylonjs.com/particles";
  28129. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28130. * Test order :
  28131. * Is the bounding sphere outside the frustum ?
  28132. * If not, are the bounding box vertices outside the frustum ?
  28133. * It not, then the cullable object is in the frustum.
  28134. */
  28135. Constants.MESHES_CULLINGSTRATEGY_STANDARD = 0;
  28136. /** Culling strategy : Bounding Sphere Only.
  28137. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28138. * It's also less accurate than the standard because some not visible objects can still be selected.
  28139. * Test : is the bounding sphere outside the frustum ?
  28140. * If not, then the cullable object is in the frustum.
  28141. */
  28142. Constants.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1;
  28143. /** Culling strategy : Optimistic Inclusion.
  28144. * This in an inclusion test first, then the standard exclusion test.
  28145. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28146. * 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.
  28147. * Anyway, it's as accurate as the standard strategy.
  28148. * Test :
  28149. * Is the cullable object bounding sphere center in the frustum ?
  28150. * If not, apply the default culling strategy.
  28151. */
  28152. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2;
  28153. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28154. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28155. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28156. * 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.
  28157. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28158. * Test :
  28159. * Is the cullable object bounding sphere center in the frustum ?
  28160. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28161. */
  28162. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3;
  28163. /**
  28164. * No logging while loading
  28165. */
  28166. Constants.SCENELOADER_NO_LOGGING = 0;
  28167. /**
  28168. * Minimal logging while loading
  28169. */
  28170. Constants.SCENELOADER_MINIMAL_LOGGING = 1;
  28171. /**
  28172. * Summary logging while loading
  28173. */
  28174. Constants.SCENELOADER_SUMMARY_LOGGING = 2;
  28175. /**
  28176. * Detailled logging while loading
  28177. */
  28178. Constants.SCENELOADER_DETAILED_LOGGING = 3;
  28179. return Constants;
  28180. }());
  28181. /***/ }),
  28182. /***/ "./Engines/engine.ts":
  28183. /*!***************************!*\
  28184. !*** ./Engines/engine.ts ***!
  28185. \***************************/
  28186. /*! exports provided: InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine */
  28187. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  28188. "use strict";
  28189. __webpack_require__.r(__webpack_exports__);
  28190. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return InstancingAttributeInfo; });
  28191. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return DepthTextureCreationOptions; });
  28192. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return EngineCapabilities; });
  28193. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return Engine; });
  28194. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  28195. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  28196. /* harmony import */ var _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/performanceMonitor */ "./Misc/performanceMonitor.ts");
  28197. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  28198. /* harmony import */ var _Misc_promise__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/promise */ "./Misc/promise.ts");
  28199. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  28200. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  28201. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  28202. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  28203. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  28204. /* harmony import */ var _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  28205. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  28206. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../States/index */ "./States/index.ts");
  28207. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  28208. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  28209. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  28210. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  28211. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  28212. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  28213. /**
  28214. * Keeps track of all the buffer info used in engine.
  28215. */
  28216. var BufferPointer = /** @class */ (function () {
  28217. function BufferPointer() {
  28218. }
  28219. return BufferPointer;
  28220. }());
  28221. /**
  28222. * Interface for attribute information associated with buffer instanciation
  28223. */
  28224. var InstancingAttributeInfo = /** @class */ (function () {
  28225. function InstancingAttributeInfo() {
  28226. }
  28227. return InstancingAttributeInfo;
  28228. }());
  28229. /**
  28230. * Define options used to create a depth texture
  28231. */
  28232. var DepthTextureCreationOptions = /** @class */ (function () {
  28233. function DepthTextureCreationOptions() {
  28234. }
  28235. return DepthTextureCreationOptions;
  28236. }());
  28237. /**
  28238. * Class used to describe the capabilities of the engine relatively to the current browser
  28239. */
  28240. var EngineCapabilities = /** @class */ (function () {
  28241. function EngineCapabilities() {
  28242. }
  28243. return EngineCapabilities;
  28244. }());
  28245. /**
  28246. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  28247. */
  28248. var Engine = /** @class */ (function () {
  28249. /**
  28250. * Creates a new engine
  28251. * @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
  28252. * @param antialias defines enable antialiasing (default: false)
  28253. * @param options defines further options to be sent to the getContext() function
  28254. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28255. */
  28256. function Engine(canvasOrContext, antialias, options, adaptToDeviceRatio) {
  28257. if (adaptToDeviceRatio === void 0) { adaptToDeviceRatio = false; }
  28258. var _this = this;
  28259. // Public members
  28260. /**
  28261. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28262. */
  28263. this.forcePOTTextures = false;
  28264. /**
  28265. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28266. */
  28267. this.isFullscreen = false;
  28268. /**
  28269. * Gets a boolean indicating if the pointer is currently locked
  28270. */
  28271. this.isPointerLock = false;
  28272. /**
  28273. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28274. */
  28275. this.cullBackFaces = true;
  28276. /**
  28277. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28278. */
  28279. this.renderEvenInBackground = true;
  28280. /**
  28281. * Gets or sets a boolean indicating that cache can be kept between frames
  28282. */
  28283. this.preventCacheWipeBetweenFrames = false;
  28284. /**
  28285. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28286. **/
  28287. this.enableOfflineSupport = false;
  28288. /**
  28289. * 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)
  28290. **/
  28291. this.disableManifestCheck = false;
  28292. /**
  28293. * Gets the list of created scenes
  28294. */
  28295. this.scenes = new Array();
  28296. /**
  28297. * Event raised when a new scene is created
  28298. */
  28299. this.onNewSceneAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28300. /**
  28301. * Gets the list of created postprocesses
  28302. */
  28303. this.postProcesses = new Array();
  28304. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28305. this.validateShaderPrograms = false;
  28306. // Observables
  28307. /**
  28308. * Observable event triggered each time the rendering canvas is resized
  28309. */
  28310. this.onResizeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28311. /**
  28312. * Observable event triggered each time the canvas loses focus
  28313. */
  28314. this.onCanvasBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28315. /**
  28316. * Observable event triggered each time the canvas gains focus
  28317. */
  28318. this.onCanvasFocusObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28319. /**
  28320. * Observable event triggered each time the canvas receives pointerout event
  28321. */
  28322. this.onCanvasPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28323. /**
  28324. * Observable event triggered before each texture is initialized
  28325. */
  28326. this.onBeforeTextureInitObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28327. //WebVR
  28328. this._vrDisplay = undefined;
  28329. this._vrSupported = false;
  28330. this._vrExclusivePointerMode = false;
  28331. // Uniform buffers list
  28332. /**
  28333. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28334. */
  28335. this.disableUniformBuffers = false;
  28336. /** @hidden */
  28337. this._uniformBuffers = new Array();
  28338. // Observables
  28339. /**
  28340. * Observable raised when the engine begins a new frame
  28341. */
  28342. this.onBeginFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28343. /**
  28344. * If set, will be used to request the next animation frame for the render loop
  28345. */
  28346. this.customAnimationFrameRequester = null;
  28347. /**
  28348. * Observable raised when the engine ends the current frame
  28349. */
  28350. this.onEndFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28351. /**
  28352. * Observable raised when the engine is about to compile a shader
  28353. */
  28354. this.onBeforeShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28355. /**
  28356. * Observable raised when the engine has jsut compiled a shader
  28357. */
  28358. this.onAfterShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28359. this._windowIsBackground = false;
  28360. this._webGLVersion = 1.0;
  28361. this._highPrecisionShadersAllowed = true;
  28362. /** @hidden */
  28363. this._badOS = false;
  28364. /** @hidden */
  28365. this._badDesktopOS = false;
  28366. /**
  28367. * Gets or sets a value indicating if we want to disable texture binding optimization.
  28368. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  28369. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  28370. */
  28371. this.disableTextureBindingOptimization = false;
  28372. /**
  28373. * Observable signaled when VR display mode changes
  28374. */
  28375. this.onVRDisplayChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28376. /**
  28377. * Observable signaled when VR request present is complete
  28378. */
  28379. this.onVRRequestPresentComplete = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28380. /**
  28381. * Observable signaled when VR request present starts
  28382. */
  28383. this.onVRRequestPresentStart = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28384. this._colorWrite = true;
  28385. /** @hidden */
  28386. this._drawCalls = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  28387. /** @hidden */
  28388. this._textureCollisions = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  28389. this._renderingQueueLaunched = false;
  28390. this._activeRenderLoops = new Array();
  28391. // Deterministic lockstepMaxSteps
  28392. this._deterministicLockstep = false;
  28393. this._lockstepMaxSteps = 4;
  28394. // Lost context
  28395. /**
  28396. * Observable signaled when a context lost event is raised
  28397. */
  28398. this.onContextLostObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28399. /**
  28400. * Observable signaled when a context restored event is raised
  28401. */
  28402. this.onContextRestoredObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28403. this._contextWasLost = false;
  28404. this._doNotHandleContextLost = false;
  28405. // FPS
  28406. this._performanceMonitor = new _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__["PerformanceMonitor"]();
  28407. this._fps = 60;
  28408. this._deltaTime = 0;
  28409. /**
  28410. * Turn this value on if you want to pause FPS computation when in background
  28411. */
  28412. this.disablePerformanceMonitorInBackground = false;
  28413. /**
  28414. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28415. */
  28416. this.disableVertexArrayObjects = false;
  28417. // States
  28418. /** @hidden */
  28419. this._depthCullingState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_DepthCullingState"]();
  28420. /** @hidden */
  28421. this._stencilState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_StencilState"]();
  28422. /** @hidden */
  28423. this._alphaState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_AlphaState"]();
  28424. /** @hidden */
  28425. this._alphaMode = Engine.ALPHA_DISABLE;
  28426. // Cache
  28427. this._internalTexturesCache = new Array();
  28428. /** @hidden */
  28429. this._activeChannel = 0;
  28430. this._currentTextureChannel = -1;
  28431. /** @hidden */
  28432. this._boundTexturesCache = {};
  28433. this._compiledEffects = {};
  28434. this._vertexAttribArraysEnabled = [];
  28435. this._uintIndicesCurrentlySet = false;
  28436. this._currentBoundBuffer = new Array();
  28437. /** @hidden */
  28438. this._currentFramebuffer = null;
  28439. this._currentBufferPointers = new Array();
  28440. this._currentInstanceLocations = new Array();
  28441. this._currentInstanceBuffers = new Array();
  28442. this._firstBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  28443. this._lastBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  28444. this._vaoRecordInProgress = false;
  28445. this._mustWipeVertexAttributes = false;
  28446. this._nextFreeTextureSlots = new Array();
  28447. this._maxSimultaneousTextures = 0;
  28448. this._activeRequests = new Array();
  28449. // Hardware supported Compressed Textures
  28450. this._texturesSupported = new Array();
  28451. /**
  28452. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28453. */
  28454. this.premultipliedAlpha = true;
  28455. this._viewportCached = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](0, 0, 0, 0);
  28456. this._onVRFullScreenTriggered = function () {
  28457. if (_this._vrDisplay && _this._vrDisplay.isPresenting) {
  28458. //get the old size before we change
  28459. _this._oldSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Size"](_this.getRenderWidth(), _this.getRenderHeight());
  28460. _this._oldHardwareScaleFactor = _this.getHardwareScalingLevel();
  28461. //get the width and height, change the render size
  28462. var leftEye = _this._vrDisplay.getEyeParameters('left');
  28463. _this.setHardwareScalingLevel(1);
  28464. _this.setSize(leftEye.renderWidth * 2, leftEye.renderHeight);
  28465. }
  28466. else {
  28467. _this.setHardwareScalingLevel(_this._oldHardwareScaleFactor);
  28468. _this.setSize(_this._oldSize.width, _this._oldSize.height);
  28469. }
  28470. };
  28471. this._unpackFlipYCached = null;
  28472. /**
  28473. * In case you are sharing the context with other applications, it might
  28474. * be interested to not cache the unpack flip y state to ensure a consistent
  28475. * value would be set.
  28476. */
  28477. this.enableUnpackFlipYCached = true;
  28478. this._boundUniforms = {};
  28479. // Register promises
  28480. _Misc_promise__WEBPACK_IMPORTED_MODULE_4__["PromisePolyfill"].Apply();
  28481. var canvas = null;
  28482. Engine.Instances.push(this);
  28483. if (!canvasOrContext) {
  28484. return;
  28485. }
  28486. options = options || {};
  28487. if (canvasOrContext.getContext) {
  28488. canvas = canvasOrContext;
  28489. this._renderingCanvas = canvas;
  28490. if (antialias != null) {
  28491. options.antialias = antialias;
  28492. }
  28493. if (options.deterministicLockstep === undefined) {
  28494. options.deterministicLockstep = false;
  28495. }
  28496. if (options.lockstepMaxSteps === undefined) {
  28497. options.lockstepMaxSteps = 4;
  28498. }
  28499. if (options.preserveDrawingBuffer === undefined) {
  28500. options.preserveDrawingBuffer = false;
  28501. }
  28502. if (options.audioEngine === undefined) {
  28503. options.audioEngine = true;
  28504. }
  28505. if (options.stencil === undefined) {
  28506. options.stencil = true;
  28507. }
  28508. if (options.premultipliedAlpha === false) {
  28509. this.premultipliedAlpha = false;
  28510. }
  28511. this._deterministicLockstep = options.deterministicLockstep;
  28512. this._lockstepMaxSteps = options.lockstepMaxSteps;
  28513. this._doNotHandleContextLost = options.doNotHandleContextLost ? true : false;
  28514. // Exceptions
  28515. if (navigator && navigator.userAgent) {
  28516. var ua = navigator.userAgent;
  28517. for (var _i = 0, _a = Engine.ExceptionList; _i < _a.length; _i++) {
  28518. var exception = _a[_i];
  28519. var key = exception.key;
  28520. var targets = exception.targets;
  28521. var check = new RegExp(key);
  28522. if (check.test(ua)) {
  28523. if (exception.capture && exception.captureConstraint) {
  28524. var capture = exception.capture;
  28525. var constraint = exception.captureConstraint;
  28526. var regex = new RegExp(capture);
  28527. var matches = regex.exec(ua);
  28528. if (matches && matches.length > 0) {
  28529. var capturedValue = parseInt(matches[matches.length - 1]);
  28530. if (capturedValue >= constraint) {
  28531. continue;
  28532. }
  28533. }
  28534. }
  28535. for (var _b = 0, targets_1 = targets; _b < targets_1.length; _b++) {
  28536. var target = targets_1[_b];
  28537. switch (target) {
  28538. case "uniformBuffer":
  28539. this.disableUniformBuffers = true;
  28540. break;
  28541. case "vao":
  28542. this.disableVertexArrayObjects = true;
  28543. break;
  28544. case "textureBindingOptimization":
  28545. this.disableTextureBindingOptimization = true;
  28546. break;
  28547. }
  28548. }
  28549. }
  28550. }
  28551. }
  28552. // GL
  28553. if (!options.disableWebGL2Support) {
  28554. try {
  28555. this._gl = (canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options));
  28556. if (this._gl) {
  28557. this._webGLVersion = 2.0;
  28558. // Prevent weird browsers to lie :-)
  28559. if (!this._gl.deleteQuery) {
  28560. this._webGLVersion = 1.0;
  28561. }
  28562. }
  28563. }
  28564. catch (e) {
  28565. // Do nothing
  28566. }
  28567. }
  28568. if (!this._gl) {
  28569. if (!canvas) {
  28570. throw new Error("The provided canvas is null or undefined.");
  28571. }
  28572. try {
  28573. this._gl = (canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options));
  28574. }
  28575. catch (e) {
  28576. throw new Error("WebGL not supported");
  28577. }
  28578. }
  28579. if (!this._gl) {
  28580. throw new Error("WebGL not supported");
  28581. }
  28582. // Ensures a consistent color space unpacking of textures cross browser.
  28583. this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE);
  28584. this._onCanvasFocus = function () {
  28585. _this.onCanvasFocusObservable.notifyObservers(_this);
  28586. };
  28587. this._onCanvasBlur = function () {
  28588. _this.onCanvasBlurObservable.notifyObservers(_this);
  28589. };
  28590. canvas.addEventListener("focus", this._onCanvasFocus);
  28591. canvas.addEventListener("blur", this._onCanvasBlur);
  28592. this._onBlur = function () {
  28593. if (_this.disablePerformanceMonitorInBackground) {
  28594. _this._performanceMonitor.disable();
  28595. }
  28596. _this._windowIsBackground = true;
  28597. };
  28598. this._onFocus = function () {
  28599. if (_this.disablePerformanceMonitorInBackground) {
  28600. _this._performanceMonitor.enable();
  28601. }
  28602. _this._windowIsBackground = false;
  28603. };
  28604. this._onCanvasPointerOut = function (ev) {
  28605. _this.onCanvasPointerOutObservable.notifyObservers(ev);
  28606. };
  28607. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  28608. window.addEventListener("blur", this._onBlur);
  28609. window.addEventListener("focus", this._onFocus);
  28610. }
  28611. canvas.addEventListener("pointerout", this._onCanvasPointerOut);
  28612. // Context lost
  28613. if (!this._doNotHandleContextLost) {
  28614. this._onContextLost = function (evt) {
  28615. evt.preventDefault();
  28616. _this._contextWasLost = true;
  28617. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context lost.");
  28618. _this.onContextLostObservable.notifyObservers(_this);
  28619. };
  28620. this._onContextRestored = function () {
  28621. // Adding a timeout to avoid race condition at browser level
  28622. setTimeout(function () {
  28623. // Rebuild gl context
  28624. _this._initGLContext();
  28625. // Rebuild effects
  28626. _this._rebuildEffects();
  28627. // Rebuild textures
  28628. _this._rebuildInternalTextures();
  28629. // Rebuild buffers
  28630. _this._rebuildBuffers();
  28631. // Cache
  28632. _this.wipeCaches(true);
  28633. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context successfully restored.");
  28634. _this.onContextRestoredObservable.notifyObservers(_this);
  28635. _this._contextWasLost = false;
  28636. }, 0);
  28637. };
  28638. canvas.addEventListener("webglcontextlost", this._onContextLost, false);
  28639. canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
  28640. }
  28641. if (!options.doNotHandleTouchAction) {
  28642. this._disableTouchAction();
  28643. }
  28644. }
  28645. else {
  28646. this._gl = canvasOrContext;
  28647. this._renderingCanvas = this._gl.canvas;
  28648. if (this._gl.renderbufferStorageMultisample) {
  28649. this._webGLVersion = 2.0;
  28650. }
  28651. var attributes = this._gl.getContextAttributes();
  28652. if (attributes) {
  28653. options.stencil = attributes.stencil;
  28654. }
  28655. }
  28656. if (options.useHighPrecisionFloats !== undefined) {
  28657. this._highPrecisionShadersAllowed = options.useHighPrecisionFloats;
  28658. }
  28659. // Viewport
  28660. var devicePixelRatio = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist() ? (window.devicePixelRatio || 1.0) : 1.0;
  28661. var limitDeviceRatio = options.limitDeviceRatio || devicePixelRatio;
  28662. this._hardwareScalingLevel = adaptToDeviceRatio ? 1.0 / Math.min(limitDeviceRatio, devicePixelRatio) : 1.0;
  28663. this.resize();
  28664. this._isStencilEnable = options.stencil ? true : false;
  28665. this._initGLContext();
  28666. if (canvas) {
  28667. var anyDoc_1 = document;
  28668. // Fullscreen
  28669. this._onFullscreenChange = function () {
  28670. if (anyDoc_1.fullscreen !== undefined) {
  28671. _this.isFullscreen = anyDoc_1.fullscreen;
  28672. }
  28673. else if (anyDoc_1.mozFullScreen !== undefined) {
  28674. _this.isFullscreen = anyDoc_1.mozFullScreen;
  28675. }
  28676. else if (anyDoc_1.webkitIsFullScreen !== undefined) {
  28677. _this.isFullscreen = anyDoc_1.webkitIsFullScreen;
  28678. }
  28679. else if (anyDoc_1.msIsFullScreen !== undefined) {
  28680. _this.isFullscreen = anyDoc_1.msIsFullScreen;
  28681. }
  28682. // Pointer lock
  28683. if (_this.isFullscreen && _this._pointerLockRequested && canvas) {
  28684. canvas.requestPointerLock = canvas.requestPointerLock ||
  28685. canvas.msRequestPointerLock ||
  28686. canvas.mozRequestPointerLock ||
  28687. canvas.webkitRequestPointerLock;
  28688. if (canvas.requestPointerLock) {
  28689. canvas.requestPointerLock();
  28690. }
  28691. }
  28692. };
  28693. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  28694. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  28695. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  28696. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  28697. // Pointer lock
  28698. this._onPointerLockChange = function () {
  28699. _this.isPointerLock = (anyDoc_1.mozPointerLockElement === canvas ||
  28700. anyDoc_1.webkitPointerLockElement === canvas ||
  28701. anyDoc_1.msPointerLockElement === canvas ||
  28702. anyDoc_1.pointerLockElement === canvas);
  28703. };
  28704. document.addEventListener("pointerlockchange", this._onPointerLockChange, false);
  28705. document.addEventListener("mspointerlockchange", this._onPointerLockChange, false);
  28706. document.addEventListener("mozpointerlockchange", this._onPointerLockChange, false);
  28707. document.addEventListener("webkitpointerlockchange", this._onPointerLockChange, false);
  28708. this._onVRDisplayPointerRestricted = function () {
  28709. if (canvas) {
  28710. canvas.requestPointerLock();
  28711. }
  28712. };
  28713. this._onVRDisplayPointerUnrestricted = function () {
  28714. if (!anyDoc_1.exitPointerLock) {
  28715. return;
  28716. }
  28717. anyDoc_1.exitPointerLock();
  28718. };
  28719. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  28720. window.addEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted, false);
  28721. window.addEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted, false);
  28722. }
  28723. }
  28724. // Create Audio Engine if needed.
  28725. if (!Engine.audioEngine && options.audioEngine && Engine.AudioEngineFactory) {
  28726. Engine.audioEngine = Engine.AudioEngineFactory(this.getRenderingCanvas());
  28727. }
  28728. // Prepare buffer pointers
  28729. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  28730. this._currentBufferPointers[i] = new BufferPointer();
  28731. }
  28732. this._linkTrackers(this._firstBoundInternalTextureTracker, this._lastBoundInternalTextureTracker);
  28733. // Load WebVR Devices
  28734. if (options.autoEnableWebVR) {
  28735. this.initWebVR();
  28736. }
  28737. // Detect if we are running on a faulty buggy OS.
  28738. this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
  28739. // Detect if we are running on a faulty buggy desktop OS.
  28740. this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  28741. console.log("Babylon.js v" + Engine.Version + " - " + this.description);
  28742. this.enableOfflineSupport = Engine.OfflineProviderFactory !== undefined;
  28743. }
  28744. Object.defineProperty(Engine, "Instances", {
  28745. /** Gets the list of created engines */
  28746. get: function () {
  28747. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].Instances;
  28748. },
  28749. enumerable: true,
  28750. configurable: true
  28751. });
  28752. Object.defineProperty(Engine, "LastCreatedEngine", {
  28753. /**
  28754. * Gets the latest created engine
  28755. */
  28756. get: function () {
  28757. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine;
  28758. },
  28759. enumerable: true,
  28760. configurable: true
  28761. });
  28762. Object.defineProperty(Engine, "LastCreatedScene", {
  28763. /**
  28764. * Gets the latest created scene
  28765. */
  28766. get: function () {
  28767. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  28768. },
  28769. enumerable: true,
  28770. configurable: true
  28771. });
  28772. /**
  28773. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28774. * @param flag defines which part of the materials must be marked as dirty
  28775. * @param predicate defines a predicate used to filter which materials should be affected
  28776. */
  28777. Engine.MarkAllMaterialsAsDirty = function (flag, predicate) {
  28778. for (var engineIndex = 0; engineIndex < Engine.Instances.length; engineIndex++) {
  28779. var engine = Engine.Instances[engineIndex];
  28780. for (var sceneIndex = 0; sceneIndex < engine.scenes.length; sceneIndex++) {
  28781. engine.scenes[sceneIndex].markAllMaterialsAsDirty(flag, predicate);
  28782. }
  28783. }
  28784. };
  28785. Object.defineProperty(Engine, "NpmPackage", {
  28786. /**
  28787. * Returns the current npm package of the sdk
  28788. */
  28789. // Not mixed with Version for tooling purpose.
  28790. get: function () {
  28791. return "babylonjs@4.0.0-alpha.33";
  28792. },
  28793. enumerable: true,
  28794. configurable: true
  28795. });
  28796. Object.defineProperty(Engine, "Version", {
  28797. /**
  28798. * Returns the current version of the framework
  28799. */
  28800. get: function () {
  28801. return "4.0.0-alpha.33";
  28802. },
  28803. enumerable: true,
  28804. configurable: true
  28805. });
  28806. Object.defineProperty(Engine.prototype, "description", {
  28807. /**
  28808. * Returns a string describing the current engine
  28809. */
  28810. get: function () {
  28811. var description = "WebGL" + this.webGLVersion;
  28812. if (this._caps.parallelShaderCompile) {
  28813. description += " - Parallel shader compilation";
  28814. }
  28815. return description;
  28816. },
  28817. enumerable: true,
  28818. configurable: true
  28819. });
  28820. Object.defineProperty(Engine, "ShadersRepository", {
  28821. /**
  28822. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28823. */
  28824. get: function () {
  28825. return _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository;
  28826. },
  28827. set: function (value) {
  28828. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository = value;
  28829. },
  28830. enumerable: true,
  28831. configurable: true
  28832. });
  28833. /**
  28834. * Method called to create the default loading screen.
  28835. * This can be overriden in your own app.
  28836. * @param canvas The rendering canvas element
  28837. * @returns The loading screen
  28838. */
  28839. Engine.DefaultLoadingScreenFactory = function (canvas) {
  28840. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_18__["_DevTools"].WarnImport("LoadingScreen");
  28841. };
  28842. Object.defineProperty(Engine.prototype, "isInVRExclusivePointerMode", {
  28843. /**
  28844. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  28845. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  28846. */
  28847. get: function () {
  28848. return this._vrExclusivePointerMode;
  28849. },
  28850. enumerable: true,
  28851. configurable: true
  28852. });
  28853. Object.defineProperty(Engine.prototype, "supportsUniformBuffers", {
  28854. /**
  28855. * Gets a boolean indicating that the engine supports uniform buffers
  28856. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28857. */
  28858. get: function () {
  28859. return this.webGLVersion > 1 && !this.disableUniformBuffers;
  28860. },
  28861. enumerable: true,
  28862. configurable: true
  28863. });
  28864. Object.defineProperty(Engine.prototype, "_shouldUseHighPrecisionShader", {
  28865. /** @hidden */
  28866. get: function () {
  28867. return this._caps.highPrecisionShaderSupported && this._highPrecisionShadersAllowed;
  28868. },
  28869. enumerable: true,
  28870. configurable: true
  28871. });
  28872. Object.defineProperty(Engine.prototype, "needPOTTextures", {
  28873. /**
  28874. * Gets a boolean indicating that only power of 2 textures are supported
  28875. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28876. */
  28877. get: function () {
  28878. return this._webGLVersion < 2 || this.forcePOTTextures;
  28879. },
  28880. enumerable: true,
  28881. configurable: true
  28882. });
  28883. Object.defineProperty(Engine.prototype, "doNotHandleContextLost", {
  28884. /**
  28885. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28886. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28887. */
  28888. get: function () {
  28889. return this._doNotHandleContextLost;
  28890. },
  28891. set: function (value) {
  28892. this._doNotHandleContextLost = value;
  28893. },
  28894. enumerable: true,
  28895. configurable: true
  28896. });
  28897. Object.defineProperty(Engine.prototype, "performanceMonitor", {
  28898. /**
  28899. * Gets the performance monitor attached to this engine
  28900. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28901. */
  28902. get: function () {
  28903. return this._performanceMonitor;
  28904. },
  28905. enumerable: true,
  28906. configurable: true
  28907. });
  28908. Object.defineProperty(Engine.prototype, "texturesSupported", {
  28909. /**
  28910. * Gets the list of texture formats supported
  28911. */
  28912. get: function () {
  28913. return this._texturesSupported;
  28914. },
  28915. enumerable: true,
  28916. configurable: true
  28917. });
  28918. Object.defineProperty(Engine.prototype, "textureFormatInUse", {
  28919. /**
  28920. * Gets the list of texture formats in use
  28921. */
  28922. get: function () {
  28923. return this._textureFormatInUse;
  28924. },
  28925. enumerable: true,
  28926. configurable: true
  28927. });
  28928. Object.defineProperty(Engine.prototype, "currentViewport", {
  28929. /**
  28930. * Gets the current viewport
  28931. */
  28932. get: function () {
  28933. return this._cachedViewport;
  28934. },
  28935. enumerable: true,
  28936. configurable: true
  28937. });
  28938. Object.defineProperty(Engine.prototype, "emptyTexture", {
  28939. /**
  28940. * Gets the default empty texture
  28941. */
  28942. get: function () {
  28943. if (!this._emptyTexture) {
  28944. this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28945. }
  28946. return this._emptyTexture;
  28947. },
  28948. enumerable: true,
  28949. configurable: true
  28950. });
  28951. Object.defineProperty(Engine.prototype, "emptyTexture3D", {
  28952. /**
  28953. * Gets the default empty 3D texture
  28954. */
  28955. get: function () {
  28956. if (!this._emptyTexture3D) {
  28957. this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28958. }
  28959. return this._emptyTexture3D;
  28960. },
  28961. enumerable: true,
  28962. configurable: true
  28963. });
  28964. Object.defineProperty(Engine.prototype, "emptyCubeTexture", {
  28965. /**
  28966. * Gets the default empty cube texture
  28967. */
  28968. get: function () {
  28969. if (!this._emptyCubeTexture) {
  28970. var faceData = new Uint8Array(4);
  28971. var cubeData = [faceData, faceData, faceData, faceData, faceData, faceData];
  28972. this._emptyCubeTexture = this.createRawCubeTexture(cubeData, 1, Engine.TEXTUREFORMAT_RGBA, Engine.TEXTURETYPE_UNSIGNED_INT, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28973. }
  28974. return this._emptyCubeTexture;
  28975. },
  28976. enumerable: true,
  28977. configurable: true
  28978. });
  28979. Engine.prototype._disableTouchAction = function () {
  28980. if (!this._renderingCanvas) {
  28981. return;
  28982. }
  28983. this._renderingCanvas.setAttribute("touch-action", "none");
  28984. this._renderingCanvas.style.touchAction = "none";
  28985. this._renderingCanvas.style.msTouchAction = "none";
  28986. };
  28987. Engine.prototype._rebuildInternalTextures = function () {
  28988. var currentState = this._internalTexturesCache.slice(); // Do a copy because the rebuild will add proxies
  28989. for (var _i = 0, currentState_1 = currentState; _i < currentState_1.length; _i++) {
  28990. var internalTexture = currentState_1[_i];
  28991. internalTexture._rebuild();
  28992. }
  28993. };
  28994. Engine.prototype._rebuildEffects = function () {
  28995. for (var key in this._compiledEffects) {
  28996. var effect = this._compiledEffects[key];
  28997. effect._prepareEffect();
  28998. }
  28999. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  29000. };
  29001. /**
  29002. * Gets a boolean indicating if all created effects are ready
  29003. * @returns true if all effects are ready
  29004. */
  29005. Engine.prototype.areAllEffectsReady = function () {
  29006. for (var key in this._compiledEffects) {
  29007. var effect = this._compiledEffects[key];
  29008. if (!effect.isReady()) {
  29009. return false;
  29010. }
  29011. }
  29012. return true;
  29013. };
  29014. Engine.prototype._rebuildBuffers = function () {
  29015. // Index / Vertex
  29016. for (var _i = 0, _a = this.scenes; _i < _a.length; _i++) {
  29017. var scene = _a[_i];
  29018. scene.resetCachedMaterial();
  29019. scene._rebuildGeometries();
  29020. scene._rebuildTextures();
  29021. }
  29022. // Uniforms
  29023. for (var _b = 0, _c = this._uniformBuffers; _b < _c.length; _b++) {
  29024. var uniformBuffer = _c[_b];
  29025. uniformBuffer._rebuild();
  29026. }
  29027. };
  29028. Engine.prototype._initGLContext = function () {
  29029. // Caps
  29030. this._caps = new EngineCapabilities();
  29031. this._caps.maxTexturesImageUnits = this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);
  29032. this._caps.maxCombinedTexturesImageUnits = this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  29033. this._caps.maxVertexTextureImageUnits = this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
  29034. this._caps.maxTextureSize = this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE);
  29035. this._caps.maxCubemapTextureSize = this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE);
  29036. this._caps.maxRenderTextureSize = this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE);
  29037. this._caps.maxVertexAttribs = this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS);
  29038. this._caps.maxVaryingVectors = this._gl.getParameter(this._gl.MAX_VARYING_VECTORS);
  29039. this._caps.maxFragmentUniformVectors = this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS);
  29040. this._caps.maxVertexUniformVectors = this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS);
  29041. // Infos
  29042. this._glVersion = this._gl.getParameter(this._gl.VERSION);
  29043. var rendererInfo = this._gl.getExtension("WEBGL_debug_renderer_info");
  29044. if (rendererInfo != null) {
  29045. this._glRenderer = this._gl.getParameter(rendererInfo.UNMASKED_RENDERER_WEBGL);
  29046. this._glVendor = this._gl.getParameter(rendererInfo.UNMASKED_VENDOR_WEBGL);
  29047. }
  29048. if (!this._glVendor) {
  29049. this._glVendor = "Unknown vendor";
  29050. }
  29051. if (!this._glRenderer) {
  29052. this._glRenderer = "Unknown renderer";
  29053. }
  29054. // Constants
  29055. this._gl.HALF_FLOAT_OES = 0x8D61; // Half floating-point type (16-bit).
  29056. if (this._gl.RGBA16F !== 0x881A) {
  29057. this._gl.RGBA16F = 0x881A; // RGBA 16-bit floating-point color-renderable internal sized format.
  29058. }
  29059. if (this._gl.RGBA32F !== 0x8814) {
  29060. this._gl.RGBA32F = 0x8814; // RGBA 32-bit floating-point color-renderable internal sized format.
  29061. }
  29062. if (this._gl.DEPTH24_STENCIL8 !== 35056) {
  29063. this._gl.DEPTH24_STENCIL8 = 35056;
  29064. }
  29065. // Extensions
  29066. this._caps.standardDerivatives = this._webGLVersion > 1 || (this._gl.getExtension('OES_standard_derivatives') !== null);
  29067. this._caps.astc = this._gl.getExtension('WEBGL_compressed_texture_astc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_astc');
  29068. this._caps.s3tc = this._gl.getExtension('WEBGL_compressed_texture_s3tc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc');
  29069. this._caps.pvrtc = this._gl.getExtension('WEBGL_compressed_texture_pvrtc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc');
  29070. this._caps.etc1 = this._gl.getExtension('WEBGL_compressed_texture_etc1') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc1');
  29071. this._caps.etc2 = this._gl.getExtension('WEBGL_compressed_texture_etc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc') ||
  29072. this._gl.getExtension('WEBGL_compressed_texture_es3_0'); // also a requirement of OpenGL ES 3
  29073. 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');
  29074. this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0;
  29075. this._caps.uintIndices = this._webGLVersion > 1 || this._gl.getExtension('OES_element_index_uint') !== null;
  29076. this._caps.fragmentDepthSupported = this._webGLVersion > 1 || this._gl.getExtension('EXT_frag_depth') !== null;
  29077. this._caps.highPrecisionShaderSupported = false;
  29078. this._caps.timerQuery = this._gl.getExtension('EXT_disjoint_timer_query_webgl2') || this._gl.getExtension("EXT_disjoint_timer_query");
  29079. if (this._caps.timerQuery) {
  29080. if (this._webGLVersion === 1) {
  29081. this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery);
  29082. }
  29083. this._caps.canUseTimestampForTimerQuery = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) > 0;
  29084. }
  29085. // Checks if some of the format renders first to allow the use of webgl inspector.
  29086. this._caps.colorBufferFloat = this._webGLVersion > 1 && this._gl.getExtension('EXT_color_buffer_float');
  29087. this._caps.textureFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_float')) ? true : false;
  29088. this._caps.textureFloatLinearFiltering = this._caps.textureFloat && this._gl.getExtension('OES_texture_float_linear') ? true : false;
  29089. this._caps.textureFloatRender = this._caps.textureFloat && this._canRenderToFloatFramebuffer() ? true : false;
  29090. this._caps.textureHalfFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_half_float')) ? true : false;
  29091. this._caps.textureHalfFloatLinearFiltering = (this._webGLVersion > 1 || (this._caps.textureHalfFloat && this._gl.getExtension('OES_texture_half_float_linear'))) ? true : false;
  29092. if (this._webGLVersion > 1) {
  29093. this._gl.HALF_FLOAT_OES = 0x140B;
  29094. }
  29095. this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer();
  29096. this._caps.textureLOD = (this._webGLVersion > 1 || this._gl.getExtension('EXT_shader_texture_lod')) ? true : false;
  29097. this._caps.multiview = this._gl.getExtension('WEBGL_multiview');
  29098. // Draw buffers
  29099. if (this._webGLVersion > 1) {
  29100. this._caps.drawBuffersExtension = true;
  29101. }
  29102. else {
  29103. var drawBuffersExtension = this._gl.getExtension('WEBGL_draw_buffers');
  29104. if (drawBuffersExtension !== null) {
  29105. this._caps.drawBuffersExtension = true;
  29106. this._gl.drawBuffers = drawBuffersExtension.drawBuffersWEBGL.bind(drawBuffersExtension);
  29107. this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
  29108. for (var i = 0; i < 16; i++) {
  29109. this._gl["COLOR_ATTACHMENT" + i + "_WEBGL"] = drawBuffersExtension["COLOR_ATTACHMENT" + i + "_WEBGL"];
  29110. }
  29111. }
  29112. else {
  29113. this._caps.drawBuffersExtension = false;
  29114. }
  29115. }
  29116. // Shader compiler threads
  29117. this._caps.parallelShaderCompile = this._gl.getExtension('KHR_parallel_shader_compile');
  29118. // Depth Texture
  29119. if (this._webGLVersion > 1) {
  29120. this._caps.depthTextureExtension = true;
  29121. }
  29122. else {
  29123. var depthTextureExtension = this._gl.getExtension('WEBGL_depth_texture');
  29124. if (depthTextureExtension != null) {
  29125. this._caps.depthTextureExtension = true;
  29126. this._gl.UNSIGNED_INT_24_8 = depthTextureExtension.UNSIGNED_INT_24_8_WEBGL;
  29127. }
  29128. }
  29129. // Vertex array object
  29130. if (this.disableVertexArrayObjects) {
  29131. this._caps.vertexArrayObject = false;
  29132. }
  29133. else if (this._webGLVersion > 1) {
  29134. this._caps.vertexArrayObject = true;
  29135. }
  29136. else {
  29137. var vertexArrayObjectExtension = this._gl.getExtension('OES_vertex_array_object');
  29138. if (vertexArrayObjectExtension != null) {
  29139. this._caps.vertexArrayObject = true;
  29140. this._gl.createVertexArray = vertexArrayObjectExtension.createVertexArrayOES.bind(vertexArrayObjectExtension);
  29141. this._gl.bindVertexArray = vertexArrayObjectExtension.bindVertexArrayOES.bind(vertexArrayObjectExtension);
  29142. this._gl.deleteVertexArray = vertexArrayObjectExtension.deleteVertexArrayOES.bind(vertexArrayObjectExtension);
  29143. }
  29144. else {
  29145. this._caps.vertexArrayObject = false;
  29146. }
  29147. }
  29148. // Instances count
  29149. if (this._webGLVersion > 1) {
  29150. this._caps.instancedArrays = true;
  29151. }
  29152. else {
  29153. var instanceExtension = this._gl.getExtension('ANGLE_instanced_arrays');
  29154. if (instanceExtension != null) {
  29155. this._caps.instancedArrays = true;
  29156. this._gl.drawArraysInstanced = instanceExtension.drawArraysInstancedANGLE.bind(instanceExtension);
  29157. this._gl.drawElementsInstanced = instanceExtension.drawElementsInstancedANGLE.bind(instanceExtension);
  29158. this._gl.vertexAttribDivisor = instanceExtension.vertexAttribDivisorANGLE.bind(instanceExtension);
  29159. }
  29160. else {
  29161. this._caps.instancedArrays = false;
  29162. }
  29163. }
  29164. // Intelligently add supported compressed formats in order to check for.
  29165. // Check for ASTC support first as it is most powerful and to be very cross platform.
  29166. // Next PVRTC & DXT, which are probably superior to ETC1/2.
  29167. // Likely no hardware which supports both PVR & DXT, so order matters little.
  29168. // ETC2 is newer and handles ETC1 (no alpha capability), so check for first.
  29169. if (this._caps.astc) {
  29170. this.texturesSupported.push('-astc.ktx');
  29171. }
  29172. if (this._caps.s3tc) {
  29173. this.texturesSupported.push('-dxt.ktx');
  29174. }
  29175. if (this._caps.pvrtc) {
  29176. this.texturesSupported.push('-pvrtc.ktx');
  29177. }
  29178. if (this._caps.etc2) {
  29179. this.texturesSupported.push('-etc2.ktx');
  29180. }
  29181. if (this._caps.etc1) {
  29182. this.texturesSupported.push('-etc1.ktx');
  29183. }
  29184. if (this._gl.getShaderPrecisionFormat) {
  29185. var vertex_highp = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT);
  29186. var fragment_highp = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
  29187. if (vertex_highp && fragment_highp) {
  29188. this._caps.highPrecisionShaderSupported = vertex_highp.precision !== 0 && fragment_highp.precision !== 0;
  29189. }
  29190. }
  29191. // Depth buffer
  29192. this.setDepthBuffer(true);
  29193. this.setDepthFunctionToLessOrEqual();
  29194. this.setDepthWrite(true);
  29195. // Texture maps
  29196. this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;
  29197. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  29198. this._nextFreeTextureSlots.push(slot);
  29199. }
  29200. };
  29201. Object.defineProperty(Engine.prototype, "webGLVersion", {
  29202. /**
  29203. * Gets version of the current webGL context
  29204. */
  29205. get: function () {
  29206. return this._webGLVersion;
  29207. },
  29208. enumerable: true,
  29209. configurable: true
  29210. });
  29211. Object.defineProperty(Engine.prototype, "isStencilEnable", {
  29212. /**
  29213. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29214. */
  29215. get: function () {
  29216. return this._isStencilEnable;
  29217. },
  29218. enumerable: true,
  29219. configurable: true
  29220. });
  29221. Engine.prototype._prepareWorkingCanvas = function () {
  29222. if (this._workingCanvas) {
  29223. return;
  29224. }
  29225. this._workingCanvas = document.createElement("canvas");
  29226. var context = this._workingCanvas.getContext("2d");
  29227. if (context) {
  29228. this._workingContext = context;
  29229. }
  29230. };
  29231. /**
  29232. * Reset the texture cache to empty state
  29233. */
  29234. Engine.prototype.resetTextureCache = function () {
  29235. for (var key in this._boundTexturesCache) {
  29236. if (!this._boundTexturesCache.hasOwnProperty(key)) {
  29237. continue;
  29238. }
  29239. var boundTexture = this._boundTexturesCache[key];
  29240. if (boundTexture) {
  29241. this._removeDesignatedSlot(boundTexture);
  29242. }
  29243. this._boundTexturesCache[key] = null;
  29244. }
  29245. if (!this.disableTextureBindingOptimization) {
  29246. this._nextFreeTextureSlots = [];
  29247. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  29248. this._nextFreeTextureSlots.push(slot);
  29249. }
  29250. }
  29251. this._currentTextureChannel = -1;
  29252. };
  29253. /**
  29254. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  29255. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29256. * @returns true if engine is in deterministic lock step mode
  29257. */
  29258. Engine.prototype.isDeterministicLockStep = function () {
  29259. return this._deterministicLockstep;
  29260. };
  29261. /**
  29262. * Gets the max steps when engine is running in deterministic lock step
  29263. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29264. * @returns the max steps
  29265. */
  29266. Engine.prototype.getLockstepMaxSteps = function () {
  29267. return this._lockstepMaxSteps;
  29268. };
  29269. /**
  29270. * Gets an object containing information about the current webGL context
  29271. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29272. */
  29273. Engine.prototype.getGlInfo = function () {
  29274. return {
  29275. vendor: this._glVendor,
  29276. renderer: this._glRenderer,
  29277. version: this._glVersion
  29278. };
  29279. };
  29280. /**
  29281. * Gets current aspect ratio
  29282. * @param camera defines the camera to use to get the aspect ratio
  29283. * @param useScreen defines if screen size must be used (or the current render target if any)
  29284. * @returns a number defining the aspect ratio
  29285. */
  29286. Engine.prototype.getAspectRatio = function (camera, useScreen) {
  29287. if (useScreen === void 0) { useScreen = false; }
  29288. var viewport = camera.viewport;
  29289. return (this.getRenderWidth(useScreen) * viewport.width) / (this.getRenderHeight(useScreen) * viewport.height);
  29290. };
  29291. /**
  29292. * Gets current screen aspect ratio
  29293. * @returns a number defining the aspect ratio
  29294. */
  29295. Engine.prototype.getScreenAspectRatio = function () {
  29296. return (this.getRenderWidth(true)) / (this.getRenderHeight(true));
  29297. };
  29298. /**
  29299. * Gets the current render width
  29300. * @param useScreen defines if screen size must be used (or the current render target if any)
  29301. * @returns a number defining the current render width
  29302. */
  29303. Engine.prototype.getRenderWidth = function (useScreen) {
  29304. if (useScreen === void 0) { useScreen = false; }
  29305. if (!useScreen && this._currentRenderTarget) {
  29306. return this._currentRenderTarget.width;
  29307. }
  29308. return this._gl.drawingBufferWidth;
  29309. };
  29310. /**
  29311. * Gets the current render height
  29312. * @param useScreen defines if screen size must be used (or the current render target if any)
  29313. * @returns a number defining the current render height
  29314. */
  29315. Engine.prototype.getRenderHeight = function (useScreen) {
  29316. if (useScreen === void 0) { useScreen = false; }
  29317. if (!useScreen && this._currentRenderTarget) {
  29318. return this._currentRenderTarget.height;
  29319. }
  29320. return this._gl.drawingBufferHeight;
  29321. };
  29322. /**
  29323. * Gets the HTML canvas attached with the current webGL context
  29324. * @returns a HTML canvas
  29325. */
  29326. Engine.prototype.getRenderingCanvas = function () {
  29327. return this._renderingCanvas;
  29328. };
  29329. /**
  29330. * Gets the client rect of the HTML canvas attached with the current webGL context
  29331. * @returns a client rectanglee
  29332. */
  29333. Engine.prototype.getRenderingCanvasClientRect = function () {
  29334. if (!this._renderingCanvas) {
  29335. return null;
  29336. }
  29337. return this._renderingCanvas.getBoundingClientRect();
  29338. };
  29339. /**
  29340. * Defines the hardware scaling level.
  29341. * By default the hardware scaling level is computed from the window device ratio.
  29342. * 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.
  29343. * @param level defines the level to use
  29344. */
  29345. Engine.prototype.setHardwareScalingLevel = function (level) {
  29346. this._hardwareScalingLevel = level;
  29347. this.resize();
  29348. };
  29349. /**
  29350. * Gets the current hardware scaling level.
  29351. * By default the hardware scaling level is computed from the window device ratio.
  29352. * 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.
  29353. * @returns a number indicating the current hardware scaling level
  29354. */
  29355. Engine.prototype.getHardwareScalingLevel = function () {
  29356. return this._hardwareScalingLevel;
  29357. };
  29358. /**
  29359. * Gets the list of loaded textures
  29360. * @returns an array containing all loaded textures
  29361. */
  29362. Engine.prototype.getLoadedTexturesCache = function () {
  29363. return this._internalTexturesCache;
  29364. };
  29365. /**
  29366. * Gets the object containing all engine capabilities
  29367. * @returns the EngineCapabilities object
  29368. */
  29369. Engine.prototype.getCaps = function () {
  29370. return this._caps;
  29371. };
  29372. /**
  29373. * Gets the current depth function
  29374. * @returns a number defining the depth function
  29375. */
  29376. Engine.prototype.getDepthFunction = function () {
  29377. return this._depthCullingState.depthFunc;
  29378. };
  29379. /**
  29380. * Sets the current depth function
  29381. * @param depthFunc defines the function to use
  29382. */
  29383. Engine.prototype.setDepthFunction = function (depthFunc) {
  29384. this._depthCullingState.depthFunc = depthFunc;
  29385. };
  29386. /**
  29387. * Sets the current depth function to GREATER
  29388. */
  29389. Engine.prototype.setDepthFunctionToGreater = function () {
  29390. this._depthCullingState.depthFunc = this._gl.GREATER;
  29391. };
  29392. /**
  29393. * Sets the current depth function to GEQUAL
  29394. */
  29395. Engine.prototype.setDepthFunctionToGreaterOrEqual = function () {
  29396. this._depthCullingState.depthFunc = this._gl.GEQUAL;
  29397. };
  29398. /**
  29399. * Sets the current depth function to LESS
  29400. */
  29401. Engine.prototype.setDepthFunctionToLess = function () {
  29402. this._depthCullingState.depthFunc = this._gl.LESS;
  29403. };
  29404. /**
  29405. * Caches the the state of the stencil buffer
  29406. */
  29407. Engine.prototype.cacheStencilState = function () {
  29408. this._cachedStencilBuffer = this.getStencilBuffer();
  29409. this._cachedStencilFunction = this.getStencilFunction();
  29410. this._cachedStencilMask = this.getStencilMask();
  29411. this._cachedStencilOperationPass = this.getStencilOperationPass();
  29412. this._cachedStencilOperationFail = this.getStencilOperationFail();
  29413. this._cachedStencilOperationDepthFail = this.getStencilOperationDepthFail();
  29414. this._cachedStencilReference = this.getStencilFunctionReference();
  29415. };
  29416. /**
  29417. * Restores the state of the stencil buffer
  29418. */
  29419. Engine.prototype.restoreStencilState = function () {
  29420. this.setStencilFunction(this._cachedStencilFunction);
  29421. this.setStencilMask(this._cachedStencilMask);
  29422. this.setStencilBuffer(this._cachedStencilBuffer);
  29423. this.setStencilOperationPass(this._cachedStencilOperationPass);
  29424. this.setStencilOperationFail(this._cachedStencilOperationFail);
  29425. this.setStencilOperationDepthFail(this._cachedStencilOperationDepthFail);
  29426. this.setStencilFunctionReference(this._cachedStencilReference);
  29427. };
  29428. /**
  29429. * Sets the current depth function to LEQUAL
  29430. */
  29431. Engine.prototype.setDepthFunctionToLessOrEqual = function () {
  29432. this._depthCullingState.depthFunc = this._gl.LEQUAL;
  29433. };
  29434. /**
  29435. * Gets a boolean indicating if stencil buffer is enabled
  29436. * @returns the current stencil buffer state
  29437. */
  29438. Engine.prototype.getStencilBuffer = function () {
  29439. return this._stencilState.stencilTest;
  29440. };
  29441. /**
  29442. * Enable or disable the stencil buffer
  29443. * @param enable defines if the stencil buffer must be enabled or disabled
  29444. */
  29445. Engine.prototype.setStencilBuffer = function (enable) {
  29446. this._stencilState.stencilTest = enable;
  29447. };
  29448. /**
  29449. * Gets the current stencil mask
  29450. * @returns a number defining the new stencil mask to use
  29451. */
  29452. Engine.prototype.getStencilMask = function () {
  29453. return this._stencilState.stencilMask;
  29454. };
  29455. /**
  29456. * Sets the current stencil mask
  29457. * @param mask defines the new stencil mask to use
  29458. */
  29459. Engine.prototype.setStencilMask = function (mask) {
  29460. this._stencilState.stencilMask = mask;
  29461. };
  29462. /**
  29463. * Gets the current stencil function
  29464. * @returns a number defining the stencil function to use
  29465. */
  29466. Engine.prototype.getStencilFunction = function () {
  29467. return this._stencilState.stencilFunc;
  29468. };
  29469. /**
  29470. * Gets the current stencil reference value
  29471. * @returns a number defining the stencil reference value to use
  29472. */
  29473. Engine.prototype.getStencilFunctionReference = function () {
  29474. return this._stencilState.stencilFuncRef;
  29475. };
  29476. /**
  29477. * Gets the current stencil mask
  29478. * @returns a number defining the stencil mask to use
  29479. */
  29480. Engine.prototype.getStencilFunctionMask = function () {
  29481. return this._stencilState.stencilFuncMask;
  29482. };
  29483. /**
  29484. * Sets the current stencil function
  29485. * @param stencilFunc defines the new stencil function to use
  29486. */
  29487. Engine.prototype.setStencilFunction = function (stencilFunc) {
  29488. this._stencilState.stencilFunc = stencilFunc;
  29489. };
  29490. /**
  29491. * Sets the current stencil reference
  29492. * @param reference defines the new stencil reference to use
  29493. */
  29494. Engine.prototype.setStencilFunctionReference = function (reference) {
  29495. this._stencilState.stencilFuncRef = reference;
  29496. };
  29497. /**
  29498. * Sets the current stencil mask
  29499. * @param mask defines the new stencil mask to use
  29500. */
  29501. Engine.prototype.setStencilFunctionMask = function (mask) {
  29502. this._stencilState.stencilFuncMask = mask;
  29503. };
  29504. /**
  29505. * Gets the current stencil operation when stencil fails
  29506. * @returns a number defining stencil operation to use when stencil fails
  29507. */
  29508. Engine.prototype.getStencilOperationFail = function () {
  29509. return this._stencilState.stencilOpStencilFail;
  29510. };
  29511. /**
  29512. * Gets the current stencil operation when depth fails
  29513. * @returns a number defining stencil operation to use when depth fails
  29514. */
  29515. Engine.prototype.getStencilOperationDepthFail = function () {
  29516. return this._stencilState.stencilOpDepthFail;
  29517. };
  29518. /**
  29519. * Gets the current stencil operation when stencil passes
  29520. * @returns a number defining stencil operation to use when stencil passes
  29521. */
  29522. Engine.prototype.getStencilOperationPass = function () {
  29523. return this._stencilState.stencilOpStencilDepthPass;
  29524. };
  29525. /**
  29526. * Sets the stencil operation to use when stencil fails
  29527. * @param operation defines the stencil operation to use when stencil fails
  29528. */
  29529. Engine.prototype.setStencilOperationFail = function (operation) {
  29530. this._stencilState.stencilOpStencilFail = operation;
  29531. };
  29532. /**
  29533. * Sets the stencil operation to use when depth fails
  29534. * @param operation defines the stencil operation to use when depth fails
  29535. */
  29536. Engine.prototype.setStencilOperationDepthFail = function (operation) {
  29537. this._stencilState.stencilOpDepthFail = operation;
  29538. };
  29539. /**
  29540. * Sets the stencil operation to use when stencil passes
  29541. * @param operation defines the stencil operation to use when stencil passes
  29542. */
  29543. Engine.prototype.setStencilOperationPass = function (operation) {
  29544. this._stencilState.stencilOpStencilDepthPass = operation;
  29545. };
  29546. /**
  29547. * Sets a boolean indicating if the dithering state is enabled or disabled
  29548. * @param value defines the dithering state
  29549. */
  29550. Engine.prototype.setDitheringState = function (value) {
  29551. if (value) {
  29552. this._gl.enable(this._gl.DITHER);
  29553. }
  29554. else {
  29555. this._gl.disable(this._gl.DITHER);
  29556. }
  29557. };
  29558. /**
  29559. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  29560. * @param value defines the rasterizer state
  29561. */
  29562. Engine.prototype.setRasterizerState = function (value) {
  29563. if (value) {
  29564. this._gl.disable(this._gl.RASTERIZER_DISCARD);
  29565. }
  29566. else {
  29567. this._gl.enable(this._gl.RASTERIZER_DISCARD);
  29568. }
  29569. };
  29570. /**
  29571. * stop executing a render loop function and remove it from the execution array
  29572. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29573. */
  29574. Engine.prototype.stopRenderLoop = function (renderFunction) {
  29575. if (!renderFunction) {
  29576. this._activeRenderLoops = [];
  29577. return;
  29578. }
  29579. var index = this._activeRenderLoops.indexOf(renderFunction);
  29580. if (index >= 0) {
  29581. this._activeRenderLoops.splice(index, 1);
  29582. }
  29583. };
  29584. /** @hidden */
  29585. Engine.prototype._renderLoop = function () {
  29586. if (!this._contextWasLost) {
  29587. var shouldRender = true;
  29588. if (!this.renderEvenInBackground && this._windowIsBackground) {
  29589. shouldRender = false;
  29590. }
  29591. if (shouldRender) {
  29592. // Start new frame
  29593. this.beginFrame();
  29594. for (var index = 0; index < this._activeRenderLoops.length; index++) {
  29595. var renderFunction = this._activeRenderLoops[index];
  29596. renderFunction();
  29597. }
  29598. // Present
  29599. this.endFrame();
  29600. }
  29601. }
  29602. if (this._activeRenderLoops.length > 0) {
  29603. // Register new frame
  29604. if (this.customAnimationFrameRequester) {
  29605. this.customAnimationFrameRequester.requestID = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this.customAnimationFrameRequester.renderFunction || this._bindedRenderFunction, this.customAnimationFrameRequester);
  29606. this._frameHandler = this.customAnimationFrameRequester.requestID;
  29607. }
  29608. else if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29609. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction, this._vrDisplay);
  29610. }
  29611. else {
  29612. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  29613. }
  29614. }
  29615. else {
  29616. this._renderingQueueLaunched = false;
  29617. }
  29618. };
  29619. /**
  29620. * Register and execute a render loop. The engine can have more than one render function
  29621. * @param renderFunction defines the function to continuously execute
  29622. */
  29623. Engine.prototype.runRenderLoop = function (renderFunction) {
  29624. if (this._activeRenderLoops.indexOf(renderFunction) !== -1) {
  29625. return;
  29626. }
  29627. this._activeRenderLoops.push(renderFunction);
  29628. if (!this._renderingQueueLaunched) {
  29629. this._renderingQueueLaunched = true;
  29630. this._bindedRenderFunction = this._renderLoop.bind(this);
  29631. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  29632. }
  29633. };
  29634. /**
  29635. * Toggle full screen mode
  29636. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29637. */
  29638. Engine.prototype.switchFullscreen = function (requestPointerLock) {
  29639. if (this.isFullscreen) {
  29640. this.exitFullscreen();
  29641. }
  29642. else {
  29643. this.enterFullscreen(requestPointerLock);
  29644. }
  29645. };
  29646. /**
  29647. * Enters full screen mode
  29648. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29649. */
  29650. Engine.prototype.enterFullscreen = function (requestPointerLock) {
  29651. if (!this.isFullscreen) {
  29652. this._pointerLockRequested = requestPointerLock;
  29653. if (this._renderingCanvas) {
  29654. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].RequestFullscreen(this._renderingCanvas);
  29655. }
  29656. }
  29657. };
  29658. /**
  29659. * Exits full screen mode
  29660. */
  29661. Engine.prototype.exitFullscreen = function () {
  29662. if (this.isFullscreen) {
  29663. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].ExitFullscreen();
  29664. }
  29665. };
  29666. /**
  29667. * Clear the current render buffer or the current render target (if any is set up)
  29668. * @param color defines the color to use
  29669. * @param backBuffer defines if the back buffer must be cleared
  29670. * @param depth defines if the depth buffer must be cleared
  29671. * @param stencil defines if the stencil buffer must be cleared
  29672. */
  29673. Engine.prototype.clear = function (color, backBuffer, depth, stencil) {
  29674. if (stencil === void 0) { stencil = false; }
  29675. this.applyStates();
  29676. var mode = 0;
  29677. if (backBuffer && color) {
  29678. this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
  29679. mode |= this._gl.COLOR_BUFFER_BIT;
  29680. }
  29681. if (depth) {
  29682. this._gl.clearDepth(1.0);
  29683. mode |= this._gl.DEPTH_BUFFER_BIT;
  29684. }
  29685. if (stencil) {
  29686. this._gl.clearStencil(0);
  29687. mode |= this._gl.STENCIL_BUFFER_BIT;
  29688. }
  29689. this._gl.clear(mode);
  29690. };
  29691. /**
  29692. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29693. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29694. * @param y defines the y-coordinate of the corner of the clear rectangle
  29695. * @param width defines the width of the clear rectangle
  29696. * @param height defines the height of the clear rectangle
  29697. * @param clearColor defines the clear color
  29698. */
  29699. Engine.prototype.scissorClear = function (x, y, width, height, clearColor) {
  29700. this.enableScissor(x, y, width, height);
  29701. this.clear(clearColor, true, true, true);
  29702. this.disableScissor();
  29703. };
  29704. /**
  29705. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29706. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29707. * @param y defines the y-coordinate of the corner of the clear rectangle
  29708. * @param width defines the width of the clear rectangle
  29709. * @param height defines the height of the clear rectangle
  29710. */
  29711. Engine.prototype.enableScissor = function (x, y, width, height) {
  29712. var gl = this._gl;
  29713. // Change state
  29714. gl.enable(gl.SCISSOR_TEST);
  29715. gl.scissor(x, y, width, height);
  29716. };
  29717. /**
  29718. * Disable previously set scissor test rectangle
  29719. */
  29720. Engine.prototype.disableScissor = function () {
  29721. var gl = this._gl;
  29722. gl.disable(gl.SCISSOR_TEST);
  29723. };
  29724. /** @hidden */
  29725. Engine.prototype._viewport = function (x, y, width, height) {
  29726. if (x !== this._viewportCached.x ||
  29727. y !== this._viewportCached.y ||
  29728. width !== this._viewportCached.z ||
  29729. height !== this._viewportCached.w) {
  29730. this._viewportCached.x = x;
  29731. this._viewportCached.y = y;
  29732. this._viewportCached.z = width;
  29733. this._viewportCached.w = height;
  29734. this._gl.viewport(x, y, width, height);
  29735. }
  29736. };
  29737. /**
  29738. * Set the WebGL's viewport
  29739. * @param viewport defines the viewport element to be used
  29740. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29741. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29742. */
  29743. Engine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  29744. var width = requiredWidth || this.getRenderWidth();
  29745. var height = requiredHeight || this.getRenderHeight();
  29746. var x = viewport.x || 0;
  29747. var y = viewport.y || 0;
  29748. this._cachedViewport = viewport;
  29749. this._viewport(x * width, y * height, width * viewport.width, height * viewport.height);
  29750. };
  29751. /**
  29752. * Directly set the WebGL Viewport
  29753. * @param x defines the x coordinate of the viewport (in screen space)
  29754. * @param y defines the y coordinate of the viewport (in screen space)
  29755. * @param width defines the width of the viewport (in screen space)
  29756. * @param height defines the height of the viewport (in screen space)
  29757. * @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
  29758. */
  29759. Engine.prototype.setDirectViewport = function (x, y, width, height) {
  29760. var currentViewport = this._cachedViewport;
  29761. this._cachedViewport = null;
  29762. this._viewport(x, y, width, height);
  29763. return currentViewport;
  29764. };
  29765. /**
  29766. * Begin a new frame
  29767. */
  29768. Engine.prototype.beginFrame = function () {
  29769. this.onBeginFrameObservable.notifyObservers(this);
  29770. this._measureFps();
  29771. };
  29772. /**
  29773. * Enf the current frame
  29774. */
  29775. Engine.prototype.endFrame = function () {
  29776. // Force a flush in case we are using a bad OS.
  29777. if (this._badOS) {
  29778. this.flushFramebuffer();
  29779. }
  29780. // Submit frame to the vr device, if enabled
  29781. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29782. // TODO: We should only submit the frame if we read frameData successfully.
  29783. try {
  29784. this._vrDisplay.submitFrame();
  29785. }
  29786. catch (e) {
  29787. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].Warn("webVR submitFrame has had an unexpected failure: " + e);
  29788. }
  29789. }
  29790. this.onEndFrameObservable.notifyObservers(this);
  29791. };
  29792. /**
  29793. * Resize the view according to the canvas' size
  29794. */
  29795. Engine.prototype.resize = function () {
  29796. // We're not resizing the size of the canvas while in VR mode & presenting
  29797. if (!(this._vrDisplay && this._vrDisplay.isPresenting)) {
  29798. var width = this._renderingCanvas ? this._renderingCanvas.clientWidth : window.innerWidth;
  29799. var height = this._renderingCanvas ? this._renderingCanvas.clientHeight : window.innerHeight;
  29800. this.setSize(width / this._hardwareScalingLevel, height / this._hardwareScalingLevel);
  29801. }
  29802. };
  29803. /**
  29804. * Force a specific size of the canvas
  29805. * @param width defines the new canvas' width
  29806. * @param height defines the new canvas' height
  29807. */
  29808. Engine.prototype.setSize = function (width, height) {
  29809. if (!this._renderingCanvas) {
  29810. return;
  29811. }
  29812. if (this._renderingCanvas.width === width && this._renderingCanvas.height === height) {
  29813. return;
  29814. }
  29815. this._renderingCanvas.width = width;
  29816. this._renderingCanvas.height = height;
  29817. for (var index = 0; index < this.scenes.length; index++) {
  29818. var scene = this.scenes[index];
  29819. for (var camIndex = 0; camIndex < scene.cameras.length; camIndex++) {
  29820. var cam = scene.cameras[camIndex];
  29821. cam._currentRenderId = 0;
  29822. }
  29823. }
  29824. if (this.onResizeObservable.hasObservers) {
  29825. this.onResizeObservable.notifyObservers(this);
  29826. }
  29827. };
  29828. // WebVR functions
  29829. /**
  29830. * Gets a boolean indicating if a webVR device was detected
  29831. * @returns true if a webVR device was detected
  29832. */
  29833. Engine.prototype.isVRDevicePresent = function () {
  29834. return !!this._vrDisplay;
  29835. };
  29836. /**
  29837. * Gets the current webVR device
  29838. * @returns the current webVR device (or null)
  29839. */
  29840. Engine.prototype.getVRDevice = function () {
  29841. return this._vrDisplay;
  29842. };
  29843. /**
  29844. * Initializes a webVR display and starts listening to display change events
  29845. * The onVRDisplayChangedObservable will be notified upon these changes
  29846. * @returns The onVRDisplayChangedObservable
  29847. */
  29848. Engine.prototype.initWebVR = function () {
  29849. this.initWebVRAsync();
  29850. return this.onVRDisplayChangedObservable;
  29851. };
  29852. /**
  29853. * Initializes a webVR display and starts listening to display change events
  29854. * The onVRDisplayChangedObservable will be notified upon these changes
  29855. * @returns A promise containing a VRDisplay and if vr is supported
  29856. */
  29857. Engine.prototype.initWebVRAsync = function () {
  29858. var _this = this;
  29859. var notifyObservers = function () {
  29860. var eventArgs = {
  29861. vrDisplay: _this._vrDisplay,
  29862. vrSupported: _this._vrSupported
  29863. };
  29864. _this.onVRDisplayChangedObservable.notifyObservers(eventArgs);
  29865. _this._webVRInitPromise = new Promise(function (res) { res(eventArgs); });
  29866. };
  29867. if (!this._onVrDisplayConnect) {
  29868. this._onVrDisplayConnect = function (event) {
  29869. _this._vrDisplay = event.display;
  29870. notifyObservers();
  29871. };
  29872. this._onVrDisplayDisconnect = function () {
  29873. _this._vrDisplay.cancelAnimationFrame(_this._frameHandler);
  29874. _this._vrDisplay = undefined;
  29875. _this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(_this._bindedRenderFunction);
  29876. notifyObservers();
  29877. };
  29878. this._onVrDisplayPresentChange = function () {
  29879. _this._vrExclusivePointerMode = _this._vrDisplay && _this._vrDisplay.isPresenting;
  29880. };
  29881. window.addEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  29882. window.addEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  29883. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  29884. }
  29885. this._webVRInitPromise = this._webVRInitPromise || this._getVRDisplaysAsync();
  29886. this._webVRInitPromise.then(notifyObservers);
  29887. return this._webVRInitPromise;
  29888. };
  29889. /**
  29890. * Call this function to switch to webVR mode
  29891. * Will do nothing if webVR is not supported or if there is no webVR device
  29892. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29893. */
  29894. Engine.prototype.enableVR = function () {
  29895. var _this = this;
  29896. if (this._vrDisplay && !this._vrDisplay.isPresenting) {
  29897. var onResolved = function () {
  29898. _this.onVRRequestPresentComplete.notifyObservers(true);
  29899. _this._onVRFullScreenTriggered();
  29900. };
  29901. var onRejected = function () {
  29902. _this.onVRRequestPresentComplete.notifyObservers(false);
  29903. };
  29904. this.onVRRequestPresentStart.notifyObservers(this);
  29905. this._vrDisplay.requestPresent([{ source: this.getRenderingCanvas() }]).then(onResolved).catch(onRejected);
  29906. }
  29907. };
  29908. /**
  29909. * Call this function to leave webVR mode
  29910. * Will do nothing if webVR is not supported or if there is no webVR device
  29911. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29912. */
  29913. Engine.prototype.disableVR = function () {
  29914. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29915. this._vrDisplay.exitPresent().then(this._onVRFullScreenTriggered).catch(this._onVRFullScreenTriggered);
  29916. }
  29917. };
  29918. Engine.prototype._getVRDisplaysAsync = function () {
  29919. var _this = this;
  29920. return new Promise(function (res) {
  29921. if (navigator.getVRDisplays) {
  29922. navigator.getVRDisplays().then(function (devices) {
  29923. _this._vrSupported = true;
  29924. // note that devices may actually be an empty array. This is fine;
  29925. // we expect this._vrDisplay to be undefined in this case.
  29926. _this._vrDisplay = devices[0];
  29927. res({
  29928. vrDisplay: _this._vrDisplay,
  29929. vrSupported: _this._vrSupported
  29930. });
  29931. });
  29932. }
  29933. else {
  29934. _this._vrDisplay = undefined;
  29935. _this._vrSupported = false;
  29936. res({
  29937. vrDisplay: _this._vrDisplay,
  29938. vrSupported: _this._vrSupported
  29939. });
  29940. }
  29941. });
  29942. };
  29943. /**
  29944. * Binds the frame buffer to the specified texture.
  29945. * @param texture The texture to render to or null for the default canvas
  29946. * @param faceIndex The face of the texture to render to in case of cube texture
  29947. * @param requiredWidth The width of the target to render to
  29948. * @param requiredHeight The height of the target to render to
  29949. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29950. * @param depthStencilTexture The depth stencil texture to use to render
  29951. * @param lodLevel defines le lod level to bind to the frame buffer
  29952. */
  29953. Engine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport, depthStencilTexture, lodLevel) {
  29954. if (lodLevel === void 0) { lodLevel = 0; }
  29955. if (this._currentRenderTarget) {
  29956. this.unBindFramebuffer(this._currentRenderTarget);
  29957. }
  29958. this._currentRenderTarget = texture;
  29959. this.bindUnboundFramebuffer(texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer);
  29960. var gl = this._gl;
  29961. if (texture.isCube) {
  29962. if (faceIndex === undefined) {
  29963. faceIndex = 0;
  29964. }
  29965. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, lodLevel);
  29966. if (depthStencilTexture) {
  29967. if (depthStencilTexture._generateStencilBuffer) {
  29968. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  29969. }
  29970. else {
  29971. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  29972. }
  29973. }
  29974. }
  29975. if (this._cachedViewport && !forceFullscreenViewport) {
  29976. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  29977. }
  29978. else {
  29979. if (!requiredWidth) {
  29980. requiredWidth = texture.width;
  29981. if (lodLevel) {
  29982. requiredWidth = requiredWidth / Math.pow(2, lodLevel);
  29983. }
  29984. }
  29985. if (!requiredHeight) {
  29986. requiredHeight = texture.height;
  29987. if (lodLevel) {
  29988. requiredHeight = requiredHeight / Math.pow(2, lodLevel);
  29989. }
  29990. }
  29991. this._viewport(0, 0, requiredWidth, requiredHeight);
  29992. }
  29993. this.wipeCaches();
  29994. };
  29995. Engine.prototype.bindUnboundFramebuffer = function (framebuffer) {
  29996. if (this._currentFramebuffer !== framebuffer) {
  29997. this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, framebuffer);
  29998. this._currentFramebuffer = framebuffer;
  29999. }
  30000. };
  30001. /**
  30002. * Unbind the current render target texture from the webGL context
  30003. * @param texture defines the render target texture to unbind
  30004. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30005. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30006. */
  30007. Engine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  30008. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  30009. this._currentRenderTarget = null;
  30010. // If MSAA, we need to bitblt back to main texture
  30011. var gl = this._gl;
  30012. if (texture._MSAAFramebuffer) {
  30013. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, texture._MSAAFramebuffer);
  30014. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, texture._framebuffer);
  30015. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  30016. }
  30017. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  30018. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  30019. gl.generateMipmap(gl.TEXTURE_2D);
  30020. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  30021. }
  30022. if (onBeforeUnbind) {
  30023. if (texture._MSAAFramebuffer) {
  30024. // Bind the correct framebuffer
  30025. this.bindUnboundFramebuffer(texture._framebuffer);
  30026. }
  30027. onBeforeUnbind();
  30028. }
  30029. this.bindUnboundFramebuffer(null);
  30030. };
  30031. /**
  30032. * Unbind a list of render target textures from the webGL context
  30033. * This is used only when drawBuffer extension or webGL2 are active
  30034. * @param textures defines the render target textures to unbind
  30035. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30036. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30037. */
  30038. Engine.prototype.unBindMultiColorAttachmentFramebuffer = function (textures, disableGenerateMipMaps, onBeforeUnbind) {
  30039. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  30040. this._currentRenderTarget = null;
  30041. // If MSAA, we need to bitblt back to main texture
  30042. var gl = this._gl;
  30043. if (textures[0]._MSAAFramebuffer) {
  30044. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, textures[0]._MSAAFramebuffer);
  30045. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, textures[0]._framebuffer);
  30046. var attachments = textures[0]._attachments;
  30047. if (!attachments) {
  30048. attachments = new Array(textures.length);
  30049. textures[0]._attachments = attachments;
  30050. }
  30051. for (var i = 0; i < textures.length; i++) {
  30052. var texture = textures[i];
  30053. for (var j = 0; j < attachments.length; j++) {
  30054. attachments[j] = gl.NONE;
  30055. }
  30056. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  30057. gl.readBuffer(attachments[i]);
  30058. gl.drawBuffers(attachments);
  30059. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  30060. }
  30061. for (var i = 0; i < attachments.length; i++) {
  30062. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  30063. }
  30064. gl.drawBuffers(attachments);
  30065. }
  30066. for (var i = 0; i < textures.length; i++) {
  30067. var texture = textures[i];
  30068. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  30069. this._bindTextureDirectly(gl.TEXTURE_2D, texture);
  30070. gl.generateMipmap(gl.TEXTURE_2D);
  30071. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  30072. }
  30073. }
  30074. if (onBeforeUnbind) {
  30075. if (textures[0]._MSAAFramebuffer) {
  30076. // Bind the correct framebuffer
  30077. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  30078. }
  30079. onBeforeUnbind();
  30080. }
  30081. this.bindUnboundFramebuffer(null);
  30082. };
  30083. /**
  30084. * Force the mipmap generation for the given render target texture
  30085. * @param texture defines the render target texture to use
  30086. */
  30087. Engine.prototype.generateMipMapsForCubemap = function (texture) {
  30088. if (texture.generateMipMaps) {
  30089. var gl = this._gl;
  30090. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  30091. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  30092. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  30093. }
  30094. };
  30095. /**
  30096. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30097. */
  30098. Engine.prototype.flushFramebuffer = function () {
  30099. this._gl.flush();
  30100. };
  30101. /**
  30102. * Unbind the current render target and bind the default framebuffer
  30103. */
  30104. Engine.prototype.restoreDefaultFramebuffer = function () {
  30105. if (this._currentRenderTarget) {
  30106. this.unBindFramebuffer(this._currentRenderTarget);
  30107. }
  30108. else {
  30109. this.bindUnboundFramebuffer(null);
  30110. }
  30111. if (this._cachedViewport) {
  30112. this.setViewport(this._cachedViewport);
  30113. }
  30114. this.wipeCaches();
  30115. };
  30116. // UBOs
  30117. /**
  30118. * Create an uniform buffer
  30119. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30120. * @param elements defines the content of the uniform buffer
  30121. * @returns the webGL uniform buffer
  30122. */
  30123. Engine.prototype.createUniformBuffer = function (elements) {
  30124. var ubo = this._gl.createBuffer();
  30125. if (!ubo) {
  30126. throw new Error("Unable to create uniform buffer");
  30127. }
  30128. this.bindUniformBuffer(ubo);
  30129. if (elements instanceof Float32Array) {
  30130. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.STATIC_DRAW);
  30131. }
  30132. else {
  30133. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.STATIC_DRAW);
  30134. }
  30135. this.bindUniformBuffer(null);
  30136. ubo.references = 1;
  30137. return ubo;
  30138. };
  30139. /**
  30140. * Create a dynamic uniform buffer
  30141. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30142. * @param elements defines the content of the uniform buffer
  30143. * @returns the webGL uniform buffer
  30144. */
  30145. Engine.prototype.createDynamicUniformBuffer = function (elements) {
  30146. var ubo = this._gl.createBuffer();
  30147. if (!ubo) {
  30148. throw new Error("Unable to create dynamic uniform buffer");
  30149. }
  30150. this.bindUniformBuffer(ubo);
  30151. if (elements instanceof Float32Array) {
  30152. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.DYNAMIC_DRAW);
  30153. }
  30154. else {
  30155. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.DYNAMIC_DRAW);
  30156. }
  30157. this.bindUniformBuffer(null);
  30158. ubo.references = 1;
  30159. return ubo;
  30160. };
  30161. /**
  30162. * Update an existing uniform buffer
  30163. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30164. * @param uniformBuffer defines the target uniform buffer
  30165. * @param elements defines the content to update
  30166. * @param offset defines the offset in the uniform buffer where update should start
  30167. * @param count defines the size of the data to update
  30168. */
  30169. Engine.prototype.updateUniformBuffer = function (uniformBuffer, elements, offset, count) {
  30170. this.bindUniformBuffer(uniformBuffer);
  30171. if (offset === undefined) {
  30172. offset = 0;
  30173. }
  30174. if (count === undefined) {
  30175. if (elements instanceof Float32Array) {
  30176. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, elements);
  30177. }
  30178. else {
  30179. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, new Float32Array(elements));
  30180. }
  30181. }
  30182. else {
  30183. if (elements instanceof Float32Array) {
  30184. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, elements.subarray(offset, offset + count));
  30185. }
  30186. else {
  30187. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, new Float32Array(elements).subarray(offset, offset + count));
  30188. }
  30189. }
  30190. this.bindUniformBuffer(null);
  30191. };
  30192. // VBOs
  30193. Engine.prototype._resetVertexBufferBinding = function () {
  30194. this.bindArrayBuffer(null);
  30195. this._cachedVertexBuffers = null;
  30196. };
  30197. /**
  30198. * Creates a vertex buffer
  30199. * @param data the data for the vertex buffer
  30200. * @returns the new WebGL static buffer
  30201. */
  30202. Engine.prototype.createVertexBuffer = function (data) {
  30203. var vbo = this._gl.createBuffer();
  30204. if (!vbo) {
  30205. throw new Error("Unable to create vertex buffer");
  30206. }
  30207. this.bindArrayBuffer(vbo);
  30208. if (data instanceof Array) {
  30209. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.STATIC_DRAW);
  30210. }
  30211. else {
  30212. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.STATIC_DRAW);
  30213. }
  30214. this._resetVertexBufferBinding();
  30215. vbo.references = 1;
  30216. return vbo;
  30217. };
  30218. /**
  30219. * Creates a dynamic vertex buffer
  30220. * @param data the data for the dynamic vertex buffer
  30221. * @returns the new WebGL dynamic buffer
  30222. */
  30223. Engine.prototype.createDynamicVertexBuffer = function (data) {
  30224. var vbo = this._gl.createBuffer();
  30225. if (!vbo) {
  30226. throw new Error("Unable to create dynamic vertex buffer");
  30227. }
  30228. this.bindArrayBuffer(vbo);
  30229. if (data instanceof Array) {
  30230. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.DYNAMIC_DRAW);
  30231. }
  30232. else {
  30233. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.DYNAMIC_DRAW);
  30234. }
  30235. this._resetVertexBufferBinding();
  30236. vbo.references = 1;
  30237. return vbo;
  30238. };
  30239. /**
  30240. * Update a dynamic index buffer
  30241. * @param indexBuffer defines the target index buffer
  30242. * @param indices defines the data to update
  30243. * @param offset defines the offset in the target index buffer where update should start
  30244. */
  30245. Engine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  30246. if (offset === void 0) { offset = 0; }
  30247. // Force cache update
  30248. this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null;
  30249. this.bindIndexBuffer(indexBuffer);
  30250. var arrayBuffer;
  30251. if (indices instanceof Uint16Array || indices instanceof Uint32Array) {
  30252. arrayBuffer = indices;
  30253. }
  30254. else {
  30255. arrayBuffer = indexBuffer.is32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  30256. }
  30257. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.DYNAMIC_DRAW);
  30258. this._resetIndexBufferBinding();
  30259. };
  30260. /**
  30261. * Updates a dynamic vertex buffer.
  30262. * @param vertexBuffer the vertex buffer to update
  30263. * @param data the data used to update the vertex buffer
  30264. * @param byteOffset the byte offset of the data
  30265. * @param byteLength the byte length of the data
  30266. */
  30267. Engine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, data, byteOffset, byteLength) {
  30268. this.bindArrayBuffer(vertexBuffer);
  30269. if (byteOffset === undefined) {
  30270. byteOffset = 0;
  30271. }
  30272. if (byteLength === undefined) {
  30273. if (data instanceof Array) {
  30274. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, new Float32Array(data));
  30275. }
  30276. else {
  30277. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, data);
  30278. }
  30279. }
  30280. else {
  30281. if (data instanceof Array) {
  30282. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, new Float32Array(data).subarray(byteOffset, byteOffset + byteLength));
  30283. }
  30284. else {
  30285. if (data instanceof ArrayBuffer) {
  30286. data = new Uint8Array(data, byteOffset, byteLength);
  30287. }
  30288. else {
  30289. data = new Uint8Array(data.buffer, data.byteOffset + byteOffset, byteLength);
  30290. }
  30291. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  30292. }
  30293. }
  30294. this._resetVertexBufferBinding();
  30295. };
  30296. Engine.prototype._resetIndexBufferBinding = function () {
  30297. this.bindIndexBuffer(null);
  30298. this._cachedIndexBuffer = null;
  30299. };
  30300. /**
  30301. * Creates a new index buffer
  30302. * @param indices defines the content of the index buffer
  30303. * @param updatable defines if the index buffer must be updatable
  30304. * @returns a new webGL buffer
  30305. */
  30306. Engine.prototype.createIndexBuffer = function (indices, updatable) {
  30307. var vbo = this._gl.createBuffer();
  30308. if (!vbo) {
  30309. throw new Error("Unable to create index buffer");
  30310. }
  30311. this.bindIndexBuffer(vbo);
  30312. // Check for 32 bits indices
  30313. var arrayBuffer;
  30314. var need32Bits = false;
  30315. if (indices instanceof Uint16Array) {
  30316. arrayBuffer = indices;
  30317. }
  30318. else {
  30319. //check 32 bit support
  30320. if (this._caps.uintIndices) {
  30321. if (indices instanceof Uint32Array) {
  30322. arrayBuffer = indices;
  30323. need32Bits = true;
  30324. }
  30325. else {
  30326. //number[] or Int32Array, check if 32 bit is necessary
  30327. for (var index = 0; index < indices.length; index++) {
  30328. if (indices[index] > 65535) {
  30329. need32Bits = true;
  30330. break;
  30331. }
  30332. }
  30333. arrayBuffer = need32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  30334. }
  30335. }
  30336. else {
  30337. //no 32 bit support, force conversion to 16 bit (values greater 16 bit are lost)
  30338. arrayBuffer = new Uint16Array(indices);
  30339. }
  30340. }
  30341. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);
  30342. this._resetIndexBufferBinding();
  30343. vbo.references = 1;
  30344. vbo.is32Bits = need32Bits;
  30345. return vbo;
  30346. };
  30347. /**
  30348. * Bind a webGL buffer to the webGL context
  30349. * @param buffer defines the buffer to bind
  30350. */
  30351. Engine.prototype.bindArrayBuffer = function (buffer) {
  30352. if (!this._vaoRecordInProgress) {
  30353. this._unbindVertexArrayObject();
  30354. }
  30355. this.bindBuffer(buffer, this._gl.ARRAY_BUFFER);
  30356. };
  30357. /**
  30358. * Bind an uniform buffer to the current webGL context
  30359. * @param buffer defines the buffer to bind
  30360. */
  30361. Engine.prototype.bindUniformBuffer = function (buffer) {
  30362. this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, buffer);
  30363. };
  30364. /**
  30365. * Bind a buffer to the current webGL context at a given location
  30366. * @param buffer defines the buffer to bind
  30367. * @param location defines the index where to bind the buffer
  30368. */
  30369. Engine.prototype.bindUniformBufferBase = function (buffer, location) {
  30370. this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, location, buffer);
  30371. };
  30372. /**
  30373. * Bind a specific block at a given index in a specific shader program
  30374. * @param shaderProgram defines the shader program
  30375. * @param blockName defines the block name
  30376. * @param index defines the index where to bind the block
  30377. */
  30378. Engine.prototype.bindUniformBlock = function (shaderProgram, blockName, index) {
  30379. var uniformLocation = this._gl.getUniformBlockIndex(shaderProgram, blockName);
  30380. this._gl.uniformBlockBinding(shaderProgram, uniformLocation, index);
  30381. };
  30382. Engine.prototype.bindIndexBuffer = function (buffer) {
  30383. if (!this._vaoRecordInProgress) {
  30384. this._unbindVertexArrayObject();
  30385. }
  30386. this.bindBuffer(buffer, this._gl.ELEMENT_ARRAY_BUFFER);
  30387. };
  30388. Engine.prototype.bindBuffer = function (buffer, target) {
  30389. if (this._vaoRecordInProgress || this._currentBoundBuffer[target] !== buffer) {
  30390. this._gl.bindBuffer(target, buffer);
  30391. this._currentBoundBuffer[target] = buffer;
  30392. }
  30393. };
  30394. /**
  30395. * update the bound buffer with the given data
  30396. * @param data defines the data to update
  30397. */
  30398. Engine.prototype.updateArrayBuffer = function (data) {
  30399. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  30400. };
  30401. Engine.prototype._vertexAttribPointer = function (buffer, indx, size, type, normalized, stride, offset) {
  30402. var pointer = this._currentBufferPointers[indx];
  30403. var changed = false;
  30404. if (!pointer.active) {
  30405. changed = true;
  30406. pointer.active = true;
  30407. pointer.index = indx;
  30408. pointer.size = size;
  30409. pointer.type = type;
  30410. pointer.normalized = normalized;
  30411. pointer.stride = stride;
  30412. pointer.offset = offset;
  30413. pointer.buffer = buffer;
  30414. }
  30415. else {
  30416. if (pointer.buffer !== buffer) {
  30417. pointer.buffer = buffer;
  30418. changed = true;
  30419. }
  30420. if (pointer.size !== size) {
  30421. pointer.size = size;
  30422. changed = true;
  30423. }
  30424. if (pointer.type !== type) {
  30425. pointer.type = type;
  30426. changed = true;
  30427. }
  30428. if (pointer.normalized !== normalized) {
  30429. pointer.normalized = normalized;
  30430. changed = true;
  30431. }
  30432. if (pointer.stride !== stride) {
  30433. pointer.stride = stride;
  30434. changed = true;
  30435. }
  30436. if (pointer.offset !== offset) {
  30437. pointer.offset = offset;
  30438. changed = true;
  30439. }
  30440. }
  30441. if (changed || this._vaoRecordInProgress) {
  30442. this.bindArrayBuffer(buffer);
  30443. this._gl.vertexAttribPointer(indx, size, type, normalized, stride, offset);
  30444. }
  30445. };
  30446. Engine.prototype._bindIndexBufferWithCache = function (indexBuffer) {
  30447. if (indexBuffer == null) {
  30448. return;
  30449. }
  30450. if (this._cachedIndexBuffer !== indexBuffer) {
  30451. this._cachedIndexBuffer = indexBuffer;
  30452. this.bindIndexBuffer(indexBuffer);
  30453. this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
  30454. }
  30455. };
  30456. Engine.prototype._bindVertexBuffersAttributes = function (vertexBuffers, effect) {
  30457. var attributes = effect.getAttributesNames();
  30458. if (!this._vaoRecordInProgress) {
  30459. this._unbindVertexArrayObject();
  30460. }
  30461. this.unbindAllAttributes();
  30462. for (var index = 0; index < attributes.length; index++) {
  30463. var order = effect.getAttributeLocation(index);
  30464. if (order >= 0) {
  30465. var vertexBuffer = vertexBuffers[attributes[index]];
  30466. if (!vertexBuffer) {
  30467. continue;
  30468. }
  30469. this._gl.enableVertexAttribArray(order);
  30470. if (!this._vaoRecordInProgress) {
  30471. this._vertexAttribArraysEnabled[order] = true;
  30472. }
  30473. var buffer = vertexBuffer.getBuffer();
  30474. if (buffer) {
  30475. this._vertexAttribPointer(buffer, order, vertexBuffer.getSize(), vertexBuffer.type, vertexBuffer.normalized, vertexBuffer.byteStride, vertexBuffer.byteOffset);
  30476. if (vertexBuffer.getIsInstanced()) {
  30477. this._gl.vertexAttribDivisor(order, vertexBuffer.getInstanceDivisor());
  30478. if (!this._vaoRecordInProgress) {
  30479. this._currentInstanceLocations.push(order);
  30480. this._currentInstanceBuffers.push(buffer);
  30481. }
  30482. }
  30483. }
  30484. }
  30485. }
  30486. };
  30487. /**
  30488. * Records a vertex array object
  30489. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30490. * @param vertexBuffers defines the list of vertex buffers to store
  30491. * @param indexBuffer defines the index buffer to store
  30492. * @param effect defines the effect to store
  30493. * @returns the new vertex array object
  30494. */
  30495. Engine.prototype.recordVertexArrayObject = function (vertexBuffers, indexBuffer, effect) {
  30496. var vao = this._gl.createVertexArray();
  30497. this._vaoRecordInProgress = true;
  30498. this._gl.bindVertexArray(vao);
  30499. this._mustWipeVertexAttributes = true;
  30500. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  30501. this.bindIndexBuffer(indexBuffer);
  30502. this._vaoRecordInProgress = false;
  30503. this._gl.bindVertexArray(null);
  30504. return vao;
  30505. };
  30506. /**
  30507. * Bind a specific vertex array object
  30508. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30509. * @param vertexArrayObject defines the vertex array object to bind
  30510. * @param indexBuffer defines the index buffer to bind
  30511. */
  30512. Engine.prototype.bindVertexArrayObject = function (vertexArrayObject, indexBuffer) {
  30513. if (this._cachedVertexArrayObject !== vertexArrayObject) {
  30514. this._cachedVertexArrayObject = vertexArrayObject;
  30515. this._gl.bindVertexArray(vertexArrayObject);
  30516. this._cachedVertexBuffers = null;
  30517. this._cachedIndexBuffer = null;
  30518. this._uintIndicesCurrentlySet = indexBuffer != null && indexBuffer.is32Bits;
  30519. this._mustWipeVertexAttributes = true;
  30520. }
  30521. };
  30522. /**
  30523. * Bind webGl buffers directly to the webGL context
  30524. * @param vertexBuffer defines the vertex buffer to bind
  30525. * @param indexBuffer defines the index buffer to bind
  30526. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30527. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30528. * @param effect defines the effect associated with the vertex buffer
  30529. */
  30530. Engine.prototype.bindBuffersDirectly = function (vertexBuffer, indexBuffer, vertexDeclaration, vertexStrideSize, effect) {
  30531. if (this._cachedVertexBuffers !== vertexBuffer || this._cachedEffectForVertexBuffers !== effect) {
  30532. this._cachedVertexBuffers = vertexBuffer;
  30533. this._cachedEffectForVertexBuffers = effect;
  30534. var attributesCount = effect.getAttributesCount();
  30535. this._unbindVertexArrayObject();
  30536. this.unbindAllAttributes();
  30537. var offset = 0;
  30538. for (var index = 0; index < attributesCount; index++) {
  30539. if (index < vertexDeclaration.length) {
  30540. var order = effect.getAttributeLocation(index);
  30541. if (order >= 0) {
  30542. this._gl.enableVertexAttribArray(order);
  30543. this._vertexAttribArraysEnabled[order] = true;
  30544. this._vertexAttribPointer(vertexBuffer, order, vertexDeclaration[index], this._gl.FLOAT, false, vertexStrideSize, offset);
  30545. }
  30546. offset += vertexDeclaration[index] * 4;
  30547. }
  30548. }
  30549. }
  30550. this._bindIndexBufferWithCache(indexBuffer);
  30551. };
  30552. Engine.prototype._unbindVertexArrayObject = function () {
  30553. if (!this._cachedVertexArrayObject) {
  30554. return;
  30555. }
  30556. this._cachedVertexArrayObject = null;
  30557. this._gl.bindVertexArray(null);
  30558. };
  30559. /**
  30560. * Bind a list of vertex buffers to the webGL context
  30561. * @param vertexBuffers defines the list of vertex buffers to bind
  30562. * @param indexBuffer defines the index buffer to bind
  30563. * @param effect defines the effect associated with the vertex buffers
  30564. */
  30565. Engine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  30566. if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {
  30567. this._cachedVertexBuffers = vertexBuffers;
  30568. this._cachedEffectForVertexBuffers = effect;
  30569. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  30570. }
  30571. this._bindIndexBufferWithCache(indexBuffer);
  30572. };
  30573. /**
  30574. * Unbind all instance attributes
  30575. */
  30576. Engine.prototype.unbindInstanceAttributes = function () {
  30577. var boundBuffer;
  30578. for (var i = 0, ul = this._currentInstanceLocations.length; i < ul; i++) {
  30579. var instancesBuffer = this._currentInstanceBuffers[i];
  30580. if (boundBuffer != instancesBuffer && instancesBuffer.references) {
  30581. boundBuffer = instancesBuffer;
  30582. this.bindArrayBuffer(instancesBuffer);
  30583. }
  30584. var offsetLocation = this._currentInstanceLocations[i];
  30585. this._gl.vertexAttribDivisor(offsetLocation, 0);
  30586. }
  30587. this._currentInstanceBuffers.length = 0;
  30588. this._currentInstanceLocations.length = 0;
  30589. };
  30590. /**
  30591. * Release and free the memory of a vertex array object
  30592. * @param vao defines the vertex array object to delete
  30593. */
  30594. Engine.prototype.releaseVertexArrayObject = function (vao) {
  30595. this._gl.deleteVertexArray(vao);
  30596. };
  30597. /** @hidden */
  30598. Engine.prototype._releaseBuffer = function (buffer) {
  30599. buffer.references--;
  30600. if (buffer.references === 0) {
  30601. this._gl.deleteBuffer(buffer);
  30602. return true;
  30603. }
  30604. return false;
  30605. };
  30606. /**
  30607. * Creates a webGL buffer to use with instanciation
  30608. * @param capacity defines the size of the buffer
  30609. * @returns the webGL buffer
  30610. */
  30611. Engine.prototype.createInstancesBuffer = function (capacity) {
  30612. var buffer = this._gl.createBuffer();
  30613. if (!buffer) {
  30614. throw new Error("Unable to create instance buffer");
  30615. }
  30616. buffer.capacity = capacity;
  30617. this.bindArrayBuffer(buffer);
  30618. this._gl.bufferData(this._gl.ARRAY_BUFFER, capacity, this._gl.DYNAMIC_DRAW);
  30619. return buffer;
  30620. };
  30621. /**
  30622. * Delete a webGL buffer used with instanciation
  30623. * @param buffer defines the webGL buffer to delete
  30624. */
  30625. Engine.prototype.deleteInstancesBuffer = function (buffer) {
  30626. this._gl.deleteBuffer(buffer);
  30627. };
  30628. /**
  30629. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30630. * @param instancesBuffer defines the webGL buffer to update and bind
  30631. * @param data defines the data to store in the buffer
  30632. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30633. */
  30634. Engine.prototype.updateAndBindInstancesBuffer = function (instancesBuffer, data, offsetLocations) {
  30635. this.bindArrayBuffer(instancesBuffer);
  30636. if (data) {
  30637. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  30638. }
  30639. if (offsetLocations[0].index !== undefined) {
  30640. var stride = 0;
  30641. for (var i = 0; i < offsetLocations.length; i++) {
  30642. var ai = offsetLocations[i];
  30643. stride += ai.attributeSize * 4;
  30644. }
  30645. for (var i = 0; i < offsetLocations.length; i++) {
  30646. var ai = offsetLocations[i];
  30647. if (!this._vertexAttribArraysEnabled[ai.index]) {
  30648. this._gl.enableVertexAttribArray(ai.index);
  30649. this._vertexAttribArraysEnabled[ai.index] = true;
  30650. }
  30651. this._vertexAttribPointer(instancesBuffer, ai.index, ai.attributeSize, ai.attribyteType || this._gl.FLOAT, ai.normalized || false, stride, ai.offset);
  30652. this._gl.vertexAttribDivisor(ai.index, 1);
  30653. this._currentInstanceLocations.push(ai.index);
  30654. this._currentInstanceBuffers.push(instancesBuffer);
  30655. }
  30656. }
  30657. else {
  30658. for (var index = 0; index < 4; index++) {
  30659. var offsetLocation = offsetLocations[index];
  30660. if (!this._vertexAttribArraysEnabled[offsetLocation]) {
  30661. this._gl.enableVertexAttribArray(offsetLocation);
  30662. this._vertexAttribArraysEnabled[offsetLocation] = true;
  30663. }
  30664. this._vertexAttribPointer(instancesBuffer, offsetLocation, 4, this._gl.FLOAT, false, 64, index * 16);
  30665. this._gl.vertexAttribDivisor(offsetLocation, 1);
  30666. this._currentInstanceLocations.push(offsetLocation);
  30667. this._currentInstanceBuffers.push(instancesBuffer);
  30668. }
  30669. }
  30670. };
  30671. /**
  30672. * Apply all cached states (depth, culling, stencil and alpha)
  30673. */
  30674. Engine.prototype.applyStates = function () {
  30675. this._depthCullingState.apply(this._gl);
  30676. this._stencilState.apply(this._gl);
  30677. this._alphaState.apply(this._gl);
  30678. };
  30679. /**
  30680. * Send a draw order
  30681. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30682. * @param indexStart defines the starting index
  30683. * @param indexCount defines the number of index to draw
  30684. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30685. */
  30686. Engine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  30687. this.drawElementsType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, indexStart, indexCount, instancesCount);
  30688. };
  30689. /**
  30690. * Draw a list of points
  30691. * @param verticesStart defines the index of first vertex to draw
  30692. * @param verticesCount defines the count of vertices to draw
  30693. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30694. */
  30695. Engine.prototype.drawPointClouds = function (verticesStart, verticesCount, instancesCount) {
  30696. this.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode, verticesStart, verticesCount, instancesCount);
  30697. };
  30698. /**
  30699. * Draw a list of unindexed primitives
  30700. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30701. * @param verticesStart defines the index of first vertex to draw
  30702. * @param verticesCount defines the count of vertices to draw
  30703. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30704. */
  30705. Engine.prototype.drawUnIndexed = function (useTriangles, verticesStart, verticesCount, instancesCount) {
  30706. this.drawArraysType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, verticesStart, verticesCount, instancesCount);
  30707. };
  30708. /**
  30709. * Draw a list of indexed primitives
  30710. * @param fillMode defines the primitive to use
  30711. * @param indexStart defines the starting index
  30712. * @param indexCount defines the number of index to draw
  30713. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30714. */
  30715. Engine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  30716. // Apply states
  30717. this.applyStates();
  30718. this._drawCalls.addCount(1, false);
  30719. // Render
  30720. var drawMode = this._drawMode(fillMode);
  30721. var indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;
  30722. var mult = this._uintIndicesCurrentlySet ? 4 : 2;
  30723. if (instancesCount) {
  30724. this._gl.drawElementsInstanced(drawMode, indexCount, indexFormat, indexStart * mult, instancesCount);
  30725. }
  30726. else {
  30727. this._gl.drawElements(drawMode, indexCount, indexFormat, indexStart * mult);
  30728. }
  30729. };
  30730. /**
  30731. * Draw a list of unindexed primitives
  30732. * @param fillMode defines the primitive to use
  30733. * @param verticesStart defines the index of first vertex to draw
  30734. * @param verticesCount defines the count of vertices to draw
  30735. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30736. */
  30737. Engine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  30738. // Apply states
  30739. this.applyStates();
  30740. this._drawCalls.addCount(1, false);
  30741. var drawMode = this._drawMode(fillMode);
  30742. if (instancesCount) {
  30743. this._gl.drawArraysInstanced(drawMode, verticesStart, verticesCount, instancesCount);
  30744. }
  30745. else {
  30746. this._gl.drawArrays(drawMode, verticesStart, verticesCount);
  30747. }
  30748. };
  30749. Engine.prototype._drawMode = function (fillMode) {
  30750. switch (fillMode) {
  30751. // Triangle views
  30752. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode:
  30753. return this._gl.TRIANGLES;
  30754. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode:
  30755. return this._gl.POINTS;
  30756. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode:
  30757. return this._gl.LINES;
  30758. // Draw modes
  30759. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointListDrawMode:
  30760. return this._gl.POINTS;
  30761. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineListDrawMode:
  30762. return this._gl.LINES;
  30763. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineLoopDrawMode:
  30764. return this._gl.LINE_LOOP;
  30765. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineStripDrawMode:
  30766. return this._gl.LINE_STRIP;
  30767. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleStripDrawMode:
  30768. return this._gl.TRIANGLE_STRIP;
  30769. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFanDrawMode:
  30770. return this._gl.TRIANGLE_FAN;
  30771. default:
  30772. return this._gl.TRIANGLES;
  30773. }
  30774. };
  30775. // Shaders
  30776. /** @hidden */
  30777. Engine.prototype._releaseEffect = function (effect) {
  30778. if (this._compiledEffects[effect._key]) {
  30779. delete this._compiledEffects[effect._key];
  30780. this._deleteProgram(effect.getProgram());
  30781. }
  30782. };
  30783. /** @hidden */
  30784. Engine.prototype._deleteProgram = function (program) {
  30785. if (program) {
  30786. program.__SPECTOR_rebuildProgram = null;
  30787. if (program.transformFeedback) {
  30788. this.deleteTransformFeedback(program.transformFeedback);
  30789. program.transformFeedback = null;
  30790. }
  30791. this._gl.deleteProgram(program);
  30792. }
  30793. };
  30794. /**
  30795. * Create a new effect (used to store vertex/fragment shaders)
  30796. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30797. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30798. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30799. * @param samplers defines an array of string used to represent textures
  30800. * @param defines defines the string containing the defines to use to compile the shaders
  30801. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30802. * @param onCompiled defines a function to call when the effect creation is successful
  30803. * @param onError defines a function to call when the effect creation has failed
  30804. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30805. * @returns the new Effect
  30806. */
  30807. Engine.prototype.createEffect = function (baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, defines, fallbacks, onCompiled, onError, indexParameters) {
  30808. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  30809. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  30810. var name = vertex + "+" + fragment + "@" + (defines ? defines : attributesNamesOrOptions.defines);
  30811. if (this._compiledEffects[name]) {
  30812. var compiledEffect = this._compiledEffects[name];
  30813. if (onCompiled && compiledEffect.isReady()) {
  30814. onCompiled(compiledEffect);
  30815. }
  30816. return compiledEffect;
  30817. }
  30818. var effect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"](baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters);
  30819. effect._key = name;
  30820. this._compiledEffects[name] = effect;
  30821. return effect;
  30822. };
  30823. Engine.prototype._compileShader = function (source, type, defines, shaderVersion) {
  30824. return this._compileRawShader(shaderVersion + (defines ? defines + "\n" : "") + source, type);
  30825. };
  30826. Engine.prototype._compileRawShader = function (source, type) {
  30827. var gl = this._gl;
  30828. var shader = gl.createShader(type === "vertex" ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);
  30829. if (!shader) {
  30830. throw new Error("Something went wrong while compile the shader.");
  30831. }
  30832. gl.shaderSource(shader, source);
  30833. gl.compileShader(shader);
  30834. return shader;
  30835. };
  30836. /**
  30837. * Directly creates a webGL program
  30838. * @param vertexCode defines the vertex shader code to use
  30839. * @param fragmentCode defines the fragment shader code to use
  30840. * @param context defines the webGL context to use (if not set, the current one will be used)
  30841. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30842. * @returns the new webGL program
  30843. */
  30844. Engine.prototype.createRawShaderProgram = function (vertexCode, fragmentCode, context, transformFeedbackVaryings) {
  30845. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30846. context = context || this._gl;
  30847. var vertexShader = this._compileRawShader(vertexCode, "vertex");
  30848. var fragmentShader = this._compileRawShader(fragmentCode, "fragment");
  30849. return this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  30850. };
  30851. /**
  30852. * Creates a webGL program
  30853. * @param vertexCode defines the vertex shader code to use
  30854. * @param fragmentCode defines the fragment shader code to use
  30855. * @param defines defines the string containing the defines to use to compile the shaders
  30856. * @param context defines the webGL context to use (if not set, the current one will be used)
  30857. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30858. * @returns the new webGL program
  30859. */
  30860. Engine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context, transformFeedbackVaryings) {
  30861. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30862. context = context || this._gl;
  30863. this.onBeforeShaderCompilationObservable.notifyObservers(this);
  30864. var shaderVersion = (this._webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  30865. var vertexShader = this._compileShader(vertexCode, "vertex", defines, shaderVersion);
  30866. var fragmentShader = this._compileShader(fragmentCode, "fragment", defines, shaderVersion);
  30867. var program = this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  30868. this.onAfterShaderCompilationObservable.notifyObservers(this);
  30869. return program;
  30870. };
  30871. Engine.prototype._createShaderProgram = function (vertexShader, fragmentShader, context, transformFeedbackVaryings) {
  30872. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30873. var shaderProgram = context.createProgram();
  30874. if (!shaderProgram) {
  30875. throw new Error("Unable to create program");
  30876. }
  30877. if (this._caps.parallelShaderCompile) {
  30878. shaderProgram.isParallelCompiled = true;
  30879. }
  30880. context.attachShader(shaderProgram, vertexShader);
  30881. context.attachShader(shaderProgram, fragmentShader);
  30882. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  30883. var transformFeedback = this.createTransformFeedback();
  30884. this.bindTransformFeedback(transformFeedback);
  30885. this.setTranformFeedbackVaryings(shaderProgram, transformFeedbackVaryings);
  30886. shaderProgram.transformFeedback = transformFeedback;
  30887. }
  30888. context.linkProgram(shaderProgram);
  30889. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  30890. this.bindTransformFeedback(null);
  30891. }
  30892. shaderProgram.context = context;
  30893. shaderProgram.vertexShader = vertexShader;
  30894. shaderProgram.fragmentShader = fragmentShader;
  30895. if (!shaderProgram.isParallelCompiled) {
  30896. this._finalizeProgram(shaderProgram);
  30897. }
  30898. return shaderProgram;
  30899. };
  30900. Engine.prototype._finalizeProgram = function (shaderProgram) {
  30901. var context = shaderProgram.context;
  30902. var vertexShader = shaderProgram.vertexShader;
  30903. var fragmentShader = shaderProgram.fragmentShader;
  30904. var linked = context.getProgramParameter(shaderProgram, context.LINK_STATUS);
  30905. if (!linked) { // Get more info
  30906. // Vertex
  30907. if (!this._gl.getShaderParameter(vertexShader, this._gl.COMPILE_STATUS)) {
  30908. var log = this._gl.getShaderInfoLog(vertexShader);
  30909. if (log) {
  30910. throw new Error(log);
  30911. }
  30912. }
  30913. // Fragment
  30914. if (!this._gl.getShaderParameter(fragmentShader, this._gl.COMPILE_STATUS)) {
  30915. var log = this._gl.getShaderInfoLog(fragmentShader);
  30916. if (log) {
  30917. throw new Error(log);
  30918. }
  30919. }
  30920. var error = context.getProgramInfoLog(shaderProgram);
  30921. if (error) {
  30922. throw new Error(error);
  30923. }
  30924. }
  30925. if (this.validateShaderPrograms) {
  30926. context.validateProgram(shaderProgram);
  30927. var validated = context.getProgramParameter(shaderProgram, context.VALIDATE_STATUS);
  30928. if (!validated) {
  30929. var error = context.getProgramInfoLog(shaderProgram);
  30930. if (error) {
  30931. throw new Error(error);
  30932. }
  30933. }
  30934. }
  30935. context.deleteShader(vertexShader);
  30936. context.deleteShader(fragmentShader);
  30937. shaderProgram.context = undefined;
  30938. shaderProgram.vertexShader = undefined;
  30939. shaderProgram.fragmentShader = undefined;
  30940. if (shaderProgram.onCompiled) {
  30941. shaderProgram.onCompiled();
  30942. shaderProgram.onCompiled = undefined;
  30943. }
  30944. };
  30945. /** @hidden */
  30946. Engine.prototype._isProgramCompiled = function (shaderProgram) {
  30947. if (!shaderProgram.isParallelCompiled) {
  30948. return true;
  30949. }
  30950. if (this._gl.getProgramParameter(shaderProgram, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)) {
  30951. this._finalizeProgram(shaderProgram);
  30952. return true;
  30953. }
  30954. return false;
  30955. };
  30956. /** @hidden */
  30957. Engine.prototype._executeWhenProgramIsCompiled = function (shaderProgram, action) {
  30958. if (!shaderProgram.isParallelCompiled) {
  30959. action();
  30960. return;
  30961. }
  30962. shaderProgram.onCompiled = action;
  30963. };
  30964. /**
  30965. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30966. * @param shaderProgram defines the webGL program to use
  30967. * @param uniformsNames defines the list of uniform names
  30968. * @returns an array of webGL uniform locations
  30969. */
  30970. Engine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  30971. var results = new Array();
  30972. for (var index = 0; index < uniformsNames.length; index++) {
  30973. results.push(this._gl.getUniformLocation(shaderProgram, uniformsNames[index]));
  30974. }
  30975. return results;
  30976. };
  30977. /**
  30978. * Gets the lsit of active attributes for a given webGL program
  30979. * @param shaderProgram defines the webGL program to use
  30980. * @param attributesNames defines the list of attribute names to get
  30981. * @returns an array of indices indicating the offset of each attribute
  30982. */
  30983. Engine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  30984. var results = [];
  30985. for (var index = 0; index < attributesNames.length; index++) {
  30986. try {
  30987. results.push(this._gl.getAttribLocation(shaderProgram, attributesNames[index]));
  30988. }
  30989. catch (e) {
  30990. results.push(-1);
  30991. }
  30992. }
  30993. return results;
  30994. };
  30995. /**
  30996. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30997. * @param effect defines the effect to activate
  30998. */
  30999. Engine.prototype.enableEffect = function (effect) {
  31000. if (!effect || effect === this._currentEffect) {
  31001. return;
  31002. }
  31003. // Use program
  31004. this.bindSamplers(effect);
  31005. this._currentEffect = effect;
  31006. if (effect.onBind) {
  31007. effect.onBind(effect);
  31008. }
  31009. if (effect._onBindObservable) {
  31010. effect._onBindObservable.notifyObservers(effect);
  31011. }
  31012. };
  31013. /**
  31014. * Set the value of an uniform to an array of int32
  31015. * @param uniform defines the webGL uniform location where to store the value
  31016. * @param array defines the array of int32 to store
  31017. */
  31018. Engine.prototype.setIntArray = function (uniform, array) {
  31019. if (!uniform) {
  31020. return;
  31021. }
  31022. this._gl.uniform1iv(uniform, array);
  31023. };
  31024. /**
  31025. * Set the value of an uniform to an array of int32 (stored as vec2)
  31026. * @param uniform defines the webGL uniform location where to store the value
  31027. * @param array defines the array of int32 to store
  31028. */
  31029. Engine.prototype.setIntArray2 = function (uniform, array) {
  31030. if (!uniform || array.length % 2 !== 0) {
  31031. return;
  31032. }
  31033. this._gl.uniform2iv(uniform, array);
  31034. };
  31035. /**
  31036. * Set the value of an uniform to an array of int32 (stored as vec3)
  31037. * @param uniform defines the webGL uniform location where to store the value
  31038. * @param array defines the array of int32 to store
  31039. */
  31040. Engine.prototype.setIntArray3 = function (uniform, array) {
  31041. if (!uniform || array.length % 3 !== 0) {
  31042. return;
  31043. }
  31044. this._gl.uniform3iv(uniform, array);
  31045. };
  31046. /**
  31047. * Set the value of an uniform to an array of int32 (stored as vec4)
  31048. * @param uniform defines the webGL uniform location where to store the value
  31049. * @param array defines the array of int32 to store
  31050. */
  31051. Engine.prototype.setIntArray4 = function (uniform, array) {
  31052. if (!uniform || array.length % 4 !== 0) {
  31053. return;
  31054. }
  31055. this._gl.uniform4iv(uniform, array);
  31056. };
  31057. /**
  31058. * Set the value of an uniform to an array of float32
  31059. * @param uniform defines the webGL uniform location where to store the value
  31060. * @param array defines the array of float32 to store
  31061. */
  31062. Engine.prototype.setFloatArray = function (uniform, array) {
  31063. if (!uniform) {
  31064. return;
  31065. }
  31066. this._gl.uniform1fv(uniform, array);
  31067. };
  31068. /**
  31069. * Set the value of an uniform to an array of float32 (stored as vec2)
  31070. * @param uniform defines the webGL uniform location where to store the value
  31071. * @param array defines the array of float32 to store
  31072. */
  31073. Engine.prototype.setFloatArray2 = function (uniform, array) {
  31074. if (!uniform || array.length % 2 !== 0) {
  31075. return;
  31076. }
  31077. this._gl.uniform2fv(uniform, array);
  31078. };
  31079. /**
  31080. * Set the value of an uniform to an array of float32 (stored as vec3)
  31081. * @param uniform defines the webGL uniform location where to store the value
  31082. * @param array defines the array of float32 to store
  31083. */
  31084. Engine.prototype.setFloatArray3 = function (uniform, array) {
  31085. if (!uniform || array.length % 3 !== 0) {
  31086. return;
  31087. }
  31088. this._gl.uniform3fv(uniform, array);
  31089. };
  31090. /**
  31091. * Set the value of an uniform to an array of float32 (stored as vec4)
  31092. * @param uniform defines the webGL uniform location where to store the value
  31093. * @param array defines the array of float32 to store
  31094. */
  31095. Engine.prototype.setFloatArray4 = function (uniform, array) {
  31096. if (!uniform || array.length % 4 !== 0) {
  31097. return;
  31098. }
  31099. this._gl.uniform4fv(uniform, array);
  31100. };
  31101. /**
  31102. * Set the value of an uniform to an array of number
  31103. * @param uniform defines the webGL uniform location where to store the value
  31104. * @param array defines the array of number to store
  31105. */
  31106. Engine.prototype.setArray = function (uniform, array) {
  31107. if (!uniform) {
  31108. return;
  31109. }
  31110. this._gl.uniform1fv(uniform, array);
  31111. };
  31112. /**
  31113. * Set the value of an uniform to an array of number (stored as vec2)
  31114. * @param uniform defines the webGL uniform location where to store the value
  31115. * @param array defines the array of number to store
  31116. */
  31117. Engine.prototype.setArray2 = function (uniform, array) {
  31118. if (!uniform || array.length % 2 !== 0) {
  31119. return;
  31120. }
  31121. this._gl.uniform2fv(uniform, array);
  31122. };
  31123. /**
  31124. * Set the value of an uniform to an array of number (stored as vec3)
  31125. * @param uniform defines the webGL uniform location where to store the value
  31126. * @param array defines the array of number to store
  31127. */
  31128. Engine.prototype.setArray3 = function (uniform, array) {
  31129. if (!uniform || array.length % 3 !== 0) {
  31130. return;
  31131. }
  31132. this._gl.uniform3fv(uniform, array);
  31133. };
  31134. /**
  31135. * Set the value of an uniform to an array of number (stored as vec4)
  31136. * @param uniform defines the webGL uniform location where to store the value
  31137. * @param array defines the array of number to store
  31138. */
  31139. Engine.prototype.setArray4 = function (uniform, array) {
  31140. if (!uniform || array.length % 4 !== 0) {
  31141. return;
  31142. }
  31143. this._gl.uniform4fv(uniform, array);
  31144. };
  31145. /**
  31146. * Set the value of an uniform to an array of float32 (stored as matrices)
  31147. * @param uniform defines the webGL uniform location where to store the value
  31148. * @param matrices defines the array of float32 to store
  31149. */
  31150. Engine.prototype.setMatrices = function (uniform, matrices) {
  31151. if (!uniform) {
  31152. return;
  31153. }
  31154. this._gl.uniformMatrix4fv(uniform, false, matrices);
  31155. };
  31156. /**
  31157. * Set the value of an uniform to a matrix
  31158. * @param uniform defines the webGL uniform location where to store the value
  31159. * @param matrix defines the matrix to store
  31160. */
  31161. Engine.prototype.setMatrix = function (uniform, matrix) {
  31162. if (!uniform) {
  31163. return;
  31164. }
  31165. this._gl.uniformMatrix4fv(uniform, false, matrix.toArray());
  31166. };
  31167. /**
  31168. * Set the value of an uniform to a matrix (3x3)
  31169. * @param uniform defines the webGL uniform location where to store the value
  31170. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31171. */
  31172. Engine.prototype.setMatrix3x3 = function (uniform, matrix) {
  31173. if (!uniform) {
  31174. return;
  31175. }
  31176. this._gl.uniformMatrix3fv(uniform, false, matrix);
  31177. };
  31178. /**
  31179. * Set the value of an uniform to a matrix (2x2)
  31180. * @param uniform defines the webGL uniform location where to store the value
  31181. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31182. */
  31183. Engine.prototype.setMatrix2x2 = function (uniform, matrix) {
  31184. if (!uniform) {
  31185. return;
  31186. }
  31187. this._gl.uniformMatrix2fv(uniform, false, matrix);
  31188. };
  31189. /**
  31190. * Set the value of an uniform to a number (int)
  31191. * @param uniform defines the webGL uniform location where to store the value
  31192. * @param value defines the int number to store
  31193. */
  31194. Engine.prototype.setInt = function (uniform, value) {
  31195. if (!uniform) {
  31196. return;
  31197. }
  31198. this._gl.uniform1i(uniform, value);
  31199. };
  31200. /**
  31201. * Set the value of an uniform to a number (float)
  31202. * @param uniform defines the webGL uniform location where to store the value
  31203. * @param value defines the float number to store
  31204. */
  31205. Engine.prototype.setFloat = function (uniform, value) {
  31206. if (!uniform) {
  31207. return;
  31208. }
  31209. this._gl.uniform1f(uniform, value);
  31210. };
  31211. /**
  31212. * Set the value of an uniform to a vec2
  31213. * @param uniform defines the webGL uniform location where to store the value
  31214. * @param x defines the 1st component of the value
  31215. * @param y defines the 2nd component of the value
  31216. */
  31217. Engine.prototype.setFloat2 = function (uniform, x, y) {
  31218. if (!uniform) {
  31219. return;
  31220. }
  31221. this._gl.uniform2f(uniform, x, y);
  31222. };
  31223. /**
  31224. * Set the value of an uniform to a vec3
  31225. * @param uniform defines the webGL uniform location where to store the value
  31226. * @param x defines the 1st component of the value
  31227. * @param y defines the 2nd component of the value
  31228. * @param z defines the 3rd component of the value
  31229. */
  31230. Engine.prototype.setFloat3 = function (uniform, x, y, z) {
  31231. if (!uniform) {
  31232. return;
  31233. }
  31234. this._gl.uniform3f(uniform, x, y, z);
  31235. };
  31236. /**
  31237. * Set the value of an uniform to a boolean
  31238. * @param uniform defines the webGL uniform location where to store the value
  31239. * @param bool defines the boolean to store
  31240. */
  31241. Engine.prototype.setBool = function (uniform, bool) {
  31242. if (!uniform) {
  31243. return;
  31244. }
  31245. this._gl.uniform1i(uniform, bool);
  31246. };
  31247. /**
  31248. * Set the value of an uniform to a vec4
  31249. * @param uniform defines the webGL uniform location where to store the value
  31250. * @param x defines the 1st component of the value
  31251. * @param y defines the 2nd component of the value
  31252. * @param z defines the 3rd component of the value
  31253. * @param w defines the 4th component of the value
  31254. */
  31255. Engine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  31256. if (!uniform) {
  31257. return;
  31258. }
  31259. this._gl.uniform4f(uniform, x, y, z, w);
  31260. };
  31261. /**
  31262. * Set the value of an uniform to a Color3
  31263. * @param uniform defines the webGL uniform location where to store the value
  31264. * @param color3 defines the color to store
  31265. */
  31266. Engine.prototype.setColor3 = function (uniform, color3) {
  31267. if (!uniform) {
  31268. return;
  31269. }
  31270. this._gl.uniform3f(uniform, color3.r, color3.g, color3.b);
  31271. };
  31272. /**
  31273. * Set the value of an uniform to a Color3 and an alpha value
  31274. * @param uniform defines the webGL uniform location where to store the value
  31275. * @param color3 defines the color to store
  31276. * @param alpha defines the alpha component to store
  31277. */
  31278. Engine.prototype.setColor4 = function (uniform, color3, alpha) {
  31279. if (!uniform) {
  31280. return;
  31281. }
  31282. this._gl.uniform4f(uniform, color3.r, color3.g, color3.b, alpha);
  31283. };
  31284. /**
  31285. * Sets a Color4 on a uniform variable
  31286. * @param uniform defines the uniform location
  31287. * @param color4 defines the value to be set
  31288. */
  31289. Engine.prototype.setDirectColor4 = function (uniform, color4) {
  31290. if (!uniform) {
  31291. return;
  31292. }
  31293. this._gl.uniform4f(uniform, color4.r, color4.g, color4.b, color4.a);
  31294. };
  31295. // States
  31296. /**
  31297. * Set various states to the webGL context
  31298. * @param culling defines backface culling state
  31299. * @param zOffset defines the value to apply to zOffset (0 by default)
  31300. * @param force defines if states must be applied even if cache is up to date
  31301. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31302. */
  31303. Engine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  31304. if (zOffset === void 0) { zOffset = 0; }
  31305. if (reverseSide === void 0) { reverseSide = false; }
  31306. // Culling
  31307. if (this._depthCullingState.cull !== culling || force) {
  31308. this._depthCullingState.cull = culling;
  31309. }
  31310. // Cull face
  31311. var cullFace = this.cullBackFaces ? this._gl.BACK : this._gl.FRONT;
  31312. if (this._depthCullingState.cullFace !== cullFace || force) {
  31313. this._depthCullingState.cullFace = cullFace;
  31314. }
  31315. // Z offset
  31316. this.setZOffset(zOffset);
  31317. // Front face
  31318. var frontFace = reverseSide ? this._gl.CW : this._gl.CCW;
  31319. if (this._depthCullingState.frontFace !== frontFace || force) {
  31320. this._depthCullingState.frontFace = frontFace;
  31321. }
  31322. };
  31323. /**
  31324. * Set the z offset to apply to current rendering
  31325. * @param value defines the offset to apply
  31326. */
  31327. Engine.prototype.setZOffset = function (value) {
  31328. this._depthCullingState.zOffset = value;
  31329. };
  31330. /**
  31331. * Gets the current value of the zOffset
  31332. * @returns the current zOffset state
  31333. */
  31334. Engine.prototype.getZOffset = function () {
  31335. return this._depthCullingState.zOffset;
  31336. };
  31337. /**
  31338. * Enable or disable depth buffering
  31339. * @param enable defines the state to set
  31340. */
  31341. Engine.prototype.setDepthBuffer = function (enable) {
  31342. this._depthCullingState.depthTest = enable;
  31343. };
  31344. /**
  31345. * Gets a boolean indicating if depth writing is enabled
  31346. * @returns the current depth writing state
  31347. */
  31348. Engine.prototype.getDepthWrite = function () {
  31349. return this._depthCullingState.depthMask;
  31350. };
  31351. /**
  31352. * Enable or disable depth writing
  31353. * @param enable defines the state to set
  31354. */
  31355. Engine.prototype.setDepthWrite = function (enable) {
  31356. this._depthCullingState.depthMask = enable;
  31357. };
  31358. /**
  31359. * Enable or disable color writing
  31360. * @param enable defines the state to set
  31361. */
  31362. Engine.prototype.setColorWrite = function (enable) {
  31363. this._gl.colorMask(enable, enable, enable, enable);
  31364. this._colorWrite = enable;
  31365. };
  31366. /**
  31367. * Gets a boolean indicating if color writing is enabled
  31368. * @returns the current color writing state
  31369. */
  31370. Engine.prototype.getColorWrite = function () {
  31371. return this._colorWrite;
  31372. };
  31373. /**
  31374. * Sets alpha constants used by some alpha blending modes
  31375. * @param r defines the red component
  31376. * @param g defines the green component
  31377. * @param b defines the blue component
  31378. * @param a defines the alpha component
  31379. */
  31380. Engine.prototype.setAlphaConstants = function (r, g, b, a) {
  31381. this._alphaState.setAlphaBlendConstants(r, g, b, a);
  31382. };
  31383. /**
  31384. * Sets the current alpha mode
  31385. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31386. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31387. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31388. */
  31389. Engine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  31390. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  31391. if (this._alphaMode === mode) {
  31392. return;
  31393. }
  31394. switch (mode) {
  31395. case Engine.ALPHA_DISABLE:
  31396. this._alphaState.alphaBlend = false;
  31397. break;
  31398. case Engine.ALPHA_PREMULTIPLIED:
  31399. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  31400. this._alphaState.alphaBlend = true;
  31401. break;
  31402. case Engine.ALPHA_PREMULTIPLIED_PORTERDUFF:
  31403. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  31404. this._alphaState.alphaBlend = true;
  31405. break;
  31406. case Engine.ALPHA_COMBINE:
  31407. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  31408. this._alphaState.alphaBlend = true;
  31409. break;
  31410. case Engine.ALPHA_ONEONE:
  31411. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  31412. this._alphaState.alphaBlend = true;
  31413. break;
  31414. case Engine.ALPHA_ADD:
  31415. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  31416. this._alphaState.alphaBlend = true;
  31417. break;
  31418. case Engine.ALPHA_SUBTRACT:
  31419. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  31420. this._alphaState.alphaBlend = true;
  31421. break;
  31422. case Engine.ALPHA_MULTIPLY:
  31423. this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE);
  31424. this._alphaState.alphaBlend = true;
  31425. break;
  31426. case Engine.ALPHA_MAXIMIZED:
  31427. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  31428. this._alphaState.alphaBlend = true;
  31429. break;
  31430. case Engine.ALPHA_INTERPOLATE:
  31431. this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR, this._gl.ONE_MINUS_CONSTANT_COLOR, this._gl.CONSTANT_ALPHA, this._gl.ONE_MINUS_CONSTANT_ALPHA);
  31432. this._alphaState.alphaBlend = true;
  31433. break;
  31434. case Engine.ALPHA_SCREENMODE:
  31435. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  31436. this._alphaState.alphaBlend = true;
  31437. break;
  31438. }
  31439. if (!noDepthWriteChange) {
  31440. this.setDepthWrite(mode === Engine.ALPHA_DISABLE);
  31441. }
  31442. this._alphaMode = mode;
  31443. };
  31444. /**
  31445. * Gets the current alpha mode
  31446. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31447. * @returns the current alpha mode
  31448. */
  31449. Engine.prototype.getAlphaMode = function () {
  31450. return this._alphaMode;
  31451. };
  31452. // Textures
  31453. /**
  31454. * Clears the list of texture accessible through engine.
  31455. * This can help preventing texture load conflict due to name collision.
  31456. */
  31457. Engine.prototype.clearInternalTexturesCache = function () {
  31458. this._internalTexturesCache = [];
  31459. };
  31460. /**
  31461. * Force the entire cache to be cleared
  31462. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31463. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31464. */
  31465. Engine.prototype.wipeCaches = function (bruteForce) {
  31466. if (this.preventCacheWipeBetweenFrames && !bruteForce) {
  31467. return;
  31468. }
  31469. this._currentEffect = null;
  31470. this._viewportCached.x = 0;
  31471. this._viewportCached.y = 0;
  31472. this._viewportCached.z = 0;
  31473. this._viewportCached.w = 0;
  31474. if (bruteForce) {
  31475. this.resetTextureCache();
  31476. this._currentProgram = null;
  31477. this._stencilState.reset();
  31478. this._depthCullingState.reset();
  31479. this.setDepthFunctionToLessOrEqual();
  31480. this._alphaState.reset();
  31481. this._unpackFlipYCached = null;
  31482. }
  31483. this._resetVertexBufferBinding();
  31484. this._cachedIndexBuffer = null;
  31485. this._cachedEffectForVertexBuffers = null;
  31486. this._unbindVertexArrayObject();
  31487. this.bindIndexBuffer(null);
  31488. };
  31489. /**
  31490. * Set the compressed texture format to use, based on the formats you have, and the formats
  31491. * supported by the hardware / browser.
  31492. *
  31493. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31494. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31495. * to API arguments needed to compressed textures. This puts the burden on the container
  31496. * generator to house the arcane code for determining these for current & future formats.
  31497. *
  31498. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31499. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31500. *
  31501. * Note: The result of this call is not taken into account when a texture is base64.
  31502. *
  31503. * @param formatsAvailable defines the list of those format families you have created
  31504. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31505. *
  31506. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31507. * @returns The extension selected.
  31508. */
  31509. Engine.prototype.setTextureFormatToUse = function (formatsAvailable) {
  31510. for (var i = 0, len1 = this.texturesSupported.length; i < len1; i++) {
  31511. for (var j = 0, len2 = formatsAvailable.length; j < len2; j++) {
  31512. if (this._texturesSupported[i] === formatsAvailable[j].toLowerCase()) {
  31513. return this._textureFormatInUse = this._texturesSupported[i];
  31514. }
  31515. }
  31516. }
  31517. // actively set format to nothing, to allow this to be called more than once
  31518. // and possibly fail the 2nd time
  31519. this._textureFormatInUse = null;
  31520. return null;
  31521. };
  31522. Engine.prototype._getSamplingParameters = function (samplingMode, generateMipMaps) {
  31523. var gl = this._gl;
  31524. var magFilter = gl.NEAREST;
  31525. var minFilter = gl.NEAREST;
  31526. switch (samplingMode) {
  31527. case Engine.TEXTURE_BILINEAR_SAMPLINGMODE:
  31528. magFilter = gl.LINEAR;
  31529. if (generateMipMaps) {
  31530. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  31531. }
  31532. else {
  31533. minFilter = gl.LINEAR;
  31534. }
  31535. break;
  31536. case Engine.TEXTURE_TRILINEAR_SAMPLINGMODE:
  31537. magFilter = gl.LINEAR;
  31538. if (generateMipMaps) {
  31539. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  31540. }
  31541. else {
  31542. minFilter = gl.LINEAR;
  31543. }
  31544. break;
  31545. case Engine.TEXTURE_NEAREST_SAMPLINGMODE:
  31546. magFilter = gl.NEAREST;
  31547. if (generateMipMaps) {
  31548. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  31549. }
  31550. else {
  31551. minFilter = gl.NEAREST;
  31552. }
  31553. break;
  31554. case Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
  31555. magFilter = gl.NEAREST;
  31556. if (generateMipMaps) {
  31557. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  31558. }
  31559. else {
  31560. minFilter = gl.NEAREST;
  31561. }
  31562. break;
  31563. case Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
  31564. magFilter = gl.NEAREST;
  31565. if (generateMipMaps) {
  31566. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  31567. }
  31568. else {
  31569. minFilter = gl.LINEAR;
  31570. }
  31571. break;
  31572. case Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
  31573. magFilter = gl.NEAREST;
  31574. if (generateMipMaps) {
  31575. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  31576. }
  31577. else {
  31578. minFilter = gl.LINEAR;
  31579. }
  31580. break;
  31581. case Engine.TEXTURE_NEAREST_LINEAR:
  31582. magFilter = gl.NEAREST;
  31583. minFilter = gl.LINEAR;
  31584. break;
  31585. case Engine.TEXTURE_NEAREST_NEAREST:
  31586. magFilter = gl.NEAREST;
  31587. minFilter = gl.NEAREST;
  31588. break;
  31589. case Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
  31590. magFilter = gl.LINEAR;
  31591. if (generateMipMaps) {
  31592. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  31593. }
  31594. else {
  31595. minFilter = gl.NEAREST;
  31596. }
  31597. break;
  31598. case Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
  31599. magFilter = gl.LINEAR;
  31600. if (generateMipMaps) {
  31601. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  31602. }
  31603. else {
  31604. minFilter = gl.NEAREST;
  31605. }
  31606. break;
  31607. case Engine.TEXTURE_LINEAR_LINEAR:
  31608. magFilter = gl.LINEAR;
  31609. minFilter = gl.LINEAR;
  31610. break;
  31611. case Engine.TEXTURE_LINEAR_NEAREST:
  31612. magFilter = gl.LINEAR;
  31613. minFilter = gl.NEAREST;
  31614. break;
  31615. }
  31616. return {
  31617. min: minFilter,
  31618. mag: magFilter
  31619. };
  31620. };
  31621. Engine.prototype._partialLoadImg = function (url, index, loadedImages, scene, onfinish, onErrorCallBack) {
  31622. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  31623. var img;
  31624. var onload = function () {
  31625. loadedImages[index] = img;
  31626. loadedImages._internalCount++;
  31627. if (scene) {
  31628. scene._removePendingData(img);
  31629. }
  31630. if (loadedImages._internalCount === 6) {
  31631. onfinish(loadedImages);
  31632. }
  31633. };
  31634. var onerror = function (message, exception) {
  31635. if (scene) {
  31636. scene._removePendingData(img);
  31637. }
  31638. if (onErrorCallBack) {
  31639. onErrorCallBack(message, exception);
  31640. }
  31641. };
  31642. img = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onerror, scene ? scene.offlineProvider : null);
  31643. if (scene) {
  31644. scene._addPendingData(img);
  31645. }
  31646. };
  31647. Engine.prototype._cascadeLoadImgs = function (scene, onfinish, files, onError) {
  31648. if (onError === void 0) { onError = null; }
  31649. var loadedImages = [];
  31650. loadedImages._internalCount = 0;
  31651. for (var index = 0; index < 6; index++) {
  31652. this._partialLoadImg(files[index], index, loadedImages, scene, onfinish, onError);
  31653. }
  31654. };
  31655. /** @hidden */
  31656. Engine.prototype._createTexture = function () {
  31657. var texture = this._gl.createTexture();
  31658. if (!texture) {
  31659. throw new Error("Unable to create texture");
  31660. }
  31661. return texture;
  31662. };
  31663. /**
  31664. * Usually called from Texture.ts.
  31665. * Passed information to create a WebGLTexture
  31666. * @param urlArg defines a value which contains one of the following:
  31667. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31668. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31669. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31670. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31671. * @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)
  31672. * @param scene needed for loading to the correct scene
  31673. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31674. * @param onLoad optional callback to be called upon successful completion
  31675. * @param onError optional callback to be called upon failure
  31676. * @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
  31677. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31678. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31679. * @param forcedExtension defines the extension to use to pick the right loader
  31680. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31681. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31682. */
  31683. Engine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallback, format, forcedExtension, excludeLoaders) {
  31684. var _this = this;
  31685. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  31686. if (onLoad === void 0) { onLoad = null; }
  31687. if (onError === void 0) { onError = null; }
  31688. if (buffer === void 0) { buffer = null; }
  31689. if (fallback === void 0) { fallback = null; }
  31690. if (format === void 0) { format = null; }
  31691. if (forcedExtension === void 0) { forcedExtension = null; }
  31692. if (excludeLoaders === void 0) { excludeLoaders = []; }
  31693. var url = String(urlArg); // assign a new string, so that the original is still available in case of fallback
  31694. var fromData = url.substr(0, 5) === "data:";
  31695. var fromBlob = url.substr(0, 5) === "blob:";
  31696. var isBase64 = fromData && url.indexOf(";base64,") !== -1;
  31697. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_URL);
  31698. // establish the file extension, if possible
  31699. var lastDot = url.lastIndexOf('.');
  31700. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? url.substring(lastDot).toLowerCase() : "");
  31701. var loader = null;
  31702. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  31703. var availableLoader = _a[_i];
  31704. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, isBase64, buffer ? true : false)) {
  31705. loader = availableLoader;
  31706. break;
  31707. }
  31708. }
  31709. if (loader) {
  31710. url = loader.transformUrl(url, this._textureFormatInUse);
  31711. }
  31712. if (scene) {
  31713. scene._addPendingData(texture);
  31714. }
  31715. texture.url = url;
  31716. texture.generateMipMaps = !noMipmap;
  31717. texture.samplingMode = samplingMode;
  31718. texture.invertY = invertY;
  31719. if (!this._doNotHandleContextLost) {
  31720. // Keep a link to the buffer only if we plan to handle context lost
  31721. texture._buffer = buffer;
  31722. }
  31723. var onLoadObserver = null;
  31724. if (onLoad && !fallback) {
  31725. onLoadObserver = texture.onLoadedObservable.add(onLoad);
  31726. }
  31727. if (!fallback) {
  31728. this._internalTexturesCache.push(texture);
  31729. }
  31730. var onInternalError = function (message, exception) {
  31731. if (scene) {
  31732. scene._removePendingData(texture);
  31733. }
  31734. var customFallback = false;
  31735. if (loader) {
  31736. var fallbackUrl = loader.getFallbackTextureUrl(url, _this._textureFormatInUse);
  31737. if (fallbackUrl) {
  31738. // Add Back
  31739. customFallback = true;
  31740. excludeLoaders.push(loader);
  31741. _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");
  31742. _this.createTexture(urlArg, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture, undefined, undefined, excludeLoaders);
  31743. }
  31744. }
  31745. if (!customFallback) {
  31746. if (onLoadObserver) {
  31747. texture.onLoadedObservable.remove(onLoadObserver);
  31748. }
  31749. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].UseFallbackTexture) {
  31750. _this.createTexture(_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].fallbackTexture, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture);
  31751. }
  31752. }
  31753. if (onError) {
  31754. onError(message || "Unknown error", exception);
  31755. }
  31756. };
  31757. // processing for non-image formats
  31758. if (loader) {
  31759. var callback = function (data) {
  31760. loader.loadData(data, texture, function (width, height, loadMipmap, isCompressed, done, loadFailed) {
  31761. if (loadFailed) {
  31762. onInternalError("TextureLoader failed to load data");
  31763. }
  31764. else {
  31765. _this._prepareWebGLTexture(texture, scene, width, height, texture.invertY, !loadMipmap, isCompressed, function () {
  31766. done();
  31767. return false;
  31768. }, samplingMode);
  31769. }
  31770. });
  31771. };
  31772. if (!buffer) {
  31773. this._loadFile(url, callback, undefined, scene ? scene.offlineProvider : undefined, true, function (request, exception) {
  31774. onInternalError("Unable to load " + (request ? request.responseURL : url, exception));
  31775. });
  31776. }
  31777. else {
  31778. callback(buffer);
  31779. }
  31780. }
  31781. else {
  31782. var onload = function (img) {
  31783. if (fromBlob && !_this._doNotHandleContextLost) {
  31784. // We need to store the image if we need to rebuild the texture
  31785. // in case of a webgl context lost
  31786. texture._buffer = img;
  31787. }
  31788. _this._prepareWebGLTexture(texture, scene, img.width, img.height, texture.invertY, noMipmap, false, function (potWidth, potHeight, continuationCallback) {
  31789. var gl = _this._gl;
  31790. var isPot = (img.width === potWidth && img.height === potHeight);
  31791. var internalFormat = format ? _this._getInternalFormat(format) : ((extension === ".jpg") ? gl.RGB : gl.RGBA);
  31792. if (isPot) {
  31793. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  31794. return false;
  31795. }
  31796. var maxTextureSize = _this._caps.maxTextureSize;
  31797. if (img.width > maxTextureSize || img.height > maxTextureSize || Engine._RescalePostProcessFactory === null) {
  31798. _this._prepareWorkingCanvas();
  31799. if (!_this._workingCanvas || !_this._workingContext) {
  31800. return false;
  31801. }
  31802. _this._workingCanvas.width = potWidth;
  31803. _this._workingCanvas.height = potHeight;
  31804. _this._workingContext.drawImage(img, 0, 0, img.width, img.height, 0, 0, potWidth, potHeight);
  31805. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  31806. texture.width = potWidth;
  31807. texture.height = potHeight;
  31808. return false;
  31809. }
  31810. else {
  31811. // Using shaders when possible to rescale because canvas.drawImage is lossy
  31812. var source_1 = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_TEMP);
  31813. _this._bindTextureDirectly(gl.TEXTURE_2D, source_1, true);
  31814. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  31815. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  31816. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  31817. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31818. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31819. _this._rescaleTexture(source_1, texture, scene, internalFormat, function () {
  31820. _this._releaseTexture(source_1);
  31821. _this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  31822. continuationCallback();
  31823. });
  31824. }
  31825. return true;
  31826. }, samplingMode);
  31827. };
  31828. if (!fromData || isBase64) {
  31829. if (buffer instanceof HTMLImageElement) {
  31830. onload(buffer);
  31831. }
  31832. else {
  31833. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onInternalError, scene ? scene.offlineProvider : null);
  31834. }
  31835. }
  31836. else if (typeof buffer === "string" || buffer instanceof ArrayBuffer || buffer instanceof Blob) {
  31837. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(buffer, onload, onInternalError, scene ? scene.offlineProvider : null);
  31838. }
  31839. else {
  31840. onload(buffer);
  31841. }
  31842. }
  31843. return texture;
  31844. };
  31845. Engine.prototype._rescaleTexture = function (source, destination, scene, internalFormat, onComplete) {
  31846. var _this = this;
  31847. var rtt = this.createRenderTargetTexture({
  31848. width: destination.width,
  31849. height: destination.height,
  31850. }, {
  31851. generateMipMaps: false,
  31852. type: Engine.TEXTURETYPE_UNSIGNED_INT,
  31853. samplingMode: Engine.TEXTURE_BILINEAR_SAMPLINGMODE,
  31854. generateDepthBuffer: false,
  31855. generateStencilBuffer: false
  31856. });
  31857. if (!this._rescalePostProcess && Engine._RescalePostProcessFactory) {
  31858. this._rescalePostProcess = Engine._RescalePostProcessFactory(this);
  31859. }
  31860. this._rescalePostProcess.getEffect().executeWhenCompiled(function () {
  31861. _this._rescalePostProcess.onApply = function (effect) {
  31862. effect._bindTexture("textureSampler", source);
  31863. };
  31864. var hostingScene = scene;
  31865. if (!hostingScene) {
  31866. hostingScene = _this.scenes[_this.scenes.length - 1];
  31867. }
  31868. hostingScene.postProcessManager.directRender([_this._rescalePostProcess], rtt, true);
  31869. _this._bindTextureDirectly(_this._gl.TEXTURE_2D, destination, true);
  31870. _this._gl.copyTexImage2D(_this._gl.TEXTURE_2D, 0, internalFormat, 0, 0, destination.width, destination.height, 0);
  31871. _this.unBindFramebuffer(rtt);
  31872. _this._releaseTexture(rtt);
  31873. if (onComplete) {
  31874. onComplete();
  31875. }
  31876. });
  31877. };
  31878. /**
  31879. * Update a raw texture
  31880. * @param texture defines the texture to update
  31881. * @param data defines the data to store in the texture
  31882. * @param format defines the format of the data
  31883. * @param invertY defines if data must be stored with Y axis inverted
  31884. * @param compression defines the compression used (null by default)
  31885. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31886. */
  31887. Engine.prototype.updateRawTexture = function (texture, data, format, invertY, compression, type) {
  31888. if (compression === void 0) { compression = null; }
  31889. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31890. if (!texture) {
  31891. return;
  31892. }
  31893. // babylon's internalSizedFomat but gl's texImage2D internalFormat
  31894. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type, format);
  31895. // babylon's internalFormat but gl's texImage2D format
  31896. var internalFormat = this._getInternalFormat(format);
  31897. var textureType = this._getWebGLTextureType(type);
  31898. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31899. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  31900. if (!this._doNotHandleContextLost) {
  31901. texture._bufferView = data;
  31902. texture.format = format;
  31903. texture.type = type;
  31904. texture.invertY = invertY;
  31905. texture._compression = compression;
  31906. }
  31907. if (texture.width % 4 !== 0) {
  31908. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  31909. }
  31910. if (compression && data) {
  31911. this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, 0, data);
  31912. }
  31913. else {
  31914. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, data);
  31915. }
  31916. if (texture.generateMipMaps) {
  31917. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31918. }
  31919. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31920. // this.resetTextureCache();
  31921. texture.isReady = true;
  31922. };
  31923. /**
  31924. * Creates a raw texture
  31925. * @param data defines the data to store in the texture
  31926. * @param width defines the width of the texture
  31927. * @param height defines the height of the texture
  31928. * @param format defines the format of the data
  31929. * @param generateMipMaps defines if the engine should generate the mip levels
  31930. * @param invertY defines if data must be stored with Y axis inverted
  31931. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31932. * @param compression defines the compression used (null by default)
  31933. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31934. * @returns the raw texture inside an InternalTexture
  31935. */
  31936. Engine.prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode, compression, type) {
  31937. if (compression === void 0) { compression = null; }
  31938. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31939. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW);
  31940. texture.baseWidth = width;
  31941. texture.baseHeight = height;
  31942. texture.width = width;
  31943. texture.height = height;
  31944. texture.format = format;
  31945. texture.generateMipMaps = generateMipMaps;
  31946. texture.samplingMode = samplingMode;
  31947. texture.invertY = invertY;
  31948. texture._compression = compression;
  31949. texture.type = type;
  31950. if (!this._doNotHandleContextLost) {
  31951. texture._bufferView = data;
  31952. }
  31953. this.updateRawTexture(texture, data, format, invertY, compression, type);
  31954. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31955. // Filters
  31956. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  31957. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  31958. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31959. if (generateMipMaps) {
  31960. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31961. }
  31962. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31963. this._internalTexturesCache.push(texture);
  31964. return texture;
  31965. };
  31966. /** @hidden */
  31967. Engine.prototype._unpackFlipY = function (value) {
  31968. if (this._unpackFlipYCached !== value) {
  31969. this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, value ? 1 : 0);
  31970. if (this.enableUnpackFlipYCached) {
  31971. this._unpackFlipYCached = value;
  31972. }
  31973. }
  31974. };
  31975. /** @hidden */
  31976. Engine.prototype._getUnpackAlignement = function () {
  31977. return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT);
  31978. };
  31979. /**
  31980. * Creates a dynamic texture
  31981. * @param width defines the width of the texture
  31982. * @param height defines the height of the texture
  31983. * @param generateMipMaps defines if the engine should generate the mip levels
  31984. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31985. * @returns the dynamic texture inside an InternalTexture
  31986. */
  31987. Engine.prototype.createDynamicTexture = function (width, height, generateMipMaps, samplingMode) {
  31988. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DYNAMIC);
  31989. texture.baseWidth = width;
  31990. texture.baseHeight = height;
  31991. if (generateMipMaps) {
  31992. width = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, this._caps.maxTextureSize) : width;
  31993. height = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, this._caps.maxTextureSize) : height;
  31994. }
  31995. // this.resetTextureCache();
  31996. texture.width = width;
  31997. texture.height = height;
  31998. texture.isReady = false;
  31999. texture.generateMipMaps = generateMipMaps;
  32000. texture.samplingMode = samplingMode;
  32001. this.updateTextureSamplingMode(samplingMode, texture);
  32002. this._internalTexturesCache.push(texture);
  32003. return texture;
  32004. };
  32005. /**
  32006. * Update the sampling mode of a given texture
  32007. * @param samplingMode defines the required sampling mode
  32008. * @param texture defines the texture to update
  32009. */
  32010. Engine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  32011. var filters = this._getSamplingParameters(samplingMode, texture.generateMipMaps);
  32012. if (texture.isCube) {
  32013. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  32014. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MIN_FILTER, filters.min);
  32015. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32016. }
  32017. else if (texture.is3D) {
  32018. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  32019. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  32020. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32021. }
  32022. else {
  32023. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  32024. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  32025. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32026. }
  32027. texture.samplingMode = samplingMode;
  32028. };
  32029. /**
  32030. * Update the content of a dynamic texture
  32031. * @param texture defines the texture to update
  32032. * @param canvas defines the canvas containing the source
  32033. * @param invertY defines if data must be stored with Y axis inverted
  32034. * @param premulAlpha defines if alpha is stored as premultiplied
  32035. * @param format defines the format of the data
  32036. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32037. */
  32038. Engine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format, forceBindTexture) {
  32039. if (premulAlpha === void 0) { premulAlpha = false; }
  32040. if (forceBindTexture === void 0) { forceBindTexture = false; }
  32041. if (!texture) {
  32042. return;
  32043. }
  32044. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true, forceBindTexture);
  32045. this._unpackFlipY(invertY);
  32046. if (premulAlpha) {
  32047. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
  32048. }
  32049. var internalFormat = format ? this._getInternalFormat(format) : this._gl.RGBA;
  32050. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, internalFormat, this._gl.UNSIGNED_BYTE, canvas);
  32051. if (texture.generateMipMaps) {
  32052. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32053. }
  32054. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32055. if (premulAlpha) {
  32056. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
  32057. }
  32058. texture.isReady = true;
  32059. };
  32060. /**
  32061. * Update a video texture
  32062. * @param texture defines the texture to update
  32063. * @param video defines the video element to use
  32064. * @param invertY defines if data must be stored with Y axis inverted
  32065. */
  32066. Engine.prototype.updateVideoTexture = function (texture, video, invertY) {
  32067. if (!texture || texture._isDisabled) {
  32068. return;
  32069. }
  32070. var wasPreviouslyBound = this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  32071. this._unpackFlipY(!invertY); // Video are upside down by default
  32072. try {
  32073. // Testing video texture support
  32074. if (this._videoTextureSupported === undefined) {
  32075. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  32076. if (this._gl.getError() !== 0) {
  32077. this._videoTextureSupported = false;
  32078. }
  32079. else {
  32080. this._videoTextureSupported = true;
  32081. }
  32082. }
  32083. // Copy video through the current working canvas if video texture is not supported
  32084. if (!this._videoTextureSupported) {
  32085. if (!texture._workingCanvas) {
  32086. texture._workingCanvas = document.createElement("canvas");
  32087. var context = texture._workingCanvas.getContext("2d");
  32088. if (!context) {
  32089. throw new Error("Unable to get 2d context");
  32090. }
  32091. texture._workingContext = context;
  32092. texture._workingCanvas.width = texture.width;
  32093. texture._workingCanvas.height = texture.height;
  32094. }
  32095. texture._workingContext.drawImage(video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, texture.width, texture.height);
  32096. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, texture._workingCanvas);
  32097. }
  32098. else {
  32099. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  32100. }
  32101. if (texture.generateMipMaps) {
  32102. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32103. }
  32104. if (!wasPreviouslyBound) {
  32105. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32106. }
  32107. // this.resetTextureCache();
  32108. texture.isReady = true;
  32109. }
  32110. catch (ex) {
  32111. // Something unexpected
  32112. // Let's disable the texture
  32113. texture._isDisabled = true;
  32114. }
  32115. };
  32116. /**
  32117. * Updates a depth texture Comparison Mode and Function.
  32118. * If the comparison Function is equal to 0, the mode will be set to none.
  32119. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32120. * @param texture The texture to set the comparison function for
  32121. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32122. */
  32123. Engine.prototype.updateTextureComparisonFunction = function (texture, comparisonFunction) {
  32124. if (this.webGLVersion === 1) {
  32125. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("WebGL 1 does not support texture comparison.");
  32126. return;
  32127. }
  32128. var gl = this._gl;
  32129. if (texture.isCube) {
  32130. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  32131. if (comparisonFunction === 0) {
  32132. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  32133. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  32134. }
  32135. else {
  32136. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  32137. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  32138. }
  32139. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32140. }
  32141. else {
  32142. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  32143. if (comparisonFunction === 0) {
  32144. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  32145. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  32146. }
  32147. else {
  32148. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  32149. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  32150. }
  32151. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32152. }
  32153. texture._comparisonFunction = comparisonFunction;
  32154. };
  32155. Engine.prototype._setupDepthStencilTexture = function (internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction) {
  32156. var width = size.width || size;
  32157. var height = size.height || size;
  32158. internalTexture.baseWidth = width;
  32159. internalTexture.baseHeight = height;
  32160. internalTexture.width = width;
  32161. internalTexture.height = height;
  32162. internalTexture.isReady = true;
  32163. internalTexture.samples = 1;
  32164. internalTexture.generateMipMaps = false;
  32165. internalTexture._generateDepthBuffer = true;
  32166. internalTexture._generateStencilBuffer = generateStencil;
  32167. internalTexture.samplingMode = bilinearFiltering ? Engine.TEXTURE_BILINEAR_SAMPLINGMODE : Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32168. internalTexture.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32169. internalTexture._comparisonFunction = comparisonFunction;
  32170. var gl = this._gl;
  32171. var target = internalTexture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  32172. var samplingParameters = this._getSamplingParameters(internalTexture.samplingMode, false);
  32173. gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, samplingParameters.mag);
  32174. gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, samplingParameters.min);
  32175. gl.texParameteri(target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32176. gl.texParameteri(target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32177. if (comparisonFunction === 0) {
  32178. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  32179. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  32180. }
  32181. else {
  32182. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  32183. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  32184. }
  32185. };
  32186. /**
  32187. * Creates a depth stencil texture.
  32188. * This is only available in WebGL 2 or with the depth texture extension available.
  32189. * @param size The size of face edge in the texture.
  32190. * @param options The options defining the texture.
  32191. * @returns The texture
  32192. */
  32193. Engine.prototype.createDepthStencilTexture = function (size, options) {
  32194. if (options.isCube) {
  32195. var width = size.width || size;
  32196. return this._createDepthStencilCubeTexture(width, options);
  32197. }
  32198. else {
  32199. return this._createDepthStencilTexture(size, options);
  32200. }
  32201. };
  32202. /**
  32203. * Creates a depth stencil texture.
  32204. * This is only available in WebGL 2 or with the depth texture extension available.
  32205. * @param size The size of face edge in the texture.
  32206. * @param options The options defining the texture.
  32207. * @returns The texture
  32208. */
  32209. Engine.prototype._createDepthStencilTexture = function (size, options) {
  32210. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DEPTHTEXTURE);
  32211. if (!this._caps.depthTextureExtension) {
  32212. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth texture is not supported by your browser or hardware.");
  32213. return internalTexture;
  32214. }
  32215. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  32216. var gl = this._gl;
  32217. this._bindTextureDirectly(gl.TEXTURE_2D, internalTexture, true);
  32218. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  32219. if (this.webGLVersion > 1) {
  32220. if (internalOptions.generateStencil) {
  32221. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH24_STENCIL8, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  32222. }
  32223. else {
  32224. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT24, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  32225. }
  32226. }
  32227. else {
  32228. if (internalOptions.generateStencil) {
  32229. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_STENCIL, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  32230. }
  32231. else {
  32232. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  32233. }
  32234. }
  32235. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32236. return internalTexture;
  32237. };
  32238. /**
  32239. * Creates a depth stencil cube texture.
  32240. * This is only available in WebGL 2.
  32241. * @param size The size of face edge in the cube texture.
  32242. * @param options The options defining the cube texture.
  32243. * @returns The cube texture
  32244. */
  32245. Engine.prototype._createDepthStencilCubeTexture = function (size, options) {
  32246. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_UNKNOWN);
  32247. internalTexture.isCube = true;
  32248. if (this.webGLVersion === 1) {
  32249. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth cube texture is not supported by WebGL 1.");
  32250. return internalTexture;
  32251. }
  32252. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  32253. var gl = this._gl;
  32254. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, internalTexture, true);
  32255. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  32256. // Create the depth/stencil buffer
  32257. for (var face = 0; face < 6; face++) {
  32258. if (internalOptions.generateStencil) {
  32259. 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);
  32260. }
  32261. else {
  32262. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, gl.DEPTH_COMPONENT24, size, size, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  32263. }
  32264. }
  32265. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32266. return internalTexture;
  32267. };
  32268. /**
  32269. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32270. * @param renderTarget The render target to set the frame buffer for
  32271. */
  32272. Engine.prototype.setFrameBufferDepthStencilTexture = function (renderTarget) {
  32273. // Create the framebuffer
  32274. var internalTexture = renderTarget.getInternalTexture();
  32275. if (!internalTexture || !internalTexture._framebuffer || !renderTarget.depthStencilTexture) {
  32276. return;
  32277. }
  32278. var gl = this._gl;
  32279. var depthStencilTexture = renderTarget.depthStencilTexture;
  32280. this.bindUnboundFramebuffer(internalTexture._framebuffer);
  32281. if (depthStencilTexture.isCube) {
  32282. if (depthStencilTexture._generateStencilBuffer) {
  32283. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  32284. }
  32285. else {
  32286. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  32287. }
  32288. }
  32289. else {
  32290. if (depthStencilTexture._generateStencilBuffer) {
  32291. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  32292. }
  32293. else {
  32294. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  32295. }
  32296. }
  32297. this.bindUnboundFramebuffer(null);
  32298. };
  32299. /**
  32300. * Creates a new render target texture
  32301. * @param size defines the size of the texture
  32302. * @param options defines the options used to create the texture
  32303. * @returns a new render target texture stored in an InternalTexture
  32304. */
  32305. Engine.prototype.createRenderTargetTexture = function (size, options) {
  32306. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__["RenderTargetCreationOptions"]();
  32307. if (options !== undefined && typeof options === "object") {
  32308. fullOptions.generateMipMaps = options.generateMipMaps;
  32309. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  32310. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  32311. fullOptions.type = options.type === undefined ? Engine.TEXTURETYPE_UNSIGNED_INT : options.type;
  32312. fullOptions.samplingMode = options.samplingMode === undefined ? Engine.TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  32313. fullOptions.format = options.format === undefined ? Engine.TEXTUREFORMAT_RGBA : options.format;
  32314. }
  32315. else {
  32316. fullOptions.generateMipMaps = options;
  32317. fullOptions.generateDepthBuffer = true;
  32318. fullOptions.generateStencilBuffer = false;
  32319. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32320. fullOptions.samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  32321. fullOptions.format = Engine.TEXTUREFORMAT_RGBA;
  32322. }
  32323. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  32324. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  32325. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32326. }
  32327. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  32328. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  32329. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32330. }
  32331. var gl = this._gl;
  32332. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  32333. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  32334. var width = size.width || size;
  32335. var height = size.height || size;
  32336. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps ? true : false);
  32337. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  32338. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32339. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  32340. }
  32341. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  32342. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  32343. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32344. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32345. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(fullOptions.type, fullOptions.format), width, height, 0, this._getInternalFormat(fullOptions.format), this._getWebGLTextureType(fullOptions.type), null);
  32346. // Create the framebuffer
  32347. var currentFrameBuffer = this._currentFramebuffer;
  32348. var framebuffer = gl.createFramebuffer();
  32349. this.bindUnboundFramebuffer(framebuffer);
  32350. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, 0);
  32351. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer ? true : false, fullOptions.generateDepthBuffer, width, height);
  32352. if (fullOptions.generateMipMaps) {
  32353. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32354. }
  32355. // Unbind
  32356. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32357. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32358. this.bindUnboundFramebuffer(currentFrameBuffer);
  32359. texture._framebuffer = framebuffer;
  32360. texture.baseWidth = width;
  32361. texture.baseHeight = height;
  32362. texture.width = width;
  32363. texture.height = height;
  32364. texture.isReady = true;
  32365. texture.samples = 1;
  32366. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  32367. texture.samplingMode = fullOptions.samplingMode;
  32368. texture.type = fullOptions.type;
  32369. texture.format = fullOptions.format;
  32370. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  32371. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  32372. // this.resetTextureCache();
  32373. this._internalTexturesCache.push(texture);
  32374. return texture;
  32375. };
  32376. /**
  32377. * Create a multi render target texture
  32378. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  32379. * @param size defines the size of the texture
  32380. * @param options defines the creation options
  32381. * @returns the cube texture as an InternalTexture
  32382. */
  32383. Engine.prototype.createMultipleRenderTarget = function (size, options) {
  32384. var generateMipMaps = false;
  32385. var generateDepthBuffer = true;
  32386. var generateStencilBuffer = false;
  32387. var generateDepthTexture = false;
  32388. var textureCount = 1;
  32389. var defaultType = Engine.TEXTURETYPE_UNSIGNED_INT;
  32390. var defaultSamplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  32391. var types = new Array();
  32392. var samplingModes = new Array();
  32393. if (options !== undefined) {
  32394. generateMipMaps = options.generateMipMaps === undefined ? false : options.generateMipMaps;
  32395. generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  32396. generateStencilBuffer = options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  32397. generateDepthTexture = options.generateDepthTexture === undefined ? false : options.generateDepthTexture;
  32398. textureCount = options.textureCount || 1;
  32399. if (options.types) {
  32400. types = options.types;
  32401. }
  32402. if (options.samplingModes) {
  32403. samplingModes = options.samplingModes;
  32404. }
  32405. }
  32406. var gl = this._gl;
  32407. // Create the framebuffer
  32408. var framebuffer = gl.createFramebuffer();
  32409. this.bindUnboundFramebuffer(framebuffer);
  32410. var width = size.width || size;
  32411. var height = size.height || size;
  32412. var textures = [];
  32413. var attachments = [];
  32414. var depthStencilBuffer = this._setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height);
  32415. for (var i = 0; i < textureCount; i++) {
  32416. var samplingMode = samplingModes[i] || defaultSamplingMode;
  32417. var type = types[i] || defaultType;
  32418. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  32419. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  32420. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32421. }
  32422. else if (type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  32423. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  32424. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32425. }
  32426. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32427. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  32428. type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32429. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  32430. }
  32431. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  32432. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  32433. textures.push(texture);
  32434. attachments.push(attachment);
  32435. gl.activeTexture(gl["TEXTURE" + i]);
  32436. gl.bindTexture(gl.TEXTURE_2D, texture._webGLTexture);
  32437. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  32438. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  32439. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32440. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32441. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), width, height, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  32442. gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, attachment, gl.TEXTURE_2D, texture._webGLTexture, 0);
  32443. if (generateMipMaps) {
  32444. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32445. }
  32446. // Unbind
  32447. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32448. texture._framebuffer = framebuffer;
  32449. texture._depthStencilBuffer = depthStencilBuffer;
  32450. texture.baseWidth = width;
  32451. texture.baseHeight = height;
  32452. texture.width = width;
  32453. texture.height = height;
  32454. texture.isReady = true;
  32455. texture.samples = 1;
  32456. texture.generateMipMaps = generateMipMaps;
  32457. texture.samplingMode = samplingMode;
  32458. texture.type = type;
  32459. texture._generateDepthBuffer = generateDepthBuffer;
  32460. texture._generateStencilBuffer = generateStencilBuffer;
  32461. texture._attachments = attachments;
  32462. this._internalTexturesCache.push(texture);
  32463. }
  32464. if (generateDepthTexture && this._caps.depthTextureExtension) {
  32465. // Depth texture
  32466. var depthTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  32467. gl.activeTexture(gl.TEXTURE0);
  32468. gl.bindTexture(gl.TEXTURE_2D, depthTexture._webGLTexture);
  32469. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  32470. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  32471. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32472. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32473. 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);
  32474. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthTexture._webGLTexture, 0);
  32475. depthTexture._framebuffer = framebuffer;
  32476. depthTexture.baseWidth = width;
  32477. depthTexture.baseHeight = height;
  32478. depthTexture.width = width;
  32479. depthTexture.height = height;
  32480. depthTexture.isReady = true;
  32481. depthTexture.samples = 1;
  32482. depthTexture.generateMipMaps = generateMipMaps;
  32483. depthTexture.samplingMode = gl.NEAREST;
  32484. depthTexture._generateDepthBuffer = generateDepthBuffer;
  32485. depthTexture._generateStencilBuffer = generateStencilBuffer;
  32486. textures.push(depthTexture);
  32487. this._internalTexturesCache.push(depthTexture);
  32488. }
  32489. gl.drawBuffers(attachments);
  32490. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32491. this.bindUnboundFramebuffer(null);
  32492. this.resetTextureCache();
  32493. return textures;
  32494. };
  32495. Engine.prototype._setupFramebufferDepthAttachments = function (generateStencilBuffer, generateDepthBuffer, width, height, samples) {
  32496. if (samples === void 0) { samples = 1; }
  32497. var depthStencilBuffer = null;
  32498. var gl = this._gl;
  32499. // Create the depth/stencil buffer
  32500. if (generateStencilBuffer) {
  32501. depthStencilBuffer = gl.createRenderbuffer();
  32502. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  32503. if (samples > 1) {
  32504. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH24_STENCIL8, width, height);
  32505. }
  32506. else {
  32507. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
  32508. }
  32509. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  32510. }
  32511. else if (generateDepthBuffer) {
  32512. depthStencilBuffer = gl.createRenderbuffer();
  32513. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  32514. if (samples > 1) {
  32515. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH_COMPONENT16, width, height);
  32516. }
  32517. else {
  32518. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
  32519. }
  32520. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  32521. }
  32522. return depthStencilBuffer;
  32523. };
  32524. /**
  32525. * Updates the sample count of a render target texture
  32526. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32527. * @param texture defines the texture to update
  32528. * @param samples defines the sample count to set
  32529. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32530. */
  32531. Engine.prototype.updateRenderTargetTextureSampleCount = function (texture, samples) {
  32532. if (this.webGLVersion < 2 || !texture) {
  32533. return 1;
  32534. }
  32535. if (texture.samples === samples) {
  32536. return samples;
  32537. }
  32538. var gl = this._gl;
  32539. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  32540. // Dispose previous render buffers
  32541. if (texture._depthStencilBuffer) {
  32542. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  32543. texture._depthStencilBuffer = null;
  32544. }
  32545. if (texture._MSAAFramebuffer) {
  32546. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  32547. texture._MSAAFramebuffer = null;
  32548. }
  32549. if (texture._MSAARenderBuffer) {
  32550. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  32551. texture._MSAARenderBuffer = null;
  32552. }
  32553. if (samples > 1) {
  32554. var framebuffer = gl.createFramebuffer();
  32555. if (!framebuffer) {
  32556. throw new Error("Unable to create multi sampled framebuffer");
  32557. }
  32558. texture._MSAAFramebuffer = framebuffer;
  32559. this.bindUnboundFramebuffer(texture._MSAAFramebuffer);
  32560. var colorRenderbuffer = gl.createRenderbuffer();
  32561. if (!colorRenderbuffer) {
  32562. throw new Error("Unable to create multi sampled framebuffer");
  32563. }
  32564. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  32565. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  32566. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorRenderbuffer);
  32567. texture._MSAARenderBuffer = colorRenderbuffer;
  32568. }
  32569. else {
  32570. this.bindUnboundFramebuffer(texture._framebuffer);
  32571. }
  32572. texture.samples = samples;
  32573. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(texture._generateStencilBuffer, texture._generateDepthBuffer, texture.width, texture.height, samples);
  32574. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32575. this.bindUnboundFramebuffer(null);
  32576. return samples;
  32577. };
  32578. /**
  32579. * Update the sample count for a given multiple render target texture
  32580. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32581. * @param textures defines the textures to update
  32582. * @param samples defines the sample count to set
  32583. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32584. */
  32585. Engine.prototype.updateMultipleRenderTargetTextureSampleCount = function (textures, samples) {
  32586. if (this.webGLVersion < 2 || !textures || textures.length == 0) {
  32587. return 1;
  32588. }
  32589. if (textures[0].samples === samples) {
  32590. return samples;
  32591. }
  32592. var gl = this._gl;
  32593. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  32594. // Dispose previous render buffers
  32595. if (textures[0]._depthStencilBuffer) {
  32596. gl.deleteRenderbuffer(textures[0]._depthStencilBuffer);
  32597. textures[0]._depthStencilBuffer = null;
  32598. }
  32599. if (textures[0]._MSAAFramebuffer) {
  32600. gl.deleteFramebuffer(textures[0]._MSAAFramebuffer);
  32601. textures[0]._MSAAFramebuffer = null;
  32602. }
  32603. for (var i = 0; i < textures.length; i++) {
  32604. if (textures[i]._MSAARenderBuffer) {
  32605. gl.deleteRenderbuffer(textures[i]._MSAARenderBuffer);
  32606. textures[i]._MSAARenderBuffer = null;
  32607. }
  32608. }
  32609. if (samples > 1) {
  32610. var framebuffer = gl.createFramebuffer();
  32611. if (!framebuffer) {
  32612. throw new Error("Unable to create multi sampled framebuffer");
  32613. }
  32614. this.bindUnboundFramebuffer(framebuffer);
  32615. var depthStencilBuffer = this._setupFramebufferDepthAttachments(textures[0]._generateStencilBuffer, textures[0]._generateDepthBuffer, textures[0].width, textures[0].height, samples);
  32616. var attachments = [];
  32617. for (var i = 0; i < textures.length; i++) {
  32618. var texture = textures[i];
  32619. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  32620. var colorRenderbuffer = gl.createRenderbuffer();
  32621. if (!colorRenderbuffer) {
  32622. throw new Error("Unable to create multi sampled framebuffer");
  32623. }
  32624. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  32625. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  32626. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, colorRenderbuffer);
  32627. texture._MSAAFramebuffer = framebuffer;
  32628. texture._MSAARenderBuffer = colorRenderbuffer;
  32629. texture.samples = samples;
  32630. texture._depthStencilBuffer = depthStencilBuffer;
  32631. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32632. attachments.push(attachment);
  32633. }
  32634. gl.drawBuffers(attachments);
  32635. }
  32636. else {
  32637. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  32638. }
  32639. this.bindUnboundFramebuffer(null);
  32640. return samples;
  32641. };
  32642. /** @hidden */
  32643. Engine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  32644. if (faceIndex === void 0) { faceIndex = 0; }
  32645. if (lod === void 0) { lod = 0; }
  32646. var gl = this._gl;
  32647. var target = gl.TEXTURE_2D;
  32648. if (texture.isCube) {
  32649. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  32650. }
  32651. this._gl.compressedTexImage2D(target, lod, internalFormat, width, height, 0, data);
  32652. };
  32653. /** @hidden */
  32654. Engine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  32655. if (faceIndex === void 0) { faceIndex = 0; }
  32656. if (lod === void 0) { lod = 0; }
  32657. var gl = this._gl;
  32658. var textureType = this._getWebGLTextureType(texture.type);
  32659. var format = this._getInternalFormat(texture.format);
  32660. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  32661. this._unpackFlipY(texture.invertY);
  32662. var target = gl.TEXTURE_2D;
  32663. if (texture.isCube) {
  32664. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  32665. }
  32666. var lodMaxWidth = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.width));
  32667. var lodMaxHeight = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.height));
  32668. var width = Math.pow(2, Math.max(lodMaxWidth - lod, 0));
  32669. var height = Math.pow(2, Math.max(lodMaxHeight - lod, 0));
  32670. gl.texImage2D(target, lod, internalFormat, width, height, 0, format, textureType, imageData);
  32671. };
  32672. /** @hidden */
  32673. Engine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  32674. if (faceIndex === void 0) { faceIndex = 0; }
  32675. if (lod === void 0) { lod = 0; }
  32676. var gl = this._gl;
  32677. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  32678. this._bindTextureDirectly(bindTarget, texture, true);
  32679. this._uploadDataToTextureDirectly(texture, imageData, faceIndex, lod);
  32680. this._bindTextureDirectly(bindTarget, null, true);
  32681. };
  32682. /** @hidden */
  32683. Engine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  32684. if (faceIndex === void 0) { faceIndex = 0; }
  32685. if (lod === void 0) { lod = 0; }
  32686. var gl = this._gl;
  32687. var textureType = this._getWebGLTextureType(texture.type);
  32688. var format = this._getInternalFormat(texture.format);
  32689. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  32690. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  32691. this._bindTextureDirectly(bindTarget, texture, true);
  32692. this._unpackFlipY(texture.invertY);
  32693. var target = gl.TEXTURE_2D;
  32694. if (texture.isCube) {
  32695. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  32696. }
  32697. gl.texImage2D(target, lod, internalFormat, format, textureType, image);
  32698. this._bindTextureDirectly(bindTarget, null, true);
  32699. };
  32700. /**
  32701. * Creates a new render target cube texture
  32702. * @param size defines the size of the texture
  32703. * @param options defines the options used to create the texture
  32704. * @returns a new render target cube texture stored in an InternalTexture
  32705. */
  32706. Engine.prototype.createRenderTargetCubeTexture = function (size, options) {
  32707. 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);
  32708. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && fullOptions.generateStencilBuffer;
  32709. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  32710. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  32711. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32712. }
  32713. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  32714. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  32715. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32716. }
  32717. var gl = this._gl;
  32718. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  32719. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32720. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps);
  32721. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  32722. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32723. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type");
  32724. }
  32725. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  32726. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  32727. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32728. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32729. for (var face = 0; face < 6; face++) {
  32730. 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);
  32731. }
  32732. // Create the framebuffer
  32733. var framebuffer = gl.createFramebuffer();
  32734. this.bindUnboundFramebuffer(framebuffer);
  32735. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer, fullOptions.generateDepthBuffer, size, size);
  32736. // MipMaps
  32737. if (fullOptions.generateMipMaps) {
  32738. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  32739. }
  32740. // Unbind
  32741. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32742. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32743. this.bindUnboundFramebuffer(null);
  32744. texture._framebuffer = framebuffer;
  32745. texture.width = size;
  32746. texture.height = size;
  32747. texture.isReady = true;
  32748. texture.isCube = true;
  32749. texture.samples = 1;
  32750. texture.generateMipMaps = fullOptions.generateMipMaps;
  32751. texture.samplingMode = fullOptions.samplingMode;
  32752. texture.type = fullOptions.type;
  32753. texture.format = fullOptions.format;
  32754. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  32755. texture._generateStencilBuffer = fullOptions.generateStencilBuffer;
  32756. this._internalTexturesCache.push(texture);
  32757. return texture;
  32758. };
  32759. /**
  32760. * Creates a cube texture
  32761. * @param rootUrl defines the url where the files to load is located
  32762. * @param scene defines the current scene
  32763. * @param files defines the list of files to load (1 per face)
  32764. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  32765. * @param onLoad defines an optional callback raised when the texture is loaded
  32766. * @param onError defines an optional callback raised if there is an issue to load the texture
  32767. * @param format defines the format of the data
  32768. * @param forcedExtension defines the extension to use to pick the right loader
  32769. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  32770. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  32771. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  32772. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  32773. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  32774. * @returns the cube texture as an InternalTexture
  32775. */
  32776. Engine.prototype.createCubeTexture = function (rootUrl, scene, files, noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback, excludeLoaders) {
  32777. var _this = this;
  32778. if (onLoad === void 0) { onLoad = null; }
  32779. if (onError === void 0) { onError = null; }
  32780. if (forcedExtension === void 0) { forcedExtension = null; }
  32781. if (createPolynomials === void 0) { createPolynomials = false; }
  32782. if (lodScale === void 0) { lodScale = 0; }
  32783. if (lodOffset === void 0) { lodOffset = 0; }
  32784. if (fallback === void 0) { fallback = null; }
  32785. if (excludeLoaders === void 0) { excludeLoaders = []; }
  32786. var gl = this._gl;
  32787. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBE);
  32788. texture.isCube = true;
  32789. texture.url = rootUrl;
  32790. texture.generateMipMaps = !noMipmap;
  32791. texture._lodGenerationScale = lodScale;
  32792. texture._lodGenerationOffset = lodOffset;
  32793. if (!this._doNotHandleContextLost) {
  32794. texture._extension = forcedExtension;
  32795. texture._files = files;
  32796. }
  32797. var lastDot = rootUrl.lastIndexOf('.');
  32798. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  32799. var loader = null;
  32800. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  32801. var availableLoader = _a[_i];
  32802. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, false, false)) {
  32803. loader = availableLoader;
  32804. break;
  32805. }
  32806. }
  32807. var onInternalError = function (request, exception) {
  32808. if (loader) {
  32809. var fallbackUrl = loader.getFallbackTextureUrl(texture.url, _this._textureFormatInUse);
  32810. _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");
  32811. if (fallbackUrl) {
  32812. excludeLoaders.push(loader);
  32813. _this.createCubeTexture(fallbackUrl, scene, files, noMipmap, onLoad, onError, format, extension, createPolynomials, lodScale, lodOffset, texture, excludeLoaders);
  32814. return;
  32815. }
  32816. }
  32817. if (onError && request) {
  32818. onError(request.status + " " + request.statusText, exception);
  32819. }
  32820. };
  32821. if (loader) {
  32822. rootUrl = loader.transformUrl(rootUrl, this._textureFormatInUse);
  32823. var onloaddata = function (data) {
  32824. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32825. loader.loadCubeData(data, texture, createPolynomials, onLoad, onError);
  32826. };
  32827. if (files && files.length === 6) {
  32828. if (loader.supportCascades) {
  32829. this._cascadeLoadFiles(scene, onloaddata, files, onError);
  32830. }
  32831. else {
  32832. if (onError) {
  32833. onError("Textures type does not support cascades.");
  32834. }
  32835. else {
  32836. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Texture loader does not support cascades.");
  32837. }
  32838. }
  32839. }
  32840. else {
  32841. this._loadFile(rootUrl, onloaddata, undefined, undefined, true, onInternalError);
  32842. }
  32843. }
  32844. else {
  32845. if (!files) {
  32846. throw new Error("Cannot load cubemap because files were not defined");
  32847. }
  32848. this._cascadeLoadImgs(scene, function (imgs) {
  32849. var width = _this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(imgs[0].width, _this._caps.maxCubemapTextureSize) : imgs[0].width;
  32850. var height = width;
  32851. _this._prepareWorkingCanvas();
  32852. if (!_this._workingCanvas || !_this._workingContext) {
  32853. return;
  32854. }
  32855. _this._workingCanvas.width = width;
  32856. _this._workingCanvas.height = height;
  32857. var faces = [
  32858. gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
  32859. gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
  32860. ];
  32861. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32862. _this._unpackFlipY(false);
  32863. var internalFormat = format ? _this._getInternalFormat(format) : _this._gl.RGBA;
  32864. for (var index = 0; index < faces.length; index++) {
  32865. if (imgs[index].width !== width || imgs[index].height !== height) {
  32866. _this._workingContext.drawImage(imgs[index], 0, 0, imgs[index].width, imgs[index].height, 0, 0, width, height);
  32867. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  32868. }
  32869. else {
  32870. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, imgs[index]);
  32871. }
  32872. }
  32873. if (!noMipmap) {
  32874. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  32875. }
  32876. _this._setCubeMapTextureParams(!noMipmap);
  32877. texture.width = width;
  32878. texture.height = height;
  32879. texture.isReady = true;
  32880. if (format) {
  32881. texture.format = format;
  32882. }
  32883. texture.onLoadedObservable.notifyObservers(texture);
  32884. texture.onLoadedObservable.clear();
  32885. if (onLoad) {
  32886. onLoad();
  32887. }
  32888. }, files, onError);
  32889. }
  32890. this._internalTexturesCache.push(texture);
  32891. return texture;
  32892. };
  32893. /**
  32894. * @hidden
  32895. */
  32896. Engine.prototype._setCubeMapTextureParams = function (loadMipmap) {
  32897. var gl = this._gl;
  32898. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  32899. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, loadMipmap ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
  32900. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32901. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32902. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32903. // this.resetTextureCache();
  32904. };
  32905. /**
  32906. * Update a raw cube texture
  32907. * @param texture defines the texture to udpdate
  32908. * @param data defines the data to store
  32909. * @param format defines the data format
  32910. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32911. * @param invertY defines if data must be stored with Y axis inverted
  32912. * @param compression defines the compression used (null by default)
  32913. * @param level defines which level of the texture to update
  32914. */
  32915. Engine.prototype.updateRawCubeTexture = function (texture, data, format, type, invertY, compression, level) {
  32916. if (compression === void 0) { compression = null; }
  32917. if (level === void 0) { level = 0; }
  32918. texture._bufferViewArray = data;
  32919. texture.format = format;
  32920. texture.type = type;
  32921. texture.invertY = invertY;
  32922. texture._compression = compression;
  32923. var gl = this._gl;
  32924. var textureType = this._getWebGLTextureType(type);
  32925. var internalFormat = this._getInternalFormat(format);
  32926. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type);
  32927. var needConversion = false;
  32928. if (internalFormat === gl.RGB) {
  32929. internalFormat = gl.RGBA;
  32930. needConversion = true;
  32931. }
  32932. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32933. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32934. if (texture.width % 4 !== 0) {
  32935. gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
  32936. }
  32937. // Data are known to be in +X +Y +Z -X -Y -Z
  32938. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  32939. var faceData = data[faceIndex];
  32940. if (compression) {
  32941. gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, (this.getCaps().s3tc)[compression], texture.width, texture.height, 0, faceData);
  32942. }
  32943. else {
  32944. if (needConversion) {
  32945. faceData = this._convertRGBtoRGBATextureData(faceData, texture.width, texture.height, type);
  32946. }
  32947. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, faceData);
  32948. }
  32949. }
  32950. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  32951. if (isPot && texture.generateMipMaps && level === 0) {
  32952. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  32953. }
  32954. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32955. // this.resetTextureCache();
  32956. texture.isReady = true;
  32957. };
  32958. /**
  32959. * Creates a new raw cube texture
  32960. * @param data defines the array of data to use to create each face
  32961. * @param size defines the size of the textures
  32962. * @param format defines the format of the data
  32963. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32964. * @param generateMipMaps defines if the engine should generate the mip levels
  32965. * @param invertY defines if data must be stored with Y axis inverted
  32966. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32967. * @param compression defines the compression used (null by default)
  32968. * @returns the cube texture as an InternalTexture
  32969. */
  32970. Engine.prototype.createRawCubeTexture = function (data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  32971. if (compression === void 0) { compression = null; }
  32972. var gl = this._gl;
  32973. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBERAW);
  32974. texture.isCube = true;
  32975. texture.format = format;
  32976. texture.type = type;
  32977. if (!this._doNotHandleContextLost) {
  32978. texture._bufferViewArray = data;
  32979. }
  32980. var textureType = this._getWebGLTextureType(type);
  32981. var internalFormat = this._getInternalFormat(format);
  32982. if (internalFormat === gl.RGB) {
  32983. internalFormat = gl.RGBA;
  32984. }
  32985. // Mipmap generation needs a sized internal format that is both color-renderable and texture-filterable
  32986. if (textureType === gl.FLOAT && !this._caps.textureFloatLinearFiltering) {
  32987. generateMipMaps = false;
  32988. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32989. _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.");
  32990. }
  32991. else if (textureType === this._gl.HALF_FLOAT_OES && !this._caps.textureHalfFloatLinearFiltering) {
  32992. generateMipMaps = false;
  32993. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32994. _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.");
  32995. }
  32996. else if (textureType === gl.FLOAT && !this._caps.textureFloatRender) {
  32997. generateMipMaps = false;
  32998. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to float textures is not supported. Mipmap generation forced to false.");
  32999. }
  33000. else if (textureType === gl.HALF_FLOAT && !this._caps.colorBufferFloat) {
  33001. generateMipMaps = false;
  33002. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to half float textures is not supported. Mipmap generation forced to false.");
  33003. }
  33004. var width = size;
  33005. var height = width;
  33006. texture.width = width;
  33007. texture.height = height;
  33008. // Double check on POT to generate Mips.
  33009. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  33010. if (!isPot) {
  33011. generateMipMaps = false;
  33012. }
  33013. // Upload data if needed. The texture won't be ready until then.
  33014. if (data) {
  33015. this.updateRawCubeTexture(texture, data, format, type, invertY, compression);
  33016. }
  33017. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  33018. // Filters
  33019. if (data && generateMipMaps) {
  33020. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  33021. }
  33022. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  33023. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  33024. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  33025. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  33026. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  33027. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  33028. texture.generateMipMaps = generateMipMaps;
  33029. return texture;
  33030. };
  33031. /**
  33032. * Creates a new raw cube texture from a specified url
  33033. * @param url defines the url where the data is located
  33034. * @param scene defines the current scene
  33035. * @param size defines the size of the textures
  33036. * @param format defines the format of the data
  33037. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  33038. * @param noMipmap defines if the engine should avoid generating the mip levels
  33039. * @param callback defines a callback used to extract texture data from loaded data
  33040. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  33041. * @param onLoad defines a callback called when texture is loaded
  33042. * @param onError defines a callback called if there is an error
  33043. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33044. * @param invertY defines if data must be stored with Y axis inverted
  33045. * @returns the cube texture as an InternalTexture
  33046. */
  33047. Engine.prototype.createRawCubeTextureFromUrl = function (url, scene, size, format, type, noMipmap, callback, mipmapGenerator, onLoad, onError, samplingMode, invertY) {
  33048. var _this = this;
  33049. if (onLoad === void 0) { onLoad = null; }
  33050. if (onError === void 0) { onError = null; }
  33051. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  33052. if (invertY === void 0) { invertY = false; }
  33053. var gl = this._gl;
  33054. var texture = this.createRawCubeTexture(null, size, format, type, !noMipmap, invertY, samplingMode);
  33055. scene._addPendingData(texture);
  33056. texture.url = url;
  33057. this._internalTexturesCache.push(texture);
  33058. var onerror = function (request, exception) {
  33059. scene._removePendingData(texture);
  33060. if (onError && request) {
  33061. onError(request.status + " " + request.statusText, exception);
  33062. }
  33063. };
  33064. var internalCallback = function (data) {
  33065. var width = texture.width;
  33066. var faceDataArrays = callback(data);
  33067. if (!faceDataArrays) {
  33068. return;
  33069. }
  33070. if (mipmapGenerator) {
  33071. var textureType = _this._getWebGLTextureType(type);
  33072. var internalFormat = _this._getInternalFormat(format);
  33073. var internalSizedFomat = _this._getRGBABufferInternalSizedFormat(type);
  33074. var needConversion = false;
  33075. if (internalFormat === gl.RGB) {
  33076. internalFormat = gl.RGBA;
  33077. needConversion = true;
  33078. }
  33079. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  33080. _this._unpackFlipY(false);
  33081. var mipData = mipmapGenerator(faceDataArrays);
  33082. for (var level = 0; level < mipData.length; level++) {
  33083. var mipSize = width >> level;
  33084. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  33085. var mipFaceData = mipData[level][faceIndex];
  33086. if (needConversion) {
  33087. mipFaceData = _this._convertRGBtoRGBATextureData(mipFaceData, mipSize, mipSize, type);
  33088. }
  33089. gl.texImage2D(faceIndex, level, internalSizedFomat, mipSize, mipSize, 0, internalFormat, textureType, mipFaceData);
  33090. }
  33091. }
  33092. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  33093. }
  33094. else {
  33095. _this.updateRawCubeTexture(texture, faceDataArrays, format, type, invertY);
  33096. }
  33097. texture.isReady = true;
  33098. // this.resetTextureCache();
  33099. scene._removePendingData(texture);
  33100. if (onLoad) {
  33101. onLoad();
  33102. }
  33103. };
  33104. this._loadFile(url, function (data) {
  33105. internalCallback(data);
  33106. }, undefined, scene.offlineProvider, true, onerror);
  33107. return texture;
  33108. };
  33109. /**
  33110. * Update a raw 3D texture
  33111. * @param texture defines the texture to update
  33112. * @param data defines the data to store
  33113. * @param format defines the data format
  33114. * @param invertY defines if data must be stored with Y axis inverted
  33115. * @param compression defines the used compression (can be null)
  33116. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  33117. */
  33118. Engine.prototype.updateRawTexture3D = function (texture, data, format, invertY, compression, textureType) {
  33119. if (compression === void 0) { compression = null; }
  33120. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  33121. var internalType = this._getWebGLTextureType(textureType);
  33122. var internalFormat = this._getInternalFormat(format);
  33123. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(textureType, format);
  33124. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  33125. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  33126. if (!this._doNotHandleContextLost) {
  33127. texture._bufferView = data;
  33128. texture.format = format;
  33129. texture.invertY = invertY;
  33130. texture._compression = compression;
  33131. }
  33132. if (texture.width % 4 !== 0) {
  33133. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  33134. }
  33135. if (compression && data) {
  33136. this._gl.compressedTexImage3D(this._gl.TEXTURE_3D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, texture.depth, 0, data);
  33137. }
  33138. else {
  33139. this._gl.texImage3D(this._gl.TEXTURE_3D, 0, internalSizedFomat, texture.width, texture.height, texture.depth, 0, internalFormat, internalType, data);
  33140. }
  33141. if (texture.generateMipMaps) {
  33142. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  33143. }
  33144. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33145. // this.resetTextureCache();
  33146. texture.isReady = true;
  33147. };
  33148. /**
  33149. * Creates a new raw 3D texture
  33150. * @param data defines the data used to create the texture
  33151. * @param width defines the width of the texture
  33152. * @param height defines the height of the texture
  33153. * @param depth defines the depth of the texture
  33154. * @param format defines the format of the texture
  33155. * @param generateMipMaps defines if the engine must generate mip levels
  33156. * @param invertY defines if data must be stored with Y axis inverted
  33157. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33158. * @param compression defines the compressed used (can be null)
  33159. * @param textureType defines the compressed used (can be null)
  33160. * @returns a new raw 3D texture (stored in an InternalTexture)
  33161. */
  33162. Engine.prototype.createRawTexture3D = function (data, width, height, depth, format, generateMipMaps, invertY, samplingMode, compression, textureType) {
  33163. if (compression === void 0) { compression = null; }
  33164. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  33165. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW3D);
  33166. texture.baseWidth = width;
  33167. texture.baseHeight = height;
  33168. texture.baseDepth = depth;
  33169. texture.width = width;
  33170. texture.height = height;
  33171. texture.depth = depth;
  33172. texture.format = format;
  33173. texture.type = textureType;
  33174. texture.generateMipMaps = generateMipMaps;
  33175. texture.samplingMode = samplingMode;
  33176. texture.is3D = true;
  33177. if (!this._doNotHandleContextLost) {
  33178. texture._bufferView = data;
  33179. }
  33180. this.updateRawTexture3D(texture, data, format, invertY, compression, textureType);
  33181. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  33182. // Filters
  33183. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  33184. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  33185. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  33186. if (generateMipMaps) {
  33187. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  33188. }
  33189. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33190. this._internalTexturesCache.push(texture);
  33191. return texture;
  33192. };
  33193. Engine.prototype._prepareWebGLTextureContinuation = function (texture, scene, noMipmap, isCompressed, samplingMode) {
  33194. var gl = this._gl;
  33195. if (!gl) {
  33196. return;
  33197. }
  33198. var filters = this._getSamplingParameters(samplingMode, !noMipmap);
  33199. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  33200. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  33201. if (!noMipmap && !isCompressed) {
  33202. gl.generateMipmap(gl.TEXTURE_2D);
  33203. }
  33204. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  33205. // this.resetTextureCache();
  33206. if (scene) {
  33207. scene._removePendingData(texture);
  33208. }
  33209. texture.onLoadedObservable.notifyObservers(texture);
  33210. texture.onLoadedObservable.clear();
  33211. };
  33212. Engine.prototype._prepareWebGLTexture = function (texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode) {
  33213. var _this = this;
  33214. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  33215. var maxTextureSize = this.getCaps().maxTextureSize;
  33216. var potWidth = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, maxTextureSize) : width);
  33217. var potHeight = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, maxTextureSize) : height);
  33218. var gl = this._gl;
  33219. if (!gl) {
  33220. return;
  33221. }
  33222. if (!texture._webGLTexture) {
  33223. // this.resetTextureCache();
  33224. if (scene) {
  33225. scene._removePendingData(texture);
  33226. }
  33227. return;
  33228. }
  33229. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  33230. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  33231. texture.baseWidth = width;
  33232. texture.baseHeight = height;
  33233. texture.width = potWidth;
  33234. texture.height = potHeight;
  33235. texture.isReady = true;
  33236. if (processFunction(potWidth, potHeight, function () {
  33237. _this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  33238. })) {
  33239. // Returning as texture needs extra async steps
  33240. return;
  33241. }
  33242. this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  33243. };
  33244. Engine.prototype._convertRGBtoRGBATextureData = function (rgbData, width, height, textureType) {
  33245. // Create new RGBA data container.
  33246. var rgbaData;
  33247. if (textureType === Engine.TEXTURETYPE_FLOAT) {
  33248. rgbaData = new Float32Array(width * height * 4);
  33249. }
  33250. else {
  33251. rgbaData = new Uint32Array(width * height * 4);
  33252. }
  33253. // Convert each pixel.
  33254. for (var x = 0; x < width; x++) {
  33255. for (var y = 0; y < height; y++) {
  33256. var index = (y * width + x) * 3;
  33257. var newIndex = (y * width + x) * 4;
  33258. // Map Old Value to new value.
  33259. rgbaData[newIndex + 0] = rgbData[index + 0];
  33260. rgbaData[newIndex + 1] = rgbData[index + 1];
  33261. rgbaData[newIndex + 2] = rgbData[index + 2];
  33262. // Add fully opaque alpha channel.
  33263. rgbaData[newIndex + 3] = 1;
  33264. }
  33265. }
  33266. return rgbaData;
  33267. };
  33268. /** @hidden */
  33269. Engine.prototype._releaseFramebufferObjects = function (texture) {
  33270. var gl = this._gl;
  33271. if (texture._framebuffer) {
  33272. gl.deleteFramebuffer(texture._framebuffer);
  33273. texture._framebuffer = null;
  33274. }
  33275. if (texture._depthStencilBuffer) {
  33276. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  33277. texture._depthStencilBuffer = null;
  33278. }
  33279. if (texture._MSAAFramebuffer) {
  33280. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  33281. texture._MSAAFramebuffer = null;
  33282. }
  33283. if (texture._MSAARenderBuffer) {
  33284. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  33285. texture._MSAARenderBuffer = null;
  33286. }
  33287. };
  33288. /** @hidden */
  33289. Engine.prototype._releaseTexture = function (texture) {
  33290. var gl = this._gl;
  33291. this._releaseFramebufferObjects(texture);
  33292. gl.deleteTexture(texture._webGLTexture);
  33293. // Unbind channels
  33294. this.unbindAllTextures();
  33295. var index = this._internalTexturesCache.indexOf(texture);
  33296. if (index !== -1) {
  33297. this._internalTexturesCache.splice(index, 1);
  33298. }
  33299. // Integrated fixed lod samplers.
  33300. if (texture._lodTextureHigh) {
  33301. texture._lodTextureHigh.dispose();
  33302. }
  33303. if (texture._lodTextureMid) {
  33304. texture._lodTextureMid.dispose();
  33305. }
  33306. if (texture._lodTextureLow) {
  33307. texture._lodTextureLow.dispose();
  33308. }
  33309. // Set output texture of post process to null if the texture has been released/disposed
  33310. this.scenes.forEach(function (scene) {
  33311. scene.postProcesses.forEach(function (postProcess) {
  33312. if (postProcess._outputTexture == texture) {
  33313. postProcess._outputTexture = null;
  33314. }
  33315. });
  33316. scene.cameras.forEach(function (camera) {
  33317. camera._postProcesses.forEach(function (postProcess) {
  33318. if (postProcess) {
  33319. if (postProcess._outputTexture == texture) {
  33320. postProcess._outputTexture = null;
  33321. }
  33322. }
  33323. });
  33324. });
  33325. });
  33326. };
  33327. Engine.prototype.setProgram = function (program) {
  33328. if (this._currentProgram !== program) {
  33329. this._gl.useProgram(program);
  33330. this._currentProgram = program;
  33331. }
  33332. };
  33333. /**
  33334. * Binds an effect to the webGL context
  33335. * @param effect defines the effect to bind
  33336. */
  33337. Engine.prototype.bindSamplers = function (effect) {
  33338. this.setProgram(effect.getProgram());
  33339. var samplers = effect.getSamplers();
  33340. for (var index = 0; index < samplers.length; index++) {
  33341. var uniform = effect.getUniform(samplers[index]);
  33342. if (uniform) {
  33343. this._boundUniforms[index] = uniform;
  33344. }
  33345. }
  33346. this._currentEffect = null;
  33347. };
  33348. Engine.prototype._moveBoundTextureOnTop = function (internalTexture) {
  33349. if (this.disableTextureBindingOptimization || this._lastBoundInternalTextureTracker.previous === internalTexture) {
  33350. return;
  33351. }
  33352. // Remove
  33353. this._linkTrackers(internalTexture.previous, internalTexture.next);
  33354. // Bind last to it
  33355. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, internalTexture);
  33356. // Bind to dummy
  33357. this._linkTrackers(internalTexture, this._lastBoundInternalTextureTracker);
  33358. };
  33359. Engine.prototype._getCorrectTextureChannel = function (channel, internalTexture) {
  33360. if (!internalTexture) {
  33361. return -1;
  33362. }
  33363. internalTexture._initialSlot = channel;
  33364. if (this.disableTextureBindingOptimization) { // We want texture sampler ID === texture channel
  33365. if (channel !== internalTexture._designatedSlot) {
  33366. this._textureCollisions.addCount(1, false);
  33367. }
  33368. }
  33369. else {
  33370. if (channel !== internalTexture._designatedSlot) {
  33371. if (internalTexture._designatedSlot > -1) { // Texture is already assigned to a slot
  33372. return internalTexture._designatedSlot;
  33373. }
  33374. else {
  33375. // No slot for this texture, let's pick a new one (if we find a free slot)
  33376. if (this._nextFreeTextureSlots.length) {
  33377. return this._nextFreeTextureSlots[0];
  33378. }
  33379. // We need to recycle the oldest bound texture, sorry.
  33380. this._textureCollisions.addCount(1, false);
  33381. return this._removeDesignatedSlot(this._firstBoundInternalTextureTracker.next);
  33382. }
  33383. }
  33384. }
  33385. return channel;
  33386. };
  33387. Engine.prototype._linkTrackers = function (previous, next) {
  33388. previous.next = next;
  33389. next.previous = previous;
  33390. };
  33391. Engine.prototype._removeDesignatedSlot = function (internalTexture) {
  33392. var currentSlot = internalTexture._designatedSlot;
  33393. if (currentSlot === -1) {
  33394. return -1;
  33395. }
  33396. internalTexture._designatedSlot = -1;
  33397. if (this.disableTextureBindingOptimization) {
  33398. return -1;
  33399. }
  33400. // Remove from bound list
  33401. this._linkTrackers(internalTexture.previous, internalTexture.next);
  33402. // Free the slot
  33403. this._boundTexturesCache[currentSlot] = null;
  33404. this._nextFreeTextureSlots.push(currentSlot);
  33405. return currentSlot;
  33406. };
  33407. Engine.prototype._activateCurrentTexture = function () {
  33408. if (this._currentTextureChannel !== this._activeChannel) {
  33409. this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel);
  33410. this._currentTextureChannel = this._activeChannel;
  33411. }
  33412. };
  33413. /** @hidden */
  33414. Engine.prototype._bindTextureDirectly = function (target, texture, forTextureDataUpdate, force) {
  33415. if (forTextureDataUpdate === void 0) { forTextureDataUpdate = false; }
  33416. if (force === void 0) { force = false; }
  33417. var wasPreviouslyBound = false;
  33418. if (forTextureDataUpdate && texture && texture._designatedSlot > -1) {
  33419. this._activeChannel = texture._designatedSlot;
  33420. }
  33421. var currentTextureBound = this._boundTexturesCache[this._activeChannel];
  33422. var isTextureForRendering = texture && texture._initialSlot > -1;
  33423. if (currentTextureBound !== texture || force) {
  33424. if (currentTextureBound) {
  33425. this._removeDesignatedSlot(currentTextureBound);
  33426. }
  33427. this._activateCurrentTexture();
  33428. if (texture && texture.isMultiview) {
  33429. this._gl.bindTexture(target, texture ? texture._colorTextureArray : null);
  33430. }
  33431. else {
  33432. this._gl.bindTexture(target, texture ? texture._webGLTexture : null);
  33433. }
  33434. this._boundTexturesCache[this._activeChannel] = texture;
  33435. if (texture) {
  33436. if (!this.disableTextureBindingOptimization) {
  33437. var slotIndex = this._nextFreeTextureSlots.indexOf(this._activeChannel);
  33438. if (slotIndex > -1) {
  33439. this._nextFreeTextureSlots.splice(slotIndex, 1);
  33440. }
  33441. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, texture);
  33442. this._linkTrackers(texture, this._lastBoundInternalTextureTracker);
  33443. }
  33444. texture._designatedSlot = this._activeChannel;
  33445. }
  33446. }
  33447. else if (forTextureDataUpdate) {
  33448. wasPreviouslyBound = true;
  33449. this._activateCurrentTexture();
  33450. }
  33451. if (isTextureForRendering && !forTextureDataUpdate) {
  33452. this._bindSamplerUniformToChannel(texture._initialSlot, this._activeChannel);
  33453. }
  33454. return wasPreviouslyBound;
  33455. };
  33456. /** @hidden */
  33457. Engine.prototype._bindTexture = function (channel, texture) {
  33458. if (channel < 0) {
  33459. return;
  33460. }
  33461. if (texture) {
  33462. channel = this._getCorrectTextureChannel(channel, texture);
  33463. }
  33464. this._activeChannel = channel;
  33465. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
  33466. };
  33467. /**
  33468. * Sets a texture to the webGL context from a postprocess
  33469. * @param channel defines the channel to use
  33470. * @param postProcess defines the source postprocess
  33471. */
  33472. Engine.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  33473. this._bindTexture(channel, postProcess ? postProcess._textures.data[postProcess._currentRenderTextureInd] : null);
  33474. };
  33475. /**
  33476. * Binds the output of the passed in post process to the texture channel specified
  33477. * @param channel The channel the texture should be bound to
  33478. * @param postProcess The post process which's output should be bound
  33479. */
  33480. Engine.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  33481. this._bindTexture(channel, postProcess ? postProcess._outputTexture : null);
  33482. };
  33483. /**
  33484. * Unbind all textures from the webGL context
  33485. */
  33486. Engine.prototype.unbindAllTextures = function () {
  33487. for (var channel = 0; channel < this._maxSimultaneousTextures; channel++) {
  33488. this._activeChannel = channel;
  33489. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  33490. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  33491. if (this.webGLVersion > 1) {
  33492. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33493. }
  33494. }
  33495. };
  33496. /**
  33497. * Sets a texture to the according uniform.
  33498. * @param channel The texture channel
  33499. * @param uniform The uniform to set
  33500. * @param texture The texture to apply
  33501. */
  33502. Engine.prototype.setTexture = function (channel, uniform, texture) {
  33503. if (channel < 0) {
  33504. return;
  33505. }
  33506. if (uniform) {
  33507. this._boundUniforms[channel] = uniform;
  33508. }
  33509. this._setTexture(channel, texture);
  33510. };
  33511. /**
  33512. * Sets a depth stencil texture from a render target to the according uniform.
  33513. * @param channel The texture channel
  33514. * @param uniform The uniform to set
  33515. * @param texture The render target texture containing the depth stencil texture to apply
  33516. */
  33517. Engine.prototype.setDepthStencilTexture = function (channel, uniform, texture) {
  33518. if (channel < 0) {
  33519. return;
  33520. }
  33521. if (uniform) {
  33522. this._boundUniforms[channel] = uniform;
  33523. }
  33524. if (!texture || !texture.depthStencilTexture) {
  33525. this._setTexture(channel, null);
  33526. }
  33527. else {
  33528. this._setTexture(channel, texture, false, true);
  33529. }
  33530. };
  33531. Engine.prototype._bindSamplerUniformToChannel = function (sourceSlot, destination) {
  33532. var uniform = this._boundUniforms[sourceSlot];
  33533. if (uniform._currentState === destination) {
  33534. return;
  33535. }
  33536. this._gl.uniform1i(uniform, destination);
  33537. uniform._currentState = destination;
  33538. };
  33539. Engine.prototype._getTextureWrapMode = function (mode) {
  33540. switch (mode) {
  33541. case Engine.TEXTURE_WRAP_ADDRESSMODE:
  33542. return this._gl.REPEAT;
  33543. case Engine.TEXTURE_CLAMP_ADDRESSMODE:
  33544. return this._gl.CLAMP_TO_EDGE;
  33545. case Engine.TEXTURE_MIRROR_ADDRESSMODE:
  33546. return this._gl.MIRRORED_REPEAT;
  33547. }
  33548. return this._gl.REPEAT;
  33549. };
  33550. Engine.prototype._setTexture = function (channel, texture, isPartOfTextureArray, depthStencilTexture) {
  33551. if (isPartOfTextureArray === void 0) { isPartOfTextureArray = false; }
  33552. if (depthStencilTexture === void 0) { depthStencilTexture = false; }
  33553. // Not ready?
  33554. if (!texture) {
  33555. if (this._boundTexturesCache[channel] != null) {
  33556. this._activeChannel = channel;
  33557. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  33558. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  33559. if (this.webGLVersion > 1) {
  33560. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33561. }
  33562. }
  33563. return false;
  33564. }
  33565. // Video
  33566. if (texture.video) {
  33567. this._activeChannel = channel;
  33568. texture.update();
  33569. }
  33570. else if (texture.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) { // Delay loading
  33571. texture.delayLoad();
  33572. return false;
  33573. }
  33574. var internalTexture;
  33575. if (depthStencilTexture) {
  33576. internalTexture = texture.depthStencilTexture;
  33577. }
  33578. else if (texture.isReady()) {
  33579. internalTexture = texture.getInternalTexture();
  33580. }
  33581. else if (texture.isCube) {
  33582. internalTexture = this.emptyCubeTexture;
  33583. }
  33584. else if (texture.is3D) {
  33585. internalTexture = this.emptyTexture3D;
  33586. }
  33587. else {
  33588. internalTexture = this.emptyTexture;
  33589. }
  33590. if (!isPartOfTextureArray) {
  33591. channel = this._getCorrectTextureChannel(channel, internalTexture);
  33592. }
  33593. var needToBind = true;
  33594. if (this._boundTexturesCache[channel] === internalTexture) {
  33595. this._moveBoundTextureOnTop(internalTexture);
  33596. if (!isPartOfTextureArray) {
  33597. this._bindSamplerUniformToChannel(internalTexture._initialSlot, channel);
  33598. }
  33599. needToBind = false;
  33600. }
  33601. this._activeChannel = channel;
  33602. if (internalTexture && internalTexture.isMultiview) {
  33603. if (needToBind) {
  33604. this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY, internalTexture, isPartOfTextureArray);
  33605. }
  33606. }
  33607. else if (internalTexture && internalTexture.is3D) {
  33608. if (needToBind) {
  33609. this._bindTextureDirectly(this._gl.TEXTURE_3D, internalTexture, isPartOfTextureArray);
  33610. }
  33611. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  33612. internalTexture._cachedWrapU = texture.wrapU;
  33613. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  33614. }
  33615. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  33616. internalTexture._cachedWrapV = texture.wrapV;
  33617. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  33618. }
  33619. if (internalTexture && internalTexture._cachedWrapR !== texture.wrapR) {
  33620. internalTexture._cachedWrapR = texture.wrapR;
  33621. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(texture.wrapR), internalTexture);
  33622. }
  33623. this._setAnisotropicLevel(this._gl.TEXTURE_3D, texture);
  33624. }
  33625. else if (internalTexture && internalTexture.isCube) {
  33626. if (needToBind) {
  33627. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, internalTexture, isPartOfTextureArray);
  33628. }
  33629. if (internalTexture._cachedCoordinatesMode !== texture.coordinatesMode) {
  33630. internalTexture._cachedCoordinatesMode = texture.coordinatesMode;
  33631. // CUBIC_MODE and SKYBOX_MODE both require CLAMP_TO_EDGE. All other modes use REPEAT.
  33632. var textureWrapMode = (texture.coordinatesMode !== Engine.TEXTURE_CUBIC_MODE && texture.coordinatesMode !== Engine.TEXTURE_SKYBOX_MODE) ? this._gl.REPEAT : this._gl.CLAMP_TO_EDGE;
  33633. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_S, textureWrapMode, internalTexture);
  33634. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_T, textureWrapMode);
  33635. }
  33636. this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP, texture);
  33637. }
  33638. else {
  33639. if (needToBind) {
  33640. this._bindTextureDirectly(this._gl.TEXTURE_2D, internalTexture, isPartOfTextureArray);
  33641. }
  33642. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  33643. internalTexture._cachedWrapU = texture.wrapU;
  33644. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  33645. }
  33646. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  33647. internalTexture._cachedWrapV = texture.wrapV;
  33648. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  33649. }
  33650. this._setAnisotropicLevel(this._gl.TEXTURE_2D, texture);
  33651. }
  33652. return true;
  33653. };
  33654. /**
  33655. * Sets an array of texture to the webGL context
  33656. * @param channel defines the channel where the texture array must be set
  33657. * @param uniform defines the associated uniform location
  33658. * @param textures defines the array of textures to bind
  33659. */
  33660. Engine.prototype.setTextureArray = function (channel, uniform, textures) {
  33661. if (channel < 0 || !uniform) {
  33662. return;
  33663. }
  33664. if (!this._textureUnits || this._textureUnits.length !== textures.length) {
  33665. this._textureUnits = new Int32Array(textures.length);
  33666. }
  33667. for (var i = 0; i < textures.length; i++) {
  33668. this._textureUnits[i] = this._getCorrectTextureChannel(channel + i, textures[i].getInternalTexture());
  33669. }
  33670. this._gl.uniform1iv(uniform, this._textureUnits);
  33671. for (var index = 0; index < textures.length; index++) {
  33672. this._setTexture(this._textureUnits[index], textures[index], true);
  33673. }
  33674. };
  33675. /** @hidden */
  33676. Engine.prototype._setAnisotropicLevel = function (target, texture) {
  33677. var internalTexture = texture.getInternalTexture();
  33678. if (!internalTexture) {
  33679. return;
  33680. }
  33681. var anisotropicFilterExtension = this._caps.textureAnisotropicFilterExtension;
  33682. var value = texture.anisotropicFilteringLevel;
  33683. if (internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST
  33684. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR
  33685. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR) {
  33686. value = 1; // Forcing the anisotropic to 1 because else webgl will force filters to linear
  33687. }
  33688. if (anisotropicFilterExtension && internalTexture._cachedAnisotropicFilteringLevel !== value) {
  33689. this._setTextureParameterFloat(target, anisotropicFilterExtension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(value, this._caps.maxAnisotropy), internalTexture);
  33690. internalTexture._cachedAnisotropicFilteringLevel = value;
  33691. }
  33692. };
  33693. Engine.prototype._setTextureParameterFloat = function (target, parameter, value, texture) {
  33694. this._bindTextureDirectly(target, texture, true, true);
  33695. this._gl.texParameterf(target, parameter, value);
  33696. };
  33697. Engine.prototype._setTextureParameterInteger = function (target, parameter, value, texture) {
  33698. if (texture) {
  33699. this._bindTextureDirectly(target, texture, true, true);
  33700. }
  33701. this._gl.texParameteri(target, parameter, value);
  33702. };
  33703. /**
  33704. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33705. * @param x defines the x coordinate of the rectangle where pixels must be read
  33706. * @param y defines the y coordinate of the rectangle where pixels must be read
  33707. * @param width defines the width of the rectangle where pixels must be read
  33708. * @param height defines the height of the rectangle where pixels must be read
  33709. * @returns a Uint8Array containing RGBA colors
  33710. */
  33711. Engine.prototype.readPixels = function (x, y, width, height) {
  33712. var data = new Uint8Array(height * width * 4);
  33713. this._gl.readPixels(x, y, width, height, this._gl.RGBA, this._gl.UNSIGNED_BYTE, data);
  33714. return data;
  33715. };
  33716. /**
  33717. * Add an externaly attached data from its key.
  33718. * This method call will fail and return false, if such key already exists.
  33719. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33720. * @param key the unique key that identifies the data
  33721. * @param data the data object to associate to the key for this Engine instance
  33722. * @return true if no such key were already present and the data was added successfully, false otherwise
  33723. */
  33724. Engine.prototype.addExternalData = function (key, data) {
  33725. if (!this._externalData) {
  33726. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33727. }
  33728. return this._externalData.add(key, data);
  33729. };
  33730. /**
  33731. * Get an externaly attached data from its key
  33732. * @param key the unique key that identifies the data
  33733. * @return the associated data, if present (can be null), or undefined if not present
  33734. */
  33735. Engine.prototype.getExternalData = function (key) {
  33736. if (!this._externalData) {
  33737. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33738. }
  33739. return this._externalData.get(key);
  33740. };
  33741. /**
  33742. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33743. * @param key the unique key that identifies the data
  33744. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33745. * @return the associated data, can be null if the factory returned null.
  33746. */
  33747. Engine.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  33748. if (!this._externalData) {
  33749. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33750. }
  33751. return this._externalData.getOrAddWithFactory(key, factory);
  33752. };
  33753. /**
  33754. * Remove an externaly attached data from the Engine instance
  33755. * @param key the unique key that identifies the data
  33756. * @return true if the data was successfully removed, false if it doesn't exist
  33757. */
  33758. Engine.prototype.removeExternalData = function (key) {
  33759. if (!this._externalData) {
  33760. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33761. }
  33762. return this._externalData.remove(key);
  33763. };
  33764. /**
  33765. * Unbind all vertex attributes from the webGL context
  33766. */
  33767. Engine.prototype.unbindAllAttributes = function () {
  33768. if (this._mustWipeVertexAttributes) {
  33769. this._mustWipeVertexAttributes = false;
  33770. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  33771. this._gl.disableVertexAttribArray(i);
  33772. this._vertexAttribArraysEnabled[i] = false;
  33773. this._currentBufferPointers[i].active = false;
  33774. }
  33775. return;
  33776. }
  33777. for (var i = 0, ul = this._vertexAttribArraysEnabled.length; i < ul; i++) {
  33778. if (i >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[i]) {
  33779. continue;
  33780. }
  33781. this._gl.disableVertexAttribArray(i);
  33782. this._vertexAttribArraysEnabled[i] = false;
  33783. this._currentBufferPointers[i].active = false;
  33784. }
  33785. };
  33786. /**
  33787. * 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
  33788. */
  33789. Engine.prototype.releaseEffects = function () {
  33790. for (var name in this._compiledEffects) {
  33791. this._deleteProgram(this._compiledEffects[name]._program);
  33792. }
  33793. this._compiledEffects = {};
  33794. };
  33795. /**
  33796. * Dispose and release all associated resources
  33797. */
  33798. Engine.prototype.dispose = function () {
  33799. this.hideLoadingUI();
  33800. this.stopRenderLoop();
  33801. this.onNewSceneAddedObservable.clear();
  33802. // Release postProcesses
  33803. while (this.postProcesses.length) {
  33804. this.postProcesses[0].dispose();
  33805. }
  33806. // Empty texture
  33807. if (this._emptyTexture) {
  33808. this._releaseTexture(this._emptyTexture);
  33809. this._emptyTexture = null;
  33810. }
  33811. if (this._emptyCubeTexture) {
  33812. this._releaseTexture(this._emptyCubeTexture);
  33813. this._emptyCubeTexture = null;
  33814. }
  33815. // Rescale PP
  33816. if (this._rescalePostProcess) {
  33817. this._rescalePostProcess.dispose();
  33818. }
  33819. // Release scenes
  33820. while (this.scenes.length) {
  33821. this.scenes[0].dispose();
  33822. }
  33823. // Release audio engine
  33824. if (Engine.Instances.length === 1 && Engine.audioEngine) {
  33825. Engine.audioEngine.dispose();
  33826. }
  33827. // Release effects
  33828. this.releaseEffects();
  33829. // Unbind
  33830. this.unbindAllAttributes();
  33831. this._boundUniforms = [];
  33832. if (this._dummyFramebuffer) {
  33833. this._gl.deleteFramebuffer(this._dummyFramebuffer);
  33834. }
  33835. //WebVR
  33836. this.disableVR();
  33837. // Events
  33838. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  33839. window.removeEventListener("blur", this._onBlur);
  33840. window.removeEventListener("focus", this._onFocus);
  33841. window.removeEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted);
  33842. window.removeEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted);
  33843. if (this._renderingCanvas) {
  33844. this._renderingCanvas.removeEventListener("focus", this._onCanvasFocus);
  33845. this._renderingCanvas.removeEventListener("blur", this._onCanvasBlur);
  33846. this._renderingCanvas.removeEventListener("pointerout", this._onCanvasPointerOut);
  33847. if (!this._doNotHandleContextLost) {
  33848. this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost);
  33849. this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored);
  33850. }
  33851. }
  33852. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  33853. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  33854. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  33855. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  33856. document.removeEventListener("pointerlockchange", this._onPointerLockChange);
  33857. document.removeEventListener("mspointerlockchange", this._onPointerLockChange);
  33858. document.removeEventListener("mozpointerlockchange", this._onPointerLockChange);
  33859. document.removeEventListener("webkitpointerlockchange", this._onPointerLockChange);
  33860. if (this._onVrDisplayConnect) {
  33861. window.removeEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  33862. if (this._onVrDisplayDisconnect) {
  33863. window.removeEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  33864. }
  33865. if (this._onVrDisplayPresentChange) {
  33866. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  33867. }
  33868. this._onVrDisplayConnect = null;
  33869. this._onVrDisplayDisconnect = null;
  33870. }
  33871. }
  33872. // Remove from Instances
  33873. var index = Engine.Instances.indexOf(this);
  33874. if (index >= 0) {
  33875. Engine.Instances.splice(index, 1);
  33876. }
  33877. this._workingCanvas = null;
  33878. this._workingContext = null;
  33879. this._currentBufferPointers = [];
  33880. this._renderingCanvas = null;
  33881. this._currentProgram = null;
  33882. this._bindedRenderFunction = null;
  33883. this.onResizeObservable.clear();
  33884. this.onCanvasBlurObservable.clear();
  33885. this.onCanvasFocusObservable.clear();
  33886. this.onCanvasPointerOutObservable.clear();
  33887. this.onBeginFrameObservable.clear();
  33888. this.onEndFrameObservable.clear();
  33889. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  33890. // Abort active requests
  33891. for (var _i = 0, _a = this._activeRequests; _i < _a.length; _i++) {
  33892. var request = _a[_i];
  33893. request.abort();
  33894. }
  33895. };
  33896. // Loading screen
  33897. /**
  33898. * Display the loading screen
  33899. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33900. */
  33901. Engine.prototype.displayLoadingUI = function () {
  33902. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  33903. return;
  33904. }
  33905. var loadingScreen = this.loadingScreen;
  33906. if (loadingScreen) {
  33907. loadingScreen.displayLoadingUI();
  33908. }
  33909. };
  33910. /**
  33911. * Hide the loading screen
  33912. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33913. */
  33914. Engine.prototype.hideLoadingUI = function () {
  33915. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  33916. return;
  33917. }
  33918. var loadingScreen = this.loadingScreen;
  33919. if (loadingScreen) {
  33920. loadingScreen.hideLoadingUI();
  33921. }
  33922. };
  33923. Object.defineProperty(Engine.prototype, "loadingScreen", {
  33924. /**
  33925. * Gets the current loading screen object
  33926. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33927. */
  33928. get: function () {
  33929. if (!this._loadingScreen && this._renderingCanvas) {
  33930. this._loadingScreen = Engine.DefaultLoadingScreenFactory(this._renderingCanvas);
  33931. }
  33932. return this._loadingScreen;
  33933. },
  33934. /**
  33935. * Sets the current loading screen object
  33936. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33937. */
  33938. set: function (loadingScreen) {
  33939. this._loadingScreen = loadingScreen;
  33940. },
  33941. enumerable: true,
  33942. configurable: true
  33943. });
  33944. Object.defineProperty(Engine.prototype, "loadingUIText", {
  33945. /**
  33946. * Sets the current loading screen text
  33947. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33948. */
  33949. set: function (text) {
  33950. this.loadingScreen.loadingUIText = text;
  33951. },
  33952. enumerable: true,
  33953. configurable: true
  33954. });
  33955. Object.defineProperty(Engine.prototype, "loadingUIBackgroundColor", {
  33956. /**
  33957. * Sets the current loading screen background color
  33958. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33959. */
  33960. set: function (color) {
  33961. this.loadingScreen.loadingUIBackgroundColor = color;
  33962. },
  33963. enumerable: true,
  33964. configurable: true
  33965. });
  33966. /**
  33967. * Attach a new callback raised when context lost event is fired
  33968. * @param callback defines the callback to call
  33969. */
  33970. Engine.prototype.attachContextLostEvent = function (callback) {
  33971. if (this._renderingCanvas) {
  33972. this._renderingCanvas.addEventListener("webglcontextlost", callback, false);
  33973. }
  33974. };
  33975. /**
  33976. * Attach a new callback raised when context restored event is fired
  33977. * @param callback defines the callback to call
  33978. */
  33979. Engine.prototype.attachContextRestoredEvent = function (callback) {
  33980. if (this._renderingCanvas) {
  33981. this._renderingCanvas.addEventListener("webglcontextrestored", callback, false);
  33982. }
  33983. };
  33984. /**
  33985. * Gets the source code of the vertex shader associated with a specific webGL program
  33986. * @param program defines the program to use
  33987. * @returns a string containing the source code of the vertex shader associated with the program
  33988. */
  33989. Engine.prototype.getVertexShaderSource = function (program) {
  33990. var shaders = this._gl.getAttachedShaders(program);
  33991. if (!shaders) {
  33992. return null;
  33993. }
  33994. return this._gl.getShaderSource(shaders[0]);
  33995. };
  33996. /**
  33997. * Gets the source code of the fragment shader associated with a specific webGL program
  33998. * @param program defines the program to use
  33999. * @returns a string containing the source code of the fragment shader associated with the program
  34000. */
  34001. Engine.prototype.getFragmentShaderSource = function (program) {
  34002. var shaders = this._gl.getAttachedShaders(program);
  34003. if (!shaders) {
  34004. return null;
  34005. }
  34006. return this._gl.getShaderSource(shaders[1]);
  34007. };
  34008. /**
  34009. * Get the current error code of the webGL context
  34010. * @returns the error code
  34011. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  34012. */
  34013. Engine.prototype.getError = function () {
  34014. return this._gl.getError();
  34015. };
  34016. // FPS
  34017. /**
  34018. * Gets the current framerate
  34019. * @returns a number representing the framerate
  34020. */
  34021. Engine.prototype.getFps = function () {
  34022. return this._fps;
  34023. };
  34024. /**
  34025. * Gets the time spent between current and previous frame
  34026. * @returns a number representing the delta time in ms
  34027. */
  34028. Engine.prototype.getDeltaTime = function () {
  34029. return this._deltaTime;
  34030. };
  34031. Engine.prototype._measureFps = function () {
  34032. this._performanceMonitor.sampleFrame();
  34033. this._fps = this._performanceMonitor.averageFPS;
  34034. this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0;
  34035. };
  34036. /** @hidden */
  34037. Engine.prototype._readTexturePixels = function (texture, width, height, faceIndex, level, buffer) {
  34038. if (faceIndex === void 0) { faceIndex = -1; }
  34039. if (level === void 0) { level = 0; }
  34040. if (buffer === void 0) { buffer = null; }
  34041. var gl = this._gl;
  34042. if (!this._dummyFramebuffer) {
  34043. var dummy = gl.createFramebuffer();
  34044. if (!dummy) {
  34045. throw new Error("Unable to create dummy framebuffer");
  34046. }
  34047. this._dummyFramebuffer = dummy;
  34048. }
  34049. gl.bindFramebuffer(gl.FRAMEBUFFER, this._dummyFramebuffer);
  34050. if (faceIndex > -1) {
  34051. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, level);
  34052. }
  34053. else {
  34054. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, level);
  34055. }
  34056. var readType = (texture.type !== undefined) ? this._getWebGLTextureType(texture.type) : gl.UNSIGNED_BYTE;
  34057. switch (readType) {
  34058. case gl.UNSIGNED_BYTE:
  34059. if (!buffer) {
  34060. buffer = new Uint8Array(4 * width * height);
  34061. }
  34062. readType = gl.UNSIGNED_BYTE;
  34063. break;
  34064. default:
  34065. if (!buffer) {
  34066. buffer = new Float32Array(4 * width * height);
  34067. }
  34068. readType = gl.FLOAT;
  34069. break;
  34070. }
  34071. gl.readPixels(0, 0, width, height, gl.RGBA, readType, buffer);
  34072. gl.bindFramebuffer(gl.FRAMEBUFFER, this._currentFramebuffer);
  34073. return buffer;
  34074. };
  34075. Engine.prototype._canRenderToFloatFramebuffer = function () {
  34076. if (this._webGLVersion > 1) {
  34077. return this._caps.colorBufferFloat;
  34078. }
  34079. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_FLOAT);
  34080. };
  34081. Engine.prototype._canRenderToHalfFloatFramebuffer = function () {
  34082. if (this._webGLVersion > 1) {
  34083. return this._caps.colorBufferFloat;
  34084. }
  34085. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_HALF_FLOAT);
  34086. };
  34087. // Thank you : http://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture
  34088. Engine.prototype._canRenderToFramebuffer = function (type) {
  34089. var gl = this._gl;
  34090. //clear existing errors
  34091. while (gl.getError() !== gl.NO_ERROR) { }
  34092. var successful = true;
  34093. var texture = gl.createTexture();
  34094. gl.bindTexture(gl.TEXTURE_2D, texture);
  34095. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), 1, 1, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  34096. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  34097. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  34098. var fb = gl.createFramebuffer();
  34099. gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
  34100. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
  34101. var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
  34102. successful = successful && (status === gl.FRAMEBUFFER_COMPLETE);
  34103. successful = successful && (gl.getError() === gl.NO_ERROR);
  34104. //try render by clearing frame buffer's color buffer
  34105. if (successful) {
  34106. gl.clear(gl.COLOR_BUFFER_BIT);
  34107. successful = successful && (gl.getError() === gl.NO_ERROR);
  34108. }
  34109. //try reading from frame to ensure render occurs (just creating the FBO is not sufficient to determine if rendering is supported)
  34110. if (successful) {
  34111. //in practice it's sufficient to just read from the backbuffer rather than handle potentially issues reading from the texture
  34112. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  34113. var readFormat = gl.RGBA;
  34114. var readType = gl.UNSIGNED_BYTE;
  34115. var buffer = new Uint8Array(4);
  34116. gl.readPixels(0, 0, 1, 1, readFormat, readType, buffer);
  34117. successful = successful && (gl.getError() === gl.NO_ERROR);
  34118. }
  34119. //clean up
  34120. gl.deleteTexture(texture);
  34121. gl.deleteFramebuffer(fb);
  34122. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  34123. //clear accumulated errors
  34124. while (!successful && (gl.getError() !== gl.NO_ERROR)) { }
  34125. return successful;
  34126. };
  34127. /** @hidden */
  34128. Engine.prototype._getWebGLTextureType = function (type) {
  34129. if (this._webGLVersion === 1) {
  34130. switch (type) {
  34131. case Engine.TEXTURETYPE_FLOAT:
  34132. return this._gl.FLOAT;
  34133. case Engine.TEXTURETYPE_HALF_FLOAT:
  34134. return this._gl.HALF_FLOAT_OES;
  34135. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  34136. return this._gl.UNSIGNED_BYTE;
  34137. }
  34138. return this._gl.UNSIGNED_BYTE;
  34139. }
  34140. switch (type) {
  34141. case Engine.TEXTURETYPE_BYTE:
  34142. return this._gl.BYTE;
  34143. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  34144. return this._gl.UNSIGNED_BYTE;
  34145. case Engine.TEXTURETYPE_SHORT:
  34146. return this._gl.SHORT;
  34147. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  34148. return this._gl.UNSIGNED_SHORT;
  34149. case Engine.TEXTURETYPE_INT:
  34150. return this._gl.INT;
  34151. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  34152. return this._gl.UNSIGNED_INT;
  34153. case Engine.TEXTURETYPE_FLOAT:
  34154. return this._gl.FLOAT;
  34155. case Engine.TEXTURETYPE_HALF_FLOAT:
  34156. return this._gl.HALF_FLOAT;
  34157. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  34158. return this._gl.UNSIGNED_SHORT_4_4_4_4;
  34159. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  34160. return this._gl.UNSIGNED_SHORT_5_5_5_1;
  34161. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  34162. return this._gl.UNSIGNED_SHORT_5_6_5;
  34163. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  34164. return this._gl.UNSIGNED_INT_2_10_10_10_REV;
  34165. case Engine.TEXTURETYPE_UNSIGNED_INT_24_8:
  34166. return this._gl.UNSIGNED_INT_24_8;
  34167. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  34168. return this._gl.UNSIGNED_INT_10F_11F_11F_REV;
  34169. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  34170. return this._gl.UNSIGNED_INT_5_9_9_9_REV;
  34171. case Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:
  34172. return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV;
  34173. }
  34174. return this._gl.UNSIGNED_BYTE;
  34175. };
  34176. Engine.prototype._getInternalFormat = function (format) {
  34177. var internalFormat = this._gl.RGBA;
  34178. switch (format) {
  34179. case Engine.TEXTUREFORMAT_ALPHA:
  34180. internalFormat = this._gl.ALPHA;
  34181. break;
  34182. case Engine.TEXTUREFORMAT_LUMINANCE:
  34183. internalFormat = this._gl.LUMINANCE;
  34184. break;
  34185. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  34186. internalFormat = this._gl.LUMINANCE_ALPHA;
  34187. break;
  34188. case Engine.TEXTUREFORMAT_RED:
  34189. internalFormat = this._gl.RED;
  34190. break;
  34191. case Engine.TEXTUREFORMAT_RG:
  34192. internalFormat = this._gl.RG;
  34193. break;
  34194. case Engine.TEXTUREFORMAT_RGB:
  34195. internalFormat = this._gl.RGB;
  34196. break;
  34197. case Engine.TEXTUREFORMAT_RGBA:
  34198. internalFormat = this._gl.RGBA;
  34199. break;
  34200. }
  34201. if (this._webGLVersion > 1) {
  34202. switch (format) {
  34203. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34204. internalFormat = this._gl.RED_INTEGER;
  34205. break;
  34206. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34207. internalFormat = this._gl.RG_INTEGER;
  34208. break;
  34209. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34210. internalFormat = this._gl.RGB_INTEGER;
  34211. break;
  34212. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34213. internalFormat = this._gl.RGBA_INTEGER;
  34214. break;
  34215. }
  34216. }
  34217. return internalFormat;
  34218. };
  34219. /** @hidden */
  34220. Engine.prototype._getRGBABufferInternalSizedFormat = function (type, format) {
  34221. if (this._webGLVersion === 1) {
  34222. if (format !== undefined) {
  34223. switch (format) {
  34224. case Engine.TEXTUREFORMAT_ALPHA:
  34225. return this._gl.ALPHA;
  34226. case Engine.TEXTUREFORMAT_LUMINANCE:
  34227. return this._gl.LUMINANCE;
  34228. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  34229. return this._gl.LUMINANCE_ALPHA;
  34230. }
  34231. }
  34232. return this._gl.RGBA;
  34233. }
  34234. switch (type) {
  34235. case Engine.TEXTURETYPE_BYTE:
  34236. switch (format) {
  34237. case Engine.TEXTUREFORMAT_RED:
  34238. return this._gl.R8_SNORM;
  34239. case Engine.TEXTUREFORMAT_RG:
  34240. return this._gl.RG8_SNORM;
  34241. case Engine.TEXTUREFORMAT_RGB:
  34242. return this._gl.RGB8_SNORM;
  34243. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34244. return this._gl.R8I;
  34245. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34246. return this._gl.RG8I;
  34247. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34248. return this._gl.RGB8I;
  34249. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34250. return this._gl.RGBA8I;
  34251. default:
  34252. return this._gl.RGBA8_SNORM;
  34253. }
  34254. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  34255. switch (format) {
  34256. case Engine.TEXTUREFORMAT_RED:
  34257. return this._gl.R8;
  34258. case Engine.TEXTUREFORMAT_RG:
  34259. return this._gl.RG8;
  34260. case Engine.TEXTUREFORMAT_RGB:
  34261. return this._gl.RGB8; // By default. Other possibilities are RGB565, SRGB8.
  34262. case Engine.TEXTUREFORMAT_RGBA:
  34263. return this._gl.RGBA8; // By default. Other possibilities are RGB5_A1, RGBA4, SRGB8_ALPHA8.
  34264. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34265. return this._gl.R8UI;
  34266. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34267. return this._gl.RG8UI;
  34268. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34269. return this._gl.RGB8UI;
  34270. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34271. return this._gl.RGBA8UI;
  34272. default:
  34273. return this._gl.RGBA8;
  34274. }
  34275. case Engine.TEXTURETYPE_SHORT:
  34276. switch (format) {
  34277. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34278. return this._gl.R16I;
  34279. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34280. return this._gl.RG16I;
  34281. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34282. return this._gl.RGB16I;
  34283. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34284. return this._gl.RGBA16I;
  34285. default:
  34286. return this._gl.RGBA16I;
  34287. }
  34288. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  34289. switch (format) {
  34290. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34291. return this._gl.R16UI;
  34292. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34293. return this._gl.RG16UI;
  34294. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34295. return this._gl.RGB16UI;
  34296. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34297. return this._gl.RGBA16UI;
  34298. default:
  34299. return this._gl.RGBA16UI;
  34300. }
  34301. case Engine.TEXTURETYPE_INT:
  34302. switch (format) {
  34303. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34304. return this._gl.R32I;
  34305. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34306. return this._gl.RG32I;
  34307. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34308. return this._gl.RGB32I;
  34309. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34310. return this._gl.RGBA32I;
  34311. default:
  34312. return this._gl.RGBA32I;
  34313. }
  34314. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  34315. switch (format) {
  34316. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34317. return this._gl.R32UI;
  34318. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34319. return this._gl.RG32UI;
  34320. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34321. return this._gl.RGB32UI;
  34322. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34323. return this._gl.RGBA32UI;
  34324. default:
  34325. return this._gl.RGBA32UI;
  34326. }
  34327. case Engine.TEXTURETYPE_FLOAT:
  34328. switch (format) {
  34329. case Engine.TEXTUREFORMAT_RED:
  34330. return this._gl.R32F; // By default. Other possibility is R16F.
  34331. case Engine.TEXTUREFORMAT_RG:
  34332. return this._gl.RG32F; // By default. Other possibility is RG16F.
  34333. case Engine.TEXTUREFORMAT_RGB:
  34334. return this._gl.RGB32F; // By default. Other possibilities are RGB16F, R11F_G11F_B10F, RGB9_E5.
  34335. case Engine.TEXTUREFORMAT_RGBA:
  34336. return this._gl.RGBA32F; // By default. Other possibility is RGBA16F.
  34337. default:
  34338. return this._gl.RGBA32F;
  34339. }
  34340. case Engine.TEXTURETYPE_HALF_FLOAT:
  34341. switch (format) {
  34342. case Engine.TEXTUREFORMAT_RED:
  34343. return this._gl.R16F;
  34344. case Engine.TEXTUREFORMAT_RG:
  34345. return this._gl.RG16F;
  34346. case Engine.TEXTUREFORMAT_RGB:
  34347. return this._gl.RGB16F; // By default. Other possibilities are R11F_G11F_B10F, RGB9_E5.
  34348. case Engine.TEXTUREFORMAT_RGBA:
  34349. return this._gl.RGBA16F;
  34350. default:
  34351. return this._gl.RGBA16F;
  34352. }
  34353. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  34354. return this._gl.RGB565;
  34355. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  34356. return this._gl.R11F_G11F_B10F;
  34357. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  34358. return this._gl.RGB9_E5;
  34359. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  34360. return this._gl.RGBA4;
  34361. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  34362. return this._gl.RGB5_A1;
  34363. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  34364. switch (format) {
  34365. case Engine.TEXTUREFORMAT_RGBA:
  34366. return this._gl.RGB10_A2; // By default. Other possibility is RGB5_A1.
  34367. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34368. return this._gl.RGB10_A2UI;
  34369. default:
  34370. return this._gl.RGB10_A2;
  34371. }
  34372. }
  34373. return this._gl.RGBA8;
  34374. };
  34375. /** @hidden */
  34376. Engine.prototype._getRGBAMultiSampleBufferFormat = function (type) {
  34377. if (type === Engine.TEXTURETYPE_FLOAT) {
  34378. return this._gl.RGBA32F;
  34379. }
  34380. else if (type === Engine.TEXTURETYPE_HALF_FLOAT) {
  34381. return this._gl.RGBA16F;
  34382. }
  34383. return this._gl.RGBA8;
  34384. };
  34385. /** @hidden */
  34386. Engine.prototype._loadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  34387. var _this = this;
  34388. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadFile(url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError);
  34389. this._activeRequests.push(request);
  34390. request.onCompleteObservable.add(function (request) {
  34391. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  34392. });
  34393. return request;
  34394. };
  34395. /** @hidden */
  34396. Engine.prototype._loadFileAsync = function (url, offlineProvider, useArrayBuffer) {
  34397. var _this = this;
  34398. return new Promise(function (resolve, reject) {
  34399. _this._loadFile(url, function (data) {
  34400. resolve(data);
  34401. }, undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  34402. reject(exception);
  34403. });
  34404. });
  34405. };
  34406. Engine.prototype._partialLoadFile = function (url, index, loadedFiles, onfinish, onErrorCallBack) {
  34407. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  34408. var onload = function (data) {
  34409. loadedFiles[index] = data;
  34410. loadedFiles._internalCount++;
  34411. if (loadedFiles._internalCount === 6) {
  34412. onfinish(loadedFiles);
  34413. }
  34414. };
  34415. var onerror = function (request, exception) {
  34416. if (onErrorCallBack && request) {
  34417. onErrorCallBack(request.status + " " + request.statusText, exception);
  34418. }
  34419. };
  34420. this._loadFile(url, onload, undefined, undefined, true, onerror);
  34421. };
  34422. Engine.prototype._cascadeLoadFiles = function (scene, onfinish, files, onError) {
  34423. if (onError === void 0) { onError = null; }
  34424. var loadedFiles = [];
  34425. loadedFiles._internalCount = 0;
  34426. for (var index = 0; index < 6; index++) {
  34427. this._partialLoadFile(files[index], index, loadedFiles, onfinish, onError);
  34428. }
  34429. };
  34430. // Statics
  34431. /**
  34432. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  34433. * @returns true if the engine can be created
  34434. * @ignorenaming
  34435. */
  34436. Engine.isSupported = function () {
  34437. try {
  34438. var tempcanvas = document.createElement("canvas");
  34439. var gl = tempcanvas.getContext("webgl") || tempcanvas.getContext("experimental-webgl");
  34440. return gl != null && !!window.WebGLRenderingContext;
  34441. }
  34442. catch (e) {
  34443. return false;
  34444. }
  34445. };
  34446. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34447. Engine.ExceptionList = [
  34448. { key: "Chrome\/63\.0", capture: "63\\.0\\.3239\\.(\\d+)", captureConstraint: 108, targets: ["uniformBuffer"] },
  34449. { key: "Firefox\/58", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  34450. { key: "Firefox\/59", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  34451. { key: "Macintosh", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  34452. { key: "iPhone", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  34453. { key: "iPad", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  34454. { key: "Chrome\/72.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] },
  34455. { key: "Chrome\/73.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] },
  34456. { key: "Chrome\/74.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] },
  34457. { key: "Mac OS.+Chrome\/71", capture: null, captureConstraint: null, targets: ["vao"] },
  34458. { key: "Mac OS.+Chrome\/72", capture: null, captureConstraint: null, targets: ["vao"] }
  34459. ];
  34460. /**
  34461. * Hidden
  34462. */
  34463. Engine._TextureLoaders = [];
  34464. // Const statics
  34465. /** Defines that alpha blending is disabled */
  34466. Engine.ALPHA_DISABLE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_DISABLE;
  34467. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34468. Engine.ALPHA_ADD = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ADD;
  34469. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34470. Engine.ALPHA_COMBINE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_COMBINE;
  34471. /** Defines that alpha blending to DEST - SRC * DEST */
  34472. Engine.ALPHA_SUBTRACT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SUBTRACT;
  34473. /** Defines that alpha blending to SRC * DEST */
  34474. Engine.ALPHA_MULTIPLY = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MULTIPLY;
  34475. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34476. Engine.ALPHA_MAXIMIZED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MAXIMIZED;
  34477. /** Defines that alpha blending to SRC + DEST */
  34478. Engine.ALPHA_ONEONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ONEONE;
  34479. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34480. Engine.ALPHA_PREMULTIPLIED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED;
  34481. /**
  34482. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34483. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34484. */
  34485. Engine.ALPHA_PREMULTIPLIED_PORTERDUFF = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  34486. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34487. Engine.ALPHA_INTERPOLATE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_INTERPOLATE;
  34488. /**
  34489. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34490. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34491. */
  34492. Engine.ALPHA_SCREENMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SCREENMODE;
  34493. /** Defines that the ressource is not delayed*/
  34494. Engine.DELAYLOADSTATE_NONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NONE;
  34495. /** Defines that the ressource was successfully delay loaded */
  34496. Engine.DELAYLOADSTATE_LOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADED;
  34497. /** Defines that the ressource is currently delay loading */
  34498. Engine.DELAYLOADSTATE_LOADING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADING;
  34499. /** Defines that the ressource is delayed and has not started loading */
  34500. Engine.DELAYLOADSTATE_NOTLOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NOTLOADED;
  34501. // Depht or Stencil test Constants.
  34502. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34503. Engine.NEVER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NEVER;
  34504. /** 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 */
  34505. Engine.ALWAYS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALWAYS;
  34506. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34507. Engine.LESS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LESS;
  34508. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34509. Engine.EQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].EQUAL;
  34510. /** 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 */
  34511. Engine.LEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LEQUAL;
  34512. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34513. Engine.GREATER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GREATER;
  34514. /** 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 */
  34515. Engine.GEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GEQUAL;
  34516. /** 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 */
  34517. Engine.NOTEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NOTEQUAL;
  34518. // Stencil Actions Constants.
  34519. /** Passed to stencilOperation to specify that stencil value must be kept */
  34520. Engine.KEEP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].KEEP;
  34521. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34522. Engine.REPLACE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].REPLACE;
  34523. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34524. Engine.INCR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR;
  34525. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34526. Engine.DECR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR;
  34527. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34528. Engine.INVERT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INVERT;
  34529. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34530. Engine.INCR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR_WRAP;
  34531. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34532. Engine.DECR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR_WRAP;
  34533. /** Texture is not repeating outside of 0..1 UVs */
  34534. Engine.TEXTURE_CLAMP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  34535. /** Texture is repeating outside of 0..1 UVs */
  34536. Engine.TEXTURE_WRAP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  34537. /** Texture is repeating and mirrored */
  34538. Engine.TEXTURE_MIRROR_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  34539. /** ALPHA */
  34540. Engine.TEXTUREFORMAT_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_ALPHA;
  34541. /** LUMINANCE */
  34542. Engine.TEXTUREFORMAT_LUMINANCE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE;
  34543. /** LUMINANCE_ALPHA */
  34544. Engine.TEXTUREFORMAT_LUMINANCE_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA;
  34545. /** RGB */
  34546. Engine.TEXTUREFORMAT_RGB = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB;
  34547. /** RGBA */
  34548. Engine.TEXTUREFORMAT_RGBA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA;
  34549. /** RED */
  34550. Engine.TEXTUREFORMAT_RED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED;
  34551. /** RED (2nd reference) */
  34552. Engine.TEXTUREFORMAT_R = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R;
  34553. /** RG */
  34554. Engine.TEXTUREFORMAT_RG = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG;
  34555. /** RED_INTEGER */
  34556. Engine.TEXTUREFORMAT_RED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED_INTEGER;
  34557. /** RED_INTEGER (2nd reference) */
  34558. Engine.TEXTUREFORMAT_R_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R_INTEGER;
  34559. /** RG_INTEGER */
  34560. Engine.TEXTUREFORMAT_RG_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG_INTEGER;
  34561. /** RGB_INTEGER */
  34562. Engine.TEXTUREFORMAT_RGB_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB_INTEGER;
  34563. /** RGBA_INTEGER */
  34564. Engine.TEXTUREFORMAT_RGBA_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA_INTEGER;
  34565. /** UNSIGNED_BYTE */
  34566. Engine.TEXTURETYPE_UNSIGNED_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_BYTE;
  34567. /** UNSIGNED_BYTE (2nd reference) */
  34568. Engine.TEXTURETYPE_UNSIGNED_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  34569. /** FLOAT */
  34570. Engine.TEXTURETYPE_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT;
  34571. /** HALF_FLOAT */
  34572. Engine.TEXTURETYPE_HALF_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_HALF_FLOAT;
  34573. /** BYTE */
  34574. Engine.TEXTURETYPE_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_BYTE;
  34575. /** SHORT */
  34576. Engine.TEXTURETYPE_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_SHORT;
  34577. /** UNSIGNED_SHORT */
  34578. Engine.TEXTURETYPE_UNSIGNED_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT;
  34579. /** INT */
  34580. Engine.TEXTURETYPE_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_INT;
  34581. /** UNSIGNED_INT */
  34582. Engine.TEXTURETYPE_UNSIGNED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INTEGER;
  34583. /** UNSIGNED_SHORT_4_4_4_4 */
  34584. Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4;
  34585. /** UNSIGNED_SHORT_5_5_5_1 */
  34586. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1;
  34587. /** UNSIGNED_SHORT_5_6_5 */
  34588. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_6_5;
  34589. /** UNSIGNED_INT_2_10_10_10_REV */
  34590. Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV;
  34591. /** UNSIGNED_INT_24_8 */
  34592. Engine.TEXTURETYPE_UNSIGNED_INT_24_8 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_24_8;
  34593. /** UNSIGNED_INT_10F_11F_11F_REV */
  34594. Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV;
  34595. /** UNSIGNED_INT_5_9_9_9_REV */
  34596. Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV;
  34597. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34598. Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV;
  34599. /** nearest is mag = nearest and min = nearest and mip = linear */
  34600. Engine.TEXTURE_NEAREST_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  34601. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34602. Engine.TEXTURE_BILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  34603. /** Trilinear is mag = linear and min = linear and mip = linear */
  34604. Engine.TEXTURE_TRILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  34605. /** nearest is mag = nearest and min = nearest and mip = linear */
  34606. Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPLINEAR;
  34607. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34608. Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPNEAREST;
  34609. /** Trilinear is mag = linear and min = linear and mip = linear */
  34610. Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPLINEAR;
  34611. /** mag = nearest and min = nearest and mip = nearest */
  34612. Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  34613. /** mag = nearest and min = linear and mip = nearest */
  34614. Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  34615. /** mag = nearest and min = linear and mip = linear */
  34616. Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  34617. /** mag = nearest and min = linear and mip = none */
  34618. Engine.TEXTURE_NEAREST_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR;
  34619. /** mag = nearest and min = nearest and mip = none */
  34620. Engine.TEXTURE_NEAREST_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST;
  34621. /** mag = linear and min = nearest and mip = nearest */
  34622. Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  34623. /** mag = linear and min = nearest and mip = linear */
  34624. Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  34625. /** mag = linear and min = linear and mip = none */
  34626. Engine.TEXTURE_LINEAR_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR;
  34627. /** mag = linear and min = nearest and mip = none */
  34628. Engine.TEXTURE_LINEAR_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST;
  34629. /** Explicit coordinates mode */
  34630. Engine.TEXTURE_EXPLICIT_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EXPLICIT_MODE;
  34631. /** Spherical coordinates mode */
  34632. Engine.TEXTURE_SPHERICAL_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SPHERICAL_MODE;
  34633. /** Planar coordinates mode */
  34634. Engine.TEXTURE_PLANAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PLANAR_MODE;
  34635. /** Cubic coordinates mode */
  34636. Engine.TEXTURE_CUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CUBIC_MODE;
  34637. /** Projection coordinates mode */
  34638. Engine.TEXTURE_PROJECTION_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PROJECTION_MODE;
  34639. /** Skybox coordinates mode */
  34640. Engine.TEXTURE_SKYBOX_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SKYBOX_MODE;
  34641. /** Inverse Cubic coordinates mode */
  34642. Engine.TEXTURE_INVCUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_INVCUBIC_MODE;
  34643. /** Equirectangular coordinates mode */
  34644. Engine.TEXTURE_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  34645. /** Equirectangular Fixed coordinates mode */
  34646. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  34647. /** Equirectangular Fixed Mirrored coordinates mode */
  34648. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  34649. // Texture rescaling mode
  34650. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34651. Engine.SCALEMODE_FLOOR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_FLOOR;
  34652. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34653. Engine.SCALEMODE_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_NEAREST;
  34654. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34655. Engine.SCALEMODE_CEILING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_CEILING;
  34656. // Updatable statics so stick with vars here
  34657. /**
  34658. * Gets or sets the epsilon value used by collision engine
  34659. */
  34660. Engine.CollisionsEpsilon = 0.001;
  34661. /**
  34662. * Method called to create the default rescale post process on each engine.
  34663. */
  34664. Engine._RescalePostProcessFactory = null;
  34665. return Engine;
  34666. }());
  34667. /***/ }),
  34668. /***/ "./Engines/engineStore.ts":
  34669. /*!********************************!*\
  34670. !*** ./Engines/engineStore.ts ***!
  34671. \********************************/
  34672. /*! exports provided: EngineStore */
  34673. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34674. "use strict";
  34675. __webpack_require__.r(__webpack_exports__);
  34676. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return EngineStore; });
  34677. /**
  34678. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34679. * during the life time of the application.
  34680. */
  34681. var EngineStore = /** @class */ (function () {
  34682. function EngineStore() {
  34683. }
  34684. Object.defineProperty(EngineStore, "LastCreatedEngine", {
  34685. /**
  34686. * Gets the latest created engine
  34687. */
  34688. get: function () {
  34689. if (this.Instances.length === 0) {
  34690. return null;
  34691. }
  34692. return this.Instances[this.Instances.length - 1];
  34693. },
  34694. enumerable: true,
  34695. configurable: true
  34696. });
  34697. Object.defineProperty(EngineStore, "LastCreatedScene", {
  34698. /**
  34699. * Gets the latest created scene
  34700. */
  34701. get: function () {
  34702. var lastCreatedEngine = this.LastCreatedEngine;
  34703. if (!lastCreatedEngine) {
  34704. return null;
  34705. }
  34706. if (lastCreatedEngine.scenes.length === 0) {
  34707. return null;
  34708. }
  34709. return lastCreatedEngine.scenes[lastCreatedEngine.scenes.length - 1];
  34710. },
  34711. enumerable: true,
  34712. configurable: true
  34713. });
  34714. /** Gets the list of created engines */
  34715. EngineStore.Instances = new Array();
  34716. return EngineStore;
  34717. }());
  34718. /***/ }),
  34719. /***/ "./Engines/index.ts":
  34720. /*!**************************!*\
  34721. !*** ./Engines/index.ts ***!
  34722. \**************************/
  34723. /*! exports provided: Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  34724. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34725. "use strict";
  34726. __webpack_require__.r(__webpack_exports__);
  34727. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  34728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _constants__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  34729. /* harmony import */ var _engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine */ "./Engines/engine.ts");
  34730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["InstancingAttributeInfo"]; });
  34731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["DepthTextureCreationOptions"]; });
  34732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["EngineCapabilities"]; });
  34733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]; });
  34734. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  34735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"]; });
  34736. /* harmony import */ var _nullEngine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./nullEngine */ "./Engines/nullEngine.ts");
  34737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngineOptions"]; });
  34738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngine"]; });
  34739. /* harmony import */ var _Extensions_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Extensions/index */ "./Engines/Extensions/index.ts");
  34740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_OcclusionDataStorage"]; });
  34741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_forceTransformFeedbackToBundle"]; });
  34742. /***/ }),
  34743. /***/ "./Engines/nullEngine.ts":
  34744. /*!*******************************!*\
  34745. !*** ./Engines/nullEngine.ts ***!
  34746. \*******************************/
  34747. /*! exports provided: NullEngineOptions, NullEngine */
  34748. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34749. "use strict";
  34750. __webpack_require__.r(__webpack_exports__);
  34751. /* WEBPACK VAR INJECTION */(function(global) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return NullEngineOptions; });
  34752. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return NullEngine; });
  34753. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34754. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  34755. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  34756. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  34757. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  34758. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  34759. /**
  34760. * Options to create the null engine
  34761. */
  34762. var NullEngineOptions = /** @class */ (function () {
  34763. function NullEngineOptions() {
  34764. /**
  34765. * Render width (Default: 512)
  34766. */
  34767. this.renderWidth = 512;
  34768. /**
  34769. * Render height (Default: 256)
  34770. */
  34771. this.renderHeight = 256;
  34772. /**
  34773. * Texture size (Default: 512)
  34774. */
  34775. this.textureSize = 512;
  34776. /**
  34777. * If delta time between frames should be constant
  34778. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34779. */
  34780. this.deterministicLockstep = false;
  34781. /**
  34782. * Maximum about of steps between frames (Default: 4)
  34783. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34784. */
  34785. this.lockstepMaxSteps = 4;
  34786. }
  34787. return NullEngineOptions;
  34788. }());
  34789. /**
  34790. * The null engine class provides support for headless version of babylon.js.
  34791. * This can be used in server side scenario or for testing purposes
  34792. */
  34793. var NullEngine = /** @class */ (function (_super) {
  34794. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NullEngine, _super);
  34795. function NullEngine(options) {
  34796. if (options === void 0) { options = new NullEngineOptions(); }
  34797. var _this = _super.call(this, null) || this;
  34798. if (options.deterministicLockstep === undefined) {
  34799. options.deterministicLockstep = false;
  34800. }
  34801. if (options.lockstepMaxSteps === undefined) {
  34802. options.lockstepMaxSteps = 4;
  34803. }
  34804. _this._options = options;
  34805. // Init caps
  34806. // We consider we are on a webgl1 capable device
  34807. _this._caps = new _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["EngineCapabilities"]();
  34808. _this._caps.maxTexturesImageUnits = 16;
  34809. _this._caps.maxVertexTextureImageUnits = 16;
  34810. _this._caps.maxTextureSize = 512;
  34811. _this._caps.maxCubemapTextureSize = 512;
  34812. _this._caps.maxRenderTextureSize = 512;
  34813. _this._caps.maxVertexAttribs = 16;
  34814. _this._caps.maxVaryingVectors = 16;
  34815. _this._caps.maxFragmentUniformVectors = 16;
  34816. _this._caps.maxVertexUniformVectors = 16;
  34817. // Extensions
  34818. _this._caps.standardDerivatives = false;
  34819. _this._caps.astc = null;
  34820. _this._caps.s3tc = null;
  34821. _this._caps.pvrtc = null;
  34822. _this._caps.etc1 = null;
  34823. _this._caps.etc2 = null;
  34824. _this._caps.textureAnisotropicFilterExtension = null;
  34825. _this._caps.maxAnisotropy = 0;
  34826. _this._caps.uintIndices = false;
  34827. _this._caps.fragmentDepthSupported = false;
  34828. _this._caps.highPrecisionShaderSupported = true;
  34829. _this._caps.colorBufferFloat = false;
  34830. _this._caps.textureFloat = false;
  34831. _this._caps.textureFloatLinearFiltering = false;
  34832. _this._caps.textureFloatRender = false;
  34833. _this._caps.textureHalfFloat = false;
  34834. _this._caps.textureHalfFloatLinearFiltering = false;
  34835. _this._caps.textureHalfFloatRender = false;
  34836. _this._caps.textureLOD = false;
  34837. _this._caps.drawBuffersExtension = false;
  34838. _this._caps.depthTextureExtension = false;
  34839. _this._caps.vertexArrayObject = false;
  34840. _this._caps.instancedArrays = false;
  34841. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log("Babylon.js v" + _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].Version + " - Null engine");
  34842. // Wrappers
  34843. var theCurrentGlobal = (typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : window);
  34844. if (typeof URL === "undefined") {
  34845. theCurrentGlobal.URL = {
  34846. createObjectURL: function () { },
  34847. revokeObjectURL: function () { }
  34848. };
  34849. }
  34850. if (typeof Blob === "undefined") {
  34851. theCurrentGlobal.Blob = function () { };
  34852. }
  34853. return _this;
  34854. }
  34855. /**
  34856. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34857. */
  34858. NullEngine.prototype.isDeterministicLockStep = function () {
  34859. return this._options.deterministicLockstep;
  34860. };
  34861. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  34862. NullEngine.prototype.getLockstepMaxSteps = function () {
  34863. return this._options.lockstepMaxSteps;
  34864. };
  34865. /**
  34866. * Sets hardware scaling, used to save performance if needed
  34867. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34868. */
  34869. NullEngine.prototype.getHardwareScalingLevel = function () {
  34870. return 1.0;
  34871. };
  34872. NullEngine.prototype.createVertexBuffer = function (vertices) {
  34873. return {
  34874. capacity: 0,
  34875. references: 1,
  34876. is32Bits: false
  34877. };
  34878. };
  34879. NullEngine.prototype.createIndexBuffer = function (indices) {
  34880. return {
  34881. capacity: 0,
  34882. references: 1,
  34883. is32Bits: false
  34884. };
  34885. };
  34886. NullEngine.prototype.clear = function (color, backBuffer, depth, stencil) {
  34887. if (stencil === void 0) { stencil = false; }
  34888. };
  34889. NullEngine.prototype.getRenderWidth = function (useScreen) {
  34890. if (useScreen === void 0) { useScreen = false; }
  34891. if (!useScreen && this._currentRenderTarget) {
  34892. return this._currentRenderTarget.width;
  34893. }
  34894. return this._options.renderWidth;
  34895. };
  34896. NullEngine.prototype.getRenderHeight = function (useScreen) {
  34897. if (useScreen === void 0) { useScreen = false; }
  34898. if (!useScreen && this._currentRenderTarget) {
  34899. return this._currentRenderTarget.height;
  34900. }
  34901. return this._options.renderHeight;
  34902. };
  34903. NullEngine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  34904. this._cachedViewport = viewport;
  34905. };
  34906. NullEngine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context) {
  34907. return {
  34908. transformFeedback: null,
  34909. __SPECTOR_rebuildProgram: null,
  34910. isParallelCompiled: false
  34911. };
  34912. };
  34913. NullEngine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  34914. return [];
  34915. };
  34916. NullEngine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  34917. return [];
  34918. };
  34919. NullEngine.prototype.bindSamplers = function (effect) {
  34920. this._currentEffect = null;
  34921. };
  34922. NullEngine.prototype.enableEffect = function (effect) {
  34923. this._currentEffect = effect;
  34924. if (effect.onBind) {
  34925. effect.onBind(effect);
  34926. }
  34927. if (effect._onBindObservable) {
  34928. effect._onBindObservable.notifyObservers(effect);
  34929. }
  34930. };
  34931. NullEngine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  34932. if (zOffset === void 0) { zOffset = 0; }
  34933. if (reverseSide === void 0) { reverseSide = false; }
  34934. };
  34935. NullEngine.prototype.setIntArray = function (uniform, array) {
  34936. };
  34937. NullEngine.prototype.setIntArray2 = function (uniform, array) {
  34938. };
  34939. NullEngine.prototype.setIntArray3 = function (uniform, array) {
  34940. };
  34941. NullEngine.prototype.setIntArray4 = function (uniform, array) {
  34942. };
  34943. NullEngine.prototype.setFloatArray = function (uniform, array) {
  34944. };
  34945. NullEngine.prototype.setFloatArray2 = function (uniform, array) {
  34946. };
  34947. NullEngine.prototype.setFloatArray3 = function (uniform, array) {
  34948. };
  34949. NullEngine.prototype.setFloatArray4 = function (uniform, array) {
  34950. };
  34951. NullEngine.prototype.setArray = function (uniform, array) {
  34952. };
  34953. NullEngine.prototype.setArray2 = function (uniform, array) {
  34954. };
  34955. NullEngine.prototype.setArray3 = function (uniform, array) {
  34956. };
  34957. NullEngine.prototype.setArray4 = function (uniform, array) {
  34958. };
  34959. NullEngine.prototype.setMatrices = function (uniform, matrices) {
  34960. };
  34961. NullEngine.prototype.setMatrix = function (uniform, matrix) {
  34962. };
  34963. NullEngine.prototype.setMatrix3x3 = function (uniform, matrix) {
  34964. };
  34965. NullEngine.prototype.setMatrix2x2 = function (uniform, matrix) {
  34966. };
  34967. NullEngine.prototype.setFloat = function (uniform, value) {
  34968. };
  34969. NullEngine.prototype.setFloat2 = function (uniform, x, y) {
  34970. };
  34971. NullEngine.prototype.setFloat3 = function (uniform, x, y, z) {
  34972. };
  34973. NullEngine.prototype.setBool = function (uniform, bool) {
  34974. };
  34975. NullEngine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  34976. };
  34977. NullEngine.prototype.setColor3 = function (uniform, color3) {
  34978. };
  34979. NullEngine.prototype.setColor4 = function (uniform, color3, alpha) {
  34980. };
  34981. NullEngine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  34982. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  34983. if (this._alphaMode === mode) {
  34984. return;
  34985. }
  34986. this._alphaState.alphaBlend = (mode !== _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  34987. if (!noDepthWriteChange) {
  34988. this.setDepthWrite(mode === _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  34989. }
  34990. this._alphaMode = mode;
  34991. };
  34992. NullEngine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  34993. };
  34994. NullEngine.prototype.wipeCaches = function (bruteForce) {
  34995. if (this.preventCacheWipeBetweenFrames) {
  34996. return;
  34997. }
  34998. this.resetTextureCache();
  34999. this._currentEffect = null;
  35000. if (bruteForce) {
  35001. this._currentProgram = null;
  35002. this._stencilState.reset();
  35003. this._depthCullingState.reset();
  35004. this._alphaState.reset();
  35005. }
  35006. this._cachedVertexBuffers = null;
  35007. this._cachedIndexBuffer = null;
  35008. this._cachedEffectForVertexBuffers = null;
  35009. };
  35010. NullEngine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  35011. };
  35012. NullEngine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  35013. };
  35014. NullEngine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  35015. };
  35016. /** @hidden */
  35017. NullEngine.prototype._createTexture = function () {
  35018. return {};
  35019. };
  35020. /** @hidden */
  35021. NullEngine.prototype._releaseTexture = function (texture) {
  35022. };
  35023. NullEngine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallBack, format) {
  35024. if (samplingMode === void 0) { samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  35025. if (onLoad === void 0) { onLoad = null; }
  35026. if (onError === void 0) { onError = null; }
  35027. if (buffer === void 0) { buffer = null; }
  35028. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_URL);
  35029. var url = String(urlArg);
  35030. texture.url = url;
  35031. texture.generateMipMaps = !noMipmap;
  35032. texture.samplingMode = samplingMode;
  35033. texture.invertY = invertY;
  35034. texture.baseWidth = this._options.textureSize;
  35035. texture.baseHeight = this._options.textureSize;
  35036. texture.width = this._options.textureSize;
  35037. texture.height = this._options.textureSize;
  35038. if (format) {
  35039. texture.format = format;
  35040. }
  35041. texture.isReady = true;
  35042. if (onLoad) {
  35043. onLoad();
  35044. }
  35045. this._internalTexturesCache.push(texture);
  35046. return texture;
  35047. };
  35048. NullEngine.prototype.createRenderTargetTexture = function (size, options) {
  35049. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__["RenderTargetCreationOptions"]();
  35050. if (options !== undefined && typeof options === "object") {
  35051. fullOptions.generateMipMaps = options.generateMipMaps;
  35052. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  35053. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  35054. fullOptions.type = options.type === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT : options.type;
  35055. fullOptions.samplingMode = options.samplingMode === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  35056. }
  35057. else {
  35058. fullOptions.generateMipMaps = options;
  35059. fullOptions.generateDepthBuffer = true;
  35060. fullOptions.generateStencilBuffer = false;
  35061. fullOptions.type = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  35062. fullOptions.samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  35063. }
  35064. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_RENDERTARGET);
  35065. var width = size.width || size;
  35066. var height = size.height || size;
  35067. texture._depthStencilBuffer = {};
  35068. texture._framebuffer = {};
  35069. texture.baseWidth = width;
  35070. texture.baseHeight = height;
  35071. texture.width = width;
  35072. texture.height = height;
  35073. texture.isReady = true;
  35074. texture.samples = 1;
  35075. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  35076. texture.samplingMode = fullOptions.samplingMode;
  35077. texture.type = fullOptions.type;
  35078. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  35079. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  35080. this._internalTexturesCache.push(texture);
  35081. return texture;
  35082. };
  35083. NullEngine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  35084. texture.samplingMode = samplingMode;
  35085. };
  35086. NullEngine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport) {
  35087. if (this._currentRenderTarget) {
  35088. this.unBindFramebuffer(this._currentRenderTarget);
  35089. }
  35090. this._currentRenderTarget = texture;
  35091. this._currentFramebuffer = texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer;
  35092. if (this._cachedViewport && !forceFullscreenViewport) {
  35093. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  35094. }
  35095. };
  35096. NullEngine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  35097. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  35098. this._currentRenderTarget = null;
  35099. if (onBeforeUnbind) {
  35100. if (texture._MSAAFramebuffer) {
  35101. this._currentFramebuffer = texture._framebuffer;
  35102. }
  35103. onBeforeUnbind();
  35104. }
  35105. this._currentFramebuffer = null;
  35106. };
  35107. NullEngine.prototype.createDynamicVertexBuffer = function (vertices) {
  35108. var vbo = {
  35109. capacity: 1,
  35110. references: 1,
  35111. is32Bits: false
  35112. };
  35113. return vbo;
  35114. };
  35115. NullEngine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format) {
  35116. if (premulAlpha === void 0) { premulAlpha = false; }
  35117. };
  35118. NullEngine.prototype.areAllEffectsReady = function () {
  35119. return true;
  35120. };
  35121. /**
  35122. * @hidden
  35123. * Get the current error code of the webGL context
  35124. * @returns the error code
  35125. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35126. */
  35127. NullEngine.prototype.getError = function () {
  35128. return 0;
  35129. };
  35130. /** @hidden */
  35131. NullEngine.prototype._getUnpackAlignement = function () {
  35132. return 1;
  35133. };
  35134. /** @hidden */
  35135. NullEngine.prototype._unpackFlipY = function (value) {
  35136. };
  35137. NullEngine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  35138. if (offset === void 0) { offset = 0; }
  35139. };
  35140. /**
  35141. * Updates a dynamic vertex buffer.
  35142. * @param vertexBuffer the vertex buffer to update
  35143. * @param data the data used to update the vertex buffer
  35144. * @param byteOffset the byte offset of the data (optional)
  35145. * @param byteLength the byte length of the data (optional)
  35146. */
  35147. NullEngine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, vertices, byteOffset, byteLength) {
  35148. };
  35149. NullEngine.prototype._bindTextureDirectly = function (target, texture) {
  35150. if (this._boundTexturesCache[this._activeChannel] !== texture) {
  35151. this._boundTexturesCache[this._activeChannel] = texture;
  35152. return true;
  35153. }
  35154. return false;
  35155. };
  35156. /** @hidden */
  35157. NullEngine.prototype._bindTexture = function (channel, texture) {
  35158. if (channel < 0) {
  35159. return;
  35160. }
  35161. this._bindTextureDirectly(0, texture);
  35162. };
  35163. /** @hidden */
  35164. NullEngine.prototype._releaseBuffer = function (buffer) {
  35165. buffer.references--;
  35166. if (buffer.references === 0) {
  35167. return true;
  35168. }
  35169. return false;
  35170. };
  35171. NullEngine.prototype.releaseEffects = function () {
  35172. };
  35173. NullEngine.prototype.displayLoadingUI = function () {
  35174. };
  35175. NullEngine.prototype.hideLoadingUI = function () {
  35176. };
  35177. /** @hidden */
  35178. NullEngine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  35179. if (faceIndex === void 0) { faceIndex = 0; }
  35180. if (lod === void 0) { lod = 0; }
  35181. };
  35182. /** @hidden */
  35183. NullEngine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  35184. if (faceIndex === void 0) { faceIndex = 0; }
  35185. if (lod === void 0) { lod = 0; }
  35186. };
  35187. /** @hidden */
  35188. NullEngine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  35189. if (faceIndex === void 0) { faceIndex = 0; }
  35190. if (lod === void 0) { lod = 0; }
  35191. };
  35192. /** @hidden */
  35193. NullEngine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  35194. if (faceIndex === void 0) { faceIndex = 0; }
  35195. if (lod === void 0) { lod = 0; }
  35196. };
  35197. return NullEngine;
  35198. }(_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"]));
  35199. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  35200. /***/ }),
  35201. /***/ "./Events/clipboardEvents.ts":
  35202. /*!***********************************!*\
  35203. !*** ./Events/clipboardEvents.ts ***!
  35204. \***********************************/
  35205. /*! exports provided: ClipboardEventTypes, ClipboardInfo */
  35206. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35207. "use strict";
  35208. __webpack_require__.r(__webpack_exports__);
  35209. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return ClipboardEventTypes; });
  35210. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return ClipboardInfo; });
  35211. /**
  35212. * Gather the list of clipboard event types as constants.
  35213. */
  35214. var ClipboardEventTypes = /** @class */ (function () {
  35215. function ClipboardEventTypes() {
  35216. }
  35217. /**
  35218. * The clipboard event is fired when a copy command is active (pressed).
  35219. */
  35220. ClipboardEventTypes.COPY = 0x01; //
  35221. /**
  35222. * The clipboard event is fired when a cut command is active (pressed).
  35223. */
  35224. ClipboardEventTypes.CUT = 0x02;
  35225. /**
  35226. * The clipboard event is fired when a paste command is active (pressed).
  35227. */
  35228. ClipboardEventTypes.PASTE = 0x03;
  35229. return ClipboardEventTypes;
  35230. }());
  35231. /**
  35232. * This class is used to store clipboard related info for the onClipboardObservable event.
  35233. */
  35234. var ClipboardInfo = /** @class */ (function () {
  35235. /**
  35236. *Creates an instance of ClipboardInfo.
  35237. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  35238. * @param event Defines the related dom event
  35239. */
  35240. function ClipboardInfo(
  35241. /**
  35242. * Defines the type of event (BABYLON.ClipboardEventTypes)
  35243. */
  35244. type,
  35245. /**
  35246. * Defines the related dom event
  35247. */
  35248. event) {
  35249. this.type = type;
  35250. this.event = event;
  35251. }
  35252. /**
  35253. * Get the clipboard event's type from the keycode.
  35254. * @param keyCode Defines the keyCode for the current keyboard event.
  35255. * @return {number}
  35256. */
  35257. ClipboardInfo.GetTypeFromCharacter = function (keyCode) {
  35258. var charCode = keyCode;
  35259. //TODO: add codes for extended ASCII
  35260. switch (charCode) {
  35261. case 67: return ClipboardEventTypes.COPY;
  35262. case 86: return ClipboardEventTypes.PASTE;
  35263. case 88: return ClipboardEventTypes.CUT;
  35264. default: return -1;
  35265. }
  35266. };
  35267. return ClipboardInfo;
  35268. }());
  35269. /***/ }),
  35270. /***/ "./Events/index.ts":
  35271. /*!*************************!*\
  35272. !*** ./Events/index.ts ***!
  35273. \*************************/
  35274. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo */
  35275. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35276. "use strict";
  35277. __webpack_require__.r(__webpack_exports__);
  35278. /* harmony import */ var _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./keyboardEvents */ "./Events/keyboardEvents.ts");
  35279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  35280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  35281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  35282. /* harmony import */ var _pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pointerEvents */ "./Events/pointerEvents.ts");
  35283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"]; });
  35284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoBase"]; });
  35285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoPre"]; });
  35286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfo"]; });
  35287. /* harmony import */ var _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./clipboardEvents */ "./Events/clipboardEvents.ts");
  35288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardEventTypes"]; });
  35289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardInfo"]; });
  35290. /***/ }),
  35291. /***/ "./Events/keyboardEvents.ts":
  35292. /*!**********************************!*\
  35293. !*** ./Events/keyboardEvents.ts ***!
  35294. \**********************************/
  35295. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre */
  35296. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35297. "use strict";
  35298. __webpack_require__.r(__webpack_exports__);
  35299. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return KeyboardEventTypes; });
  35300. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return KeyboardInfo; });
  35301. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return KeyboardInfoPre; });
  35302. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35303. /**
  35304. * Gather the list of keyboard event types as constants.
  35305. */
  35306. var KeyboardEventTypes = /** @class */ (function () {
  35307. function KeyboardEventTypes() {
  35308. }
  35309. /**
  35310. * The keydown event is fired when a key becomes active (pressed).
  35311. */
  35312. KeyboardEventTypes.KEYDOWN = 0x01;
  35313. /**
  35314. * The keyup event is fired when a key has been released.
  35315. */
  35316. KeyboardEventTypes.KEYUP = 0x02;
  35317. return KeyboardEventTypes;
  35318. }());
  35319. /**
  35320. * This class is used to store keyboard related info for the onKeyboardObservable event.
  35321. */
  35322. var KeyboardInfo = /** @class */ (function () {
  35323. /**
  35324. * Instantiates a new keyboard info.
  35325. * This class is used to store keyboard related info for the onKeyboardObservable event.
  35326. * @param type Defines the type of event (KeyboardEventTypes)
  35327. * @param event Defines the related dom event
  35328. */
  35329. function KeyboardInfo(
  35330. /**
  35331. * Defines the type of event (KeyboardEventTypes)
  35332. */
  35333. type,
  35334. /**
  35335. * Defines the related dom event
  35336. */
  35337. event) {
  35338. this.type = type;
  35339. this.event = event;
  35340. }
  35341. return KeyboardInfo;
  35342. }());
  35343. /**
  35344. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  35345. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  35346. */
  35347. var KeyboardInfoPre = /** @class */ (function (_super) {
  35348. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeyboardInfoPre, _super);
  35349. /**
  35350. * Instantiates a new keyboard pre info.
  35351. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  35352. * @param type Defines the type of event (KeyboardEventTypes)
  35353. * @param event Defines the related dom event
  35354. */
  35355. function KeyboardInfoPre(
  35356. /**
  35357. * Defines the type of event (KeyboardEventTypes)
  35358. */
  35359. type,
  35360. /**
  35361. * Defines the related dom event
  35362. */
  35363. event) {
  35364. var _this = _super.call(this, type, event) || this;
  35365. _this.type = type;
  35366. _this.event = event;
  35367. _this.skipOnPointerObservable = false;
  35368. return _this;
  35369. }
  35370. return KeyboardInfoPre;
  35371. }(KeyboardInfo));
  35372. /***/ }),
  35373. /***/ "./Events/pointerEvents.ts":
  35374. /*!*********************************!*\
  35375. !*** ./Events/pointerEvents.ts ***!
  35376. \*********************************/
  35377. /*! exports provided: PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo */
  35378. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35379. "use strict";
  35380. __webpack_require__.r(__webpack_exports__);
  35381. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return PointerEventTypes; });
  35382. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return PointerInfoBase; });
  35383. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return PointerInfoPre; });
  35384. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return PointerInfo; });
  35385. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35386. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  35387. /**
  35388. * Gather the list of pointer event types as constants.
  35389. */
  35390. var PointerEventTypes = /** @class */ (function () {
  35391. function PointerEventTypes() {
  35392. }
  35393. /**
  35394. * 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.
  35395. */
  35396. PointerEventTypes.POINTERDOWN = 0x01;
  35397. /**
  35398. * The pointerup event is fired when a pointer is no longer active.
  35399. */
  35400. PointerEventTypes.POINTERUP = 0x02;
  35401. /**
  35402. * The pointermove event is fired when a pointer changes coordinates.
  35403. */
  35404. PointerEventTypes.POINTERMOVE = 0x04;
  35405. /**
  35406. * The pointerwheel event is fired when a mouse wheel has been rotated.
  35407. */
  35408. PointerEventTypes.POINTERWHEEL = 0x08;
  35409. /**
  35410. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  35411. */
  35412. PointerEventTypes.POINTERPICK = 0x10;
  35413. /**
  35414. * The pointertap event is fired when a the object has been touched and released without drag.
  35415. */
  35416. PointerEventTypes.POINTERTAP = 0x20;
  35417. /**
  35418. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  35419. */
  35420. PointerEventTypes.POINTERDOUBLETAP = 0x40;
  35421. return PointerEventTypes;
  35422. }());
  35423. /**
  35424. * Base class of pointer info types.
  35425. */
  35426. var PointerInfoBase = /** @class */ (function () {
  35427. /**
  35428. * Instantiates the base class of pointers info.
  35429. * @param type Defines the type of event (PointerEventTypes)
  35430. * @param event Defines the related dom event
  35431. */
  35432. function PointerInfoBase(
  35433. /**
  35434. * Defines the type of event (PointerEventTypes)
  35435. */
  35436. type,
  35437. /**
  35438. * Defines the related dom event
  35439. */
  35440. event) {
  35441. this.type = type;
  35442. this.event = event;
  35443. }
  35444. return PointerInfoBase;
  35445. }());
  35446. /**
  35447. * This class is used to store pointer related info for the onPrePointerObservable event.
  35448. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  35449. */
  35450. var PointerInfoPre = /** @class */ (function (_super) {
  35451. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfoPre, _super);
  35452. /**
  35453. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  35454. * @param type Defines the type of event (PointerEventTypes)
  35455. * @param event Defines the related dom event
  35456. * @param localX Defines the local x coordinates of the pointer when the event occured
  35457. * @param localY Defines the local y coordinates of the pointer when the event occured
  35458. */
  35459. function PointerInfoPre(type, event, localX, localY) {
  35460. var _this = _super.call(this, type, event) || this;
  35461. /**
  35462. * Ray from a pointer if availible (eg. 6dof controller)
  35463. */
  35464. _this.ray = null;
  35465. _this.skipOnPointerObservable = false;
  35466. _this.localPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](localX, localY);
  35467. return _this;
  35468. }
  35469. return PointerInfoPre;
  35470. }(PointerInfoBase));
  35471. /**
  35472. * This type contains all the data related to a pointer event in Babylon.js.
  35473. * 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.
  35474. */
  35475. var PointerInfo = /** @class */ (function (_super) {
  35476. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfo, _super);
  35477. /**
  35478. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  35479. * @param type Defines the type of event (PointerEventTypes)
  35480. * @param event Defines the related dom event
  35481. * @param pickInfo Defines the picking info associated to the info (if any)\
  35482. */
  35483. function PointerInfo(type, event,
  35484. /**
  35485. * Defines the picking info associated to the info (if any)\
  35486. */
  35487. pickInfo) {
  35488. var _this = _super.call(this, type, event) || this;
  35489. _this.pickInfo = pickInfo;
  35490. return _this;
  35491. }
  35492. return PointerInfo;
  35493. }(PointerInfoBase));
  35494. /***/ }),
  35495. /***/ "./Gamepads/Controllers/daydreamController.ts":
  35496. /*!****************************************************!*\
  35497. !*** ./Gamepads/Controllers/daydreamController.ts ***!
  35498. \****************************************************/
  35499. /*! exports provided: DaydreamController */
  35500. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35501. "use strict";
  35502. __webpack_require__.r(__webpack_exports__);
  35503. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return DaydreamController; });
  35504. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35505. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  35506. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35507. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35508. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35509. /**
  35510. * Google Daydream controller
  35511. */
  35512. var DaydreamController = /** @class */ (function (_super) {
  35513. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DaydreamController, _super);
  35514. /**
  35515. * Creates a new DaydreamController from a gamepad
  35516. * @param vrGamepad the gamepad that the controller should be created from
  35517. */
  35518. function DaydreamController(vrGamepad) {
  35519. var _this = _super.call(this, vrGamepad) || this;
  35520. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].DAYDREAM;
  35521. return _this;
  35522. }
  35523. /**
  35524. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35525. * @param scene scene in which to add meshes
  35526. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35527. */
  35528. DaydreamController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35529. var _this = this;
  35530. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", DaydreamController.MODEL_BASE_URL, DaydreamController.MODEL_FILENAME, scene, function (newMeshes) {
  35531. _this._defaultModel = newMeshes[1];
  35532. _this.attachToMesh(_this._defaultModel);
  35533. if (meshLoaded) {
  35534. meshLoaded(_this._defaultModel);
  35535. }
  35536. });
  35537. };
  35538. /**
  35539. * Called once for each button that changed state since the last frame
  35540. * @param buttonIdx Which button index changed
  35541. * @param state New state of the button
  35542. * @param changes Which properties on the state changed since last frame
  35543. */
  35544. DaydreamController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35545. // Daydream controller only has 1 GamepadButton (on the trackpad).
  35546. if (buttonIdx === 0) {
  35547. var observable = this.onTriggerStateChangedObservable;
  35548. if (observable) {
  35549. observable.notifyObservers(state);
  35550. }
  35551. }
  35552. else {
  35553. // If the app or home buttons are ever made available
  35554. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Unrecognized Daydream button index: " + buttonIdx);
  35555. }
  35556. };
  35557. /**
  35558. * Base Url for the controller model.
  35559. */
  35560. DaydreamController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  35561. /**
  35562. * File name for the controller model.
  35563. */
  35564. DaydreamController.MODEL_FILENAME = 'generic.babylon';
  35565. /**
  35566. * Gamepad Id prefix used to identify Daydream Controller.
  35567. */
  35568. DaydreamController.GAMEPAD_ID_PREFIX = 'Daydream'; // id is 'Daydream Controller'
  35569. return DaydreamController;
  35570. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  35571. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35572. canCreate: function (gamepadInfo) {
  35573. return gamepadInfo.id.indexOf(DaydreamController.GAMEPAD_ID_PREFIX) === 0;
  35574. },
  35575. create: function (gamepadInfo) {
  35576. return new DaydreamController(gamepadInfo);
  35577. }
  35578. });
  35579. /***/ }),
  35580. /***/ "./Gamepads/Controllers/gearVRController.ts":
  35581. /*!**************************************************!*\
  35582. !*** ./Gamepads/Controllers/gearVRController.ts ***!
  35583. \**************************************************/
  35584. /*! exports provided: GearVRController */
  35585. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35586. "use strict";
  35587. __webpack_require__.r(__webpack_exports__);
  35588. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return GearVRController; });
  35589. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35590. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  35591. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  35592. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35593. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35594. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35595. /**
  35596. * Gear VR Controller
  35597. */
  35598. var GearVRController = /** @class */ (function (_super) {
  35599. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GearVRController, _super);
  35600. /**
  35601. * Creates a new GearVRController from a gamepad
  35602. * @param vrGamepad the gamepad that the controller should be created from
  35603. */
  35604. function GearVRController(vrGamepad) {
  35605. var _this = _super.call(this, vrGamepad) || this;
  35606. _this._buttonIndexToObservableNameMap = [
  35607. 'onPadStateChangedObservable',
  35608. 'onTriggerStateChangedObservable' // Trigger
  35609. ];
  35610. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerType"].GEAR_VR;
  35611. // Initial starting position defaults to where hand would be (incase of only 3dof controller)
  35612. _this._calculatedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](_this.hand == "left" ? -0.15 : 0.15, -0.5, 0.25);
  35613. _this._disableTrackPosition(_this._calculatedPosition);
  35614. return _this;
  35615. }
  35616. /**
  35617. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35618. * @param scene scene in which to add meshes
  35619. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35620. */
  35621. GearVRController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35622. var _this = this;
  35623. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__["SceneLoader"].ImportMesh("", GearVRController.MODEL_BASE_URL, GearVRController.MODEL_FILENAME, scene, function (newMeshes) {
  35624. // Offset the controller so it will rotate around the users wrist
  35625. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", scene);
  35626. newMeshes[1].parent = mesh;
  35627. newMeshes[1].position.z = -0.15;
  35628. _this._defaultModel = mesh;
  35629. _this.attachToMesh(_this._defaultModel);
  35630. if (meshLoaded) {
  35631. meshLoaded(_this._defaultModel);
  35632. }
  35633. });
  35634. };
  35635. /**
  35636. * Called once for each button that changed state since the last frame
  35637. * @param buttonIdx Which button index changed
  35638. * @param state New state of the button
  35639. * @param changes Which properties on the state changed since last frame
  35640. */
  35641. GearVRController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35642. if (buttonIdx < this._buttonIndexToObservableNameMap.length) {
  35643. var observableName = this._buttonIndexToObservableNameMap[buttonIdx];
  35644. // Only emit events for buttons that we know how to map from index to observable
  35645. var observable = this[observableName];
  35646. if (observable) {
  35647. observable.notifyObservers(state);
  35648. }
  35649. }
  35650. };
  35651. /**
  35652. * Base Url for the controller model.
  35653. */
  35654. GearVRController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  35655. /**
  35656. * File name for the controller model.
  35657. */
  35658. GearVRController.MODEL_FILENAME = 'generic.babylon';
  35659. /**
  35660. * Gamepad Id prefix used to identify this controller.
  35661. */
  35662. GearVRController.GAMEPAD_ID_PREFIX = 'Gear VR'; // id is 'Gear VR Controller'
  35663. return GearVRController;
  35664. }(_webVRController__WEBPACK_IMPORTED_MODULE_4__["WebVRController"]));
  35665. _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35666. canCreate: function (gamepadInfo) {
  35667. return gamepadInfo.id.indexOf(GearVRController.GAMEPAD_ID_PREFIX) === 0 ||
  35668. gamepadInfo.id.indexOf('Oculus Go') !== -1;
  35669. },
  35670. create: function (gamepadInfo) {
  35671. return new GearVRController(gamepadInfo);
  35672. }
  35673. });
  35674. /***/ }),
  35675. /***/ "./Gamepads/Controllers/genericController.ts":
  35676. /*!***************************************************!*\
  35677. !*** ./Gamepads/Controllers/genericController.ts ***!
  35678. \***************************************************/
  35679. /*! exports provided: GenericController */
  35680. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35681. "use strict";
  35682. __webpack_require__.r(__webpack_exports__);
  35683. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return GenericController; });
  35684. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35685. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35686. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35687. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35688. /**
  35689. * Generic Controller
  35690. */
  35691. var GenericController = /** @class */ (function (_super) {
  35692. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericController, _super);
  35693. /**
  35694. * Creates a new GenericController from a gamepad
  35695. * @param vrGamepad the gamepad that the controller should be created from
  35696. */
  35697. function GenericController(vrGamepad) {
  35698. return _super.call(this, vrGamepad) || this;
  35699. }
  35700. /**
  35701. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35702. * @param scene scene in which to add meshes
  35703. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35704. */
  35705. GenericController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35706. var _this = this;
  35707. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", GenericController.MODEL_BASE_URL, GenericController.MODEL_FILENAME, scene, function (newMeshes) {
  35708. _this._defaultModel = newMeshes[1];
  35709. _this.attachToMesh(_this._defaultModel);
  35710. if (meshLoaded) {
  35711. meshLoaded(_this._defaultModel);
  35712. }
  35713. });
  35714. };
  35715. /**
  35716. * Called once for each button that changed state since the last frame
  35717. * @param buttonIdx Which button index changed
  35718. * @param state New state of the button
  35719. * @param changes Which properties on the state changed since last frame
  35720. */
  35721. GenericController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35722. console.log("Button id: " + buttonIdx + "state: ");
  35723. console.dir(state);
  35724. };
  35725. /**
  35726. * Base Url for the controller model.
  35727. */
  35728. GenericController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  35729. /**
  35730. * File name for the controller model.
  35731. */
  35732. GenericController.MODEL_FILENAME = 'generic.babylon';
  35733. return GenericController;
  35734. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  35735. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._DefaultControllerFactory = function (gamepadInfo) { return new GenericController(gamepadInfo); };
  35736. /***/ }),
  35737. /***/ "./Gamepads/Controllers/index.ts":
  35738. /*!***************************************!*\
  35739. !*** ./Gamepads/Controllers/index.ts ***!
  35740. \***************************************/
  35741. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController */
  35742. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35743. "use strict";
  35744. __webpack_require__.r(__webpack_exports__);
  35745. /* harmony import */ var _daydreamController__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./daydreamController */ "./Gamepads/Controllers/daydreamController.ts");
  35746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _daydreamController__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  35747. /* harmony import */ var _gearVRController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gearVRController */ "./Gamepads/Controllers/gearVRController.ts");
  35748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _gearVRController__WEBPACK_IMPORTED_MODULE_1__["GearVRController"]; });
  35749. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  35750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _genericController__WEBPACK_IMPORTED_MODULE_2__["GenericController"]; });
  35751. /* harmony import */ var _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./oculusTouchController */ "./Gamepads/Controllers/oculusTouchController.ts");
  35752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__["OculusTouchController"]; });
  35753. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"]; });
  35755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]; });
  35756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledController"]; });
  35757. /* harmony import */ var _viveController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./viveController */ "./Gamepads/Controllers/viveController.ts");
  35758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _viveController__WEBPACK_IMPORTED_MODULE_5__["ViveController"]; });
  35759. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _webVRController__WEBPACK_IMPORTED_MODULE_6__["WebVRController"]; });
  35761. /* harmony import */ var _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./windowsMotionController */ "./Gamepads/Controllers/windowsMotionController.ts");
  35762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__["WindowsMotionController"]; });
  35763. /***/ }),
  35764. /***/ "./Gamepads/Controllers/oculusTouchController.ts":
  35765. /*!*******************************************************!*\
  35766. !*** ./Gamepads/Controllers/oculusTouchController.ts ***!
  35767. \*******************************************************/
  35768. /*! exports provided: OculusTouchController */
  35769. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35770. "use strict";
  35771. __webpack_require__.r(__webpack_exports__);
  35772. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return OculusTouchController; });
  35773. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35774. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35775. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35776. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35777. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35778. /**
  35779. * Oculus Touch Controller
  35780. */
  35781. var OculusTouchController = /** @class */ (function (_super) {
  35782. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](OculusTouchController, _super);
  35783. /**
  35784. * Creates a new OculusTouchController from a gamepad
  35785. * @param vrGamepad the gamepad that the controller should be created from
  35786. */
  35787. function OculusTouchController(vrGamepad) {
  35788. var _this = _super.call(this, vrGamepad) || this;
  35789. /**
  35790. * Fired when the secondary trigger on this controller is modified
  35791. */
  35792. _this.onSecondaryTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35793. /**
  35794. * Fired when the thumb rest on this controller is modified
  35795. */
  35796. _this.onThumbRestChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35797. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].OCULUS;
  35798. return _this;
  35799. }
  35800. /**
  35801. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35802. * @param scene scene in which to add meshes
  35803. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35804. */
  35805. OculusTouchController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35806. var _this = this;
  35807. var meshName;
  35808. // Hand
  35809. if (this.hand === 'left') {
  35810. meshName = OculusTouchController.MODEL_LEFT_FILENAME;
  35811. }
  35812. else { // Right is the default if no hand is specified
  35813. meshName = OculusTouchController.MODEL_RIGHT_FILENAME;
  35814. }
  35815. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", OculusTouchController.MODEL_BASE_URL, meshName, scene, function (newMeshes) {
  35816. /*
  35817. Parent Mesh name: oculus_touch_left
  35818. - body
  35819. - trigger
  35820. - thumbstick
  35821. - grip
  35822. - button_y
  35823. - button_x
  35824. - button_enter
  35825. */
  35826. _this._defaultModel = newMeshes[1];
  35827. _this.attachToMesh(_this._defaultModel);
  35828. if (meshLoaded) {
  35829. meshLoaded(_this._defaultModel);
  35830. }
  35831. });
  35832. };
  35833. Object.defineProperty(OculusTouchController.prototype, "onAButtonStateChangedObservable", {
  35834. /**
  35835. * Fired when the A button on this controller is modified
  35836. */
  35837. get: function () {
  35838. if (this.hand === 'right') {
  35839. return this.onMainButtonStateChangedObservable;
  35840. }
  35841. else {
  35842. throw new Error('No A button on left hand');
  35843. }
  35844. },
  35845. enumerable: true,
  35846. configurable: true
  35847. });
  35848. Object.defineProperty(OculusTouchController.prototype, "onBButtonStateChangedObservable", {
  35849. /**
  35850. * Fired when the B button on this controller is modified
  35851. */
  35852. get: function () {
  35853. if (this.hand === 'right') {
  35854. return this.onSecondaryButtonStateChangedObservable;
  35855. }
  35856. else {
  35857. throw new Error('No B button on left hand');
  35858. }
  35859. },
  35860. enumerable: true,
  35861. configurable: true
  35862. });
  35863. Object.defineProperty(OculusTouchController.prototype, "onXButtonStateChangedObservable", {
  35864. /**
  35865. * Fired when the X button on this controller is modified
  35866. */
  35867. get: function () {
  35868. if (this.hand === 'left') {
  35869. return this.onMainButtonStateChangedObservable;
  35870. }
  35871. else {
  35872. throw new Error('No X button on right hand');
  35873. }
  35874. },
  35875. enumerable: true,
  35876. configurable: true
  35877. });
  35878. Object.defineProperty(OculusTouchController.prototype, "onYButtonStateChangedObservable", {
  35879. /**
  35880. * Fired when the Y button on this controller is modified
  35881. */
  35882. get: function () {
  35883. if (this.hand === 'left') {
  35884. return this.onSecondaryButtonStateChangedObservable;
  35885. }
  35886. else {
  35887. throw new Error('No Y button on right hand');
  35888. }
  35889. },
  35890. enumerable: true,
  35891. configurable: true
  35892. });
  35893. /**
  35894. * Called once for each button that changed state since the last frame
  35895. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  35896. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  35897. * 2) secondary trigger (same)
  35898. * 3) A (right) X (left), touch, pressed = value
  35899. * 4) B / Y
  35900. * 5) thumb rest
  35901. * @param buttonIdx Which button index changed
  35902. * @param state New state of the button
  35903. * @param changes Which properties on the state changed since last frame
  35904. */
  35905. OculusTouchController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35906. var notifyObject = state; //{ state: state, changes: changes };
  35907. var triggerDirection = this.hand === 'right' ? -1 : 1;
  35908. switch (buttonIdx) {
  35909. case 0:
  35910. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  35911. return;
  35912. case 1: // index trigger
  35913. if (this._defaultModel) {
  35914. (this._defaultModel.getChildren()[3]).rotation.x = -notifyObject.value * 0.20;
  35915. (this._defaultModel.getChildren()[3]).position.y = -notifyObject.value * 0.005;
  35916. (this._defaultModel.getChildren()[3]).position.z = -notifyObject.value * 0.005;
  35917. }
  35918. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  35919. return;
  35920. case 2: // secondary trigger
  35921. if (this._defaultModel) {
  35922. (this._defaultModel.getChildren()[4]).position.x = triggerDirection * notifyObject.value * 0.0035;
  35923. }
  35924. this.onSecondaryTriggerStateChangedObservable.notifyObservers(notifyObject);
  35925. return;
  35926. case 3:
  35927. if (this._defaultModel) {
  35928. if (notifyObject.pressed) {
  35929. (this._defaultModel.getChildren()[1]).position.y = -0.001;
  35930. }
  35931. else {
  35932. (this._defaultModel.getChildren()[1]).position.y = 0;
  35933. }
  35934. }
  35935. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  35936. return;
  35937. case 4:
  35938. if (this._defaultModel) {
  35939. if (notifyObject.pressed) {
  35940. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  35941. }
  35942. else {
  35943. (this._defaultModel.getChildren()[2]).position.y = 0;
  35944. }
  35945. }
  35946. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  35947. return;
  35948. case 5:
  35949. this.onThumbRestChangedObservable.notifyObservers(notifyObject);
  35950. return;
  35951. }
  35952. };
  35953. /**
  35954. * Base Url for the controller model.
  35955. */
  35956. OculusTouchController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/oculus/';
  35957. /**
  35958. * File name for the left controller model.
  35959. */
  35960. OculusTouchController.MODEL_LEFT_FILENAME = 'left.babylon';
  35961. /**
  35962. * File name for the right controller model.
  35963. */
  35964. OculusTouchController.MODEL_RIGHT_FILENAME = 'right.babylon';
  35965. return OculusTouchController;
  35966. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  35967. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35968. canCreate: function (gamepadInfo) {
  35969. return gamepadInfo.id.indexOf('Oculus Touch') !== -1;
  35970. },
  35971. create: function (gamepadInfo) {
  35972. return new OculusTouchController(gamepadInfo);
  35973. }
  35974. });
  35975. /***/ }),
  35976. /***/ "./Gamepads/Controllers/poseEnabledController.ts":
  35977. /*!*******************************************************!*\
  35978. !*** ./Gamepads/Controllers/poseEnabledController.ts ***!
  35979. \*******************************************************/
  35980. /*! exports provided: PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController */
  35981. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35982. "use strict";
  35983. __webpack_require__.r(__webpack_exports__);
  35984. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return PoseEnabledControllerType; });
  35985. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return PoseEnabledControllerHelper; });
  35986. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return PoseEnabledController; });
  35987. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35988. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35989. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  35990. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  35991. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  35992. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  35993. /**
  35994. * Defines the types of pose enabled controllers that are supported
  35995. */
  35996. var PoseEnabledControllerType;
  35997. (function (PoseEnabledControllerType) {
  35998. /**
  35999. * HTC Vive
  36000. */
  36001. PoseEnabledControllerType[PoseEnabledControllerType["VIVE"] = 0] = "VIVE";
  36002. /**
  36003. * Oculus Rift
  36004. */
  36005. PoseEnabledControllerType[PoseEnabledControllerType["OCULUS"] = 1] = "OCULUS";
  36006. /**
  36007. * Windows mixed reality
  36008. */
  36009. PoseEnabledControllerType[PoseEnabledControllerType["WINDOWS"] = 2] = "WINDOWS";
  36010. /**
  36011. * Samsung gear VR
  36012. */
  36013. PoseEnabledControllerType[PoseEnabledControllerType["GEAR_VR"] = 3] = "GEAR_VR";
  36014. /**
  36015. * Google Daydream
  36016. */
  36017. PoseEnabledControllerType[PoseEnabledControllerType["DAYDREAM"] = 4] = "DAYDREAM";
  36018. /**
  36019. * Generic
  36020. */
  36021. PoseEnabledControllerType[PoseEnabledControllerType["GENERIC"] = 5] = "GENERIC";
  36022. })(PoseEnabledControllerType || (PoseEnabledControllerType = {}));
  36023. /**
  36024. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  36025. */
  36026. var PoseEnabledControllerHelper = /** @class */ (function () {
  36027. function PoseEnabledControllerHelper() {
  36028. }
  36029. /**
  36030. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  36031. * @param vrGamepad the gamepad to initialized
  36032. * @returns a vr controller of the type the gamepad identified as
  36033. */
  36034. PoseEnabledControllerHelper.InitiateController = function (vrGamepad) {
  36035. for (var _i = 0, _a = this._ControllerFactories; _i < _a.length; _i++) {
  36036. var factory = _a[_i];
  36037. if (factory.canCreate(vrGamepad)) {
  36038. return factory.create(vrGamepad);
  36039. }
  36040. }
  36041. if (this._DefaultControllerFactory) {
  36042. return this._DefaultControllerFactory(vrGamepad);
  36043. }
  36044. throw "The type of gamepad you are trying to load needs to be imported first or is not supported.";
  36045. };
  36046. /** @hidden */
  36047. PoseEnabledControllerHelper._ControllerFactories = [];
  36048. /** @hidden */
  36049. PoseEnabledControllerHelper._DefaultControllerFactory = null;
  36050. return PoseEnabledControllerHelper;
  36051. }());
  36052. /**
  36053. * Defines the PoseEnabledController object that contains state of a vr capable controller
  36054. */
  36055. var PoseEnabledController = /** @class */ (function (_super) {
  36056. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PoseEnabledController, _super);
  36057. /**
  36058. * Creates a new PoseEnabledController from a gamepad
  36059. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  36060. */
  36061. function PoseEnabledController(browserGamepad) {
  36062. var _this = _super.call(this, browserGamepad.id, browserGamepad.index, browserGamepad) || this;
  36063. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  36064. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  36065. _this._deviceRoomRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36066. /**
  36067. * The device position in babylon space
  36068. */
  36069. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  36070. /**
  36071. * The device rotation in babylon space
  36072. */
  36073. _this.deviceRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36074. /**
  36075. * The scale factor of the device in babylon space
  36076. */
  36077. _this.deviceScaleFactor = 1;
  36078. // Used to convert 6dof controllers to 3dof
  36079. _this._trackPosition = true;
  36080. _this._maxRotationDistFromHeadset = Math.PI / 5;
  36081. _this._draggedRoomRotation = 0;
  36082. _this._leftHandSystemQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36083. /**
  36084. * Internal, matrix used to convert room space to babylon space
  36085. * @hidden
  36086. */
  36087. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  36088. /**
  36089. * Node to be used when casting a ray from the controller
  36090. * @hidden
  36091. */
  36092. _this._pointingPoseNode = null;
  36093. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  36094. /**
  36095. * @hidden
  36096. */
  36097. _this._meshAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36098. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED;
  36099. _this.controllerType = PoseEnabledControllerType.GENERIC;
  36100. _this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  36101. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36102. _this._calculatedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  36103. _this._calculatedRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36104. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(Math.PI, 0, 0, _this._leftHandSystemQuaternion);
  36105. return _this;
  36106. }
  36107. /**
  36108. * @hidden
  36109. */
  36110. PoseEnabledController.prototype._disableTrackPosition = function (fixedPosition) {
  36111. if (this._trackPosition) {
  36112. this._calculatedPosition.copyFrom(fixedPosition);
  36113. this._trackPosition = false;
  36114. }
  36115. };
  36116. /**
  36117. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  36118. */
  36119. PoseEnabledController.prototype.update = function () {
  36120. _super.prototype.update.call(this);
  36121. this._updatePoseAndMesh();
  36122. };
  36123. /**
  36124. * Updates only the pose device and mesh without doing any button event checking
  36125. */
  36126. PoseEnabledController.prototype._updatePoseAndMesh = function () {
  36127. var pose = this.browserGamepad.pose;
  36128. this.updateFromDevice(pose);
  36129. 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) {
  36130. var camera = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene.activeCamera;
  36131. camera._computeDevicePosition();
  36132. this._deviceToWorld.setTranslation(camera.devicePosition);
  36133. if (camera.deviceRotationQuaternion) {
  36134. var camera = camera;
  36135. camera._deviceRoomRotationQuaternion.toEulerAnglesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[0]);
  36136. // Find the radian distance away that the headset is from the controllers rotation
  36137. 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));
  36138. if (Math.abs(distanceAway) > this._maxRotationDistFromHeadset) {
  36139. // Only rotate enouph to be within the _maxRotationDistFromHeadset
  36140. var rotationAmount = distanceAway - (distanceAway < 0 ? -this._maxRotationDistFromHeadset : this._maxRotationDistFromHeadset);
  36141. this._draggedRoomRotation += rotationAmount;
  36142. // Rotate controller around headset
  36143. var sin = Math.sin(-rotationAmount);
  36144. var cos = Math.cos(-rotationAmount);
  36145. this._calculatedPosition.x = this._calculatedPosition.x * cos - this._calculatedPosition.z * sin;
  36146. this._calculatedPosition.z = this._calculatedPosition.x * sin + this._calculatedPosition.z * cos;
  36147. }
  36148. }
  36149. }
  36150. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._calculatedPosition, this._deviceToWorld, this.devicePosition);
  36151. this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix);
  36152. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  36153. this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation);
  36154. if (this._mesh) {
  36155. this._mesh.position.copyFrom(this.devicePosition);
  36156. if (this._mesh.rotationQuaternion) {
  36157. this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion);
  36158. }
  36159. }
  36160. };
  36161. /**
  36162. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  36163. * @param poseData raw pose fromthe device
  36164. */
  36165. PoseEnabledController.prototype.updateFromDevice = function (poseData) {
  36166. if (poseData) {
  36167. this.rawPose = poseData;
  36168. if (poseData.position) {
  36169. this._deviceRoomPosition.copyFromFloats(poseData.position[0], poseData.position[1], -poseData.position[2]);
  36170. if (this._mesh && this._mesh.getScene().useRightHandedSystem) {
  36171. this._deviceRoomPosition.z *= -1;
  36172. }
  36173. if (this._trackPosition) {
  36174. this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor, this._calculatedPosition);
  36175. }
  36176. this._calculatedPosition.addInPlace(this.position);
  36177. }
  36178. var pose = this.rawPose;
  36179. if (poseData.orientation && pose.orientation) {
  36180. this._deviceRoomRotationQuaternion.copyFromFloats(pose.orientation[0], pose.orientation[1], -pose.orientation[2], -pose.orientation[3]);
  36181. if (this._mesh) {
  36182. if (this._mesh.getScene().useRightHandedSystem) {
  36183. this._deviceRoomRotationQuaternion.z *= -1;
  36184. this._deviceRoomRotationQuaternion.w *= -1;
  36185. }
  36186. else {
  36187. this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion, this._deviceRoomRotationQuaternion);
  36188. }
  36189. }
  36190. // if the camera is set, rotate to the camera's rotation
  36191. this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion, this._calculatedRotation);
  36192. }
  36193. }
  36194. };
  36195. /**
  36196. * Attaches a mesh to the controller
  36197. * @param mesh the mesh to be attached
  36198. */
  36199. PoseEnabledController.prototype.attachToMesh = function (mesh) {
  36200. if (this._mesh) {
  36201. this._mesh.parent = null;
  36202. }
  36203. this._mesh = mesh;
  36204. if (this._poseControlledCamera) {
  36205. this._mesh.parent = this._poseControlledCamera;
  36206. }
  36207. if (!this._mesh.rotationQuaternion) {
  36208. this._mesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36209. }
  36210. // 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
  36211. this._updatePoseAndMesh();
  36212. if (this._pointingPoseNode) {
  36213. var parents = [];
  36214. var obj = this._pointingPoseNode;
  36215. while (obj.parent) {
  36216. parents.push(obj.parent);
  36217. obj = obj.parent;
  36218. }
  36219. parents.reverse().forEach(function (p) { p.computeWorldMatrix(true); });
  36220. }
  36221. this._meshAttachedObservable.notifyObservers(mesh);
  36222. };
  36223. /**
  36224. * Attaches the controllers mesh to a camera
  36225. * @param camera the camera the mesh should be attached to
  36226. */
  36227. PoseEnabledController.prototype.attachToPoseControlledCamera = function (camera) {
  36228. this._poseControlledCamera = camera;
  36229. if (this._mesh) {
  36230. this._mesh.parent = this._poseControlledCamera;
  36231. }
  36232. };
  36233. /**
  36234. * Disposes of the controller
  36235. */
  36236. PoseEnabledController.prototype.dispose = function () {
  36237. if (this._mesh) {
  36238. this._mesh.dispose();
  36239. }
  36240. this._mesh = null;
  36241. _super.prototype.dispose.call(this);
  36242. };
  36243. Object.defineProperty(PoseEnabledController.prototype, "mesh", {
  36244. /**
  36245. * The mesh that is attached to the controller
  36246. */
  36247. get: function () {
  36248. return this._mesh;
  36249. },
  36250. enumerable: true,
  36251. configurable: true
  36252. });
  36253. /**
  36254. * Gets the ray of the controller in the direction the controller is pointing
  36255. * @param length the length the resulting ray should be
  36256. * @returns a ray in the direction the controller is pointing
  36257. */
  36258. PoseEnabledController.prototype.getForwardRay = function (length) {
  36259. if (length === void 0) { length = 100; }
  36260. if (!this.mesh) {
  36261. 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);
  36262. }
  36263. var m = this._pointingPoseNode ? this._pointingPoseNode.getWorldMatrix() : this.mesh.getWorldMatrix();
  36264. var origin = m.getTranslation();
  36265. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, -1);
  36266. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(forward, m);
  36267. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(forwardWorld);
  36268. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](origin, direction, length);
  36269. };
  36270. /**
  36271. * Name of the child mesh that can be used to cast a ray from the controller
  36272. */
  36273. PoseEnabledController.POINTING_POSE = "POINTING_POSE";
  36274. return PoseEnabledController;
  36275. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"]));
  36276. /***/ }),
  36277. /***/ "./Gamepads/Controllers/viveController.ts":
  36278. /*!************************************************!*\
  36279. !*** ./Gamepads/Controllers/viveController.ts ***!
  36280. \************************************************/
  36281. /*! exports provided: ViveController */
  36282. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36283. "use strict";
  36284. __webpack_require__.r(__webpack_exports__);
  36285. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return ViveController; });
  36286. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36287. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  36288. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  36289. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36290. /**
  36291. * Vive Controller
  36292. */
  36293. var ViveController = /** @class */ (function (_super) {
  36294. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ViveController, _super);
  36295. /**
  36296. * Creates a new ViveController from a gamepad
  36297. * @param vrGamepad the gamepad that the controller should be created from
  36298. */
  36299. function ViveController(vrGamepad) {
  36300. var _this = _super.call(this, vrGamepad) || this;
  36301. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerType"].VIVE;
  36302. _this._invertLeftStickY = true;
  36303. return _this;
  36304. }
  36305. /**
  36306. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  36307. * @param scene scene in which to add meshes
  36308. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  36309. */
  36310. ViveController.prototype.initControllerMesh = function (scene, meshLoaded) {
  36311. var _this = this;
  36312. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", ViveController.MODEL_BASE_URL, ViveController.MODEL_FILENAME, scene, function (newMeshes) {
  36313. /*
  36314. Parent Mesh name: ViveWand
  36315. - body
  36316. - r_gripper
  36317. - l_gripper
  36318. - menu_button
  36319. - system_button
  36320. - trackpad
  36321. - trigger
  36322. - LED
  36323. */
  36324. _this._defaultModel = newMeshes[1];
  36325. _this.attachToMesh(_this._defaultModel);
  36326. if (meshLoaded) {
  36327. meshLoaded(_this._defaultModel);
  36328. }
  36329. });
  36330. };
  36331. Object.defineProperty(ViveController.prototype, "onLeftButtonStateChangedObservable", {
  36332. /**
  36333. * Fired when the left button on this controller is modified
  36334. */
  36335. get: function () {
  36336. return this.onMainButtonStateChangedObservable;
  36337. },
  36338. enumerable: true,
  36339. configurable: true
  36340. });
  36341. Object.defineProperty(ViveController.prototype, "onRightButtonStateChangedObservable", {
  36342. /**
  36343. * Fired when the right button on this controller is modified
  36344. */
  36345. get: function () {
  36346. return this.onMainButtonStateChangedObservable;
  36347. },
  36348. enumerable: true,
  36349. configurable: true
  36350. });
  36351. Object.defineProperty(ViveController.prototype, "onMenuButtonStateChangedObservable", {
  36352. /**
  36353. * Fired when the menu button on this controller is modified
  36354. */
  36355. get: function () {
  36356. return this.onSecondaryButtonStateChangedObservable;
  36357. },
  36358. enumerable: true,
  36359. configurable: true
  36360. });
  36361. /**
  36362. * Called once for each button that changed state since the last frame
  36363. * Vive mapping:
  36364. * 0: touchpad
  36365. * 1: trigger
  36366. * 2: left AND right buttons
  36367. * 3: menu button
  36368. * @param buttonIdx Which button index changed
  36369. * @param state New state of the button
  36370. * @param changes Which properties on the state changed since last frame
  36371. */
  36372. ViveController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  36373. var notifyObject = state; //{ state: state, changes: changes };
  36374. switch (buttonIdx) {
  36375. case 0:
  36376. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  36377. return;
  36378. case 1: // index trigger
  36379. if (this._defaultModel) {
  36380. (this._defaultModel.getChildren()[6]).rotation.x = -notifyObject.value * 0.15;
  36381. }
  36382. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  36383. return;
  36384. case 2: // left AND right button
  36385. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  36386. return;
  36387. case 3:
  36388. if (this._defaultModel) {
  36389. if (notifyObject.pressed) {
  36390. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  36391. }
  36392. else {
  36393. (this._defaultModel.getChildren()[2]).position.y = 0;
  36394. }
  36395. }
  36396. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  36397. return;
  36398. }
  36399. };
  36400. /**
  36401. * Base Url for the controller model.
  36402. */
  36403. ViveController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/vive/';
  36404. /**
  36405. * File name for the controller model.
  36406. */
  36407. ViveController.MODEL_FILENAME = 'wand.babylon';
  36408. return ViveController;
  36409. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  36410. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  36411. canCreate: function (gamepadInfo) {
  36412. return gamepadInfo.id.toLowerCase().indexOf('openvr') !== -1;
  36413. },
  36414. create: function (gamepadInfo) {
  36415. return new ViveController(gamepadInfo);
  36416. }
  36417. });
  36418. /***/ }),
  36419. /***/ "./Gamepads/Controllers/webVRController.ts":
  36420. /*!*************************************************!*\
  36421. !*** ./Gamepads/Controllers/webVRController.ts ***!
  36422. \*************************************************/
  36423. /*! exports provided: WebVRController */
  36424. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36425. "use strict";
  36426. __webpack_require__.r(__webpack_exports__);
  36427. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return WebVRController; });
  36428. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36429. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  36430. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36431. /**
  36432. * Defines the WebVRController object that represents controllers tracked in 3D space
  36433. */
  36434. var WebVRController = /** @class */ (function (_super) {
  36435. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRController, _super);
  36436. /**
  36437. * Creates a new WebVRController from a gamepad
  36438. * @param vrGamepad the gamepad that the WebVRController should be created from
  36439. */
  36440. function WebVRController(vrGamepad) {
  36441. var _this = _super.call(this, vrGamepad) || this;
  36442. // Observables
  36443. /**
  36444. * Fired when the trigger state has changed
  36445. */
  36446. _this.onTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36447. /**
  36448. * Fired when the main button state has changed
  36449. */
  36450. _this.onMainButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36451. /**
  36452. * Fired when the secondary button state has changed
  36453. */
  36454. _this.onSecondaryButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36455. /**
  36456. * Fired when the pad state has changed
  36457. */
  36458. _this.onPadStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36459. /**
  36460. * Fired when controllers stick values have changed
  36461. */
  36462. _this.onPadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36463. /**
  36464. * X and Y axis corrisponding to the controllers joystick
  36465. */
  36466. _this.pad = { x: 0, y: 0 };
  36467. // avoid GC, store state in a tmp object
  36468. _this._changes = {
  36469. pressChanged: false,
  36470. touchChanged: false,
  36471. valueChanged: false,
  36472. changed: false
  36473. };
  36474. _this._buttons = new Array(vrGamepad.buttons.length);
  36475. _this.hand = vrGamepad.hand;
  36476. return _this;
  36477. }
  36478. /**
  36479. * Fired when a controller button's state has changed
  36480. * @param callback the callback containing the button that was modified
  36481. */
  36482. WebVRController.prototype.onButtonStateChange = function (callback) {
  36483. this._onButtonStateChange = callback;
  36484. };
  36485. Object.defineProperty(WebVRController.prototype, "defaultModel", {
  36486. /**
  36487. * The default controller model for the controller
  36488. */
  36489. get: function () {
  36490. return this._defaultModel;
  36491. },
  36492. enumerable: true,
  36493. configurable: true
  36494. });
  36495. /**
  36496. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  36497. */
  36498. WebVRController.prototype.update = function () {
  36499. _super.prototype.update.call(this);
  36500. for (var index = 0; index < this._buttons.length; index++) {
  36501. this._setButtonValue(this.browserGamepad.buttons[index], this._buttons[index], index);
  36502. }
  36503. if (this.leftStick.x !== this.pad.x || this.leftStick.y !== this.pad.y) {
  36504. this.pad.x = this.leftStick.x;
  36505. this.pad.y = this.leftStick.y;
  36506. this.onPadValuesChangedObservable.notifyObservers(this.pad);
  36507. }
  36508. };
  36509. WebVRController.prototype._setButtonValue = function (newState, currentState, buttonIndex) {
  36510. if (!newState) {
  36511. newState = {
  36512. pressed: false,
  36513. touched: false,
  36514. value: 0
  36515. };
  36516. }
  36517. if (!currentState) {
  36518. this._buttons[buttonIndex] = {
  36519. pressed: newState.pressed,
  36520. touched: newState.touched,
  36521. value: newState.value
  36522. };
  36523. return;
  36524. }
  36525. this._checkChanges(newState, currentState);
  36526. if (this._changes.changed) {
  36527. this._onButtonStateChange && this._onButtonStateChange(this.index, buttonIndex, newState);
  36528. this._handleButtonChange(buttonIndex, newState, this._changes);
  36529. }
  36530. this._buttons[buttonIndex].pressed = newState.pressed;
  36531. this._buttons[buttonIndex].touched = newState.touched;
  36532. // oculus triggers are never 0, thou not touched.
  36533. this._buttons[buttonIndex].value = newState.value < 0.00000001 ? 0 : newState.value;
  36534. };
  36535. WebVRController.prototype._checkChanges = function (newState, currentState) {
  36536. this._changes.pressChanged = newState.pressed !== currentState.pressed;
  36537. this._changes.touchChanged = newState.touched !== currentState.touched;
  36538. this._changes.valueChanged = newState.value !== currentState.value;
  36539. this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged;
  36540. return this._changes;
  36541. };
  36542. /**
  36543. * Disposes of th webVRCOntroller
  36544. */
  36545. WebVRController.prototype.dispose = function () {
  36546. _super.prototype.dispose.call(this);
  36547. this.onTriggerStateChangedObservable.clear();
  36548. this.onMainButtonStateChangedObservable.clear();
  36549. this.onSecondaryButtonStateChangedObservable.clear();
  36550. this.onPadStateChangedObservable.clear();
  36551. this.onPadValuesChangedObservable.clear();
  36552. };
  36553. return WebVRController;
  36554. }(_poseEnabledController__WEBPACK_IMPORTED_MODULE_2__["PoseEnabledController"]));
  36555. /***/ }),
  36556. /***/ "./Gamepads/Controllers/windowsMotionController.ts":
  36557. /*!*********************************************************!*\
  36558. !*** ./Gamepads/Controllers/windowsMotionController.ts ***!
  36559. \*********************************************************/
  36560. /*! exports provided: WindowsMotionController */
  36561. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36562. "use strict";
  36563. __webpack_require__.r(__webpack_exports__);
  36564. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return WindowsMotionController; });
  36565. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36566. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  36567. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  36568. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  36569. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  36570. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  36571. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  36572. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  36573. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  36574. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36575. /**
  36576. * Defines the LoadedMeshInfo object that describes information about the loaded webVR controller mesh
  36577. */
  36578. var LoadedMeshInfo = /** @class */ (function () {
  36579. function LoadedMeshInfo() {
  36580. /**
  36581. * Map of the button meshes contained in the controller
  36582. */
  36583. this.buttonMeshes = {};
  36584. /**
  36585. * Map of the axis meshes contained in the controller
  36586. */
  36587. this.axisMeshes = {};
  36588. }
  36589. return LoadedMeshInfo;
  36590. }());
  36591. /**
  36592. * Defines the WindowsMotionController object that the state of the windows motion controller
  36593. */
  36594. var WindowsMotionController = /** @class */ (function (_super) {
  36595. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WindowsMotionController, _super);
  36596. /**
  36597. * Creates a new WindowsMotionController from a gamepad
  36598. * @param vrGamepad the gamepad that the controller should be created from
  36599. */
  36600. function WindowsMotionController(vrGamepad) {
  36601. var _this = _super.call(this, vrGamepad) || this;
  36602. _this._mapping = {
  36603. // Semantic button names
  36604. buttons: ['thumbstick', 'trigger', 'grip', 'menu', 'trackpad'],
  36605. // A mapping of the button name to glTF model node name
  36606. // that should be transformed by button value.
  36607. buttonMeshNames: {
  36608. 'trigger': 'SELECT',
  36609. 'menu': 'MENU',
  36610. 'grip': 'GRASP',
  36611. 'thumbstick': 'THUMBSTICK_PRESS',
  36612. 'trackpad': 'TOUCHPAD_PRESS'
  36613. },
  36614. // This mapping is used to translate from the Motion Controller to Babylon semantics
  36615. buttonObservableNames: {
  36616. 'trigger': 'onTriggerStateChangedObservable',
  36617. 'menu': 'onSecondaryButtonStateChangedObservable',
  36618. 'grip': 'onMainButtonStateChangedObservable',
  36619. 'thumbstick': 'onPadStateChangedObservable',
  36620. 'trackpad': 'onTrackpadChangedObservable'
  36621. },
  36622. // A mapping of the axis name to glTF model node name
  36623. // that should be transformed by axis value.
  36624. // This array mirrors the browserGamepad.axes array, such that
  36625. // the mesh corresponding to axis 0 is in this array index 0.
  36626. axisMeshNames: [
  36627. 'THUMBSTICK_X',
  36628. 'THUMBSTICK_Y',
  36629. 'TOUCHPAD_TOUCH_X',
  36630. 'TOUCHPAD_TOUCH_Y'
  36631. ],
  36632. pointingPoseMeshName: _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledController"].POINTING_POSE
  36633. };
  36634. /**
  36635. * Fired when the trackpad on this controller is clicked
  36636. */
  36637. _this.onTrackpadChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  36638. /**
  36639. * Fired when the trackpad on this controller is modified
  36640. */
  36641. _this.onTrackpadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  36642. /**
  36643. * The current x and y values of this controller's trackpad
  36644. */
  36645. _this.trackpad = { x: 0, y: 0 };
  36646. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerType"].WINDOWS;
  36647. _this._loadedMeshInfo = null;
  36648. return _this;
  36649. }
  36650. Object.defineProperty(WindowsMotionController.prototype, "onTriggerButtonStateChangedObservable", {
  36651. /**
  36652. * Fired when the trigger on this controller is modified
  36653. */
  36654. get: function () {
  36655. return this.onTriggerStateChangedObservable;
  36656. },
  36657. enumerable: true,
  36658. configurable: true
  36659. });
  36660. Object.defineProperty(WindowsMotionController.prototype, "onMenuButtonStateChangedObservable", {
  36661. /**
  36662. * Fired when the menu button on this controller is modified
  36663. */
  36664. get: function () {
  36665. return this.onSecondaryButtonStateChangedObservable;
  36666. },
  36667. enumerable: true,
  36668. configurable: true
  36669. });
  36670. Object.defineProperty(WindowsMotionController.prototype, "onGripButtonStateChangedObservable", {
  36671. /**
  36672. * Fired when the grip button on this controller is modified
  36673. */
  36674. get: function () {
  36675. return this.onMainButtonStateChangedObservable;
  36676. },
  36677. enumerable: true,
  36678. configurable: true
  36679. });
  36680. Object.defineProperty(WindowsMotionController.prototype, "onThumbstickButtonStateChangedObservable", {
  36681. /**
  36682. * Fired when the thumbstick button on this controller is modified
  36683. */
  36684. get: function () {
  36685. return this.onPadStateChangedObservable;
  36686. },
  36687. enumerable: true,
  36688. configurable: true
  36689. });
  36690. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadButtonStateChangedObservable", {
  36691. /**
  36692. * Fired when the touchpad button on this controller is modified
  36693. */
  36694. get: function () {
  36695. return this.onTrackpadChangedObservable;
  36696. },
  36697. enumerable: true,
  36698. configurable: true
  36699. });
  36700. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadValuesChangedObservable", {
  36701. /**
  36702. * Fired when the touchpad values on this controller are modified
  36703. */
  36704. get: function () {
  36705. return this.onTrackpadValuesChangedObservable;
  36706. },
  36707. enumerable: true,
  36708. configurable: true
  36709. });
  36710. WindowsMotionController.prototype._updateTrackpad = function () {
  36711. if (this.browserGamepad.axes && (this.browserGamepad.axes[2] != this.trackpad.x || this.browserGamepad.axes[3] != this.trackpad.y)) {
  36712. this.trackpad.x = this.browserGamepad["axes"][2];
  36713. this.trackpad.y = this.browserGamepad["axes"][3];
  36714. this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad);
  36715. }
  36716. };
  36717. /**
  36718. * Called once per frame by the engine.
  36719. */
  36720. WindowsMotionController.prototype.update = function () {
  36721. _super.prototype.update.call(this);
  36722. if (this.browserGamepad.axes) {
  36723. this._updateTrackpad();
  36724. // Only need to animate axes if there is a loaded mesh
  36725. if (this._loadedMeshInfo) {
  36726. for (var axis = 0; axis < this._mapping.axisMeshNames.length; axis++) {
  36727. this._lerpAxisTransform(axis, this.browserGamepad.axes[axis]);
  36728. }
  36729. }
  36730. }
  36731. };
  36732. /**
  36733. * Called once for each button that changed state since the last frame
  36734. * @param buttonIdx Which button index changed
  36735. * @param state New state of the button
  36736. * @param changes Which properties on the state changed since last frame
  36737. */
  36738. WindowsMotionController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  36739. var buttonName = this._mapping.buttons[buttonIdx];
  36740. if (!buttonName) {
  36741. return;
  36742. }
  36743. // Update the trackpad to ensure trackpad.x/y are accurate during button events between frames
  36744. this._updateTrackpad();
  36745. // Only emit events for buttons that we know how to map from index to name
  36746. var observable = this[(this._mapping.buttonObservableNames)[buttonName]];
  36747. if (observable) {
  36748. observable.notifyObservers(state);
  36749. }
  36750. this._lerpButtonTransform(buttonName, state.value);
  36751. };
  36752. /**
  36753. * Moves the buttons on the controller mesh based on their current state
  36754. * @param buttonName the name of the button to move
  36755. * @param buttonValue the value of the button which determines the buttons new position
  36756. */
  36757. WindowsMotionController.prototype._lerpButtonTransform = function (buttonName, buttonValue) {
  36758. // If there is no loaded mesh, there is nothing to transform.
  36759. if (!this._loadedMeshInfo) {
  36760. return;
  36761. }
  36762. var meshInfo = this._loadedMeshInfo.buttonMeshes[buttonName];
  36763. if (!meshInfo.unpressed.rotationQuaternion || !meshInfo.pressed.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  36764. return;
  36765. }
  36766. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.unpressed.rotationQuaternion, meshInfo.pressed.rotationQuaternion, buttonValue, meshInfo.value.rotationQuaternion);
  36767. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.unpressed.position, meshInfo.pressed.position, buttonValue, meshInfo.value.position);
  36768. };
  36769. /**
  36770. * Moves the axis on the controller mesh based on its current state
  36771. * @param axis the index of the axis
  36772. * @param axisValue the value of the axis which determines the meshes new position
  36773. * @hidden
  36774. */
  36775. WindowsMotionController.prototype._lerpAxisTransform = function (axis, axisValue) {
  36776. if (!this._loadedMeshInfo) {
  36777. return;
  36778. }
  36779. var meshInfo = this._loadedMeshInfo.axisMeshes[axis];
  36780. if (!meshInfo) {
  36781. return;
  36782. }
  36783. if (!meshInfo.min.rotationQuaternion || !meshInfo.max.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  36784. return;
  36785. }
  36786. // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)
  36787. var lerpValue = axisValue * 0.5 + 0.5;
  36788. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.min.rotationQuaternion, meshInfo.max.rotationQuaternion, lerpValue, meshInfo.value.rotationQuaternion);
  36789. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.min.position, meshInfo.max.position, lerpValue, meshInfo.value.position);
  36790. };
  36791. /**
  36792. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  36793. * @param scene scene in which to add meshes
  36794. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  36795. */
  36796. WindowsMotionController.prototype.initControllerMesh = function (scene, meshLoaded, forceDefault) {
  36797. var _this = this;
  36798. if (forceDefault === void 0) { forceDefault = false; }
  36799. var path;
  36800. var filename;
  36801. // Checking if GLB loader is present
  36802. if (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].IsPluginForExtensionAvailable(".glb")) {
  36803. // Determine the device specific folder based on the ID suffix
  36804. var device = 'default';
  36805. if (this.id && !forceDefault) {
  36806. var match = this.id.match(WindowsMotionController.GAMEPAD_ID_PATTERN);
  36807. device = ((match && match[0]) || device);
  36808. }
  36809. // Hand
  36810. if (this.hand === 'left') {
  36811. filename = WindowsMotionController.MODEL_LEFT_FILENAME;
  36812. }
  36813. else { // Right is the default if no hand is specified
  36814. filename = WindowsMotionController.MODEL_RIGHT_FILENAME;
  36815. }
  36816. path = WindowsMotionController.MODEL_BASE_URL + device + '/';
  36817. }
  36818. else {
  36819. _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");
  36820. path = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_BASE_URL;
  36821. filename = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_FILENAME;
  36822. }
  36823. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].ImportMesh("", path, filename, scene, function (meshes) {
  36824. // glTF files successfully loaded from the remote server, now process them to ensure they are in the right format.
  36825. _this._loadedMeshInfo = _this.processModel(scene, meshes);
  36826. if (!_this._loadedMeshInfo) {
  36827. return;
  36828. }
  36829. _this._defaultModel = _this._loadedMeshInfo.rootNode;
  36830. _this.attachToMesh(_this._defaultModel);
  36831. if (meshLoaded) {
  36832. meshLoaded(_this._defaultModel);
  36833. }
  36834. }, null, function (scene, message) {
  36835. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log(message);
  36836. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Failed to retrieve controller model from the remote server: ' + path + filename);
  36837. if (!forceDefault) {
  36838. _this.initControllerMesh(scene, meshLoaded, true);
  36839. }
  36840. });
  36841. };
  36842. /**
  36843. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  36844. * can be transformed by button presses and axes values, based on this._mapping.
  36845. *
  36846. * @param scene scene in which the meshes exist
  36847. * @param meshes list of meshes that make up the controller model to process
  36848. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  36849. */
  36850. WindowsMotionController.prototype.processModel = function (scene, meshes) {
  36851. var loadedMeshInfo = null;
  36852. // Create a new mesh to contain the glTF hierarchy
  36853. var parentMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this.id + " " + this.hand, scene);
  36854. // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'
  36855. var childMesh = null;
  36856. for (var i = 0; i < meshes.length; i++) {
  36857. var mesh = meshes[i];
  36858. if (!mesh.parent) {
  36859. // Exclude controller meshes from picking results
  36860. mesh.isPickable = false;
  36861. // Handle root node, attach to the new parentMesh
  36862. childMesh = mesh;
  36863. break;
  36864. }
  36865. }
  36866. if (childMesh) {
  36867. childMesh.setParent(parentMesh);
  36868. // Create our mesh info. Note that this method will always return non-null.
  36869. loadedMeshInfo = this.createMeshInfo(parentMesh);
  36870. }
  36871. else {
  36872. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Could not find root node in model file.');
  36873. }
  36874. return loadedMeshInfo;
  36875. };
  36876. WindowsMotionController.prototype.createMeshInfo = function (rootNode) {
  36877. var loadedMeshInfo = new LoadedMeshInfo();
  36878. var i;
  36879. loadedMeshInfo.rootNode = rootNode;
  36880. // Reset the caches
  36881. loadedMeshInfo.buttonMeshes = {};
  36882. loadedMeshInfo.axisMeshes = {};
  36883. // Button Meshes
  36884. for (i = 0; i < this._mapping.buttons.length; i++) {
  36885. var buttonMeshName = this._mapping.buttonMeshNames[this._mapping.buttons[i]];
  36886. if (!buttonMeshName) {
  36887. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown button at index: ' + i + ' with mapped name: ' + this._mapping.buttons[i]);
  36888. continue;
  36889. }
  36890. var buttonMesh = getChildByName(rootNode, buttonMeshName);
  36891. if (!buttonMesh) {
  36892. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button mesh with name: ' + buttonMeshName);
  36893. continue;
  36894. }
  36895. var buttonMeshInfo = {
  36896. index: i,
  36897. value: getImmediateChildByName(buttonMesh, 'VALUE'),
  36898. pressed: getImmediateChildByName(buttonMesh, 'PRESSED'),
  36899. unpressed: getImmediateChildByName(buttonMesh, 'UNPRESSED')
  36900. };
  36901. if (buttonMeshInfo.value && buttonMeshInfo.pressed && buttonMeshInfo.unpressed) {
  36902. loadedMeshInfo.buttonMeshes[this._mapping.buttons[i]] = buttonMeshInfo;
  36903. }
  36904. else {
  36905. // If we didn't find the mesh, it simply means this button won't have transforms applied as mapped button value changes.
  36906. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button submesh under mesh with name: ' + buttonMeshName +
  36907. '(VALUE: ' + !!buttonMeshInfo.value +
  36908. ', PRESSED: ' + !!buttonMeshInfo.pressed +
  36909. ', UNPRESSED:' + !!buttonMeshInfo.unpressed +
  36910. ')');
  36911. }
  36912. }
  36913. // Axis Meshes
  36914. for (i = 0; i < this._mapping.axisMeshNames.length; i++) {
  36915. var axisMeshName = this._mapping.axisMeshNames[i];
  36916. if (!axisMeshName) {
  36917. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown axis at index: ' + i);
  36918. continue;
  36919. }
  36920. var axisMesh = getChildByName(rootNode, axisMeshName);
  36921. if (!axisMesh) {
  36922. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis mesh with name: ' + axisMeshName);
  36923. continue;
  36924. }
  36925. var axisMeshInfo = {
  36926. index: i,
  36927. value: getImmediateChildByName(axisMesh, 'VALUE'),
  36928. min: getImmediateChildByName(axisMesh, 'MIN'),
  36929. max: getImmediateChildByName(axisMesh, 'MAX')
  36930. };
  36931. if (axisMeshInfo.value && axisMeshInfo.min && axisMeshInfo.max) {
  36932. loadedMeshInfo.axisMeshes[i] = axisMeshInfo;
  36933. }
  36934. else {
  36935. // If we didn't find the mesh, it simply means thit axis won't have transforms applied as mapped axis values change.
  36936. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis submesh under mesh with name: ' + axisMeshName +
  36937. '(VALUE: ' + !!axisMeshInfo.value +
  36938. ', MIN: ' + !!axisMeshInfo.min +
  36939. ', MAX:' + !!axisMeshInfo.max +
  36940. ')');
  36941. }
  36942. }
  36943. // Pointing Ray
  36944. loadedMeshInfo.pointingPoseNode = getChildByName(rootNode, this._mapping.pointingPoseMeshName);
  36945. if (!loadedMeshInfo.pointingPoseNode) {
  36946. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing pointing pose mesh with name: ' + this._mapping.pointingPoseMeshName);
  36947. }
  36948. else {
  36949. this._pointingPoseNode = loadedMeshInfo.pointingPoseNode;
  36950. }
  36951. return loadedMeshInfo;
  36952. // Look through all children recursively. This will return null if no mesh exists with the given name.
  36953. function getChildByName(node, name) {
  36954. return node.getChildren(function (n) { return n.name === name; }, false)[0];
  36955. }
  36956. // Look through only immediate children. This will return null if no mesh exists with the given name.
  36957. function getImmediateChildByName(node, name) {
  36958. return node.getChildren(function (n) { return n.name == name; }, true)[0];
  36959. }
  36960. };
  36961. /**
  36962. * Gets the ray of the controller in the direction the controller is pointing
  36963. * @param length the length the resulting ray should be
  36964. * @returns a ray in the direction the controller is pointing
  36965. */
  36966. WindowsMotionController.prototype.getForwardRay = function (length) {
  36967. if (length === void 0) { length = 100; }
  36968. if (!(this._loadedMeshInfo && this._loadedMeshInfo.pointingPoseNode)) {
  36969. return _super.prototype.getForwardRay.call(this, length);
  36970. }
  36971. var m = this._loadedMeshInfo.pointingPoseNode.getWorldMatrix();
  36972. var origin = m.getTranslation();
  36973. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  36974. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(forward, m);
  36975. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(forwardWorld);
  36976. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](origin, direction, length);
  36977. };
  36978. /**
  36979. * Disposes of the controller
  36980. */
  36981. WindowsMotionController.prototype.dispose = function () {
  36982. _super.prototype.dispose.call(this);
  36983. this.onTrackpadChangedObservable.clear();
  36984. };
  36985. /**
  36986. * The base url used to load the left and right controller models
  36987. */
  36988. WindowsMotionController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/microsoft/';
  36989. /**
  36990. * The name of the left controller model file
  36991. */
  36992. WindowsMotionController.MODEL_LEFT_FILENAME = 'left.glb';
  36993. /**
  36994. * The name of the right controller model file
  36995. */
  36996. WindowsMotionController.MODEL_RIGHT_FILENAME = 'right.glb';
  36997. /**
  36998. * The controller name prefix for this controller type
  36999. */
  37000. WindowsMotionController.GAMEPAD_ID_PREFIX = 'Spatial Controller (Spatial Interaction Source) ';
  37001. /**
  37002. * The controller id pattern for this controller type
  37003. */
  37004. WindowsMotionController.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;
  37005. return WindowsMotionController;
  37006. }(_webVRController__WEBPACK_IMPORTED_MODULE_7__["WebVRController"]));
  37007. _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  37008. canCreate: function (gamepadInfo) {
  37009. return gamepadInfo.id.indexOf(WindowsMotionController.GAMEPAD_ID_PREFIX) === 0;
  37010. },
  37011. create: function (gamepadInfo) {
  37012. return new WindowsMotionController(gamepadInfo);
  37013. }
  37014. });
  37015. /***/ }),
  37016. /***/ "./Gamepads/gamepad.ts":
  37017. /*!*****************************!*\
  37018. !*** ./Gamepads/gamepad.ts ***!
  37019. \*****************************/
  37020. /*! exports provided: StickValues, Gamepad, GenericPad */
  37021. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37022. "use strict";
  37023. __webpack_require__.r(__webpack_exports__);
  37024. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return StickValues; });
  37025. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return Gamepad; });
  37026. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return GenericPad; });
  37027. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37028. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37029. /**
  37030. * Represents a gamepad control stick position
  37031. */
  37032. var StickValues = /** @class */ (function () {
  37033. /**
  37034. * Initializes the gamepad x and y control stick values
  37035. * @param x The x component of the gamepad control stick value
  37036. * @param y The y component of the gamepad control stick value
  37037. */
  37038. function StickValues(
  37039. /**
  37040. * The x component of the control stick
  37041. */
  37042. x,
  37043. /**
  37044. * The y component of the control stick
  37045. */
  37046. y) {
  37047. this.x = x;
  37048. this.y = y;
  37049. }
  37050. return StickValues;
  37051. }());
  37052. /**
  37053. * Represents a gamepad
  37054. */
  37055. var Gamepad = /** @class */ (function () {
  37056. /**
  37057. * Initializes the gamepad
  37058. * @param id The id of the gamepad
  37059. * @param index The index of the gamepad
  37060. * @param browserGamepad The browser gamepad
  37061. * @param leftStickX The x component of the left joystick
  37062. * @param leftStickY The y component of the left joystick
  37063. * @param rightStickX The x component of the right joystick
  37064. * @param rightStickY The y component of the right joystick
  37065. */
  37066. function Gamepad(
  37067. /**
  37068. * The id of the gamepad
  37069. */
  37070. id,
  37071. /**
  37072. * The index of the gamepad
  37073. */
  37074. index,
  37075. /**
  37076. * The browser gamepad
  37077. */
  37078. browserGamepad, leftStickX, leftStickY, rightStickX, rightStickY) {
  37079. if (leftStickX === void 0) { leftStickX = 0; }
  37080. if (leftStickY === void 0) { leftStickY = 1; }
  37081. if (rightStickX === void 0) { rightStickX = 2; }
  37082. if (rightStickY === void 0) { rightStickY = 3; }
  37083. this.id = id;
  37084. this.index = index;
  37085. this.browserGamepad = browserGamepad;
  37086. this._leftStick = { x: 0, y: 0 };
  37087. this._rightStick = { x: 0, y: 0 };
  37088. /** @hidden */
  37089. this._isConnected = true;
  37090. /**
  37091. * Specifies whether the left control stick should be Y-inverted
  37092. */
  37093. this._invertLeftStickY = false;
  37094. this.type = Gamepad.GAMEPAD;
  37095. this._leftStickAxisX = leftStickX;
  37096. this._leftStickAxisY = leftStickY;
  37097. this._rightStickAxisX = rightStickX;
  37098. this._rightStickAxisY = rightStickY;
  37099. if (this.browserGamepad.axes.length >= 2) {
  37100. this._leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  37101. }
  37102. if (this.browserGamepad.axes.length >= 4) {
  37103. this._rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  37104. }
  37105. }
  37106. Object.defineProperty(Gamepad.prototype, "isConnected", {
  37107. /**
  37108. * Specifies if the gamepad has been connected
  37109. */
  37110. get: function () {
  37111. return this._isConnected;
  37112. },
  37113. enumerable: true,
  37114. configurable: true
  37115. });
  37116. /**
  37117. * Callback triggered when the left joystick has changed
  37118. * @param callback
  37119. */
  37120. Gamepad.prototype.onleftstickchanged = function (callback) {
  37121. this._onleftstickchanged = callback;
  37122. };
  37123. /**
  37124. * Callback triggered when the right joystick has changed
  37125. * @param callback
  37126. */
  37127. Gamepad.prototype.onrightstickchanged = function (callback) {
  37128. this._onrightstickchanged = callback;
  37129. };
  37130. Object.defineProperty(Gamepad.prototype, "leftStick", {
  37131. /**
  37132. * Gets the left joystick
  37133. */
  37134. get: function () {
  37135. return this._leftStick;
  37136. },
  37137. /**
  37138. * Sets the left joystick values
  37139. */
  37140. set: function (newValues) {
  37141. if (this._onleftstickchanged && (this._leftStick.x !== newValues.x || this._leftStick.y !== newValues.y)) {
  37142. this._onleftstickchanged(newValues);
  37143. }
  37144. this._leftStick = newValues;
  37145. },
  37146. enumerable: true,
  37147. configurable: true
  37148. });
  37149. Object.defineProperty(Gamepad.prototype, "rightStick", {
  37150. /**
  37151. * Gets the right joystick
  37152. */
  37153. get: function () {
  37154. return this._rightStick;
  37155. },
  37156. /**
  37157. * Sets the right joystick value
  37158. */
  37159. set: function (newValues) {
  37160. if (this._onrightstickchanged && (this._rightStick.x !== newValues.x || this._rightStick.y !== newValues.y)) {
  37161. this._onrightstickchanged(newValues);
  37162. }
  37163. this._rightStick = newValues;
  37164. },
  37165. enumerable: true,
  37166. configurable: true
  37167. });
  37168. /**
  37169. * Updates the gamepad joystick positions
  37170. */
  37171. Gamepad.prototype.update = function () {
  37172. if (this._leftStick) {
  37173. this.leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  37174. if (this._invertLeftStickY) {
  37175. this.leftStick.y *= -1;
  37176. }
  37177. }
  37178. if (this._rightStick) {
  37179. this.rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  37180. }
  37181. };
  37182. /**
  37183. * Disposes the gamepad
  37184. */
  37185. Gamepad.prototype.dispose = function () {
  37186. };
  37187. /**
  37188. * Represents a gamepad controller
  37189. */
  37190. Gamepad.GAMEPAD = 0;
  37191. /**
  37192. * Represents a generic controller
  37193. */
  37194. Gamepad.GENERIC = 1;
  37195. /**
  37196. * Represents an XBox controller
  37197. */
  37198. Gamepad.XBOX = 2;
  37199. /**
  37200. * Represents a pose-enabled controller
  37201. */
  37202. Gamepad.POSE_ENABLED = 3;
  37203. return Gamepad;
  37204. }());
  37205. /**
  37206. * Represents a generic gamepad
  37207. */
  37208. var GenericPad = /** @class */ (function (_super) {
  37209. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericPad, _super);
  37210. /**
  37211. * Initializes the generic gamepad
  37212. * @param id The id of the generic gamepad
  37213. * @param index The index of the generic gamepad
  37214. * @param browserGamepad The browser gamepad
  37215. */
  37216. function GenericPad(id, index, browserGamepad) {
  37217. var _this = _super.call(this, id, index, browserGamepad) || this;
  37218. /**
  37219. * Observable triggered when a button has been pressed
  37220. */
  37221. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37222. /**
  37223. * Observable triggered when a button has been released
  37224. */
  37225. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37226. _this.type = Gamepad.GENERIC;
  37227. _this._buttons = new Array(browserGamepad.buttons.length);
  37228. return _this;
  37229. }
  37230. /**
  37231. * Callback triggered when a button has been pressed
  37232. * @param callback Called when a button has been pressed
  37233. */
  37234. GenericPad.prototype.onbuttondown = function (callback) {
  37235. this._onbuttondown = callback;
  37236. };
  37237. /**
  37238. * Callback triggered when a button has been released
  37239. * @param callback Called when a button has been released
  37240. */
  37241. GenericPad.prototype.onbuttonup = function (callback) {
  37242. this._onbuttonup = callback;
  37243. };
  37244. GenericPad.prototype._setButtonValue = function (newValue, currentValue, buttonIndex) {
  37245. if (newValue !== currentValue) {
  37246. if (newValue === 1) {
  37247. if (this._onbuttondown) {
  37248. this._onbuttondown(buttonIndex);
  37249. }
  37250. this.onButtonDownObservable.notifyObservers(buttonIndex);
  37251. }
  37252. if (newValue === 0) {
  37253. if (this._onbuttonup) {
  37254. this._onbuttonup(buttonIndex);
  37255. }
  37256. this.onButtonUpObservable.notifyObservers(buttonIndex);
  37257. }
  37258. }
  37259. return newValue;
  37260. };
  37261. /**
  37262. * Updates the generic gamepad
  37263. */
  37264. GenericPad.prototype.update = function () {
  37265. _super.prototype.update.call(this);
  37266. for (var index = 0; index < this._buttons.length; index++) {
  37267. this._buttons[index] = this._setButtonValue(this.browserGamepad.buttons[index].value, this._buttons[index], index);
  37268. }
  37269. };
  37270. /**
  37271. * Disposes the generic gamepad
  37272. */
  37273. GenericPad.prototype.dispose = function () {
  37274. _super.prototype.dispose.call(this);
  37275. this.onButtonDownObservable.clear();
  37276. this.onButtonUpObservable.clear();
  37277. };
  37278. return GenericPad;
  37279. }(Gamepad));
  37280. /***/ }),
  37281. /***/ "./Gamepads/gamepadManager.ts":
  37282. /*!************************************!*\
  37283. !*** ./Gamepads/gamepadManager.ts ***!
  37284. \************************************/
  37285. /*! exports provided: GamepadManager */
  37286. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37287. "use strict";
  37288. __webpack_require__.r(__webpack_exports__);
  37289. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return GamepadManager; });
  37290. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  37291. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37292. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  37293. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  37294. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  37295. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  37296. /**
  37297. * Manager for handling gamepads
  37298. */
  37299. var GamepadManager = /** @class */ (function () {
  37300. /**
  37301. * Initializes the gamepad manager
  37302. * @param _scene BabylonJS scene
  37303. */
  37304. function GamepadManager(_scene) {
  37305. var _this = this;
  37306. this._scene = _scene;
  37307. this._babylonGamepads = [];
  37308. this._oneGamepadConnected = false;
  37309. /** @hidden */
  37310. this._isMonitoring = false;
  37311. /**
  37312. * observable to be triggered when the gamepad controller has been disconnected
  37313. */
  37314. this.onGamepadDisconnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37315. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  37316. this._gamepadEventSupported = false;
  37317. }
  37318. else {
  37319. this._gamepadEventSupported = 'GamepadEvent' in window;
  37320. this._gamepadSupport = (navigator.getGamepads ||
  37321. navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads);
  37322. }
  37323. this.onGamepadConnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"](function (observer) {
  37324. // This will be used to raise the onGamepadConnected for all gamepads ALREADY connected
  37325. for (var i in _this._babylonGamepads) {
  37326. var gamepad = _this._babylonGamepads[i];
  37327. if (gamepad && gamepad._isConnected) {
  37328. _this.onGamepadConnectedObservable.notifyObserver(observer, gamepad);
  37329. }
  37330. }
  37331. });
  37332. this._onGamepadConnectedEvent = function (evt) {
  37333. var gamepad = evt.gamepad;
  37334. if (gamepad.index in _this._babylonGamepads) {
  37335. if (_this._babylonGamepads[gamepad.index].isConnected) {
  37336. return;
  37337. }
  37338. }
  37339. var newGamepad;
  37340. if (_this._babylonGamepads[gamepad.index]) {
  37341. newGamepad = _this._babylonGamepads[gamepad.index];
  37342. newGamepad.browserGamepad = gamepad;
  37343. newGamepad._isConnected = true;
  37344. }
  37345. else {
  37346. newGamepad = _this._addNewGamepad(gamepad);
  37347. }
  37348. _this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  37349. _this._startMonitoringGamepads();
  37350. };
  37351. this._onGamepadDisconnectedEvent = function (evt) {
  37352. var gamepad = evt.gamepad;
  37353. // Remove the gamepad from the list of gamepads to monitor.
  37354. for (var i in _this._babylonGamepads) {
  37355. if (_this._babylonGamepads[i].index === gamepad.index) {
  37356. var disconnectedGamepad = _this._babylonGamepads[i];
  37357. disconnectedGamepad._isConnected = false;
  37358. _this.onGamepadDisconnectedObservable.notifyObservers(disconnectedGamepad);
  37359. break;
  37360. }
  37361. }
  37362. };
  37363. if (this._gamepadSupport) {
  37364. //first add already-connected gamepads
  37365. this._updateGamepadObjects();
  37366. if (this._babylonGamepads.length) {
  37367. this._startMonitoringGamepads();
  37368. }
  37369. // Checking if the gamepad connected event is supported (like in Firefox)
  37370. if (this._gamepadEventSupported) {
  37371. window.addEventListener('gamepadconnected', this._onGamepadConnectedEvent, false);
  37372. window.addEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent, false);
  37373. }
  37374. else {
  37375. this._startMonitoringGamepads();
  37376. }
  37377. }
  37378. }
  37379. Object.defineProperty(GamepadManager.prototype, "gamepads", {
  37380. /**
  37381. * The gamepads in the game pad manager
  37382. */
  37383. get: function () {
  37384. return this._babylonGamepads;
  37385. },
  37386. enumerable: true,
  37387. configurable: true
  37388. });
  37389. /**
  37390. * Get the gamepad controllers based on type
  37391. * @param type The type of gamepad controller
  37392. * @returns Nullable gamepad
  37393. */
  37394. GamepadManager.prototype.getGamepadByType = function (type) {
  37395. if (type === void 0) { type = _gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].XBOX; }
  37396. for (var _i = 0, _a = this._babylonGamepads; _i < _a.length; _i++) {
  37397. var gamepad = _a[_i];
  37398. if (gamepad && gamepad.type === type) {
  37399. return gamepad;
  37400. }
  37401. }
  37402. return null;
  37403. };
  37404. /**
  37405. * Disposes the gamepad manager
  37406. */
  37407. GamepadManager.prototype.dispose = function () {
  37408. if (this._gamepadEventSupported) {
  37409. if (this._onGamepadConnectedEvent) {
  37410. window.removeEventListener('gamepadconnected', this._onGamepadConnectedEvent);
  37411. }
  37412. if (this._onGamepadDisconnectedEvent) {
  37413. window.removeEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent);
  37414. }
  37415. this._onGamepadConnectedEvent = null;
  37416. this._onGamepadDisconnectedEvent = null;
  37417. }
  37418. this._babylonGamepads.forEach(function (gamepad) {
  37419. gamepad.dispose();
  37420. });
  37421. this.onGamepadConnectedObservable.clear();
  37422. this.onGamepadDisconnectedObservable.clear();
  37423. this._oneGamepadConnected = false;
  37424. this._stopMonitoringGamepads();
  37425. this._babylonGamepads = [];
  37426. };
  37427. GamepadManager.prototype._addNewGamepad = function (gamepad) {
  37428. if (!this._oneGamepadConnected) {
  37429. this._oneGamepadConnected = true;
  37430. }
  37431. var newGamepad;
  37432. var xboxOne = (gamepad.id.search("Xbox One") !== -1);
  37433. if (xboxOne || gamepad.id.search("Xbox 360") !== -1 || gamepad.id.search("xinput") !== -1) {
  37434. newGamepad = new _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"](gamepad.id, gamepad.index, gamepad, xboxOne);
  37435. }
  37436. // if pose is supported, use the (WebVR) pose enabled controller
  37437. else if (gamepad.pose) {
  37438. newGamepad = _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"].InitiateController(gamepad);
  37439. }
  37440. else {
  37441. newGamepad = new _gamepad__WEBPACK_IMPORTED_MODULE_5__["GenericPad"](gamepad.id, gamepad.index, gamepad);
  37442. }
  37443. this._babylonGamepads[newGamepad.index] = newGamepad;
  37444. return newGamepad;
  37445. };
  37446. GamepadManager.prototype._startMonitoringGamepads = function () {
  37447. if (!this._isMonitoring) {
  37448. this._isMonitoring = true;
  37449. //back-comp
  37450. if (!this._scene) {
  37451. this._checkGamepadsStatus();
  37452. }
  37453. }
  37454. };
  37455. GamepadManager.prototype._stopMonitoringGamepads = function () {
  37456. this._isMonitoring = false;
  37457. };
  37458. /** @hidden */
  37459. GamepadManager.prototype._checkGamepadsStatus = function () {
  37460. var _this = this;
  37461. // Hack to be compatible Chrome
  37462. this._updateGamepadObjects();
  37463. for (var i in this._babylonGamepads) {
  37464. var gamepad = this._babylonGamepads[i];
  37465. if (!gamepad || !gamepad.isConnected) {
  37466. continue;
  37467. }
  37468. gamepad.update();
  37469. }
  37470. if (this._isMonitoring && !this._scene) {
  37471. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].QueueNewFrame(function () { _this._checkGamepadsStatus(); });
  37472. }
  37473. };
  37474. // This function is called only on Chrome, which does not properly support
  37475. // connection/disconnection events and forces you to recopy again the gamepad object
  37476. GamepadManager.prototype._updateGamepadObjects = function () {
  37477. var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);
  37478. for (var i = 0; i < gamepads.length; i++) {
  37479. var gamepad = gamepads[i];
  37480. if (gamepad) {
  37481. if (!this._babylonGamepads[gamepad.index]) {
  37482. var newGamepad = this._addNewGamepad(gamepad);
  37483. this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  37484. }
  37485. else {
  37486. // Forced to copy again this object for Chrome for unknown reason
  37487. this._babylonGamepads[i].browserGamepad = gamepad;
  37488. if (!this._babylonGamepads[i].isConnected) {
  37489. this._babylonGamepads[i]._isConnected = true;
  37490. this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[i]);
  37491. }
  37492. }
  37493. }
  37494. }
  37495. };
  37496. return GamepadManager;
  37497. }());
  37498. /***/ }),
  37499. /***/ "./Gamepads/gamepadSceneComponent.ts":
  37500. /*!*******************************************!*\
  37501. !*** ./Gamepads/gamepadSceneComponent.ts ***!
  37502. \*******************************************/
  37503. /*! exports provided: GamepadSystemSceneComponent */
  37504. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37505. "use strict";
  37506. __webpack_require__.r(__webpack_exports__);
  37507. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return GamepadSystemSceneComponent; });
  37508. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  37509. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  37510. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  37511. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  37512. /* harmony import */ var _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  37513. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  37514. /* harmony import */ var _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  37515. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "gamepadManager", {
  37516. get: function () {
  37517. if (!this._gamepadManager) {
  37518. this._gamepadManager = new _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"](this);
  37519. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD);
  37520. if (!component) {
  37521. component = new GamepadSystemSceneComponent(this);
  37522. this._addComponent(component);
  37523. }
  37524. }
  37525. return this._gamepadManager;
  37526. },
  37527. enumerable: true,
  37528. configurable: true
  37529. });
  37530. /**
  37531. * Adds a gamepad to the free camera inputs manager
  37532. */
  37533. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addGamepad = function () {
  37534. this.add(new _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraGamepadInput"]());
  37535. return this;
  37536. };
  37537. /**
  37538. * Adds a gamepad to the arc rotate camera inputs manager
  37539. */
  37540. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["ArcRotateCameraInputsManager"].prototype.addGamepad = function () {
  37541. this.add(new _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__["ArcRotateCameraGamepadInput"]());
  37542. return this;
  37543. };
  37544. /**
  37545. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  37546. */
  37547. var GamepadSystemSceneComponent = /** @class */ (function () {
  37548. /**
  37549. * Creates a new instance of the component for the given scene
  37550. * @param scene Defines the scene to register the component in
  37551. */
  37552. function GamepadSystemSceneComponent(scene) {
  37553. /**
  37554. * The component name helpfull to identify the component in the list of scene components.
  37555. */
  37556. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD;
  37557. this.scene = scene;
  37558. }
  37559. /**
  37560. * Registers the component in a given scene
  37561. */
  37562. GamepadSystemSceneComponent.prototype.register = function () {
  37563. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_GAMEPAD, this, this._beforeCameraUpdate);
  37564. };
  37565. /**
  37566. * Rebuilds the elements related to this component in case of
  37567. * context lost for instance.
  37568. */
  37569. GamepadSystemSceneComponent.prototype.rebuild = function () {
  37570. // Nothing to do for gamepads
  37571. };
  37572. /**
  37573. * Disposes the component and the associated ressources
  37574. */
  37575. GamepadSystemSceneComponent.prototype.dispose = function () {
  37576. var gamepadManager = this.scene._gamepadManager;
  37577. if (gamepadManager) {
  37578. gamepadManager.dispose();
  37579. this.scene._gamepadManager = null;
  37580. }
  37581. };
  37582. GamepadSystemSceneComponent.prototype._beforeCameraUpdate = function () {
  37583. var gamepadManager = this.scene._gamepadManager;
  37584. if (gamepadManager && gamepadManager._isMonitoring) {
  37585. gamepadManager._checkGamepadsStatus();
  37586. }
  37587. };
  37588. return GamepadSystemSceneComponent;
  37589. }());
  37590. /***/ }),
  37591. /***/ "./Gamepads/index.ts":
  37592. /*!***************************!*\
  37593. !*** ./Gamepads/index.ts ***!
  37594. \***************************/
  37595. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad */
  37596. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37597. "use strict";
  37598. __webpack_require__.r(__webpack_exports__);
  37599. /* harmony import */ var _Controllers_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Controllers/index */ "./Gamepads/Controllers/index.ts");
  37600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  37601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  37602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  37603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  37604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  37605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  37606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  37607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  37608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  37609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  37610. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  37611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["StickValues"]; });
  37612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["Gamepad"]; });
  37613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["GenericPad"]; });
  37614. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  37615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"]; });
  37616. /* harmony import */ var _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  37617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__["GamepadSystemSceneComponent"]; });
  37618. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  37619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Button"]; });
  37620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Dpad"]; });
  37621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"]; });
  37622. /***/ }),
  37623. /***/ "./Gamepads/xboxGamepad.ts":
  37624. /*!*********************************!*\
  37625. !*** ./Gamepads/xboxGamepad.ts ***!
  37626. \*********************************/
  37627. /*! exports provided: Xbox360Button, Xbox360Dpad, Xbox360Pad */
  37628. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37629. "use strict";
  37630. __webpack_require__.r(__webpack_exports__);
  37631. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return Xbox360Button; });
  37632. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return Xbox360Dpad; });
  37633. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return Xbox360Pad; });
  37634. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37635. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37636. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  37637. /**
  37638. * Defines supported buttons for XBox360 compatible gamepads
  37639. */
  37640. var Xbox360Button;
  37641. (function (Xbox360Button) {
  37642. /** A */
  37643. Xbox360Button[Xbox360Button["A"] = 0] = "A";
  37644. /** B */
  37645. Xbox360Button[Xbox360Button["B"] = 1] = "B";
  37646. /** X */
  37647. Xbox360Button[Xbox360Button["X"] = 2] = "X";
  37648. /** Y */
  37649. Xbox360Button[Xbox360Button["Y"] = 3] = "Y";
  37650. /** Start */
  37651. Xbox360Button[Xbox360Button["Start"] = 4] = "Start";
  37652. /** Back */
  37653. Xbox360Button[Xbox360Button["Back"] = 5] = "Back";
  37654. /** Left button */
  37655. Xbox360Button[Xbox360Button["LB"] = 6] = "LB";
  37656. /** Right button */
  37657. Xbox360Button[Xbox360Button["RB"] = 7] = "RB";
  37658. /** Left stick */
  37659. Xbox360Button[Xbox360Button["LeftStick"] = 8] = "LeftStick";
  37660. /** Right stick */
  37661. Xbox360Button[Xbox360Button["RightStick"] = 9] = "RightStick";
  37662. })(Xbox360Button || (Xbox360Button = {}));
  37663. /** Defines values for XBox360 DPad */
  37664. var Xbox360Dpad;
  37665. (function (Xbox360Dpad) {
  37666. /** Up */
  37667. Xbox360Dpad[Xbox360Dpad["Up"] = 0] = "Up";
  37668. /** Down */
  37669. Xbox360Dpad[Xbox360Dpad["Down"] = 1] = "Down";
  37670. /** Left */
  37671. Xbox360Dpad[Xbox360Dpad["Left"] = 2] = "Left";
  37672. /** Right */
  37673. Xbox360Dpad[Xbox360Dpad["Right"] = 3] = "Right";
  37674. })(Xbox360Dpad || (Xbox360Dpad = {}));
  37675. /**
  37676. * Defines a XBox360 gamepad
  37677. */
  37678. var Xbox360Pad = /** @class */ (function (_super) {
  37679. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Xbox360Pad, _super);
  37680. /**
  37681. * Creates a new XBox360 gamepad object
  37682. * @param id defines the id of this gamepad
  37683. * @param index defines its index
  37684. * @param gamepad defines the internal HTML gamepad object
  37685. * @param xboxOne defines if it is a XBox One gamepad
  37686. */
  37687. function Xbox360Pad(id, index, gamepad, xboxOne) {
  37688. if (xboxOne === void 0) { xboxOne = false; }
  37689. var _this = _super.call(this, id, index, gamepad, 0, 1, 2, 3) || this;
  37690. _this._leftTrigger = 0;
  37691. _this._rightTrigger = 0;
  37692. /** Observable raised when a button is pressed */
  37693. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37694. /** Observable raised when a button is released */
  37695. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37696. /** Observable raised when a pad is pressed */
  37697. _this.onPadDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37698. /** Observable raised when a pad is released */
  37699. _this.onPadUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37700. _this._buttonA = 0;
  37701. _this._buttonB = 0;
  37702. _this._buttonX = 0;
  37703. _this._buttonY = 0;
  37704. _this._buttonBack = 0;
  37705. _this._buttonStart = 0;
  37706. _this._buttonLB = 0;
  37707. _this._buttonRB = 0;
  37708. _this._buttonLeftStick = 0;
  37709. _this._buttonRightStick = 0;
  37710. _this._dPadUp = 0;
  37711. _this._dPadDown = 0;
  37712. _this._dPadLeft = 0;
  37713. _this._dPadRight = 0;
  37714. _this._isXboxOnePad = false;
  37715. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"].XBOX;
  37716. _this._isXboxOnePad = xboxOne;
  37717. return _this;
  37718. }
  37719. /**
  37720. * Defines the callback to call when left trigger is pressed
  37721. * @param callback defines the callback to use
  37722. */
  37723. Xbox360Pad.prototype.onlefttriggerchanged = function (callback) {
  37724. this._onlefttriggerchanged = callback;
  37725. };
  37726. /**
  37727. * Defines the callback to call when right trigger is pressed
  37728. * @param callback defines the callback to use
  37729. */
  37730. Xbox360Pad.prototype.onrighttriggerchanged = function (callback) {
  37731. this._onrighttriggerchanged = callback;
  37732. };
  37733. Object.defineProperty(Xbox360Pad.prototype, "leftTrigger", {
  37734. /**
  37735. * Gets the left trigger value
  37736. */
  37737. get: function () {
  37738. return this._leftTrigger;
  37739. },
  37740. /**
  37741. * Sets the left trigger value
  37742. */
  37743. set: function (newValue) {
  37744. if (this._onlefttriggerchanged && this._leftTrigger !== newValue) {
  37745. this._onlefttriggerchanged(newValue);
  37746. }
  37747. this._leftTrigger = newValue;
  37748. },
  37749. enumerable: true,
  37750. configurable: true
  37751. });
  37752. Object.defineProperty(Xbox360Pad.prototype, "rightTrigger", {
  37753. /**
  37754. * Gets the right trigger value
  37755. */
  37756. get: function () {
  37757. return this._rightTrigger;
  37758. },
  37759. /**
  37760. * Sets the right trigger value
  37761. */
  37762. set: function (newValue) {
  37763. if (this._onrighttriggerchanged && this._rightTrigger !== newValue) {
  37764. this._onrighttriggerchanged(newValue);
  37765. }
  37766. this._rightTrigger = newValue;
  37767. },
  37768. enumerable: true,
  37769. configurable: true
  37770. });
  37771. /**
  37772. * Defines the callback to call when a button is pressed
  37773. * @param callback defines the callback to use
  37774. */
  37775. Xbox360Pad.prototype.onbuttondown = function (callback) {
  37776. this._onbuttondown = callback;
  37777. };
  37778. /**
  37779. * Defines the callback to call when a button is released
  37780. * @param callback defines the callback to use
  37781. */
  37782. Xbox360Pad.prototype.onbuttonup = function (callback) {
  37783. this._onbuttonup = callback;
  37784. };
  37785. /**
  37786. * Defines the callback to call when a pad is pressed
  37787. * @param callback defines the callback to use
  37788. */
  37789. Xbox360Pad.prototype.ondpaddown = function (callback) {
  37790. this._ondpaddown = callback;
  37791. };
  37792. /**
  37793. * Defines the callback to call when a pad is released
  37794. * @param callback defines the callback to use
  37795. */
  37796. Xbox360Pad.prototype.ondpadup = function (callback) {
  37797. this._ondpadup = callback;
  37798. };
  37799. Xbox360Pad.prototype._setButtonValue = function (newValue, currentValue, buttonType) {
  37800. if (newValue !== currentValue) {
  37801. if (newValue === 1) {
  37802. if (this._onbuttondown) {
  37803. this._onbuttondown(buttonType);
  37804. }
  37805. this.onButtonDownObservable.notifyObservers(buttonType);
  37806. }
  37807. if (newValue === 0) {
  37808. if (this._onbuttonup) {
  37809. this._onbuttonup(buttonType);
  37810. }
  37811. this.onButtonUpObservable.notifyObservers(buttonType);
  37812. }
  37813. }
  37814. return newValue;
  37815. };
  37816. Xbox360Pad.prototype._setDPadValue = function (newValue, currentValue, buttonType) {
  37817. if (newValue !== currentValue) {
  37818. if (newValue === 1) {
  37819. if (this._ondpaddown) {
  37820. this._ondpaddown(buttonType);
  37821. }
  37822. this.onPadDownObservable.notifyObservers(buttonType);
  37823. }
  37824. if (newValue === 0) {
  37825. if (this._ondpadup) {
  37826. this._ondpadup(buttonType);
  37827. }
  37828. this.onPadUpObservable.notifyObservers(buttonType);
  37829. }
  37830. }
  37831. return newValue;
  37832. };
  37833. Object.defineProperty(Xbox360Pad.prototype, "buttonA", {
  37834. /**
  37835. * Gets the value of the `A` button
  37836. */
  37837. get: function () {
  37838. return this._buttonA;
  37839. },
  37840. /**
  37841. * Sets the value of the `A` button
  37842. */
  37843. set: function (value) {
  37844. this._buttonA = this._setButtonValue(value, this._buttonA, Xbox360Button.A);
  37845. },
  37846. enumerable: true,
  37847. configurable: true
  37848. });
  37849. Object.defineProperty(Xbox360Pad.prototype, "buttonB", {
  37850. /**
  37851. * Gets the value of the `B` button
  37852. */
  37853. get: function () {
  37854. return this._buttonB;
  37855. },
  37856. /**
  37857. * Sets the value of the `B` button
  37858. */
  37859. set: function (value) {
  37860. this._buttonB = this._setButtonValue(value, this._buttonB, Xbox360Button.B);
  37861. },
  37862. enumerable: true,
  37863. configurable: true
  37864. });
  37865. Object.defineProperty(Xbox360Pad.prototype, "buttonX", {
  37866. /**
  37867. * Gets the value of the `X` button
  37868. */
  37869. get: function () {
  37870. return this._buttonX;
  37871. },
  37872. /**
  37873. * Sets the value of the `X` button
  37874. */
  37875. set: function (value) {
  37876. this._buttonX = this._setButtonValue(value, this._buttonX, Xbox360Button.X);
  37877. },
  37878. enumerable: true,
  37879. configurable: true
  37880. });
  37881. Object.defineProperty(Xbox360Pad.prototype, "buttonY", {
  37882. /**
  37883. * Gets the value of the `Y` button
  37884. */
  37885. get: function () {
  37886. return this._buttonY;
  37887. },
  37888. /**
  37889. * Sets the value of the `Y` button
  37890. */
  37891. set: function (value) {
  37892. this._buttonY = this._setButtonValue(value, this._buttonY, Xbox360Button.Y);
  37893. },
  37894. enumerable: true,
  37895. configurable: true
  37896. });
  37897. Object.defineProperty(Xbox360Pad.prototype, "buttonStart", {
  37898. /**
  37899. * Gets the value of the `Start` button
  37900. */
  37901. get: function () {
  37902. return this._buttonStart;
  37903. },
  37904. /**
  37905. * Sets the value of the `Start` button
  37906. */
  37907. set: function (value) {
  37908. this._buttonStart = this._setButtonValue(value, this._buttonStart, Xbox360Button.Start);
  37909. },
  37910. enumerable: true,
  37911. configurable: true
  37912. });
  37913. Object.defineProperty(Xbox360Pad.prototype, "buttonBack", {
  37914. /**
  37915. * Gets the value of the `Back` button
  37916. */
  37917. get: function () {
  37918. return this._buttonBack;
  37919. },
  37920. /**
  37921. * Sets the value of the `Back` button
  37922. */
  37923. set: function (value) {
  37924. this._buttonBack = this._setButtonValue(value, this._buttonBack, Xbox360Button.Back);
  37925. },
  37926. enumerable: true,
  37927. configurable: true
  37928. });
  37929. Object.defineProperty(Xbox360Pad.prototype, "buttonLB", {
  37930. /**
  37931. * Gets the value of the `Left` button
  37932. */
  37933. get: function () {
  37934. return this._buttonLB;
  37935. },
  37936. /**
  37937. * Sets the value of the `Left` button
  37938. */
  37939. set: function (value) {
  37940. this._buttonLB = this._setButtonValue(value, this._buttonLB, Xbox360Button.LB);
  37941. },
  37942. enumerable: true,
  37943. configurable: true
  37944. });
  37945. Object.defineProperty(Xbox360Pad.prototype, "buttonRB", {
  37946. /**
  37947. * Gets the value of the `Right` button
  37948. */
  37949. get: function () {
  37950. return this._buttonRB;
  37951. },
  37952. /**
  37953. * Sets the value of the `Right` button
  37954. */
  37955. set: function (value) {
  37956. this._buttonRB = this._setButtonValue(value, this._buttonRB, Xbox360Button.RB);
  37957. },
  37958. enumerable: true,
  37959. configurable: true
  37960. });
  37961. Object.defineProperty(Xbox360Pad.prototype, "buttonLeftStick", {
  37962. /**
  37963. * Gets the value of the Left joystick
  37964. */
  37965. get: function () {
  37966. return this._buttonLeftStick;
  37967. },
  37968. /**
  37969. * Sets the value of the Left joystick
  37970. */
  37971. set: function (value) {
  37972. this._buttonLeftStick = this._setButtonValue(value, this._buttonLeftStick, Xbox360Button.LeftStick);
  37973. },
  37974. enumerable: true,
  37975. configurable: true
  37976. });
  37977. Object.defineProperty(Xbox360Pad.prototype, "buttonRightStick", {
  37978. /**
  37979. * Gets the value of the Right joystick
  37980. */
  37981. get: function () {
  37982. return this._buttonRightStick;
  37983. },
  37984. /**
  37985. * Sets the value of the Right joystick
  37986. */
  37987. set: function (value) {
  37988. this._buttonRightStick = this._setButtonValue(value, this._buttonRightStick, Xbox360Button.RightStick);
  37989. },
  37990. enumerable: true,
  37991. configurable: true
  37992. });
  37993. Object.defineProperty(Xbox360Pad.prototype, "dPadUp", {
  37994. /**
  37995. * Gets the value of D-pad up
  37996. */
  37997. get: function () {
  37998. return this._dPadUp;
  37999. },
  38000. /**
  38001. * Sets the value of D-pad up
  38002. */
  38003. set: function (value) {
  38004. this._dPadUp = this._setDPadValue(value, this._dPadUp, Xbox360Dpad.Up);
  38005. },
  38006. enumerable: true,
  38007. configurable: true
  38008. });
  38009. Object.defineProperty(Xbox360Pad.prototype, "dPadDown", {
  38010. /**
  38011. * Gets the value of D-pad down
  38012. */
  38013. get: function () {
  38014. return this._dPadDown;
  38015. },
  38016. /**
  38017. * Sets the value of D-pad down
  38018. */
  38019. set: function (value) {
  38020. this._dPadDown = this._setDPadValue(value, this._dPadDown, Xbox360Dpad.Down);
  38021. },
  38022. enumerable: true,
  38023. configurable: true
  38024. });
  38025. Object.defineProperty(Xbox360Pad.prototype, "dPadLeft", {
  38026. /**
  38027. * Gets the value of D-pad left
  38028. */
  38029. get: function () {
  38030. return this._dPadLeft;
  38031. },
  38032. /**
  38033. * Sets the value of D-pad left
  38034. */
  38035. set: function (value) {
  38036. this._dPadLeft = this._setDPadValue(value, this._dPadLeft, Xbox360Dpad.Left);
  38037. },
  38038. enumerable: true,
  38039. configurable: true
  38040. });
  38041. Object.defineProperty(Xbox360Pad.prototype, "dPadRight", {
  38042. /**
  38043. * Gets the value of D-pad right
  38044. */
  38045. get: function () {
  38046. return this._dPadRight;
  38047. },
  38048. /**
  38049. * Sets the value of D-pad right
  38050. */
  38051. set: function (value) {
  38052. this._dPadRight = this._setDPadValue(value, this._dPadRight, Xbox360Dpad.Right);
  38053. },
  38054. enumerable: true,
  38055. configurable: true
  38056. });
  38057. /**
  38058. * Force the gamepad to synchronize with device values
  38059. */
  38060. Xbox360Pad.prototype.update = function () {
  38061. _super.prototype.update.call(this);
  38062. if (this._isXboxOnePad) {
  38063. this.buttonA = this.browserGamepad.buttons[0].value;
  38064. this.buttonB = this.browserGamepad.buttons[1].value;
  38065. this.buttonX = this.browserGamepad.buttons[2].value;
  38066. this.buttonY = this.browserGamepad.buttons[3].value;
  38067. this.buttonLB = this.browserGamepad.buttons[4].value;
  38068. this.buttonRB = this.browserGamepad.buttons[5].value;
  38069. this.leftTrigger = this.browserGamepad.axes[2];
  38070. this.rightTrigger = this.browserGamepad.axes[5];
  38071. this.buttonBack = this.browserGamepad.buttons[9].value;
  38072. this.buttonStart = this.browserGamepad.buttons[8].value;
  38073. this.buttonLeftStick = this.browserGamepad.buttons[6].value;
  38074. this.buttonRightStick = this.browserGamepad.buttons[7].value;
  38075. this.dPadUp = this.browserGamepad.buttons[11].value;
  38076. this.dPadDown = this.browserGamepad.buttons[12].value;
  38077. this.dPadLeft = this.browserGamepad.buttons[13].value;
  38078. this.dPadRight = this.browserGamepad.buttons[14].value;
  38079. }
  38080. else {
  38081. this.buttonA = this.browserGamepad.buttons[0].value;
  38082. this.buttonB = this.browserGamepad.buttons[1].value;
  38083. this.buttonX = this.browserGamepad.buttons[2].value;
  38084. this.buttonY = this.browserGamepad.buttons[3].value;
  38085. this.buttonLB = this.browserGamepad.buttons[4].value;
  38086. this.buttonRB = this.browserGamepad.buttons[5].value;
  38087. this.leftTrigger = this.browserGamepad.buttons[6].value;
  38088. this.rightTrigger = this.browserGamepad.buttons[7].value;
  38089. this.buttonBack = this.browserGamepad.buttons[8].value;
  38090. this.buttonStart = this.browserGamepad.buttons[9].value;
  38091. this.buttonLeftStick = this.browserGamepad.buttons[10].value;
  38092. this.buttonRightStick = this.browserGamepad.buttons[11].value;
  38093. this.dPadUp = this.browserGamepad.buttons[12].value;
  38094. this.dPadDown = this.browserGamepad.buttons[13].value;
  38095. this.dPadLeft = this.browserGamepad.buttons[14].value;
  38096. this.dPadRight = this.browserGamepad.buttons[15].value;
  38097. }
  38098. };
  38099. /**
  38100. * Disposes the gamepad
  38101. */
  38102. Xbox360Pad.prototype.dispose = function () {
  38103. _super.prototype.dispose.call(this);
  38104. this.onButtonDownObservable.clear();
  38105. this.onButtonUpObservable.clear();
  38106. this.onPadDownObservable.clear();
  38107. this.onPadUpObservable.clear();
  38108. };
  38109. return Xbox360Pad;
  38110. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"]));
  38111. /***/ }),
  38112. /***/ "./Gizmos/axisDragGizmo.ts":
  38113. /*!*********************************!*\
  38114. !*** ./Gizmos/axisDragGizmo.ts ***!
  38115. \*********************************/
  38116. /*! exports provided: AxisDragGizmo */
  38117. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38118. "use strict";
  38119. __webpack_require__.r(__webpack_exports__);
  38120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return AxisDragGizmo; });
  38121. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38122. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38123. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38124. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  38125. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  38126. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  38127. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38128. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38129. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38130. /**
  38131. * Single axis drag gizmo
  38132. */
  38133. var AxisDragGizmo = /** @class */ (function (_super) {
  38134. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisDragGizmo, _super);
  38135. /**
  38136. * Creates an AxisDragGizmo
  38137. * @param gizmoLayer The utility layer the gizmo will be added to
  38138. * @param dragAxis The axis which the gizmo will be able to drag on
  38139. * @param color The color of the gizmo
  38140. */
  38141. function AxisDragGizmo(dragAxis, color, gizmoLayer) {
  38142. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  38143. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38144. var _this = _super.call(this, gizmoLayer) || this;
  38145. _this._pointerObserver = null;
  38146. /**
  38147. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38148. */
  38149. _this.snapDistance = 0;
  38150. /**
  38151. * Event that fires each time the gizmo snaps to a new location.
  38152. * * snapDistance is the the change in distance
  38153. */
  38154. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38155. // Create Material
  38156. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38157. coloredMaterial.diffuseColor = color;
  38158. coloredMaterial.specularColor = color.subtract(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.1, 0.1, 0.1));
  38159. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38160. hoverMaterial.diffuseColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  38161. // Build mesh on root node
  38162. var arrow = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, coloredMaterial);
  38163. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  38164. arrow.scaling.scaleInPlace(1 / 3);
  38165. arrow.parent = _this._rootMesh;
  38166. var currentSnapDragDistance = 0;
  38167. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38168. var tmpSnapEvent = { snapDistance: 0 };
  38169. // Add drag behavior to handle events when the gizmo is dragged
  38170. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragAxis: dragAxis });
  38171. _this.dragBehavior.moveAttached = false;
  38172. _this._rootMesh.addBehavior(_this.dragBehavior);
  38173. var localDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38174. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  38175. _this.dragBehavior.onDragObservable.add(function (event) {
  38176. if (_this.attachedMesh) {
  38177. // Convert delta to local translation if it has a parent
  38178. if (_this.attachedMesh.parent) {
  38179. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  38180. tmpMatrix.setTranslationFromFloats(0, 0, 0);
  38181. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(event.delta, tmpMatrix, localDelta);
  38182. }
  38183. else {
  38184. localDelta.copyFrom(event.delta);
  38185. }
  38186. // Snapping logic
  38187. if (_this.snapDistance == 0) {
  38188. _this.attachedMesh.position.addInPlace(localDelta);
  38189. }
  38190. else {
  38191. currentSnapDragDistance += event.dragDistance;
  38192. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  38193. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  38194. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  38195. localDelta.normalizeToRef(tmpVector);
  38196. tmpVector.scaleInPlace(_this.snapDistance * dragSteps);
  38197. _this.attachedMesh.position.addInPlace(tmpVector);
  38198. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  38199. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  38200. }
  38201. }
  38202. }
  38203. });
  38204. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38205. if (_this._customMeshSet) {
  38206. return;
  38207. }
  38208. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  38209. var material = isHovered ? hoverMaterial : coloredMaterial;
  38210. _this._rootMesh.getChildMeshes().forEach(function (m) {
  38211. m.material = material;
  38212. if (m.color) {
  38213. m.color = material.diffuseColor;
  38214. }
  38215. });
  38216. });
  38217. var light = gizmoLayer._getSharedGizmoLight();
  38218. light.includedOnlyMeshes = light.includedOnlyMeshes.concat(_this._rootMesh.getChildMeshes(false));
  38219. return _this;
  38220. }
  38221. /** @hidden */
  38222. AxisDragGizmo._CreateArrow = function (scene, material) {
  38223. var arrow = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  38224. var cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("cylinder", { diameterTop: 0, height: 0.075, diameterBottom: 0.0375, tessellation: 96 }, scene);
  38225. var line = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("cylinder", { diameterTop: 0.005, height: 0.275, diameterBottom: 0.005, tessellation: 96 }, scene);
  38226. line.material = material;
  38227. cylinder.parent = arrow;
  38228. line.parent = arrow;
  38229. // Position arrow pointing in its drag axis
  38230. cylinder.material = material;
  38231. cylinder.rotation.x = Math.PI / 2;
  38232. cylinder.position.z += 0.3;
  38233. line.position.z += 0.275 / 2;
  38234. line.rotation.x = Math.PI / 2;
  38235. return arrow;
  38236. };
  38237. /** @hidden */
  38238. AxisDragGizmo._CreateArrowInstance = function (scene, arrow) {
  38239. var instance = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  38240. for (var _i = 0, _a = arrow.getChildMeshes(); _i < _a.length; _i++) {
  38241. var mesh = _a[_i];
  38242. var childInstance = mesh.createInstance(mesh.name);
  38243. childInstance.parent = instance;
  38244. }
  38245. return instance;
  38246. };
  38247. AxisDragGizmo.prototype._attachedMeshChanged = function (value) {
  38248. if (this.dragBehavior) {
  38249. this.dragBehavior.enabled = value ? true : false;
  38250. }
  38251. };
  38252. /**
  38253. * Disposes of the gizmo
  38254. */
  38255. AxisDragGizmo.prototype.dispose = function () {
  38256. this.onSnapObservable.clear();
  38257. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38258. this.dragBehavior.detach();
  38259. _super.prototype.dispose.call(this);
  38260. };
  38261. return AxisDragGizmo;
  38262. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  38263. /***/ }),
  38264. /***/ "./Gizmos/axisScaleGizmo.ts":
  38265. /*!**********************************!*\
  38266. !*** ./Gizmos/axisScaleGizmo.ts ***!
  38267. \**********************************/
  38268. /*! exports provided: AxisScaleGizmo */
  38269. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38270. "use strict";
  38271. __webpack_require__.r(__webpack_exports__);
  38272. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return AxisScaleGizmo; });
  38273. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38274. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38275. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38276. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38277. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  38278. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  38279. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38280. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  38281. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38282. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38283. /**
  38284. * Single axis scale gizmo
  38285. */
  38286. var AxisScaleGizmo = /** @class */ (function (_super) {
  38287. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisScaleGizmo, _super);
  38288. /**
  38289. * Creates an AxisScaleGizmo
  38290. * @param gizmoLayer The utility layer the gizmo will be added to
  38291. * @param dragAxis The axis which the gizmo will be able to scale on
  38292. * @param color The color of the gizmo
  38293. */
  38294. function AxisScaleGizmo(dragAxis, color, gizmoLayer) {
  38295. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  38296. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38297. var _this = _super.call(this, gizmoLayer) || this;
  38298. _this._pointerObserver = null;
  38299. /**
  38300. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38301. */
  38302. _this.snapDistance = 0;
  38303. /**
  38304. * Event that fires each time the gizmo snaps to a new location.
  38305. * * snapDistance is the the change in distance
  38306. */
  38307. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38308. /**
  38309. * If the scaling operation should be done on all axis (default: false)
  38310. */
  38311. _this.uniformScaling = false;
  38312. // Create Material
  38313. _this._coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38314. _this._coloredMaterial.diffuseColor = color;
  38315. _this._coloredMaterial.specularColor = color.subtract(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.1, 0.1, 0.1));
  38316. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38317. hoverMaterial.diffuseColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  38318. // Build mesh on root node
  38319. var arrow = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38320. var arrowMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__["BoxBuilder"].CreateBox("yPosMesh", { size: 0.4 }, gizmoLayer.utilityLayerScene);
  38321. var arrowTail = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_5__["CylinderBuilder"].CreateCylinder("cylinder", { diameterTop: 0.005, height: 0.275, diameterBottom: 0.005, tessellation: 96 }, gizmoLayer.utilityLayerScene);
  38322. arrowTail.material = _this._coloredMaterial;
  38323. arrow.addChild(arrowMesh);
  38324. arrow.addChild(arrowTail);
  38325. // Position arrow pointing in its drag axis
  38326. arrowMesh.scaling.scaleInPlace(0.1);
  38327. arrowMesh.material = _this._coloredMaterial;
  38328. arrowMesh.rotation.x = Math.PI / 2;
  38329. arrowMesh.position.z += 0.3;
  38330. arrowTail.position.z += 0.275 / 2;
  38331. arrowTail.rotation.x = Math.PI / 2;
  38332. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  38333. _this._rootMesh.addChild(arrow);
  38334. arrow.scaling.scaleInPlace(1 / 3);
  38335. // Add drag behavior to handle events when the gizmo is dragged
  38336. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__["PointerDragBehavior"]({ dragAxis: dragAxis });
  38337. _this.dragBehavior.moveAttached = false;
  38338. _this._rootMesh.addBehavior(_this.dragBehavior);
  38339. var currentSnapDragDistance = 0;
  38340. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38341. var tmpSnapEvent = { snapDistance: 0 };
  38342. _this.dragBehavior.onDragObservable.add(function (event) {
  38343. if (_this.attachedMesh) {
  38344. // Snapping logic
  38345. var snapped = false;
  38346. var dragSteps = 0;
  38347. if (_this.uniformScaling) {
  38348. _this.attachedMesh.scaling.normalizeToRef(tmpVector);
  38349. if (tmpVector.y < 0) {
  38350. tmpVector.scaleInPlace(-1);
  38351. }
  38352. }
  38353. else {
  38354. tmpVector.copyFrom(dragAxis);
  38355. }
  38356. if (_this.snapDistance == 0) {
  38357. tmpVector.scaleToRef(event.dragDistance, tmpVector);
  38358. }
  38359. else {
  38360. currentSnapDragDistance += event.dragDistance;
  38361. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  38362. dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  38363. if (currentSnapDragDistance < 0) {
  38364. dragSteps *= -1;
  38365. }
  38366. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  38367. tmpVector.scaleToRef(_this.snapDistance * dragSteps, tmpVector);
  38368. snapped = true;
  38369. }
  38370. else {
  38371. tmpVector.scaleInPlace(0);
  38372. }
  38373. }
  38374. _this.attachedMesh.scaling.addInPlace(tmpVector);
  38375. if (snapped) {
  38376. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  38377. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  38378. }
  38379. }
  38380. });
  38381. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38382. if (_this._customMeshSet) {
  38383. return;
  38384. }
  38385. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  38386. var material = isHovered ? hoverMaterial : _this._coloredMaterial;
  38387. _this._rootMesh.getChildMeshes().forEach(function (m) {
  38388. m.material = material;
  38389. if (m.color) {
  38390. m.color = material.diffuseColor;
  38391. }
  38392. });
  38393. });
  38394. var light = gizmoLayer._getSharedGizmoLight();
  38395. light.includedOnlyMeshes = light.includedOnlyMeshes.concat(_this._rootMesh.getChildMeshes());
  38396. return _this;
  38397. }
  38398. AxisScaleGizmo.prototype._attachedMeshChanged = function (value) {
  38399. if (this.dragBehavior) {
  38400. this.dragBehavior.enabled = value ? true : false;
  38401. }
  38402. };
  38403. /**
  38404. * Disposes of the gizmo
  38405. */
  38406. AxisScaleGizmo.prototype.dispose = function () {
  38407. this.onSnapObservable.clear();
  38408. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38409. this.dragBehavior.detach();
  38410. _super.prototype.dispose.call(this);
  38411. };
  38412. /**
  38413. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  38414. * @param mesh The mesh to replace the default mesh of the gizmo
  38415. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  38416. */
  38417. AxisScaleGizmo.prototype.setCustomMesh = function (mesh, useGizmoMaterial) {
  38418. var _this = this;
  38419. if (useGizmoMaterial === void 0) { useGizmoMaterial = false; }
  38420. _super.prototype.setCustomMesh.call(this, mesh);
  38421. if (useGizmoMaterial) {
  38422. this._rootMesh.getChildMeshes().forEach(function (m) {
  38423. m.material = _this._coloredMaterial;
  38424. if (m.color) {
  38425. m.color = _this._coloredMaterial.diffuseColor;
  38426. }
  38427. });
  38428. this._customMeshSet = false;
  38429. }
  38430. };
  38431. return AxisScaleGizmo;
  38432. }(_gizmo__WEBPACK_IMPORTED_MODULE_8__["Gizmo"]));
  38433. /***/ }),
  38434. /***/ "./Gizmos/boundingBoxGizmo.ts":
  38435. /*!************************************!*\
  38436. !*** ./Gizmos/boundingBoxGizmo.ts ***!
  38437. \************************************/
  38438. /*! exports provided: BoundingBoxGizmo */
  38439. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38440. "use strict";
  38441. __webpack_require__.r(__webpack_exports__);
  38442. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return BoundingBoxGizmo; });
  38443. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38444. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38445. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38446. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38447. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38448. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38449. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  38450. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  38451. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  38452. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  38453. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38454. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38455. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38456. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Misc/pivotTools */ "./Misc/pivotTools.ts");
  38457. /**
  38458. * Bounding box gizmo
  38459. */
  38460. var BoundingBoxGizmo = /** @class */ (function (_super) {
  38461. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoundingBoxGizmo, _super);
  38462. /**
  38463. * Creates an BoundingBoxGizmo
  38464. * @param gizmoLayer The utility layer the gizmo will be added to
  38465. * @param color The color of the gizmo
  38466. */
  38467. function BoundingBoxGizmo(color, gizmoLayer) {
  38468. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Gray(); }
  38469. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__["UtilityLayerRenderer"].DefaultKeepDepthUtilityLayer; }
  38470. var _this = _super.call(this, gizmoLayer) || this;
  38471. _this._boundingDimensions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 1);
  38472. _this._renderObserver = null;
  38473. _this._pointerObserver = null;
  38474. _this._scaleDragSpeed = 0.2;
  38475. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38476. _this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  38477. _this._tmpRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  38478. /**
  38479. * 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)
  38480. */
  38481. _this.ignoreChildren = false;
  38482. /**
  38483. * 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)
  38484. */
  38485. _this.includeChildPredicate = null;
  38486. /**
  38487. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  38488. */
  38489. _this.rotationSphereSize = 0.1;
  38490. /**
  38491. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  38492. */
  38493. _this.scaleBoxSize = 0.1;
  38494. /**
  38495. * 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)
  38496. */
  38497. _this.fixedDragMeshScreenSize = false;
  38498. /**
  38499. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  38500. */
  38501. _this.fixedDragMeshScreenSizeDistanceFactor = 10;
  38502. /**
  38503. * Fired when a rotation sphere or scale box is dragged
  38504. */
  38505. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38506. /**
  38507. * Fired when a scale box is dragged
  38508. */
  38509. _this.onScaleBoxDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38510. /**
  38511. * Fired when a scale box drag is ended
  38512. */
  38513. _this.onScaleBoxDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38514. /**
  38515. * Fired when a rotation sphere is dragged
  38516. */
  38517. _this.onRotationSphereDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38518. /**
  38519. * Fired when a rotation sphere drag is ended
  38520. */
  38521. _this.onRotationSphereDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38522. /**
  38523. * 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)
  38524. */
  38525. _this.scalePivot = null;
  38526. _this._existingMeshScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  38527. // Dragging
  38528. _this._dragMesh = null;
  38529. _this.pointerDragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]();
  38530. // Do not update the gizmo's scale so it has a fixed size to the object its attached to
  38531. _this._updateScale = false;
  38532. _this._anchorMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("anchor", gizmoLayer.utilityLayerScene);
  38533. // Create Materials
  38534. _this.coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38535. _this.coloredMaterial.disableLighting = true;
  38536. _this.hoverColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38537. _this.hoverColoredMaterial.disableLighting = true;
  38538. // Build bounding box out of lines
  38539. _this._lineBoundingBox = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38540. _this._lineBoundingBox.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38541. var lines = [];
  38542. 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));
  38543. 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));
  38544. 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));
  38545. 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));
  38546. 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));
  38547. 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));
  38548. 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));
  38549. 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));
  38550. 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));
  38551. 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));
  38552. 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));
  38553. 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));
  38554. lines.forEach(function (l) {
  38555. l.color = color;
  38556. l.position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-_this._boundingDimensions.x / 2, -_this._boundingDimensions.y / 2, -_this._boundingDimensions.z / 2));
  38557. l.isPickable = false;
  38558. _this._lineBoundingBox.addChild(l);
  38559. });
  38560. _this._rootMesh.addChild(_this._lineBoundingBox);
  38561. _this.setColor(color);
  38562. // Create rotation spheres
  38563. _this._rotateSpheresParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38564. _this._rotateSpheresParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38565. var _loop_1 = function (i_1) {
  38566. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__["SphereBuilder"].CreateSphere("", { diameter: 1 }, gizmoLayer.utilityLayerScene);
  38567. sphere.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38568. sphere.material = this_1.coloredMaterial;
  38569. // Drag behavior
  38570. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({});
  38571. _dragBehavior.moveAttached = false;
  38572. _dragBehavior.updateDragPlane = false;
  38573. sphere.addBehavior(_dragBehavior);
  38574. var startingTurnDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  38575. var totalTurnAmountOfDrag = 0;
  38576. _dragBehavior.onDragStartObservable.add(function () {
  38577. startingTurnDirection.copyFrom(sphere.forward);
  38578. totalTurnAmountOfDrag = 0;
  38579. });
  38580. _dragBehavior.onDragObservable.add(function (event) {
  38581. _this.onRotationSphereDragObservable.notifyObservers({});
  38582. if (_this.attachedMesh) {
  38583. var originalParent = _this.attachedMesh.parent;
  38584. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  38585. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  38586. return;
  38587. }
  38588. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  38589. var worldDragDirection = startingTurnDirection;
  38590. // Project the world right on to the drag plane
  38591. var toSub = event.dragPlaneNormal.scale(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(event.dragPlaneNormal, worldDragDirection));
  38592. var dragAxis = worldDragDirection.subtract(toSub).normalizeToNew();
  38593. // project drag delta on to the resulting drag axis and rotate based on that
  38594. var projectDist = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(dragAxis, event.delta) < 0 ? Math.abs(event.delta.length()) : -Math.abs(event.delta.length());
  38595. // Make rotation relative to size of mesh.
  38596. projectDist = (projectDist / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  38597. // Rotate based on axis
  38598. if (!_this.attachedMesh.rotationQuaternion) {
  38599. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  38600. }
  38601. if (!_this._anchorMesh.rotationQuaternion) {
  38602. _this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this._anchorMesh.rotation.y, _this._anchorMesh.rotation.x, _this._anchorMesh.rotation.z);
  38603. }
  38604. // Do not allow the object to turn more than a full circle
  38605. totalTurnAmountOfDrag += projectDist;
  38606. if (Math.abs(totalTurnAmountOfDrag) <= 2 * Math.PI) {
  38607. if (i_1 >= 8) {
  38608. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, 0, projectDist, _this._tmpQuaternion);
  38609. }
  38610. else if (i_1 >= 4) {
  38611. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(projectDist, 0, 0, _this._tmpQuaternion);
  38612. }
  38613. else {
  38614. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, projectDist, 0, _this._tmpQuaternion);
  38615. }
  38616. // Rotate around center of bounding box
  38617. _this._anchorMesh.addChild(_this.attachedMesh);
  38618. _this._anchorMesh.rotationQuaternion.multiplyToRef(_this._tmpQuaternion, _this._anchorMesh.rotationQuaternion);
  38619. _this._anchorMesh.removeChild(_this.attachedMesh);
  38620. _this.attachedMesh.setParent(originalParent);
  38621. }
  38622. _this.updateBoundingBox();
  38623. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  38624. }
  38625. _this._updateDummy();
  38626. });
  38627. // Selection/deselection
  38628. _dragBehavior.onDragStartObservable.add(function () {
  38629. _this.onDragStartObservable.notifyObservers({});
  38630. _this._selectNode(sphere);
  38631. });
  38632. _dragBehavior.onDragEndObservable.add(function () {
  38633. _this.onRotationSphereDragEndObservable.notifyObservers({});
  38634. _this._selectNode(null);
  38635. _this._updateDummy();
  38636. });
  38637. this_1._rotateSpheresParent.addChild(sphere);
  38638. };
  38639. var this_1 = this, _dragBehavior;
  38640. for (var i_1 = 0; i_1 < 12; i_1++) {
  38641. _loop_1(i_1);
  38642. }
  38643. _this._rootMesh.addChild(_this._rotateSpheresParent);
  38644. // Create scale cubes
  38645. _this._scaleBoxesParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38646. _this._scaleBoxesParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38647. for (var i = 0; i < 2; i++) {
  38648. for (var j = 0; j < 2; j++) {
  38649. var _loop_2 = function () {
  38650. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("", { size: 1 }, gizmoLayer.utilityLayerScene);
  38651. box.material = this_2.coloredMaterial;
  38652. // Dragging logic
  38653. var dragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](i == 0 ? -1 : 1, j == 0 ? -1 : 1, k == 0 ? -1 : 1);
  38654. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({ dragAxis: dragAxis });
  38655. _dragBehavior.moveAttached = false;
  38656. box.addBehavior(_dragBehavior);
  38657. _dragBehavior.onDragObservable.add(function (event) {
  38658. _this.onScaleBoxDragObservable.notifyObservers({});
  38659. if (_this.attachedMesh) {
  38660. var originalParent = _this.attachedMesh.parent;
  38661. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  38662. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  38663. return;
  38664. }
  38665. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  38666. var relativeDragDistance = (event.dragDistance / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  38667. var deltaScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](relativeDragDistance, relativeDragDistance, relativeDragDistance);
  38668. deltaScale.scaleInPlace(_this._scaleDragSpeed);
  38669. _this.updateBoundingBox();
  38670. if (_this.scalePivot) {
  38671. _this.attachedMesh.getWorldMatrix().getRotationMatrixToRef(_this._tmpRotationMatrix);
  38672. // Move anchor to desired pivot point (Bottom left corner + dimension/2)
  38673. _this._boundingDimensions.scaleToRef(0.5, _this._tmpVector);
  38674. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  38675. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  38676. _this._boundingDimensions.multiplyToRef(_this.scalePivot, _this._tmpVector);
  38677. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  38678. _this._anchorMesh.position.addInPlace(_this._tmpVector);
  38679. }
  38680. else {
  38681. // Scale from the position of the opposite corner
  38682. box.absolutePosition.subtractToRef(_this._anchorMesh.position, _this._tmpVector);
  38683. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  38684. }
  38685. _this._anchorMesh.addChild(_this.attachedMesh);
  38686. _this._anchorMesh.scaling.addInPlace(deltaScale);
  38687. if (_this._anchorMesh.scaling.x < 0 || _this._anchorMesh.scaling.y < 0 || _this._anchorMesh.scaling.z < 0) {
  38688. _this._anchorMesh.scaling.subtractInPlace(deltaScale);
  38689. }
  38690. _this._anchorMesh.removeChild(_this.attachedMesh);
  38691. _this.attachedMesh.setParent(originalParent);
  38692. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  38693. }
  38694. _this._updateDummy();
  38695. });
  38696. // Selection/deselection
  38697. _dragBehavior.onDragStartObservable.add(function () {
  38698. _this.onDragStartObservable.notifyObservers({});
  38699. _this._selectNode(box);
  38700. });
  38701. _dragBehavior.onDragEndObservable.add(function () {
  38702. _this.onScaleBoxDragEndObservable.notifyObservers({});
  38703. _this._selectNode(null);
  38704. _this._updateDummy();
  38705. });
  38706. this_2._scaleBoxesParent.addChild(box);
  38707. };
  38708. var this_2 = this, _dragBehavior;
  38709. for (var k = 0; k < 2; k++) {
  38710. _loop_2();
  38711. }
  38712. }
  38713. }
  38714. _this._rootMesh.addChild(_this._scaleBoxesParent);
  38715. // Hover color change
  38716. var pointerIds = new Array();
  38717. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38718. if (!pointerIds[pointerInfo.event.pointerId]) {
  38719. _this._rotateSpheresParent.getChildMeshes().concat(_this._scaleBoxesParent.getChildMeshes()).forEach(function (mesh) {
  38720. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh == mesh) {
  38721. pointerIds[pointerInfo.event.pointerId] = mesh;
  38722. mesh.material = _this.hoverColoredMaterial;
  38723. }
  38724. });
  38725. }
  38726. else {
  38727. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh != pointerIds[pointerInfo.event.pointerId]) {
  38728. pointerIds[pointerInfo.event.pointerId].material = _this.coloredMaterial;
  38729. delete pointerIds[pointerInfo.event.pointerId];
  38730. }
  38731. }
  38732. });
  38733. // Update bounding box positions
  38734. _this._renderObserver = _this.gizmoLayer.originalScene.onBeforeRenderObservable.add(function () {
  38735. // Only update the bouding box if scaling has changed
  38736. if (_this.attachedMesh && !_this._existingMeshScale.equals(_this.attachedMesh.scaling)) {
  38737. _this.updateBoundingBox();
  38738. }
  38739. else if (_this.fixedDragMeshScreenSize) {
  38740. _this._updateRotationSpheres();
  38741. _this._updateScaleBoxes();
  38742. }
  38743. // If dragg mesh is enabled and dragging, update the attached mesh pose to match the drag mesh
  38744. if (_this._dragMesh && _this.attachedMesh && _this.pointerDragBehavior.dragging) {
  38745. _this._lineBoundingBox.position.rotateByQuaternionToRef(_this._rootMesh.rotationQuaternion, _this._tmpVector);
  38746. _this.attachedMesh.setAbsolutePosition(_this._dragMesh.position.add(_this._tmpVector.scale(-1)));
  38747. }
  38748. });
  38749. _this.updateBoundingBox();
  38750. return _this;
  38751. }
  38752. /**
  38753. * Sets the color of the bounding box gizmo
  38754. * @param color the color to set
  38755. */
  38756. BoundingBoxGizmo.prototype.setColor = function (color) {
  38757. this.coloredMaterial.emissiveColor = color;
  38758. this.hoverColoredMaterial.emissiveColor = color.clone().add(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.3, 0.3, 0.3));
  38759. this._lineBoundingBox.getChildren().forEach(function (l) {
  38760. if (l.color) {
  38761. l.color = color;
  38762. }
  38763. });
  38764. };
  38765. BoundingBoxGizmo.prototype._attachedMeshChanged = function (value) {
  38766. var _this = this;
  38767. if (value) {
  38768. // Reset anchor mesh to match attached mesh's scale
  38769. // This is needed to avoid invalid box/sphere position on first drag
  38770. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(value);
  38771. var originalParent = value.parent;
  38772. this._anchorMesh.addChild(value);
  38773. this._anchorMesh.removeChild(value);
  38774. value.setParent(originalParent);
  38775. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(value);
  38776. this.updateBoundingBox();
  38777. value.getChildMeshes(false).forEach(function (m) {
  38778. m.markAsDirty("scaling");
  38779. });
  38780. this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(function () {
  38781. _this._updateDummy();
  38782. });
  38783. }
  38784. };
  38785. BoundingBoxGizmo.prototype._selectNode = function (selectedMesh) {
  38786. this._rotateSpheresParent.getChildMeshes()
  38787. .concat(this._scaleBoxesParent.getChildMeshes()).forEach(function (m) {
  38788. m.isVisible = (!selectedMesh || m == selectedMesh);
  38789. });
  38790. };
  38791. /**
  38792. * Updates the bounding box information for the Gizmo
  38793. */
  38794. BoundingBoxGizmo.prototype.updateBoundingBox = function () {
  38795. if (this.attachedMesh) {
  38796. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(this.attachedMesh);
  38797. var originalParent = this.attachedMesh.parent;
  38798. this.attachedMesh.setParent(null);
  38799. this._update();
  38800. // Rotate based on axis
  38801. if (!this.attachedMesh.rotationQuaternion) {
  38802. this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);
  38803. }
  38804. if (!this._anchorMesh.rotationQuaternion) {
  38805. this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z);
  38806. }
  38807. this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  38808. // Store original position and reset mesh to origin before computing the bounding box
  38809. this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  38810. this._tmpVector.copyFrom(this.attachedMesh.position);
  38811. this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1);
  38812. this.attachedMesh.position.set(0, 0, 0);
  38813. // Update bounding dimensions/positions
  38814. var boundingMinMax = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);
  38815. boundingMinMax.max.subtractToRef(boundingMinMax.min, this._boundingDimensions);
  38816. // Update gizmo to match bounding box scaling and rotation
  38817. this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions);
  38818. 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);
  38819. this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position);
  38820. this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position);
  38821. this._lineBoundingBox.computeWorldMatrix();
  38822. this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition);
  38823. // restore position/rotation values
  38824. this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion);
  38825. this.attachedMesh.position.copyFrom(this._tmpVector);
  38826. this.attachedMesh.setParent(originalParent);
  38827. }
  38828. this._updateRotationSpheres();
  38829. this._updateScaleBoxes();
  38830. if (this.attachedMesh) {
  38831. this._existingMeshScale.copyFrom(this.attachedMesh.scaling);
  38832. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(this.attachedMesh);
  38833. }
  38834. };
  38835. BoundingBoxGizmo.prototype._updateRotationSpheres = function () {
  38836. var rotateSpheres = this._rotateSpheresParent.getChildMeshes();
  38837. for (var i = 0; i < 3; i++) {
  38838. for (var j = 0; j < 2; j++) {
  38839. for (var k = 0; k < 2; k++) {
  38840. var index = ((i * 4) + (j * 2)) + k;
  38841. if (i == 0) {
  38842. rotateSpheres[index].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  38843. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38844. 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));
  38845. }
  38846. if (i == 1) {
  38847. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y / 2, this._boundingDimensions.z * k);
  38848. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38849. 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));
  38850. }
  38851. if (i == 2) {
  38852. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y * k, this._boundingDimensions.z / 2);
  38853. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38854. 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));
  38855. }
  38856. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  38857. rotateSpheres[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  38858. var distanceFromCamera = this.rotationSphereSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  38859. rotateSpheres[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  38860. }
  38861. else {
  38862. rotateSpheres[index].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize);
  38863. }
  38864. }
  38865. }
  38866. }
  38867. };
  38868. BoundingBoxGizmo.prototype._updateScaleBoxes = function () {
  38869. var scaleBoxes = this._scaleBoxesParent.getChildMeshes();
  38870. for (var i = 0; i < 2; i++) {
  38871. for (var j = 0; j < 2; j++) {
  38872. for (var k = 0; k < 2; k++) {
  38873. var index = ((i * 4) + (j * 2)) + k;
  38874. if (scaleBoxes[index]) {
  38875. scaleBoxes[index].position.set(this._boundingDimensions.x * i, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  38876. scaleBoxes[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38877. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  38878. scaleBoxes[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  38879. var distanceFromCamera = this.scaleBoxSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  38880. scaleBoxes[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  38881. }
  38882. else {
  38883. scaleBoxes[index].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);
  38884. }
  38885. }
  38886. }
  38887. }
  38888. }
  38889. };
  38890. /**
  38891. * Enables rotation on the specified axis and disables rotation on the others
  38892. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  38893. */
  38894. BoundingBoxGizmo.prototype.setEnabledRotationAxis = function (axis) {
  38895. this._rotateSpheresParent.getChildMeshes().forEach(function (m, i) {
  38896. if (i < 4) {
  38897. m.setEnabled(axis.indexOf("x") != -1);
  38898. }
  38899. else if (i < 8) {
  38900. m.setEnabled(axis.indexOf("y") != -1);
  38901. }
  38902. else {
  38903. m.setEnabled(axis.indexOf("z") != -1);
  38904. }
  38905. });
  38906. };
  38907. /**
  38908. * Enables/disables scaling
  38909. * @param enable if scaling should be enabled
  38910. */
  38911. BoundingBoxGizmo.prototype.setEnabledScaling = function (enable) {
  38912. this._scaleBoxesParent.getChildMeshes().forEach(function (m, i) {
  38913. m.setEnabled(enable);
  38914. });
  38915. };
  38916. BoundingBoxGizmo.prototype._updateDummy = function () {
  38917. if (this._dragMesh) {
  38918. this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition());
  38919. this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling);
  38920. this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion);
  38921. }
  38922. };
  38923. /**
  38924. * Enables a pointer drag behavior on the bounding box of the gizmo
  38925. */
  38926. BoundingBoxGizmo.prototype.enableDragBehavior = function () {
  38927. this._dragMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].CreateBox("dummy", 1, this.gizmoLayer.utilityLayerScene);
  38928. this._dragMesh.visibility = 0;
  38929. this._dragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38930. this.pointerDragBehavior.useObjectOrienationForDragging = false;
  38931. this._dragMesh.addBehavior(this.pointerDragBehavior);
  38932. };
  38933. /**
  38934. * Disposes of the gizmo
  38935. */
  38936. BoundingBoxGizmo.prototype.dispose = function () {
  38937. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38938. this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver);
  38939. this._lineBoundingBox.dispose();
  38940. this._rotateSpheresParent.dispose();
  38941. this._scaleBoxesParent.dispose();
  38942. if (this._dragMesh) {
  38943. this._dragMesh.dispose();
  38944. }
  38945. _super.prototype.dispose.call(this);
  38946. };
  38947. /**
  38948. * 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)
  38949. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  38950. * @returns the bounding box mesh with the passed in mesh as a child
  38951. */
  38952. BoundingBoxGizmo.MakeNotPickableAndWrapInBoundingBox = function (mesh) {
  38953. var makeNotPickable = function (root) {
  38954. root.isPickable = false;
  38955. root.getChildMeshes().forEach(function (c) {
  38956. makeNotPickable(c);
  38957. });
  38958. };
  38959. makeNotPickable(mesh);
  38960. // Reset position to get boudning box from origin with no rotation
  38961. if (!mesh.rotationQuaternion) {
  38962. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(mesh.rotation.y, mesh.rotation.x, mesh.rotation.z);
  38963. }
  38964. var oldPos = mesh.position.clone();
  38965. var oldRot = mesh.rotationQuaternion.clone();
  38966. mesh.rotationQuaternion.set(0, 0, 0, 1);
  38967. mesh.position.set(0, 0, 0);
  38968. // Update bounding dimensions/positions
  38969. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("box", { size: 1 }, mesh.getScene());
  38970. var boundingMinMax = mesh.getHierarchyBoundingVectors();
  38971. boundingMinMax.max.subtractToRef(boundingMinMax.min, box.scaling);
  38972. // Adjust scale to avoid undefined behavior when adding child
  38973. if (box.scaling.y === 0) {
  38974. box.scaling.y = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38975. }
  38976. if (box.scaling.x === 0) {
  38977. box.scaling.x = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38978. }
  38979. if (box.scaling.z === 0) {
  38980. box.scaling.z = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38981. }
  38982. box.position.set((boundingMinMax.max.x + boundingMinMax.min.x) / 2, (boundingMinMax.max.y + boundingMinMax.min.y) / 2, (boundingMinMax.max.z + boundingMinMax.min.z) / 2);
  38983. // Restore original positions
  38984. mesh.addChild(box);
  38985. mesh.rotationQuaternion.copyFrom(oldRot);
  38986. mesh.position.copyFrom(oldPos);
  38987. // Reverse parenting
  38988. mesh.removeChild(box);
  38989. box.addChild(mesh);
  38990. box.visibility = 0;
  38991. return box;
  38992. };
  38993. /**
  38994. * CustomMeshes are not supported by this gizmo
  38995. * @param mesh The mesh to replace the default mesh of the gizmo
  38996. */
  38997. BoundingBoxGizmo.prototype.setCustomMesh = function (mesh) {
  38998. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("Custom meshes are not supported on this gizmo");
  38999. };
  39000. return BoundingBoxGizmo;
  39001. }(_gizmo__WEBPACK_IMPORTED_MODULE_10__["Gizmo"]));
  39002. /***/ }),
  39003. /***/ "./Gizmos/gizmo.ts":
  39004. /*!*************************!*\
  39005. !*** ./Gizmos/gizmo.ts ***!
  39006. \*************************/
  39007. /*! exports provided: Gizmo */
  39008. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39009. "use strict";
  39010. __webpack_require__.r(__webpack_exports__);
  39011. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return Gizmo; });
  39012. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39013. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39014. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39015. /**
  39016. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  39017. */
  39018. var Gizmo = /** @class */ (function () {
  39019. /**
  39020. * Creates a gizmo
  39021. * @param gizmoLayer The utility layer the gizmo will be added to
  39022. */
  39023. function Gizmo(
  39024. /** The utility layer the gizmo will be added to */
  39025. gizmoLayer) {
  39026. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39027. var _this = this;
  39028. this.gizmoLayer = gizmoLayer;
  39029. /**
  39030. * Ratio for the scale of the gizmo (Default: 1)
  39031. */
  39032. this.scaleRatio = 1;
  39033. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  39034. /**
  39035. * If a custom mesh has been set (Default: false)
  39036. */
  39037. this._customMeshSet = false;
  39038. /**
  39039. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  39040. */
  39041. this.updateGizmoRotationToMatchAttachedMesh = true;
  39042. /**
  39043. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  39044. */
  39045. this.updateGizmoPositionToMatchAttachedMesh = true;
  39046. /**
  39047. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  39048. */
  39049. this._updateScale = true;
  39050. this._interactionsEnabled = true;
  39051. this._tempVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  39052. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]("gizmoRootNode", gizmoLayer.utilityLayerScene);
  39053. this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function () {
  39054. _this._update();
  39055. });
  39056. this.attachedMesh = null;
  39057. }
  39058. Object.defineProperty(Gizmo.prototype, "attachedMesh", {
  39059. /**
  39060. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  39061. * * When set, interactions will be enabled
  39062. */
  39063. get: function () {
  39064. return this._attachedMesh;
  39065. },
  39066. set: function (value) {
  39067. this._attachedMesh = value;
  39068. this._rootMesh.setEnabled(value ? true : false);
  39069. this._attachedMeshChanged(value);
  39070. },
  39071. enumerable: true,
  39072. configurable: true
  39073. });
  39074. /**
  39075. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  39076. * @param mesh The mesh to replace the default mesh of the gizmo
  39077. */
  39078. Gizmo.prototype.setCustomMesh = function (mesh) {
  39079. if (mesh.getScene() != this.gizmoLayer.utilityLayerScene) {
  39080. throw "When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";
  39081. }
  39082. this._rootMesh.getChildMeshes().forEach(function (c) {
  39083. c.dispose();
  39084. });
  39085. mesh.parent = this._rootMesh;
  39086. this._customMeshSet = true;
  39087. };
  39088. Gizmo.prototype._attachedMeshChanged = function (value) {
  39089. };
  39090. /**
  39091. * @hidden
  39092. * Updates the gizmo to match the attached mesh's position/rotation
  39093. */
  39094. Gizmo.prototype._update = function () {
  39095. if (this.attachedMesh) {
  39096. var effectiveMesh = this.attachedMesh._effectiveMesh || this.attachedMesh;
  39097. if (this.updateGizmoRotationToMatchAttachedMesh) {
  39098. if (!this._rootMesh.rotationQuaternion) {
  39099. this._rootMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(this._rootMesh.rotation.y, this._rootMesh.rotation.x, this._rootMesh.rotation.z);
  39100. }
  39101. // Remove scaling before getting rotation matrix to get rotation matrix unmodified by scale
  39102. this._tempVector.copyFrom(effectiveMesh.scaling);
  39103. if (effectiveMesh.scaling.x < 0) {
  39104. effectiveMesh.scaling.x *= -1;
  39105. }
  39106. if (effectiveMesh.scaling.y < 0) {
  39107. effectiveMesh.scaling.y *= -1;
  39108. }
  39109. if (effectiveMesh.scaling.z < 0) {
  39110. effectiveMesh.scaling.z *= -1;
  39111. }
  39112. effectiveMesh.computeWorldMatrix().getRotationMatrixToRef(this._tmpMatrix);
  39113. effectiveMesh.scaling.copyFrom(this._tempVector);
  39114. effectiveMesh.computeWorldMatrix();
  39115. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._tmpMatrix, this._rootMesh.rotationQuaternion);
  39116. }
  39117. else if (this._rootMesh.rotationQuaternion) {
  39118. this._rootMesh.rotationQuaternion.set(0, 0, 0, 1);
  39119. }
  39120. if (this.updateGizmoPositionToMatchAttachedMesh) {
  39121. this._rootMesh.position.copyFrom(effectiveMesh.absolutePosition);
  39122. }
  39123. if (this._updateScale && this.gizmoLayer.utilityLayerScene.activeCamera && this.attachedMesh) {
  39124. var cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.globalPosition;
  39125. if (this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition) {
  39126. cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition;
  39127. }
  39128. this._rootMesh.position.subtractToRef(cameraPosition, this._tempVector);
  39129. var dist = this._tempVector.length() * this.scaleRatio;
  39130. this._rootMesh.scaling.set(dist, dist, dist);
  39131. }
  39132. }
  39133. };
  39134. /**
  39135. * Disposes of the gizmo
  39136. */
  39137. Gizmo.prototype.dispose = function () {
  39138. this._rootMesh.dispose();
  39139. if (this._beforeRenderObserver) {
  39140. this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  39141. }
  39142. };
  39143. return Gizmo;
  39144. }());
  39145. /***/ }),
  39146. /***/ "./Gizmos/gizmoManager.ts":
  39147. /*!********************************!*\
  39148. !*** ./Gizmos/gizmoManager.ts ***!
  39149. \********************************/
  39150. /*! exports provided: GizmoManager */
  39151. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39152. "use strict";
  39153. __webpack_require__.r(__webpack_exports__);
  39154. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return GizmoManager; });
  39155. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39156. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  39157. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  39158. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39159. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39160. /* harmony import */ var _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  39161. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  39162. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  39163. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  39164. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  39165. /**
  39166. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  39167. */
  39168. var GizmoManager = /** @class */ (function () {
  39169. /**
  39170. * Instatiates a gizmo manager
  39171. * @param scene the scene to overlay the gizmos on top of
  39172. */
  39173. function GizmoManager(scene) {
  39174. var _this = this;
  39175. this.scene = scene;
  39176. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  39177. this.clearGizmoOnEmptyPointerEvent = false;
  39178. /** Fires an event when the manager is attached to a mesh */
  39179. this.onAttachedToMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  39180. this._gizmosEnabled = { positionGizmo: false, rotationGizmo: false, scaleGizmo: false, boundingBoxGizmo: false };
  39181. this._pointerObserver = null;
  39182. this._attachedMesh = null;
  39183. this._boundingBoxColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromHexString("#0984e3");
  39184. /**
  39185. * When bounding box gizmo is enabled, this can be used to track drag/end events
  39186. */
  39187. this.boundingBoxDragBehavior = new _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]();
  39188. /**
  39189. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  39190. */
  39191. this.attachableMeshes = null;
  39192. /**
  39193. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  39194. */
  39195. this.usePointerToAttachGizmos = true;
  39196. this._defaultKeepDepthUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  39197. this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  39198. this._defaultUtilityLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"].DefaultUtilityLayer;
  39199. this.gizmos = { positionGizmo: null, rotationGizmo: null, scaleGizmo: null, boundingBoxGizmo: null };
  39200. // Instatiate/dispose gizmos based on pointer actions
  39201. this._pointerObserver = scene.onPointerObservable.add(function (pointerInfo) {
  39202. if (!_this.usePointerToAttachGizmos) {
  39203. return;
  39204. }
  39205. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  39206. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh) {
  39207. var node = pointerInfo.pickInfo.pickedMesh;
  39208. if (_this.attachableMeshes == null) {
  39209. // Attach to the most parent node
  39210. while (node && node.parent != null) {
  39211. node = node.parent;
  39212. }
  39213. }
  39214. else {
  39215. // Attach to the parent node that is an attachableMesh
  39216. var found = false;
  39217. _this.attachableMeshes.forEach(function (mesh) {
  39218. if (node && (node == mesh || node.isDescendantOf(mesh))) {
  39219. node = mesh;
  39220. found = true;
  39221. }
  39222. });
  39223. if (!found) {
  39224. node = null;
  39225. }
  39226. }
  39227. if (node instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]) {
  39228. if (_this._attachedMesh != node) {
  39229. _this.attachToMesh(node);
  39230. }
  39231. }
  39232. else {
  39233. if (_this.clearGizmoOnEmptyPointerEvent) {
  39234. _this.attachToMesh(null);
  39235. }
  39236. }
  39237. }
  39238. else {
  39239. if (_this.clearGizmoOnEmptyPointerEvent) {
  39240. _this.attachToMesh(null);
  39241. }
  39242. }
  39243. }
  39244. });
  39245. }
  39246. /**
  39247. * Attaches a set of gizmos to the specified mesh
  39248. * @param mesh The mesh the gizmo's should be attached to
  39249. */
  39250. GizmoManager.prototype.attachToMesh = function (mesh) {
  39251. if (this._attachedMesh) {
  39252. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  39253. }
  39254. this._attachedMesh = mesh;
  39255. for (var key in this.gizmos) {
  39256. var gizmo = (this.gizmos[key]);
  39257. if (gizmo && this._gizmosEnabled[key]) {
  39258. gizmo.attachedMesh = mesh;
  39259. }
  39260. }
  39261. if (this.boundingBoxGizmoEnabled && this._attachedMesh) {
  39262. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  39263. }
  39264. this.onAttachedToMeshObservable.notifyObservers(mesh);
  39265. };
  39266. Object.defineProperty(GizmoManager.prototype, "positionGizmoEnabled", {
  39267. get: function () {
  39268. return this._gizmosEnabled.positionGizmo;
  39269. },
  39270. /**
  39271. * If the position gizmo is enabled
  39272. */
  39273. set: function (value) {
  39274. if (value) {
  39275. if (!this.gizmos.positionGizmo) {
  39276. this.gizmos.positionGizmo = new _positionGizmo__WEBPACK_IMPORTED_MODULE_7__["PositionGizmo"](this._defaultUtilityLayer);
  39277. }
  39278. this.gizmos.positionGizmo.attachedMesh = this._attachedMesh;
  39279. }
  39280. else if (this.gizmos.positionGizmo) {
  39281. this.gizmos.positionGizmo.attachedMesh = null;
  39282. }
  39283. this._gizmosEnabled.positionGizmo = value;
  39284. },
  39285. enumerable: true,
  39286. configurable: true
  39287. });
  39288. Object.defineProperty(GizmoManager.prototype, "rotationGizmoEnabled", {
  39289. get: function () {
  39290. return this._gizmosEnabled.rotationGizmo;
  39291. },
  39292. /**
  39293. * If the rotation gizmo is enabled
  39294. */
  39295. set: function (value) {
  39296. if (value) {
  39297. if (!this.gizmos.rotationGizmo) {
  39298. this.gizmos.rotationGizmo = new _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__["RotationGizmo"](this._defaultUtilityLayer);
  39299. }
  39300. this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh;
  39301. }
  39302. else if (this.gizmos.rotationGizmo) {
  39303. this.gizmos.rotationGizmo.attachedMesh = null;
  39304. }
  39305. this._gizmosEnabled.rotationGizmo = value;
  39306. },
  39307. enumerable: true,
  39308. configurable: true
  39309. });
  39310. Object.defineProperty(GizmoManager.prototype, "scaleGizmoEnabled", {
  39311. get: function () {
  39312. return this._gizmosEnabled.scaleGizmo;
  39313. },
  39314. /**
  39315. * If the scale gizmo is enabled
  39316. */
  39317. set: function (value) {
  39318. if (value) {
  39319. this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"](this._defaultUtilityLayer);
  39320. this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh;
  39321. }
  39322. else if (this.gizmos.scaleGizmo) {
  39323. this.gizmos.scaleGizmo.attachedMesh = null;
  39324. }
  39325. this._gizmosEnabled.scaleGizmo = value;
  39326. },
  39327. enumerable: true,
  39328. configurable: true
  39329. });
  39330. Object.defineProperty(GizmoManager.prototype, "boundingBoxGizmoEnabled", {
  39331. get: function () {
  39332. return this._gizmosEnabled.boundingBoxGizmo;
  39333. },
  39334. /**
  39335. * If the boundingBox gizmo is enabled
  39336. */
  39337. set: function (value) {
  39338. if (value) {
  39339. this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__["BoundingBoxGizmo"](this._boundingBoxColor, this._defaultKeepDepthUtilityLayer);
  39340. this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh;
  39341. if (this._attachedMesh) {
  39342. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  39343. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  39344. }
  39345. }
  39346. else if (this.gizmos.boundingBoxGizmo) {
  39347. if (this._attachedMesh) {
  39348. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  39349. }
  39350. this.gizmos.boundingBoxGizmo.attachedMesh = null;
  39351. }
  39352. this._gizmosEnabled.boundingBoxGizmo = value;
  39353. },
  39354. enumerable: true,
  39355. configurable: true
  39356. });
  39357. /**
  39358. * Disposes of the gizmo manager
  39359. */
  39360. GizmoManager.prototype.dispose = function () {
  39361. this.scene.onPointerObservable.remove(this._pointerObserver);
  39362. for (var key in this.gizmos) {
  39363. var gizmo = (this.gizmos[key]);
  39364. if (gizmo) {
  39365. gizmo.dispose();
  39366. }
  39367. }
  39368. this._defaultKeepDepthUtilityLayer.dispose();
  39369. this.boundingBoxDragBehavior.detach();
  39370. this.onAttachedToMeshObservable.clear();
  39371. };
  39372. return GizmoManager;
  39373. }());
  39374. /***/ }),
  39375. /***/ "./Gizmos/index.ts":
  39376. /*!*************************!*\
  39377. !*** ./Gizmos/index.ts ***!
  39378. \*************************/
  39379. /*! exports provided: AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo */
  39380. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39381. "use strict";
  39382. __webpack_require__.r(__webpack_exports__);
  39383. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  39384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  39385. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  39386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__["AxisScaleGizmo"]; });
  39387. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  39388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__["BoundingBoxGizmo"]; });
  39389. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _gizmo__WEBPACK_IMPORTED_MODULE_3__["Gizmo"]; });
  39391. /* harmony import */ var _gizmoManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmoManager */ "./Gizmos/gizmoManager.ts");
  39392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _gizmoManager__WEBPACK_IMPORTED_MODULE_4__["GizmoManager"]; });
  39393. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  39394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__["PlaneRotationGizmo"]; });
  39395. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  39396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _positionGizmo__WEBPACK_IMPORTED_MODULE_6__["PositionGizmo"]; });
  39397. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  39398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__["RotationGizmo"]; });
  39399. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  39400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"]; });
  39401. /* harmony import */ var _lightGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./lightGizmo */ "./Gizmos/lightGizmo.ts");
  39402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _lightGizmo__WEBPACK_IMPORTED_MODULE_9__["LightGizmo"]; });
  39403. /***/ }),
  39404. /***/ "./Gizmos/lightGizmo.ts":
  39405. /*!******************************!*\
  39406. !*** ./Gizmos/lightGizmo.ts ***!
  39407. \******************************/
  39408. /*! exports provided: LightGizmo */
  39409. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39410. "use strict";
  39411. __webpack_require__.r(__webpack_exports__);
  39412. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return LightGizmo; });
  39413. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39414. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39415. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  39416. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39417. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39418. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  39419. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  39420. /* harmony import */ var _Lights_directionalLight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Lights/directionalLight */ "./Lights/directionalLight.ts");
  39421. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  39422. /* harmony import */ var _Meshes_Builders_hemisphereBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/hemisphereBuilder */ "./Meshes/Builders/hemisphereBuilder.ts");
  39423. /* harmony import */ var _Lights_spotLight__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Lights/spotLight */ "./Lights/spotLight.ts");
  39424. /**
  39425. * Gizmo that enables viewing a light
  39426. */
  39427. var LightGizmo = /** @class */ (function (_super) {
  39428. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LightGizmo, _super);
  39429. /**
  39430. * Creates a LightGizmo
  39431. * @param gizmoLayer The utility layer the gizmo will be added to
  39432. */
  39433. function LightGizmo(gizmoLayer) {
  39434. var _this = _super.call(this, gizmoLayer) || this;
  39435. _this._light = null;
  39436. _this.attachedMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", _this.gizmoLayer.utilityLayerScene);
  39437. _this._material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("light", _this.gizmoLayer.originalScene);
  39438. _this._material.diffuseColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.5, 0.5, 0.5);
  39439. _this._material.specularColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.1, 0.1, 0.1);
  39440. return _this;
  39441. }
  39442. Object.defineProperty(LightGizmo.prototype, "light", {
  39443. get: function () {
  39444. return this._light;
  39445. },
  39446. /**
  39447. * The light that the gizmo is attached to
  39448. */
  39449. set: function (light) {
  39450. var _this = this;
  39451. this._light = light;
  39452. if (light) {
  39453. // Create the mesh for the given light type
  39454. if (this._lightMesh) {
  39455. this._lightMesh.dispose();
  39456. }
  39457. if (light instanceof _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_6__["HemisphericLight"]) {
  39458. this._lightMesh = LightGizmo._CreateHemisphericLightMesh(this.gizmoLayer.utilityLayerScene);
  39459. }
  39460. else if (light instanceof _Lights_directionalLight__WEBPACK_IMPORTED_MODULE_7__["DirectionalLight"]) {
  39461. this._lightMesh = LightGizmo._CreateDirectionalLightMesh(this.gizmoLayer.utilityLayerScene);
  39462. }
  39463. else if (light instanceof _Lights_spotLight__WEBPACK_IMPORTED_MODULE_10__["SpotLight"]) {
  39464. this._lightMesh = LightGizmo._CreateSpotLightMesh(this.gizmoLayer.utilityLayerScene);
  39465. }
  39466. else {
  39467. this._lightMesh = LightGizmo._CreatePointLightMesh(this.gizmoLayer.utilityLayerScene);
  39468. }
  39469. this._lightMesh.getChildMeshes(false).forEach(function (m) {
  39470. m.material = _this._material;
  39471. });
  39472. this._lightMesh.parent = this._rootMesh;
  39473. // Add lighting to the light gizmo
  39474. var gizmoLight = this.gizmoLayer._getSharedGizmoLight();
  39475. gizmoLight.includedOnlyMeshes = gizmoLight.includedOnlyMeshes.concat(this._lightMesh.getChildMeshes(false));
  39476. // Get update position and direction if the light has it
  39477. if (light.position) {
  39478. this.attachedMesh.position.copyFrom(light.position);
  39479. }
  39480. if (light.direction) {
  39481. this._lightMesh.setDirection(light.direction);
  39482. }
  39483. }
  39484. },
  39485. enumerable: true,
  39486. configurable: true
  39487. });
  39488. /**
  39489. * @hidden
  39490. * Updates the gizmo to match the attached mesh's position/rotation
  39491. */
  39492. LightGizmo.prototype._update = function () {
  39493. _super.prototype._update.call(this);
  39494. if (!this._light) {
  39495. return;
  39496. }
  39497. if (this._light.position) {
  39498. this._light.position.copyFrom(this.attachedMesh.position);
  39499. }
  39500. if (this._light.direction) {
  39501. this._light.direction.copyFrom(this._lightMesh.forward);
  39502. }
  39503. if (!this._light.isEnabled()) {
  39504. this._material.diffuseColor.set(0, 0, 0);
  39505. }
  39506. else {
  39507. this._material.diffuseColor.set(this._light.diffuse.r / 3, this._light.diffuse.g / 3, this._light.diffuse.b / 3);
  39508. }
  39509. };
  39510. LightGizmo._CreateHemisphericLightMesh = function (scene) {
  39511. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("hemisphereLight", scene);
  39512. var hemisphere = _Meshes_Builders_hemisphereBuilder__WEBPACK_IMPORTED_MODULE_9__["HemisphereBuilder"].CreateHemisphere(root.name, { segments: 10, diameter: 1 }, scene);
  39513. hemisphere.position.z = -0.15;
  39514. hemisphere.rotation.x = Math.PI / 2;
  39515. hemisphere.parent = root;
  39516. var lines = this._createLightLines(3, scene);
  39517. lines.parent = root;
  39518. lines.position.z - 0.15;
  39519. root.scaling.scaleInPlace(LightGizmo._Scale);
  39520. root.rotation.x = Math.PI / 2;
  39521. return root;
  39522. };
  39523. LightGizmo._CreatePointLightMesh = function (scene) {
  39524. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("pointLight", scene);
  39525. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_8__["SphereBuilder"].CreateSphere(root.name, { segments: 10, diameter: 1 }, scene);
  39526. sphere.rotation.x = Math.PI / 2;
  39527. sphere.parent = root;
  39528. var lines = this._createLightLines(5, scene);
  39529. lines.parent = root;
  39530. root.scaling.scaleInPlace(LightGizmo._Scale);
  39531. root.rotation.x = Math.PI / 2;
  39532. return root;
  39533. };
  39534. LightGizmo._CreateSpotLightMesh = function (scene) {
  39535. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("spotLight", scene);
  39536. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_8__["SphereBuilder"].CreateSphere(root.name, { segments: 10, diameter: 1 }, scene);
  39537. sphere.parent = root;
  39538. var hemisphere = _Meshes_Builders_hemisphereBuilder__WEBPACK_IMPORTED_MODULE_9__["HemisphereBuilder"].CreateHemisphere(root.name, { segments: 10, diameter: 2 }, scene);
  39539. hemisphere.parent = root;
  39540. hemisphere.rotation.x = -Math.PI / 2;
  39541. var lines = this._createLightLines(2, scene);
  39542. lines.parent = root;
  39543. root.scaling.scaleInPlace(LightGizmo._Scale);
  39544. root.rotation.x = Math.PI / 2;
  39545. return root;
  39546. };
  39547. LightGizmo._CreateDirectionalLightMesh = function (scene) {
  39548. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("directionalLight", scene);
  39549. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](root.name, scene);
  39550. mesh.parent = root;
  39551. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_8__["SphereBuilder"].CreateSphere(root.name, { diameter: 1.2, segments: 10 }, scene);
  39552. sphere.parent = mesh;
  39553. var line = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateCylinder(root.name, 6, 0.3, 0.3, 6, 1, scene);
  39554. line.parent = mesh;
  39555. var left = line.clone(root.name);
  39556. left.scaling.y = 0.5;
  39557. left.position.x += 1.25;
  39558. var right = line.clone(root.name);
  39559. right.scaling.y = 0.5;
  39560. right.position.x += -1.25;
  39561. var arrowHead = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateCylinder(root.name, 1, 0, 0.6, 6, 1, scene);
  39562. arrowHead.position.y += 3;
  39563. arrowHead.parent = mesh;
  39564. var left = arrowHead.clone(root.name);
  39565. left.position.y = 1.5;
  39566. left.position.x += 1.25;
  39567. var right = arrowHead.clone(root.name);
  39568. right.position.y = 1.5;
  39569. right.position.x += -1.25;
  39570. mesh.scaling.scaleInPlace(LightGizmo._Scale);
  39571. mesh.rotation.z = Math.PI / 2;
  39572. mesh.rotation.y = Math.PI / 2;
  39573. return root;
  39574. };
  39575. // Static helper methods
  39576. LightGizmo._Scale = 0.007;
  39577. /**
  39578. * Creates the lines for a light mesh
  39579. */
  39580. LightGizmo._createLightLines = function (levels, scene) {
  39581. var distFromSphere = 1.2;
  39582. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("root", scene);
  39583. root.rotation.x = Math.PI / 2;
  39584. // Create the top line, this will be cloned for all other lines
  39585. var linePivot = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("linePivot", scene);
  39586. linePivot.parent = root;
  39587. var line = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateCylinder("line", 2, 0.2, 0.3, 6, 1, scene);
  39588. line.position.y = line.scaling.y / 2 + distFromSphere;
  39589. line.parent = linePivot;
  39590. if (levels < 2) {
  39591. return linePivot;
  39592. }
  39593. for (var i = 0; i < 4; i++) {
  39594. var l = linePivot.clone("lineParentClone");
  39595. l.rotation.z = Math.PI / 4;
  39596. l.rotation.y = (Math.PI / 2) + (Math.PI / 2 * i);
  39597. l.getChildMeshes()[0].scaling.y = 0.5;
  39598. l.getChildMeshes()[0].scaling.x = l.getChildMeshes()[0].scaling.z = 0.8;
  39599. l.getChildMeshes()[0].position.y = l.getChildMeshes()[0].scaling.y / 2 + distFromSphere;
  39600. }
  39601. if (levels < 3) {
  39602. return root;
  39603. }
  39604. for (var i = 0; i < 4; i++) {
  39605. var l = linePivot.clone("linePivotClone");
  39606. l.rotation.z = Math.PI / 2;
  39607. l.rotation.y = (Math.PI / 2 * i);
  39608. }
  39609. if (levels < 4) {
  39610. return root;
  39611. }
  39612. for (var i = 0; i < 4; i++) {
  39613. var l = linePivot.clone("linePivotClone");
  39614. l.rotation.z = Math.PI + (Math.PI / 4);
  39615. l.rotation.y = (Math.PI / 2) + (Math.PI / 2 * i);
  39616. l.getChildMeshes()[0].scaling.y = 0.5;
  39617. l.getChildMeshes()[0].scaling.x = l.getChildMeshes()[0].scaling.z = 0.8;
  39618. l.getChildMeshes()[0].position.y = l.getChildMeshes()[0].scaling.y / 2 + distFromSphere;
  39619. }
  39620. if (levels < 5) {
  39621. return root;
  39622. }
  39623. var l = linePivot.clone("linePivotClone");
  39624. l.rotation.z = Math.PI;
  39625. return root;
  39626. };
  39627. return LightGizmo;
  39628. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  39629. /***/ }),
  39630. /***/ "./Gizmos/planeRotationGizmo.ts":
  39631. /*!**************************************!*\
  39632. !*** ./Gizmos/planeRotationGizmo.ts ***!
  39633. \**************************************/
  39634. /*! exports provided: PlaneRotationGizmo */
  39635. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39636. "use strict";
  39637. __webpack_require__.r(__webpack_exports__);
  39638. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return PlaneRotationGizmo; });
  39639. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39640. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39641. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39642. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  39643. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39644. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  39645. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39646. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39647. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  39648. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  39649. /**
  39650. * Single plane rotation gizmo
  39651. */
  39652. var PlaneRotationGizmo = /** @class */ (function (_super) {
  39653. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaneRotationGizmo, _super);
  39654. /**
  39655. * Creates a PlaneRotationGizmo
  39656. * @param gizmoLayer The utility layer the gizmo will be added to
  39657. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  39658. * @param color The color of the gizmo
  39659. * @param tessellation Amount of tessellation to be used when creating rotation circles
  39660. */
  39661. function PlaneRotationGizmo(planeNormal, color, gizmoLayer, tessellation) {
  39662. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  39663. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39664. if (tessellation === void 0) { tessellation = 32; }
  39665. var _this = _super.call(this, gizmoLayer) || this;
  39666. _this._pointerObserver = null;
  39667. /**
  39668. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  39669. */
  39670. _this.snapDistance = 0;
  39671. /**
  39672. * Event that fires each time the gizmo snaps to a new location.
  39673. * * snapDistance is the the change in distance
  39674. */
  39675. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39676. // Create Material
  39677. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  39678. coloredMaterial.diffuseColor = color;
  39679. coloredMaterial.specularColor = color.subtract(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.1, 0.1, 0.1));
  39680. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  39681. hoverMaterial.diffuseColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  39682. // Build mesh on root node
  39683. var parentMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  39684. var drag = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateTorus("", 0.6, 0.03, tessellation, gizmoLayer.utilityLayerScene);
  39685. drag.visibility = 0;
  39686. var rotationMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateTorus("", 0.6, 0.005, tessellation, gizmoLayer.utilityLayerScene);
  39687. rotationMesh.material = coloredMaterial;
  39688. // Position arrow pointing in its drag axis
  39689. rotationMesh.rotation.x = Math.PI / 2;
  39690. drag.rotation.x = Math.PI / 2;
  39691. parentMesh.addChild(rotationMesh);
  39692. parentMesh.addChild(drag);
  39693. parentMesh.lookAt(_this._rootMesh.position.add(planeNormal));
  39694. _this._rootMesh.addChild(parentMesh);
  39695. parentMesh.scaling.scaleInPlace(1 / 3);
  39696. // Add drag behavior to handle events when the gizmo is dragged
  39697. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragPlaneNormal: planeNormal });
  39698. _this.dragBehavior.moveAttached = false;
  39699. _this.dragBehavior.maxDragAngle = Math.PI * 9 / 20;
  39700. _this.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = true;
  39701. _this._rootMesh.addBehavior(_this.dragBehavior);
  39702. var lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39703. _this.dragBehavior.onDragStartObservable.add(function (e) {
  39704. if (_this.attachedMesh) {
  39705. lastDragPosition.copyFrom(e.dragPlanePoint);
  39706. }
  39707. });
  39708. var rotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  39709. var planeNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39710. var localPlaneNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39711. var tmpSnapEvent = { snapDistance: 0 };
  39712. var currentSnapDragDistance = 0;
  39713. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  39714. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39715. var amountToRotate = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  39716. _this.dragBehavior.onDragObservable.add(function (event) {
  39717. if (_this.attachedMesh) {
  39718. if (!_this.attachedMesh.rotationQuaternion) {
  39719. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  39720. }
  39721. // Calc angle over full 360 degree (https://stackoverflow.com/questions/43493711/the-angle-between-two-3d-vectors-with-a-result-range-0-360)
  39722. var newVector = event.dragPlanePoint.subtract(_this.attachedMesh.absolutePosition).normalize();
  39723. var originalVector = lastDragPosition.subtract(_this.attachedMesh.absolutePosition).normalize();
  39724. var cross = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(newVector, originalVector);
  39725. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(newVector, originalVector);
  39726. var angle = Math.atan2(cross.length(), dot);
  39727. planeNormalTowardsCamera.copyFrom(planeNormal);
  39728. localPlaneNormalTowardsCamera.copyFrom(planeNormal);
  39729. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  39730. _this.attachedMesh.rotationQuaternion.toRotationMatrix(rotationMatrix);
  39731. localPlaneNormalTowardsCamera = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(planeNormalTowardsCamera, rotationMatrix);
  39732. }
  39733. // Flip up vector depending on which side the camera is on
  39734. if (gizmoLayer.utilityLayerScene.activeCamera) {
  39735. var camVec = gizmoLayer.utilityLayerScene.activeCamera.position.subtract(_this.attachedMesh.position);
  39736. if (_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(camVec, localPlaneNormalTowardsCamera) > 0) {
  39737. planeNormalTowardsCamera.scaleInPlace(-1);
  39738. localPlaneNormalTowardsCamera.scaleInPlace(-1);
  39739. }
  39740. }
  39741. var halfCircleSide = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(localPlaneNormalTowardsCamera, cross) > 0.0;
  39742. if (halfCircleSide) {
  39743. angle = -angle;
  39744. }
  39745. // Snapping logic
  39746. var snapped = false;
  39747. if (_this.snapDistance != 0) {
  39748. currentSnapDragDistance += angle;
  39749. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  39750. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  39751. if (currentSnapDragDistance < 0) {
  39752. dragSteps *= -1;
  39753. }
  39754. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  39755. angle = _this.snapDistance * dragSteps;
  39756. snapped = true;
  39757. }
  39758. else {
  39759. angle = 0;
  39760. }
  39761. }
  39762. // If the mesh has a parent, convert needed world rotation to local rotation
  39763. tmpMatrix.reset();
  39764. if (_this.attachedMesh.parent) {
  39765. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  39766. tmpMatrix.getRotationMatrixToRef(tmpMatrix);
  39767. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(planeNormalTowardsCamera, tmpMatrix, planeNormalTowardsCamera);
  39768. }
  39769. // Convert angle and axis to quaternion (http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm)
  39770. var quaternionCoefficient = Math.sin(angle / 2);
  39771. amountToRotate.set(planeNormalTowardsCamera.x * quaternionCoefficient, planeNormalTowardsCamera.y * quaternionCoefficient, planeNormalTowardsCamera.z * quaternionCoefficient, Math.cos(angle / 2));
  39772. // 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
  39773. if (tmpMatrix.determinant() > 0) {
  39774. amountToRotate.toEulerAnglesToRef(tmpVector);
  39775. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(tmpVector.y, -tmpVector.x, -tmpVector.z, amountToRotate);
  39776. }
  39777. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  39778. // Rotate selected mesh quaternion over fixed axis
  39779. _this.attachedMesh.rotationQuaternion.multiplyToRef(amountToRotate, _this.attachedMesh.rotationQuaternion);
  39780. }
  39781. else {
  39782. // Rotate selected mesh quaternion over rotated axis
  39783. amountToRotate.multiplyToRef(_this.attachedMesh.rotationQuaternion, _this.attachedMesh.rotationQuaternion);
  39784. }
  39785. lastDragPosition.copyFrom(event.dragPlanePoint);
  39786. if (snapped) {
  39787. tmpSnapEvent.snapDistance = angle;
  39788. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  39789. }
  39790. }
  39791. });
  39792. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  39793. if (_this._customMeshSet) {
  39794. return;
  39795. }
  39796. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  39797. var material = isHovered ? hoverMaterial : coloredMaterial;
  39798. _this._rootMesh.getChildMeshes().forEach(function (m) {
  39799. m.material = material;
  39800. if (m.color) {
  39801. m.color = material.diffuseColor;
  39802. }
  39803. });
  39804. });
  39805. var light = gizmoLayer._getSharedGizmoLight();
  39806. light.includedOnlyMeshes = light.includedOnlyMeshes.concat(_this._rootMesh.getChildMeshes(false));
  39807. return _this;
  39808. }
  39809. PlaneRotationGizmo.prototype._attachedMeshChanged = function (value) {
  39810. if (this.dragBehavior) {
  39811. this.dragBehavior.enabled = value ? true : false;
  39812. }
  39813. };
  39814. /**
  39815. * Disposes of the gizmo
  39816. */
  39817. PlaneRotationGizmo.prototype.dispose = function () {
  39818. this.onSnapObservable.clear();
  39819. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  39820. this.dragBehavior.detach();
  39821. _super.prototype.dispose.call(this);
  39822. };
  39823. return PlaneRotationGizmo;
  39824. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  39825. /***/ }),
  39826. /***/ "./Gizmos/positionGizmo.ts":
  39827. /*!*********************************!*\
  39828. !*** ./Gizmos/positionGizmo.ts ***!
  39829. \*********************************/
  39830. /*! exports provided: PositionGizmo */
  39831. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39832. "use strict";
  39833. __webpack_require__.r(__webpack_exports__);
  39834. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return PositionGizmo; });
  39835. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39836. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39837. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39838. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39839. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39840. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  39841. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39842. /**
  39843. * Gizmo that enables dragging a mesh along 3 axis
  39844. */
  39845. var PositionGizmo = /** @class */ (function (_super) {
  39846. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PositionGizmo, _super);
  39847. /**
  39848. * Creates a PositionGizmo
  39849. * @param gizmoLayer The utility layer the gizmo will be added to
  39850. */
  39851. function PositionGizmo(gizmoLayer) {
  39852. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39853. var _this = _super.call(this, gizmoLayer) || this;
  39854. /** Fires an event when any of it's sub gizmos are dragged */
  39855. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39856. /** Fires an event when any of it's sub gizmos are released from dragging */
  39857. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39858. _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);
  39859. _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);
  39860. _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);
  39861. // Relay drag events
  39862. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  39863. gizmo.dragBehavior.onDragStartObservable.add(function () {
  39864. _this.onDragStartObservable.notifyObservers({});
  39865. });
  39866. gizmo.dragBehavior.onDragEndObservable.add(function () {
  39867. _this.onDragEndObservable.notifyObservers({});
  39868. });
  39869. });
  39870. _this.attachedMesh = null;
  39871. return _this;
  39872. }
  39873. Object.defineProperty(PositionGizmo.prototype, "attachedMesh", {
  39874. get: function () {
  39875. return this.xGizmo.attachedMesh;
  39876. },
  39877. set: function (mesh) {
  39878. if (this.xGizmo) {
  39879. this.xGizmo.attachedMesh = mesh;
  39880. this.yGizmo.attachedMesh = mesh;
  39881. this.zGizmo.attachedMesh = mesh;
  39882. }
  39883. },
  39884. enumerable: true,
  39885. configurable: true
  39886. });
  39887. Object.defineProperty(PositionGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  39888. get: function () {
  39889. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  39890. },
  39891. set: function (value) {
  39892. if (this.xGizmo) {
  39893. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39894. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39895. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39896. }
  39897. },
  39898. enumerable: true,
  39899. configurable: true
  39900. });
  39901. Object.defineProperty(PositionGizmo.prototype, "snapDistance", {
  39902. get: function () {
  39903. return this.xGizmo.snapDistance;
  39904. },
  39905. /**
  39906. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39907. */
  39908. set: function (value) {
  39909. if (this.xGizmo) {
  39910. this.xGizmo.snapDistance = value;
  39911. this.yGizmo.snapDistance = value;
  39912. this.zGizmo.snapDistance = value;
  39913. }
  39914. },
  39915. enumerable: true,
  39916. configurable: true
  39917. });
  39918. Object.defineProperty(PositionGizmo.prototype, "scaleRatio", {
  39919. get: function () {
  39920. return this.xGizmo.scaleRatio;
  39921. },
  39922. /**
  39923. * Ratio for the scale of the gizmo (Default: 1)
  39924. */
  39925. set: function (value) {
  39926. if (this.xGizmo) {
  39927. this.xGizmo.scaleRatio = value;
  39928. this.yGizmo.scaleRatio = value;
  39929. this.zGizmo.scaleRatio = value;
  39930. }
  39931. },
  39932. enumerable: true,
  39933. configurable: true
  39934. });
  39935. /**
  39936. * Disposes of the gizmo
  39937. */
  39938. PositionGizmo.prototype.dispose = function () {
  39939. this.xGizmo.dispose();
  39940. this.yGizmo.dispose();
  39941. this.zGizmo.dispose();
  39942. this.onDragStartObservable.clear();
  39943. this.onDragEndObservable.clear();
  39944. };
  39945. /**
  39946. * CustomMeshes are not supported by this gizmo
  39947. * @param mesh The mesh to replace the default mesh of the gizmo
  39948. */
  39949. PositionGizmo.prototype.setCustomMesh = function (mesh) {
  39950. _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)");
  39951. };
  39952. return PositionGizmo;
  39953. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  39954. /***/ }),
  39955. /***/ "./Gizmos/rotationGizmo.ts":
  39956. /*!*********************************!*\
  39957. !*** ./Gizmos/rotationGizmo.ts ***!
  39958. \*********************************/
  39959. /*! exports provided: RotationGizmo */
  39960. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39961. "use strict";
  39962. __webpack_require__.r(__webpack_exports__);
  39963. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return RotationGizmo; });
  39964. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39965. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39966. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39967. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39968. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39969. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  39970. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39971. /**
  39972. * Gizmo that enables rotating a mesh along 3 axis
  39973. */
  39974. var RotationGizmo = /** @class */ (function (_super) {
  39975. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RotationGizmo, _super);
  39976. /**
  39977. * Creates a RotationGizmo
  39978. * @param gizmoLayer The utility layer the gizmo will be added to
  39979. * @param tessellation Amount of tessellation to be used when creating rotation circles
  39980. */
  39981. function RotationGizmo(gizmoLayer, tessellation) {
  39982. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39983. if (tessellation === void 0) { tessellation = 32; }
  39984. var _this = _super.call(this, gizmoLayer) || this;
  39985. /** Fires an event when any of it's sub gizmos are dragged */
  39986. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39987. /** Fires an event when any of it's sub gizmos are released from dragging */
  39988. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39989. _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);
  39990. _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);
  39991. _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);
  39992. // Relay drag events
  39993. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  39994. gizmo.dragBehavior.onDragStartObservable.add(function () {
  39995. _this.onDragStartObservable.notifyObservers({});
  39996. });
  39997. gizmo.dragBehavior.onDragEndObservable.add(function () {
  39998. _this.onDragEndObservable.notifyObservers({});
  39999. });
  40000. });
  40001. _this.attachedMesh = null;
  40002. return _this;
  40003. }
  40004. Object.defineProperty(RotationGizmo.prototype, "attachedMesh", {
  40005. get: function () {
  40006. return this.xGizmo.attachedMesh;
  40007. },
  40008. set: function (mesh) {
  40009. if (this.xGizmo) {
  40010. this.xGizmo.attachedMesh = mesh;
  40011. this.yGizmo.attachedMesh = mesh;
  40012. this.zGizmo.attachedMesh = mesh;
  40013. }
  40014. },
  40015. enumerable: true,
  40016. configurable: true
  40017. });
  40018. Object.defineProperty(RotationGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  40019. get: function () {
  40020. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  40021. },
  40022. set: function (value) {
  40023. if (this.xGizmo) {
  40024. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40025. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40026. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40027. }
  40028. },
  40029. enumerable: true,
  40030. configurable: true
  40031. });
  40032. Object.defineProperty(RotationGizmo.prototype, "snapDistance", {
  40033. get: function () {
  40034. return this.xGizmo.snapDistance;
  40035. },
  40036. /**
  40037. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40038. */
  40039. set: function (value) {
  40040. if (this.xGizmo) {
  40041. this.xGizmo.snapDistance = value;
  40042. this.yGizmo.snapDistance = value;
  40043. this.zGizmo.snapDistance = value;
  40044. }
  40045. },
  40046. enumerable: true,
  40047. configurable: true
  40048. });
  40049. Object.defineProperty(RotationGizmo.prototype, "scaleRatio", {
  40050. get: function () {
  40051. return this.xGizmo.scaleRatio;
  40052. },
  40053. /**
  40054. * Ratio for the scale of the gizmo (Default: 1)
  40055. */
  40056. set: function (value) {
  40057. if (this.xGizmo) {
  40058. this.xGizmo.scaleRatio = value;
  40059. this.yGizmo.scaleRatio = value;
  40060. this.zGizmo.scaleRatio = value;
  40061. }
  40062. },
  40063. enumerable: true,
  40064. configurable: true
  40065. });
  40066. /**
  40067. * Disposes of the gizmo
  40068. */
  40069. RotationGizmo.prototype.dispose = function () {
  40070. this.xGizmo.dispose();
  40071. this.yGizmo.dispose();
  40072. this.zGizmo.dispose();
  40073. this.onDragStartObservable.clear();
  40074. this.onDragEndObservable.clear();
  40075. };
  40076. /**
  40077. * CustomMeshes are not supported by this gizmo
  40078. * @param mesh The mesh to replace the default mesh of the gizmo
  40079. */
  40080. RotationGizmo.prototype.setCustomMesh = function (mesh) {
  40081. _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)");
  40082. };
  40083. return RotationGizmo;
  40084. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  40085. /***/ }),
  40086. /***/ "./Gizmos/scaleGizmo.ts":
  40087. /*!******************************!*\
  40088. !*** ./Gizmos/scaleGizmo.ts ***!
  40089. \******************************/
  40090. /*! exports provided: ScaleGizmo */
  40091. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40092. "use strict";
  40093. __webpack_require__.r(__webpack_exports__);
  40094. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return ScaleGizmo; });
  40095. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40096. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  40097. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40098. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40099. /* harmony import */ var _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  40100. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  40101. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  40102. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  40103. /**
  40104. * Gizmo that enables scaling a mesh along 3 axis
  40105. */
  40106. var ScaleGizmo = /** @class */ (function (_super) {
  40107. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScaleGizmo, _super);
  40108. /**
  40109. * Creates a ScaleGizmo
  40110. * @param gizmoLayer The utility layer the gizmo will be added to
  40111. */
  40112. function ScaleGizmo(gizmoLayer) {
  40113. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  40114. var _this = _super.call(this, gizmoLayer) || this;
  40115. /** Fires an event when any of it's sub gizmos are dragged */
  40116. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  40117. /** Fires an event when any of it's sub gizmos are released from dragging */
  40118. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  40119. _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);
  40120. _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);
  40121. _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);
  40122. // Create uniform scale gizmo
  40123. _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);
  40124. _this.uniformScaleGizmo.updateGizmoRotationToMatchAttachedMesh = false;
  40125. _this.uniformScaleGizmo.uniformScaling = true;
  40126. var uniformScalingMesh = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  40127. uniformScalingMesh.scaling.scaleInPlace(0.02);
  40128. uniformScalingMesh.visibility = 0;
  40129. var octahedron = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  40130. octahedron.scaling.scaleInPlace(0.007);
  40131. uniformScalingMesh.addChild(octahedron);
  40132. _this.uniformScaleGizmo.setCustomMesh(uniformScalingMesh, true);
  40133. var light = gizmoLayer._getSharedGizmoLight();
  40134. light.includedOnlyMeshes = light.includedOnlyMeshes.concat(octahedron);
  40135. // Relay drag events
  40136. [_this.xGizmo, _this.yGizmo, _this.zGizmo, _this.uniformScaleGizmo].forEach(function (gizmo) {
  40137. gizmo.dragBehavior.onDragStartObservable.add(function () {
  40138. _this.onDragStartObservable.notifyObservers({});
  40139. });
  40140. gizmo.dragBehavior.onDragEndObservable.add(function () {
  40141. _this.onDragEndObservable.notifyObservers({});
  40142. });
  40143. });
  40144. _this.attachedMesh = null;
  40145. return _this;
  40146. }
  40147. Object.defineProperty(ScaleGizmo.prototype, "attachedMesh", {
  40148. get: function () {
  40149. return this.xGizmo.attachedMesh;
  40150. },
  40151. set: function (mesh) {
  40152. if (this.xGizmo) {
  40153. this.xGizmo.attachedMesh = mesh;
  40154. this.yGizmo.attachedMesh = mesh;
  40155. this.zGizmo.attachedMesh = mesh;
  40156. this.uniformScaleGizmo.attachedMesh = mesh;
  40157. }
  40158. },
  40159. enumerable: true,
  40160. configurable: true
  40161. });
  40162. Object.defineProperty(ScaleGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  40163. get: function () {
  40164. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  40165. },
  40166. set: function (value) {
  40167. if (!value) {
  40168. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.");
  40169. }
  40170. if (this.xGizmo) {
  40171. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40172. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40173. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40174. }
  40175. },
  40176. enumerable: true,
  40177. configurable: true
  40178. });
  40179. Object.defineProperty(ScaleGizmo.prototype, "snapDistance", {
  40180. get: function () {
  40181. return this.xGizmo.snapDistance;
  40182. },
  40183. /**
  40184. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40185. */
  40186. set: function (value) {
  40187. if (this.xGizmo) {
  40188. this.xGizmo.snapDistance = value;
  40189. this.yGizmo.snapDistance = value;
  40190. this.zGizmo.snapDistance = value;
  40191. this.uniformScaleGizmo.snapDistance = value;
  40192. }
  40193. },
  40194. enumerable: true,
  40195. configurable: true
  40196. });
  40197. Object.defineProperty(ScaleGizmo.prototype, "scaleRatio", {
  40198. get: function () {
  40199. return this.xGizmo.scaleRatio;
  40200. },
  40201. /**
  40202. * Ratio for the scale of the gizmo (Default: 1)
  40203. */
  40204. set: function (value) {
  40205. if (this.xGizmo) {
  40206. this.xGizmo.scaleRatio = value;
  40207. this.yGizmo.scaleRatio = value;
  40208. this.zGizmo.scaleRatio = value;
  40209. this.uniformScaleGizmo.scaleRatio = value;
  40210. }
  40211. },
  40212. enumerable: true,
  40213. configurable: true
  40214. });
  40215. /**
  40216. * Disposes of the gizmo
  40217. */
  40218. ScaleGizmo.prototype.dispose = function () {
  40219. this.xGizmo.dispose();
  40220. this.yGizmo.dispose();
  40221. this.zGizmo.dispose();
  40222. this.uniformScaleGizmo.dispose();
  40223. this.onDragStartObservable.clear();
  40224. this.onDragEndObservable.clear();
  40225. };
  40226. return ScaleGizmo;
  40227. }(_gizmo__WEBPACK_IMPORTED_MODULE_5__["Gizmo"]));
  40228. /***/ }),
  40229. /***/ "./Helpers/environmentHelper.ts":
  40230. /*!**************************************!*\
  40231. !*** ./Helpers/environmentHelper.ts ***!
  40232. \**************************************/
  40233. /*! exports provided: EnvironmentHelper */
  40234. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40235. "use strict";
  40236. __webpack_require__.r(__webpack_exports__);
  40237. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return EnvironmentHelper; });
  40238. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40239. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40240. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  40241. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40242. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  40243. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  40244. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40245. /* harmony import */ var _Materials_Textures_mirrorTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  40246. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  40247. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  40248. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  40249. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  40250. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  40251. /**
  40252. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  40253. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  40254. * It also helps with the default setup of your imageProcessing configuration.
  40255. */
  40256. var EnvironmentHelper = /** @class */ (function () {
  40257. /**
  40258. * constructor
  40259. * @param options Defines the options we want to customize the helper
  40260. * @param scene The scene to add the material to
  40261. */
  40262. function EnvironmentHelper(options, scene) {
  40263. var _this = this;
  40264. this._errorHandler = function (message, exception) {
  40265. _this.onErrorObservable.notifyObservers({ message: message, exception: exception });
  40266. };
  40267. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, EnvironmentHelper._getDefaultOptions(), options);
  40268. this._scene = scene;
  40269. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  40270. this._setupBackground();
  40271. this._setupImageProcessing();
  40272. }
  40273. /**
  40274. * Creates the default options for the helper.
  40275. */
  40276. EnvironmentHelper._getDefaultOptions = function () {
  40277. return {
  40278. createGround: true,
  40279. groundSize: 15,
  40280. groundTexture: this._groundTextureCDNUrl,
  40281. groundColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  40282. groundOpacity: 0.9,
  40283. enableGroundShadow: true,
  40284. groundShadowLevel: 0.5,
  40285. enableGroundMirror: false,
  40286. groundMirrorSizeRatio: 0.3,
  40287. groundMirrorBlurKernel: 64,
  40288. groundMirrorAmount: 1,
  40289. groundMirrorFresnelWeight: 1,
  40290. groundMirrorFallOffDistance: 0,
  40291. groundMirrorTextureType: _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT,
  40292. groundYBias: 0.00001,
  40293. createSkybox: true,
  40294. skyboxSize: 20,
  40295. skyboxTexture: this._skyboxTextureCDNUrl,
  40296. skyboxColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  40297. backgroundYRotation: 0,
  40298. sizeAuto: true,
  40299. rootPosition: _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(),
  40300. setupImageProcessing: true,
  40301. environmentTexture: this._environmentTextureCDNUrl,
  40302. cameraExposure: 0.8,
  40303. cameraContrast: 1.2,
  40304. toneMappingEnabled: true,
  40305. };
  40306. };
  40307. Object.defineProperty(EnvironmentHelper.prototype, "rootMesh", {
  40308. /**
  40309. * Gets the root mesh created by the helper.
  40310. */
  40311. get: function () {
  40312. return this._rootMesh;
  40313. },
  40314. enumerable: true,
  40315. configurable: true
  40316. });
  40317. Object.defineProperty(EnvironmentHelper.prototype, "skybox", {
  40318. /**
  40319. * Gets the skybox created by the helper.
  40320. */
  40321. get: function () {
  40322. return this._skybox;
  40323. },
  40324. enumerable: true,
  40325. configurable: true
  40326. });
  40327. Object.defineProperty(EnvironmentHelper.prototype, "skyboxTexture", {
  40328. /**
  40329. * Gets the skybox texture created by the helper.
  40330. */
  40331. get: function () {
  40332. return this._skyboxTexture;
  40333. },
  40334. enumerable: true,
  40335. configurable: true
  40336. });
  40337. Object.defineProperty(EnvironmentHelper.prototype, "skyboxMaterial", {
  40338. /**
  40339. * Gets the skybox material created by the helper.
  40340. */
  40341. get: function () {
  40342. return this._skyboxMaterial;
  40343. },
  40344. enumerable: true,
  40345. configurable: true
  40346. });
  40347. Object.defineProperty(EnvironmentHelper.prototype, "ground", {
  40348. /**
  40349. * Gets the ground mesh created by the helper.
  40350. */
  40351. get: function () {
  40352. return this._ground;
  40353. },
  40354. enumerable: true,
  40355. configurable: true
  40356. });
  40357. Object.defineProperty(EnvironmentHelper.prototype, "groundTexture", {
  40358. /**
  40359. * Gets the ground texture created by the helper.
  40360. */
  40361. get: function () {
  40362. return this._groundTexture;
  40363. },
  40364. enumerable: true,
  40365. configurable: true
  40366. });
  40367. Object.defineProperty(EnvironmentHelper.prototype, "groundMirror", {
  40368. /**
  40369. * Gets the ground mirror created by the helper.
  40370. */
  40371. get: function () {
  40372. return this._groundMirror;
  40373. },
  40374. enumerable: true,
  40375. configurable: true
  40376. });
  40377. Object.defineProperty(EnvironmentHelper.prototype, "groundMirrorRenderList", {
  40378. /**
  40379. * Gets the ground mirror render list to helps pushing the meshes
  40380. * you wish in the ground reflection.
  40381. */
  40382. get: function () {
  40383. if (this._groundMirror) {
  40384. return this._groundMirror.renderList;
  40385. }
  40386. return null;
  40387. },
  40388. enumerable: true,
  40389. configurable: true
  40390. });
  40391. Object.defineProperty(EnvironmentHelper.prototype, "groundMaterial", {
  40392. /**
  40393. * Gets the ground material created by the helper.
  40394. */
  40395. get: function () {
  40396. return this._groundMaterial;
  40397. },
  40398. enumerable: true,
  40399. configurable: true
  40400. });
  40401. /**
  40402. * Updates the background according to the new options
  40403. * @param options
  40404. */
  40405. EnvironmentHelper.prototype.updateOptions = function (options) {
  40406. var newOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, this._options, options);
  40407. if (this._ground && !newOptions.createGround) {
  40408. this._ground.dispose();
  40409. this._ground = null;
  40410. }
  40411. if (this._groundMaterial && !newOptions.createGround) {
  40412. this._groundMaterial.dispose();
  40413. this._groundMaterial = null;
  40414. }
  40415. if (this._groundTexture) {
  40416. if (this._options.groundTexture != newOptions.groundTexture) {
  40417. this._groundTexture.dispose();
  40418. this._groundTexture = null;
  40419. }
  40420. }
  40421. if (this._skybox && !newOptions.createSkybox) {
  40422. this._skybox.dispose();
  40423. this._skybox = null;
  40424. }
  40425. if (this._skyboxMaterial && !newOptions.createSkybox) {
  40426. this._skyboxMaterial.dispose();
  40427. this._skyboxMaterial = null;
  40428. }
  40429. if (this._skyboxTexture) {
  40430. if (this._options.skyboxTexture != newOptions.skyboxTexture) {
  40431. this._skyboxTexture.dispose();
  40432. this._skyboxTexture = null;
  40433. }
  40434. }
  40435. if (this._groundMirror && !newOptions.enableGroundMirror) {
  40436. this._groundMirror.dispose();
  40437. this._groundMirror = null;
  40438. }
  40439. if (this._scene.environmentTexture) {
  40440. if (this._options.environmentTexture != newOptions.environmentTexture) {
  40441. this._scene.environmentTexture.dispose();
  40442. }
  40443. }
  40444. this._options = newOptions;
  40445. this._setupBackground();
  40446. this._setupImageProcessing();
  40447. };
  40448. /**
  40449. * Sets the primary color of all the available elements.
  40450. * @param color the main color to affect to the ground and the background
  40451. */
  40452. EnvironmentHelper.prototype.setMainColor = function (color) {
  40453. if (this.groundMaterial) {
  40454. this.groundMaterial.primaryColor = color;
  40455. }
  40456. if (this.skyboxMaterial) {
  40457. this.skyboxMaterial.primaryColor = color;
  40458. }
  40459. if (this.groundMirror) {
  40460. this.groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](color.r, color.g, color.b, 1.0);
  40461. }
  40462. };
  40463. /**
  40464. * Setup the image processing according to the specified options.
  40465. */
  40466. EnvironmentHelper.prototype._setupImageProcessing = function () {
  40467. if (this._options.setupImageProcessing) {
  40468. this._scene.imageProcessingConfiguration.contrast = this._options.cameraContrast;
  40469. this._scene.imageProcessingConfiguration.exposure = this._options.cameraExposure;
  40470. this._scene.imageProcessingConfiguration.toneMappingEnabled = this._options.toneMappingEnabled;
  40471. this._setupEnvironmentTexture();
  40472. }
  40473. };
  40474. /**
  40475. * Setup the environment texture according to the specified options.
  40476. */
  40477. EnvironmentHelper.prototype._setupEnvironmentTexture = function () {
  40478. if (this._scene.environmentTexture) {
  40479. return;
  40480. }
  40481. if (this._options.environmentTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  40482. this._scene.environmentTexture = this._options.environmentTexture;
  40483. return;
  40484. }
  40485. var environmentTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(this._options.environmentTexture, this._scene);
  40486. this._scene.environmentTexture = environmentTexture;
  40487. };
  40488. /**
  40489. * Setup the background according to the specified options.
  40490. */
  40491. EnvironmentHelper.prototype._setupBackground = function () {
  40492. if (!this._rootMesh) {
  40493. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]("BackgroundHelper", this._scene);
  40494. }
  40495. this._rootMesh.rotation.y = this._options.backgroundYRotation;
  40496. var sceneSize = this._getSceneSize();
  40497. if (this._options.createGround) {
  40498. this._setupGround(sceneSize);
  40499. this._setupGroundMaterial();
  40500. this._setupGroundDiffuseTexture();
  40501. if (this._options.enableGroundMirror) {
  40502. this._setupGroundMirrorTexture(sceneSize);
  40503. }
  40504. this._setupMirrorInGroundMaterial();
  40505. }
  40506. if (this._options.createSkybox) {
  40507. this._setupSkybox(sceneSize);
  40508. this._setupSkyboxMaterial();
  40509. this._setupSkyboxReflectionTexture();
  40510. }
  40511. this._rootMesh.position.x = sceneSize.rootPosition.x;
  40512. this._rootMesh.position.z = sceneSize.rootPosition.z;
  40513. this._rootMesh.position.y = sceneSize.rootPosition.y;
  40514. };
  40515. /**
  40516. * Get the scene sizes according to the setup.
  40517. */
  40518. EnvironmentHelper.prototype._getSceneSize = function () {
  40519. var _this = this;
  40520. var groundSize = this._options.groundSize;
  40521. var skyboxSize = this._options.skyboxSize;
  40522. var rootPosition = this._options.rootPosition;
  40523. if (!this._scene.meshes || this._scene.meshes.length === 1) { // 1 only means the root of the helper.
  40524. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  40525. }
  40526. var sceneExtends = this._scene.getWorldExtends(function (mesh) {
  40527. return (mesh !== _this._ground && mesh !== _this._rootMesh && mesh !== _this._skybox);
  40528. });
  40529. var sceneDiagonal = sceneExtends.max.subtract(sceneExtends.min);
  40530. if (this._options.sizeAuto) {
  40531. if (this._scene.activeCamera instanceof _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"] &&
  40532. this._scene.activeCamera.upperRadiusLimit) {
  40533. groundSize = this._scene.activeCamera.upperRadiusLimit * 2;
  40534. skyboxSize = groundSize;
  40535. }
  40536. var sceneDiagonalLenght = sceneDiagonal.length();
  40537. if (sceneDiagonalLenght > groundSize) {
  40538. groundSize = sceneDiagonalLenght * 2;
  40539. skyboxSize = groundSize;
  40540. }
  40541. // 10 % bigger.
  40542. groundSize *= 1.1;
  40543. skyboxSize *= 1.5;
  40544. rootPosition = sceneExtends.min.add(sceneDiagonal.scale(0.5));
  40545. rootPosition.y = sceneExtends.min.y - this._options.groundYBias;
  40546. }
  40547. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  40548. };
  40549. /**
  40550. * Setup the ground according to the specified options.
  40551. */
  40552. EnvironmentHelper.prototype._setupGround = function (sceneSize) {
  40553. var _this = this;
  40554. if (!this._ground || this._ground.isDisposed()) {
  40555. this._ground = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreatePlane("BackgroundPlane", sceneSize.groundSize, this._scene);
  40556. this._ground.rotation.x = Math.PI / 2; // Face up by default.
  40557. this._ground.parent = this._rootMesh;
  40558. this._ground.onDisposeObservable.add(function () { _this._ground = null; });
  40559. }
  40560. this._ground.receiveShadows = this._options.enableGroundShadow;
  40561. };
  40562. /**
  40563. * Setup the ground material according to the specified options.
  40564. */
  40565. EnvironmentHelper.prototype._setupGroundMaterial = function () {
  40566. if (!this._groundMaterial) {
  40567. this._groundMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundPlaneMaterial", this._scene);
  40568. }
  40569. this._groundMaterial.alpha = this._options.groundOpacity;
  40570. this._groundMaterial.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  40571. this._groundMaterial.shadowLevel = this._options.groundShadowLevel;
  40572. this._groundMaterial.primaryColor = this._options.groundColor;
  40573. this._groundMaterial.useRGBColor = false;
  40574. this._groundMaterial.enableNoise = true;
  40575. if (this._ground) {
  40576. this._ground.material = this._groundMaterial;
  40577. }
  40578. };
  40579. /**
  40580. * Setup the ground diffuse texture according to the specified options.
  40581. */
  40582. EnvironmentHelper.prototype._setupGroundDiffuseTexture = function () {
  40583. if (!this._groundMaterial) {
  40584. return;
  40585. }
  40586. if (this._groundTexture) {
  40587. return;
  40588. }
  40589. if (this._options.groundTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  40590. this._groundMaterial.diffuseTexture = this._options.groundTexture;
  40591. return;
  40592. }
  40593. var diffuseTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](this._options.groundTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  40594. diffuseTexture.gammaSpace = false;
  40595. diffuseTexture.hasAlpha = true;
  40596. this._groundMaterial.diffuseTexture = diffuseTexture;
  40597. };
  40598. /**
  40599. * Setup the ground mirror texture according to the specified options.
  40600. */
  40601. EnvironmentHelper.prototype._setupGroundMirrorTexture = function (sceneSize) {
  40602. var wrapping = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  40603. if (!this._groundMirror) {
  40604. 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);
  40605. this._groundMirror.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Plane"](0, -1, 0, sceneSize.rootPosition.y);
  40606. this._groundMirror.anisotropicFilteringLevel = 1;
  40607. this._groundMirror.wrapU = wrapping;
  40608. this._groundMirror.wrapV = wrapping;
  40609. this._groundMirror.gammaSpace = false;
  40610. if (this._groundMirror.renderList) {
  40611. for (var i = 0; i < this._scene.meshes.length; i++) {
  40612. var mesh = this._scene.meshes[i];
  40613. if (mesh !== this._ground &&
  40614. mesh !== this._skybox &&
  40615. mesh !== this._rootMesh) {
  40616. this._groundMirror.renderList.push(mesh);
  40617. }
  40618. }
  40619. }
  40620. }
  40621. this._groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](this._options.groundColor.r, this._options.groundColor.g, this._options.groundColor.b, 1);
  40622. this._groundMirror.adaptiveBlurKernel = this._options.groundMirrorBlurKernel;
  40623. };
  40624. /**
  40625. * Setup the ground to receive the mirror texture.
  40626. */
  40627. EnvironmentHelper.prototype._setupMirrorInGroundMaterial = function () {
  40628. if (this._groundMaterial) {
  40629. this._groundMaterial.reflectionTexture = this._groundMirror;
  40630. this._groundMaterial.reflectionFresnel = true;
  40631. this._groundMaterial.reflectionAmount = this._options.groundMirrorAmount;
  40632. this._groundMaterial.reflectionStandardFresnelWeight = this._options.groundMirrorFresnelWeight;
  40633. this._groundMaterial.reflectionFalloffDistance = this._options.groundMirrorFallOffDistance;
  40634. }
  40635. };
  40636. /**
  40637. * Setup the skybox according to the specified options.
  40638. */
  40639. EnvironmentHelper.prototype._setupSkybox = function (sceneSize) {
  40640. var _this = this;
  40641. if (!this._skybox || this._skybox.isDisposed()) {
  40642. this._skybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateBox("BackgroundSkybox", sceneSize.skyboxSize, this._scene, undefined, _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].BACKSIDE);
  40643. this._skybox.onDisposeObservable.add(function () { _this._skybox = null; });
  40644. }
  40645. this._skybox.parent = this._rootMesh;
  40646. };
  40647. /**
  40648. * Setup the skybox material according to the specified options.
  40649. */
  40650. EnvironmentHelper.prototype._setupSkyboxMaterial = function () {
  40651. if (!this._skybox) {
  40652. return;
  40653. }
  40654. if (!this._skyboxMaterial) {
  40655. this._skyboxMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundSkyboxMaterial", this._scene);
  40656. }
  40657. this._skyboxMaterial.useRGBColor = false;
  40658. this._skyboxMaterial.primaryColor = this._options.skyboxColor;
  40659. this._skyboxMaterial.enableNoise = true;
  40660. this._skybox.material = this._skyboxMaterial;
  40661. };
  40662. /**
  40663. * Setup the skybox reflection texture according to the specified options.
  40664. */
  40665. EnvironmentHelper.prototype._setupSkyboxReflectionTexture = function () {
  40666. if (!this._skyboxMaterial) {
  40667. return;
  40668. }
  40669. if (this._skyboxTexture) {
  40670. return;
  40671. }
  40672. if (this._options.skyboxTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  40673. this._skyboxMaterial.reflectionTexture = this._options.skyboxTexture;
  40674. return;
  40675. }
  40676. this._skyboxTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"](this._options.skyboxTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  40677. this._skyboxTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].SKYBOX_MODE;
  40678. this._skyboxTexture.gammaSpace = false;
  40679. this._skyboxMaterial.reflectionTexture = this._skyboxTexture;
  40680. };
  40681. /**
  40682. * Dispose all the elements created by the Helper.
  40683. */
  40684. EnvironmentHelper.prototype.dispose = function () {
  40685. if (this._groundMaterial) {
  40686. this._groundMaterial.dispose(true, true);
  40687. }
  40688. if (this._skyboxMaterial) {
  40689. this._skyboxMaterial.dispose(true, true);
  40690. }
  40691. this._rootMesh.dispose(false);
  40692. };
  40693. /**
  40694. * Default ground texture URL.
  40695. */
  40696. EnvironmentHelper._groundTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundGround.png";
  40697. /**
  40698. * Default skybox texture URL.
  40699. */
  40700. EnvironmentHelper._skyboxTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundSkybox.dds";
  40701. /**
  40702. * Default environment texture URL.
  40703. */
  40704. EnvironmentHelper._environmentTextureCDNUrl = "https://assets.babylonjs.com/environments/environmentSpecular.env";
  40705. return EnvironmentHelper;
  40706. }());
  40707. /***/ }),
  40708. /***/ "./Helpers/index.ts":
  40709. /*!**************************!*\
  40710. !*** ./Helpers/index.ts ***!
  40711. \**************************/
  40712. /*! exports provided: EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome */
  40713. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40714. "use strict";
  40715. __webpack_require__.r(__webpack_exports__);
  40716. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  40717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _environmentHelper__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  40718. /* harmony import */ var _photoDome__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./photoDome */ "./Helpers/photoDome.ts");
  40719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _photoDome__WEBPACK_IMPORTED_MODULE_1__["PhotoDome"]; });
  40720. /* harmony import */ var _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneHelpers */ "./Helpers/sceneHelpers.ts");
  40721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__["_forceSceneHelpersToBundle"]; });
  40722. /* harmony import */ var _videoDome__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./videoDome */ "./Helpers/videoDome.ts");
  40723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _videoDome__WEBPACK_IMPORTED_MODULE_3__["VideoDome"]; });
  40724. /***/ }),
  40725. /***/ "./Helpers/photoDome.ts":
  40726. /*!******************************!*\
  40727. !*** ./Helpers/photoDome.ts ***!
  40728. \******************************/
  40729. /*! exports provided: PhotoDome */
  40730. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40731. "use strict";
  40732. __webpack_require__.r(__webpack_exports__);
  40733. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return PhotoDome; });
  40734. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40735. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40736. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  40737. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  40738. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40739. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  40740. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  40741. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40742. /**
  40743. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  40744. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  40745. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  40746. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  40747. */
  40748. var PhotoDome = /** @class */ (function (_super) {
  40749. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PhotoDome, _super);
  40750. /**
  40751. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  40752. * @param name Element's name, child elements will append suffixes for their own names.
  40753. * @param urlsOfPhoto defines the url of the photo to display
  40754. * @param options defines an object containing optional or exposed sub element properties
  40755. * @param onError defines a callback called when an error occured while loading the texture
  40756. */
  40757. function PhotoDome(name, urlOfPhoto, options, scene, onError) {
  40758. if (onError === void 0) { onError = null; }
  40759. var _this = _super.call(this, name, scene) || this;
  40760. _this._useDirectMapping = false;
  40761. /**
  40762. * Observable raised when an error occured while loading the 360 image
  40763. */
  40764. _this.onLoadErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  40765. // set defaults and manage values
  40766. name = name || "photoDome";
  40767. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  40768. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  40769. if (options.useDirectMapping === undefined) {
  40770. _this._useDirectMapping = true;
  40771. }
  40772. else {
  40773. _this._useDirectMapping = options.useDirectMapping;
  40774. }
  40775. if (options.faceForward === undefined) {
  40776. options.faceForward = true;
  40777. }
  40778. _this._setReady(false);
  40779. // create
  40780. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  40781. _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);
  40782. // configure material
  40783. material.opacityFresnel = false;
  40784. material.useEquirectangularFOV = true;
  40785. material.fovMultiplier = 1.0;
  40786. _this.photoTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](urlOfPhoto, scene, true, !_this._useDirectMapping, undefined, undefined, function (message, exception) {
  40787. _this.onLoadErrorObservable.notifyObservers(message || "Unknown error occured");
  40788. if (onError) {
  40789. onError(message, exception);
  40790. }
  40791. });
  40792. _this.photoTexture.onLoadObservable.addOnce(function () {
  40793. _this._setReady(true);
  40794. });
  40795. // configure mesh
  40796. _this._mesh.material = material;
  40797. _this._mesh.parent = _this;
  40798. // Initial rotation
  40799. if (options.faceForward && scene.activeCamera) {
  40800. var camera = scene.activeCamera;
  40801. var forward = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Forward();
  40802. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].TransformNormal(forward, camera.getViewMatrix());
  40803. direction.normalize();
  40804. _this.rotation.y = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Dot(forward, direction));
  40805. }
  40806. return _this;
  40807. }
  40808. Object.defineProperty(PhotoDome.prototype, "photoTexture", {
  40809. /**
  40810. * Gets or sets the texture being displayed on the sphere
  40811. */
  40812. get: function () {
  40813. return this._photoTexture;
  40814. },
  40815. set: function (value) {
  40816. if (this._photoTexture === value) {
  40817. return;
  40818. }
  40819. this._photoTexture = value;
  40820. if (this._useDirectMapping) {
  40821. this._photoTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  40822. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  40823. this._material.diffuseTexture = this._photoTexture;
  40824. }
  40825. else {
  40826. this._photoTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  40827. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  40828. this._material.reflectionTexture = this._photoTexture;
  40829. }
  40830. },
  40831. enumerable: true,
  40832. configurable: true
  40833. });
  40834. Object.defineProperty(PhotoDome.prototype, "fovMultiplier", {
  40835. /**
  40836. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  40837. * Also see the options.resolution property.
  40838. */
  40839. get: function () {
  40840. return this._material.fovMultiplier;
  40841. },
  40842. set: function (value) {
  40843. this._material.fovMultiplier = value;
  40844. },
  40845. enumerable: true,
  40846. configurable: true
  40847. });
  40848. /**
  40849. * Releases resources associated with this node.
  40850. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  40851. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  40852. */
  40853. PhotoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  40854. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  40855. this._photoTexture.dispose();
  40856. this._mesh.dispose();
  40857. this._material.dispose();
  40858. this.onLoadErrorObservable.clear();
  40859. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  40860. };
  40861. return PhotoDome;
  40862. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__["TransformNode"]));
  40863. /***/ }),
  40864. /***/ "./Helpers/sceneHelpers.ts":
  40865. /*!*********************************!*\
  40866. !*** ./Helpers/sceneHelpers.ts ***!
  40867. \*********************************/
  40868. /*! exports provided: _forceSceneHelpersToBundle */
  40869. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40870. "use strict";
  40871. __webpack_require__.r(__webpack_exports__);
  40872. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _forceSceneHelpersToBundle; });
  40873. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  40874. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  40875. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40876. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  40877. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40878. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  40879. /* harmony import */ var _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/PBR/pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  40880. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  40881. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  40882. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  40883. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  40884. /* harmony import */ var _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/XR/webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  40885. /* harmony import */ var _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Cameras/XR/webXRInput */ "./Cameras/XR/webXRInput.ts");
  40886. /* harmony import */ var _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Cameras/XR/webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  40887. /* harmony import */ var _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Cameras/XR/webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  40888. /* harmony import */ var _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Cameras/VR/vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  40889. /* harmony import */ var _Materials_Textures_Loaders_ddsTextureLoader__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Materials/Textures/Loaders/ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  40890. /* harmony import */ var _Materials_Textures_Loaders_envTextureLoader__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Materials/Textures/Loaders/envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  40891. /* harmony import */ var _Materials_Textures_Loaders_ktxTextureLoader__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Materials/Textures/Loaders/ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  40892. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  40893. /** @hidden */
  40894. var _forceSceneHelpersToBundle = true;
  40895. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultLight = function (replace) {
  40896. if (replace === void 0) { replace = false; }
  40897. // Dispose existing light in replace mode.
  40898. if (replace) {
  40899. if (this.lights) {
  40900. for (var i = 0; i < this.lights.length; i++) {
  40901. this.lights[i].dispose();
  40902. }
  40903. }
  40904. }
  40905. // Light
  40906. if (this.lights.length === 0) {
  40907. new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__["HemisphericLight"]("default light", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up(), this);
  40908. }
  40909. };
  40910. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCamera = function (createArcRotateCamera, replace, attachCameraControls) {
  40911. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  40912. if (replace === void 0) { replace = false; }
  40913. if (attachCameraControls === void 0) { attachCameraControls = false; }
  40914. // Dispose existing camera in replace mode.
  40915. if (replace) {
  40916. if (this.activeCamera) {
  40917. this.activeCamera.dispose();
  40918. this.activeCamera = null;
  40919. }
  40920. }
  40921. // Camera
  40922. if (!this.activeCamera) {
  40923. var worldExtends = this.getWorldExtends();
  40924. var worldSize = worldExtends.max.subtract(worldExtends.min);
  40925. var worldCenter = worldExtends.min.add(worldSize.scale(0.5));
  40926. var camera;
  40927. var radius = worldSize.length() * 1.5;
  40928. // empty scene scenario!
  40929. if (!isFinite(radius)) {
  40930. radius = 1;
  40931. worldCenter.copyFromFloats(0, 0, 0);
  40932. }
  40933. if (createArcRotateCamera) {
  40934. var arcRotateCamera = new _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__["ArcRotateCamera"]("default camera", -(Math.PI / 2), Math.PI / 2, radius, worldCenter, this);
  40935. arcRotateCamera.lowerRadiusLimit = radius * 0.01;
  40936. arcRotateCamera.wheelPrecision = 100 / radius;
  40937. camera = arcRotateCamera;
  40938. }
  40939. else {
  40940. 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);
  40941. freeCamera.setTarget(worldCenter);
  40942. camera = freeCamera;
  40943. }
  40944. camera.minZ = radius * 0.01;
  40945. camera.maxZ = radius * 1000;
  40946. camera.speed = radius * 0.2;
  40947. this.activeCamera = camera;
  40948. var canvas = this.getEngine().getRenderingCanvas();
  40949. if (attachCameraControls && canvas) {
  40950. camera.attachControl(canvas);
  40951. }
  40952. }
  40953. };
  40954. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCameraOrLight = function (createArcRotateCamera, replace, attachCameraControls) {
  40955. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  40956. if (replace === void 0) { replace = false; }
  40957. if (attachCameraControls === void 0) { attachCameraControls = false; }
  40958. this.createDefaultLight(replace);
  40959. this.createDefaultCamera(createArcRotateCamera, replace, attachCameraControls);
  40960. };
  40961. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultSkybox = function (environmentTexture, pbr, scale, blur, setGlobalEnvTexture) {
  40962. if (pbr === void 0) { pbr = false; }
  40963. if (scale === void 0) { scale = 1000; }
  40964. if (blur === void 0) { blur = 0; }
  40965. if (setGlobalEnvTexture === void 0) { setGlobalEnvTexture = true; }
  40966. if (!environmentTexture) {
  40967. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Can not create default skybox without environment texture.");
  40968. return null;
  40969. }
  40970. if (setGlobalEnvTexture) {
  40971. if (environmentTexture) {
  40972. this.environmentTexture = environmentTexture;
  40973. }
  40974. }
  40975. // Skybox
  40976. var hdrSkybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateBox("hdrSkyBox", scale, this);
  40977. if (pbr) {
  40978. var hdrSkyboxMaterial = new _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__["PBRMaterial"]("skyBox", this);
  40979. hdrSkyboxMaterial.backFaceCulling = false;
  40980. hdrSkyboxMaterial.reflectionTexture = environmentTexture.clone();
  40981. if (hdrSkyboxMaterial.reflectionTexture) {
  40982. hdrSkyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  40983. }
  40984. hdrSkyboxMaterial.microSurface = 1.0 - blur;
  40985. hdrSkyboxMaterial.disableLighting = true;
  40986. hdrSkyboxMaterial.twoSidedLighting = true;
  40987. hdrSkybox.infiniteDistance = true;
  40988. hdrSkybox.material = hdrSkyboxMaterial;
  40989. }
  40990. else {
  40991. var skyboxMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("skyBox", this);
  40992. skyboxMaterial.backFaceCulling = false;
  40993. skyboxMaterial.reflectionTexture = environmentTexture.clone();
  40994. if (skyboxMaterial.reflectionTexture) {
  40995. skyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  40996. }
  40997. skyboxMaterial.disableLighting = true;
  40998. hdrSkybox.infiniteDistance = true;
  40999. hdrSkybox.material = skyboxMaterial;
  41000. }
  41001. hdrSkybox.isPickable = false;
  41002. return hdrSkybox;
  41003. };
  41004. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultEnvironment = function (options) {
  41005. if (_environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"]) {
  41006. return new _environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"](options, this);
  41007. }
  41008. return null;
  41009. };
  41010. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultVRExperience = function (webVROptions) {
  41011. if (webVROptions === void 0) { webVROptions = {}; }
  41012. return new _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__["VRExperienceHelper"](this, webVROptions);
  41013. };
  41014. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultXRExperienceAsync = function () {
  41015. var _this = this;
  41016. return _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__["WebXRExperienceHelper"].CreateAsync(this).then(function (helper) {
  41017. var outputCanvas = new _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__["WebXRManagedOutputCanvas"](helper);
  41018. return _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__["WebXREnterExitUI"].CreateAsync(_this, helper, { outputCanvasContext: outputCanvas.canvasContext })
  41019. .then(function (ui) {
  41020. new _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__["WebXRInput"](helper);
  41021. return helper;
  41022. });
  41023. });
  41024. };
  41025. /***/ }),
  41026. /***/ "./Helpers/videoDome.ts":
  41027. /*!******************************!*\
  41028. !*** ./Helpers/videoDome.ts ***!
  41029. \******************************/
  41030. /*! exports provided: VideoDome */
  41031. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41032. "use strict";
  41033. __webpack_require__.r(__webpack_exports__);
  41034. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return VideoDome; });
  41035. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  41036. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  41037. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  41038. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  41039. /* harmony import */ var _Materials_Textures_videoTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/videoTexture */ "./Materials/Textures/videoTexture.ts");
  41040. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  41041. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  41042. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  41043. /**
  41044. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  41045. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  41046. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  41047. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  41048. */
  41049. var VideoDome = /** @class */ (function (_super) {
  41050. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoDome, _super);
  41051. /**
  41052. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  41053. * @param name Element's name, child elements will append suffixes for their own names.
  41054. * @param urlsOrVideo defines the url(s) or the video element to use
  41055. * @param options An object containing optional or exposed sub element properties
  41056. */
  41057. function VideoDome(name, urlsOrVideo, options, scene) {
  41058. var _this = _super.call(this, name, scene) || this;
  41059. _this._useDirectMapping = false;
  41060. _this._videoMode = VideoDome.MODE_MONOSCOPIC;
  41061. /**
  41062. * Oberserver used in Stereoscopic VR Mode.
  41063. */
  41064. _this._onBeforeCameraRenderObserver = null;
  41065. scene = _this.getScene();
  41066. // set defaults and manage values
  41067. name = name || "videoDome";
  41068. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  41069. options.clickToPlay = Boolean(options.clickToPlay);
  41070. options.autoPlay = options.autoPlay === undefined ? true : Boolean(options.autoPlay);
  41071. options.loop = options.loop === undefined ? true : Boolean(options.loop);
  41072. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  41073. if (options.useDirectMapping === undefined) {
  41074. _this._useDirectMapping = true;
  41075. }
  41076. else {
  41077. _this._useDirectMapping = options.useDirectMapping;
  41078. }
  41079. if (options.faceForward === undefined) {
  41080. options.faceForward = true;
  41081. }
  41082. _this._setReady(false);
  41083. // create
  41084. var tempOptions = { loop: options.loop, autoPlay: options.autoPlay, autoUpdateTexture: true, poster: options.poster };
  41085. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  41086. 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);
  41087. _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);
  41088. texture.onLoadObservable.addOnce(function () {
  41089. _this._setReady(true);
  41090. });
  41091. // configure material
  41092. material.useEquirectangularFOV = true;
  41093. material.fovMultiplier = 1.0;
  41094. material.opacityFresnel = false;
  41095. if (_this._useDirectMapping) {
  41096. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  41097. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  41098. material.diffuseTexture = texture;
  41099. }
  41100. else {
  41101. texture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  41102. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  41103. material.reflectionTexture = texture;
  41104. }
  41105. // configure mesh
  41106. _this._mesh.material = material;
  41107. _this._mesh.parent = _this;
  41108. // optional configuration
  41109. if (options.clickToPlay) {
  41110. scene.onPointerUp = function () {
  41111. _this._videoTexture.video.play();
  41112. };
  41113. }
  41114. // Initial rotation
  41115. if (options.faceForward && scene.activeCamera) {
  41116. var camera = scene.activeCamera;
  41117. var forward = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Forward();
  41118. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].TransformNormal(forward, camera.getViewMatrix());
  41119. direction.normalize();
  41120. _this.rotation.y = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Dot(forward, direction));
  41121. }
  41122. return _this;
  41123. }
  41124. Object.defineProperty(VideoDome.prototype, "videoTexture", {
  41125. /**
  41126. * Gets the video texture being displayed on the sphere
  41127. */
  41128. get: function () {
  41129. return this._videoTexture;
  41130. },
  41131. enumerable: true,
  41132. configurable: true
  41133. });
  41134. Object.defineProperty(VideoDome.prototype, "fovMultiplier", {
  41135. /**
  41136. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  41137. * Also see the options.resolution property.
  41138. */
  41139. get: function () {
  41140. return this._material.fovMultiplier;
  41141. },
  41142. set: function (value) {
  41143. this._material.fovMultiplier = value;
  41144. },
  41145. enumerable: true,
  41146. configurable: true
  41147. });
  41148. Object.defineProperty(VideoDome.prototype, "videoMode", {
  41149. /**
  41150. * Gets or set the current video mode for the video. It can be:
  41151. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  41152. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  41153. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  41154. */
  41155. get: function () {
  41156. return this._videoMode;
  41157. },
  41158. set: function (value) {
  41159. if (this._videoMode === value) {
  41160. return;
  41161. }
  41162. this._changeVideoMode(value);
  41163. },
  41164. enumerable: true,
  41165. configurable: true
  41166. });
  41167. VideoDome.prototype._changeVideoMode = function (value) {
  41168. var _this = this;
  41169. this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  41170. this._videoMode = value;
  41171. // Default Setup and Reset.
  41172. this._videoTexture.uScale = 1;
  41173. this._videoTexture.vScale = 1;
  41174. this._videoTexture.uOffset = 0;
  41175. this._videoTexture.vOffset = 0;
  41176. switch (value) {
  41177. case VideoDome.MODE_SIDEBYSIDE:
  41178. this._videoTexture.uScale = 0.5;
  41179. this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add(function (camera) {
  41180. _this._videoTexture.uOffset = camera.isRightCamera ? 0.5 : 0.0;
  41181. });
  41182. break;
  41183. case VideoDome.MODE_TOPBOTTOM:
  41184. this._videoTexture.vScale = 0.5;
  41185. this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add(function (camera) {
  41186. _this._videoTexture.vOffset = camera.isRightCamera ? 0.5 : 0.0;
  41187. });
  41188. break;
  41189. }
  41190. };
  41191. /**
  41192. * Releases resources associated with this node.
  41193. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  41194. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  41195. */
  41196. VideoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  41197. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  41198. this._videoTexture.dispose();
  41199. this._mesh.dispose();
  41200. this._material.dispose();
  41201. this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  41202. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  41203. };
  41204. /**
  41205. * Define the video source as a Monoscopic panoramic 360 video.
  41206. */
  41207. VideoDome.MODE_MONOSCOPIC = 0;
  41208. /**
  41209. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  41210. */
  41211. VideoDome.MODE_TOPBOTTOM = 1;
  41212. /**
  41213. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  41214. */
  41215. VideoDome.MODE_SIDEBYSIDE = 2;
  41216. return VideoDome;
  41217. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]));
  41218. /***/ }),
  41219. /***/ "./Instrumentation/engineInstrumentation.ts":
  41220. /*!**************************************************!*\
  41221. !*** ./Instrumentation/engineInstrumentation.ts ***!
  41222. \**************************************************/
  41223. /*! exports provided: EngineInstrumentation */
  41224. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41225. "use strict";
  41226. __webpack_require__.r(__webpack_exports__);
  41227. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return EngineInstrumentation; });
  41228. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  41229. /**
  41230. * This class can be used to get instrumentation data from a Babylon engine
  41231. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  41232. */
  41233. var EngineInstrumentation = /** @class */ (function () {
  41234. /**
  41235. * Instantiates a new engine instrumentation.
  41236. * This class can be used to get instrumentation data from a Babylon engine
  41237. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  41238. * @param engine Defines the engine to instrument
  41239. */
  41240. function EngineInstrumentation(
  41241. /**
  41242. * Define the instrumented engine.
  41243. */
  41244. engine) {
  41245. this.engine = engine;
  41246. this._captureGPUFrameTime = false;
  41247. this._gpuFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41248. this._captureShaderCompilationTime = false;
  41249. this._shaderCompilationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41250. // Observers
  41251. this._onBeginFrameObserver = null;
  41252. this._onEndFrameObserver = null;
  41253. this._onBeforeShaderCompilationObserver = null;
  41254. this._onAfterShaderCompilationObserver = null;
  41255. }
  41256. Object.defineProperty(EngineInstrumentation.prototype, "gpuFrameTimeCounter", {
  41257. // Properties
  41258. /**
  41259. * Gets the perf counter used for GPU frame time
  41260. */
  41261. get: function () {
  41262. return this._gpuFrameTime;
  41263. },
  41264. enumerable: true,
  41265. configurable: true
  41266. });
  41267. Object.defineProperty(EngineInstrumentation.prototype, "captureGPUFrameTime", {
  41268. /**
  41269. * Gets the GPU frame time capture status
  41270. */
  41271. get: function () {
  41272. return this._captureGPUFrameTime;
  41273. },
  41274. /**
  41275. * Enable or disable the GPU frame time capture
  41276. */
  41277. set: function (value) {
  41278. var _this = this;
  41279. if (value === this._captureGPUFrameTime) {
  41280. return;
  41281. }
  41282. this._captureGPUFrameTime = value;
  41283. if (value) {
  41284. this._onBeginFrameObserver = this.engine.onBeginFrameObservable.add(function () {
  41285. if (!_this._gpuFrameTimeToken) {
  41286. _this._gpuFrameTimeToken = _this.engine.startTimeQuery();
  41287. }
  41288. });
  41289. this._onEndFrameObserver = this.engine.onEndFrameObservable.add(function () {
  41290. if (!_this._gpuFrameTimeToken) {
  41291. return;
  41292. }
  41293. var time = _this.engine.endTimeQuery(_this._gpuFrameTimeToken);
  41294. if (time > -1) {
  41295. _this._gpuFrameTimeToken = null;
  41296. _this._gpuFrameTime.fetchNewFrame();
  41297. _this._gpuFrameTime.addCount(time, true);
  41298. }
  41299. });
  41300. }
  41301. else {
  41302. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  41303. this._onBeginFrameObserver = null;
  41304. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  41305. this._onEndFrameObserver = null;
  41306. }
  41307. },
  41308. enumerable: true,
  41309. configurable: true
  41310. });
  41311. Object.defineProperty(EngineInstrumentation.prototype, "shaderCompilationTimeCounter", {
  41312. /**
  41313. * Gets the perf counter used for shader compilation time
  41314. */
  41315. get: function () {
  41316. return this._shaderCompilationTime;
  41317. },
  41318. enumerable: true,
  41319. configurable: true
  41320. });
  41321. Object.defineProperty(EngineInstrumentation.prototype, "captureShaderCompilationTime", {
  41322. /**
  41323. * Gets the shader compilation time capture status
  41324. */
  41325. get: function () {
  41326. return this._captureShaderCompilationTime;
  41327. },
  41328. /**
  41329. * Enable or disable the shader compilation time capture
  41330. */
  41331. set: function (value) {
  41332. var _this = this;
  41333. if (value === this._captureShaderCompilationTime) {
  41334. return;
  41335. }
  41336. this._captureShaderCompilationTime = value;
  41337. if (value) {
  41338. this._onBeforeShaderCompilationObserver = this.engine.onBeforeShaderCompilationObservable.add(function () {
  41339. _this._shaderCompilationTime.fetchNewFrame();
  41340. _this._shaderCompilationTime.beginMonitoring();
  41341. });
  41342. this._onAfterShaderCompilationObserver = this.engine.onAfterShaderCompilationObservable.add(function () {
  41343. _this._shaderCompilationTime.endMonitoring();
  41344. });
  41345. }
  41346. else {
  41347. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  41348. this._onBeforeShaderCompilationObserver = null;
  41349. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  41350. this._onAfterShaderCompilationObserver = null;
  41351. }
  41352. },
  41353. enumerable: true,
  41354. configurable: true
  41355. });
  41356. /**
  41357. * Dispose and release associated resources.
  41358. */
  41359. EngineInstrumentation.prototype.dispose = function () {
  41360. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  41361. this._onBeginFrameObserver = null;
  41362. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  41363. this._onEndFrameObserver = null;
  41364. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  41365. this._onBeforeShaderCompilationObserver = null;
  41366. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  41367. this._onAfterShaderCompilationObserver = null;
  41368. this.engine = null;
  41369. };
  41370. return EngineInstrumentation;
  41371. }());
  41372. /***/ }),
  41373. /***/ "./Instrumentation/index.ts":
  41374. /*!**********************************!*\
  41375. !*** ./Instrumentation/index.ts ***!
  41376. \**********************************/
  41377. /*! exports provided: EngineInstrumentation, SceneInstrumentation, _TimeToken */
  41378. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41379. "use strict";
  41380. __webpack_require__.r(__webpack_exports__);
  41381. /* harmony import */ var _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engineInstrumentation */ "./Instrumentation/engineInstrumentation.ts");
  41382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  41383. /* harmony import */ var _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sceneInstrumentation */ "./Instrumentation/sceneInstrumentation.ts");
  41384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__["SceneInstrumentation"]; });
  41385. /* harmony import */ var _timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./timeToken */ "./Instrumentation/timeToken.ts");
  41386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]; });
  41387. /***/ }),
  41388. /***/ "./Instrumentation/sceneInstrumentation.ts":
  41389. /*!*************************************************!*\
  41390. !*** ./Instrumentation/sceneInstrumentation.ts ***!
  41391. \*************************************************/
  41392. /*! exports provided: SceneInstrumentation */
  41393. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41394. "use strict";
  41395. __webpack_require__.r(__webpack_exports__);
  41396. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return SceneInstrumentation; });
  41397. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  41398. /**
  41399. * This class can be used to get instrumentation data from a Babylon engine
  41400. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  41401. */
  41402. var SceneInstrumentation = /** @class */ (function () {
  41403. /**
  41404. * Instantiates a new scene instrumentation.
  41405. * This class can be used to get instrumentation data from a Babylon engine
  41406. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  41407. * @param scene Defines the scene to instrument
  41408. */
  41409. function SceneInstrumentation(
  41410. /**
  41411. * Defines the scene to instrument
  41412. */
  41413. scene) {
  41414. var _this = this;
  41415. this.scene = scene;
  41416. this._captureActiveMeshesEvaluationTime = false;
  41417. this._activeMeshesEvaluationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41418. this._captureRenderTargetsRenderTime = false;
  41419. this._renderTargetsRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41420. this._captureFrameTime = false;
  41421. this._frameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41422. this._captureRenderTime = false;
  41423. this._renderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41424. this._captureInterFrameTime = false;
  41425. this._interFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41426. this._captureParticlesRenderTime = false;
  41427. this._particlesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41428. this._captureSpritesRenderTime = false;
  41429. this._spritesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41430. this._capturePhysicsTime = false;
  41431. this._physicsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41432. this._captureAnimationsTime = false;
  41433. this._animationsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41434. this._captureCameraRenderTime = false;
  41435. this._cameraRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41436. // Observers
  41437. this._onBeforeActiveMeshesEvaluationObserver = null;
  41438. this._onAfterActiveMeshesEvaluationObserver = null;
  41439. this._onBeforeRenderTargetsRenderObserver = null;
  41440. this._onAfterRenderTargetsRenderObserver = null;
  41441. this._onAfterRenderObserver = null;
  41442. this._onBeforeDrawPhaseObserver = null;
  41443. this._onAfterDrawPhaseObserver = null;
  41444. this._onBeforeAnimationsObserver = null;
  41445. this._onBeforeParticlesRenderingObserver = null;
  41446. this._onAfterParticlesRenderingObserver = null;
  41447. this._onBeforeSpritesRenderingObserver = null;
  41448. this._onAfterSpritesRenderingObserver = null;
  41449. this._onBeforePhysicsObserver = null;
  41450. this._onAfterPhysicsObserver = null;
  41451. this._onAfterAnimationsObserver = null;
  41452. this._onBeforeCameraRenderObserver = null;
  41453. this._onAfterCameraRenderObserver = null;
  41454. // Before render
  41455. this._onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(function () {
  41456. if (_this._captureActiveMeshesEvaluationTime) {
  41457. _this._activeMeshesEvaluationTime.fetchNewFrame();
  41458. }
  41459. if (_this._captureRenderTargetsRenderTime) {
  41460. _this._renderTargetsRenderTime.fetchNewFrame();
  41461. }
  41462. if (_this._captureFrameTime) {
  41463. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Scene rendering");
  41464. _this._frameTime.beginMonitoring();
  41465. }
  41466. if (_this._captureInterFrameTime) {
  41467. _this._interFrameTime.endMonitoring();
  41468. }
  41469. if (_this._captureParticlesRenderTime) {
  41470. _this._particlesRenderTime.fetchNewFrame();
  41471. }
  41472. if (_this._captureSpritesRenderTime) {
  41473. _this._spritesRenderTime.fetchNewFrame();
  41474. }
  41475. if (_this._captureAnimationsTime) {
  41476. _this._animationsTime.beginMonitoring();
  41477. }
  41478. _this.scene.getEngine()._drawCalls.fetchNewFrame();
  41479. _this.scene.getEngine()._textureCollisions.fetchNewFrame();
  41480. });
  41481. // After render
  41482. this._onAfterRenderObserver = scene.onAfterRenderObservable.add(function () {
  41483. if (_this._captureFrameTime) {
  41484. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Scene rendering");
  41485. _this._frameTime.endMonitoring();
  41486. }
  41487. if (_this._captureRenderTime) {
  41488. _this._renderTime.endMonitoring(false);
  41489. }
  41490. if (_this._captureInterFrameTime) {
  41491. _this._interFrameTime.beginMonitoring();
  41492. }
  41493. });
  41494. }
  41495. Object.defineProperty(SceneInstrumentation.prototype, "activeMeshesEvaluationTimeCounter", {
  41496. // Properties
  41497. /**
  41498. * Gets the perf counter used for active meshes evaluation time
  41499. */
  41500. get: function () {
  41501. return this._activeMeshesEvaluationTime;
  41502. },
  41503. enumerable: true,
  41504. configurable: true
  41505. });
  41506. Object.defineProperty(SceneInstrumentation.prototype, "captureActiveMeshesEvaluationTime", {
  41507. /**
  41508. * Gets the active meshes evaluation time capture status
  41509. */
  41510. get: function () {
  41511. return this._captureActiveMeshesEvaluationTime;
  41512. },
  41513. /**
  41514. * Enable or disable the active meshes evaluation time capture
  41515. */
  41516. set: function (value) {
  41517. var _this = this;
  41518. if (value === this._captureActiveMeshesEvaluationTime) {
  41519. return;
  41520. }
  41521. this._captureActiveMeshesEvaluationTime = value;
  41522. if (value) {
  41523. this._onBeforeActiveMeshesEvaluationObserver = this.scene.onBeforeActiveMeshesEvaluationObservable.add(function () {
  41524. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Active meshes evaluation");
  41525. _this._activeMeshesEvaluationTime.beginMonitoring();
  41526. });
  41527. this._onAfterActiveMeshesEvaluationObserver = this.scene.onAfterActiveMeshesEvaluationObservable.add(function () {
  41528. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Active meshes evaluation");
  41529. _this._activeMeshesEvaluationTime.endMonitoring();
  41530. });
  41531. }
  41532. else {
  41533. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  41534. this._onBeforeActiveMeshesEvaluationObserver = null;
  41535. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  41536. this._onAfterActiveMeshesEvaluationObserver = null;
  41537. }
  41538. },
  41539. enumerable: true,
  41540. configurable: true
  41541. });
  41542. Object.defineProperty(SceneInstrumentation.prototype, "renderTargetsRenderTimeCounter", {
  41543. /**
  41544. * Gets the perf counter used for render targets render time
  41545. */
  41546. get: function () {
  41547. return this._renderTargetsRenderTime;
  41548. },
  41549. enumerable: true,
  41550. configurable: true
  41551. });
  41552. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTargetsRenderTime", {
  41553. /**
  41554. * Gets the render targets render time capture status
  41555. */
  41556. get: function () {
  41557. return this._captureRenderTargetsRenderTime;
  41558. },
  41559. /**
  41560. * Enable or disable the render targets render time capture
  41561. */
  41562. set: function (value) {
  41563. var _this = this;
  41564. if (value === this._captureRenderTargetsRenderTime) {
  41565. return;
  41566. }
  41567. this._captureRenderTargetsRenderTime = value;
  41568. if (value) {
  41569. this._onBeforeRenderTargetsRenderObserver = this.scene.onBeforeRenderTargetsRenderObservable.add(function () {
  41570. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Render targets rendering");
  41571. _this._renderTargetsRenderTime.beginMonitoring();
  41572. });
  41573. this._onAfterRenderTargetsRenderObserver = this.scene.onAfterRenderTargetsRenderObservable.add(function () {
  41574. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Render targets rendering");
  41575. _this._renderTargetsRenderTime.endMonitoring(false);
  41576. });
  41577. }
  41578. else {
  41579. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  41580. this._onBeforeRenderTargetsRenderObserver = null;
  41581. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  41582. this._onAfterRenderTargetsRenderObserver = null;
  41583. }
  41584. },
  41585. enumerable: true,
  41586. configurable: true
  41587. });
  41588. Object.defineProperty(SceneInstrumentation.prototype, "particlesRenderTimeCounter", {
  41589. /**
  41590. * Gets the perf counter used for particles render time
  41591. */
  41592. get: function () {
  41593. return this._particlesRenderTime;
  41594. },
  41595. enumerable: true,
  41596. configurable: true
  41597. });
  41598. Object.defineProperty(SceneInstrumentation.prototype, "captureParticlesRenderTime", {
  41599. /**
  41600. * Gets the particles render time capture status
  41601. */
  41602. get: function () {
  41603. return this._captureParticlesRenderTime;
  41604. },
  41605. /**
  41606. * Enable or disable the particles render time capture
  41607. */
  41608. set: function (value) {
  41609. var _this = this;
  41610. if (value === this._captureParticlesRenderTime) {
  41611. return;
  41612. }
  41613. this._captureParticlesRenderTime = value;
  41614. if (value) {
  41615. this._onBeforeParticlesRenderingObserver = this.scene.onBeforeParticlesRenderingObservable.add(function () {
  41616. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Particles");
  41617. _this._particlesRenderTime.beginMonitoring();
  41618. });
  41619. this._onAfterParticlesRenderingObserver = this.scene.onAfterParticlesRenderingObservable.add(function () {
  41620. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Particles");
  41621. _this._particlesRenderTime.endMonitoring(false);
  41622. });
  41623. }
  41624. else {
  41625. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  41626. this._onBeforeParticlesRenderingObserver = null;
  41627. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  41628. this._onAfterParticlesRenderingObserver = null;
  41629. }
  41630. },
  41631. enumerable: true,
  41632. configurable: true
  41633. });
  41634. Object.defineProperty(SceneInstrumentation.prototype, "spritesRenderTimeCounter", {
  41635. /**
  41636. * Gets the perf counter used for sprites render time
  41637. */
  41638. get: function () {
  41639. return this._spritesRenderTime;
  41640. },
  41641. enumerable: true,
  41642. configurable: true
  41643. });
  41644. Object.defineProperty(SceneInstrumentation.prototype, "captureSpritesRenderTime", {
  41645. /**
  41646. * Gets the sprites render time capture status
  41647. */
  41648. get: function () {
  41649. return this._captureSpritesRenderTime;
  41650. },
  41651. /**
  41652. * Enable or disable the sprites render time capture
  41653. */
  41654. set: function (value) {
  41655. var _this = this;
  41656. if (value === this._captureSpritesRenderTime) {
  41657. return;
  41658. }
  41659. this._captureSpritesRenderTime = value;
  41660. if (!this.scene.spriteManagers) {
  41661. return;
  41662. }
  41663. if (value) {
  41664. this._onBeforeSpritesRenderingObserver = this.scene.onBeforeSpritesRenderingObservable.add(function () {
  41665. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Sprites");
  41666. _this._spritesRenderTime.beginMonitoring();
  41667. });
  41668. this._onAfterSpritesRenderingObserver = this.scene.onAfterSpritesRenderingObservable.add(function () {
  41669. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Sprites");
  41670. _this._spritesRenderTime.endMonitoring(false);
  41671. });
  41672. }
  41673. else {
  41674. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  41675. this._onBeforeSpritesRenderingObserver = null;
  41676. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  41677. this._onAfterSpritesRenderingObserver = null;
  41678. }
  41679. },
  41680. enumerable: true,
  41681. configurable: true
  41682. });
  41683. Object.defineProperty(SceneInstrumentation.prototype, "physicsTimeCounter", {
  41684. /**
  41685. * Gets the perf counter used for physics time
  41686. */
  41687. get: function () {
  41688. return this._physicsTime;
  41689. },
  41690. enumerable: true,
  41691. configurable: true
  41692. });
  41693. Object.defineProperty(SceneInstrumentation.prototype, "capturePhysicsTime", {
  41694. /**
  41695. * Gets the physics time capture status
  41696. */
  41697. get: function () {
  41698. return this._capturePhysicsTime;
  41699. },
  41700. /**
  41701. * Enable or disable the physics time capture
  41702. */
  41703. set: function (value) {
  41704. var _this = this;
  41705. if (value === this._capturePhysicsTime) {
  41706. return;
  41707. }
  41708. if (!this.scene.onBeforePhysicsObservable) {
  41709. return;
  41710. }
  41711. this._capturePhysicsTime = value;
  41712. if (value) {
  41713. this._onBeforePhysicsObserver = this.scene.onBeforePhysicsObservable.add(function () {
  41714. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Physics");
  41715. _this._physicsTime.beginMonitoring();
  41716. });
  41717. this._onAfterPhysicsObserver = this.scene.onAfterPhysicsObservable.add(function () {
  41718. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Physics");
  41719. _this._physicsTime.endMonitoring();
  41720. });
  41721. }
  41722. else {
  41723. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  41724. this._onBeforePhysicsObserver = null;
  41725. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  41726. this._onAfterPhysicsObserver = null;
  41727. }
  41728. },
  41729. enumerable: true,
  41730. configurable: true
  41731. });
  41732. Object.defineProperty(SceneInstrumentation.prototype, "animationsTimeCounter", {
  41733. /**
  41734. * Gets the perf counter used for animations time
  41735. */
  41736. get: function () {
  41737. return this._animationsTime;
  41738. },
  41739. enumerable: true,
  41740. configurable: true
  41741. });
  41742. Object.defineProperty(SceneInstrumentation.prototype, "captureAnimationsTime", {
  41743. /**
  41744. * Gets the animations time capture status
  41745. */
  41746. get: function () {
  41747. return this._captureAnimationsTime;
  41748. },
  41749. /**
  41750. * Enable or disable the animations time capture
  41751. */
  41752. set: function (value) {
  41753. var _this = this;
  41754. if (value === this._captureAnimationsTime) {
  41755. return;
  41756. }
  41757. this._captureAnimationsTime = value;
  41758. if (value) {
  41759. this._onAfterAnimationsObserver = this.scene.onAfterAnimationsObservable.add(function () {
  41760. _this._animationsTime.endMonitoring();
  41761. });
  41762. }
  41763. else {
  41764. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  41765. this._onAfterAnimationsObserver = null;
  41766. }
  41767. },
  41768. enumerable: true,
  41769. configurable: true
  41770. });
  41771. Object.defineProperty(SceneInstrumentation.prototype, "frameTimeCounter", {
  41772. /**
  41773. * Gets the perf counter used for frame time capture
  41774. */
  41775. get: function () {
  41776. return this._frameTime;
  41777. },
  41778. enumerable: true,
  41779. configurable: true
  41780. });
  41781. Object.defineProperty(SceneInstrumentation.prototype, "captureFrameTime", {
  41782. /**
  41783. * Gets the frame time capture status
  41784. */
  41785. get: function () {
  41786. return this._captureFrameTime;
  41787. },
  41788. /**
  41789. * Enable or disable the frame time capture
  41790. */
  41791. set: function (value) {
  41792. this._captureFrameTime = value;
  41793. },
  41794. enumerable: true,
  41795. configurable: true
  41796. });
  41797. Object.defineProperty(SceneInstrumentation.prototype, "interFrameTimeCounter", {
  41798. /**
  41799. * Gets the perf counter used for inter-frames time capture
  41800. */
  41801. get: function () {
  41802. return this._interFrameTime;
  41803. },
  41804. enumerable: true,
  41805. configurable: true
  41806. });
  41807. Object.defineProperty(SceneInstrumentation.prototype, "captureInterFrameTime", {
  41808. /**
  41809. * Gets the inter-frames time capture status
  41810. */
  41811. get: function () {
  41812. return this._captureInterFrameTime;
  41813. },
  41814. /**
  41815. * Enable or disable the inter-frames time capture
  41816. */
  41817. set: function (value) {
  41818. this._captureInterFrameTime = value;
  41819. },
  41820. enumerable: true,
  41821. configurable: true
  41822. });
  41823. Object.defineProperty(SceneInstrumentation.prototype, "renderTimeCounter", {
  41824. /**
  41825. * Gets the perf counter used for render time capture
  41826. */
  41827. get: function () {
  41828. return this._renderTime;
  41829. },
  41830. enumerable: true,
  41831. configurable: true
  41832. });
  41833. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTime", {
  41834. /**
  41835. * Gets the render time capture status
  41836. */
  41837. get: function () {
  41838. return this._captureRenderTime;
  41839. },
  41840. /**
  41841. * Enable or disable the render time capture
  41842. */
  41843. set: function (value) {
  41844. var _this = this;
  41845. if (value === this._captureRenderTime) {
  41846. return;
  41847. }
  41848. this._captureRenderTime = value;
  41849. if (value) {
  41850. this._onBeforeDrawPhaseObserver = this.scene.onBeforeDrawPhaseObservable.add(function () {
  41851. _this._renderTime.beginMonitoring();
  41852. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Main render");
  41853. });
  41854. this._onAfterDrawPhaseObserver = this.scene.onAfterDrawPhaseObservable.add(function () {
  41855. _this._renderTime.endMonitoring(false);
  41856. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Main render");
  41857. });
  41858. }
  41859. else {
  41860. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  41861. this._onBeforeDrawPhaseObserver = null;
  41862. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  41863. this._onAfterDrawPhaseObserver = null;
  41864. }
  41865. },
  41866. enumerable: true,
  41867. configurable: true
  41868. });
  41869. Object.defineProperty(SceneInstrumentation.prototype, "cameraRenderTimeCounter", {
  41870. /**
  41871. * Gets the perf counter used for camera render time capture
  41872. */
  41873. get: function () {
  41874. return this._cameraRenderTime;
  41875. },
  41876. enumerable: true,
  41877. configurable: true
  41878. });
  41879. Object.defineProperty(SceneInstrumentation.prototype, "captureCameraRenderTime", {
  41880. /**
  41881. * Gets the camera render time capture status
  41882. */
  41883. get: function () {
  41884. return this._captureCameraRenderTime;
  41885. },
  41886. /**
  41887. * Enable or disable the camera render time capture
  41888. */
  41889. set: function (value) {
  41890. var _this = this;
  41891. if (value === this._captureCameraRenderTime) {
  41892. return;
  41893. }
  41894. this._captureCameraRenderTime = value;
  41895. if (value) {
  41896. this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add(function (camera) {
  41897. _this._cameraRenderTime.beginMonitoring();
  41898. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Rendering camera " + camera.name);
  41899. });
  41900. this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add(function (camera) {
  41901. _this._cameraRenderTime.endMonitoring(false);
  41902. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Rendering camera " + camera.name);
  41903. });
  41904. }
  41905. else {
  41906. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  41907. this._onBeforeCameraRenderObserver = null;
  41908. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  41909. this._onAfterCameraRenderObserver = null;
  41910. }
  41911. },
  41912. enumerable: true,
  41913. configurable: true
  41914. });
  41915. Object.defineProperty(SceneInstrumentation.prototype, "drawCallsCounter", {
  41916. /**
  41917. * Gets the perf counter used for draw calls
  41918. */
  41919. get: function () {
  41920. return this.scene.getEngine()._drawCalls;
  41921. },
  41922. enumerable: true,
  41923. configurable: true
  41924. });
  41925. Object.defineProperty(SceneInstrumentation.prototype, "textureCollisionsCounter", {
  41926. /**
  41927. * Gets the perf counter used for texture collisions
  41928. */
  41929. get: function () {
  41930. return this.scene.getEngine()._textureCollisions;
  41931. },
  41932. enumerable: true,
  41933. configurable: true
  41934. });
  41935. /**
  41936. * Dispose and release associated resources.
  41937. */
  41938. SceneInstrumentation.prototype.dispose = function () {
  41939. this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  41940. this._onAfterRenderObserver = null;
  41941. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  41942. this._onBeforeActiveMeshesEvaluationObserver = null;
  41943. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  41944. this._onAfterActiveMeshesEvaluationObserver = null;
  41945. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  41946. this._onBeforeRenderTargetsRenderObserver = null;
  41947. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  41948. this._onAfterRenderTargetsRenderObserver = null;
  41949. this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver);
  41950. this._onBeforeAnimationsObserver = null;
  41951. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  41952. this._onBeforeParticlesRenderingObserver = null;
  41953. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  41954. this._onAfterParticlesRenderingObserver = null;
  41955. if (this._onBeforeSpritesRenderingObserver) {
  41956. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  41957. this._onBeforeSpritesRenderingObserver = null;
  41958. }
  41959. if (this._onAfterSpritesRenderingObserver) {
  41960. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  41961. this._onAfterSpritesRenderingObserver = null;
  41962. }
  41963. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  41964. this._onBeforeDrawPhaseObserver = null;
  41965. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  41966. this._onAfterDrawPhaseObserver = null;
  41967. if (this._onBeforePhysicsObserver) {
  41968. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  41969. this._onBeforePhysicsObserver = null;
  41970. }
  41971. if (this._onAfterPhysicsObserver) {
  41972. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  41973. this._onAfterPhysicsObserver = null;
  41974. }
  41975. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  41976. this._onAfterAnimationsObserver = null;
  41977. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  41978. this._onBeforeCameraRenderObserver = null;
  41979. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  41980. this._onAfterCameraRenderObserver = null;
  41981. this.scene = null;
  41982. };
  41983. return SceneInstrumentation;
  41984. }());
  41985. /***/ }),
  41986. /***/ "./Instrumentation/timeToken.ts":
  41987. /*!**************************************!*\
  41988. !*** ./Instrumentation/timeToken.ts ***!
  41989. \**************************************/
  41990. /*! exports provided: _TimeToken */
  41991. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41992. "use strict";
  41993. __webpack_require__.r(__webpack_exports__);
  41994. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _TimeToken; });
  41995. /**
  41996. * @hidden
  41997. **/
  41998. var _TimeToken = /** @class */ (function () {
  41999. function _TimeToken() {
  42000. this._timeElapsedQueryEnded = false;
  42001. }
  42002. return _TimeToken;
  42003. }());
  42004. /***/ }),
  42005. /***/ "./Layers/effectLayer.ts":
  42006. /*!*******************************!*\
  42007. !*** ./Layers/effectLayer.ts ***!
  42008. \*******************************/
  42009. /*! exports provided: EffectLayer */
  42010. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42011. "use strict";
  42012. __webpack_require__.r(__webpack_exports__);
  42013. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return EffectLayer; });
  42014. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  42015. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  42016. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  42017. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  42018. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42019. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  42020. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42021. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42022. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  42023. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42024. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  42025. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42026. /* harmony import */ var _Shaders_glowMapGeneration_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.fragment */ "./Shaders/glowMapGeneration.fragment.ts");
  42027. /* harmony import */ var _Shaders_glowMapGeneration_vertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.vertex */ "./Shaders/glowMapGeneration.vertex.ts");
  42028. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  42029. /**
  42030. * The effect layer Helps adding post process effect blended with the main pass.
  42031. *
  42032. * This can be for instance use to generate glow or higlight effects on the scene.
  42033. *
  42034. * The effect layer class can not be used directly and is intented to inherited from to be
  42035. * customized per effects.
  42036. */
  42037. var EffectLayer = /** @class */ (function () {
  42038. /**
  42039. * Instantiates a new effect Layer and references it in the scene.
  42040. * @param name The name of the layer
  42041. * @param scene The scene to use the layer in
  42042. */
  42043. function EffectLayer(
  42044. /** The Friendly of the effect in the scene */
  42045. name, scene) {
  42046. this._vertexBuffers = {};
  42047. this._maxSize = 0;
  42048. this._mainTextureDesiredSize = { width: 0, height: 0 };
  42049. this._shouldRender = true;
  42050. this._postProcesses = [];
  42051. this._textures = [];
  42052. this._emissiveTextureAndColor = { texture: null, color: new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]() };
  42053. /**
  42054. * The clear color of the texture used to generate the glow map.
  42055. */
  42056. this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]();
  42057. /**
  42058. * Specifies wether the highlight layer is enabled or not.
  42059. */
  42060. this.isEnabled = true;
  42061. /**
  42062. * An event triggered when the effect layer has been disposed.
  42063. */
  42064. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  42065. /**
  42066. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  42067. */
  42068. this.onBeforeRenderMainTextureObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  42069. /**
  42070. * An event triggered when the generated texture is being merged in the scene.
  42071. */
  42072. this.onBeforeComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  42073. /**
  42074. * An event triggered when the generated texture has been merged in the scene.
  42075. */
  42076. this.onAfterComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  42077. /**
  42078. * An event triggered when the efffect layer changes its size.
  42079. */
  42080. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  42081. this.name = name;
  42082. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  42083. EffectLayer._SceneComponentInitialization(this._scene);
  42084. this._engine = this._scene.getEngine();
  42085. this._maxSize = this._engine.getCaps().maxTextureSize;
  42086. this._scene.effectLayers.push(this);
  42087. // Generate Buffers
  42088. this._generateIndexBuffer();
  42089. this._genrateVertexBuffer();
  42090. }
  42091. Object.defineProperty(EffectLayer.prototype, "camera", {
  42092. /**
  42093. * Gets the camera attached to the layer.
  42094. */
  42095. get: function () {
  42096. return this._effectLayerOptions.camera;
  42097. },
  42098. enumerable: true,
  42099. configurable: true
  42100. });
  42101. Object.defineProperty(EffectLayer.prototype, "renderingGroupId", {
  42102. /**
  42103. * Gets the rendering group id the layer should render in.
  42104. */
  42105. get: function () {
  42106. return this._effectLayerOptions.renderingGroupId;
  42107. },
  42108. enumerable: true,
  42109. configurable: true
  42110. });
  42111. /**
  42112. * Initializes the effect layer with the required options.
  42113. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  42114. */
  42115. EffectLayer.prototype._init = function (options) {
  42116. // Adapt options
  42117. 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);
  42118. this._setMainTextureSize();
  42119. this._createMainTexture();
  42120. this._createTextureAndPostProcesses();
  42121. this._mergeEffect = this._createMergeEffect();
  42122. };
  42123. /**
  42124. * Generates the index buffer of the full screen quad blending to the main canvas.
  42125. */
  42126. EffectLayer.prototype._generateIndexBuffer = function () {
  42127. // Indices
  42128. var indices = [];
  42129. indices.push(0);
  42130. indices.push(1);
  42131. indices.push(2);
  42132. indices.push(0);
  42133. indices.push(2);
  42134. indices.push(3);
  42135. this._indexBuffer = this._engine.createIndexBuffer(indices);
  42136. };
  42137. /**
  42138. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  42139. */
  42140. EffectLayer.prototype._genrateVertexBuffer = function () {
  42141. // VBO
  42142. var vertices = [];
  42143. vertices.push(1, 1);
  42144. vertices.push(-1, 1);
  42145. vertices.push(-1, -1);
  42146. vertices.push(1, -1);
  42147. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"](this._engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind, false, false, 2);
  42148. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = vertexBuffer;
  42149. };
  42150. /**
  42151. * Sets the main texture desired size which is the closest power of two
  42152. * of the engine canvas size.
  42153. */
  42154. EffectLayer.prototype._setMainTextureSize = function () {
  42155. if (this._effectLayerOptions.mainTextureFixedSize) {
  42156. this._mainTextureDesiredSize.width = this._effectLayerOptions.mainTextureFixedSize;
  42157. this._mainTextureDesiredSize.height = this._effectLayerOptions.mainTextureFixedSize;
  42158. }
  42159. else {
  42160. this._mainTextureDesiredSize.width = this._engine.getRenderWidth() * this._effectLayerOptions.mainTextureRatio;
  42161. this._mainTextureDesiredSize.height = this._engine.getRenderHeight() * this._effectLayerOptions.mainTextureRatio;
  42162. this._mainTextureDesiredSize.width = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.width, this._maxSize) : this._mainTextureDesiredSize.width;
  42163. this._mainTextureDesiredSize.height = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.height, this._maxSize) : this._mainTextureDesiredSize.height;
  42164. }
  42165. this._mainTextureDesiredSize.width = Math.floor(this._mainTextureDesiredSize.width);
  42166. this._mainTextureDesiredSize.height = Math.floor(this._mainTextureDesiredSize.height);
  42167. };
  42168. /**
  42169. * Creates the main texture for the effect layer.
  42170. */
  42171. EffectLayer.prototype._createMainTexture = function () {
  42172. var _this = this;
  42173. this._mainTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerMainRTT", {
  42174. width: this._mainTextureDesiredSize.width,
  42175. height: this._mainTextureDesiredSize.height
  42176. }, this._scene, false, true, _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  42177. this._mainTexture.activeCamera = this._effectLayerOptions.camera;
  42178. this._mainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  42179. this._mainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  42180. this._mainTexture.anisotropicFilteringLevel = 1;
  42181. this._mainTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE);
  42182. this._mainTexture.renderParticles = false;
  42183. this._mainTexture.renderList = null;
  42184. this._mainTexture.ignoreCameraViewport = true;
  42185. // Custom render function
  42186. this._mainTexture.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  42187. _this.onBeforeRenderMainTextureObservable.notifyObservers(_this);
  42188. var index;
  42189. var engine = _this._scene.getEngine();
  42190. if (depthOnlySubMeshes.length) {
  42191. engine.setColorWrite(false);
  42192. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  42193. _this._renderSubMesh(depthOnlySubMeshes.data[index]);
  42194. }
  42195. engine.setColorWrite(true);
  42196. }
  42197. for (index = 0; index < opaqueSubMeshes.length; index++) {
  42198. _this._renderSubMesh(opaqueSubMeshes.data[index]);
  42199. }
  42200. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  42201. _this._renderSubMesh(alphaTestSubMeshes.data[index]);
  42202. }
  42203. for (index = 0; index < transparentSubMeshes.length; index++) {
  42204. _this._renderSubMesh(transparentSubMeshes.data[index]);
  42205. }
  42206. };
  42207. this._mainTexture.onClearObservable.add(function (engine) {
  42208. engine.clear(_this.neutralColor, true, true, true);
  42209. });
  42210. };
  42211. /**
  42212. * Adds specific effects defines.
  42213. * @param defines The defines to add specifics to.
  42214. */
  42215. EffectLayer.prototype._addCustomEffectDefines = function (defines) {
  42216. // Nothing to add by default.
  42217. };
  42218. /**
  42219. * Checks for the readiness of the element composing the layer.
  42220. * @param subMesh the mesh to check for
  42221. * @param useInstances specify wether or not to use instances to render the mesh
  42222. * @param emissiveTexture the associated emissive texture used to generate the glow
  42223. * @return true if ready otherwise, false
  42224. */
  42225. EffectLayer.prototype._isReady = function (subMesh, useInstances, emissiveTexture) {
  42226. var material = subMesh.getMaterial();
  42227. if (!material) {
  42228. return false;
  42229. }
  42230. if (!material.isReadyForSubMesh(subMesh.getMesh(), subMesh, useInstances)) {
  42231. return false;
  42232. }
  42233. var defines = [];
  42234. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  42235. var mesh = subMesh.getMesh();
  42236. var uv1 = false;
  42237. var uv2 = false;
  42238. // Diffuse
  42239. if (material) {
  42240. var needAlphaTest = material.needAlphaTesting();
  42241. var diffuseTexture = material.getAlphaTestTexture();
  42242. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  42243. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  42244. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  42245. defines.push("#define DIFFUSE");
  42246. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  42247. diffuseTexture.coordinatesIndex === 1) {
  42248. defines.push("#define DIFFUSEUV2");
  42249. uv2 = true;
  42250. }
  42251. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  42252. defines.push("#define DIFFUSEUV1");
  42253. uv1 = true;
  42254. }
  42255. if (needAlphaTest) {
  42256. defines.push("#define ALPHATEST");
  42257. defines.push("#define ALPHATESTVALUE 0.4");
  42258. }
  42259. }
  42260. var opacityTexture = material.opacityTexture;
  42261. if (opacityTexture) {
  42262. defines.push("#define OPACITY");
  42263. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  42264. opacityTexture.coordinatesIndex === 1) {
  42265. defines.push("#define OPACITYUV2");
  42266. uv2 = true;
  42267. }
  42268. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  42269. defines.push("#define OPACITYUV1");
  42270. uv1 = true;
  42271. }
  42272. }
  42273. }
  42274. // Emissive
  42275. if (emissiveTexture) {
  42276. defines.push("#define EMISSIVE");
  42277. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  42278. emissiveTexture.coordinatesIndex === 1) {
  42279. defines.push("#define EMISSIVEUV2");
  42280. uv2 = true;
  42281. }
  42282. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  42283. defines.push("#define EMISSIVEUV1");
  42284. uv1 = true;
  42285. }
  42286. }
  42287. // Vertex
  42288. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind) && mesh.hasVertexAlpha) {
  42289. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind);
  42290. defines.push("#define VERTEXALPHA");
  42291. }
  42292. if (uv1) {
  42293. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind);
  42294. defines.push("#define UV1");
  42295. }
  42296. if (uv2) {
  42297. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind);
  42298. defines.push("#define UV2");
  42299. }
  42300. // Bones
  42301. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  42302. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesKind);
  42303. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsKind);
  42304. if (mesh.numBoneInfluencers > 4) {
  42305. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesExtraKind);
  42306. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsExtraKind);
  42307. }
  42308. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  42309. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  42310. }
  42311. else {
  42312. defines.push("#define NUM_BONE_INFLUENCERS 0");
  42313. }
  42314. // Morph targets
  42315. var manager = mesh.morphTargetManager;
  42316. var morphInfluencers = 0;
  42317. if (manager) {
  42318. if (manager.numInfluencers > 0) {
  42319. defines.push("#define MORPHTARGETS");
  42320. morphInfluencers = manager.numInfluencers;
  42321. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  42322. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  42323. }
  42324. }
  42325. // Instances
  42326. if (useInstances) {
  42327. defines.push("#define INSTANCES");
  42328. attribs.push("world0");
  42329. attribs.push("world1");
  42330. attribs.push("world2");
  42331. attribs.push("world3");
  42332. }
  42333. this._addCustomEffectDefines(defines);
  42334. // Get correct effect
  42335. var join = defines.join("\n");
  42336. if (this._cachedDefines !== join) {
  42337. this._cachedDefines = join;
  42338. this._effectLayerMapGenerationEffect = this._scene.getEngine().createEffect("glowMapGeneration", attribs, ["world", "mBones", "viewProjection",
  42339. "color", "morphTargetInfluences",
  42340. "diffuseMatrix", "emissiveMatrix", "opacityMatrix", "opacityIntensity"], ["diffuseSampler", "emissiveSampler", "opacitySampler"], join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  42341. }
  42342. return this._effectLayerMapGenerationEffect.isReady();
  42343. };
  42344. /**
  42345. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  42346. */
  42347. EffectLayer.prototype.render = function () {
  42348. var currentEffect = this._mergeEffect;
  42349. // Check
  42350. if (!currentEffect.isReady()) {
  42351. return;
  42352. }
  42353. for (var i = 0; i < this._postProcesses.length; i++) {
  42354. if (!this._postProcesses[i].isReady()) {
  42355. return;
  42356. }
  42357. }
  42358. var engine = this._scene.getEngine();
  42359. this.onBeforeComposeObservable.notifyObservers(this);
  42360. // Render
  42361. engine.enableEffect(currentEffect);
  42362. engine.setState(false);
  42363. // VBOs
  42364. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  42365. // Cache
  42366. var previousAlphaMode = engine.getAlphaMode();
  42367. // Go Blend.
  42368. engine.setAlphaMode(this._effectLayerOptions.alphaBlendingMode);
  42369. // Blends the map on the main canvas.
  42370. this._internalRender(currentEffect);
  42371. // Restore Alpha
  42372. engine.setAlphaMode(previousAlphaMode);
  42373. this.onAfterComposeObservable.notifyObservers(this);
  42374. // Handle size changes.
  42375. var size = this._mainTexture.getSize();
  42376. this._setMainTextureSize();
  42377. if (size.width !== this._mainTextureDesiredSize.width || size.height !== this._mainTextureDesiredSize.height) {
  42378. // Recreate RTT and post processes on size change.
  42379. this.onSizeChangedObservable.notifyObservers(this);
  42380. this._disposeTextureAndPostProcesses();
  42381. this._createMainTexture();
  42382. this._createTextureAndPostProcesses();
  42383. }
  42384. };
  42385. /**
  42386. * Determine if a given mesh will be used in the current effect.
  42387. * @param mesh mesh to test
  42388. * @returns true if the mesh will be used
  42389. */
  42390. EffectLayer.prototype.hasMesh = function (mesh) {
  42391. if (this.renderingGroupId === -1 || mesh.renderingGroupId === this.renderingGroupId) {
  42392. return true;
  42393. }
  42394. return false;
  42395. };
  42396. /**
  42397. * Returns true if the layer contains information to display, otherwise false.
  42398. * @returns true if the glow layer should be rendered
  42399. */
  42400. EffectLayer.prototype.shouldRender = function () {
  42401. return this.isEnabled && this._shouldRender;
  42402. };
  42403. /**
  42404. * Returns true if the mesh should render, otherwise false.
  42405. * @param mesh The mesh to render
  42406. * @returns true if it should render otherwise false
  42407. */
  42408. EffectLayer.prototype._shouldRenderMesh = function (mesh) {
  42409. return true;
  42410. };
  42411. /**
  42412. * Returns true if the mesh can be rendered, otherwise false.
  42413. * @param mesh The mesh to render
  42414. * @param material The material used on the mesh
  42415. * @returns true if it can be rendered otherwise false
  42416. */
  42417. EffectLayer.prototype._canRenderMesh = function (mesh, material) {
  42418. return !material.needAlphaBlendingForMesh(mesh);
  42419. };
  42420. /**
  42421. * Returns true if the mesh should render, otherwise false.
  42422. * @param mesh The mesh to render
  42423. * @returns true if it should render otherwise false
  42424. */
  42425. EffectLayer.prototype._shouldRenderEmissiveTextureForMesh = function () {
  42426. return true;
  42427. };
  42428. /**
  42429. * Renders the submesh passed in parameter to the generation map.
  42430. */
  42431. EffectLayer.prototype._renderSubMesh = function (subMesh) {
  42432. var _this = this;
  42433. if (!this.shouldRender()) {
  42434. return;
  42435. }
  42436. var material = subMesh.getMaterial();
  42437. var mesh = subMesh.getRenderingMesh();
  42438. var scene = this._scene;
  42439. var engine = scene.getEngine();
  42440. if (!material) {
  42441. return;
  42442. }
  42443. // Do not block in blend mode.
  42444. if (!this._canRenderMesh(mesh, material)) {
  42445. return;
  42446. }
  42447. // Culling
  42448. engine.setState(material.backFaceCulling);
  42449. // Managing instances
  42450. var batch = mesh._getInstancesRenderList(subMesh._id);
  42451. if (batch.mustReturn) {
  42452. return;
  42453. }
  42454. // Early Exit per mesh
  42455. if (!this._shouldRenderMesh(mesh)) {
  42456. return;
  42457. }
  42458. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  42459. this._setEmissiveTextureAndColor(mesh, subMesh, material);
  42460. if (this._isReady(subMesh, hardwareInstancedRendering, this._emissiveTextureAndColor.texture)) {
  42461. engine.enableEffect(this._effectLayerMapGenerationEffect);
  42462. mesh._bind(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode);
  42463. this._effectLayerMapGenerationEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  42464. this._effectLayerMapGenerationEffect.setFloat4("color", this._emissiveTextureAndColor.color.r, this._emissiveTextureAndColor.color.g, this._emissiveTextureAndColor.color.b, this._emissiveTextureAndColor.color.a);
  42465. var needAlphaTest = material.needAlphaTesting();
  42466. var diffuseTexture = material.getAlphaTestTexture();
  42467. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  42468. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  42469. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  42470. this._effectLayerMapGenerationEffect.setTexture("diffuseSampler", diffuseTexture);
  42471. var textureMatrix = diffuseTexture.getTextureMatrix();
  42472. if (textureMatrix) {
  42473. this._effectLayerMapGenerationEffect.setMatrix("diffuseMatrix", textureMatrix);
  42474. }
  42475. }
  42476. var opacityTexture = material.opacityTexture;
  42477. if (opacityTexture) {
  42478. this._effectLayerMapGenerationEffect.setTexture("opacitySampler", opacityTexture);
  42479. this._effectLayerMapGenerationEffect.setFloat("opacityIntensity", opacityTexture.level);
  42480. var textureMatrix = opacityTexture.getTextureMatrix();
  42481. if (textureMatrix) {
  42482. this._effectLayerMapGenerationEffect.setMatrix("opacityMatrix", textureMatrix);
  42483. }
  42484. }
  42485. // Glow emissive only
  42486. if (this._emissiveTextureAndColor.texture) {
  42487. this._effectLayerMapGenerationEffect.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture);
  42488. this._effectLayerMapGenerationEffect.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix());
  42489. }
  42490. // Bones
  42491. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  42492. this._effectLayerMapGenerationEffect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  42493. }
  42494. // Morph targets
  42495. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effectLayerMapGenerationEffect);
  42496. // Draw
  42497. mesh._processRendering(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effectLayerMapGenerationEffect.setMatrix("world", world); });
  42498. }
  42499. else {
  42500. // Need to reset refresh rate of the main map
  42501. this._mainTexture.resetRefreshCounter();
  42502. }
  42503. };
  42504. /**
  42505. * Rebuild the required buffers.
  42506. * @hidden Internal use only.
  42507. */
  42508. EffectLayer.prototype._rebuild = function () {
  42509. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  42510. if (vb) {
  42511. vb._rebuild();
  42512. }
  42513. this._generateIndexBuffer();
  42514. };
  42515. /**
  42516. * Dispose only the render target textures and post process.
  42517. */
  42518. EffectLayer.prototype._disposeTextureAndPostProcesses = function () {
  42519. this._mainTexture.dispose();
  42520. for (var i = 0; i < this._postProcesses.length; i++) {
  42521. if (this._postProcesses[i]) {
  42522. this._postProcesses[i].dispose();
  42523. }
  42524. }
  42525. this._postProcesses = [];
  42526. for (var i = 0; i < this._textures.length; i++) {
  42527. if (this._textures[i]) {
  42528. this._textures[i].dispose();
  42529. }
  42530. }
  42531. this._textures = [];
  42532. };
  42533. /**
  42534. * Dispose the highlight layer and free resources.
  42535. */
  42536. EffectLayer.prototype.dispose = function () {
  42537. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  42538. if (vertexBuffer) {
  42539. vertexBuffer.dispose();
  42540. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = null;
  42541. }
  42542. if (this._indexBuffer) {
  42543. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  42544. this._indexBuffer = null;
  42545. }
  42546. // Clean textures and post processes
  42547. this._disposeTextureAndPostProcesses();
  42548. // Remove from scene
  42549. var index = this._scene.effectLayers.indexOf(this, 0);
  42550. if (index > -1) {
  42551. this._scene.effectLayers.splice(index, 1);
  42552. }
  42553. // Callback
  42554. this.onDisposeObservable.notifyObservers(this);
  42555. this.onDisposeObservable.clear();
  42556. this.onBeforeRenderMainTextureObservable.clear();
  42557. this.onBeforeComposeObservable.clear();
  42558. this.onAfterComposeObservable.clear();
  42559. this.onSizeChangedObservable.clear();
  42560. };
  42561. /**
  42562. * Gets the class name of the effect layer
  42563. * @returns the string with the class name of the effect layer
  42564. */
  42565. EffectLayer.prototype.getClassName = function () {
  42566. return "EffectLayer";
  42567. };
  42568. /**
  42569. * Creates an effect layer from parsed effect layer data
  42570. * @param parsedEffectLayer defines effect layer data
  42571. * @param scene defines the current scene
  42572. * @param rootUrl defines the root URL containing the effect layer information
  42573. * @returns a parsed effect Layer
  42574. */
  42575. EffectLayer.Parse = function (parsedEffectLayer, scene, rootUrl) {
  42576. var effectLayerType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedEffectLayer.customType);
  42577. return effectLayerType.Parse(parsedEffectLayer, scene, rootUrl);
  42578. };
  42579. /** @hidden */
  42580. EffectLayer._SceneComponentInitialization = function (_) {
  42581. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__["_DevTools"].WarnImport("EffectLayerSceneComponent");
  42582. };
  42583. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42584. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42585. ], EffectLayer.prototype, "name", void 0);
  42586. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42587. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  42588. ], EffectLayer.prototype, "neutralColor", void 0);
  42589. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42590. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42591. ], EffectLayer.prototype, "isEnabled", void 0);
  42592. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42593. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsCameraReference"])()
  42594. ], EffectLayer.prototype, "camera", null);
  42595. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42596. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42597. ], EffectLayer.prototype, "renderingGroupId", null);
  42598. return EffectLayer;
  42599. }());
  42600. /***/ }),
  42601. /***/ "./Layers/effectLayerSceneComponent.ts":
  42602. /*!*********************************************!*\
  42603. !*** ./Layers/effectLayerSceneComponent.ts ***!
  42604. \*********************************************/
  42605. /*! exports provided: EffectLayerSceneComponent */
  42606. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42607. "use strict";
  42608. __webpack_require__.r(__webpack_exports__);
  42609. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return EffectLayerSceneComponent; });
  42610. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  42611. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  42612. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42613. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  42614. // Adds the parser to the scene parsers.
  42615. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER, function (parsedData, scene, container, rootUrl) {
  42616. if (parsedData.effectLayers) {
  42617. if (!container.effectLayers) {
  42618. container.effectLayers = new Array();
  42619. }
  42620. for (var index = 0; index < parsedData.effectLayers.length; index++) {
  42621. var effectLayer = _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"].Parse(parsedData.effectLayers[index], scene, rootUrl);
  42622. container.effectLayers.push(effectLayer);
  42623. }
  42624. }
  42625. });
  42626. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.removeEffectLayer = function (toRemove) {
  42627. var index = this.effectLayers.indexOf(toRemove);
  42628. if (index !== -1) {
  42629. this.effectLayers.splice(index, 1);
  42630. }
  42631. return index;
  42632. };
  42633. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.addEffectLayer = function (newEffectLayer) {
  42634. this.effectLayers.push(newEffectLayer);
  42635. };
  42636. /**
  42637. * Defines the layer scene component responsible to manage any effect layers
  42638. * in a given scene.
  42639. */
  42640. var EffectLayerSceneComponent = /** @class */ (function () {
  42641. /**
  42642. * Creates a new instance of the component for the given scene
  42643. * @param scene Defines the scene to register the component in
  42644. */
  42645. function EffectLayerSceneComponent(scene) {
  42646. /**
  42647. * The component name helpfull to identify the component in the list of scene components.
  42648. */
  42649. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER;
  42650. this._renderEffects = false;
  42651. this._needStencil = false;
  42652. this._previousStencilState = false;
  42653. this.scene = scene;
  42654. this._engine = scene.getEngine();
  42655. scene.effectLayers = new Array();
  42656. }
  42657. /**
  42658. * Registers the component in a given scene
  42659. */
  42660. EffectLayerSceneComponent.prototype.register = function () {
  42661. this.scene._isReadyForMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_ISREADYFORMESH_EFFECTLAYER, this, this._isReadyForMesh);
  42662. this.scene._cameraDrawRenderTargetStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER, this, this._renderMainTexture);
  42663. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_EFFECTLAYER, this, this._setStencil);
  42664. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW, this, this._drawRenderingGroup);
  42665. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER, this, this._setStencilBack);
  42666. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW, this, this._drawCamera);
  42667. };
  42668. /**
  42669. * Rebuilds the elements related to this component in case of
  42670. * context lost for instance.
  42671. */
  42672. EffectLayerSceneComponent.prototype.rebuild = function () {
  42673. var layers = this.scene.effectLayers;
  42674. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  42675. var effectLayer = layers_1[_i];
  42676. effectLayer._rebuild();
  42677. }
  42678. };
  42679. /**
  42680. * Serializes the component data to the specified json object
  42681. * @param serializationObject The object to serialize to
  42682. */
  42683. EffectLayerSceneComponent.prototype.serialize = function (serializationObject) {
  42684. // Effect layers
  42685. serializationObject.effectLayers = [];
  42686. var layers = this.scene.effectLayers;
  42687. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  42688. var effectLayer = layers_2[_i];
  42689. if (effectLayer.serialize) {
  42690. serializationObject.effectLayers.push(effectLayer.serialize());
  42691. }
  42692. }
  42693. };
  42694. /**
  42695. * Adds all the element from the container to the scene
  42696. * @param container the container holding the elements
  42697. */
  42698. EffectLayerSceneComponent.prototype.addFromContainer = function (container) {
  42699. var _this = this;
  42700. if (!container.effectLayers) {
  42701. return;
  42702. }
  42703. container.effectLayers.forEach(function (o) {
  42704. _this.scene.addEffectLayer(o);
  42705. });
  42706. };
  42707. /**
  42708. * Removes all the elements in the container from the scene
  42709. * @param container contains the elements to remove
  42710. * @param dispose if the removed element should be disposed (default: false)
  42711. */
  42712. EffectLayerSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  42713. var _this = this;
  42714. if (!container.effectLayers) {
  42715. return;
  42716. }
  42717. container.effectLayers.forEach(function (o) {
  42718. _this.scene.removeEffectLayer(o);
  42719. if (dispose) {
  42720. o.dispose();
  42721. }
  42722. });
  42723. };
  42724. /**
  42725. * Disposes the component and the associated ressources.
  42726. */
  42727. EffectLayerSceneComponent.prototype.dispose = function () {
  42728. var layers = this.scene.effectLayers;
  42729. while (layers.length) {
  42730. layers[0].dispose();
  42731. }
  42732. };
  42733. EffectLayerSceneComponent.prototype._isReadyForMesh = function (mesh, hardwareInstancedRendering) {
  42734. var layers = this.scene.effectLayers;
  42735. for (var _i = 0, layers_3 = layers; _i < layers_3.length; _i++) {
  42736. var layer = layers_3[_i];
  42737. if (!layer.hasMesh(mesh)) {
  42738. continue;
  42739. }
  42740. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  42741. var subMesh = _b[_a];
  42742. if (!layer.isReady(subMesh, hardwareInstancedRendering)) {
  42743. return false;
  42744. }
  42745. }
  42746. }
  42747. return true;
  42748. };
  42749. EffectLayerSceneComponent.prototype._renderMainTexture = function (camera) {
  42750. this._renderEffects = false;
  42751. this._needStencil = false;
  42752. var layers = this.scene.effectLayers;
  42753. if (layers && layers.length > 0) {
  42754. this._previousStencilState = this._engine.getStencilBuffer();
  42755. for (var _i = 0, layers_4 = layers; _i < layers_4.length; _i++) {
  42756. var effectLayer = layers_4[_i];
  42757. if (effectLayer.shouldRender() &&
  42758. (!effectLayer.camera ||
  42759. (effectLayer.camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && camera === effectLayer.camera) ||
  42760. (effectLayer.camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && effectLayer.camera._rigCameras.indexOf(camera) > -1))) {
  42761. this._renderEffects = true;
  42762. this._needStencil = this._needStencil || effectLayer.needStencil();
  42763. var renderTarget = effectLayer._mainTexture;
  42764. if (renderTarget._shouldRender()) {
  42765. this.scene.incrementRenderId();
  42766. renderTarget.render(false, false);
  42767. }
  42768. }
  42769. }
  42770. this.scene.incrementRenderId();
  42771. }
  42772. };
  42773. EffectLayerSceneComponent.prototype._setStencil = function () {
  42774. // Activate effect Layer stencil
  42775. if (this._needStencil) {
  42776. this._engine.setStencilBuffer(true);
  42777. }
  42778. };
  42779. EffectLayerSceneComponent.prototype._setStencilBack = function () {
  42780. // Restore effect Layer stencil
  42781. if (this._needStencil) {
  42782. this._engine.setStencilBuffer(this._previousStencilState);
  42783. }
  42784. };
  42785. EffectLayerSceneComponent.prototype._draw = function (renderingGroupId) {
  42786. if (this._renderEffects) {
  42787. this._engine.setDepthBuffer(false);
  42788. var layers = this.scene.effectLayers;
  42789. for (var i = 0; i < layers.length; i++) {
  42790. var effectLayer = layers[i];
  42791. if (effectLayer.renderingGroupId === renderingGroupId) {
  42792. if (effectLayer.shouldRender()) {
  42793. effectLayer.render();
  42794. }
  42795. }
  42796. }
  42797. this._engine.setDepthBuffer(true);
  42798. }
  42799. };
  42800. EffectLayerSceneComponent.prototype._drawCamera = function () {
  42801. if (this._renderEffects) {
  42802. this._draw(-1);
  42803. }
  42804. };
  42805. EffectLayerSceneComponent.prototype._drawRenderingGroup = function (index) {
  42806. if (!this.scene._isInIntermediateRendering() && this._renderEffects) {
  42807. this._draw(index);
  42808. }
  42809. };
  42810. return EffectLayerSceneComponent;
  42811. }());
  42812. _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"]._SceneComponentInitialization = function (scene) {
  42813. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER);
  42814. if (!component) {
  42815. component = new EffectLayerSceneComponent(scene);
  42816. scene._addComponent(component);
  42817. }
  42818. };
  42819. /***/ }),
  42820. /***/ "./Layers/glowLayer.ts":
  42821. /*!*****************************!*\
  42822. !*** ./Layers/glowLayer.ts ***!
  42823. \*****************************/
  42824. /*! exports provided: GlowLayer */
  42825. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42826. "use strict";
  42827. __webpack_require__.r(__webpack_exports__);
  42828. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return GlowLayer; });
  42829. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  42830. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  42831. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  42832. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42833. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42834. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42835. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  42836. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42837. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  42838. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42839. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  42840. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42841. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  42842. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  42843. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  42844. /* harmony import */ var _Layers_effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Layers/effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  42845. _abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"].prototype.getGlowLayerByName = function (name) {
  42846. for (var index = 0; index < this.effectLayers.length; index++) {
  42847. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === GlowLayer.EffectName) {
  42848. return this.effectLayers[index];
  42849. }
  42850. }
  42851. return null;
  42852. };
  42853. /**
  42854. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  42855. *
  42856. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  42857. * glowy meshes to your scene.
  42858. *
  42859. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  42860. */
  42861. var GlowLayer = /** @class */ (function (_super) {
  42862. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowLayer, _super);
  42863. /**
  42864. * Instantiates a new glow Layer and references it to the scene.
  42865. * @param name The name of the layer
  42866. * @param scene The scene to use the layer in
  42867. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  42868. */
  42869. function GlowLayer(name, scene, options) {
  42870. var _this = _super.call(this, name, scene) || this;
  42871. _this._intensity = 1.0;
  42872. _this._includedOnlyMeshes = [];
  42873. _this._excludedMeshes = [];
  42874. _this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 1);
  42875. // Adapt options
  42876. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ mainTextureRatio: GlowLayer.DefaultTextureRatio, blurKernelSize: 32, mainTextureFixedSize: undefined, camera: null, mainTextureSamples: 1, renderingGroupId: -1 }, options);
  42877. // Initialize the layer
  42878. _this._init({
  42879. alphaBlendingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ALPHA_ADD,
  42880. camera: _this._options.camera,
  42881. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  42882. mainTextureRatio: _this._options.mainTextureRatio,
  42883. renderingGroupId: _this._options.renderingGroupId
  42884. });
  42885. return _this;
  42886. }
  42887. Object.defineProperty(GlowLayer.prototype, "blurKernelSize", {
  42888. /**
  42889. * Gets the kernel size of the blur.
  42890. */
  42891. get: function () {
  42892. return this._horizontalBlurPostprocess1.kernel;
  42893. },
  42894. /**
  42895. * Sets the kernel size of the blur.
  42896. */
  42897. set: function (value) {
  42898. this._horizontalBlurPostprocess1.kernel = value;
  42899. this._verticalBlurPostprocess1.kernel = value;
  42900. this._horizontalBlurPostprocess2.kernel = value;
  42901. this._verticalBlurPostprocess2.kernel = value;
  42902. },
  42903. enumerable: true,
  42904. configurable: true
  42905. });
  42906. Object.defineProperty(GlowLayer.prototype, "intensity", {
  42907. /**
  42908. * Gets the glow intensity.
  42909. */
  42910. get: function () {
  42911. return this._intensity;
  42912. },
  42913. /**
  42914. * Sets the glow intensity.
  42915. */
  42916. set: function (value) {
  42917. this._intensity = value;
  42918. },
  42919. enumerable: true,
  42920. configurable: true
  42921. });
  42922. /**
  42923. * Get the effect name of the layer.
  42924. * @return The effect name
  42925. */
  42926. GlowLayer.prototype.getEffectName = function () {
  42927. return GlowLayer.EffectName;
  42928. };
  42929. /**
  42930. * Create the merge effect. This is the shader use to blit the information back
  42931. * to the main canvas at the end of the scene rendering.
  42932. */
  42933. GlowLayer.prototype._createMergeEffect = function () {
  42934. // Effect
  42935. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler", "textureSampler2"], "#define EMISSIVE \n");
  42936. };
  42937. /**
  42938. * Creates the render target textures and post processes used in the glow layer.
  42939. */
  42940. GlowLayer.prototype._createTextureAndPostProcesses = function () {
  42941. var _this = this;
  42942. var blurTextureWidth = this._mainTextureDesiredSize.width;
  42943. var blurTextureHeight = this._mainTextureDesiredSize.height;
  42944. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  42945. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  42946. var textureType = 0;
  42947. if (this._engine.getCaps().textureHalfFloatRender) {
  42948. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_HALF_FLOAT;
  42949. }
  42950. else {
  42951. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  42952. }
  42953. this._blurTexture1 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT", {
  42954. width: blurTextureWidth,
  42955. height: blurTextureHeight
  42956. }, this._scene, false, true, textureType);
  42957. this._blurTexture1.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42958. this._blurTexture1.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42959. this._blurTexture1.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  42960. this._blurTexture1.renderParticles = false;
  42961. this._blurTexture1.ignoreCameraViewport = true;
  42962. var blurTextureWidth2 = Math.floor(blurTextureWidth / 2);
  42963. var blurTextureHeight2 = Math.floor(blurTextureHeight / 2);
  42964. this._blurTexture2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT2", {
  42965. width: blurTextureWidth2,
  42966. height: blurTextureHeight2
  42967. }, this._scene, false, true, textureType);
  42968. this._blurTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42969. this._blurTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42970. this._blurTexture2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  42971. this._blurTexture2.renderParticles = false;
  42972. this._blurTexture2.ignoreCameraViewport = true;
  42973. this._textures = [this._blurTexture1, this._blurTexture2];
  42974. 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, {
  42975. width: blurTextureWidth,
  42976. height: blurTextureHeight
  42977. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42978. this._horizontalBlurPostprocess1.width = blurTextureWidth;
  42979. this._horizontalBlurPostprocess1.height = blurTextureHeight;
  42980. this._horizontalBlurPostprocess1.onApplyObservable.add(function (effect) {
  42981. effect.setTexture("textureSampler", _this._mainTexture);
  42982. });
  42983. 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, {
  42984. width: blurTextureWidth,
  42985. height: blurTextureHeight
  42986. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42987. 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, {
  42988. width: blurTextureWidth2,
  42989. height: blurTextureHeight2
  42990. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42991. this._horizontalBlurPostprocess2.width = blurTextureWidth2;
  42992. this._horizontalBlurPostprocess2.height = blurTextureHeight2;
  42993. this._horizontalBlurPostprocess2.onApplyObservable.add(function (effect) {
  42994. effect.setTexture("textureSampler", _this._blurTexture1);
  42995. });
  42996. 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, {
  42997. width: blurTextureWidth2,
  42998. height: blurTextureHeight2
  42999. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  43000. this._postProcesses = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1, this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  43001. this._postProcesses1 = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1];
  43002. this._postProcesses2 = [this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  43003. this._mainTexture.samples = this._options.mainTextureSamples;
  43004. this._mainTexture.onAfterUnbindObservable.add(function () {
  43005. var internalTexture = _this._blurTexture1.getInternalTexture();
  43006. if (internalTexture) {
  43007. _this._scene.postProcessManager.directRender(_this._postProcesses1, internalTexture, true);
  43008. internalTexture = _this._blurTexture2.getInternalTexture();
  43009. if (internalTexture) {
  43010. _this._scene.postProcessManager.directRender(_this._postProcesses2, internalTexture, true);
  43011. }
  43012. }
  43013. });
  43014. // Prevent autoClear.
  43015. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  43016. };
  43017. /**
  43018. * Checks for the readiness of the element composing the layer.
  43019. * @param subMesh the mesh to check for
  43020. * @param useInstances specify wether or not to use instances to render the mesh
  43021. * @param emissiveTexture the associated emissive texture used to generate the glow
  43022. * @return true if ready otherwise, false
  43023. */
  43024. GlowLayer.prototype.isReady = function (subMesh, useInstances) {
  43025. var material = subMesh.getMaterial();
  43026. var mesh = subMesh.getRenderingMesh();
  43027. if (!material || !mesh) {
  43028. return false;
  43029. }
  43030. var emissiveTexture = material.emissiveTexture;
  43031. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  43032. };
  43033. /**
  43034. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  43035. */
  43036. GlowLayer.prototype.needStencil = function () {
  43037. return false;
  43038. };
  43039. /**
  43040. * Returns true if the mesh can be rendered, otherwise false.
  43041. * @param mesh The mesh to render
  43042. * @param material The material used on the mesh
  43043. * @returns true if it can be rendered otherwise false
  43044. */
  43045. GlowLayer.prototype._canRenderMesh = function (mesh, material) {
  43046. return true;
  43047. };
  43048. /**
  43049. * Implementation specific of rendering the generating effect on the main canvas.
  43050. * @param effect The effect used to render through
  43051. */
  43052. GlowLayer.prototype._internalRender = function (effect) {
  43053. // Texture
  43054. effect.setTexture("textureSampler", this._blurTexture1);
  43055. effect.setTexture("textureSampler2", this._blurTexture2);
  43056. effect.setFloat("offset", this._intensity);
  43057. // Cache
  43058. var engine = this._engine;
  43059. var previousStencilBuffer = engine.getStencilBuffer();
  43060. // Draw order
  43061. engine.setStencilBuffer(false);
  43062. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, 6);
  43063. // Draw order
  43064. engine.setStencilBuffer(previousStencilBuffer);
  43065. };
  43066. /**
  43067. * Sets the required values for both the emissive texture and and the main color.
  43068. */
  43069. GlowLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  43070. var textureLevel = 1.0;
  43071. if (this.customEmissiveTextureSelector) {
  43072. this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(mesh, subMesh, material);
  43073. }
  43074. else {
  43075. if (material) {
  43076. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  43077. if (this._emissiveTextureAndColor.texture) {
  43078. textureLevel = this._emissiveTextureAndColor.texture.level;
  43079. }
  43080. }
  43081. else {
  43082. this._emissiveTextureAndColor.texture = null;
  43083. }
  43084. }
  43085. if (this.customEmissiveColorSelector) {
  43086. this.customEmissiveColorSelector(mesh, subMesh, material, this._emissiveTextureAndColor.color);
  43087. }
  43088. else {
  43089. if (material.emissiveColor) {
  43090. this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, material.alpha);
  43091. }
  43092. else {
  43093. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  43094. }
  43095. }
  43096. };
  43097. /**
  43098. * Returns true if the mesh should render, otherwise false.
  43099. * @param mesh The mesh to render
  43100. * @returns true if it should render otherwise false
  43101. */
  43102. GlowLayer.prototype._shouldRenderMesh = function (mesh) {
  43103. return this.hasMesh(mesh);
  43104. };
  43105. /**
  43106. * Adds specific effects defines.
  43107. * @param defines The defines to add specifics to.
  43108. */
  43109. GlowLayer.prototype._addCustomEffectDefines = function (defines) {
  43110. defines.push("#define GLOW");
  43111. };
  43112. /**
  43113. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  43114. * @param mesh The mesh to exclude from the glow layer
  43115. */
  43116. GlowLayer.prototype.addExcludedMesh = function (mesh) {
  43117. if (this._excludedMeshes.indexOf(mesh.uniqueId) === -1) {
  43118. this._excludedMeshes.push(mesh.uniqueId);
  43119. }
  43120. };
  43121. /**
  43122. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  43123. * @param mesh The mesh to remove
  43124. */
  43125. GlowLayer.prototype.removeExcludedMesh = function (mesh) {
  43126. var index = this._excludedMeshes.indexOf(mesh.uniqueId);
  43127. if (index !== -1) {
  43128. this._excludedMeshes.splice(index, 1);
  43129. }
  43130. };
  43131. /**
  43132. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  43133. * @param mesh The mesh to include in the glow layer
  43134. */
  43135. GlowLayer.prototype.addIncludedOnlyMesh = function (mesh) {
  43136. if (this._includedOnlyMeshes.indexOf(mesh.uniqueId) === -1) {
  43137. this._includedOnlyMeshes.push(mesh.uniqueId);
  43138. }
  43139. };
  43140. /**
  43141. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  43142. * @param mesh The mesh to remove
  43143. */
  43144. GlowLayer.prototype.removeIncludedOnlyMesh = function (mesh) {
  43145. var index = this._includedOnlyMeshes.indexOf(mesh.uniqueId);
  43146. if (index !== -1) {
  43147. this._includedOnlyMeshes.splice(index, 1);
  43148. }
  43149. };
  43150. /**
  43151. * Determine if a given mesh will be used in the glow layer
  43152. * @param mesh The mesh to test
  43153. * @returns true if the mesh will be highlighted by the current glow layer
  43154. */
  43155. GlowLayer.prototype.hasMesh = function (mesh) {
  43156. if (!_super.prototype.hasMesh.call(this, mesh)) {
  43157. return false;
  43158. }
  43159. // Included Mesh
  43160. if (this._includedOnlyMeshes.length) {
  43161. return this._includedOnlyMeshes.indexOf(mesh.uniqueId) !== -1;
  43162. }
  43163. // Excluded Mesh
  43164. if (this._excludedMeshes.length) {
  43165. return this._excludedMeshes.indexOf(mesh.uniqueId) === -1;
  43166. }
  43167. return true;
  43168. };
  43169. /**
  43170. * Free any resources and references associated to a mesh.
  43171. * Internal use
  43172. * @param mesh The mesh to free.
  43173. * @hidden
  43174. */
  43175. GlowLayer.prototype._disposeMesh = function (mesh) {
  43176. this.removeIncludedOnlyMesh(mesh);
  43177. this.removeExcludedMesh(mesh);
  43178. };
  43179. /**
  43180. * Gets the class name of the effect layer
  43181. * @returns the string with the class name of the effect layer
  43182. */
  43183. GlowLayer.prototype.getClassName = function () {
  43184. return "GlowLayer";
  43185. };
  43186. /**
  43187. * Serializes this glow layer
  43188. * @returns a serialized glow layer object
  43189. */
  43190. GlowLayer.prototype.serialize = function () {
  43191. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  43192. serializationObject.customType = "BABYLON.GlowLayer";
  43193. var index;
  43194. // Included meshes
  43195. serializationObject.includedMeshes = [];
  43196. if (this._includedOnlyMeshes.length) {
  43197. for (index = 0; index < this._includedOnlyMeshes.length; index++) {
  43198. var mesh = this._scene.getMeshByUniqueID(this._includedOnlyMeshes[index]);
  43199. if (mesh) {
  43200. serializationObject.includedMeshes.push(mesh.id);
  43201. }
  43202. }
  43203. }
  43204. // Excluded meshes
  43205. serializationObject.excludedMeshes = [];
  43206. if (this._excludedMeshes.length) {
  43207. for (index = 0; index < this._excludedMeshes.length; index++) {
  43208. var mesh = this._scene.getMeshByUniqueID(this._excludedMeshes[index]);
  43209. if (mesh) {
  43210. serializationObject.excludedMeshes.push(mesh.id);
  43211. }
  43212. }
  43213. }
  43214. return serializationObject;
  43215. };
  43216. /**
  43217. * Creates a Glow Layer from parsed glow layer data
  43218. * @param parsedGlowLayer defines glow layer data
  43219. * @param scene defines the current scene
  43220. * @param rootUrl defines the root URL containing the glow layer information
  43221. * @returns a parsed Glow Layer
  43222. */
  43223. GlowLayer.Parse = function (parsedGlowLayer, scene, rootUrl) {
  43224. var gl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new GlowLayer(parsedGlowLayer.name, scene, parsedGlowLayer.options); }, parsedGlowLayer, scene, rootUrl);
  43225. var index;
  43226. // Excluded meshes
  43227. for (index = 0; index < parsedGlowLayer.excludedMeshes.length; index++) {
  43228. var mesh = scene.getMeshByID(parsedGlowLayer.excludedMeshes[index]);
  43229. if (mesh) {
  43230. gl.addExcludedMesh(mesh);
  43231. }
  43232. }
  43233. // Included meshes
  43234. for (index = 0; index < parsedGlowLayer.includedMeshes.length; index++) {
  43235. var mesh = scene.getMeshByID(parsedGlowLayer.includedMeshes[index]);
  43236. if (mesh) {
  43237. gl.addIncludedOnlyMesh(mesh);
  43238. }
  43239. }
  43240. return gl;
  43241. };
  43242. /**
  43243. * Effect Name of the layer.
  43244. */
  43245. GlowLayer.EffectName = "GlowLayer";
  43246. /**
  43247. * The default blur kernel size used for the glow.
  43248. */
  43249. GlowLayer.DefaultBlurKernelSize = 32;
  43250. /**
  43251. * The default texture size ratio used for the glow.
  43252. */
  43253. GlowLayer.DefaultTextureRatio = 0.5;
  43254. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43255. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43256. ], GlowLayer.prototype, "blurKernelSize", null);
  43257. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43258. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43259. ], GlowLayer.prototype, "intensity", null);
  43260. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43261. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  43262. ], GlowLayer.prototype, "_options", void 0);
  43263. return GlowLayer;
  43264. }(_effectLayer__WEBPACK_IMPORTED_MODULE_9__["EffectLayer"]));
  43265. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.GlowLayer"] = GlowLayer;
  43266. /***/ }),
  43267. /***/ "./Layers/highlightLayer.ts":
  43268. /*!**********************************!*\
  43269. !*** ./Layers/highlightLayer.ts ***!
  43270. \**********************************/
  43271. /*! exports provided: HighlightLayer */
  43272. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43273. "use strict";
  43274. __webpack_require__.r(__webpack_exports__);
  43275. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return HighlightLayer; });
  43276. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  43277. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  43278. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  43279. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  43280. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  43281. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  43282. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  43283. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  43284. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  43285. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  43286. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  43287. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  43288. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  43289. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  43290. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43291. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  43292. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  43293. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  43294. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  43295. /* harmony import */ var _Shaders_glowBlurPostProcess_fragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/glowBlurPostProcess.fragment */ "./Shaders/glowBlurPostProcess.fragment.ts");
  43296. _abstractScene__WEBPACK_IMPORTED_MODULE_13__["AbstractScene"].prototype.getHighlightLayerByName = function (name) {
  43297. for (var index = 0; index < this.effectLayers.length; index++) {
  43298. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === HighlightLayer.EffectName) {
  43299. return this.effectLayers[index];
  43300. }
  43301. }
  43302. return null;
  43303. };
  43304. /**
  43305. * Special Glow Blur post process only blurring the alpha channel
  43306. * It enforces keeping the most luminous color in the color channel.
  43307. */
  43308. var GlowBlurPostProcess = /** @class */ (function (_super) {
  43309. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowBlurPostProcess, _super);
  43310. function GlowBlurPostProcess(name, direction, kernel, options, camera, samplingMode, engine, reusable) {
  43311. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE; }
  43312. var _this = _super.call(this, name, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, options, camera, samplingMode, engine, reusable) || this;
  43313. _this.direction = direction;
  43314. _this.kernel = kernel;
  43315. _this.onApplyObservable.add(function (effect) {
  43316. effect.setFloat2("screenSize", _this.width, _this.height);
  43317. effect.setVector2("direction", _this.direction);
  43318. effect.setFloat("blurWidth", _this.kernel);
  43319. });
  43320. return _this;
  43321. }
  43322. return GlowBlurPostProcess;
  43323. }(_PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__["PostProcess"]));
  43324. /**
  43325. * The highlight layer Helps adding a glow effect around a mesh.
  43326. *
  43327. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  43328. * glowy meshes to your scene.
  43329. *
  43330. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  43331. */
  43332. var HighlightLayer = /** @class */ (function (_super) {
  43333. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightLayer, _super);
  43334. /**
  43335. * Instantiates a new highlight Layer and references it to the scene..
  43336. * @param name The name of the layer
  43337. * @param scene The scene to use the layer in
  43338. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  43339. */
  43340. function HighlightLayer(name, scene, options) {
  43341. var _this = _super.call(this, name, scene) || this;
  43342. _this.name = name;
  43343. /**
  43344. * Specifies whether or not the inner glow is ACTIVE in the layer.
  43345. */
  43346. _this.innerGlow = true;
  43347. /**
  43348. * Specifies whether or not the outer glow is ACTIVE in the layer.
  43349. */
  43350. _this.outerGlow = true;
  43351. /**
  43352. * An event triggered when the highlight layer is being blurred.
  43353. */
  43354. _this.onBeforeBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  43355. /**
  43356. * An event triggered when the highlight layer has been blurred.
  43357. */
  43358. _this.onAfterBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  43359. _this._instanceGlowingMeshStencilReference = HighlightLayer.GlowingMeshStencilReference++;
  43360. _this._meshes = {};
  43361. _this._excludedMeshes = {};
  43362. _this.neutralColor = HighlightLayer.NeutralColor;
  43363. // Warn on stencil
  43364. if (!_this._engine.isStencilEnable) {
  43365. _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 }");
  43366. }
  43367. // Adapt options
  43368. _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);
  43369. // Initialize the layer
  43370. _this._init({
  43371. alphaBlendingMode: _this._options.alphaBlendingMode,
  43372. camera: _this._options.camera,
  43373. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  43374. mainTextureRatio: _this._options.mainTextureRatio,
  43375. renderingGroupId: _this._options.renderingGroupId
  43376. });
  43377. // Do not render as long as no meshes have been added
  43378. _this._shouldRender = false;
  43379. return _this;
  43380. }
  43381. Object.defineProperty(HighlightLayer.prototype, "blurHorizontalSize", {
  43382. /**
  43383. * Gets the horizontal size of the blur.
  43384. */
  43385. get: function () {
  43386. return this._horizontalBlurPostprocess.kernel;
  43387. },
  43388. /**
  43389. * Specifies the horizontal size of the blur.
  43390. */
  43391. set: function (value) {
  43392. this._horizontalBlurPostprocess.kernel = value;
  43393. },
  43394. enumerable: true,
  43395. configurable: true
  43396. });
  43397. Object.defineProperty(HighlightLayer.prototype, "blurVerticalSize", {
  43398. /**
  43399. * Gets the vertical size of the blur.
  43400. */
  43401. get: function () {
  43402. return this._verticalBlurPostprocess.kernel;
  43403. },
  43404. /**
  43405. * Specifies the vertical size of the blur.
  43406. */
  43407. set: function (value) {
  43408. this._verticalBlurPostprocess.kernel = value;
  43409. },
  43410. enumerable: true,
  43411. configurable: true
  43412. });
  43413. /**
  43414. * Get the effect name of the layer.
  43415. * @return The effect name
  43416. */
  43417. HighlightLayer.prototype.getEffectName = function () {
  43418. return HighlightLayer.EffectName;
  43419. };
  43420. /**
  43421. * Create the merge effect. This is the shader use to blit the information back
  43422. * to the main canvas at the end of the scene rendering.
  43423. */
  43424. HighlightLayer.prototype._createMergeEffect = function () {
  43425. // Effect
  43426. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? "#define STROKE \n" : undefined);
  43427. };
  43428. /**
  43429. * Creates the render target textures and post processes used in the highlight layer.
  43430. */
  43431. HighlightLayer.prototype._createTextureAndPostProcesses = function () {
  43432. var _this = this;
  43433. var blurTextureWidth = this._mainTextureDesiredSize.width * this._options.blurTextureSizeRatio;
  43434. var blurTextureHeight = this._mainTextureDesiredSize.height * this._options.blurTextureSizeRatio;
  43435. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  43436. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  43437. var textureType = 0;
  43438. if (this._engine.getCaps().textureHalfFloatRender) {
  43439. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_HALF_FLOAT;
  43440. }
  43441. else {
  43442. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  43443. }
  43444. this._blurTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerBlurRTT", {
  43445. width: blurTextureWidth,
  43446. height: blurTextureHeight
  43447. }, this._scene, false, true, textureType);
  43448. this._blurTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  43449. this._blurTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  43450. this._blurTexture.anisotropicFilteringLevel = 16;
  43451. this._blurTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].TRILINEAR_SAMPLINGMODE);
  43452. this._blurTexture.renderParticles = false;
  43453. this._blurTexture.ignoreCameraViewport = true;
  43454. this._textures = [this._blurTexture];
  43455. if (this._options.alphaBlendingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].ALPHA_COMBINE) {
  43456. 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());
  43457. this._downSamplePostprocess.onApplyObservable.add(function (effect) {
  43458. effect.setTexture("textureSampler", _this._mainTexture);
  43459. });
  43460. 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());
  43461. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  43462. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  43463. });
  43464. 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());
  43465. this._verticalBlurPostprocess.onApplyObservable.add(function (effect) {
  43466. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  43467. });
  43468. this._postProcesses = [this._downSamplePostprocess, this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  43469. }
  43470. else {
  43471. 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, {
  43472. width: blurTextureWidth,
  43473. height: blurTextureHeight
  43474. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  43475. this._horizontalBlurPostprocess.width = blurTextureWidth;
  43476. this._horizontalBlurPostprocess.height = blurTextureHeight;
  43477. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  43478. effect.setTexture("textureSampler", _this._mainTexture);
  43479. });
  43480. 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, {
  43481. width: blurTextureWidth,
  43482. height: blurTextureHeight
  43483. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  43484. this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  43485. }
  43486. this._mainTexture.onAfterUnbindObservable.add(function () {
  43487. _this.onBeforeBlurObservable.notifyObservers(_this);
  43488. var internalTexture = _this._blurTexture.getInternalTexture();
  43489. if (internalTexture) {
  43490. _this._scene.postProcessManager.directRender(_this._postProcesses, internalTexture, true);
  43491. }
  43492. _this.onAfterBlurObservable.notifyObservers(_this);
  43493. });
  43494. // Prevent autoClear.
  43495. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  43496. };
  43497. /**
  43498. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  43499. */
  43500. HighlightLayer.prototype.needStencil = function () {
  43501. return true;
  43502. };
  43503. /**
  43504. * Checks for the readiness of the element composing the layer.
  43505. * @param subMesh the mesh to check for
  43506. * @param useInstances specify wether or not to use instances to render the mesh
  43507. * @param emissiveTexture the associated emissive texture used to generate the glow
  43508. * @return true if ready otherwise, false
  43509. */
  43510. HighlightLayer.prototype.isReady = function (subMesh, useInstances) {
  43511. var material = subMesh.getMaterial();
  43512. var mesh = subMesh.getRenderingMesh();
  43513. if (!material || !mesh || !this._meshes) {
  43514. return false;
  43515. }
  43516. var emissiveTexture = null;
  43517. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  43518. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  43519. emissiveTexture = material.emissiveTexture;
  43520. }
  43521. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  43522. };
  43523. /**
  43524. * Implementation specific of rendering the generating effect on the main canvas.
  43525. * @param effect The effect used to render through
  43526. */
  43527. HighlightLayer.prototype._internalRender = function (effect) {
  43528. // Texture
  43529. effect.setTexture("textureSampler", this._blurTexture);
  43530. // Cache
  43531. var engine = this._engine;
  43532. engine.cacheStencilState();
  43533. // Stencil operations
  43534. engine.setStencilOperationPass(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].REPLACE);
  43535. engine.setStencilOperationFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  43536. engine.setStencilOperationDepthFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  43537. // Draw order
  43538. engine.setStencilMask(0x00);
  43539. engine.setStencilBuffer(true);
  43540. engine.setStencilFunctionReference(this._instanceGlowingMeshStencilReference);
  43541. // 2 passes inner outer
  43542. if (this.outerGlow) {
  43543. effect.setFloat("offset", 0);
  43544. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].NOTEQUAL);
  43545. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  43546. }
  43547. if (this.innerGlow) {
  43548. effect.setFloat("offset", 1);
  43549. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].EQUAL);
  43550. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  43551. }
  43552. // Restore Cache
  43553. engine.restoreStencilState();
  43554. };
  43555. /**
  43556. * Returns true if the layer contains information to display, otherwise false.
  43557. */
  43558. HighlightLayer.prototype.shouldRender = function () {
  43559. if (_super.prototype.shouldRender.call(this)) {
  43560. return this._meshes ? true : false;
  43561. }
  43562. return false;
  43563. };
  43564. /**
  43565. * Returns true if the mesh should render, otherwise false.
  43566. * @param mesh The mesh to render
  43567. * @returns true if it should render otherwise false
  43568. */
  43569. HighlightLayer.prototype._shouldRenderMesh = function (mesh) {
  43570. // Excluded Mesh
  43571. if (this._excludedMeshes && this._excludedMeshes[mesh.uniqueId]) {
  43572. return false;
  43573. }
  43574. if (!_super.prototype.hasMesh.call(this, mesh)) {
  43575. return false;
  43576. }
  43577. return true;
  43578. };
  43579. /**
  43580. * Sets the required values for both the emissive texture and and the main color.
  43581. */
  43582. HighlightLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  43583. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  43584. if (highlightLayerMesh) {
  43585. this._emissiveTextureAndColor.color.set(highlightLayerMesh.color.r, highlightLayerMesh.color.g, highlightLayerMesh.color.b, 1.0);
  43586. }
  43587. else {
  43588. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  43589. }
  43590. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  43591. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  43592. this._emissiveTextureAndColor.color.set(1.0, 1.0, 1.0, 1.0);
  43593. }
  43594. else {
  43595. this._emissiveTextureAndColor.texture = null;
  43596. }
  43597. };
  43598. /**
  43599. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  43600. * @param mesh The mesh to exclude from the highlight layer
  43601. */
  43602. HighlightLayer.prototype.addExcludedMesh = function (mesh) {
  43603. if (!this._excludedMeshes) {
  43604. return;
  43605. }
  43606. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  43607. if (!meshExcluded) {
  43608. this._excludedMeshes[mesh.uniqueId] = {
  43609. mesh: mesh,
  43610. beforeBind: mesh.onBeforeBindObservable.add(function (mesh) {
  43611. mesh.getEngine().setStencilBuffer(false);
  43612. }),
  43613. afterRender: mesh.onAfterRenderObservable.add(function (mesh) {
  43614. mesh.getEngine().setStencilBuffer(true);
  43615. }),
  43616. };
  43617. }
  43618. };
  43619. /**
  43620. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  43621. * @param mesh The mesh to highlight
  43622. */
  43623. HighlightLayer.prototype.removeExcludedMesh = function (mesh) {
  43624. if (!this._excludedMeshes) {
  43625. return;
  43626. }
  43627. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  43628. if (meshExcluded) {
  43629. if (meshExcluded.beforeBind) {
  43630. mesh.onBeforeBindObservable.remove(meshExcluded.beforeBind);
  43631. }
  43632. if (meshExcluded.afterRender) {
  43633. mesh.onAfterRenderObservable.remove(meshExcluded.afterRender);
  43634. }
  43635. }
  43636. this._excludedMeshes[mesh.uniqueId] = null;
  43637. };
  43638. /**
  43639. * Determine if a given mesh will be highlighted by the current HighlightLayer
  43640. * @param mesh mesh to test
  43641. * @returns true if the mesh will be highlighted by the current HighlightLayer
  43642. */
  43643. HighlightLayer.prototype.hasMesh = function (mesh) {
  43644. if (!this._meshes) {
  43645. return false;
  43646. }
  43647. if (!_super.prototype.hasMesh.call(this, mesh)) {
  43648. return false;
  43649. }
  43650. return this._meshes[mesh.uniqueId] !== undefined && this._meshes[mesh.uniqueId] !== null;
  43651. };
  43652. /**
  43653. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  43654. * @param mesh The mesh to highlight
  43655. * @param color The color of the highlight
  43656. * @param glowEmissiveOnly Extract the glow from the emissive texture
  43657. */
  43658. HighlightLayer.prototype.addMesh = function (mesh, color, glowEmissiveOnly) {
  43659. var _this = this;
  43660. if (glowEmissiveOnly === void 0) { glowEmissiveOnly = false; }
  43661. if (!this._meshes) {
  43662. return;
  43663. }
  43664. var meshHighlight = this._meshes[mesh.uniqueId];
  43665. if (meshHighlight) {
  43666. meshHighlight.color = color;
  43667. }
  43668. else {
  43669. this._meshes[mesh.uniqueId] = {
  43670. mesh: mesh,
  43671. color: color,
  43672. // Lambda required for capture due to Observable this context
  43673. observerHighlight: mesh.onBeforeBindObservable.add(function (mesh) {
  43674. if (_this._excludedMeshes && _this._excludedMeshes[mesh.uniqueId]) {
  43675. _this._defaultStencilReference(mesh);
  43676. }
  43677. else {
  43678. mesh.getScene().getEngine().setStencilFunctionReference(_this._instanceGlowingMeshStencilReference);
  43679. }
  43680. }),
  43681. observerDefault: mesh.onAfterRenderObservable.add(this._defaultStencilReference),
  43682. glowEmissiveOnly: glowEmissiveOnly
  43683. };
  43684. mesh.onDisposeObservable.add(function () {
  43685. _this._disposeMesh(mesh);
  43686. });
  43687. }
  43688. this._shouldRender = true;
  43689. };
  43690. /**
  43691. * Remove a mesh from the highlight layer in order to make it stop glowing.
  43692. * @param mesh The mesh to highlight
  43693. */
  43694. HighlightLayer.prototype.removeMesh = function (mesh) {
  43695. if (!this._meshes) {
  43696. return;
  43697. }
  43698. var meshHighlight = this._meshes[mesh.uniqueId];
  43699. if (meshHighlight) {
  43700. if (meshHighlight.observerHighlight) {
  43701. mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  43702. }
  43703. if (meshHighlight.observerDefault) {
  43704. mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  43705. }
  43706. delete this._meshes[mesh.uniqueId];
  43707. }
  43708. this._shouldRender = false;
  43709. for (var meshHighlightToCheck in this._meshes) {
  43710. if (this._meshes[meshHighlightToCheck]) {
  43711. this._shouldRender = true;
  43712. break;
  43713. }
  43714. }
  43715. };
  43716. /**
  43717. * Force the stencil to the normal expected value for none glowing parts
  43718. */
  43719. HighlightLayer.prototype._defaultStencilReference = function (mesh) {
  43720. mesh.getScene().getEngine().setStencilFunctionReference(HighlightLayer.NormalMeshStencilReference);
  43721. };
  43722. /**
  43723. * Free any resources and references associated to a mesh.
  43724. * Internal use
  43725. * @param mesh The mesh to free.
  43726. * @hidden
  43727. */
  43728. HighlightLayer.prototype._disposeMesh = function (mesh) {
  43729. this.removeMesh(mesh);
  43730. this.removeExcludedMesh(mesh);
  43731. };
  43732. /**
  43733. * Dispose the highlight layer and free resources.
  43734. */
  43735. HighlightLayer.prototype.dispose = function () {
  43736. if (this._meshes) {
  43737. // Clean mesh references
  43738. for (var id in this._meshes) {
  43739. var meshHighlight = this._meshes[id];
  43740. if (meshHighlight && meshHighlight.mesh) {
  43741. if (meshHighlight.observerHighlight) {
  43742. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  43743. }
  43744. if (meshHighlight.observerDefault) {
  43745. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  43746. }
  43747. }
  43748. }
  43749. this._meshes = null;
  43750. }
  43751. if (this._excludedMeshes) {
  43752. for (var id in this._excludedMeshes) {
  43753. var meshHighlight = this._excludedMeshes[id];
  43754. if (meshHighlight) {
  43755. if (meshHighlight.beforeBind) {
  43756. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.beforeBind);
  43757. }
  43758. if (meshHighlight.afterRender) {
  43759. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.afterRender);
  43760. }
  43761. }
  43762. }
  43763. this._excludedMeshes = null;
  43764. }
  43765. _super.prototype.dispose.call(this);
  43766. };
  43767. /**
  43768. * Gets the class name of the effect layer
  43769. * @returns the string with the class name of the effect layer
  43770. */
  43771. HighlightLayer.prototype.getClassName = function () {
  43772. return "HighlightLayer";
  43773. };
  43774. /**
  43775. * Serializes this Highlight layer
  43776. * @returns a serialized Highlight layer object
  43777. */
  43778. HighlightLayer.prototype.serialize = function () {
  43779. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  43780. serializationObject.customType = "BABYLON.HighlightLayer";
  43781. // Highlighted meshes
  43782. serializationObject.meshes = [];
  43783. if (this._meshes) {
  43784. for (var m in this._meshes) {
  43785. var mesh = this._meshes[m];
  43786. if (mesh) {
  43787. serializationObject.meshes.push({
  43788. glowEmissiveOnly: mesh.glowEmissiveOnly,
  43789. color: mesh.color.asArray(),
  43790. meshId: mesh.mesh.id
  43791. });
  43792. }
  43793. }
  43794. }
  43795. // Excluded meshes
  43796. serializationObject.excludedMeshes = [];
  43797. if (this._excludedMeshes) {
  43798. for (var e in this._excludedMeshes) {
  43799. var excludedMesh = this._excludedMeshes[e];
  43800. if (excludedMesh) {
  43801. serializationObject.excludedMeshes.push(excludedMesh.mesh.id);
  43802. }
  43803. }
  43804. }
  43805. return serializationObject;
  43806. };
  43807. /**
  43808. * Creates a Highlight layer from parsed Highlight layer data
  43809. * @param parsedHightlightLayer defines the Highlight layer data
  43810. * @param scene defines the current scene
  43811. * @param rootUrl defines the root URL containing the Highlight layer information
  43812. * @returns a parsed Highlight layer
  43813. */
  43814. HighlightLayer.Parse = function (parsedHightlightLayer, scene, rootUrl) {
  43815. var hl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new HighlightLayer(parsedHightlightLayer.name, scene, parsedHightlightLayer.options); }, parsedHightlightLayer, scene, rootUrl);
  43816. var index;
  43817. // Excluded meshes
  43818. for (index = 0; index < parsedHightlightLayer.excludedMeshes.length; index++) {
  43819. var mesh = scene.getMeshByID(parsedHightlightLayer.excludedMeshes[index]);
  43820. if (mesh) {
  43821. hl.addExcludedMesh(mesh);
  43822. }
  43823. }
  43824. // Included meshes
  43825. for (index = 0; index < parsedHightlightLayer.meshes.length; index++) {
  43826. var highlightedMesh = parsedHightlightLayer.meshes[index];
  43827. var mesh = scene.getMeshByID(highlightedMesh.meshId);
  43828. if (mesh) {
  43829. hl.addMesh(mesh, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromArray(highlightedMesh.color), highlightedMesh.glowEmissiveOnly);
  43830. }
  43831. }
  43832. return hl;
  43833. };
  43834. /**
  43835. * Effect Name of the highlight layer.
  43836. */
  43837. HighlightLayer.EffectName = "HighlightLayer";
  43838. /**
  43839. * The neutral color used during the preparation of the glow effect.
  43840. * This is black by default as the blend operation is a blend operation.
  43841. */
  43842. HighlightLayer.NeutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  43843. /**
  43844. * Stencil value used for glowing meshes.
  43845. */
  43846. HighlightLayer.GlowingMeshStencilReference = 0x02;
  43847. /**
  43848. * Stencil value used for the other meshes in the scene.
  43849. */
  43850. HighlightLayer.NormalMeshStencilReference = 0x01;
  43851. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43852. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43853. ], HighlightLayer.prototype, "innerGlow", void 0);
  43854. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43855. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43856. ], HighlightLayer.prototype, "outerGlow", void 0);
  43857. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43858. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43859. ], HighlightLayer.prototype, "blurHorizontalSize", null);
  43860. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43861. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43862. ], HighlightLayer.prototype, "blurVerticalSize", null);
  43863. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43864. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  43865. ], HighlightLayer.prototype, "_options", void 0);
  43866. return HighlightLayer;
  43867. }(_effectLayer__WEBPACK_IMPORTED_MODULE_12__["EffectLayer"]));
  43868. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__["_TypeStore"].RegisteredTypes["BABYLON.HighlightLayer"] = HighlightLayer;
  43869. /***/ }),
  43870. /***/ "./Layers/index.ts":
  43871. /*!*************************!*\
  43872. !*** ./Layers/index.ts ***!
  43873. \*************************/
  43874. /*! exports provided: EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent */
  43875. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43876. "use strict";
  43877. __webpack_require__.r(__webpack_exports__);
  43878. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  43879. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _effectLayer__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  43880. /* harmony import */ var _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  43881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__["EffectLayerSceneComponent"]; });
  43882. /* harmony import */ var _glowLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glowLayer */ "./Layers/glowLayer.ts");
  43883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _glowLayer__WEBPACK_IMPORTED_MODULE_2__["GlowLayer"]; });
  43884. /* harmony import */ var _highlightLayer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./highlightLayer */ "./Layers/highlightLayer.ts");
  43885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _highlightLayer__WEBPACK_IMPORTED_MODULE_3__["HighlightLayer"]; });
  43886. /* harmony import */ var _layer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./layer */ "./Layers/layer.ts");
  43887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _layer__WEBPACK_IMPORTED_MODULE_4__["Layer"]; });
  43888. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  43889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__["LayerSceneComponent"]; });
  43890. /***/ }),
  43891. /***/ "./Layers/layer.ts":
  43892. /*!*************************!*\
  43893. !*** ./Layers/layer.ts ***!
  43894. \*************************/
  43895. /*! exports provided: Layer */
  43896. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43897. "use strict";
  43898. __webpack_require__.r(__webpack_exports__);
  43899. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return Layer; });
  43900. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  43901. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  43902. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  43903. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  43904. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  43905. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  43906. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  43907. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  43908. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43909. /* harmony import */ var _Shaders_layer_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/layer.fragment */ "./Shaders/layer.fragment.ts");
  43910. /* harmony import */ var _Shaders_layer_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/layer.vertex */ "./Shaders/layer.vertex.ts");
  43911. /**
  43912. * This represents a full screen 2d layer.
  43913. * This can be useful to display a picture in the background of your scene for instance.
  43914. * @see https://www.babylonjs-playground.com/#08A2BS#1
  43915. */
  43916. var Layer = /** @class */ (function () {
  43917. /**
  43918. * Instantiates a new layer.
  43919. * This represents a full screen 2d layer.
  43920. * This can be useful to display a picture in the background of your scene for instance.
  43921. * @see https://www.babylonjs-playground.com/#08A2BS#1
  43922. * @param name Define the name of the layer in the scene
  43923. * @param imgUrl Define the url of the texture to display in the layer
  43924. * @param scene Define the scene the layer belongs to
  43925. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  43926. * @param color Defines a color for the layer
  43927. */
  43928. function Layer(
  43929. /**
  43930. * Define the name of the layer.
  43931. */
  43932. name, imgUrl, scene, isBackground, color) {
  43933. this.name = name;
  43934. /**
  43935. * Define the scale of the layer in order to zoom in out of the texture.
  43936. */
  43937. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1, 1);
  43938. /**
  43939. * Define an offset for the layer in order to shift the texture.
  43940. */
  43941. this.offset = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 0);
  43942. /**
  43943. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  43944. */
  43945. this.alphaBlendingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  43946. /**
  43947. * Define a mask to restrict the layer to only some of the scene cameras.
  43948. */
  43949. this.layerMask = 0x0FFFFFFF;
  43950. /**
  43951. * Define the list of render target the layer is visible into.
  43952. */
  43953. this.renderTargetTextures = [];
  43954. /**
  43955. * Define if the layer is only used in renderTarget or if it also
  43956. * renders in the main frame buffer of the canvas.
  43957. */
  43958. this.renderOnlyInRenderTargetTextures = false;
  43959. this._vertexBuffers = {};
  43960. /**
  43961. * An event triggered when the layer is disposed.
  43962. */
  43963. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  43964. /**
  43965. * An event triggered before rendering the scene
  43966. */
  43967. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  43968. /**
  43969. * An event triggered after rendering the scene
  43970. */
  43971. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  43972. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"](imgUrl, scene, true) : null;
  43973. this.isBackground = isBackground === undefined ? true : isBackground;
  43974. this.color = color === undefined ? new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1, 1, 1, 1) : color;
  43975. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene);
  43976. var layerComponent = this._scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_LAYER);
  43977. if (!layerComponent) {
  43978. layerComponent = new _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__["LayerSceneComponent"](this._scene);
  43979. this._scene._addComponent(layerComponent);
  43980. }
  43981. this._scene.layers.push(this);
  43982. var engine = this._scene.getEngine();
  43983. // VBO
  43984. var vertices = [];
  43985. vertices.push(1, 1);
  43986. vertices.push(-1, 1);
  43987. vertices.push(-1, -1);
  43988. vertices.push(1, -1);
  43989. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"](engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, false, false, 2);
  43990. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = vertexBuffer;
  43991. this._createIndexBuffer();
  43992. // Effects
  43993. this._effect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "");
  43994. this._alphaTestEffect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "#define ALPHATEST");
  43995. }
  43996. Object.defineProperty(Layer.prototype, "onDispose", {
  43997. /**
  43998. * Back compatibility with callback before the onDisposeObservable existed.
  43999. * The set callback will be triggered when the layer has been disposed.
  44000. */
  44001. set: function (callback) {
  44002. if (this._onDisposeObserver) {
  44003. this.onDisposeObservable.remove(this._onDisposeObserver);
  44004. }
  44005. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  44006. },
  44007. enumerable: true,
  44008. configurable: true
  44009. });
  44010. Object.defineProperty(Layer.prototype, "onBeforeRender", {
  44011. /**
  44012. * Back compatibility with callback before the onBeforeRenderObservable existed.
  44013. * The set callback will be triggered just before rendering the layer.
  44014. */
  44015. set: function (callback) {
  44016. if (this._onBeforeRenderObserver) {
  44017. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  44018. }
  44019. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  44020. },
  44021. enumerable: true,
  44022. configurable: true
  44023. });
  44024. Object.defineProperty(Layer.prototype, "onAfterRender", {
  44025. /**
  44026. * Back compatibility with callback before the onAfterRenderObservable existed.
  44027. * The set callback will be triggered just after rendering the layer.
  44028. */
  44029. set: function (callback) {
  44030. if (this._onAfterRenderObserver) {
  44031. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  44032. }
  44033. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  44034. },
  44035. enumerable: true,
  44036. configurable: true
  44037. });
  44038. Layer.prototype._createIndexBuffer = function () {
  44039. var engine = this._scene.getEngine();
  44040. // Indices
  44041. var indices = [];
  44042. indices.push(0);
  44043. indices.push(1);
  44044. indices.push(2);
  44045. indices.push(0);
  44046. indices.push(2);
  44047. indices.push(3);
  44048. this._indexBuffer = engine.createIndexBuffer(indices);
  44049. };
  44050. /** @hidden */
  44051. Layer.prototype._rebuild = function () {
  44052. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  44053. if (vb) {
  44054. vb._rebuild();
  44055. }
  44056. this._createIndexBuffer();
  44057. };
  44058. /**
  44059. * Renders the layer in the scene.
  44060. */
  44061. Layer.prototype.render = function () {
  44062. var currentEffect = this.alphaTest ? this._alphaTestEffect : this._effect;
  44063. // Check
  44064. if (!currentEffect.isReady() || !this.texture || !this.texture.isReady()) {
  44065. return;
  44066. }
  44067. var engine = this._scene.getEngine();
  44068. this.onBeforeRenderObservable.notifyObservers(this);
  44069. // Render
  44070. engine.enableEffect(currentEffect);
  44071. engine.setState(false);
  44072. // Texture
  44073. currentEffect.setTexture("textureSampler", this.texture);
  44074. currentEffect.setMatrix("textureMatrix", this.texture.getTextureMatrix());
  44075. // Color
  44076. currentEffect.setFloat4("color", this.color.r, this.color.g, this.color.b, this.color.a);
  44077. // Scale / offset
  44078. currentEffect.setVector2("offset", this.offset);
  44079. currentEffect.setVector2("scale", this.scale);
  44080. // VBOs
  44081. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  44082. // Draw order
  44083. if (!this.alphaTest) {
  44084. engine.setAlphaMode(this.alphaBlendingMode);
  44085. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  44086. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  44087. }
  44088. else {
  44089. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  44090. }
  44091. this.onAfterRenderObservable.notifyObservers(this);
  44092. };
  44093. /**
  44094. * Disposes and releases the associated ressources.
  44095. */
  44096. Layer.prototype.dispose = function () {
  44097. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  44098. if (vertexBuffer) {
  44099. vertexBuffer.dispose();
  44100. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  44101. }
  44102. if (this._indexBuffer) {
  44103. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  44104. this._indexBuffer = null;
  44105. }
  44106. if (this.texture) {
  44107. this.texture.dispose();
  44108. this.texture = null;
  44109. }
  44110. // Clean RTT list
  44111. this.renderTargetTextures = [];
  44112. // Remove from scene
  44113. var index = this._scene.layers.indexOf(this);
  44114. this._scene.layers.splice(index, 1);
  44115. // Callback
  44116. this.onDisposeObservable.notifyObservers(this);
  44117. this.onDisposeObservable.clear();
  44118. this.onAfterRenderObservable.clear();
  44119. this.onBeforeRenderObservable.clear();
  44120. };
  44121. return Layer;
  44122. }());
  44123. /***/ }),
  44124. /***/ "./Layers/layerSceneComponent.ts":
  44125. /*!***************************************!*\
  44126. !*** ./Layers/layerSceneComponent.ts ***!
  44127. \***************************************/
  44128. /*! exports provided: LayerSceneComponent */
  44129. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44130. "use strict";
  44131. __webpack_require__.r(__webpack_exports__);
  44132. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return LayerSceneComponent; });
  44133. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  44134. /**
  44135. * Defines the layer scene component responsible to manage any layers
  44136. * in a given scene.
  44137. */
  44138. var LayerSceneComponent = /** @class */ (function () {
  44139. /**
  44140. * Creates a new instance of the component for the given scene
  44141. * @param scene Defines the scene to register the component in
  44142. */
  44143. function LayerSceneComponent(scene) {
  44144. /**
  44145. * The component name helpfull to identify the component in the list of scene components.
  44146. */
  44147. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_LAYER;
  44148. this.scene = scene;
  44149. this._engine = scene.getEngine();
  44150. scene.layers = new Array();
  44151. }
  44152. /**
  44153. * Registers the component in a given scene
  44154. */
  44155. LayerSceneComponent.prototype.register = function () {
  44156. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_LAYER, this, this._drawCameraBackground);
  44157. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LAYER, this, this._drawCameraForeground);
  44158. this.scene._beforeRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORERENDERTARGETDRAW_LAYER, this, this._drawRenderTargetBackground);
  44159. this.scene._afterRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERRENDERTARGETDRAW_LAYER, this, this._drawRenderTargetForeground);
  44160. };
  44161. /**
  44162. * Rebuilds the elements related to this component in case of
  44163. * context lost for instance.
  44164. */
  44165. LayerSceneComponent.prototype.rebuild = function () {
  44166. var layers = this.scene.layers;
  44167. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  44168. var layer = layers_1[_i];
  44169. layer._rebuild();
  44170. }
  44171. };
  44172. /**
  44173. * Disposes the component and the associated ressources.
  44174. */
  44175. LayerSceneComponent.prototype.dispose = function () {
  44176. var layers = this.scene.layers;
  44177. while (layers.length) {
  44178. layers[0].dispose();
  44179. }
  44180. };
  44181. LayerSceneComponent.prototype._draw = function (predicate) {
  44182. var layers = this.scene.layers;
  44183. if (layers.length) {
  44184. this._engine.setDepthBuffer(false);
  44185. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  44186. var layer = layers_2[_i];
  44187. if (predicate(layer)) {
  44188. layer.render();
  44189. }
  44190. }
  44191. this._engine.setDepthBuffer(true);
  44192. }
  44193. };
  44194. LayerSceneComponent.prototype._drawCameraPredicate = function (layer, isBackground, cameraLayerMask) {
  44195. return !layer.renderOnlyInRenderTargetTextures &&
  44196. layer.isBackground === isBackground &&
  44197. ((layer.layerMask & cameraLayerMask) !== 0);
  44198. };
  44199. LayerSceneComponent.prototype._drawCameraBackground = function (camera) {
  44200. var _this = this;
  44201. this._draw(function (layer) {
  44202. return _this._drawCameraPredicate(layer, true, camera.layerMask);
  44203. });
  44204. };
  44205. LayerSceneComponent.prototype._drawCameraForeground = function (camera) {
  44206. var _this = this;
  44207. this._draw(function (layer) {
  44208. return _this._drawCameraPredicate(layer, false, camera.layerMask);
  44209. });
  44210. };
  44211. LayerSceneComponent.prototype._drawRenderTargetPredicate = function (layer, isBackground, cameraLayerMask, renderTargetTexture) {
  44212. return (layer.renderTargetTextures.length > 0) &&
  44213. layer.isBackground === isBackground &&
  44214. (layer.renderTargetTextures.indexOf(renderTargetTexture) > -1) &&
  44215. ((layer.layerMask & cameraLayerMask) !== 0);
  44216. };
  44217. LayerSceneComponent.prototype._drawRenderTargetBackground = function (renderTarget) {
  44218. var _this = this;
  44219. this._draw(function (layer) {
  44220. return _this._drawRenderTargetPredicate(layer, true, _this.scene.activeCamera.layerMask, renderTarget);
  44221. });
  44222. };
  44223. LayerSceneComponent.prototype._drawRenderTargetForeground = function (renderTarget) {
  44224. var _this = this;
  44225. this._draw(function (layer) {
  44226. return _this._drawRenderTargetPredicate(layer, false, _this.scene.activeCamera.layerMask, renderTarget);
  44227. });
  44228. };
  44229. return LayerSceneComponent;
  44230. }());
  44231. /***/ }),
  44232. /***/ "./Legacy/legacy.ts":
  44233. /*!**************************!*\
  44234. !*** ./Legacy/legacy.ts ***!
  44235. \**************************/
  44236. /*! exports provided: Debug, AbstractScene, KeepAssets, AssetContainer, Node, Scene, SceneComponentConstants, Stage, Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction, Animatable, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange, Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound, Bone, BoneIKController, BoneLookController, Skeleton, CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, EquiRectangularCubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, TrailMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, BoxBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, MorphTarget, MorphTargetManager, Database, BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEventOptions, PhysicsUpdraftEventOptions, PhysicsVortexEventOptions, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, AnaglyphPostProcess, BlackAndWhitePostProcess, BloomEffect, BloomMergePostProcess, BlurPostProcess, ChromaticAberrationPostProcess, CircleOfConfusionPostProcess, ColorCorrectionPostProcess, ConvolutionPostProcess, DepthOfFieldBlurPostProcess, DepthOfFieldEffectBlurLevel, DepthOfFieldEffect, DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess, DisplayPassPostProcess, ExtractHighlightsPostProcess, FilterPostProcess, FxaaPostProcess, GrainPostProcess, HighlightsPostProcess, ImageProcessingPostProcess, MotionBlurPostProcess, PassPostProcess, PassCubePostProcess, PostProcess, PostProcessManager, RefractionPostProcess, SharpenPostProcess, StereoscopicInterlacePostProcess, TonemappingOperator, TonemapPostProcess, VolumetricLightScatteringPostProcess, VRDistortionCorrectionPostProcess, VRMultiviewToSingleviewPostProcess, ReflectionProbe, BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer, Sprite, SpriteManager, SpriteSceneComponent, _AlphaState, _DepthCullingState, _StencilState, AndOrNotEvaluator, AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, EquiRectangularCubeTextureAssetTask, AssetsManager, DDSTools, expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsMatrix, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, MeshExploder, FilesInput, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, WebRequest, InspectableType, AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRMaterialDefines, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, DracoCompression, DiscBuilder, RibbonBuilder, HemisphereBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  44237. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44238. "use strict";
  44239. __webpack_require__.r(__webpack_exports__);
  44240. /* WEBPACK VAR INJECTION */(function(global) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Debug", function() { return Debug; });
  44241. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  44242. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/index */ "./Debug/index.ts");
  44243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  44244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeepAssets"]; });
  44245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetContainer"]; });
  44246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Node"]; });
  44247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scene"]; });
  44248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"]; });
  44249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Stage"]; });
  44250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  44251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionEvent"]; });
  44252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionManager"]; });
  44253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Condition"]; });
  44254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueCondition"]; });
  44255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PredicateCondition"]; });
  44256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StateCondition"]; });
  44257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SwitchBooleanAction"]; });
  44258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetStateAction"]; });
  44259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetValueAction"]; });
  44260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IncrementValueAction"]; });
  44261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlayAnimationAction"]; });
  44262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopAnimationAction"]; });
  44263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DoNothingAction"]; });
  44264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CombineAction"]; });
  44265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExecuteCodeAction"]; });
  44266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetParentAction"]; });
  44267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaySoundAction"]; });
  44268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopSoundAction"]; });
  44269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InterpolateValueAction"]; });
  44270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  44271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animation"]; });
  44272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetedAnimation"]; });
  44273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationGroup"]; });
  44274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationPropertiesOverride"]; });
  44275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"]; });
  44276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleEase"]; });
  44277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackEase"]; });
  44278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BounceEase"]; });
  44279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubicEase"]; });
  44280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ElasticEase"]; });
  44281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]; });
  44282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PowerEase"]; });
  44283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuadraticEase"]; });
  44284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuarticEase"]; });
  44285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuinticEase"]; });
  44286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SineEase"]; });
  44287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurveEase"]; });
  44288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RuntimeAnimation"]; });
  44289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationEvent"]; });
  44290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationKeyInterpolation"]; });
  44291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationRange"]; });
  44292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  44293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioEngine"]; });
  44294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioSceneComponent"]; });
  44295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sound"]; });
  44296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SoundTrack"]; });
  44297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WeightedSound"]; });
  44298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  44299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneIKController"]; });
  44300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneLookController"]; });
  44301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Skeleton"]; });
  44302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]; });
  44303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputsManager"]; });
  44304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Camera"]; });
  44305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetCamera"]; });
  44306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCamera"]; });
  44307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraInputsManager"]; });
  44308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TouchCamera"]; });
  44309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCamera"]; });
  44310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraInputsManager"]; });
  44311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeviceOrientationCamera"]; });
  44312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCamera"]; });
  44313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraInputsManager"]; });
  44314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCamera"]; });
  44315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcFollowCamera"]; });
  44316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadCamera"]; });
  44317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniversalCamera"]; });
  44318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoysticksCamera"]; });
  44319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  44320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultCollisionCoordinator"]; });
  44321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PickingInfo"]; });
  44322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IntersectionInfo"]; });
  44323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  44324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingInfo"]; });
  44325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingSphere"]; });
  44326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ray"]; });
  44327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  44328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneAxesViewer"]; });
  44329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DebugLayer"]; });
  44330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsViewer"]; });
  44331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RayHelper"]; });
  44332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SkeletonViewer"]; });
  44333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  44334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancingAttributeInfo"]; });
  44335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthTextureCreationOptions"]; });
  44336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineCapabilities"]; });
  44337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Engine"]; });
  44338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineStore"]; });
  44339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngineOptions"]; });
  44340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngine"]; });
  44341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  44342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  44343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  44344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"]; });
  44345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoBase"]; });
  44346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoPre"]; });
  44347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"]; });
  44348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardEventTypes"]; });
  44349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardInfo"]; });
  44350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  44351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  44352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  44353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  44354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  44355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  44356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  44357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  44358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  44359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  44360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StickValues"]; });
  44361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gamepad"]; });
  44362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericPad"]; });
  44363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadManager"]; });
  44364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadSystemSceneComponent"]; });
  44365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Button"]; });
  44366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Dpad"]; });
  44367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Pad"]; });
  44368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  44369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisScaleGizmo"]; });
  44370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxGizmo"]; });
  44371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gizmo"]; });
  44372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GizmoManager"]; });
  44373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneRotationGizmo"]; });
  44374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionGizmo"]; });
  44375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RotationGizmo"]; });
  44376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScaleGizmo"]; });
  44377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LightGizmo"]; });
  44378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  44379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhotoDome"]; });
  44380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceSceneHelpersToBundle"]; });
  44381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoDome"]; });
  44382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  44383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneInstrumentation"]; });
  44384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TimeToken"]; });
  44385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  44386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayerSceneComponent"]; });
  44387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GlowLayer"]; });
  44388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightLayer"]; });
  44389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Layer"]; });
  44390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LayerSceneComponent"]; });
  44391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  44392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystem"]; });
  44393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystemSceneComponent"]; });
  44394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  44395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowLight"]; });
  44396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DirectionalLight"]; });
  44397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]; });
  44398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointLight"]; });
  44399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpotLight"]; });
  44400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  44401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderProgressEvent"]; });
  44402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"]; });
  44403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderFlags"]; });
  44404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCurves"]; });
  44405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectFallbacks"]; });
  44406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectCreationOptions"]; });
  44407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Effect"]; });
  44408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FresnelParameters"]; });
  44409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfigurationDefines"]; });
  44410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfiguration"]; });
  44411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Material"]; });
  44412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialDefines"]; });
  44413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialHelper"]; });
  44414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiMaterial"]; });
  44415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PushMaterial"]; });
  44416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShaderMaterial"]; });
  44417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterialDefines"]; });
  44418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterial"]; });
  44419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  44420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTexture"]; });
  44421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EquiRectangularCubeTexture"]; });
  44422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTexture"]; });
  44423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InternalTexture"]; });
  44424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DummyInternalTextureTracker"]; });
  44425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MirrorTexture"]; });
  44426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiRenderTarget"]; });
  44427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture"]; });
  44428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetTexture"]; });
  44429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Texture"]; });
  44430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniformBuffer"]; });
  44431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialFlags"]; });
  44432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  44433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToGammaSpace"]; });
  44434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]; });
  44435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; });
  44436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3"]; });
  44437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color4"]; });
  44438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2"]; });
  44439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3"]; });
  44440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector4"]; });
  44441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Size"]; });
  44442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]; });
  44443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix"]; });
  44444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Plane"]; });
  44445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Viewport"]; });
  44446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Frustum"]; });
  44447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Space"]; });
  44448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Axis"]; });
  44449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurve"]; });
  44450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Orientation"]; });
  44451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Angle"]; });
  44452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Arc2"]; });
  44453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path2"]; });
  44454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path3D"]; });
  44455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Curve3"]; });
  44456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]; });
  44457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalTextureVertex"]; });
  44458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tmp"]; });
  44459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]; });
  44460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalHarmonics"]; });
  44461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  44462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Buffer"]; });
  44463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"]; });
  44464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CSG"]; });
  44465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Geometry"]; });
  44466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundMesh"]; });
  44467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TrailMesh"]; });
  44468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedMesh"]; });
  44469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesMesh"]; });
  44470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedLinesMesh"]; });
  44471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshLODLevel"]; });
  44472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_CreationDataStorage"]; });
  44473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_InstancesBatch"]; });
  44474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Mesh"]; });
  44475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexData"]; });
  44476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshBuilder"]; });
  44477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationSettings"]; });
  44478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationQueue"]; });
  44479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationType"]; });
  44480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplicationQueueSceneComponent"]; });
  44481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Polygon"]; });
  44482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonMeshBuilder"]; });
  44483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSubMesh"]; });
  44484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubMesh"]; });
  44485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TransformNode"]; });
  44486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  44487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereBuilder"]; });
  44488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderBuilder"]; });
  44489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesBuilder"]; });
  44490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneBuilder"]; });
  44491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  44492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTargetManager"]; });
  44493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  44494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  44495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GPUParticleSystem"]; });
  44496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Particle"]; });
  44497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleHelper"]; });
  44498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystem"]; });
  44499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_IDoNeedToBeInTheBuild"]; });
  44500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystemSet"]; });
  44501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticle"]; });
  44502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ModelShape"]; });
  44503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthSortedParticle"]; });
  44504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticleSystem"]; });
  44505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitterType"]; });
  44506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitter"]; });
  44507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  44508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngineSceneComponent"]; });
  44509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsHelper"]; });
  44510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialExplosionEventOptions"]; });
  44511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftEventOptions"]; });
  44512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsVortexEventOptions"]; });
  44513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialImpulseFalloff"]; });
  44514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftMode"]; });
  44515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"]; });
  44516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsJoint"]; });
  44517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DistanceJoint"]; });
  44518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotorEnabledJoint"]; });
  44519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HingeJoint"]; });
  44520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Hinge2Joint"]; });
  44521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  44522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlackAndWhitePostProcess"]; });
  44523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomEffect"]; });
  44524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomMergePostProcess"]; });
  44525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlurPostProcess"]; });
  44526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ChromaticAberrationPostProcess"]; });
  44527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleOfConfusionPostProcess"]; });
  44528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCorrectionPostProcess"]; });
  44529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConvolutionPostProcess"]; });
  44530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldBlurPostProcess"]; });
  44531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffectBlurLevel"]; });
  44532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffect"]; });
  44533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcessOptions"]; });
  44534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcess"]; });
  44535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayPassPostProcess"]; });
  44536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExtractHighlightsPostProcess"]; });
  44537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilterPostProcess"]; });
  44538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FxaaPostProcess"]; });
  44539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GrainPostProcess"]; });
  44540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightsPostProcess"]; });
  44541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingPostProcess"]; });
  44542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotionBlurPostProcess"]; });
  44543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassPostProcess"]; });
  44544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassCubePostProcess"]; });
  44545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcess"]; });
  44546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessManager"]; });
  44547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionPostProcess"]; });
  44548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SharpenPostProcess"]; });
  44549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicInterlacePostProcess"]; });
  44550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemappingOperator"]; });
  44551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemapPostProcess"]; });
  44552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumetricLightScatteringPostProcess"]; });
  44553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDistortionCorrectionPostProcess"]; });
  44554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleviewPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRMultiviewToSingleviewPostProcess"]; });
  44555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  44556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  44557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRenderer"]; });
  44558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRendererSceneComponent"]; });
  44559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EdgesRenderer"]; });
  44560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LineEdgesRenderer"]; });
  44561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRenderer"]; });
  44562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRendererSceneComponent"]; });
  44563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OutlineRenderer"]; });
  44564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"]; });
  44565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroupInfo"]; });
  44566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingManager"]; });
  44567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"]; });
  44568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  44569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteManager"]; });
  44570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteSceneComponent"]; });
  44571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  44572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DepthCullingState"]; });
  44573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_StencilState"]; });
  44574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  44575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetTaskState"]; });
  44576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractAssetTask"]; });
  44577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsProgressEvent"]; });
  44578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshAssetTask"]; });
  44579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextFileAssetTask"]; });
  44580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BinaryFileAssetTask"]; });
  44581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageAssetTask"]; });
  44582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureAssetTask"]; });
  44583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTextureAssetTask"]; });
  44584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTextureAssetTask"]; });
  44585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EquiRectangularCubeTextureAssetTask"]; });
  44586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsManager"]; });
  44587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DDSTools"]; });
  44588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["expandToProperty"]; });
  44589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serialize"]; });
  44590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsTexture"]; });
  44591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor3"]; });
  44592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsFresnelParameters"]; });
  44593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector2"]; });
  44594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector3"]; });
  44595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsMeshReference"]; });
  44596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColorCurves"]; });
  44597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor4"]; });
  44598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsImageProcessingConfiguration"]; });
  44599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsQuaternion"]; });
  44600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsMatrix"]; });
  44601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsCameraReference"]; });
  44602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SerializationHelper"]; });
  44603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Deferred"]; });
  44604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"]; });
  44605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshExploder"]; });
  44606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInput"]; });
  44607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"]; });
  44608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EventState"]; });
  44609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observer"]; });
  44610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiObserver"]; });
  44611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observable"]; });
  44612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerformanceMonitor"]; });
  44613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RollingAverage"]; });
  44614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PromisePolyfill"]; });
  44615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimization"]; });
  44616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureOptimization"]; });
  44617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HardwareScalingOptimization"]; });
  44618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowsOptimization"]; });
  44619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessesOptimization"]; });
  44620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlaresOptimization"]; });
  44621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomOptimization"]; });
  44622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticlesOptimization"]; });
  44623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetsOptimization"]; });
  44624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MergeMeshesOptimization"]; });
  44625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizerOptions"]; });
  44626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizer"]; });
  44627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneSerializer"]; });
  44628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArray"]; });
  44629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"]; });
  44630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StringDictionary"]; });
  44631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tags"]; });
  44632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureTools"]; });
  44633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TGATools"]; });
  44634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradient"]; });
  44635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3Gradient"]; });
  44636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FactorGradient"]; });
  44637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LoadFileError"]; });
  44638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RetryStrategy"]; });
  44639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tools"]; });
  44640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]; });
  44641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["className"]; });
  44642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AsyncLoop"]; });
  44643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoRecorder"]; });
  44644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"]; });
  44645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"]; });
  44646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WorkerPool"]; });
  44647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Logger"]; });
  44648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"]; });
  44649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInputStore"]; });
  44650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"]; });
  44651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PivotTools"]; });
  44652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"]; });
  44653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScreenshotTools"]; });
  44654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebRequest"]; });
  44655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InspectableType"]; });
  44656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  44657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  44658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  44659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  44660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FadeInOutBehavior"]; });
  44661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiPointerScaleBehavior"]; });
  44662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]; });
  44663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SixDofDragBehavior"]; });
  44664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  44665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  44666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  44667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  44668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  44669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  44670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  44671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraKeyboardMoveInput"]; });
  44672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraMouseWheelInput"]; });
  44673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraPointersInput"]; });
  44674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  44675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  44676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  44677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  44678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  44679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  44680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  44681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphFreeCamera"]; });
  44682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphGamepadCamera"]; });
  44683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphUniversalCamera"]; });
  44684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicArcRotateCamera"]; });
  44685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicFreeCamera"]; });
  44686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicGamepadCamera"]; });
  44687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicUniversalCamera"]; });
  44688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  44689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationArcRotateCamera"]; });
  44690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationFreeCamera"]; });
  44691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationGamepadCamera"]; });
  44692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OnAfterEnteringVRObservableEvent"]; });
  44693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRExperienceHelper"]; });
  44694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRFreeCamera"]; });
  44695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  44696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIButton"]; });
  44697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIOptions"]; });
  44698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUI"]; });
  44699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRState"]; });
  44700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRExperienceHelper"]; });
  44701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRController"]; });
  44702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRInput"]; });
  44703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRManagedOutputCanvas"]; });
  44704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRSessionManager"]; });
  44705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  44706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeBlock"]; });
  44707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeSceneComponent"]; });
  44708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  44709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceTransformFeedbackToBundle"]; });
  44710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  44711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGeneratorSceneComponent"]; });
  44712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  44713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  44714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMaterialDefines"]; });
  44715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  44716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseSimpleMaterial"]; });
  44717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"]; });
  44718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMetallicRoughnessMaterial"]; });
  44719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRSpecularGlossinessMaterial"]; });
  44720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradingTexture"]; });
  44721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DynamicTexture"]; });
  44722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTexture"]; });
  44723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawCubeTexture"]; });
  44724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture3D"]; });
  44725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionTexture"]; });
  44726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoTexture"]; });
  44727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  44728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DiscBuilder"]; });
  44729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"]; });
  44730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphereBuilder"]; });
  44731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusBuilder"]; });
  44732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusKnotBuilder"]; });
  44733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonBuilder"]; });
  44734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShapeBuilder"]; });
  44735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LatheBuilder"]; });
  44736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundBuilder"]; });
  44737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TubeBuilder"]; });
  44738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolyhedronBuilder"]; });
  44739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IcoSphereBuilder"]; });
  44740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DecalBuilder"]; });
  44741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  44742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConeParticleEmitter"]; });
  44743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderParticleEmitter"]; });
  44744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderDirectedParticleEmitter"]; });
  44745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericParticleEmitter"]; });
  44746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointParticleEmitter"]; });
  44747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereParticleEmitter"]; });
  44748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereDirectedParticleEmitter"]; });
  44749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  44750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AmmoJSPlugin"]; });
  44751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OimoJSPlugin"]; });
  44752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderEffect"]; });
  44753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipeline"]; });
  44754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManager"]; });
  44755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManagerSceneComponent"]; });
  44756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  44757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRTools"]; });
  44758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"]; });
  44759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  44760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_ENVTextureLoader"]; });
  44761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_KTXTextureLoader"]; });
  44762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TGATextureLoader"]; });
  44763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  44764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NoiseProceduralTexture"]; });
  44765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTextureSceneComponent"]; });
  44766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  44767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  44768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  44769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  44770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  44771. /**
  44772. * Legacy support, defining window.BABYLON (global variable).
  44773. *
  44774. * This is the entry point for the UMD module.
  44775. * The entry point for a future ESM package should be index.ts
  44776. */
  44777. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  44778. if (typeof globalObject !== "undefined") {
  44779. globalObject.BABYLON = BABYLON;
  44780. globalObject.BABYLON = globalObject.BABYLON || {};
  44781. var BABYLON = globalObject.BABYLON;
  44782. BABYLON.Debug = BABYLON.Debug || {};
  44783. var keys = [];
  44784. for (var key in _Debug_index__WEBPACK_IMPORTED_MODULE_1__) {
  44785. BABYLON.Debug[key] = _Debug_index__WEBPACK_IMPORTED_MODULE_1__[key];
  44786. keys.push(key);
  44787. }
  44788. for (var key in _index__WEBPACK_IMPORTED_MODULE_0__) {
  44789. BABYLON[key] = _index__WEBPACK_IMPORTED_MODULE_0__[key];
  44790. }
  44791. }
  44792. var Debug = {
  44793. AxesViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"],
  44794. BoneAxesViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"],
  44795. PhysicsViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["PhysicsViewer"],
  44796. SkeletonViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["SkeletonViewer"],
  44797. };
  44798. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  44799. /***/ }),
  44800. /***/ "./LensFlares/index.ts":
  44801. /*!*****************************!*\
  44802. !*** ./LensFlares/index.ts ***!
  44803. \*****************************/
  44804. /*! exports provided: LensFlare, LensFlareSystem, LensFlareSystemSceneComponent */
  44805. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44806. "use strict";
  44807. __webpack_require__.r(__webpack_exports__);
  44808. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  44809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _lensFlare__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  44810. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  44811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__["LensFlareSystem"]; });
  44812. /* harmony import */ var _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lensFlareSystemSceneComponent */ "./LensFlares/lensFlareSystemSceneComponent.ts");
  44813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__["LensFlareSystemSceneComponent"]; });
  44814. /***/ }),
  44815. /***/ "./LensFlares/lensFlare.ts":
  44816. /*!*********************************!*\
  44817. !*** ./LensFlares/lensFlare.ts ***!
  44818. \*********************************/
  44819. /*! exports provided: LensFlare */
  44820. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44821. "use strict";
  44822. __webpack_require__.r(__webpack_exports__);
  44823. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return LensFlare; });
  44824. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  44825. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  44826. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  44827. /**
  44828. * This represents one of the lens effect in a `lensFlareSystem`.
  44829. * It controls one of the indiviual texture used in the effect.
  44830. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44831. */
  44832. var LensFlare = /** @class */ (function () {
  44833. /**
  44834. * Instantiates a new Lens Flare.
  44835. * This represents one of the lens effect in a `lensFlareSystem`.
  44836. * It controls one of the indiviual texture used in the effect.
  44837. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44838. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  44839. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  44840. * @param color Define the lens color
  44841. * @param imgUrl Define the lens texture url
  44842. * @param system Define the `lensFlareSystem` this flare is part of
  44843. */
  44844. function LensFlare(
  44845. /**
  44846. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  44847. */
  44848. size,
  44849. /**
  44850. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  44851. */
  44852. position, color, imgUrl, system) {
  44853. this.size = size;
  44854. this.position = position;
  44855. /**
  44856. * Define the alpha mode to render this particular lens.
  44857. */
  44858. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_ONEONE;
  44859. this.color = color || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](1, 1, 1);
  44860. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](imgUrl, system.getScene(), true) : null;
  44861. this._system = system;
  44862. system.lensFlares.push(this);
  44863. }
  44864. /**
  44865. * Creates a new Lens Flare.
  44866. * This represents one of the lens effect in a `lensFlareSystem`.
  44867. * It controls one of the indiviual texture used in the effect.
  44868. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44869. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  44870. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  44871. * @param color Define the lens color
  44872. * @param imgUrl Define the lens texture url
  44873. * @param system Define the `lensFlareSystem` this flare is part of
  44874. * @returns The newly created Lens Flare
  44875. */
  44876. LensFlare.AddFlare = function (size, position, color, imgUrl, system) {
  44877. return new LensFlare(size, position, color, imgUrl, system);
  44878. };
  44879. /**
  44880. * Dispose and release the lens flare with its associated resources.
  44881. */
  44882. LensFlare.prototype.dispose = function () {
  44883. if (this.texture) {
  44884. this.texture.dispose();
  44885. }
  44886. // Remove from scene
  44887. var index = this._system.lensFlares.indexOf(this);
  44888. this._system.lensFlares.splice(index, 1);
  44889. };
  44890. return LensFlare;
  44891. }());
  44892. /***/ }),
  44893. /***/ "./LensFlares/lensFlareSystem.ts":
  44894. /*!***************************************!*\
  44895. !*** ./LensFlares/lensFlareSystem.ts ***!
  44896. \***************************************/
  44897. /*! exports provided: LensFlareSystem */
  44898. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44899. "use strict";
  44900. __webpack_require__.r(__webpack_exports__);
  44901. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return LensFlareSystem; });
  44902. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  44903. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  44904. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  44905. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  44906. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  44907. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  44908. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  44909. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  44910. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  44911. /* harmony import */ var _Shaders_lensFlare_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/lensFlare.fragment */ "./Shaders/lensFlare.fragment.ts");
  44912. /* harmony import */ var _Shaders_lensFlare_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/lensFlare.vertex */ "./Shaders/lensFlare.vertex.ts");
  44913. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  44914. /**
  44915. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  44916. * It is usually composed of several `lensFlare`.
  44917. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44918. */
  44919. var LensFlareSystem = /** @class */ (function () {
  44920. /**
  44921. * Instantiates a lens flare system.
  44922. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  44923. * It is usually composed of several `lensFlare`.
  44924. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44925. * @param name Define the name of the lens flare system in the scene
  44926. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  44927. * @param scene Define the scene the lens flare system belongs to
  44928. */
  44929. function LensFlareSystem(
  44930. /**
  44931. * Define the name of the lens flare system
  44932. */
  44933. name, emitter, scene) {
  44934. this.name = name;
  44935. /**
  44936. * List of lens flares used in this system.
  44937. */
  44938. this.lensFlares = new Array();
  44939. /**
  44940. * Define a limit from the border the lens flare can be visible.
  44941. */
  44942. this.borderLimit = 300;
  44943. /**
  44944. * Define a viewport border we do not want to see the lens flare in.
  44945. */
  44946. this.viewportBorder = 0;
  44947. /**
  44948. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  44949. */
  44950. this.layerMask = 0x0FFFFFFF;
  44951. this._vertexBuffers = {};
  44952. this._isEnabled = true;
  44953. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  44954. LensFlareSystem._SceneComponentInitialization(this._scene);
  44955. this._emitter = emitter;
  44956. this.id = name;
  44957. scene.lensFlareSystems.push(this);
  44958. this.meshesSelectionPredicate = function (m) { return (scene.activeCamera && m.material && m.isVisible && m.isEnabled() && m.isBlocker && ((m.layerMask & scene.activeCamera.layerMask) != 0)); };
  44959. var engine = scene.getEngine();
  44960. // VBO
  44961. var vertices = [];
  44962. vertices.push(1, 1);
  44963. vertices.push(-1, 1);
  44964. vertices.push(-1, -1);
  44965. vertices.push(1, -1);
  44966. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind] = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"](engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind, false, false, 2);
  44967. // Indices
  44968. var indices = [];
  44969. indices.push(0);
  44970. indices.push(1);
  44971. indices.push(2);
  44972. indices.push(0);
  44973. indices.push(2);
  44974. indices.push(3);
  44975. this._indexBuffer = engine.createIndexBuffer(indices);
  44976. // Effects
  44977. this._effect = engine.createEffect("lensFlare", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["color", "viewportMatrix"], ["textureSampler"], "");
  44978. }
  44979. Object.defineProperty(LensFlareSystem.prototype, "isEnabled", {
  44980. /**
  44981. * Define if the lens flare system is enabled.
  44982. */
  44983. get: function () {
  44984. return this._isEnabled;
  44985. },
  44986. set: function (value) {
  44987. this._isEnabled = value;
  44988. },
  44989. enumerable: true,
  44990. configurable: true
  44991. });
  44992. /**
  44993. * Get the scene the effects belongs to.
  44994. * @returns the scene holding the lens flare system
  44995. */
  44996. LensFlareSystem.prototype.getScene = function () {
  44997. return this._scene;
  44998. };
  44999. /**
  45000. * Get the emitter of the lens flare system.
  45001. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  45002. * @returns the emitter of the lens flare system
  45003. */
  45004. LensFlareSystem.prototype.getEmitter = function () {
  45005. return this._emitter;
  45006. };
  45007. /**
  45008. * Set the emitter of the lens flare system.
  45009. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  45010. * @param newEmitter Define the new emitter of the system
  45011. */
  45012. LensFlareSystem.prototype.setEmitter = function (newEmitter) {
  45013. this._emitter = newEmitter;
  45014. };
  45015. /**
  45016. * Get the lens flare system emitter position.
  45017. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  45018. * @returns the position
  45019. */
  45020. LensFlareSystem.prototype.getEmitterPosition = function () {
  45021. return this._emitter.getAbsolutePosition ? this._emitter.getAbsolutePosition() : this._emitter.position;
  45022. };
  45023. /**
  45024. * @hidden
  45025. */
  45026. LensFlareSystem.prototype.computeEffectivePosition = function (globalViewport) {
  45027. var position = this.getEmitterPosition();
  45028. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), this._scene.getTransformMatrix(), globalViewport);
  45029. this._positionX = position.x;
  45030. this._positionY = position.y;
  45031. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(this.getEmitterPosition(), this._scene.getViewMatrix());
  45032. if (this.viewportBorder > 0) {
  45033. globalViewport.x -= this.viewportBorder;
  45034. globalViewport.y -= this.viewportBorder;
  45035. globalViewport.width += this.viewportBorder * 2;
  45036. globalViewport.height += this.viewportBorder * 2;
  45037. position.x += this.viewportBorder;
  45038. position.y += this.viewportBorder;
  45039. this._positionX += this.viewportBorder;
  45040. this._positionY += this.viewportBorder;
  45041. }
  45042. if (position.z > 0) {
  45043. if ((this._positionX > globalViewport.x) && (this._positionX < globalViewport.x + globalViewport.width)) {
  45044. if ((this._positionY > globalViewport.y) && (this._positionY < globalViewport.y + globalViewport.height)) {
  45045. return true;
  45046. }
  45047. }
  45048. return true;
  45049. }
  45050. return false;
  45051. };
  45052. /** @hidden */
  45053. LensFlareSystem.prototype._isVisible = function () {
  45054. if (!this._isEnabled || !this._scene.activeCamera) {
  45055. return false;
  45056. }
  45057. var emitterPosition = this.getEmitterPosition();
  45058. var direction = emitterPosition.subtract(this._scene.activeCamera.globalPosition);
  45059. var distance = direction.length();
  45060. direction.normalize();
  45061. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](this._scene.activeCamera.globalPosition, direction);
  45062. var pickInfo = this._scene.pickWithRay(ray, this.meshesSelectionPredicate, true);
  45063. return !pickInfo || !pickInfo.hit || pickInfo.distance > distance;
  45064. };
  45065. /**
  45066. * @hidden
  45067. */
  45068. LensFlareSystem.prototype.render = function () {
  45069. if (!this._effect.isReady() || !this._scene.activeCamera) {
  45070. return false;
  45071. }
  45072. var engine = this._scene.getEngine();
  45073. var viewport = this._scene.activeCamera.viewport;
  45074. var globalViewport = viewport.toGlobal(engine.getRenderWidth(true), engine.getRenderHeight(true));
  45075. // Position
  45076. if (!this.computeEffectivePosition(globalViewport)) {
  45077. return false;
  45078. }
  45079. // Visibility
  45080. if (!this._isVisible()) {
  45081. return false;
  45082. }
  45083. // Intensity
  45084. var awayX;
  45085. var awayY;
  45086. if (this._positionX < this.borderLimit + globalViewport.x) {
  45087. awayX = this.borderLimit + globalViewport.x - this._positionX;
  45088. }
  45089. else if (this._positionX > globalViewport.x + globalViewport.width - this.borderLimit) {
  45090. awayX = this._positionX - globalViewport.x - globalViewport.width + this.borderLimit;
  45091. }
  45092. else {
  45093. awayX = 0;
  45094. }
  45095. if (this._positionY < this.borderLimit + globalViewport.y) {
  45096. awayY = this.borderLimit + globalViewport.y - this._positionY;
  45097. }
  45098. else if (this._positionY > globalViewport.y + globalViewport.height - this.borderLimit) {
  45099. awayY = this._positionY - globalViewport.y - globalViewport.height + this.borderLimit;
  45100. }
  45101. else {
  45102. awayY = 0;
  45103. }
  45104. var away = (awayX > awayY) ? awayX : awayY;
  45105. away -= this.viewportBorder;
  45106. if (away > this.borderLimit) {
  45107. away = this.borderLimit;
  45108. }
  45109. var intensity = 1.0 - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Clamp(away / this.borderLimit, 0, 1);
  45110. if (intensity < 0) {
  45111. return false;
  45112. }
  45113. if (intensity > 1.0) {
  45114. intensity = 1.0;
  45115. }
  45116. if (this.viewportBorder > 0) {
  45117. globalViewport.x += this.viewportBorder;
  45118. globalViewport.y += this.viewportBorder;
  45119. globalViewport.width -= this.viewportBorder * 2;
  45120. globalViewport.height -= this.viewportBorder * 2;
  45121. this._positionX -= this.viewportBorder;
  45122. this._positionY -= this.viewportBorder;
  45123. }
  45124. // Position
  45125. var centerX = globalViewport.x + globalViewport.width / 2;
  45126. var centerY = globalViewport.y + globalViewport.height / 2;
  45127. var distX = centerX - this._positionX;
  45128. var distY = centerY - this._positionY;
  45129. // Effects
  45130. engine.enableEffect(this._effect);
  45131. engine.setState(false);
  45132. engine.setDepthBuffer(false);
  45133. // VBOs
  45134. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  45135. // Flares
  45136. for (var index = 0; index < this.lensFlares.length; index++) {
  45137. var flare = this.lensFlares[index];
  45138. engine.setAlphaMode(flare.alphaMode);
  45139. var x = centerX - (distX * flare.position);
  45140. var y = centerY - (distY * flare.position);
  45141. var cw = flare.size;
  45142. var ch = flare.size * engine.getAspectRatio(this._scene.activeCamera, true);
  45143. var cx = 2 * (x / (globalViewport.width + globalViewport.x * 2)) - 1.0;
  45144. var cy = 1.0 - 2 * (y / (globalViewport.height + globalViewport.y * 2));
  45145. var viewportMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromValues(cw / 2, 0, 0, 0, 0, ch / 2, 0, 0, 0, 0, 1, 0, cx, cy, 0, 1);
  45146. this._effect.setMatrix("viewportMatrix", viewportMatrix);
  45147. // Texture
  45148. this._effect.setTexture("textureSampler", flare.texture);
  45149. // Color
  45150. this._effect.setFloat4("color", flare.color.r * intensity, flare.color.g * intensity, flare.color.b * intensity, 1.0);
  45151. // Draw order
  45152. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  45153. }
  45154. engine.setDepthBuffer(true);
  45155. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  45156. return true;
  45157. };
  45158. /**
  45159. * Dispose and release the lens flare with its associated resources.
  45160. */
  45161. LensFlareSystem.prototype.dispose = function () {
  45162. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  45163. if (vertexBuffer) {
  45164. vertexBuffer.dispose();
  45165. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind] = null;
  45166. }
  45167. if (this._indexBuffer) {
  45168. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  45169. this._indexBuffer = null;
  45170. }
  45171. while (this.lensFlares.length) {
  45172. this.lensFlares[0].dispose();
  45173. }
  45174. // Remove from scene
  45175. var index = this._scene.lensFlareSystems.indexOf(this);
  45176. this._scene.lensFlareSystems.splice(index, 1);
  45177. };
  45178. /**
  45179. * Parse a lens flare system from a JSON repressentation
  45180. * @param parsedLensFlareSystem Define the JSON to parse
  45181. * @param scene Define the scene the parsed system should be instantiated in
  45182. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  45183. * @returns the parsed system
  45184. */
  45185. LensFlareSystem.Parse = function (parsedLensFlareSystem, scene, rootUrl) {
  45186. var emitter = scene.getLastEntryByID(parsedLensFlareSystem.emitterId);
  45187. var name = parsedLensFlareSystem.name || "lensFlareSystem#" + parsedLensFlareSystem.emitterId;
  45188. var lensFlareSystem = new LensFlareSystem(name, emitter, scene);
  45189. lensFlareSystem.id = parsedLensFlareSystem.id || name;
  45190. lensFlareSystem.borderLimit = parsedLensFlareSystem.borderLimit;
  45191. for (var index = 0; index < parsedLensFlareSystem.flares.length; index++) {
  45192. var parsedFlare = parsedLensFlareSystem.flares[index];
  45193. _lensFlare__WEBPACK_IMPORTED_MODULE_7__["LensFlare"].AddFlare(parsedFlare.size, parsedFlare.position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFlare.color), parsedFlare.textureName ? rootUrl + parsedFlare.textureName : "", lensFlareSystem);
  45194. }
  45195. return lensFlareSystem;
  45196. };
  45197. /**
  45198. * Serialize the current Lens Flare System into a JSON representation.
  45199. * @returns the serialized JSON
  45200. */
  45201. LensFlareSystem.prototype.serialize = function () {
  45202. var serializationObject = {};
  45203. serializationObject.id = this.id;
  45204. serializationObject.name = this.name;
  45205. serializationObject.emitterId = this.getEmitter().id;
  45206. serializationObject.borderLimit = this.borderLimit;
  45207. serializationObject.flares = [];
  45208. for (var index = 0; index < this.lensFlares.length; index++) {
  45209. var flare = this.lensFlares[index];
  45210. serializationObject.flares.push({
  45211. size: flare.size,
  45212. position: flare.position,
  45213. color: flare.color.asArray(),
  45214. textureName: _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(flare.texture ? flare.texture.name : "")
  45215. });
  45216. }
  45217. return serializationObject;
  45218. };
  45219. /** @hidden */
  45220. LensFlareSystem._SceneComponentInitialization = function (_) {
  45221. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("LensFlareSystemSceneComponent");
  45222. };
  45223. return LensFlareSystem;
  45224. }());
  45225. /***/ }),
  45226. /***/ "./LensFlares/lensFlareSystemSceneComponent.ts":
  45227. /*!*****************************************************!*\
  45228. !*** ./LensFlares/lensFlareSystemSceneComponent.ts ***!
  45229. \*****************************************************/
  45230. /*! exports provided: LensFlareSystemSceneComponent */
  45231. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45232. "use strict";
  45233. __webpack_require__.r(__webpack_exports__);
  45234. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return LensFlareSystemSceneComponent; });
  45235. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  45236. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  45237. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  45238. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  45239. // Adds the parser to the scene parsers.
  45240. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM, function (parsedData, scene, container, rootUrl) {
  45241. // Lens flares
  45242. if (parsedData.lensFlareSystems !== undefined && parsedData.lensFlareSystems !== null) {
  45243. if (!container.lensFlareSystems) {
  45244. container.lensFlareSystems = new Array();
  45245. }
  45246. for (var index = 0, cache = parsedData.lensFlareSystems.length; index < cache; index++) {
  45247. var parsedLensFlareSystem = parsedData.lensFlareSystems[index];
  45248. var lf = _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"].Parse(parsedLensFlareSystem, scene, rootUrl);
  45249. container.lensFlareSystems.push(lf);
  45250. }
  45251. }
  45252. });
  45253. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByName = function (name) {
  45254. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  45255. if (this.lensFlareSystems[index].name === name) {
  45256. return this.lensFlareSystems[index];
  45257. }
  45258. }
  45259. return null;
  45260. };
  45261. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByID = function (id) {
  45262. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  45263. if (this.lensFlareSystems[index].id === id) {
  45264. return this.lensFlareSystems[index];
  45265. }
  45266. }
  45267. return null;
  45268. };
  45269. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.removeLensFlareSystem = function (toRemove) {
  45270. var index = this.lensFlareSystems.indexOf(toRemove);
  45271. if (index !== -1) {
  45272. this.lensFlareSystems.splice(index, 1);
  45273. }
  45274. return index;
  45275. };
  45276. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.addLensFlareSystem = function (newLensFlareSystem) {
  45277. this.lensFlareSystems.push(newLensFlareSystem);
  45278. };
  45279. /**
  45280. * Defines the lens flare scene component responsible to manage any lens flares
  45281. * in a given scene.
  45282. */
  45283. var LensFlareSystemSceneComponent = /** @class */ (function () {
  45284. /**
  45285. * Creates a new instance of the component for the given scene
  45286. * @param scene Defines the scene to register the component in
  45287. */
  45288. function LensFlareSystemSceneComponent(scene) {
  45289. /**
  45290. * The component name helpfull to identify the component in the list of scene components.
  45291. */
  45292. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM;
  45293. this.scene = scene;
  45294. scene.lensFlareSystems = new Array();
  45295. }
  45296. /**
  45297. * Registers the component in a given scene
  45298. */
  45299. LensFlareSystemSceneComponent.prototype.register = function () {
  45300. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LENSFLARESYSTEM, this, this._draw);
  45301. };
  45302. /**
  45303. * Rebuilds the elements related to this component in case of
  45304. * context lost for instance.
  45305. */
  45306. LensFlareSystemSceneComponent.prototype.rebuild = function () {
  45307. // Nothing to do for lens flare
  45308. };
  45309. /**
  45310. * Adds all the element from the container to the scene
  45311. * @param container the container holding the elements
  45312. */
  45313. LensFlareSystemSceneComponent.prototype.addFromContainer = function (container) {
  45314. var _this = this;
  45315. if (!container.lensFlareSystems) {
  45316. return;
  45317. }
  45318. container.lensFlareSystems.forEach(function (o) {
  45319. _this.scene.addLensFlareSystem(o);
  45320. });
  45321. };
  45322. /**
  45323. * Removes all the elements in the container from the scene
  45324. * @param container contains the elements to remove
  45325. * @param dispose if the removed element should be disposed (default: false)
  45326. */
  45327. LensFlareSystemSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  45328. var _this = this;
  45329. if (!container.lensFlareSystems) {
  45330. return;
  45331. }
  45332. container.lensFlareSystems.forEach(function (o) {
  45333. _this.scene.removeLensFlareSystem(o);
  45334. if (dispose) {
  45335. o.dispose();
  45336. }
  45337. });
  45338. };
  45339. /**
  45340. * Serializes the component data to the specified json object
  45341. * @param serializationObject The object to serialize to
  45342. */
  45343. LensFlareSystemSceneComponent.prototype.serialize = function (serializationObject) {
  45344. // Lens flares
  45345. serializationObject.lensFlareSystems = [];
  45346. var lensFlareSystems = this.scene.lensFlareSystems;
  45347. for (var _i = 0, lensFlareSystems_1 = lensFlareSystems; _i < lensFlareSystems_1.length; _i++) {
  45348. var lensFlareSystem = lensFlareSystems_1[_i];
  45349. serializationObject.lensFlareSystems.push(lensFlareSystem.serialize());
  45350. }
  45351. };
  45352. /**
  45353. * Disposes the component and the associated ressources.
  45354. */
  45355. LensFlareSystemSceneComponent.prototype.dispose = function () {
  45356. var lensFlareSystems = this.scene.lensFlareSystems;
  45357. while (lensFlareSystems.length) {
  45358. lensFlareSystems[0].dispose();
  45359. }
  45360. };
  45361. LensFlareSystemSceneComponent.prototype._draw = function (camera) {
  45362. // Lens flares
  45363. if (this.scene.lensFlaresEnabled) {
  45364. var lensFlareSystems = this.scene.lensFlareSystems;
  45365. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  45366. for (var _i = 0, lensFlareSystems_2 = lensFlareSystems; _i < lensFlareSystems_2.length; _i++) {
  45367. var lensFlareSystem = lensFlareSystems_2[_i];
  45368. if ((camera.layerMask & lensFlareSystem.layerMask) !== 0) {
  45369. lensFlareSystem.render();
  45370. }
  45371. }
  45372. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  45373. }
  45374. };
  45375. return LensFlareSystemSceneComponent;
  45376. }());
  45377. _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"]._SceneComponentInitialization = function (scene) {
  45378. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM);
  45379. if (!component) {
  45380. component = new LensFlareSystemSceneComponent(scene);
  45381. scene._addComponent(component);
  45382. }
  45383. };
  45384. /***/ }),
  45385. /***/ "./Lights/Shadows/index.ts":
  45386. /*!*********************************!*\
  45387. !*** ./Lights/Shadows/index.ts ***!
  45388. \*********************************/
  45389. /*! exports provided: ShadowGenerator, ShadowGeneratorSceneComponent */
  45390. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45391. "use strict";
  45392. __webpack_require__.r(__webpack_exports__);
  45393. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  45394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  45395. /* harmony import */ var _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowGeneratorSceneComponent */ "./Lights/Shadows/shadowGeneratorSceneComponent.ts");
  45396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__["ShadowGeneratorSceneComponent"]; });
  45397. /***/ }),
  45398. /***/ "./Lights/Shadows/shadowGenerator.ts":
  45399. /*!*******************************************!*\
  45400. !*** ./Lights/Shadows/shadowGenerator.ts ***!
  45401. \*******************************************/
  45402. /*! exports provided: ShadowGenerator */
  45403. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45404. "use strict";
  45405. __webpack_require__.r(__webpack_exports__);
  45406. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return ShadowGenerator; });
  45407. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  45408. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  45409. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  45410. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  45411. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  45412. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  45413. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  45414. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  45415. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  45416. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  45417. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  45418. /* harmony import */ var _Shaders_shadowMap_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Shaders/shadowMap.fragment */ "./Shaders/shadowMap.fragment.ts");
  45419. /* harmony import */ var _Shaders_shadowMap_vertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Shaders/shadowMap.vertex */ "./Shaders/shadowMap.vertex.ts");
  45420. /* harmony import */ var _Shaders_depthBoxBlur_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Shaders/depthBoxBlur.fragment */ "./Shaders/depthBoxBlur.fragment.ts");
  45421. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  45422. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  45423. /**
  45424. * Default implementation IShadowGenerator.
  45425. * This is the main object responsible of generating shadows in the framework.
  45426. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  45427. */
  45428. var ShadowGenerator = /** @class */ (function () {
  45429. /**
  45430. * Creates a ShadowGenerator object.
  45431. * A ShadowGenerator is the required tool to use the shadows.
  45432. * Each light casting shadows needs to use its own ShadowGenerator.
  45433. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  45434. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  45435. * @param light The light object generating the shadows.
  45436. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  45437. */
  45438. function ShadowGenerator(mapSize, light, usefulFloatFirst) {
  45439. /**
  45440. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  45441. */
  45442. this.onBeforeShadowMapRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_14__["Observable"]();
  45443. /**
  45444. * Observable triggered before a mesh is rendered in the shadow map.
  45445. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  45446. */
  45447. this.onBeforeShadowMapRenderMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_14__["Observable"]();
  45448. this._bias = 0.00005;
  45449. this._normalBias = 0;
  45450. this._blurBoxOffset = 1;
  45451. this._blurScale = 2;
  45452. this._blurKernel = 1;
  45453. this._useKernelBlur = false;
  45454. this._filter = ShadowGenerator.FILTER_NONE;
  45455. this._filteringQuality = ShadowGenerator.QUALITY_HIGH;
  45456. this._contactHardeningLightSizeUVRatio = 0.1;
  45457. this._darkness = 0;
  45458. this._transparencyShadow = false;
  45459. /**
  45460. * Controls the extent to which the shadows fade out at the edge of the frustum
  45461. * Used only by directionals and spots
  45462. */
  45463. this.frustumEdgeFalloff = 0;
  45464. /**
  45465. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  45466. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  45467. * It might on the other hand introduce peter panning.
  45468. */
  45469. this.forceBackFacesOnly = false;
  45470. this._lightDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  45471. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  45472. this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  45473. this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  45474. this._cachedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  45475. this._cachedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  45476. this._currentFaceIndex = 0;
  45477. this._currentFaceIndexCache = 0;
  45478. this._defaultTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  45479. this._mapSize = mapSize;
  45480. this._light = light;
  45481. this._scene = light.getScene();
  45482. light._shadowGenerator = this;
  45483. ShadowGenerator._SceneComponentInitialization(this._scene);
  45484. // Texture type fallback from float to int if not supported.
  45485. var caps = this._scene.getEngine().getCaps();
  45486. if (!usefulFloatFirst) {
  45487. if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  45488. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  45489. }
  45490. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  45491. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  45492. }
  45493. else {
  45494. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  45495. }
  45496. }
  45497. else {
  45498. if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  45499. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  45500. }
  45501. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  45502. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  45503. }
  45504. else {
  45505. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  45506. }
  45507. }
  45508. this._initializeGenerator();
  45509. this._applyFilterValues();
  45510. }
  45511. Object.defineProperty(ShadowGenerator.prototype, "bias", {
  45512. /**
  45513. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  45514. */
  45515. get: function () {
  45516. return this._bias;
  45517. },
  45518. /**
  45519. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  45520. */
  45521. set: function (bias) {
  45522. this._bias = bias;
  45523. },
  45524. enumerable: true,
  45525. configurable: true
  45526. });
  45527. Object.defineProperty(ShadowGenerator.prototype, "normalBias", {
  45528. /**
  45529. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  45530. */
  45531. get: function () {
  45532. return this._normalBias;
  45533. },
  45534. /**
  45535. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  45536. */
  45537. set: function (normalBias) {
  45538. this._normalBias = normalBias;
  45539. },
  45540. enumerable: true,
  45541. configurable: true
  45542. });
  45543. Object.defineProperty(ShadowGenerator.prototype, "blurBoxOffset", {
  45544. /**
  45545. * Gets the blur box offset: offset applied during the blur pass.
  45546. * Only useful if useKernelBlur = false
  45547. */
  45548. get: function () {
  45549. return this._blurBoxOffset;
  45550. },
  45551. /**
  45552. * Sets the blur box offset: offset applied during the blur pass.
  45553. * Only useful if useKernelBlur = false
  45554. */
  45555. set: function (value) {
  45556. if (this._blurBoxOffset === value) {
  45557. return;
  45558. }
  45559. this._blurBoxOffset = value;
  45560. this._disposeBlurPostProcesses();
  45561. },
  45562. enumerable: true,
  45563. configurable: true
  45564. });
  45565. Object.defineProperty(ShadowGenerator.prototype, "blurScale", {
  45566. /**
  45567. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  45568. * 2 means half of the size.
  45569. */
  45570. get: function () {
  45571. return this._blurScale;
  45572. },
  45573. /**
  45574. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  45575. * 2 means half of the size.
  45576. */
  45577. set: function (value) {
  45578. if (this._blurScale === value) {
  45579. return;
  45580. }
  45581. this._blurScale = value;
  45582. this._disposeBlurPostProcesses();
  45583. },
  45584. enumerable: true,
  45585. configurable: true
  45586. });
  45587. Object.defineProperty(ShadowGenerator.prototype, "blurKernel", {
  45588. /**
  45589. * Gets the blur kernel: kernel size of the blur pass.
  45590. * Only useful if useKernelBlur = true
  45591. */
  45592. get: function () {
  45593. return this._blurKernel;
  45594. },
  45595. /**
  45596. * Sets the blur kernel: kernel size of the blur pass.
  45597. * Only useful if useKernelBlur = true
  45598. */
  45599. set: function (value) {
  45600. if (this._blurKernel === value) {
  45601. return;
  45602. }
  45603. this._blurKernel = value;
  45604. this._disposeBlurPostProcesses();
  45605. },
  45606. enumerable: true,
  45607. configurable: true
  45608. });
  45609. Object.defineProperty(ShadowGenerator.prototype, "useKernelBlur", {
  45610. /**
  45611. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  45612. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  45613. */
  45614. get: function () {
  45615. return this._useKernelBlur;
  45616. },
  45617. /**
  45618. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  45619. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  45620. */
  45621. set: function (value) {
  45622. if (this._useKernelBlur === value) {
  45623. return;
  45624. }
  45625. this._useKernelBlur = value;
  45626. this._disposeBlurPostProcesses();
  45627. },
  45628. enumerable: true,
  45629. configurable: true
  45630. });
  45631. Object.defineProperty(ShadowGenerator.prototype, "depthScale", {
  45632. /**
  45633. * Gets the depth scale used in ESM mode.
  45634. */
  45635. get: function () {
  45636. return this._depthScale !== undefined ? this._depthScale : this._light.getDepthScale();
  45637. },
  45638. /**
  45639. * Sets the depth scale used in ESM mode.
  45640. * This can override the scale stored on the light.
  45641. */
  45642. set: function (value) {
  45643. this._depthScale = value;
  45644. },
  45645. enumerable: true,
  45646. configurable: true
  45647. });
  45648. Object.defineProperty(ShadowGenerator.prototype, "filter", {
  45649. /**
  45650. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  45651. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  45652. */
  45653. get: function () {
  45654. return this._filter;
  45655. },
  45656. /**
  45657. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  45658. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  45659. */
  45660. set: function (value) {
  45661. // Blurring the cubemap is going to be too expensive. Reverting to unblurred version
  45662. if (this._light.needCube()) {
  45663. if (value === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  45664. this.useExponentialShadowMap = true;
  45665. return;
  45666. }
  45667. else if (value === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  45668. this.useCloseExponentialShadowMap = true;
  45669. return;
  45670. }
  45671. // PCF on cubemap would also be expensive
  45672. else if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  45673. this.usePoissonSampling = true;
  45674. return;
  45675. }
  45676. }
  45677. // Weblg1 fallback for PCF.
  45678. if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  45679. if (this._scene.getEngine().webGLVersion === 1) {
  45680. this.usePoissonSampling = true;
  45681. return;
  45682. }
  45683. }
  45684. if (this._filter === value) {
  45685. return;
  45686. }
  45687. this._filter = value;
  45688. this._disposeBlurPostProcesses();
  45689. this._applyFilterValues();
  45690. this._light._markMeshesAsLightDirty();
  45691. },
  45692. enumerable: true,
  45693. configurable: true
  45694. });
  45695. Object.defineProperty(ShadowGenerator.prototype, "usePoissonSampling", {
  45696. /**
  45697. * Gets if the current filter is set to Poisson Sampling.
  45698. */
  45699. get: function () {
  45700. return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING;
  45701. },
  45702. /**
  45703. * Sets the current filter to Poisson Sampling.
  45704. */
  45705. set: function (value) {
  45706. if (!value && this.filter !== ShadowGenerator.FILTER_POISSONSAMPLING) {
  45707. return;
  45708. }
  45709. this.filter = (value ? ShadowGenerator.FILTER_POISSONSAMPLING : ShadowGenerator.FILTER_NONE);
  45710. },
  45711. enumerable: true,
  45712. configurable: true
  45713. });
  45714. Object.defineProperty(ShadowGenerator.prototype, "useExponentialShadowMap", {
  45715. /**
  45716. * Gets if the current filter is set to ESM.
  45717. */
  45718. get: function () {
  45719. return this.filter === ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP;
  45720. },
  45721. /**
  45722. * Sets the current filter is to ESM.
  45723. */
  45724. set: function (value) {
  45725. if (!value && this.filter !== ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP) {
  45726. return;
  45727. }
  45728. this.filter = (value ? ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45729. },
  45730. enumerable: true,
  45731. configurable: true
  45732. });
  45733. Object.defineProperty(ShadowGenerator.prototype, "useBlurExponentialShadowMap", {
  45734. /**
  45735. * Gets if the current filter is set to filtered ESM.
  45736. */
  45737. get: function () {
  45738. return this.filter === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP;
  45739. },
  45740. /**
  45741. * Gets if the current filter is set to filtered ESM.
  45742. */
  45743. set: function (value) {
  45744. if (!value && this.filter !== ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  45745. return;
  45746. }
  45747. this.filter = (value ? ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45748. },
  45749. enumerable: true,
  45750. configurable: true
  45751. });
  45752. Object.defineProperty(ShadowGenerator.prototype, "useCloseExponentialShadowMap", {
  45753. /**
  45754. * Gets if the current filter is set to "close ESM" (using the inverse of the
  45755. * exponential to prevent steep falloff artifacts).
  45756. */
  45757. get: function () {
  45758. return this.filter === ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP;
  45759. },
  45760. /**
  45761. * Sets the current filter to "close ESM" (using the inverse of the
  45762. * exponential to prevent steep falloff artifacts).
  45763. */
  45764. set: function (value) {
  45765. if (!value && this.filter !== ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP) {
  45766. return;
  45767. }
  45768. this.filter = (value ? ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45769. },
  45770. enumerable: true,
  45771. configurable: true
  45772. });
  45773. Object.defineProperty(ShadowGenerator.prototype, "useBlurCloseExponentialShadowMap", {
  45774. /**
  45775. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  45776. * exponential to prevent steep falloff artifacts).
  45777. */
  45778. get: function () {
  45779. return this.filter === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP;
  45780. },
  45781. /**
  45782. * Sets the current filter to filtered "close ESM" (using the inverse of the
  45783. * exponential to prevent steep falloff artifacts).
  45784. */
  45785. set: function (value) {
  45786. if (!value && this.filter !== ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  45787. return;
  45788. }
  45789. this.filter = (value ? ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45790. },
  45791. enumerable: true,
  45792. configurable: true
  45793. });
  45794. Object.defineProperty(ShadowGenerator.prototype, "usePercentageCloserFiltering", {
  45795. /**
  45796. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  45797. */
  45798. get: function () {
  45799. return this.filter === ShadowGenerator.FILTER_PCF;
  45800. },
  45801. /**
  45802. * Sets the current filter to "PCF" (percentage closer filtering).
  45803. */
  45804. set: function (value) {
  45805. if (!value && this.filter !== ShadowGenerator.FILTER_PCF) {
  45806. return;
  45807. }
  45808. this.filter = (value ? ShadowGenerator.FILTER_PCF : ShadowGenerator.FILTER_NONE);
  45809. },
  45810. enumerable: true,
  45811. configurable: true
  45812. });
  45813. Object.defineProperty(ShadowGenerator.prototype, "filteringQuality", {
  45814. /**
  45815. * Gets the PCF or PCSS Quality.
  45816. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  45817. */
  45818. get: function () {
  45819. return this._filteringQuality;
  45820. },
  45821. /**
  45822. * Sets the PCF or PCSS Quality.
  45823. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  45824. */
  45825. set: function (filteringQuality) {
  45826. this._filteringQuality = filteringQuality;
  45827. },
  45828. enumerable: true,
  45829. configurable: true
  45830. });
  45831. Object.defineProperty(ShadowGenerator.prototype, "useContactHardeningShadow", {
  45832. /**
  45833. * Gets if the current filter is set to "PCSS" (contact hardening).
  45834. */
  45835. get: function () {
  45836. return this.filter === ShadowGenerator.FILTER_PCSS;
  45837. },
  45838. /**
  45839. * Sets the current filter to "PCSS" (contact hardening).
  45840. */
  45841. set: function (value) {
  45842. if (!value && this.filter !== ShadowGenerator.FILTER_PCSS) {
  45843. return;
  45844. }
  45845. this.filter = (value ? ShadowGenerator.FILTER_PCSS : ShadowGenerator.FILTER_NONE);
  45846. },
  45847. enumerable: true,
  45848. configurable: true
  45849. });
  45850. Object.defineProperty(ShadowGenerator.prototype, "contactHardeningLightSizeUVRatio", {
  45851. /**
  45852. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  45853. * Using a ratio helps keeping shape stability independently of the map size.
  45854. *
  45855. * It does not account for the light projection as it was having too much
  45856. * instability during the light setup or during light position changes.
  45857. *
  45858. * Only valid if useContactHardeningShadow is true.
  45859. */
  45860. get: function () {
  45861. return this._contactHardeningLightSizeUVRatio;
  45862. },
  45863. /**
  45864. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  45865. * Using a ratio helps keeping shape stability independently of the map size.
  45866. *
  45867. * It does not account for the light projection as it was having too much
  45868. * instability during the light setup or during light position changes.
  45869. *
  45870. * Only valid if useContactHardeningShadow is true.
  45871. */
  45872. set: function (contactHardeningLightSizeUVRatio) {
  45873. this._contactHardeningLightSizeUVRatio = contactHardeningLightSizeUVRatio;
  45874. },
  45875. enumerable: true,
  45876. configurable: true
  45877. });
  45878. /**
  45879. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  45880. * 0 means strongest and 1 would means no shadow.
  45881. * @returns the darkness.
  45882. */
  45883. ShadowGenerator.prototype.getDarkness = function () {
  45884. return this._darkness;
  45885. };
  45886. /**
  45887. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  45888. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  45889. * @returns the shadow generator allowing fluent coding.
  45890. */
  45891. ShadowGenerator.prototype.setDarkness = function (darkness) {
  45892. if (darkness >= 1.0) {
  45893. this._darkness = 1.0;
  45894. }
  45895. else if (darkness <= 0.0) {
  45896. this._darkness = 0.0;
  45897. }
  45898. else {
  45899. this._darkness = darkness;
  45900. }
  45901. return this;
  45902. };
  45903. /**
  45904. * Sets the ability to have transparent shadow (boolean).
  45905. * @param transparent True if transparent else False
  45906. * @returns the shadow generator allowing fluent coding
  45907. */
  45908. ShadowGenerator.prototype.setTransparencyShadow = function (transparent) {
  45909. this._transparencyShadow = transparent;
  45910. return this;
  45911. };
  45912. /**
  45913. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  45914. * @returns The render target texture if present otherwise, null
  45915. */
  45916. ShadowGenerator.prototype.getShadowMap = function () {
  45917. return this._shadowMap;
  45918. };
  45919. /**
  45920. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  45921. * @returns The render target texture if the shadow map is present otherwise, null
  45922. */
  45923. ShadowGenerator.prototype.getShadowMapForRendering = function () {
  45924. if (this._shadowMap2) {
  45925. return this._shadowMap2;
  45926. }
  45927. return this._shadowMap;
  45928. };
  45929. /**
  45930. * Helper function to add a mesh and its descendants to the list of shadow casters.
  45931. * @param mesh Mesh to add
  45932. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  45933. * @returns the Shadow Generator itself
  45934. */
  45935. ShadowGenerator.prototype.addShadowCaster = function (mesh, includeDescendants) {
  45936. if (includeDescendants === void 0) { includeDescendants = true; }
  45937. var _a;
  45938. if (!this._shadowMap) {
  45939. return this;
  45940. }
  45941. if (!this._shadowMap.renderList) {
  45942. this._shadowMap.renderList = [];
  45943. }
  45944. this._shadowMap.renderList.push(mesh);
  45945. if (includeDescendants) {
  45946. (_a = this._shadowMap.renderList).push.apply(_a, mesh.getChildMeshes());
  45947. }
  45948. return this;
  45949. };
  45950. /**
  45951. * Helper function to remove a mesh and its descendants from the list of shadow casters
  45952. * @param mesh Mesh to remove
  45953. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  45954. * @returns the Shadow Generator itself
  45955. */
  45956. ShadowGenerator.prototype.removeShadowCaster = function (mesh, includeDescendants) {
  45957. if (includeDescendants === void 0) { includeDescendants = true; }
  45958. if (!this._shadowMap || !this._shadowMap.renderList) {
  45959. return this;
  45960. }
  45961. var index = this._shadowMap.renderList.indexOf(mesh);
  45962. if (index !== -1) {
  45963. this._shadowMap.renderList.splice(index, 1);
  45964. }
  45965. if (includeDescendants) {
  45966. for (var _i = 0, _a = mesh.getChildren(); _i < _a.length; _i++) {
  45967. var child = _a[_i];
  45968. this.removeShadowCaster(child);
  45969. }
  45970. }
  45971. return this;
  45972. };
  45973. /**
  45974. * Returns the associated light object.
  45975. * @returns the light generating the shadow
  45976. */
  45977. ShadowGenerator.prototype.getLight = function () {
  45978. return this._light;
  45979. };
  45980. ShadowGenerator.prototype._initializeGenerator = function () {
  45981. this._light._markMeshesAsLightDirty();
  45982. this._initializeShadowMap();
  45983. };
  45984. ShadowGenerator.prototype._initializeShadowMap = function () {
  45985. var _this = this;
  45986. // Render target
  45987. var engine = this._scene.getEngine();
  45988. if (engine.webGLVersion > 1) {
  45989. this._shadowMap = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"](this._light.name + "_shadowMap", this._mapSize, this._scene, false, true, this._textureType, this._light.needCube(), undefined, false, false);
  45990. this._shadowMap.createDepthStencilTexture(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].LESS, true);
  45991. }
  45992. else {
  45993. this._shadowMap = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"](this._light.name + "_shadowMap", this._mapSize, this._scene, false, true, this._textureType, this._light.needCube());
  45994. }
  45995. this._shadowMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  45996. this._shadowMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  45997. this._shadowMap.anisotropicFilteringLevel = 1;
  45998. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  45999. this._shadowMap.renderParticles = false;
  46000. this._shadowMap.ignoreCameraViewport = true;
  46001. // Record Face Index before render.
  46002. this._shadowMap.onBeforeRenderObservable.add(function (faceIndex) {
  46003. _this._currentFaceIndex = faceIndex;
  46004. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  46005. engine.setColorWrite(false);
  46006. }
  46007. });
  46008. // Custom render function.
  46009. this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this);
  46010. // Blur if required afer render.
  46011. this._shadowMap.onAfterUnbindObservable.add(function () {
  46012. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  46013. engine.setColorWrite(true);
  46014. }
  46015. if (!_this.useBlurExponentialShadowMap && !_this.useBlurCloseExponentialShadowMap) {
  46016. return;
  46017. }
  46018. var shadowMap = _this.getShadowMapForRendering();
  46019. if (shadowMap) {
  46020. _this._scene.postProcessManager.directRender(_this._blurPostProcesses, shadowMap.getInternalTexture(), true);
  46021. }
  46022. });
  46023. // Clear according to the chosen filter.
  46024. var clearZero = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](0, 0, 0, 0);
  46025. var clearOne = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  46026. this._shadowMap.onClearObservable.add(function (engine) {
  46027. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  46028. engine.clear(clearOne, false, true, false);
  46029. }
  46030. else if (_this.useExponentialShadowMap || _this.useBlurExponentialShadowMap) {
  46031. engine.clear(clearZero, true, true, false);
  46032. }
  46033. else {
  46034. engine.clear(clearOne, true, true, false);
  46035. }
  46036. });
  46037. };
  46038. ShadowGenerator.prototype._initializeBlurRTTAndPostProcesses = function () {
  46039. var _this = this;
  46040. var engine = this._scene.getEngine();
  46041. var targetSize = this._mapSize / this.blurScale;
  46042. if (!this.useKernelBlur || this.blurScale !== 1.0) {
  46043. this._shadowMap2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"](this._light.name + "_shadowMap2", targetSize, this._scene, false, true, this._textureType);
  46044. this._shadowMap2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  46045. this._shadowMap2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  46046. this._shadowMap2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  46047. }
  46048. if (this.useKernelBlur) {
  46049. this._kernelBlurXPostprocess = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__["BlurPostProcess"](this._light.name + "KernelBlurX", new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1, 0), this.blurKernel, 1.0, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE, engine, false, this._textureType);
  46050. this._kernelBlurXPostprocess.width = targetSize;
  46051. this._kernelBlurXPostprocess.height = targetSize;
  46052. this._kernelBlurXPostprocess.onApplyObservable.add(function (effect) {
  46053. effect.setTexture("textureSampler", _this._shadowMap);
  46054. });
  46055. this._kernelBlurYPostprocess = new _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__["BlurPostProcess"](this._light.name + "KernelBlurY", new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 1), this.blurKernel, 1.0, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE, engine, false, this._textureType);
  46056. this._kernelBlurXPostprocess.autoClear = false;
  46057. this._kernelBlurYPostprocess.autoClear = false;
  46058. if (this._textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  46059. this._kernelBlurXPostprocess.packedFloat = true;
  46060. this._kernelBlurYPostprocess.packedFloat = true;
  46061. }
  46062. this._blurPostProcesses = [this._kernelBlurXPostprocess, this._kernelBlurYPostprocess];
  46063. }
  46064. else {
  46065. this._boxBlurPostprocess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__["PostProcess"](this._light.name + "DepthBoxBlur", "depthBoxBlur", ["screenSize", "boxOffset"], [], 1.0, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE, engine, false, "#define OFFSET " + this._blurBoxOffset, this._textureType);
  46066. this._boxBlurPostprocess.onApplyObservable.add(function (effect) {
  46067. effect.setFloat2("screenSize", targetSize, targetSize);
  46068. effect.setTexture("textureSampler", _this._shadowMap);
  46069. });
  46070. this._boxBlurPostprocess.autoClear = false;
  46071. this._blurPostProcesses = [this._boxBlurPostprocess];
  46072. }
  46073. };
  46074. ShadowGenerator.prototype._renderForShadowMap = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  46075. var index;
  46076. var engine = this._scene.getEngine();
  46077. if (depthOnlySubMeshes.length) {
  46078. engine.setColorWrite(false);
  46079. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  46080. this._renderSubMeshForShadowMap(depthOnlySubMeshes.data[index]);
  46081. }
  46082. engine.setColorWrite(true);
  46083. }
  46084. for (index = 0; index < opaqueSubMeshes.length; index++) {
  46085. this._renderSubMeshForShadowMap(opaqueSubMeshes.data[index]);
  46086. }
  46087. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  46088. this._renderSubMeshForShadowMap(alphaTestSubMeshes.data[index]);
  46089. }
  46090. if (this._transparencyShadow) {
  46091. for (index = 0; index < transparentSubMeshes.length; index++) {
  46092. this._renderSubMeshForShadowMap(transparentSubMeshes.data[index]);
  46093. }
  46094. }
  46095. };
  46096. ShadowGenerator.prototype._renderSubMeshForShadowMap = function (subMesh) {
  46097. var _this = this;
  46098. var mesh = subMesh.getRenderingMesh();
  46099. var scene = this._scene;
  46100. var engine = scene.getEngine();
  46101. var material = subMesh.getMaterial();
  46102. if (!material || subMesh.verticesCount === 0) {
  46103. return;
  46104. }
  46105. // Culling
  46106. engine.setState(material.backFaceCulling);
  46107. // Managing instances
  46108. var batch = mesh._getInstancesRenderList(subMesh._id);
  46109. if (batch.mustReturn) {
  46110. return;
  46111. }
  46112. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  46113. if (this.isReady(subMesh, hardwareInstancedRendering)) {
  46114. engine.enableEffect(this._effect);
  46115. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  46116. this._effect.setFloat3("biasAndScale", this.bias, this.normalBias, this.depthScale);
  46117. this._effect.setMatrix("viewProjection", this.getTransformMatrix());
  46118. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  46119. this._effect.setVector3("lightData", this._cachedDirection);
  46120. }
  46121. else {
  46122. this._effect.setVector3("lightData", this._cachedPosition);
  46123. }
  46124. if (scene.activeCamera) {
  46125. this._effect.setFloat2("depthValues", this.getLight().getDepthMinZ(scene.activeCamera), this.getLight().getDepthMinZ(scene.activeCamera) + this.getLight().getDepthMaxZ(scene.activeCamera));
  46126. }
  46127. // Alpha test
  46128. if (material && material.needAlphaTesting()) {
  46129. var alphaTexture = material.getAlphaTestTexture();
  46130. if (alphaTexture) {
  46131. this._effect.setTexture("diffuseSampler", alphaTexture);
  46132. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix() || this._defaultTextureMatrix);
  46133. }
  46134. }
  46135. // Bones
  46136. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  46137. var skeleton = mesh.skeleton;
  46138. if (skeleton.isUsingTextureForMatrices) {
  46139. var boneTexture = skeleton.getTransformMatrixTexture();
  46140. if (!boneTexture) {
  46141. return;
  46142. }
  46143. this._effect.setTexture("boneSampler", boneTexture);
  46144. this._effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  46145. }
  46146. else {
  46147. this._effect.setMatrices("mBones", skeleton.getTransformMatrices((mesh)));
  46148. }
  46149. }
  46150. // Morph targets
  46151. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effect);
  46152. if (this.forceBackFacesOnly) {
  46153. engine.setState(true, 0, false, true);
  46154. }
  46155. // Observables
  46156. this.onBeforeShadowMapRenderMeshObservable.notifyObservers(mesh);
  46157. this.onBeforeShadowMapRenderObservable.notifyObservers(this._effect);
  46158. // Draw
  46159. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  46160. if (this.forceBackFacesOnly) {
  46161. engine.setState(true, 0, false, false);
  46162. }
  46163. }
  46164. else {
  46165. // Need to reset refresh rate of the shadowMap
  46166. if (this._shadowMap) {
  46167. this._shadowMap.resetRefreshCounter();
  46168. }
  46169. }
  46170. };
  46171. ShadowGenerator.prototype._applyFilterValues = function () {
  46172. if (!this._shadowMap) {
  46173. return;
  46174. }
  46175. if (this.filter === ShadowGenerator.FILTER_NONE || this.filter === ShadowGenerator.FILTER_PCSS) {
  46176. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].NEAREST_SAMPLINGMODE);
  46177. }
  46178. else {
  46179. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  46180. }
  46181. };
  46182. /**
  46183. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  46184. * @param onCompiled Callback triggered at the and of the effects compilation
  46185. * @param options Sets of optional options forcing the compilation with different modes
  46186. */
  46187. ShadowGenerator.prototype.forceCompilation = function (onCompiled, options) {
  46188. var _this = this;
  46189. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ useInstances: false }, options);
  46190. var shadowMap = this.getShadowMap();
  46191. if (!shadowMap) {
  46192. if (onCompiled) {
  46193. onCompiled(this);
  46194. }
  46195. return;
  46196. }
  46197. var renderList = shadowMap.renderList;
  46198. if (!renderList) {
  46199. if (onCompiled) {
  46200. onCompiled(this);
  46201. }
  46202. return;
  46203. }
  46204. var subMeshes = new Array();
  46205. for (var _i = 0, renderList_1 = renderList; _i < renderList_1.length; _i++) {
  46206. var mesh = renderList_1[_i];
  46207. subMeshes.push.apply(subMeshes, mesh.subMeshes);
  46208. }
  46209. if (subMeshes.length === 0) {
  46210. if (onCompiled) {
  46211. onCompiled(this);
  46212. }
  46213. return;
  46214. }
  46215. var currentIndex = 0;
  46216. var checkReady = function () {
  46217. if (!_this._scene || !_this._scene.getEngine()) {
  46218. return;
  46219. }
  46220. while (_this.isReady(subMeshes[currentIndex], localOptions.useInstances)) {
  46221. currentIndex++;
  46222. if (currentIndex >= subMeshes.length) {
  46223. if (onCompiled) {
  46224. onCompiled(_this);
  46225. }
  46226. return;
  46227. }
  46228. }
  46229. setTimeout(checkReady, 16);
  46230. };
  46231. checkReady();
  46232. };
  46233. /**
  46234. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  46235. * @param options Sets of optional options forcing the compilation with different modes
  46236. * @returns A promise that resolves when the compilation completes
  46237. */
  46238. ShadowGenerator.prototype.forceCompilationAsync = function (options) {
  46239. var _this = this;
  46240. return new Promise(function (resolve) {
  46241. _this.forceCompilation(function () {
  46242. resolve();
  46243. }, options);
  46244. });
  46245. };
  46246. /**
  46247. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  46248. * @param subMesh The submesh we want to render in the shadow map
  46249. * @param useInstances Defines wether will draw in the map using instances
  46250. * @returns true if ready otherwise, false
  46251. */
  46252. ShadowGenerator.prototype.isReady = function (subMesh, useInstances) {
  46253. var defines = [];
  46254. if (this._textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  46255. defines.push("#define FLOAT");
  46256. }
  46257. if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  46258. defines.push("#define ESM");
  46259. }
  46260. else if (this.usePercentageCloserFiltering || this.useContactHardeningShadow) {
  46261. defines.push("#define DEPTHTEXTURE");
  46262. }
  46263. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind];
  46264. var mesh = subMesh.getMesh();
  46265. var material = subMesh.getMaterial();
  46266. // Normal bias.
  46267. if (this.normalBias && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  46268. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  46269. defines.push("#define NORMAL");
  46270. if (mesh.nonUniformScaling) {
  46271. defines.push("#define NONUNIFORMSCALING");
  46272. }
  46273. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  46274. defines.push("#define DIRECTIONINLIGHTDATA");
  46275. }
  46276. }
  46277. // Alpha test
  46278. if (material && material.needAlphaTesting()) {
  46279. var alphaTexture = material.getAlphaTestTexture();
  46280. if (alphaTexture) {
  46281. defines.push("#define ALPHATEST");
  46282. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  46283. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  46284. defines.push("#define UV1");
  46285. }
  46286. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  46287. if (alphaTexture.coordinatesIndex === 1) {
  46288. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  46289. defines.push("#define UV2");
  46290. }
  46291. }
  46292. }
  46293. }
  46294. // Bones
  46295. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  46296. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  46297. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  46298. if (mesh.numBoneInfluencers > 4) {
  46299. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  46300. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind);
  46301. }
  46302. var skeleton = mesh.skeleton;
  46303. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  46304. if (skeleton.isUsingTextureForMatrices) {
  46305. defines.push("#define BONETEXTURE");
  46306. }
  46307. else {
  46308. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  46309. }
  46310. }
  46311. else {
  46312. defines.push("#define NUM_BONE_INFLUENCERS 0");
  46313. }
  46314. // Morph targets
  46315. var manager = mesh.morphTargetManager;
  46316. var morphInfluencers = 0;
  46317. if (manager) {
  46318. if (manager.numInfluencers > 0) {
  46319. defines.push("#define MORPHTARGETS");
  46320. morphInfluencers = manager.numInfluencers;
  46321. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  46322. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  46323. }
  46324. }
  46325. // Instances
  46326. if (useInstances) {
  46327. defines.push("#define INSTANCES");
  46328. attribs.push("world0");
  46329. attribs.push("world1");
  46330. attribs.push("world2");
  46331. attribs.push("world3");
  46332. }
  46333. if (this.customShaderOptions) {
  46334. if (this.customShaderOptions.defines) {
  46335. for (var _i = 0, _a = this.customShaderOptions.defines; _i < _a.length; _i++) {
  46336. var define = _a[_i];
  46337. if (defines.indexOf(define) === -1) {
  46338. defines.push(define);
  46339. }
  46340. }
  46341. }
  46342. }
  46343. // Get correct effect
  46344. var join = defines.join("\n");
  46345. if (this._cachedDefines !== join) {
  46346. this._cachedDefines = join;
  46347. var shaderName = "shadowMap";
  46348. var uniforms = ["world", "mBones", "viewProjection", "diffuseMatrix", "lightData", "depthValues", "biasAndScale", "morphTargetInfluences", "boneTextureWidth"];
  46349. var samplers = ["diffuseSampler", "boneSampler"];
  46350. // Custom shader?
  46351. if (this.customShaderOptions) {
  46352. shaderName = this.customShaderOptions.shaderName;
  46353. if (this.customShaderOptions.attributes) {
  46354. for (var _b = 0, _c = this.customShaderOptions.attributes; _b < _c.length; _b++) {
  46355. var attrib = _c[_b];
  46356. if (attribs.indexOf(attrib) === -1) {
  46357. attribs.push(attrib);
  46358. }
  46359. }
  46360. }
  46361. if (this.customShaderOptions.uniforms) {
  46362. for (var _d = 0, _e = this.customShaderOptions.uniforms; _d < _e.length; _d++) {
  46363. var uniform = _e[_d];
  46364. if (uniforms.indexOf(uniform) === -1) {
  46365. uniforms.push(uniform);
  46366. }
  46367. }
  46368. }
  46369. if (this.customShaderOptions.samplers) {
  46370. for (var _f = 0, _g = this.customShaderOptions.samplers; _f < _g.length; _f++) {
  46371. var sampler = _g[_f];
  46372. if (samplers.indexOf(sampler) === -1) {
  46373. samplers.push(sampler);
  46374. }
  46375. }
  46376. }
  46377. }
  46378. this._effect = this._scene.getEngine().createEffect(shaderName, attribs, uniforms, samplers, join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  46379. }
  46380. if (!this._effect.isReady()) {
  46381. return false;
  46382. }
  46383. if (this.useBlurExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  46384. if (!this._blurPostProcesses || !this._blurPostProcesses.length) {
  46385. this._initializeBlurRTTAndPostProcesses();
  46386. }
  46387. }
  46388. if (this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady()) {
  46389. return false;
  46390. }
  46391. if (this._kernelBlurYPostprocess && !this._kernelBlurYPostprocess.isReady()) {
  46392. return false;
  46393. }
  46394. if (this._boxBlurPostprocess && !this._boxBlurPostprocess.isReady()) {
  46395. return false;
  46396. }
  46397. return true;
  46398. };
  46399. /**
  46400. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  46401. * @param defines Defines of the material we want to update
  46402. * @param lightIndex Index of the light in the enabled light list of the material
  46403. */
  46404. ShadowGenerator.prototype.prepareDefines = function (defines, lightIndex) {
  46405. var scene = this._scene;
  46406. var light = this._light;
  46407. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  46408. return;
  46409. }
  46410. defines["SHADOW" + lightIndex] = true;
  46411. if (this.useContactHardeningShadow) {
  46412. defines["SHADOWPCSS" + lightIndex] = true;
  46413. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  46414. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  46415. }
  46416. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  46417. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  46418. }
  46419. // else default to high.
  46420. }
  46421. if (this.usePercentageCloserFiltering) {
  46422. defines["SHADOWPCF" + lightIndex] = true;
  46423. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  46424. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  46425. }
  46426. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  46427. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  46428. }
  46429. // else default to high.
  46430. }
  46431. else if (this.usePoissonSampling) {
  46432. defines["SHADOWPOISSON" + lightIndex] = true;
  46433. }
  46434. else if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  46435. defines["SHADOWESM" + lightIndex] = true;
  46436. }
  46437. else if (this.useCloseExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  46438. defines["SHADOWCLOSEESM" + lightIndex] = true;
  46439. }
  46440. if (light.needCube()) {
  46441. defines["SHADOWCUBE" + lightIndex] = true;
  46442. }
  46443. };
  46444. /**
  46445. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  46446. * defined in the generator but impacting the effect).
  46447. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  46448. * @param effect The effect we are binfing the information for
  46449. */
  46450. ShadowGenerator.prototype.bindShadowLight = function (lightIndex, effect) {
  46451. var light = this._light;
  46452. var scene = this._scene;
  46453. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  46454. return;
  46455. }
  46456. var camera = scene.activeCamera;
  46457. if (!camera) {
  46458. return;
  46459. }
  46460. var shadowMap = this.getShadowMap();
  46461. if (!shadowMap) {
  46462. return;
  46463. }
  46464. if (!light.needCube()) {
  46465. effect.setMatrix("lightMatrix" + lightIndex, this.getTransformMatrix());
  46466. }
  46467. // Only PCF uses depth stencil texture.
  46468. if (this._filter === ShadowGenerator.FILTER_PCF) {
  46469. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  46470. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), shadowMap.getSize().width, 1 / shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  46471. }
  46472. else if (this._filter === ShadowGenerator.FILTER_PCSS) {
  46473. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  46474. effect.setTexture("depthSampler" + lightIndex, this.getShadowMapForRendering());
  46475. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / shadowMap.getSize().width, this._contactHardeningLightSizeUVRatio * shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  46476. }
  46477. else {
  46478. effect.setTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  46479. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / shadowMap.getSize().width, this.depthScale, this.frustumEdgeFalloff, lightIndex);
  46480. }
  46481. light._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(camera), this.getLight().getDepthMinZ(camera) + this.getLight().getDepthMaxZ(camera), lightIndex);
  46482. };
  46483. /**
  46484. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  46485. * (eq to shadow prjection matrix * light transform matrix)
  46486. * @returns The transform matrix used to create the shadow map
  46487. */
  46488. ShadowGenerator.prototype.getTransformMatrix = function () {
  46489. var scene = this._scene;
  46490. if (this._currentRenderID === scene.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex) {
  46491. return this._transformMatrix;
  46492. }
  46493. this._currentRenderID = scene.getRenderId();
  46494. this._currentFaceIndexCache = this._currentFaceIndex;
  46495. var lightPosition = this._light.position;
  46496. if (this._light.computeTransformedInformation()) {
  46497. lightPosition = this._light.transformedPosition;
  46498. }
  46499. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection);
  46500. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this._lightDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up())) === 1.0) {
  46501. this._lightDirection.z = 0.0000000000001; // Required to avoid perfectly perpendicular light
  46502. }
  46503. if (this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
  46504. this._cachedPosition.copyFrom(lightPosition);
  46505. this._cachedDirection.copyFrom(this._lightDirection);
  46506. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].LookAtLHToRef(lightPosition, lightPosition.add(this._lightDirection), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up(), this._viewMatrix);
  46507. var shadowMap = this.getShadowMap();
  46508. if (shadowMap) {
  46509. var renderList = shadowMap.renderList;
  46510. if (renderList) {
  46511. this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, renderList);
  46512. }
  46513. }
  46514. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  46515. }
  46516. return this._transformMatrix;
  46517. };
  46518. /**
  46519. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  46520. * Cube and 2D textures for instance.
  46521. */
  46522. ShadowGenerator.prototype.recreateShadowMap = function () {
  46523. var shadowMap = this._shadowMap;
  46524. if (!shadowMap) {
  46525. return;
  46526. }
  46527. // Track render list.
  46528. var renderList = shadowMap.renderList;
  46529. // Clean up existing data.
  46530. this._disposeRTTandPostProcesses();
  46531. // Reinitializes.
  46532. this._initializeGenerator();
  46533. // Reaffect the filter to ensure a correct fallback if necessary.
  46534. this.filter = this.filter;
  46535. // Reaffect the filter.
  46536. this._applyFilterValues();
  46537. // Reaffect Render List.
  46538. this._shadowMap.renderList = renderList;
  46539. };
  46540. ShadowGenerator.prototype._disposeBlurPostProcesses = function () {
  46541. if (this._shadowMap2) {
  46542. this._shadowMap2.dispose();
  46543. this._shadowMap2 = null;
  46544. }
  46545. if (this._boxBlurPostprocess) {
  46546. this._boxBlurPostprocess.dispose();
  46547. this._boxBlurPostprocess = null;
  46548. }
  46549. if (this._kernelBlurXPostprocess) {
  46550. this._kernelBlurXPostprocess.dispose();
  46551. this._kernelBlurXPostprocess = null;
  46552. }
  46553. if (this._kernelBlurYPostprocess) {
  46554. this._kernelBlurYPostprocess.dispose();
  46555. this._kernelBlurYPostprocess = null;
  46556. }
  46557. this._blurPostProcesses = [];
  46558. };
  46559. ShadowGenerator.prototype._disposeRTTandPostProcesses = function () {
  46560. if (this._shadowMap) {
  46561. this._shadowMap.dispose();
  46562. this._shadowMap = null;
  46563. }
  46564. this._disposeBlurPostProcesses();
  46565. };
  46566. /**
  46567. * Disposes the ShadowGenerator.
  46568. * Returns nothing.
  46569. */
  46570. ShadowGenerator.prototype.dispose = function () {
  46571. this._disposeRTTandPostProcesses();
  46572. if (this._light) {
  46573. this._light._shadowGenerator = null;
  46574. this._light._markMeshesAsLightDirty();
  46575. }
  46576. };
  46577. /**
  46578. * Serializes the shadow generator setup to a json object.
  46579. * @returns The serialized JSON object
  46580. */
  46581. ShadowGenerator.prototype.serialize = function () {
  46582. var serializationObject = {};
  46583. var shadowMap = this.getShadowMap();
  46584. if (!shadowMap) {
  46585. return serializationObject;
  46586. }
  46587. serializationObject.lightId = this._light.id;
  46588. serializationObject.mapSize = shadowMap.getRenderSize();
  46589. serializationObject.useExponentialShadowMap = this.useExponentialShadowMap;
  46590. serializationObject.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap;
  46591. serializationObject.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  46592. serializationObject.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  46593. serializationObject.usePoissonSampling = this.usePoissonSampling;
  46594. serializationObject.forceBackFacesOnly = this.forceBackFacesOnly;
  46595. serializationObject.depthScale = this.depthScale;
  46596. serializationObject.darkness = this.getDarkness();
  46597. serializationObject.blurBoxOffset = this.blurBoxOffset;
  46598. serializationObject.blurKernel = this.blurKernel;
  46599. serializationObject.blurScale = this.blurScale;
  46600. serializationObject.useKernelBlur = this.useKernelBlur;
  46601. serializationObject.transparencyShadow = this._transparencyShadow;
  46602. serializationObject.frustumEdgeFalloff = this.frustumEdgeFalloff;
  46603. serializationObject.bias = this.bias;
  46604. serializationObject.normalBias = this.normalBias;
  46605. serializationObject.usePercentageCloserFiltering = this.usePercentageCloserFiltering;
  46606. serializationObject.useContactHardeningShadow = this.useContactHardeningShadow;
  46607. serializationObject.filteringQuality = this.filteringQuality;
  46608. serializationObject.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio;
  46609. serializationObject.renderList = [];
  46610. if (shadowMap.renderList) {
  46611. for (var meshIndex = 0; meshIndex < shadowMap.renderList.length; meshIndex++) {
  46612. var mesh = shadowMap.renderList[meshIndex];
  46613. serializationObject.renderList.push(mesh.id);
  46614. }
  46615. }
  46616. return serializationObject;
  46617. };
  46618. /**
  46619. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  46620. * @param parsedShadowGenerator The JSON object to parse
  46621. * @param scene The scene to create the shadow map for
  46622. * @returns The parsed shadow generator
  46623. */
  46624. ShadowGenerator.Parse = function (parsedShadowGenerator, scene) {
  46625. var light = scene.getLightByID(parsedShadowGenerator.lightId);
  46626. var shadowGenerator = new ShadowGenerator(parsedShadowGenerator.mapSize, light);
  46627. var shadowMap = shadowGenerator.getShadowMap();
  46628. for (var meshIndex = 0; meshIndex < parsedShadowGenerator.renderList.length; meshIndex++) {
  46629. var meshes = scene.getMeshesByID(parsedShadowGenerator.renderList[meshIndex]);
  46630. meshes.forEach(function (mesh) {
  46631. if (!shadowMap) {
  46632. return;
  46633. }
  46634. if (!shadowMap.renderList) {
  46635. shadowMap.renderList = [];
  46636. }
  46637. shadowMap.renderList.push(mesh);
  46638. });
  46639. }
  46640. if (parsedShadowGenerator.usePoissonSampling) {
  46641. shadowGenerator.usePoissonSampling = true;
  46642. }
  46643. else if (parsedShadowGenerator.useExponentialShadowMap) {
  46644. shadowGenerator.useExponentialShadowMap = true;
  46645. }
  46646. else if (parsedShadowGenerator.useBlurExponentialShadowMap) {
  46647. shadowGenerator.useBlurExponentialShadowMap = true;
  46648. }
  46649. else if (parsedShadowGenerator.useCloseExponentialShadowMap) {
  46650. shadowGenerator.useCloseExponentialShadowMap = true;
  46651. }
  46652. else if (parsedShadowGenerator.useBlurCloseExponentialShadowMap) {
  46653. shadowGenerator.useBlurCloseExponentialShadowMap = true;
  46654. }
  46655. else if (parsedShadowGenerator.usePercentageCloserFiltering) {
  46656. shadowGenerator.usePercentageCloserFiltering = true;
  46657. }
  46658. else if (parsedShadowGenerator.useContactHardeningShadow) {
  46659. shadowGenerator.useContactHardeningShadow = true;
  46660. }
  46661. if (parsedShadowGenerator.filteringQuality) {
  46662. shadowGenerator.filteringQuality = parsedShadowGenerator.filteringQuality;
  46663. }
  46664. if (parsedShadowGenerator.contactHardeningLightSizeUVRatio) {
  46665. shadowGenerator.contactHardeningLightSizeUVRatio = parsedShadowGenerator.contactHardeningLightSizeUVRatio;
  46666. }
  46667. // Backward compat
  46668. else if (parsedShadowGenerator.useVarianceShadowMap) {
  46669. shadowGenerator.useExponentialShadowMap = true;
  46670. }
  46671. else if (parsedShadowGenerator.useBlurVarianceShadowMap) {
  46672. shadowGenerator.useBlurExponentialShadowMap = true;
  46673. }
  46674. if (parsedShadowGenerator.depthScale) {
  46675. shadowGenerator.depthScale = parsedShadowGenerator.depthScale;
  46676. }
  46677. if (parsedShadowGenerator.blurScale) {
  46678. shadowGenerator.blurScale = parsedShadowGenerator.blurScale;
  46679. }
  46680. if (parsedShadowGenerator.blurBoxOffset) {
  46681. shadowGenerator.blurBoxOffset = parsedShadowGenerator.blurBoxOffset;
  46682. }
  46683. if (parsedShadowGenerator.useKernelBlur) {
  46684. shadowGenerator.useKernelBlur = parsedShadowGenerator.useKernelBlur;
  46685. }
  46686. if (parsedShadowGenerator.blurKernel) {
  46687. shadowGenerator.blurKernel = parsedShadowGenerator.blurKernel;
  46688. }
  46689. if (parsedShadowGenerator.bias !== undefined) {
  46690. shadowGenerator.bias = parsedShadowGenerator.bias;
  46691. }
  46692. if (parsedShadowGenerator.normalBias !== undefined) {
  46693. shadowGenerator.normalBias = parsedShadowGenerator.normalBias;
  46694. }
  46695. if (parsedShadowGenerator.frustumEdgeFalloff !== undefined) {
  46696. shadowGenerator.frustumEdgeFalloff = parsedShadowGenerator.frustumEdgeFalloff;
  46697. }
  46698. if (parsedShadowGenerator.darkness) {
  46699. shadowGenerator.setDarkness(parsedShadowGenerator.darkness);
  46700. }
  46701. if (parsedShadowGenerator.transparencyShadow) {
  46702. shadowGenerator.setTransparencyShadow(true);
  46703. }
  46704. shadowGenerator.forceBackFacesOnly = parsedShadowGenerator.forceBackFacesOnly;
  46705. return shadowGenerator;
  46706. };
  46707. /**
  46708. * Shadow generator mode None: no filtering applied.
  46709. */
  46710. ShadowGenerator.FILTER_NONE = 0;
  46711. /**
  46712. * Shadow generator mode ESM: Exponential Shadow Mapping.
  46713. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46714. */
  46715. ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP = 1;
  46716. /**
  46717. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  46718. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  46719. */
  46720. ShadowGenerator.FILTER_POISSONSAMPLING = 2;
  46721. /**
  46722. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  46723. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46724. */
  46725. ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP = 3;
  46726. /**
  46727. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  46728. * edge artifacts on steep falloff.
  46729. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46730. */
  46731. ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP = 4;
  46732. /**
  46733. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  46734. * edge artifacts on steep falloff.
  46735. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46736. */
  46737. ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP = 5;
  46738. /**
  46739. * Shadow generator mode PCF: Percentage Closer Filtering
  46740. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  46741. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  46742. */
  46743. ShadowGenerator.FILTER_PCF = 6;
  46744. /**
  46745. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  46746. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  46747. * Contact Hardening
  46748. */
  46749. ShadowGenerator.FILTER_PCSS = 7;
  46750. /**
  46751. * Reserved for PCF and PCSS
  46752. * Highest Quality.
  46753. *
  46754. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  46755. *
  46756. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  46757. */
  46758. ShadowGenerator.QUALITY_HIGH = 0;
  46759. /**
  46760. * Reserved for PCF and PCSS
  46761. * Good tradeoff for quality/perf cross devices
  46762. *
  46763. * Execute PCF on a 3*3 kernel.
  46764. *
  46765. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  46766. */
  46767. ShadowGenerator.QUALITY_MEDIUM = 1;
  46768. /**
  46769. * Reserved for PCF and PCSS
  46770. * The lowest quality but the fastest.
  46771. *
  46772. * Execute PCF on a 1*1 kernel.
  46773. *
  46774. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  46775. */
  46776. ShadowGenerator.QUALITY_LOW = 2;
  46777. /** @hidden */
  46778. ShadowGenerator._SceneComponentInitialization = function (_) {
  46779. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__["_DevTools"].WarnImport("ShadowGeneratorSceneComponent");
  46780. };
  46781. return ShadowGenerator;
  46782. }());
  46783. /***/ }),
  46784. /***/ "./Lights/Shadows/shadowGeneratorSceneComponent.ts":
  46785. /*!*********************************************************!*\
  46786. !*** ./Lights/Shadows/shadowGeneratorSceneComponent.ts ***!
  46787. \*********************************************************/
  46788. /*! exports provided: ShadowGeneratorSceneComponent */
  46789. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46790. "use strict";
  46791. __webpack_require__.r(__webpack_exports__);
  46792. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return ShadowGeneratorSceneComponent; });
  46793. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  46794. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  46795. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  46796. // Adds the parser to the scene parsers.
  46797. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR, function (parsedData, scene) {
  46798. // Shadows
  46799. if (parsedData.shadowGenerators !== undefined && parsedData.shadowGenerators !== null) {
  46800. for (var index = 0, cache = parsedData.shadowGenerators.length; index < cache; index++) {
  46801. var parsedShadowGenerator = parsedData.shadowGenerators[index];
  46802. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"].Parse(parsedShadowGenerator, scene);
  46803. // SG would be available on their associated lights
  46804. }
  46805. }
  46806. });
  46807. /**
  46808. * Defines the shadow generator component responsible to manage any shadow generators
  46809. * in a given scene.
  46810. */
  46811. var ShadowGeneratorSceneComponent = /** @class */ (function () {
  46812. /**
  46813. * Creates a new instance of the component for the given scene
  46814. * @param scene Defines the scene to register the component in
  46815. */
  46816. function ShadowGeneratorSceneComponent(scene) {
  46817. /**
  46818. * The component name helpfull to identify the component in the list of scene components.
  46819. */
  46820. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR;
  46821. this.scene = scene;
  46822. }
  46823. /**
  46824. * Registers the component in a given scene
  46825. */
  46826. ShadowGeneratorSceneComponent.prototype.register = function () {
  46827. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_SHADOWGENERATOR, this, this._gatherRenderTargets);
  46828. };
  46829. /**
  46830. * Rebuilds the elements related to this component in case of
  46831. * context lost for instance.
  46832. */
  46833. ShadowGeneratorSceneComponent.prototype.rebuild = function () {
  46834. // Nothing To Do Here.
  46835. };
  46836. /**
  46837. * Serializes the component data to the specified json object
  46838. * @param serializationObject The object to serialize to
  46839. */
  46840. ShadowGeneratorSceneComponent.prototype.serialize = function (serializationObject) {
  46841. // Shadows
  46842. serializationObject.shadowGenerators = [];
  46843. var lights = this.scene.lights;
  46844. for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) {
  46845. var light = lights_1[_i];
  46846. var shadowGenerator = light.getShadowGenerator();
  46847. if (shadowGenerator) {
  46848. serializationObject.shadowGenerators.push(shadowGenerator.serialize());
  46849. }
  46850. }
  46851. };
  46852. /**
  46853. * Adds all the element from the container to the scene
  46854. * @param container the container holding the elements
  46855. */
  46856. ShadowGeneratorSceneComponent.prototype.addFromContainer = function (container) {
  46857. // Nothing To Do Here. (directly attached to a light)
  46858. };
  46859. /**
  46860. * Removes all the elements in the container from the scene
  46861. * @param container contains the elements to remove
  46862. * @param dispose if the removed element should be disposed (default: false)
  46863. */
  46864. ShadowGeneratorSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  46865. // Nothing To Do Here. (directly attached to a light)
  46866. };
  46867. /**
  46868. * Rebuilds the elements related to this component in case of
  46869. * context lost for instance.
  46870. */
  46871. ShadowGeneratorSceneComponent.prototype.dispose = function () {
  46872. // Nothing To Do Here.
  46873. };
  46874. ShadowGeneratorSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  46875. // Shadows
  46876. var scene = this.scene;
  46877. if (this.scene.shadowsEnabled) {
  46878. for (var lightIndex = 0; lightIndex < scene.lights.length; lightIndex++) {
  46879. var light = scene.lights[lightIndex];
  46880. var shadowGenerator = light.getShadowGenerator();
  46881. if (light.isEnabled() && light.shadowEnabled && shadowGenerator) {
  46882. var shadowMap = (shadowGenerator.getShadowMap());
  46883. if (scene.textures.indexOf(shadowMap) !== -1) {
  46884. renderTargets.push(shadowMap);
  46885. }
  46886. }
  46887. }
  46888. }
  46889. };
  46890. return ShadowGeneratorSceneComponent;
  46891. }());
  46892. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]._SceneComponentInitialization = function (scene) {
  46893. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR);
  46894. if (!component) {
  46895. component = new ShadowGeneratorSceneComponent(scene);
  46896. scene._addComponent(component);
  46897. }
  46898. };
  46899. /***/ }),
  46900. /***/ "./Lights/directionalLight.ts":
  46901. /*!************************************!*\
  46902. !*** ./Lights/directionalLight.ts ***!
  46903. \************************************/
  46904. /*! exports provided: DirectionalLight */
  46905. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46906. "use strict";
  46907. __webpack_require__.r(__webpack_exports__);
  46908. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return DirectionalLight; });
  46909. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46910. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46911. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46912. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46913. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46914. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  46915. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_1", function (name, scene) {
  46916. return function () { return new DirectionalLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  46917. });
  46918. /**
  46919. * A directional light is defined by a direction (what a surprise!).
  46920. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46921. * An example of a directional light is when a distance planet is lit by the apparently parallel lines of light from its sun. Light in a downward direction will light the top of an object.
  46922. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46923. */
  46924. var DirectionalLight = /** @class */ (function (_super) {
  46925. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DirectionalLight, _super);
  46926. /**
  46927. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46928. * The directional light is emitted from everywhere in the given direction.
  46929. * It can cast shadows.
  46930. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46931. * @param name The friendly name of the light
  46932. * @param direction The direction of the light
  46933. * @param scene The scene the light belongs to
  46934. */
  46935. function DirectionalLight(name, direction, scene) {
  46936. var _this = _super.call(this, name, scene) || this;
  46937. _this._shadowFrustumSize = 0;
  46938. _this._shadowOrthoScale = 0.1;
  46939. /**
  46940. * Automatically compute the projection matrix to best fit (including all the casters)
  46941. * on each frame.
  46942. */
  46943. _this.autoUpdateExtends = true;
  46944. // Cache
  46945. _this._orthoLeft = Number.MAX_VALUE;
  46946. _this._orthoRight = Number.MIN_VALUE;
  46947. _this._orthoTop = Number.MIN_VALUE;
  46948. _this._orthoBottom = Number.MAX_VALUE;
  46949. _this.position = direction.scale(-1.0);
  46950. _this.direction = direction;
  46951. return _this;
  46952. }
  46953. Object.defineProperty(DirectionalLight.prototype, "shadowFrustumSize", {
  46954. /**
  46955. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46956. */
  46957. get: function () {
  46958. return this._shadowFrustumSize;
  46959. },
  46960. /**
  46961. * Specifies a fix frustum size for the shadow generation.
  46962. */
  46963. set: function (value) {
  46964. this._shadowFrustumSize = value;
  46965. this.forceProjectionMatrixCompute();
  46966. },
  46967. enumerable: true,
  46968. configurable: true
  46969. });
  46970. Object.defineProperty(DirectionalLight.prototype, "shadowOrthoScale", {
  46971. /**
  46972. * Gets the shadow projection scale against the optimal computed one.
  46973. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46974. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46975. */
  46976. get: function () {
  46977. return this._shadowOrthoScale;
  46978. },
  46979. /**
  46980. * Sets the shadow projection scale against the optimal computed one.
  46981. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46982. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46983. */
  46984. set: function (value) {
  46985. this._shadowOrthoScale = value;
  46986. this.forceProjectionMatrixCompute();
  46987. },
  46988. enumerable: true,
  46989. configurable: true
  46990. });
  46991. /**
  46992. * Returns the string "DirectionalLight".
  46993. * @return The class name
  46994. */
  46995. DirectionalLight.prototype.getClassName = function () {
  46996. return "DirectionalLight";
  46997. };
  46998. /**
  46999. * Returns the integer 1.
  47000. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47001. */
  47002. DirectionalLight.prototype.getTypeID = function () {
  47003. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT;
  47004. };
  47005. /**
  47006. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47007. * Returns the DirectionalLight Shadow projection matrix.
  47008. */
  47009. DirectionalLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47010. if (this.shadowFrustumSize > 0) {
  47011. this._setDefaultFixedFrustumShadowProjectionMatrix(matrix);
  47012. }
  47013. else {
  47014. this._setDefaultAutoExtendShadowProjectionMatrix(matrix, viewMatrix, renderList);
  47015. }
  47016. };
  47017. /**
  47018. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47019. * Returns the DirectionalLight Shadow projection matrix.
  47020. */
  47021. DirectionalLight.prototype._setDefaultFixedFrustumShadowProjectionMatrix = function (matrix) {
  47022. var activeCamera = this.getScene().activeCamera;
  47023. if (!activeCamera) {
  47024. return;
  47025. }
  47026. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].OrthoLHToRef(this.shadowFrustumSize, this.shadowFrustumSize, this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ, this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ, matrix);
  47027. };
  47028. /**
  47029. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47030. * Returns the DirectionalLight Shadow projection matrix.
  47031. */
  47032. DirectionalLight.prototype._setDefaultAutoExtendShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47033. var activeCamera = this.getScene().activeCamera;
  47034. if (!activeCamera) {
  47035. return;
  47036. }
  47037. // Check extends
  47038. if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
  47039. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47040. this._orthoLeft = Number.MAX_VALUE;
  47041. this._orthoRight = Number.MIN_VALUE;
  47042. this._orthoTop = Number.MIN_VALUE;
  47043. this._orthoBottom = Number.MAX_VALUE;
  47044. for (var meshIndex = 0; meshIndex < renderList.length; meshIndex++) {
  47045. var mesh = renderList[meshIndex];
  47046. if (!mesh) {
  47047. continue;
  47048. }
  47049. var boundingInfo = mesh.getBoundingInfo();
  47050. var boundingBox = boundingInfo.boundingBox;
  47051. for (var index = 0; index < boundingBox.vectorsWorld.length; index++) {
  47052. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(boundingBox.vectorsWorld[index], viewMatrix, tempVector3);
  47053. if (tempVector3.x < this._orthoLeft) {
  47054. this._orthoLeft = tempVector3.x;
  47055. }
  47056. if (tempVector3.y < this._orthoBottom) {
  47057. this._orthoBottom = tempVector3.y;
  47058. }
  47059. if (tempVector3.x > this._orthoRight) {
  47060. this._orthoRight = tempVector3.x;
  47061. }
  47062. if (tempVector3.y > this._orthoTop) {
  47063. this._orthoTop = tempVector3.y;
  47064. }
  47065. }
  47066. }
  47067. }
  47068. var xOffset = this._orthoRight - this._orthoLeft;
  47069. var yOffset = this._orthoTop - this._orthoBottom;
  47070. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].OrthoOffCenterLHToRef(this._orthoLeft - xOffset * this.shadowOrthoScale, this._orthoRight + xOffset * this.shadowOrthoScale, this._orthoBottom - yOffset * this.shadowOrthoScale, this._orthoTop + yOffset * this.shadowOrthoScale, this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ, this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ, matrix);
  47071. };
  47072. DirectionalLight.prototype._buildUniformLayout = function () {
  47073. this._uniformBuffer.addUniform("vLightData", 4);
  47074. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  47075. this._uniformBuffer.addUniform("vLightSpecular", 3);
  47076. this._uniformBuffer.addUniform("shadowsInfo", 3);
  47077. this._uniformBuffer.addUniform("depthValues", 2);
  47078. this._uniformBuffer.create();
  47079. };
  47080. /**
  47081. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47082. * @param effect The effect to update
  47083. * @param lightIndex The index of the light in the effect to update
  47084. * @returns The directional light
  47085. */
  47086. DirectionalLight.prototype.transferToEffect = function (effect, lightIndex) {
  47087. if (this.computeTransformedInformation()) {
  47088. this._uniformBuffer.updateFloat4("vLightData", this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z, 1, lightIndex);
  47089. return this;
  47090. }
  47091. this._uniformBuffer.updateFloat4("vLightData", this.direction.x, this.direction.y, this.direction.z, 1, lightIndex);
  47092. return this;
  47093. };
  47094. /**
  47095. * Gets the minZ used for shadow according to both the scene and the light.
  47096. *
  47097. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47098. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47099. * @param activeCamera The camera we are returning the min for
  47100. * @returns the depth min z
  47101. */
  47102. DirectionalLight.prototype.getDepthMinZ = function (activeCamera) {
  47103. return 1;
  47104. };
  47105. /**
  47106. * Gets the maxZ used for shadow according to both the scene and the light.
  47107. *
  47108. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47109. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47110. * @param activeCamera The camera we are returning the max for
  47111. * @returns the depth max z
  47112. */
  47113. DirectionalLight.prototype.getDepthMaxZ = function (activeCamera) {
  47114. return 1;
  47115. };
  47116. /**
  47117. * Prepares the list of defines specific to the light type.
  47118. * @param defines the list of defines
  47119. * @param lightIndex defines the index of the light for the effect
  47120. */
  47121. DirectionalLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  47122. defines["DIRLIGHT" + lightIndex] = true;
  47123. };
  47124. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47125. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47126. ], DirectionalLight.prototype, "shadowFrustumSize", null);
  47127. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47128. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47129. ], DirectionalLight.prototype, "shadowOrthoScale", null);
  47130. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47131. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47132. ], DirectionalLight.prototype, "autoUpdateExtends", void 0);
  47133. return DirectionalLight;
  47134. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  47135. /***/ }),
  47136. /***/ "./Lights/hemisphericLight.ts":
  47137. /*!************************************!*\
  47138. !*** ./Lights/hemisphericLight.ts ***!
  47139. \************************************/
  47140. /*! exports provided: HemisphericLight */
  47141. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47142. "use strict";
  47143. __webpack_require__.r(__webpack_exports__);
  47144. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return HemisphericLight; });
  47145. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47146. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47147. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47148. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  47149. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47150. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_3", function (name, scene) {
  47151. return function () { return new HemisphericLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  47152. });
  47153. /**
  47154. * The HemisphericLight simulates the ambient environment light,
  47155. * so the passed direction is the light reflection direction, not the incoming direction.
  47156. */
  47157. var HemisphericLight = /** @class */ (function (_super) {
  47158. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HemisphericLight, _super);
  47159. /**
  47160. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  47161. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  47162. * The HemisphericLight can't cast shadows.
  47163. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47164. * @param name The friendly name of the light
  47165. * @param direction The direction of the light reflection
  47166. * @param scene The scene the light belongs to
  47167. */
  47168. function HemisphericLight(name, direction, scene) {
  47169. var _this = _super.call(this, name, scene) || this;
  47170. /**
  47171. * The groundColor is the light in the opposite direction to the one specified during creation.
  47172. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  47173. */
  47174. _this.groundColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.0, 0.0, 0.0);
  47175. _this.direction = direction || _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  47176. return _this;
  47177. }
  47178. HemisphericLight.prototype._buildUniformLayout = function () {
  47179. this._uniformBuffer.addUniform("vLightData", 4);
  47180. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  47181. this._uniformBuffer.addUniform("vLightSpecular", 3);
  47182. this._uniformBuffer.addUniform("vLightGround", 3);
  47183. this._uniformBuffer.addUniform("shadowsInfo", 3);
  47184. this._uniformBuffer.addUniform("depthValues", 2);
  47185. this._uniformBuffer.create();
  47186. };
  47187. /**
  47188. * Returns the string "HemisphericLight".
  47189. * @return The class name
  47190. */
  47191. HemisphericLight.prototype.getClassName = function () {
  47192. return "HemisphericLight";
  47193. };
  47194. /**
  47195. * Sets the HemisphericLight direction towards the passed target (Vector3).
  47196. * Returns the updated direction.
  47197. * @param target The target the direction should point to
  47198. * @return The computed direction
  47199. */
  47200. HemisphericLight.prototype.setDirectionToTarget = function (target) {
  47201. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero()));
  47202. return this.direction;
  47203. };
  47204. /**
  47205. * Returns the shadow generator associated to the light.
  47206. * @returns Always null for hemispheric lights because it does not support shadows.
  47207. */
  47208. HemisphericLight.prototype.getShadowGenerator = function () {
  47209. return null;
  47210. };
  47211. /**
  47212. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  47213. * @param effect The effect to update
  47214. * @param lightIndex The index of the light in the effect to update
  47215. * @returns The hemispheric light
  47216. */
  47217. HemisphericLight.prototype.transferToEffect = function (effect, lightIndex) {
  47218. var normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  47219. this._uniformBuffer.updateFloat4("vLightData", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, 0.0, lightIndex);
  47220. this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), lightIndex);
  47221. return this;
  47222. };
  47223. /**
  47224. * Computes the world matrix of the node
  47225. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  47226. * @param useWasUpdatedFlag defines a reserved property
  47227. * @returns the world matrix
  47228. */
  47229. HemisphericLight.prototype.computeWorldMatrix = function () {
  47230. if (!this._worldMatrix) {
  47231. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  47232. }
  47233. return this._worldMatrix;
  47234. };
  47235. /**
  47236. * Returns the integer 3.
  47237. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47238. */
  47239. HemisphericLight.prototype.getTypeID = function () {
  47240. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_HEMISPHERICLIGHT;
  47241. };
  47242. /**
  47243. * Prepares the list of defines specific to the light type.
  47244. * @param defines the list of defines
  47245. * @param lightIndex defines the index of the light for the effect
  47246. */
  47247. HemisphericLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  47248. defines["HEMILIGHT" + lightIndex] = true;
  47249. };
  47250. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47251. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  47252. ], HemisphericLight.prototype, "groundColor", void 0);
  47253. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47254. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  47255. ], HemisphericLight.prototype, "direction", void 0);
  47256. return HemisphericLight;
  47257. }(_light__WEBPACK_IMPORTED_MODULE_4__["Light"]));
  47258. /***/ }),
  47259. /***/ "./Lights/index.ts":
  47260. /*!*************************!*\
  47261. !*** ./Lights/index.ts ***!
  47262. \*************************/
  47263. /*! exports provided: Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, ShadowGenerator, ShadowGeneratorSceneComponent */
  47264. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47265. "use strict";
  47266. __webpack_require__.r(__webpack_exports__);
  47267. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _light__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  47269. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  47270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _shadowLight__WEBPACK_IMPORTED_MODULE_1__["ShadowLight"]; });
  47271. /* harmony import */ var _Shadows_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Shadows/index */ "./Lights/Shadows/index.ts");
  47272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGenerator"]; });
  47273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGeneratorSceneComponent"]; });
  47274. /* harmony import */ var _directionalLight__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./directionalLight */ "./Lights/directionalLight.ts");
  47275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _directionalLight__WEBPACK_IMPORTED_MODULE_3__["DirectionalLight"]; });
  47276. /* harmony import */ var _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hemisphericLight */ "./Lights/hemisphericLight.ts");
  47277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__["HemisphericLight"]; });
  47278. /* harmony import */ var _pointLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./pointLight */ "./Lights/pointLight.ts");
  47279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _pointLight__WEBPACK_IMPORTED_MODULE_5__["PointLight"]; });
  47280. /* harmony import */ var _spotLight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./spotLight */ "./Lights/spotLight.ts");
  47281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _spotLight__WEBPACK_IMPORTED_MODULE_6__["SpotLight"]; });
  47282. /***/ }),
  47283. /***/ "./Lights/light.ts":
  47284. /*!*************************!*\
  47285. !*** ./Lights/light.ts ***!
  47286. \*************************/
  47287. /*! exports provided: Light */
  47288. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47289. "use strict";
  47290. __webpack_require__.r(__webpack_exports__);
  47291. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return Light; });
  47292. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47293. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47294. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47295. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  47296. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  47297. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  47298. /**
  47299. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  47300. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  47301. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  47302. */
  47303. var Light = /** @class */ (function (_super) {
  47304. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Light, _super);
  47305. /**
  47306. * Creates a Light object in the scene.
  47307. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47308. * @param name The firendly name of the light
  47309. * @param scene The scene the light belongs too
  47310. */
  47311. function Light(name, scene) {
  47312. var _this = _super.call(this, name, scene) || this;
  47313. /**
  47314. * Diffuse gives the basic color to an object.
  47315. */
  47316. _this.diffuse = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  47317. /**
  47318. * Specular produces a highlight color on an object.
  47319. * Note: This is note affecting PBR materials.
  47320. */
  47321. _this.specular = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  47322. /**
  47323. * Defines the falloff type for this light. This lets overrriding how punctual light are
  47324. * falling off base on range or angle.
  47325. * This can be set to any values in Light.FALLOFF_x.
  47326. *
  47327. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  47328. * other types of materials.
  47329. */
  47330. _this.falloffType = Light.FALLOFF_DEFAULT;
  47331. /**
  47332. * Strength of the light.
  47333. * Note: By default it is define in the framework own unit.
  47334. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  47335. */
  47336. _this.intensity = 1.0;
  47337. _this._range = Number.MAX_VALUE;
  47338. _this._inverseSquaredRange = 0;
  47339. /**
  47340. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  47341. * of light.
  47342. */
  47343. _this._photometricScale = 1.0;
  47344. _this._intensityMode = Light.INTENSITYMODE_AUTOMATIC;
  47345. _this._radius = 0.00001;
  47346. /**
  47347. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  47348. * exceeding the number allowed of the materials.
  47349. */
  47350. _this.renderPriority = 0;
  47351. _this._shadowEnabled = true;
  47352. _this._excludeWithLayerMask = 0;
  47353. _this._includeOnlyWithLayerMask = 0;
  47354. _this._lightmapMode = 0;
  47355. /**
  47356. * @hidden Internal use only.
  47357. */
  47358. _this._excludedMeshesIds = new Array();
  47359. /**
  47360. * @hidden Internal use only.
  47361. */
  47362. _this._includedOnlyMeshesIds = new Array();
  47363. /** @hidden */
  47364. _this._isLight = true;
  47365. _this.getScene().addLight(_this);
  47366. _this._uniformBuffer = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__["UniformBuffer"](_this.getScene().getEngine());
  47367. _this._buildUniformLayout();
  47368. _this.includedOnlyMeshes = new Array();
  47369. _this.excludedMeshes = new Array();
  47370. _this._resyncMeshes();
  47371. return _this;
  47372. }
  47373. Object.defineProperty(Light.prototype, "range", {
  47374. /**
  47375. * Defines how far from the source the light is impacting in scene units.
  47376. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  47377. */
  47378. get: function () {
  47379. return this._range;
  47380. },
  47381. /**
  47382. * Defines how far from the source the light is impacting in scene units.
  47383. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  47384. */
  47385. set: function (value) {
  47386. this._range = value;
  47387. this._inverseSquaredRange = 1.0 / (this.range * this.range);
  47388. },
  47389. enumerable: true,
  47390. configurable: true
  47391. });
  47392. Object.defineProperty(Light.prototype, "intensityMode", {
  47393. /**
  47394. * Gets the photometric scale used to interpret the intensity.
  47395. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  47396. */
  47397. get: function () {
  47398. return this._intensityMode;
  47399. },
  47400. /**
  47401. * Sets the photometric scale used to interpret the intensity.
  47402. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  47403. */
  47404. set: function (value) {
  47405. this._intensityMode = value;
  47406. this._computePhotometricScale();
  47407. },
  47408. enumerable: true,
  47409. configurable: true
  47410. });
  47411. Object.defineProperty(Light.prototype, "radius", {
  47412. /**
  47413. * Gets the light radius used by PBR Materials to simulate soft area lights.
  47414. */
  47415. get: function () {
  47416. return this._radius;
  47417. },
  47418. /**
  47419. * sets the light radius used by PBR Materials to simulate soft area lights.
  47420. */
  47421. set: function (value) {
  47422. this._radius = value;
  47423. this._computePhotometricScale();
  47424. },
  47425. enumerable: true,
  47426. configurable: true
  47427. });
  47428. Object.defineProperty(Light.prototype, "shadowEnabled", {
  47429. /**
  47430. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  47431. * the current shadow generator.
  47432. */
  47433. get: function () {
  47434. return this._shadowEnabled;
  47435. },
  47436. /**
  47437. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  47438. * the current shadow generator.
  47439. */
  47440. set: function (value) {
  47441. if (this._shadowEnabled === value) {
  47442. return;
  47443. }
  47444. this._shadowEnabled = value;
  47445. this._markMeshesAsLightDirty();
  47446. },
  47447. enumerable: true,
  47448. configurable: true
  47449. });
  47450. Object.defineProperty(Light.prototype, "includedOnlyMeshes", {
  47451. /**
  47452. * Gets the only meshes impacted by this light.
  47453. */
  47454. get: function () {
  47455. return this._includedOnlyMeshes;
  47456. },
  47457. /**
  47458. * Sets the only meshes impacted by this light.
  47459. */
  47460. set: function (value) {
  47461. this._includedOnlyMeshes = value;
  47462. this._hookArrayForIncludedOnly(value);
  47463. },
  47464. enumerable: true,
  47465. configurable: true
  47466. });
  47467. Object.defineProperty(Light.prototype, "excludedMeshes", {
  47468. /**
  47469. * Gets the meshes not impacted by this light.
  47470. */
  47471. get: function () {
  47472. return this._excludedMeshes;
  47473. },
  47474. /**
  47475. * Sets the meshes not impacted by this light.
  47476. */
  47477. set: function (value) {
  47478. this._excludedMeshes = value;
  47479. this._hookArrayForExcluded(value);
  47480. },
  47481. enumerable: true,
  47482. configurable: true
  47483. });
  47484. Object.defineProperty(Light.prototype, "excludeWithLayerMask", {
  47485. /**
  47486. * Gets the layer id use to find what meshes are not impacted by the light.
  47487. * Inactive if 0
  47488. */
  47489. get: function () {
  47490. return this._excludeWithLayerMask;
  47491. },
  47492. /**
  47493. * Sets the layer id use to find what meshes are not impacted by the light.
  47494. * Inactive if 0
  47495. */
  47496. set: function (value) {
  47497. this._excludeWithLayerMask = value;
  47498. this._resyncMeshes();
  47499. },
  47500. enumerable: true,
  47501. configurable: true
  47502. });
  47503. Object.defineProperty(Light.prototype, "includeOnlyWithLayerMask", {
  47504. /**
  47505. * Gets the layer id use to find what meshes are impacted by the light.
  47506. * Inactive if 0
  47507. */
  47508. get: function () {
  47509. return this._includeOnlyWithLayerMask;
  47510. },
  47511. /**
  47512. * Sets the layer id use to find what meshes are impacted by the light.
  47513. * Inactive if 0
  47514. */
  47515. set: function (value) {
  47516. this._includeOnlyWithLayerMask = value;
  47517. this._resyncMeshes();
  47518. },
  47519. enumerable: true,
  47520. configurable: true
  47521. });
  47522. Object.defineProperty(Light.prototype, "lightmapMode", {
  47523. /**
  47524. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  47525. */
  47526. get: function () {
  47527. return this._lightmapMode;
  47528. },
  47529. /**
  47530. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  47531. */
  47532. set: function (value) {
  47533. if (this._lightmapMode === value) {
  47534. return;
  47535. }
  47536. this._lightmapMode = value;
  47537. this._markMeshesAsLightDirty();
  47538. },
  47539. enumerable: true,
  47540. configurable: true
  47541. });
  47542. /**
  47543. * Returns the string "Light".
  47544. * @returns the class name
  47545. */
  47546. Light.prototype.getClassName = function () {
  47547. return "Light";
  47548. };
  47549. /**
  47550. * Converts the light information to a readable string for debug purpose.
  47551. * @param fullDetails Supports for multiple levels of logging within scene loading
  47552. * @returns the human readable light info
  47553. */
  47554. Light.prototype.toString = function (fullDetails) {
  47555. var ret = "Name: " + this.name;
  47556. ret += ", type: " + (["Point", "Directional", "Spot", "Hemispheric"])[this.getTypeID()];
  47557. if (this.animations) {
  47558. for (var i = 0; i < this.animations.length; i++) {
  47559. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  47560. }
  47561. }
  47562. if (fullDetails) {
  47563. }
  47564. return ret;
  47565. };
  47566. /** @hidden */
  47567. Light.prototype._syncParentEnabledState = function () {
  47568. _super.prototype._syncParentEnabledState.call(this);
  47569. this._resyncMeshes();
  47570. };
  47571. /**
  47572. * Set the enabled state of this node.
  47573. * @param value - the new enabled state
  47574. */
  47575. Light.prototype.setEnabled = function (value) {
  47576. _super.prototype.setEnabled.call(this, value);
  47577. this._resyncMeshes();
  47578. };
  47579. /**
  47580. * Returns the Light associated shadow generator if any.
  47581. * @return the associated shadow generator.
  47582. */
  47583. Light.prototype.getShadowGenerator = function () {
  47584. return this._shadowGenerator;
  47585. };
  47586. /**
  47587. * Returns a Vector3, the absolute light position in the World.
  47588. * @returns the world space position of the light
  47589. */
  47590. Light.prototype.getAbsolutePosition = function () {
  47591. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47592. };
  47593. /**
  47594. * Specifies if the light will affect the passed mesh.
  47595. * @param mesh The mesh to test against the light
  47596. * @return true the mesh is affected otherwise, false.
  47597. */
  47598. Light.prototype.canAffectMesh = function (mesh) {
  47599. if (!mesh) {
  47600. return true;
  47601. }
  47602. if (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {
  47603. return false;
  47604. }
  47605. if (this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  47606. return false;
  47607. }
  47608. if (this.includeOnlyWithLayerMask !== 0 && (this.includeOnlyWithLayerMask & mesh.layerMask) === 0) {
  47609. return false;
  47610. }
  47611. if (this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & mesh.layerMask) {
  47612. return false;
  47613. }
  47614. return true;
  47615. };
  47616. /**
  47617. * Sort function to order lights for rendering.
  47618. * @param a First Light object to compare to second.
  47619. * @param b Second Light object to compare first.
  47620. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  47621. */
  47622. Light.CompareLightsPriority = function (a, b) {
  47623. //shadow-casting lights have priority over non-shadow-casting lights
  47624. //the renderPrioirty is a secondary sort criterion
  47625. if (a.shadowEnabled !== b.shadowEnabled) {
  47626. return (b.shadowEnabled ? 1 : 0) - (a.shadowEnabled ? 1 : 0);
  47627. }
  47628. return b.renderPriority - a.renderPriority;
  47629. };
  47630. /**
  47631. * Releases resources associated with this node.
  47632. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47633. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47634. */
  47635. Light.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  47636. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  47637. if (this._shadowGenerator) {
  47638. this._shadowGenerator.dispose();
  47639. this._shadowGenerator = null;
  47640. }
  47641. // Animations
  47642. this.getScene().stopAnimation(this);
  47643. // Remove from meshes
  47644. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  47645. var mesh = _a[_i];
  47646. mesh._removeLightSource(this);
  47647. }
  47648. this._uniformBuffer.dispose();
  47649. // Remove from scene
  47650. this.getScene().removeLight(this);
  47651. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  47652. };
  47653. /**
  47654. * Returns the light type ID (integer).
  47655. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47656. */
  47657. Light.prototype.getTypeID = function () {
  47658. return 0;
  47659. };
  47660. /**
  47661. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  47662. * @returns the scaled intensity in intensity mode unit
  47663. */
  47664. Light.prototype.getScaledIntensity = function () {
  47665. return this._photometricScale * this.intensity;
  47666. };
  47667. /**
  47668. * Returns a new Light object, named "name", from the current one.
  47669. * @param name The name of the cloned light
  47670. * @returns the new created light
  47671. */
  47672. Light.prototype.clone = function (name) {
  47673. var constructor = Light.GetConstructorFromName(this.getTypeID(), name, this.getScene());
  47674. if (!constructor) {
  47675. return null;
  47676. }
  47677. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(constructor, this);
  47678. };
  47679. /**
  47680. * Serializes the current light into a Serialization object.
  47681. * @returns the serialized object.
  47682. */
  47683. Light.prototype.serialize = function () {
  47684. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  47685. // Type
  47686. serializationObject.type = this.getTypeID();
  47687. // Parent
  47688. if (this.parent) {
  47689. serializationObject.parentId = this.parent.id;
  47690. }
  47691. // Inclusion / exclusions
  47692. if (this.excludedMeshes.length > 0) {
  47693. serializationObject.excludedMeshesIds = [];
  47694. this.excludedMeshes.forEach(function (mesh) {
  47695. serializationObject.excludedMeshesIds.push(mesh.id);
  47696. });
  47697. }
  47698. if (this.includedOnlyMeshes.length > 0) {
  47699. serializationObject.includedOnlyMeshesIds = [];
  47700. this.includedOnlyMeshes.forEach(function (mesh) {
  47701. serializationObject.includedOnlyMeshesIds.push(mesh.id);
  47702. });
  47703. }
  47704. // Animations
  47705. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  47706. serializationObject.ranges = this.serializeAnimationRanges();
  47707. return serializationObject;
  47708. };
  47709. /**
  47710. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  47711. * This new light is named "name" and added to the passed scene.
  47712. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  47713. * @param name The friendly name of the light
  47714. * @param scene The scene the new light will belong to
  47715. * @returns the constructor function
  47716. */
  47717. Light.GetConstructorFromName = function (type, name, scene) {
  47718. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_3__["Node"].Construct("Light_Type_" + type, name, scene);
  47719. if (constructorFunc) {
  47720. return constructorFunc;
  47721. }
  47722. // Default to no light for none present once.
  47723. return null;
  47724. };
  47725. /**
  47726. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  47727. * @param parsedLight The JSON representation of the light
  47728. * @param scene The scene to create the parsed light in
  47729. * @returns the created light after parsing
  47730. */
  47731. Light.Parse = function (parsedLight, scene) {
  47732. var constructor = Light.GetConstructorFromName(parsedLight.type, parsedLight.name, scene);
  47733. if (!constructor) {
  47734. return null;
  47735. }
  47736. var light = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(constructor, parsedLight, scene);
  47737. // Inclusion / exclusions
  47738. if (parsedLight.excludedMeshesIds) {
  47739. light._excludedMeshesIds = parsedLight.excludedMeshesIds;
  47740. }
  47741. if (parsedLight.includedOnlyMeshesIds) {
  47742. light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;
  47743. }
  47744. // Parent
  47745. if (parsedLight.parentId) {
  47746. light._waitingParentId = parsedLight.parentId;
  47747. }
  47748. // Animations
  47749. if (parsedLight.animations) {
  47750. for (var animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {
  47751. var parsedAnimation = parsedLight.animations[animationIndex];
  47752. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  47753. if (internalClass) {
  47754. light.animations.push(internalClass.Parse(parsedAnimation));
  47755. }
  47756. }
  47757. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].ParseAnimationRanges(light, parsedLight, scene);
  47758. }
  47759. if (parsedLight.autoAnimate) {
  47760. scene.beginAnimation(light, parsedLight.autoAnimateFrom, parsedLight.autoAnimateTo, parsedLight.autoAnimateLoop, parsedLight.autoAnimateSpeed || 1.0);
  47761. }
  47762. return light;
  47763. };
  47764. Light.prototype._hookArrayForExcluded = function (array) {
  47765. var _this = this;
  47766. var oldPush = array.push;
  47767. array.push = function () {
  47768. var items = [];
  47769. for (var _i = 0; _i < arguments.length; _i++) {
  47770. items[_i] = arguments[_i];
  47771. }
  47772. var result = oldPush.apply(array, items);
  47773. for (var _a = 0, items_1 = items; _a < items_1.length; _a++) {
  47774. var item = items_1[_a];
  47775. item._resyncLighSource(_this);
  47776. }
  47777. return result;
  47778. };
  47779. var oldSplice = array.splice;
  47780. array.splice = function (index, deleteCount) {
  47781. var deleted = oldSplice.apply(array, [index, deleteCount]);
  47782. for (var _i = 0, deleted_1 = deleted; _i < deleted_1.length; _i++) {
  47783. var item = deleted_1[_i];
  47784. item._resyncLighSource(_this);
  47785. }
  47786. return deleted;
  47787. };
  47788. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  47789. var item = array_1[_i];
  47790. item._resyncLighSource(this);
  47791. }
  47792. };
  47793. Light.prototype._hookArrayForIncludedOnly = function (array) {
  47794. var _this = this;
  47795. var oldPush = array.push;
  47796. array.push = function () {
  47797. var items = [];
  47798. for (var _i = 0; _i < arguments.length; _i++) {
  47799. items[_i] = arguments[_i];
  47800. }
  47801. var result = oldPush.apply(array, items);
  47802. _this._resyncMeshes();
  47803. return result;
  47804. };
  47805. var oldSplice = array.splice;
  47806. array.splice = function (index, deleteCount) {
  47807. var deleted = oldSplice.apply(array, [index, deleteCount]);
  47808. _this._resyncMeshes();
  47809. return deleted;
  47810. };
  47811. this._resyncMeshes();
  47812. };
  47813. Light.prototype._resyncMeshes = function () {
  47814. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  47815. var mesh = _a[_i];
  47816. mesh._resyncLighSource(this);
  47817. }
  47818. };
  47819. /**
  47820. * Forces the meshes to update their light related information in their rendering used effects
  47821. * @hidden Internal Use Only
  47822. */
  47823. Light.prototype._markMeshesAsLightDirty = function () {
  47824. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  47825. var mesh = _a[_i];
  47826. if (mesh._lightSources.indexOf(this) !== -1) {
  47827. mesh._markSubMeshesAsLightDirty();
  47828. }
  47829. }
  47830. };
  47831. /**
  47832. * Recomputes the cached photometric scale if needed.
  47833. */
  47834. Light.prototype._computePhotometricScale = function () {
  47835. this._photometricScale = this._getPhotometricScale();
  47836. this.getScene().resetCachedMaterial();
  47837. };
  47838. /**
  47839. * Returns the Photometric Scale according to the light type and intensity mode.
  47840. */
  47841. Light.prototype._getPhotometricScale = function () {
  47842. var photometricScale = 0.0;
  47843. var lightTypeID = this.getTypeID();
  47844. //get photometric mode
  47845. var photometricMode = this.intensityMode;
  47846. if (photometricMode === Light.INTENSITYMODE_AUTOMATIC) {
  47847. if (lightTypeID === Light.LIGHTTYPEID_DIRECTIONALLIGHT) {
  47848. photometricMode = Light.INTENSITYMODE_ILLUMINANCE;
  47849. }
  47850. else {
  47851. photometricMode = Light.INTENSITYMODE_LUMINOUSINTENSITY;
  47852. }
  47853. }
  47854. //compute photometric scale
  47855. switch (lightTypeID) {
  47856. case Light.LIGHTTYPEID_POINTLIGHT:
  47857. case Light.LIGHTTYPEID_SPOTLIGHT:
  47858. switch (photometricMode) {
  47859. case Light.INTENSITYMODE_LUMINOUSPOWER:
  47860. photometricScale = 1.0 / (4.0 * Math.PI);
  47861. break;
  47862. case Light.INTENSITYMODE_LUMINOUSINTENSITY:
  47863. photometricScale = 1.0;
  47864. break;
  47865. case Light.INTENSITYMODE_LUMINANCE:
  47866. photometricScale = this.radius * this.radius;
  47867. break;
  47868. }
  47869. break;
  47870. case Light.LIGHTTYPEID_DIRECTIONALLIGHT:
  47871. switch (photometricMode) {
  47872. case Light.INTENSITYMODE_ILLUMINANCE:
  47873. photometricScale = 1.0;
  47874. break;
  47875. case Light.INTENSITYMODE_LUMINANCE:
  47876. // When radius (and therefore solid angle) is non-zero a directional lights brightness can be specified via central (peak) luminance.
  47877. // For a directional light the 'radius' defines the angular radius (in radians) rather than world-space radius (e.g. in metres).
  47878. var apexAngleRadians = this.radius;
  47879. // Impose a minimum light angular size to avoid the light becoming an infinitely small angular light source (i.e. a dirac delta function).
  47880. apexAngleRadians = Math.max(apexAngleRadians, 0.001);
  47881. var solidAngle = 2.0 * Math.PI * (1.0 - Math.cos(apexAngleRadians));
  47882. photometricScale = solidAngle;
  47883. break;
  47884. }
  47885. break;
  47886. case Light.LIGHTTYPEID_HEMISPHERICLIGHT:
  47887. // No fall off in hemisperic light.
  47888. photometricScale = 1.0;
  47889. break;
  47890. }
  47891. return photometricScale;
  47892. };
  47893. /**
  47894. * Reorder the light in the scene according to their defined priority.
  47895. * @hidden Internal Use Only
  47896. */
  47897. Light.prototype._reorderLightsInScene = function () {
  47898. var scene = this.getScene();
  47899. if (this._renderPriority != 0) {
  47900. scene.requireLightSorting = true;
  47901. }
  47902. this.getScene().sortLightsByPriority();
  47903. };
  47904. /**
  47905. * Falloff Default: light is falling off following the material specification:
  47906. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  47907. */
  47908. Light.FALLOFF_DEFAULT = 0;
  47909. /**
  47910. * Falloff Physical: light is falling off following the inverse squared distance law.
  47911. */
  47912. Light.FALLOFF_PHYSICAL = 1;
  47913. /**
  47914. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  47915. * to enhance interoperability with other engines.
  47916. */
  47917. Light.FALLOFF_GLTF = 2;
  47918. /**
  47919. * Falloff Standard: light is falling off like in the standard material
  47920. * to enhance interoperability with other materials.
  47921. */
  47922. Light.FALLOFF_STANDARD = 3;
  47923. //lightmapMode Consts
  47924. /**
  47925. * If every light affecting the material is in this lightmapMode,
  47926. * material.lightmapTexture adds or multiplies
  47927. * (depends on material.useLightmapAsShadowmap)
  47928. * after every other light calculations.
  47929. */
  47930. Light.LIGHTMAP_DEFAULT = 0;
  47931. /**
  47932. * material.lightmapTexture as only diffuse lighting from this light
  47933. * adds only specular lighting from this light
  47934. * adds dynamic shadows
  47935. */
  47936. Light.LIGHTMAP_SPECULAR = 1;
  47937. /**
  47938. * material.lightmapTexture as only lighting
  47939. * no light calculation from this light
  47940. * only adds dynamic shadows from this light
  47941. */
  47942. Light.LIGHTMAP_SHADOWSONLY = 2;
  47943. // Intensity Mode Consts
  47944. /**
  47945. * Each light type uses the default quantity according to its type:
  47946. * point/spot lights use luminous intensity
  47947. * directional lights use illuminance
  47948. */
  47949. Light.INTENSITYMODE_AUTOMATIC = 0;
  47950. /**
  47951. * lumen (lm)
  47952. */
  47953. Light.INTENSITYMODE_LUMINOUSPOWER = 1;
  47954. /**
  47955. * candela (lm/sr)
  47956. */
  47957. Light.INTENSITYMODE_LUMINOUSINTENSITY = 2;
  47958. /**
  47959. * lux (lm/m^2)
  47960. */
  47961. Light.INTENSITYMODE_ILLUMINANCE = 3;
  47962. /**
  47963. * nit (cd/m^2)
  47964. */
  47965. Light.INTENSITYMODE_LUMINANCE = 4;
  47966. // Light types ids const.
  47967. /**
  47968. * Light type const id of the point light.
  47969. */
  47970. Light.LIGHTTYPEID_POINTLIGHT = 0;
  47971. /**
  47972. * Light type const id of the directional light.
  47973. */
  47974. Light.LIGHTTYPEID_DIRECTIONALLIGHT = 1;
  47975. /**
  47976. * Light type const id of the spot light.
  47977. */
  47978. Light.LIGHTTYPEID_SPOTLIGHT = 2;
  47979. /**
  47980. * Light type const id of the hemispheric light.
  47981. */
  47982. Light.LIGHTTYPEID_HEMISPHERICLIGHT = 3;
  47983. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47984. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  47985. ], Light.prototype, "diffuse", void 0);
  47986. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47987. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  47988. ], Light.prototype, "specular", void 0);
  47989. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47990. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47991. ], Light.prototype, "falloffType", void 0);
  47992. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47993. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47994. ], Light.prototype, "intensity", void 0);
  47995. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47996. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47997. ], Light.prototype, "range", null);
  47998. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47999. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48000. ], Light.prototype, "intensityMode", null);
  48001. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48002. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48003. ], Light.prototype, "radius", null);
  48004. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48005. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48006. ], Light.prototype, "_renderPriority", void 0);
  48007. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48008. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_reorderLightsInScene")
  48009. ], Light.prototype, "renderPriority", void 0);
  48010. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48011. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("shadowEnabled")
  48012. ], Light.prototype, "_shadowEnabled", void 0);
  48013. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48014. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("excludeWithLayerMask")
  48015. ], Light.prototype, "_excludeWithLayerMask", void 0);
  48016. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48017. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("includeOnlyWithLayerMask")
  48018. ], Light.prototype, "_includeOnlyWithLayerMask", void 0);
  48019. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48020. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("lightmapMode")
  48021. ], Light.prototype, "_lightmapMode", void 0);
  48022. return Light;
  48023. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  48024. /***/ }),
  48025. /***/ "./Lights/pointLight.ts":
  48026. /*!******************************!*\
  48027. !*** ./Lights/pointLight.ts ***!
  48028. \******************************/
  48029. /*! exports provided: PointLight */
  48030. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48031. "use strict";
  48032. __webpack_require__.r(__webpack_exports__);
  48033. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return PointLight; });
  48034. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  48035. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  48036. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  48037. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  48038. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  48039. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  48040. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_0", function (name, scene) {
  48041. return function () { return new PointLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  48042. });
  48043. /**
  48044. * A point light is a light defined by an unique point in world space.
  48045. * The light is emitted in every direction from this point.
  48046. * A good example of a point light is a standard light bulb.
  48047. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48048. */
  48049. var PointLight = /** @class */ (function (_super) {
  48050. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointLight, _super);
  48051. /**
  48052. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48053. * A PointLight emits the light in every direction.
  48054. * It can cast shadows.
  48055. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48056. * ```javascript
  48057. * var pointLight = new PointLight("pl", camera.position, scene);
  48058. * ```
  48059. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48060. * @param name The light friendly name
  48061. * @param position The position of the point light in the scene
  48062. * @param scene The scene the lights belongs to
  48063. */
  48064. function PointLight(name, position, scene) {
  48065. var _this = _super.call(this, name, scene) || this;
  48066. _this._shadowAngle = Math.PI / 2;
  48067. _this.position = position;
  48068. return _this;
  48069. }
  48070. Object.defineProperty(PointLight.prototype, "shadowAngle", {
  48071. /**
  48072. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48073. * This specifies what angle the shadow will use to be created.
  48074. *
  48075. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48076. */
  48077. get: function () {
  48078. return this._shadowAngle;
  48079. },
  48080. /**
  48081. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48082. * This specifies what angle the shadow will use to be created.
  48083. *
  48084. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48085. */
  48086. set: function (value) {
  48087. this._shadowAngle = value;
  48088. this.forceProjectionMatrixCompute();
  48089. },
  48090. enumerable: true,
  48091. configurable: true
  48092. });
  48093. Object.defineProperty(PointLight.prototype, "direction", {
  48094. /**
  48095. * Gets the direction if it has been set.
  48096. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48097. */
  48098. get: function () {
  48099. return this._direction;
  48100. },
  48101. /**
  48102. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48103. */
  48104. set: function (value) {
  48105. var previousNeedCube = this.needCube();
  48106. this._direction = value;
  48107. if (this.needCube() !== previousNeedCube && this._shadowGenerator) {
  48108. this._shadowGenerator.recreateShadowMap();
  48109. }
  48110. },
  48111. enumerable: true,
  48112. configurable: true
  48113. });
  48114. /**
  48115. * Returns the string "PointLight"
  48116. * @returns the class name
  48117. */
  48118. PointLight.prototype.getClassName = function () {
  48119. return "PointLight";
  48120. };
  48121. /**
  48122. * Returns the integer 0.
  48123. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48124. */
  48125. PointLight.prototype.getTypeID = function () {
  48126. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_POINTLIGHT;
  48127. };
  48128. /**
  48129. * Specifies wether or not the shadowmap should be a cube texture.
  48130. * @returns true if the shadowmap needs to be a cube texture.
  48131. */
  48132. PointLight.prototype.needCube = function () {
  48133. return !this.direction;
  48134. };
  48135. /**
  48136. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48137. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48138. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48139. */
  48140. PointLight.prototype.getShadowDirection = function (faceIndex) {
  48141. if (this.direction) {
  48142. return _super.prototype.getShadowDirection.call(this, faceIndex);
  48143. }
  48144. else {
  48145. switch (faceIndex) {
  48146. case 0:
  48147. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1.0, 0.0, 0.0);
  48148. case 1:
  48149. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](-1.0, 0.0, 0.0);
  48150. case 2:
  48151. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, -1.0, 0.0);
  48152. case 3:
  48153. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 1.0, 0.0);
  48154. case 4:
  48155. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, 1.0);
  48156. case 5:
  48157. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, -1.0);
  48158. }
  48159. }
  48160. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  48161. };
  48162. /**
  48163. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48164. * - fov = PI / 2
  48165. * - aspect ratio : 1.0
  48166. * - z-near and far equal to the active camera minZ and maxZ.
  48167. * Returns the PointLight.
  48168. */
  48169. PointLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  48170. var activeCamera = this.getScene().activeCamera;
  48171. if (!activeCamera) {
  48172. return;
  48173. }
  48174. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(this.shadowAngle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  48175. };
  48176. PointLight.prototype._buildUniformLayout = function () {
  48177. this._uniformBuffer.addUniform("vLightData", 4);
  48178. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  48179. this._uniformBuffer.addUniform("vLightSpecular", 3);
  48180. this._uniformBuffer.addUniform("vLightFalloff", 4);
  48181. this._uniformBuffer.addUniform("shadowsInfo", 3);
  48182. this._uniformBuffer.addUniform("depthValues", 2);
  48183. this._uniformBuffer.create();
  48184. };
  48185. /**
  48186. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48187. * @param effect The effect to update
  48188. * @param lightIndex The index of the light in the effect to update
  48189. * @returns The point light
  48190. */
  48191. PointLight.prototype.transferToEffect = function (effect, lightIndex) {
  48192. if (this.computeTransformedInformation()) {
  48193. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0.0, lightIndex);
  48194. }
  48195. else {
  48196. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, 0, lightIndex);
  48197. }
  48198. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, 0, 0, lightIndex);
  48199. return this;
  48200. };
  48201. /**
  48202. * Prepares the list of defines specific to the light type.
  48203. * @param defines the list of defines
  48204. * @param lightIndex defines the index of the light for the effect
  48205. */
  48206. PointLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  48207. defines["POINTLIGHT" + lightIndex] = true;
  48208. };
  48209. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48210. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48211. ], PointLight.prototype, "shadowAngle", null);
  48212. return PointLight;
  48213. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  48214. /***/ }),
  48215. /***/ "./Lights/shadowLight.ts":
  48216. /*!*******************************!*\
  48217. !*** ./Lights/shadowLight.ts ***!
  48218. \*******************************/
  48219. /*! exports provided: ShadowLight */
  48220. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48221. "use strict";
  48222. __webpack_require__.r(__webpack_exports__);
  48223. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return ShadowLight; });
  48224. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  48225. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  48226. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  48227. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  48228. /**
  48229. * Base implementation IShadowLight
  48230. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  48231. */
  48232. var ShadowLight = /** @class */ (function (_super) {
  48233. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowLight, _super);
  48234. function ShadowLight() {
  48235. var _this = _super !== null && _super.apply(this, arguments) || this;
  48236. _this._needProjectionMatrixCompute = true;
  48237. return _this;
  48238. }
  48239. ShadowLight.prototype._setPosition = function (value) {
  48240. this._position = value;
  48241. };
  48242. Object.defineProperty(ShadowLight.prototype, "position", {
  48243. /**
  48244. * Sets the position the shadow will be casted from. Also use as the light position for both
  48245. * point and spot lights.
  48246. */
  48247. get: function () {
  48248. return this._position;
  48249. },
  48250. /**
  48251. * Sets the position the shadow will be casted from. Also use as the light position for both
  48252. * point and spot lights.
  48253. */
  48254. set: function (value) {
  48255. this._setPosition(value);
  48256. },
  48257. enumerable: true,
  48258. configurable: true
  48259. });
  48260. ShadowLight.prototype._setDirection = function (value) {
  48261. this._direction = value;
  48262. };
  48263. Object.defineProperty(ShadowLight.prototype, "direction", {
  48264. /**
  48265. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  48266. * Also use as the light direction on spot and directional lights.
  48267. */
  48268. get: function () {
  48269. return this._direction;
  48270. },
  48271. /**
  48272. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  48273. * Also use as the light direction on spot and directional lights.
  48274. */
  48275. set: function (value) {
  48276. this._setDirection(value);
  48277. },
  48278. enumerable: true,
  48279. configurable: true
  48280. });
  48281. Object.defineProperty(ShadowLight.prototype, "shadowMinZ", {
  48282. /**
  48283. * Gets the shadow projection clipping minimum z value.
  48284. */
  48285. get: function () {
  48286. return this._shadowMinZ;
  48287. },
  48288. /**
  48289. * Sets the shadow projection clipping minimum z value.
  48290. */
  48291. set: function (value) {
  48292. this._shadowMinZ = value;
  48293. this.forceProjectionMatrixCompute();
  48294. },
  48295. enumerable: true,
  48296. configurable: true
  48297. });
  48298. Object.defineProperty(ShadowLight.prototype, "shadowMaxZ", {
  48299. /**
  48300. * Sets the shadow projection clipping maximum z value.
  48301. */
  48302. get: function () {
  48303. return this._shadowMaxZ;
  48304. },
  48305. /**
  48306. * Gets the shadow projection clipping maximum z value.
  48307. */
  48308. set: function (value) {
  48309. this._shadowMaxZ = value;
  48310. this.forceProjectionMatrixCompute();
  48311. },
  48312. enumerable: true,
  48313. configurable: true
  48314. });
  48315. /**
  48316. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  48317. * @returns true if the information has been computed, false if it does not need to (no parenting)
  48318. */
  48319. ShadowLight.prototype.computeTransformedInformation = function () {
  48320. if (this.parent && this.parent.getWorldMatrix) {
  48321. if (!this.transformedPosition) {
  48322. this.transformedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  48323. }
  48324. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
  48325. // In case the direction is present.
  48326. if (this.direction) {
  48327. if (!this.transformedDirection) {
  48328. this.transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  48329. }
  48330. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection);
  48331. }
  48332. return true;
  48333. }
  48334. return false;
  48335. };
  48336. /**
  48337. * Return the depth scale used for the shadow map.
  48338. * @returns the depth scale.
  48339. */
  48340. ShadowLight.prototype.getDepthScale = function () {
  48341. return 50.0;
  48342. };
  48343. /**
  48344. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  48345. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48346. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48347. */
  48348. ShadowLight.prototype.getShadowDirection = function (faceIndex) {
  48349. return this.transformedDirection ? this.transformedDirection : this.direction;
  48350. };
  48351. /**
  48352. * Returns the ShadowLight absolute position in the World.
  48353. * @returns the position vector in world space
  48354. */
  48355. ShadowLight.prototype.getAbsolutePosition = function () {
  48356. return this.transformedPosition ? this.transformedPosition : this.position;
  48357. };
  48358. /**
  48359. * Sets the ShadowLight direction toward the passed target.
  48360. * @param target The point to target in local space
  48361. * @returns the updated ShadowLight direction
  48362. */
  48363. ShadowLight.prototype.setDirectionToTarget = function (target) {
  48364. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(this.position));
  48365. return this.direction;
  48366. };
  48367. /**
  48368. * Returns the light rotation in euler definition.
  48369. * @returns the x y z rotation in local space.
  48370. */
  48371. ShadowLight.prototype.getRotation = function () {
  48372. this.direction.normalize();
  48373. var xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y);
  48374. var yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(xaxis, this.direction);
  48375. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].RotationFromAxis(xaxis, yaxis, this.direction);
  48376. };
  48377. /**
  48378. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  48379. * @returns true if a cube texture needs to be use
  48380. */
  48381. ShadowLight.prototype.needCube = function () {
  48382. return false;
  48383. };
  48384. /**
  48385. * Detects if the projection matrix requires to be recomputed this frame.
  48386. * @returns true if it requires to be recomputed otherwise, false.
  48387. */
  48388. ShadowLight.prototype.needProjectionMatrixCompute = function () {
  48389. return this._needProjectionMatrixCompute;
  48390. };
  48391. /**
  48392. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  48393. */
  48394. ShadowLight.prototype.forceProjectionMatrixCompute = function () {
  48395. this._needProjectionMatrixCompute = true;
  48396. };
  48397. /** @hidden */
  48398. ShadowLight.prototype._initCache = function () {
  48399. _super.prototype._initCache.call(this);
  48400. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  48401. };
  48402. /** @hidden */
  48403. ShadowLight.prototype._isSynchronized = function () {
  48404. if (!this._cache.position.equals(this.position)) {
  48405. return false;
  48406. }
  48407. return true;
  48408. };
  48409. /**
  48410. * Computes the world matrix of the node
  48411. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  48412. * @returns the world matrix
  48413. */
  48414. ShadowLight.prototype.computeWorldMatrix = function (force) {
  48415. if (!force && this.isSynchronized()) {
  48416. this._currentRenderId = this.getScene().getRenderId();
  48417. return this._worldMatrix;
  48418. }
  48419. this._updateCache();
  48420. this._cache.position.copyFrom(this.position);
  48421. if (!this._worldMatrix) {
  48422. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  48423. }
  48424. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
  48425. if (this.parent && this.parent.getWorldMatrix) {
  48426. this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  48427. this._markSyncedWithParent();
  48428. }
  48429. // Cache the determinant
  48430. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  48431. return this._worldMatrix;
  48432. };
  48433. /**
  48434. * Gets the minZ used for shadow according to both the scene and the light.
  48435. * @param activeCamera The camera we are returning the min for
  48436. * @returns the depth min z
  48437. */
  48438. ShadowLight.prototype.getDepthMinZ = function (activeCamera) {
  48439. return this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ;
  48440. };
  48441. /**
  48442. * Gets the maxZ used for shadow according to both the scene and the light.
  48443. * @param activeCamera The camera we are returning the max for
  48444. * @returns the depth max z
  48445. */
  48446. ShadowLight.prototype.getDepthMaxZ = function (activeCamera) {
  48447. return this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ;
  48448. };
  48449. /**
  48450. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  48451. * @param matrix The materix to updated with the projection information
  48452. * @param viewMatrix The transform matrix of the light
  48453. * @param renderList The list of mesh to render in the map
  48454. * @returns The current light
  48455. */
  48456. ShadowLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  48457. if (this.customProjectionMatrixBuilder) {
  48458. this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
  48459. }
  48460. else {
  48461. this._setDefaultShadowProjectionMatrix(matrix, viewMatrix, renderList);
  48462. }
  48463. return this;
  48464. };
  48465. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48466. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  48467. ], ShadowLight.prototype, "position", null);
  48468. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48469. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  48470. ], ShadowLight.prototype, "direction", null);
  48471. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48472. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48473. ], ShadowLight.prototype, "shadowMinZ", null);
  48474. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48475. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48476. ], ShadowLight.prototype, "shadowMaxZ", null);
  48477. return ShadowLight;
  48478. }(_light__WEBPACK_IMPORTED_MODULE_3__["Light"]));
  48479. /***/ }),
  48480. /***/ "./Lights/spotLight.ts":
  48481. /*!*****************************!*\
  48482. !*** ./Lights/spotLight.ts ***!
  48483. \*****************************/
  48484. /*! exports provided: SpotLight */
  48485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48486. "use strict";
  48487. __webpack_require__.r(__webpack_exports__);
  48488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return SpotLight; });
  48489. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  48490. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  48491. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  48492. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  48493. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  48494. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  48495. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_2", function (name, scene) {
  48496. return function () { return new SpotLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), 0, 0, scene); };
  48497. });
  48498. /**
  48499. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48500. * These values define a cone of light starting from the position, emitting toward the direction.
  48501. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48502. * and the exponent defines the speed of the decay of the light with distance (reach).
  48503. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48504. */
  48505. var SpotLight = /** @class */ (function (_super) {
  48506. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpotLight, _super);
  48507. /**
  48508. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48509. * It can cast shadows.
  48510. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48511. * @param name The light friendly name
  48512. * @param position The position of the spot light in the scene
  48513. * @param direction The direction of the light in the scene
  48514. * @param angle The cone angle of the light in Radians
  48515. * @param exponent The light decay speed with the distance from the emission spot
  48516. * @param scene The scene the lights belongs to
  48517. */
  48518. function SpotLight(name, position, direction, angle, exponent, scene) {
  48519. var _this = _super.call(this, name, scene) || this;
  48520. _this._innerAngle = 0;
  48521. _this._projectionTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  48522. _this._projectionTextureLightNear = 1e-6;
  48523. _this._projectionTextureLightFar = 1000.0;
  48524. _this._projectionTextureUpDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  48525. _this._projectionTextureViewLightDirty = true;
  48526. _this._projectionTextureProjectionLightDirty = true;
  48527. _this._projectionTextureDirty = true;
  48528. _this._projectionTextureViewTargetVector = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  48529. _this._projectionTextureViewLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  48530. _this._projectionTextureProjectionLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  48531. _this._projectionTextureScalingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromValues(0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 1.0);
  48532. _this.position = position;
  48533. _this.direction = direction;
  48534. _this.angle = angle;
  48535. _this.exponent = exponent;
  48536. return _this;
  48537. }
  48538. Object.defineProperty(SpotLight.prototype, "angle", {
  48539. /**
  48540. * Gets the cone angle of the spot light in Radians.
  48541. */
  48542. get: function () {
  48543. return this._angle;
  48544. },
  48545. /**
  48546. * Sets the cone angle of the spot light in Radians.
  48547. */
  48548. set: function (value) {
  48549. this._angle = value;
  48550. this._cosHalfAngle = Math.cos(value * 0.5);
  48551. this._projectionTextureProjectionLightDirty = true;
  48552. this.forceProjectionMatrixCompute();
  48553. this._computeAngleValues();
  48554. },
  48555. enumerable: true,
  48556. configurable: true
  48557. });
  48558. Object.defineProperty(SpotLight.prototype, "innerAngle", {
  48559. /**
  48560. * Only used in gltf falloff mode, this defines the angle where
  48561. * the directional falloff will start before cutting at angle which could be seen
  48562. * as outer angle.
  48563. */
  48564. get: function () {
  48565. return this._innerAngle;
  48566. },
  48567. /**
  48568. * Only used in gltf falloff mode, this defines the angle where
  48569. * the directional falloff will start before cutting at angle which could be seen
  48570. * as outer angle.
  48571. */
  48572. set: function (value) {
  48573. this._innerAngle = value;
  48574. this._computeAngleValues();
  48575. },
  48576. enumerable: true,
  48577. configurable: true
  48578. });
  48579. Object.defineProperty(SpotLight.prototype, "shadowAngleScale", {
  48580. /**
  48581. * Allows scaling the angle of the light for shadow generation only.
  48582. */
  48583. get: function () {
  48584. return this._shadowAngleScale;
  48585. },
  48586. /**
  48587. * Allows scaling the angle of the light for shadow generation only.
  48588. */
  48589. set: function (value) {
  48590. this._shadowAngleScale = value;
  48591. this.forceProjectionMatrixCompute();
  48592. },
  48593. enumerable: true,
  48594. configurable: true
  48595. });
  48596. Object.defineProperty(SpotLight.prototype, "projectionTextureMatrix", {
  48597. /**
  48598. * Allows reading the projecton texture
  48599. */
  48600. get: function () {
  48601. return this._projectionTextureMatrix;
  48602. },
  48603. enumerable: true,
  48604. configurable: true
  48605. });
  48606. Object.defineProperty(SpotLight.prototype, "projectionTextureLightNear", {
  48607. /**
  48608. * Gets the near clip of the Spotlight for texture projection.
  48609. */
  48610. get: function () {
  48611. return this._projectionTextureLightNear;
  48612. },
  48613. /**
  48614. * Sets the near clip of the Spotlight for texture projection.
  48615. */
  48616. set: function (value) {
  48617. this._projectionTextureLightNear = value;
  48618. this._projectionTextureProjectionLightDirty = true;
  48619. },
  48620. enumerable: true,
  48621. configurable: true
  48622. });
  48623. Object.defineProperty(SpotLight.prototype, "projectionTextureLightFar", {
  48624. /**
  48625. * Gets the far clip of the Spotlight for texture projection.
  48626. */
  48627. get: function () {
  48628. return this._projectionTextureLightFar;
  48629. },
  48630. /**
  48631. * Sets the far clip of the Spotlight for texture projection.
  48632. */
  48633. set: function (value) {
  48634. this._projectionTextureLightFar = value;
  48635. this._projectionTextureProjectionLightDirty = true;
  48636. },
  48637. enumerable: true,
  48638. configurable: true
  48639. });
  48640. Object.defineProperty(SpotLight.prototype, "projectionTextureUpDirection", {
  48641. /**
  48642. * Gets the Up vector of the Spotlight for texture projection.
  48643. */
  48644. get: function () {
  48645. return this._projectionTextureUpDirection;
  48646. },
  48647. /**
  48648. * Sets the Up vector of the Spotlight for texture projection.
  48649. */
  48650. set: function (value) {
  48651. this._projectionTextureUpDirection = value;
  48652. this._projectionTextureProjectionLightDirty = true;
  48653. },
  48654. enumerable: true,
  48655. configurable: true
  48656. });
  48657. Object.defineProperty(SpotLight.prototype, "projectionTexture", {
  48658. /**
  48659. * Gets the projection texture of the light.
  48660. */
  48661. get: function () {
  48662. return this._projectionTexture;
  48663. },
  48664. /**
  48665. * Sets the projection texture of the light.
  48666. */
  48667. set: function (value) {
  48668. this._projectionTexture = value;
  48669. this._projectionTextureDirty = true;
  48670. },
  48671. enumerable: true,
  48672. configurable: true
  48673. });
  48674. /**
  48675. * Returns the string "SpotLight".
  48676. * @returns the class name
  48677. */
  48678. SpotLight.prototype.getClassName = function () {
  48679. return "SpotLight";
  48680. };
  48681. /**
  48682. * Returns the integer 2.
  48683. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48684. */
  48685. SpotLight.prototype.getTypeID = function () {
  48686. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_SPOTLIGHT;
  48687. };
  48688. /**
  48689. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48690. */
  48691. SpotLight.prototype._setDirection = function (value) {
  48692. _super.prototype._setDirection.call(this, value);
  48693. this._projectionTextureViewLightDirty = true;
  48694. };
  48695. /**
  48696. * Overrides the position setter to recompute the projection texture view light Matrix.
  48697. */
  48698. SpotLight.prototype._setPosition = function (value) {
  48699. _super.prototype._setPosition.call(this, value);
  48700. this._projectionTextureViewLightDirty = true;
  48701. };
  48702. /**
  48703. * Sets the passed matrix "matrix" as perspective projection matrix for the shadows and the passed view matrix with the fov equal to the SpotLight angle and and aspect ratio of 1.0.
  48704. * Returns the SpotLight.
  48705. */
  48706. SpotLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  48707. var activeCamera = this.getScene().activeCamera;
  48708. if (!activeCamera) {
  48709. return;
  48710. }
  48711. this._shadowAngleScale = this._shadowAngleScale || 1;
  48712. var angle = this._shadowAngleScale * this._angle;
  48713. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(angle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  48714. };
  48715. SpotLight.prototype._computeProjectionTextureViewLightMatrix = function () {
  48716. this._projectionTextureViewLightDirty = false;
  48717. this._projectionTextureDirty = true;
  48718. this.position.addToRef(this.direction, this._projectionTextureViewTargetVector);
  48719. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].LookAtLHToRef(this.position, this._projectionTextureViewTargetVector, this._projectionTextureUpDirection, this._projectionTextureViewLightMatrix);
  48720. };
  48721. SpotLight.prototype._computeProjectionTextureProjectionLightMatrix = function () {
  48722. this._projectionTextureProjectionLightDirty = false;
  48723. this._projectionTextureDirty = true;
  48724. var light_far = this.projectionTextureLightFar;
  48725. var light_near = this.projectionTextureLightNear;
  48726. var P = light_far / (light_far - light_near);
  48727. var Q = -P * light_near;
  48728. var S = 1.0 / Math.tan(this._angle / 2.0);
  48729. var A = 1.0;
  48730. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromValuesToRef(S / A, 0.0, 0.0, 0.0, 0.0, S, 0.0, 0.0, 0.0, 0.0, P, 1.0, 0.0, 0.0, Q, 0.0, this._projectionTextureProjectionLightMatrix);
  48731. };
  48732. /**
  48733. * Main function for light texture projection matrix computing.
  48734. */
  48735. SpotLight.prototype._computeProjectionTextureMatrix = function () {
  48736. this._projectionTextureDirty = false;
  48737. this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix);
  48738. this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix);
  48739. };
  48740. SpotLight.prototype._buildUniformLayout = function () {
  48741. this._uniformBuffer.addUniform("vLightData", 4);
  48742. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  48743. this._uniformBuffer.addUniform("vLightSpecular", 3);
  48744. this._uniformBuffer.addUniform("vLightDirection", 3);
  48745. this._uniformBuffer.addUniform("vLightFalloff", 4);
  48746. this._uniformBuffer.addUniform("shadowsInfo", 3);
  48747. this._uniformBuffer.addUniform("depthValues", 2);
  48748. this._uniformBuffer.create();
  48749. };
  48750. SpotLight.prototype._computeAngleValues = function () {
  48751. this._lightAngleScale = 1.0 / Math.max(0.001, (Math.cos(this._innerAngle * 0.5) - this._cosHalfAngle));
  48752. this._lightAngleOffset = -this._cosHalfAngle * this._lightAngleScale;
  48753. };
  48754. /**
  48755. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48756. * @param effect The effect to update
  48757. * @param lightIndex The index of the light in the effect to update
  48758. * @returns The spot light
  48759. */
  48760. SpotLight.prototype.transferToEffect = function (effect, lightIndex) {
  48761. var normalizeDirection;
  48762. if (this.computeTransformedInformation()) {
  48763. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent, lightIndex);
  48764. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.transformedDirection);
  48765. }
  48766. else {
  48767. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, this.exponent, lightIndex);
  48768. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  48769. }
  48770. this._uniformBuffer.updateFloat4("vLightDirection", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, this._cosHalfAngle, lightIndex);
  48771. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, this._lightAngleScale, this._lightAngleOffset, lightIndex);
  48772. if (this.projectionTexture && this.projectionTexture.isReady()) {
  48773. if (this._projectionTextureViewLightDirty) {
  48774. this._computeProjectionTextureViewLightMatrix();
  48775. }
  48776. if (this._projectionTextureProjectionLightDirty) {
  48777. this._computeProjectionTextureProjectionLightMatrix();
  48778. }
  48779. if (this._projectionTextureDirty) {
  48780. this._computeProjectionTextureMatrix();
  48781. }
  48782. effect.setMatrix("textureProjectionMatrix" + lightIndex, this._projectionTextureMatrix);
  48783. effect.setTexture("projectionLightSampler" + lightIndex, this.projectionTexture);
  48784. }
  48785. return this;
  48786. };
  48787. /**
  48788. * Disposes the light and the associated resources.
  48789. */
  48790. SpotLight.prototype.dispose = function () {
  48791. _super.prototype.dispose.call(this);
  48792. if (this._projectionTexture) {
  48793. this._projectionTexture.dispose();
  48794. }
  48795. };
  48796. /**
  48797. * Prepares the list of defines specific to the light type.
  48798. * @param defines the list of defines
  48799. * @param lightIndex defines the index of the light for the effect
  48800. */
  48801. SpotLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  48802. defines["SPOTLIGHT" + lightIndex] = true;
  48803. defines["PROJECTEDLIGHTTEXTURE" + lightIndex] = this.projectionTexture ? true : false;
  48804. };
  48805. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48806. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48807. ], SpotLight.prototype, "angle", null);
  48808. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48809. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48810. ], SpotLight.prototype, "innerAngle", null);
  48811. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48812. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48813. ], SpotLight.prototype, "shadowAngleScale", null);
  48814. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48815. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48816. ], SpotLight.prototype, "exponent", void 0);
  48817. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48818. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48819. ], SpotLight.prototype, "projectionTextureLightNear", null);
  48820. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48821. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48822. ], SpotLight.prototype, "projectionTextureLightFar", null);
  48823. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48824. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48825. ], SpotLight.prototype, "projectionTextureUpDirection", null);
  48826. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48827. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("projectedLightTexture")
  48828. ], SpotLight.prototype, "_projectionTexture", void 0);
  48829. return SpotLight;
  48830. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  48831. /***/ }),
  48832. /***/ "./Loading/Plugins/babylonFileLoader.ts":
  48833. /*!**********************************************!*\
  48834. !*** ./Loading/Plugins/babylonFileLoader.ts ***!
  48835. \**********************************************/
  48836. /*! exports provided: _BabylonLoaderRegistered */
  48837. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48838. "use strict";
  48839. __webpack_require__.r(__webpack_exports__);
  48840. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _BabylonLoaderRegistered; });
  48841. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  48842. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  48843. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  48844. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  48845. /* harmony import */ var _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/geometry */ "./Meshes/geometry.ts");
  48846. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/transformNode */ "./Meshes/transformNode.ts");
  48847. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  48848. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  48849. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  48850. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  48851. /* harmony import */ var _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Animations/animationGroup */ "./Animations/animationGroup.ts");
  48852. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  48853. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  48854. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  48855. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  48856. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../assetContainer */ "./assetContainer.ts");
  48857. /* harmony import */ var _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Actions/actionManager */ "./Actions/actionManager.ts");
  48858. /* harmony import */ var _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Bones/skeleton */ "./Bones/skeleton.ts");
  48859. /* harmony import */ var _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Morph/morphTargetManager */ "./Morph/morphTargetManager.ts");
  48860. /* harmony import */ var _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../Physics/Plugins/cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  48861. /* harmony import */ var _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Physics/Plugins/oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  48862. /* harmony import */ var _Physics_Plugins_ammoJSPlugin__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Physics/Plugins/ammoJSPlugin */ "./Physics/Plugins/ammoJSPlugin.ts");
  48863. /* harmony import */ var _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Probes/reflectionProbe */ "./Probes/reflectionProbe.ts");
  48864. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  48865. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  48866. /** @hidden */
  48867. var _BabylonLoaderRegistered = true;
  48868. var parseMaterialById = function (id, parsedData, scene, rootUrl) {
  48869. for (var index = 0, cache = parsedData.materials.length; index < cache; index++) {
  48870. var parsedMaterial = parsedData.materials[index];
  48871. if (parsedMaterial.id === id) {
  48872. return _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  48873. }
  48874. }
  48875. return null;
  48876. };
  48877. var isDescendantOf = function (mesh, names, hierarchyIds) {
  48878. for (var i in names) {
  48879. if (mesh.name === names[i]) {
  48880. hierarchyIds.push(mesh.id);
  48881. return true;
  48882. }
  48883. }
  48884. if (mesh.parentId && hierarchyIds.indexOf(mesh.parentId) !== -1) {
  48885. hierarchyIds.push(mesh.id);
  48886. return true;
  48887. }
  48888. return false;
  48889. };
  48890. var logOperation = function (operation, producer) {
  48891. return operation + " of " + (producer ? producer.file + " from " + producer.name + " version: " + producer.version + ", exporter version: " + producer.exporter_version : "unknown");
  48892. };
  48893. var loadAssetContainer = function (scene, data, rootUrl, onError, addToScene) {
  48894. if (addToScene === void 0) { addToScene = false; }
  48895. var container = new _assetContainer__WEBPACK_IMPORTED_MODULE_15__["AssetContainer"](scene);
  48896. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  48897. // when SceneLoader.debugLogging = true (default), or exception encountered.
  48898. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  48899. // and avoid problems with multiple concurrent .babylon loads.
  48900. var log = "importScene has failed JSON parse";
  48901. try {
  48902. var parsedData = JSON.parse(data);
  48903. log = "";
  48904. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  48905. var index;
  48906. var cache;
  48907. // Environment texture
  48908. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  48909. // PBR needed for both HDR texture (gamma space) & a sky box
  48910. var isPBR = parsedData.isPBR !== undefined ? parsedData.isPBR : true;
  48911. if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
  48912. var hdrSize = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
  48913. var hdrTexture = new _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__["HDRCubeTexture"]((parsedData.environmentTexture.match(/https?:\/\//g) ? "" : rootUrl) + parsedData.environmentTexture, scene, hdrSize, true, !isPBR);
  48914. if (parsedData.environmentTextureRotationY) {
  48915. hdrTexture.rotationY = parsedData.environmentTextureRotationY;
  48916. }
  48917. scene.environmentTexture = hdrTexture;
  48918. }
  48919. else {
  48920. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_24__["Tools"].EndsWith(parsedData.environmentTexture, ".env")) {
  48921. var compressedTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"]((parsedData.environmentTexture.match(/https?:\/\//g) ? "" : rootUrl) + parsedData.environmentTexture, scene);
  48922. if (parsedData.environmentTextureRotationY) {
  48923. compressedTexture.rotationY = parsedData.environmentTextureRotationY;
  48924. }
  48925. scene.environmentTexture = compressedTexture;
  48926. }
  48927. else {
  48928. var cubeTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData((parsedData.environmentTexture.match(/https?:\/\//g) ? "" : rootUrl) + parsedData.environmentTexture, scene);
  48929. if (parsedData.environmentTextureRotationY) {
  48930. cubeTexture.rotationY = parsedData.environmentTextureRotationY;
  48931. }
  48932. scene.environmentTexture = cubeTexture;
  48933. }
  48934. }
  48935. if (parsedData.createDefaultSkybox === true) {
  48936. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  48937. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  48938. scene.createDefaultSkybox(scene.environmentTexture, isPBR, skyboxScale, skyboxBlurLevel);
  48939. }
  48940. container.environmentTexture = scene.environmentTexture;
  48941. }
  48942. // Lights
  48943. if (parsedData.lights !== undefined && parsedData.lights !== null) {
  48944. for (index = 0, cache = parsedData.lights.length; index < cache; index++) {
  48945. var parsedLight = parsedData.lights[index];
  48946. var light = _Lights_light__WEBPACK_IMPORTED_MODULE_11__["Light"].Parse(parsedLight, scene);
  48947. if (light) {
  48948. container.lights.push(light);
  48949. log += (index === 0 ? "\n\tLights:" : "");
  48950. log += "\n\t\t" + light.toString(fullDetails);
  48951. }
  48952. }
  48953. }
  48954. // Reflection probes
  48955. if (parsedData.reflectionProbes !== undefined && parsedData.reflectionProbes !== null) {
  48956. for (index = 0, cache = parsedData.reflectionProbes.length; index < cache; index++) {
  48957. var parsedReflectionProbe = parsedData.reflectionProbes[index];
  48958. var reflectionProbe = _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_22__["ReflectionProbe"].Parse(parsedReflectionProbe, scene, rootUrl);
  48959. if (reflectionProbe) {
  48960. container.reflectionProbes.push(reflectionProbe);
  48961. log += (index === 0 ? "\n\tReflection Probes:" : "");
  48962. log += "\n\t\t" + reflectionProbe.toString(fullDetails);
  48963. }
  48964. }
  48965. }
  48966. // Animations
  48967. if (parsedData.animations !== undefined && parsedData.animations !== null) {
  48968. for (index = 0, cache = parsedData.animations.length; index < cache; index++) {
  48969. var parsedAnimation = parsedData.animations[index];
  48970. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_23__["_TypeStore"].GetClass("BABYLON.Animation");
  48971. if (internalClass) {
  48972. var animation = internalClass.Parse(parsedAnimation);
  48973. scene.animations.push(animation);
  48974. container.animations.push(animation);
  48975. log += (index === 0 ? "\n\tAnimations:" : "");
  48976. log += "\n\t\t" + animation.toString(fullDetails);
  48977. }
  48978. }
  48979. }
  48980. // Materials
  48981. if (parsedData.materials !== undefined && parsedData.materials !== null) {
  48982. for (index = 0, cache = parsedData.materials.length; index < cache; index++) {
  48983. var parsedMaterial = parsedData.materials[index];
  48984. var mat = _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  48985. container.materials.push(mat);
  48986. log += (index === 0 ? "\n\tMaterials:" : "");
  48987. log += "\n\t\t" + mat.toString(fullDetails);
  48988. }
  48989. }
  48990. if (parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  48991. for (index = 0, cache = parsedData.multiMaterials.length; index < cache; index++) {
  48992. var parsedMultiMaterial = parsedData.multiMaterials[index];
  48993. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  48994. container.multiMaterials.push(mmat);
  48995. log += (index === 0 ? "\n\tMultiMaterials:" : "");
  48996. log += "\n\t\t" + mmat.toString(fullDetails);
  48997. }
  48998. }
  48999. // Morph targets
  49000. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  49001. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  49002. var managerData = _a[_i];
  49003. container.morphTargetManagers.push(_Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene));
  49004. }
  49005. }
  49006. // Skeletons
  49007. if (parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  49008. for (index = 0, cache = parsedData.skeletons.length; index < cache; index++) {
  49009. var parsedSkeleton = parsedData.skeletons[index];
  49010. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  49011. container.skeletons.push(skeleton);
  49012. log += (index === 0 ? "\n\tSkeletons:" : "");
  49013. log += "\n\t\t" + skeleton.toString(fullDetails);
  49014. }
  49015. }
  49016. // Geometries
  49017. var geometries = parsedData.geometries;
  49018. if (geometries !== undefined && geometries !== null) {
  49019. var addedGeometry = new Array();
  49020. // VertexData
  49021. var vertexData = geometries.vertexData;
  49022. if (vertexData !== undefined && vertexData !== null) {
  49023. for (index = 0, cache = vertexData.length; index < cache; index++) {
  49024. var parsedVertexData = vertexData[index];
  49025. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedVertexData, scene, rootUrl));
  49026. }
  49027. }
  49028. addedGeometry.forEach(function (g) {
  49029. if (g) {
  49030. container.geometries.push(g);
  49031. }
  49032. });
  49033. }
  49034. // Transform nodes
  49035. if (parsedData.transformNodes !== undefined && parsedData.transformNodes !== null) {
  49036. for (index = 0, cache = parsedData.transformNodes.length; index < cache; index++) {
  49037. var parsedTransformNode = parsedData.transformNodes[index];
  49038. var node = _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__["TransformNode"].Parse(parsedTransformNode, scene, rootUrl);
  49039. container.transformNodes.push(node);
  49040. }
  49041. }
  49042. // Meshes
  49043. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  49044. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  49045. var parsedMesh = parsedData.meshes[index];
  49046. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  49047. container.meshes.push(mesh);
  49048. log += (index === 0 ? "\n\tMeshes:" : "");
  49049. log += "\n\t\t" + mesh.toString(fullDetails);
  49050. }
  49051. }
  49052. // Cameras
  49053. if (parsedData.cameras !== undefined && parsedData.cameras !== null) {
  49054. for (index = 0, cache = parsedData.cameras.length; index < cache; index++) {
  49055. var parsedCamera = parsedData.cameras[index];
  49056. var camera = _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].Parse(parsedCamera, scene);
  49057. container.cameras.push(camera);
  49058. log += (index === 0 ? "\n\tCameras:" : "");
  49059. log += "\n\t\t" + camera.toString(fullDetails);
  49060. }
  49061. }
  49062. // Animation Groups
  49063. if (parsedData.animationGroups !== undefined && parsedData.animationGroups !== null) {
  49064. for (index = 0, cache = parsedData.animationGroups.length; index < cache; index++) {
  49065. var parsedAnimationGroup = parsedData.animationGroups[index];
  49066. var animationGroup = _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__["AnimationGroup"].Parse(parsedAnimationGroup, scene);
  49067. container.animationGroups.push(animationGroup);
  49068. log += (index === 0 ? "\n\tAnimationGroups:" : "");
  49069. log += "\n\t\t" + animationGroup.toString(fullDetails);
  49070. }
  49071. }
  49072. // Browsing all the graph to connect the dots
  49073. for (index = 0, cache = scene.cameras.length; index < cache; index++) {
  49074. var camera = scene.cameras[index];
  49075. if (camera._waitingParentId) {
  49076. camera.parent = scene.getLastEntryByID(camera._waitingParentId);
  49077. camera._waitingParentId = null;
  49078. }
  49079. }
  49080. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  49081. var light_1 = scene.lights[index];
  49082. if (light_1 && light_1._waitingParentId) {
  49083. light_1.parent = scene.getLastEntryByID(light_1._waitingParentId);
  49084. light_1._waitingParentId = null;
  49085. }
  49086. }
  49087. // Connect parents & children and parse actions
  49088. for (index = 0, cache = scene.transformNodes.length; index < cache; index++) {
  49089. var transformNode = scene.transformNodes[index];
  49090. if (transformNode._waitingParentId) {
  49091. transformNode.parent = scene.getLastEntryByID(transformNode._waitingParentId);
  49092. transformNode._waitingParentId = null;
  49093. }
  49094. }
  49095. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  49096. var mesh = scene.meshes[index];
  49097. if (mesh._waitingParentId) {
  49098. mesh.parent = scene.getLastEntryByID(mesh._waitingParentId);
  49099. mesh._waitingParentId = null;
  49100. }
  49101. }
  49102. // freeze world matrix application
  49103. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  49104. var currentMesh = scene.meshes[index];
  49105. if (currentMesh._waitingFreezeWorldMatrix) {
  49106. currentMesh.freezeWorldMatrix();
  49107. currentMesh._waitingFreezeWorldMatrix = null;
  49108. }
  49109. else {
  49110. currentMesh.computeWorldMatrix(true);
  49111. }
  49112. }
  49113. // Lights exclusions / inclusions
  49114. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  49115. var light_2 = scene.lights[index];
  49116. // Excluded check
  49117. if (light_2._excludedMeshesIds.length > 0) {
  49118. for (var excludedIndex = 0; excludedIndex < light_2._excludedMeshesIds.length; excludedIndex++) {
  49119. var excludedMesh = scene.getMeshByID(light_2._excludedMeshesIds[excludedIndex]);
  49120. if (excludedMesh) {
  49121. light_2.excludedMeshes.push(excludedMesh);
  49122. }
  49123. }
  49124. light_2._excludedMeshesIds = [];
  49125. }
  49126. // Included check
  49127. if (light_2._includedOnlyMeshesIds.length > 0) {
  49128. for (var includedOnlyIndex = 0; includedOnlyIndex < light_2._includedOnlyMeshesIds.length; includedOnlyIndex++) {
  49129. var includedOnlyMesh = scene.getMeshByID(light_2._includedOnlyMeshesIds[includedOnlyIndex]);
  49130. if (includedOnlyMesh) {
  49131. light_2.includedOnlyMeshes.push(includedOnlyMesh);
  49132. }
  49133. }
  49134. light_2._includedOnlyMeshesIds = [];
  49135. }
  49136. }
  49137. _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].Parse(parsedData, scene, container, rootUrl);
  49138. // Actions (scene) Done last as it can access other objects.
  49139. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  49140. var mesh = scene.meshes[index];
  49141. if (mesh._waitingActions) {
  49142. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(mesh._waitingActions, mesh, scene);
  49143. mesh._waitingActions = null;
  49144. }
  49145. }
  49146. if (parsedData.actions !== undefined && parsedData.actions !== null) {
  49147. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(parsedData.actions, null, scene);
  49148. }
  49149. if (!addToScene) {
  49150. container.removeAllFromScene();
  49151. }
  49152. }
  49153. catch (err) {
  49154. var msg = logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + log;
  49155. if (onError) {
  49156. onError(msg, err);
  49157. }
  49158. else {
  49159. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  49160. throw err;
  49161. }
  49162. }
  49163. finally {
  49164. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  49165. _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 : ""));
  49166. }
  49167. }
  49168. return container;
  49169. };
  49170. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].RegisterPlugin({
  49171. name: "babylon.js",
  49172. extensions: ".babylon",
  49173. canDirectLoad: function (data) {
  49174. if (data.indexOf("babylon") !== -1) { // We consider that the producer string is filled
  49175. return true;
  49176. }
  49177. return false;
  49178. },
  49179. importMesh: function (meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons, onError) {
  49180. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  49181. // when SceneLoader.debugLogging = true (default), or exception encountered.
  49182. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  49183. // and avoid problems with multiple concurrent .babylon loads.
  49184. var log = "importMesh has failed JSON parse";
  49185. try {
  49186. var parsedData = JSON.parse(data);
  49187. log = "";
  49188. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  49189. if (!meshesNames) {
  49190. meshesNames = null;
  49191. }
  49192. else if (!Array.isArray(meshesNames)) {
  49193. meshesNames = [meshesNames];
  49194. }
  49195. var hierarchyIds = new Array();
  49196. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  49197. var loadedSkeletonsIds = [];
  49198. var loadedMaterialsIds = [];
  49199. var index;
  49200. var cache;
  49201. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  49202. var parsedMesh = parsedData.meshes[index];
  49203. if (meshesNames === null || isDescendantOf(parsedMesh, meshesNames, hierarchyIds)) {
  49204. if (meshesNames !== null) {
  49205. // Remove found mesh name from list.
  49206. delete meshesNames[meshesNames.indexOf(parsedMesh.name)];
  49207. }
  49208. //Geometry?
  49209. if (parsedMesh.geometryId !== undefined && parsedMesh.geometryId !== null) {
  49210. //does the file contain geometries?
  49211. if (parsedData.geometries !== undefined && parsedData.geometries !== null) {
  49212. //find the correct geometry and add it to the scene
  49213. var found = false;
  49214. ["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach(function (geometryType) {
  49215. if (found === true || !parsedData.geometries[geometryType] || !(Array.isArray(parsedData.geometries[geometryType]))) {
  49216. return;
  49217. }
  49218. else {
  49219. parsedData.geometries[geometryType].forEach(function (parsedGeometryData) {
  49220. if (parsedGeometryData.id === parsedMesh.geometryId) {
  49221. switch (geometryType) {
  49222. case "vertexData":
  49223. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedGeometryData, scene, rootUrl);
  49224. break;
  49225. }
  49226. found = true;
  49227. }
  49228. });
  49229. }
  49230. });
  49231. if (found === false) {
  49232. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Geometry not found for mesh " + parsedMesh.id);
  49233. }
  49234. }
  49235. }
  49236. // Material ?
  49237. if (parsedMesh.materialId) {
  49238. var materialFound = (loadedMaterialsIds.indexOf(parsedMesh.materialId) !== -1);
  49239. if (materialFound === false && parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  49240. for (var multimatIndex = 0, multimatCache = parsedData.multiMaterials.length; multimatIndex < multimatCache; multimatIndex++) {
  49241. var parsedMultiMaterial = parsedData.multiMaterials[multimatIndex];
  49242. if (parsedMultiMaterial.id === parsedMesh.materialId) {
  49243. for (var matIndex = 0, matCache = parsedMultiMaterial.materials.length; matIndex < matCache; matIndex++) {
  49244. var subMatId = parsedMultiMaterial.materials[matIndex];
  49245. loadedMaterialsIds.push(subMatId);
  49246. var mat = parseMaterialById(subMatId, parsedData, scene, rootUrl);
  49247. if (mat) {
  49248. log += "\n\tMaterial " + mat.toString(fullDetails);
  49249. }
  49250. }
  49251. loadedMaterialsIds.push(parsedMultiMaterial.id);
  49252. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  49253. if (mmat) {
  49254. materialFound = true;
  49255. log += "\n\tMulti-Material " + mmat.toString(fullDetails);
  49256. }
  49257. break;
  49258. }
  49259. }
  49260. }
  49261. if (materialFound === false) {
  49262. loadedMaterialsIds.push(parsedMesh.materialId);
  49263. var mat = parseMaterialById(parsedMesh.materialId, parsedData, scene, rootUrl);
  49264. if (!mat) {
  49265. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Material not found for mesh " + parsedMesh.id);
  49266. }
  49267. else {
  49268. log += "\n\tMaterial " + mat.toString(fullDetails);
  49269. }
  49270. }
  49271. }
  49272. // Skeleton ?
  49273. if (parsedMesh.skeletonId > -1 && parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  49274. var skeletonAlreadyLoaded = (loadedSkeletonsIds.indexOf(parsedMesh.skeletonId) > -1);
  49275. if (skeletonAlreadyLoaded === false) {
  49276. for (var skeletonIndex = 0, skeletonCache = parsedData.skeletons.length; skeletonIndex < skeletonCache; skeletonIndex++) {
  49277. var parsedSkeleton = parsedData.skeletons[skeletonIndex];
  49278. if (parsedSkeleton.id === parsedMesh.skeletonId) {
  49279. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  49280. skeletons.push(skeleton);
  49281. loadedSkeletonsIds.push(parsedSkeleton.id);
  49282. log += "\n\tSkeleton " + skeleton.toString(fullDetails);
  49283. }
  49284. }
  49285. }
  49286. }
  49287. // Morph targets ?
  49288. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  49289. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  49290. var managerData = _a[_i];
  49291. _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene);
  49292. }
  49293. }
  49294. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  49295. meshes.push(mesh);
  49296. log += "\n\tMesh " + mesh.toString(fullDetails);
  49297. }
  49298. }
  49299. // Connecting parents
  49300. var currentMesh;
  49301. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  49302. currentMesh = scene.meshes[index];
  49303. if (currentMesh._waitingParentId) {
  49304. currentMesh.parent = scene.getLastEntryByID(currentMesh._waitingParentId);
  49305. currentMesh._waitingParentId = null;
  49306. }
  49307. }
  49308. // freeze and compute world matrix application
  49309. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  49310. currentMesh = scene.meshes[index];
  49311. if (currentMesh._waitingFreezeWorldMatrix) {
  49312. currentMesh.freezeWorldMatrix();
  49313. currentMesh._waitingFreezeWorldMatrix = null;
  49314. }
  49315. else {
  49316. currentMesh.computeWorldMatrix(true);
  49317. }
  49318. }
  49319. }
  49320. // Particles
  49321. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  49322. var parser = _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_12__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  49323. if (parser) {
  49324. for (index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  49325. var parsedParticleSystem = parsedData.particleSystems[index];
  49326. if (hierarchyIds.indexOf(parsedParticleSystem.emitterId) !== -1) {
  49327. particleSystems.push(parser(parsedParticleSystem, scene, rootUrl));
  49328. }
  49329. }
  49330. }
  49331. }
  49332. return true;
  49333. }
  49334. catch (err) {
  49335. var msg = logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + log;
  49336. if (onError) {
  49337. onError(msg, err);
  49338. }
  49339. else {
  49340. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  49341. throw err;
  49342. }
  49343. }
  49344. finally {
  49345. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  49346. _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 : ""));
  49347. }
  49348. }
  49349. return false;
  49350. },
  49351. load: function (scene, data, rootUrl, onError) {
  49352. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  49353. // when SceneLoader.debugLogging = true (default), or exception encountered.
  49354. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  49355. // and avoid problems with multiple concurrent .babylon loads.
  49356. var log = "importScene has failed JSON parse";
  49357. try {
  49358. var parsedData = JSON.parse(data);
  49359. log = "";
  49360. // Scene
  49361. if (parsedData.useDelayedTextureLoading !== undefined && parsedData.useDelayedTextureLoading !== null) {
  49362. scene.useDelayedTextureLoading = parsedData.useDelayedTextureLoading && !_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].ForceFullSceneLoadingForIncremental;
  49363. }
  49364. if (parsedData.autoClear !== undefined && parsedData.autoClear !== null) {
  49365. scene.autoClear = parsedData.autoClear;
  49366. }
  49367. if (parsedData.clearColor !== undefined && parsedData.clearColor !== null) {
  49368. scene.clearColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(parsedData.clearColor);
  49369. }
  49370. if (parsedData.ambientColor !== undefined && parsedData.ambientColor !== null) {
  49371. scene.ambientColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.ambientColor);
  49372. }
  49373. if (parsedData.gravity !== undefined && parsedData.gravity !== null) {
  49374. scene.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.gravity);
  49375. }
  49376. // Fog
  49377. if (parsedData.fogMode && parsedData.fogMode !== 0) {
  49378. scene.fogMode = parsedData.fogMode;
  49379. scene.fogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.fogColor);
  49380. scene.fogStart = parsedData.fogStart;
  49381. scene.fogEnd = parsedData.fogEnd;
  49382. scene.fogDensity = parsedData.fogDensity;
  49383. log += "\tFog mode for scene: ";
  49384. switch (scene.fogMode) {
  49385. // getters not compiling, so using hardcoded
  49386. case 1:
  49387. log += "exp\n";
  49388. break;
  49389. case 2:
  49390. log += "exp2\n";
  49391. break;
  49392. case 3:
  49393. log += "linear\n";
  49394. break;
  49395. }
  49396. }
  49397. //Physics
  49398. if (parsedData.physicsEnabled) {
  49399. var physicsPlugin;
  49400. if (parsedData.physicsEngine === "cannon") {
  49401. physicsPlugin = new _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__["CannonJSPlugin"]();
  49402. }
  49403. else if (parsedData.physicsEngine === "oimo") {
  49404. physicsPlugin = new _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__["OimoJSPlugin"]();
  49405. }
  49406. else if (parsedData.physicsEngine === "ammo") {
  49407. physicsPlugin = new _Physics_Plugins_ammoJSPlugin__WEBPACK_IMPORTED_MODULE_21__["AmmoJSPlugin"]();
  49408. }
  49409. log = "\tPhysics engine " + (parsedData.physicsEngine ? parsedData.physicsEngine : "oimo") + " enabled\n";
  49410. //else - default engine, which is currently oimo
  49411. var physicsGravity = parsedData.physicsGravity ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.physicsGravity) : null;
  49412. scene.enablePhysics(physicsGravity, physicsPlugin);
  49413. }
  49414. // Metadata
  49415. if (parsedData.metadata !== undefined && parsedData.metadata !== null) {
  49416. scene.metadata = parsedData.metadata;
  49417. }
  49418. //collisions, if defined. otherwise, default is true
  49419. if (parsedData.collisionsEnabled !== undefined && parsedData.collisionsEnabled !== null) {
  49420. scene.collisionsEnabled = parsedData.collisionsEnabled;
  49421. }
  49422. var container = loadAssetContainer(scene, data, rootUrl, onError, true);
  49423. if (!container) {
  49424. return false;
  49425. }
  49426. if (parsedData.autoAnimate) {
  49427. scene.beginAnimation(scene, parsedData.autoAnimateFrom, parsedData.autoAnimateTo, parsedData.autoAnimateLoop, parsedData.autoAnimateSpeed || 1.0);
  49428. }
  49429. if (parsedData.activeCameraID !== undefined && parsedData.activeCameraID !== null) {
  49430. scene.setActiveCameraByID(parsedData.activeCameraID);
  49431. }
  49432. // Environment texture
  49433. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  49434. // PBR needed for both HDR texture (gamma space) & a sky box
  49435. var isPBR = parsedData.isPBR !== undefined ? parsedData.isPBR : true;
  49436. if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
  49437. var hdrSize = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
  49438. var hdrTexture = new _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__["HDRCubeTexture"](rootUrl + parsedData.environmentTexture, scene, hdrSize, true, !isPBR);
  49439. if (parsedData.environmentTextureRotationY) {
  49440. hdrTexture.rotationY = parsedData.environmentTextureRotationY;
  49441. }
  49442. scene.environmentTexture = hdrTexture;
  49443. }
  49444. else {
  49445. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_24__["Tools"].EndsWith(parsedData.environmentTexture, ".env")) {
  49446. var compressedTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"](rootUrl + parsedData.environmentTexture, scene);
  49447. if (parsedData.environmentTextureRotationY) {
  49448. compressedTexture.rotationY = parsedData.environmentTextureRotationY;
  49449. }
  49450. scene.environmentTexture = compressedTexture;
  49451. }
  49452. else {
  49453. var cubeTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(rootUrl + parsedData.environmentTexture, scene);
  49454. if (parsedData.environmentTextureRotationY) {
  49455. cubeTexture.rotationY = parsedData.environmentTextureRotationY;
  49456. }
  49457. scene.environmentTexture = cubeTexture;
  49458. }
  49459. }
  49460. if (parsedData.createDefaultSkybox === true) {
  49461. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  49462. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  49463. scene.createDefaultSkybox(scene.environmentTexture, isPBR, skyboxScale, skyboxBlurLevel);
  49464. }
  49465. }
  49466. // Finish
  49467. return true;
  49468. }
  49469. catch (err) {
  49470. var msg = logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + log;
  49471. if (onError) {
  49472. onError(msg, err);
  49473. }
  49474. else {
  49475. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  49476. throw err;
  49477. }
  49478. }
  49479. finally {
  49480. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  49481. _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 : ""));
  49482. }
  49483. }
  49484. return false;
  49485. },
  49486. loadAssetContainer: function (scene, data, rootUrl, onError) {
  49487. var container = loadAssetContainer(scene, data, rootUrl, onError);
  49488. return container;
  49489. }
  49490. });
  49491. /***/ }),
  49492. /***/ "./Loading/Plugins/index.ts":
  49493. /*!**********************************!*\
  49494. !*** ./Loading/Plugins/index.ts ***!
  49495. \**********************************/
  49496. /*! exports provided: _BabylonLoaderRegistered */
  49497. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49498. "use strict";
  49499. __webpack_require__.r(__webpack_exports__);
  49500. /* harmony import */ var _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./babylonFileLoader */ "./Loading/Plugins/babylonFileLoader.ts");
  49501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  49502. /***/ }),
  49503. /***/ "./Loading/index.ts":
  49504. /*!**************************!*\
  49505. !*** ./Loading/index.ts ***!
  49506. \**************************/
  49507. /*! exports provided: DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, _BabylonLoaderRegistered */
  49508. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49509. "use strict";
  49510. __webpack_require__.r(__webpack_exports__);
  49511. /* harmony import */ var _loadingScreen__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./loadingScreen */ "./Loading/loadingScreen.ts");
  49512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _loadingScreen__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  49513. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Plugins/index */ "./Loading/Plugins/index.ts");
  49514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_1__["_BabylonLoaderRegistered"]; });
  49515. /* harmony import */ var _sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneLoader */ "./Loading/sceneLoader.ts");
  49516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoaderProgressEvent"]; });
  49517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"]; });
  49518. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  49519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__["SceneLoaderFlags"]; });
  49520. /***/ }),
  49521. /***/ "./Loading/loadingScreen.ts":
  49522. /*!**********************************!*\
  49523. !*** ./Loading/loadingScreen.ts ***!
  49524. \**********************************/
  49525. /*! exports provided: DefaultLoadingScreen */
  49526. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49527. "use strict";
  49528. __webpack_require__.r(__webpack_exports__);
  49529. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return DefaultLoadingScreen; });
  49530. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  49531. /**
  49532. * Class used for the default loading screen
  49533. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  49534. */
  49535. var DefaultLoadingScreen = /** @class */ (function () {
  49536. /**
  49537. * Creates a new default loading screen
  49538. * @param _renderingCanvas defines the canvas used to render the scene
  49539. * @param _loadingText defines the default text to display
  49540. * @param _loadingDivBackgroundColor defines the default background color
  49541. */
  49542. function DefaultLoadingScreen(_renderingCanvas, _loadingText, _loadingDivBackgroundColor) {
  49543. if (_loadingText === void 0) { _loadingText = ""; }
  49544. if (_loadingDivBackgroundColor === void 0) { _loadingDivBackgroundColor = "black"; }
  49545. var _this = this;
  49546. this._renderingCanvas = _renderingCanvas;
  49547. this._loadingText = _loadingText;
  49548. this._loadingDivBackgroundColor = _loadingDivBackgroundColor;
  49549. // Resize
  49550. this._resizeLoadingUI = function () {
  49551. var canvasRect = _this._renderingCanvas.getBoundingClientRect();
  49552. var canvasPositioning = window.getComputedStyle(_this._renderingCanvas).position;
  49553. if (!_this._loadingDiv) {
  49554. return;
  49555. }
  49556. _this._loadingDiv.style.position = (canvasPositioning === "fixed") ? "fixed" : "absolute";
  49557. _this._loadingDiv.style.left = canvasRect.left + "px";
  49558. _this._loadingDiv.style.top = canvasRect.top + "px";
  49559. _this._loadingDiv.style.width = canvasRect.width + "px";
  49560. _this._loadingDiv.style.height = canvasRect.height + "px";
  49561. };
  49562. }
  49563. /**
  49564. * Function called to display the loading screen
  49565. */
  49566. DefaultLoadingScreen.prototype.displayLoadingUI = function () {
  49567. if (this._loadingDiv) {
  49568. // Do not add a loading screen if there is already one
  49569. return;
  49570. }
  49571. this._loadingDiv = document.createElement("div");
  49572. this._loadingDiv.id = "babylonjsLoadingDiv";
  49573. this._loadingDiv.style.opacity = "0";
  49574. this._loadingDiv.style.transition = "opacity 1.5s ease";
  49575. this._loadingDiv.style.pointerEvents = "none";
  49576. // Loading text
  49577. this._loadingTextDiv = document.createElement("div");
  49578. this._loadingTextDiv.style.position = "absolute";
  49579. this._loadingTextDiv.style.left = "0";
  49580. this._loadingTextDiv.style.top = "50%";
  49581. this._loadingTextDiv.style.marginTop = "80px";
  49582. this._loadingTextDiv.style.width = "100%";
  49583. this._loadingTextDiv.style.height = "20px";
  49584. this._loadingTextDiv.style.fontFamily = "Arial";
  49585. this._loadingTextDiv.style.fontSize = "14px";
  49586. this._loadingTextDiv.style.color = "white";
  49587. this._loadingTextDiv.style.textAlign = "center";
  49588. this._loadingTextDiv.innerHTML = "Loading";
  49589. this._loadingDiv.appendChild(this._loadingTextDiv);
  49590. //set the predefined text
  49591. this._loadingTextDiv.innerHTML = this._loadingText;
  49592. // Generating keyframes
  49593. var style = document.createElement('style');
  49594. style.type = 'text/css';
  49595. 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 }";
  49596. style.innerHTML = keyFrames;
  49597. document.getElementsByTagName('head')[0].appendChild(style);
  49598. // Loading img
  49599. var imgBack = new Image();
  49600. 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";
  49601. imgBack.style.position = "absolute";
  49602. imgBack.style.left = "50%";
  49603. imgBack.style.top = "50%";
  49604. imgBack.style.marginLeft = "-60px";
  49605. imgBack.style.marginTop = "-60px";
  49606. imgBack.style.animation = "spin1 2s infinite ease-in-out";
  49607. imgBack.style.webkitAnimation = "spin1 2s infinite ease-in-out";
  49608. imgBack.style.transformOrigin = "50% 50%";
  49609. imgBack.style.webkitTransformOrigin = "50% 50%";
  49610. this._loadingDiv.appendChild(imgBack);
  49611. this._resizeLoadingUI();
  49612. window.addEventListener("resize", this._resizeLoadingUI);
  49613. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  49614. document.body.appendChild(this._loadingDiv);
  49615. this._loadingDiv.style.opacity = "1";
  49616. };
  49617. /**
  49618. * Function called to hide the loading screen
  49619. */
  49620. DefaultLoadingScreen.prototype.hideLoadingUI = function () {
  49621. var _this = this;
  49622. if (!this._loadingDiv) {
  49623. return;
  49624. }
  49625. var onTransitionEnd = function () {
  49626. if (!_this._loadingDiv) {
  49627. return;
  49628. }
  49629. if (_this._loadingDiv.parentElement) {
  49630. _this._loadingDiv.parentElement.removeChild(_this._loadingDiv);
  49631. }
  49632. window.removeEventListener("resize", _this._resizeLoadingUI);
  49633. _this._loadingDiv = null;
  49634. };
  49635. this._loadingDiv.style.opacity = "0";
  49636. this._loadingDiv.addEventListener("transitionend", onTransitionEnd);
  49637. };
  49638. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIText", {
  49639. get: function () {
  49640. return this._loadingText;
  49641. },
  49642. /**
  49643. * Gets or sets the text to display while loading
  49644. */
  49645. set: function (text) {
  49646. this._loadingText = text;
  49647. if (this._loadingTextDiv) {
  49648. this._loadingTextDiv.innerHTML = this._loadingText;
  49649. }
  49650. },
  49651. enumerable: true,
  49652. configurable: true
  49653. });
  49654. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIBackgroundColor", {
  49655. /**
  49656. * Gets or sets the color to use for the background
  49657. */
  49658. get: function () {
  49659. return this._loadingDivBackgroundColor;
  49660. },
  49661. set: function (color) {
  49662. this._loadingDivBackgroundColor = color;
  49663. if (!this._loadingDiv) {
  49664. return;
  49665. }
  49666. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  49667. },
  49668. enumerable: true,
  49669. configurable: true
  49670. });
  49671. return DefaultLoadingScreen;
  49672. }());
  49673. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].DefaultLoadingScreenFactory = function (canvas) { return new DefaultLoadingScreen(canvas); };
  49674. /***/ }),
  49675. /***/ "./Loading/sceneLoader.ts":
  49676. /*!********************************!*\
  49677. !*** ./Loading/sceneLoader.ts ***!
  49678. \********************************/
  49679. /*! exports provided: SceneLoaderProgressEvent, SceneLoader */
  49680. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49681. "use strict";
  49682. __webpack_require__.r(__webpack_exports__);
  49683. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return SceneLoaderProgressEvent; });
  49684. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return SceneLoader; });
  49685. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  49686. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  49687. /* harmony import */ var _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/filesInputStore */ "./Misc/filesInputStore.ts");
  49688. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  49689. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  49690. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  49691. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  49692. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  49693. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  49694. /**
  49695. * Class used to represent data loading progression
  49696. */
  49697. var SceneLoaderProgressEvent = /** @class */ (function () {
  49698. /**
  49699. * Create a new progress event
  49700. * @param lengthComputable defines if data length to load can be evaluated
  49701. * @param loaded defines the loaded data length
  49702. * @param total defines the data length to load
  49703. */
  49704. function SceneLoaderProgressEvent(
  49705. /** defines if data length to load can be evaluated */
  49706. lengthComputable,
  49707. /** defines the loaded data length */
  49708. loaded,
  49709. /** defines the data length to load */
  49710. total) {
  49711. this.lengthComputable = lengthComputable;
  49712. this.loaded = loaded;
  49713. this.total = total;
  49714. }
  49715. /**
  49716. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  49717. * @param event defines the source event
  49718. * @returns a new SceneLoaderProgressEvent
  49719. */
  49720. SceneLoaderProgressEvent.FromProgressEvent = function (event) {
  49721. return new SceneLoaderProgressEvent(event.lengthComputable, event.loaded, event.total);
  49722. };
  49723. return SceneLoaderProgressEvent;
  49724. }());
  49725. /**
  49726. * Class used to load scene from various file formats using registered plugins
  49727. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  49728. */
  49729. var SceneLoader = /** @class */ (function () {
  49730. function SceneLoader() {
  49731. }
  49732. Object.defineProperty(SceneLoader, "ForceFullSceneLoadingForIncremental", {
  49733. /**
  49734. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49735. */
  49736. get: function () {
  49737. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental;
  49738. },
  49739. set: function (value) {
  49740. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental = value;
  49741. },
  49742. enumerable: true,
  49743. configurable: true
  49744. });
  49745. Object.defineProperty(SceneLoader, "ShowLoadingScreen", {
  49746. /**
  49747. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49748. */
  49749. get: function () {
  49750. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen;
  49751. },
  49752. set: function (value) {
  49753. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen = value;
  49754. },
  49755. enumerable: true,
  49756. configurable: true
  49757. });
  49758. Object.defineProperty(SceneLoader, "loggingLevel", {
  49759. /**
  49760. * Defines the current logging level (while loading the scene)
  49761. * @ignorenaming
  49762. */
  49763. get: function () {
  49764. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel;
  49765. },
  49766. set: function (value) {
  49767. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel = value;
  49768. },
  49769. enumerable: true,
  49770. configurable: true
  49771. });
  49772. Object.defineProperty(SceneLoader, "CleanBoneMatrixWeights", {
  49773. /**
  49774. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49775. */
  49776. get: function () {
  49777. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights;
  49778. },
  49779. set: function (value) {
  49780. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights = value;
  49781. },
  49782. enumerable: true,
  49783. configurable: true
  49784. });
  49785. SceneLoader._getDefaultPlugin = function () {
  49786. return SceneLoader._registeredPlugins[".babylon"];
  49787. };
  49788. SceneLoader._getPluginForExtension = function (extension) {
  49789. var registeredPlugin = SceneLoader._registeredPlugins[extension];
  49790. if (registeredPlugin) {
  49791. return registeredPlugin;
  49792. }
  49793. _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");
  49794. return SceneLoader._getDefaultPlugin();
  49795. };
  49796. SceneLoader._getPluginForDirectLoad = function (data) {
  49797. for (var extension in SceneLoader._registeredPlugins) {
  49798. var plugin = SceneLoader._registeredPlugins[extension].plugin;
  49799. if (plugin.canDirectLoad && plugin.canDirectLoad(data)) {
  49800. return SceneLoader._registeredPlugins[extension];
  49801. }
  49802. }
  49803. return SceneLoader._getDefaultPlugin();
  49804. };
  49805. SceneLoader._getPluginForFilename = function (sceneFilename) {
  49806. var queryStringPosition = sceneFilename.indexOf("?");
  49807. if (queryStringPosition !== -1) {
  49808. sceneFilename = sceneFilename.substring(0, queryStringPosition);
  49809. }
  49810. var dotPosition = sceneFilename.lastIndexOf(".");
  49811. var extension = sceneFilename.substring(dotPosition, sceneFilename.length).toLowerCase();
  49812. return SceneLoader._getPluginForExtension(extension);
  49813. };
  49814. // use babylon file loader directly if sceneFilename is prefixed with "data:"
  49815. SceneLoader._getDirectLoad = function (sceneFilename) {
  49816. if (sceneFilename.substr(0, 5) === "data:") {
  49817. return sceneFilename.substr(5);
  49818. }
  49819. return null;
  49820. };
  49821. SceneLoader._loadData = function (fileInfo, scene, onSuccess, onProgress, onError, onDispose, pluginExtension) {
  49822. var directLoad = SceneLoader._getDirectLoad(fileInfo.name);
  49823. var registeredPlugin = pluginExtension ? SceneLoader._getPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._getPluginForDirectLoad(fileInfo.name) : SceneLoader._getPluginForFilename(fileInfo.name));
  49824. var plugin;
  49825. if (registeredPlugin.plugin.createPlugin) {
  49826. plugin = registeredPlugin.plugin.createPlugin();
  49827. }
  49828. else {
  49829. plugin = registeredPlugin.plugin;
  49830. }
  49831. if (!plugin) {
  49832. 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.";
  49833. }
  49834. var useArrayBuffer = registeredPlugin.isBinary;
  49835. var offlineProvider;
  49836. SceneLoader.OnPluginActivatedObservable.notifyObservers(plugin);
  49837. var dataCallback = function (data, responseURL) {
  49838. if (scene.isDisposed) {
  49839. onError("Scene has been disposed");
  49840. return;
  49841. }
  49842. scene.offlineProvider = offlineProvider;
  49843. onSuccess(plugin, data, responseURL);
  49844. };
  49845. var request = null;
  49846. var pluginDisposed = false;
  49847. var onDisposeObservable = plugin.onDisposeObservable;
  49848. if (onDisposeObservable) {
  49849. onDisposeObservable.add(function () {
  49850. pluginDisposed = true;
  49851. if (request) {
  49852. request.abort();
  49853. request = null;
  49854. }
  49855. onDispose();
  49856. });
  49857. }
  49858. var manifestChecked = function () {
  49859. if (pluginDisposed) {
  49860. return;
  49861. }
  49862. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(fileInfo.url, dataCallback, onProgress ? function (event) {
  49863. onProgress(SceneLoaderProgressEvent.FromProgressEvent(event));
  49864. } : undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  49865. onError("Failed to load scene." + (exception ? " " + exception.message : ""), exception);
  49866. });
  49867. };
  49868. if (directLoad) {
  49869. dataCallback(directLoad);
  49870. return plugin;
  49871. }
  49872. var file = fileInfo.file || _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad[fileInfo.name.toLowerCase()];
  49873. if (fileInfo.rootUrl.indexOf("file:") === -1 || (fileInfo.rootUrl.indexOf("file:") !== -1 && !file)) {
  49874. var engine = scene.getEngine();
  49875. var canUseOfflineSupport = engine.enableOfflineSupport;
  49876. if (canUseOfflineSupport) {
  49877. // Also check for exceptions
  49878. var exceptionFound = false;
  49879. for (var _i = 0, _a = scene.disableOfflineSupportExceptionRules; _i < _a.length; _i++) {
  49880. var regex = _a[_i];
  49881. if (regex.test(fileInfo.url)) {
  49882. exceptionFound = true;
  49883. break;
  49884. }
  49885. }
  49886. canUseOfflineSupport = !exceptionFound;
  49887. }
  49888. if (canUseOfflineSupport && _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory) {
  49889. // Checking if a manifest file has been set for this scene and if offline mode has been requested
  49890. offlineProvider = _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory(fileInfo.url, manifestChecked, engine.disableManifestCheck);
  49891. }
  49892. else {
  49893. manifestChecked();
  49894. }
  49895. }
  49896. // Loading file from disk via input file or drag'n'drop
  49897. else {
  49898. if (file) {
  49899. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ReadFile(file, dataCallback, onProgress, useArrayBuffer);
  49900. }
  49901. else {
  49902. onError("Unable to find file named " + fileInfo.name);
  49903. }
  49904. }
  49905. return plugin;
  49906. };
  49907. SceneLoader._getFileInfo = function (rootUrl, sceneFilename) {
  49908. var url;
  49909. var name;
  49910. var file = null;
  49911. if (!sceneFilename) {
  49912. url = rootUrl;
  49913. name = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(rootUrl);
  49914. rootUrl = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFolderPath(rootUrl);
  49915. }
  49916. else if (sceneFilename.name) {
  49917. var sceneFile = sceneFilename;
  49918. url = rootUrl + sceneFile.name;
  49919. name = sceneFile.name;
  49920. file = sceneFile;
  49921. }
  49922. else {
  49923. var filename = sceneFilename;
  49924. if (filename.substr(0, 1) === "/") {
  49925. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Wrong sceneFilename parameter");
  49926. return null;
  49927. }
  49928. url = rootUrl + filename;
  49929. name = filename;
  49930. }
  49931. return {
  49932. url: url,
  49933. rootUrl: rootUrl,
  49934. name: name,
  49935. file: file
  49936. };
  49937. };
  49938. // Public functions
  49939. /**
  49940. * Gets a plugin that can load the given extension
  49941. * @param extension defines the extension to load
  49942. * @returns a plugin or null if none works
  49943. */
  49944. SceneLoader.GetPluginForExtension = function (extension) {
  49945. return SceneLoader._getPluginForExtension(extension).plugin;
  49946. };
  49947. /**
  49948. * Gets a boolean indicating that the given extension can be loaded
  49949. * @param extension defines the extension to load
  49950. * @returns true if the extension is supported
  49951. */
  49952. SceneLoader.IsPluginForExtensionAvailable = function (extension) {
  49953. return !!SceneLoader._registeredPlugins[extension];
  49954. };
  49955. /**
  49956. * Adds a new plugin to the list of registered plugins
  49957. * @param plugin defines the plugin to add
  49958. */
  49959. SceneLoader.RegisterPlugin = function (plugin) {
  49960. if (typeof plugin.extensions === "string") {
  49961. var extension = plugin.extensions;
  49962. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  49963. plugin: plugin,
  49964. isBinary: false
  49965. };
  49966. }
  49967. else {
  49968. var extensions = plugin.extensions;
  49969. Object.keys(extensions).forEach(function (extension) {
  49970. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  49971. plugin: plugin,
  49972. isBinary: extensions[extension].isBinary
  49973. };
  49974. });
  49975. }
  49976. };
  49977. /**
  49978. * Import meshes into a scene
  49979. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49980. * @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)
  49981. * @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)
  49982. * @param scene the instance of BABYLON.Scene to append to
  49983. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  49984. * @param onProgress a callback with a progress event for each file being loaded
  49985. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49986. * @param pluginExtension the extension used to determine the plugin
  49987. * @returns The loaded plugin
  49988. */
  49989. SceneLoader.ImportMesh = function (meshNames, rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  49990. if (sceneFilename === void 0) { sceneFilename = ""; }
  49991. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49992. if (onSuccess === void 0) { onSuccess = null; }
  49993. if (onProgress === void 0) { onProgress = null; }
  49994. if (onError === void 0) { onError = null; }
  49995. if (pluginExtension === void 0) { pluginExtension = null; }
  49996. if (!scene) {
  49997. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to import mesh to");
  49998. return null;
  49999. }
  50000. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  50001. if (!fileInfo) {
  50002. return null;
  50003. }
  50004. var loadingToken = {};
  50005. scene._addPendingData(loadingToken);
  50006. var disposeHandler = function () {
  50007. scene._removePendingData(loadingToken);
  50008. };
  50009. var errorHandler = function (message, exception) {
  50010. var errorMessage = "Unable to import meshes from " + fileInfo.url + ": " + message;
  50011. if (onError) {
  50012. onError(scene, errorMessage, exception);
  50013. }
  50014. else {
  50015. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  50016. // should the exception be thrown?
  50017. }
  50018. disposeHandler();
  50019. };
  50020. var progressHandler = onProgress ? function (event) {
  50021. try {
  50022. onProgress(event);
  50023. }
  50024. catch (e) {
  50025. errorHandler("Error in onProgress callback", e);
  50026. }
  50027. } : undefined;
  50028. var successHandler = function (meshes, particleSystems, skeletons, animationGroups) {
  50029. scene.importedMeshesFiles.push(fileInfo.url);
  50030. if (onSuccess) {
  50031. try {
  50032. onSuccess(meshes, particleSystems, skeletons, animationGroups);
  50033. }
  50034. catch (e) {
  50035. errorHandler("Error in onSuccess callback", e);
  50036. }
  50037. }
  50038. scene._removePendingData(loadingToken);
  50039. };
  50040. return SceneLoader._loadData(fileInfo, scene, function (plugin, data, responseURL) {
  50041. if (plugin.rewriteRootURL) {
  50042. fileInfo.rootUrl = plugin.rewriteRootURL(fileInfo.rootUrl, responseURL);
  50043. }
  50044. if (plugin.importMesh) {
  50045. var syncedPlugin = plugin;
  50046. var meshes = new Array();
  50047. var particleSystems = new Array();
  50048. var skeletons = new Array();
  50049. if (!syncedPlugin.importMesh(meshNames, scene, data, fileInfo.rootUrl, meshes, particleSystems, skeletons, errorHandler)) {
  50050. return;
  50051. }
  50052. scene.loadingPluginName = plugin.name;
  50053. successHandler(meshes, particleSystems, skeletons, []);
  50054. }
  50055. else {
  50056. var asyncedPlugin = plugin;
  50057. asyncedPlugin.importMeshAsync(meshNames, scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (result) {
  50058. scene.loadingPluginName = plugin.name;
  50059. successHandler(result.meshes, result.particleSystems, result.skeletons, result.animationGroups);
  50060. }).catch(function (error) {
  50061. errorHandler(error.message, error);
  50062. });
  50063. }
  50064. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  50065. };
  50066. /**
  50067. * Import meshes into a scene
  50068. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50069. * @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)
  50070. * @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)
  50071. * @param scene the instance of BABYLON.Scene to append to
  50072. * @param onProgress a callback with a progress event for each file being loaded
  50073. * @param pluginExtension the extension used to determine the plugin
  50074. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  50075. */
  50076. SceneLoader.ImportMeshAsync = function (meshNames, rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  50077. if (sceneFilename === void 0) { sceneFilename = ""; }
  50078. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  50079. if (onProgress === void 0) { onProgress = null; }
  50080. if (pluginExtension === void 0) { pluginExtension = null; }
  50081. return new Promise(function (resolve, reject) {
  50082. SceneLoader.ImportMesh(meshNames, rootUrl, sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  50083. resolve({
  50084. meshes: meshes,
  50085. particleSystems: particleSystems,
  50086. skeletons: skeletons,
  50087. animationGroups: animationGroups
  50088. });
  50089. }, onProgress, function (scene, message, exception) {
  50090. reject(exception || new Error(message));
  50091. }, pluginExtension);
  50092. });
  50093. };
  50094. /**
  50095. * Load a scene
  50096. * @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)
  50097. * @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)
  50098. * @param engine is the instance of BABYLON.Engine to use to create the scene
  50099. * @param onSuccess a callback with the scene when import succeeds
  50100. * @param onProgress a callback with a progress event for each file being loaded
  50101. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50102. * @param pluginExtension the extension used to determine the plugin
  50103. * @returns The loaded plugin
  50104. */
  50105. SceneLoader.Load = function (rootUrl, sceneFilename, engine, onSuccess, onProgress, onError, pluginExtension) {
  50106. if (sceneFilename === void 0) { sceneFilename = ""; }
  50107. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  50108. if (onSuccess === void 0) { onSuccess = null; }
  50109. if (onProgress === void 0) { onProgress = null; }
  50110. if (onError === void 0) { onError = null; }
  50111. if (pluginExtension === void 0) { pluginExtension = null; }
  50112. if (!engine) {
  50113. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("No engine available");
  50114. return null;
  50115. }
  50116. return SceneLoader.Append(rootUrl, sceneFilename, new _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"](engine), onSuccess, onProgress, onError, pluginExtension);
  50117. };
  50118. /**
  50119. * Load a scene
  50120. * @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)
  50121. * @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)
  50122. * @param engine is the instance of BABYLON.Engine to use to create the scene
  50123. * @param onProgress a callback with a progress event for each file being loaded
  50124. * @param pluginExtension the extension used to determine the plugin
  50125. * @returns The loaded scene
  50126. */
  50127. SceneLoader.LoadAsync = function (rootUrl, sceneFilename, engine, onProgress, pluginExtension) {
  50128. if (sceneFilename === void 0) { sceneFilename = ""; }
  50129. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  50130. if (onProgress === void 0) { onProgress = null; }
  50131. if (pluginExtension === void 0) { pluginExtension = null; }
  50132. return new Promise(function (resolve, reject) {
  50133. SceneLoader.Load(rootUrl, sceneFilename, engine, function (scene) {
  50134. resolve(scene);
  50135. }, onProgress, function (scene, message, exception) {
  50136. reject(exception || new Error(message));
  50137. }, pluginExtension);
  50138. });
  50139. };
  50140. /**
  50141. * Append a scene
  50142. * @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)
  50143. * @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)
  50144. * @param scene is the instance of BABYLON.Scene to append to
  50145. * @param onSuccess a callback with the scene when import succeeds
  50146. * @param onProgress a callback with a progress event for each file being loaded
  50147. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50148. * @param pluginExtension the extension used to determine the plugin
  50149. * @returns The loaded plugin
  50150. */
  50151. SceneLoader.Append = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  50152. if (sceneFilename === void 0) { sceneFilename = ""; }
  50153. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  50154. if (onSuccess === void 0) { onSuccess = null; }
  50155. if (onProgress === void 0) { onProgress = null; }
  50156. if (onError === void 0) { onError = null; }
  50157. if (pluginExtension === void 0) { pluginExtension = null; }
  50158. if (!scene) {
  50159. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to append to");
  50160. return null;
  50161. }
  50162. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  50163. if (!fileInfo) {
  50164. return null;
  50165. }
  50166. if (SceneLoader.ShowLoadingScreen) {
  50167. scene.getEngine().displayLoadingUI();
  50168. }
  50169. var loadingToken = {};
  50170. scene._addPendingData(loadingToken);
  50171. var disposeHandler = function () {
  50172. scene._removePendingData(loadingToken);
  50173. scene.getEngine().hideLoadingUI();
  50174. };
  50175. var errorHandler = function (message, exception) {
  50176. var errorMessage = "Unable to load from " + fileInfo.url + (message ? ": " + message : "");
  50177. if (onError) {
  50178. onError(scene, errorMessage, exception);
  50179. }
  50180. else {
  50181. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  50182. // should the exception be thrown?
  50183. }
  50184. disposeHandler();
  50185. };
  50186. var progressHandler = onProgress ? function (event) {
  50187. try {
  50188. onProgress(event);
  50189. }
  50190. catch (e) {
  50191. errorHandler("Error in onProgress callback", e);
  50192. }
  50193. } : undefined;
  50194. var successHandler = function () {
  50195. if (onSuccess) {
  50196. try {
  50197. onSuccess(scene);
  50198. }
  50199. catch (e) {
  50200. errorHandler("Error in onSuccess callback", e);
  50201. }
  50202. }
  50203. scene._removePendingData(loadingToken);
  50204. };
  50205. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  50206. if (plugin.load) {
  50207. var syncedPlugin = plugin;
  50208. if (!syncedPlugin.load(scene, data, fileInfo.rootUrl, errorHandler)) {
  50209. return;
  50210. }
  50211. scene.loadingPluginName = plugin.name;
  50212. successHandler();
  50213. }
  50214. else {
  50215. var asyncedPlugin = plugin;
  50216. asyncedPlugin.loadAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function () {
  50217. scene.loadingPluginName = plugin.name;
  50218. successHandler();
  50219. }).catch(function (error) {
  50220. errorHandler(error.message, error);
  50221. });
  50222. }
  50223. if (SceneLoader.ShowLoadingScreen) {
  50224. scene.executeWhenReady(function () {
  50225. scene.getEngine().hideLoadingUI();
  50226. });
  50227. }
  50228. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  50229. };
  50230. /**
  50231. * Append a scene
  50232. * @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)
  50233. * @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)
  50234. * @param scene is the instance of BABYLON.Scene to append to
  50235. * @param onProgress a callback with a progress event for each file being loaded
  50236. * @param pluginExtension the extension used to determine the plugin
  50237. * @returns The given scene
  50238. */
  50239. SceneLoader.AppendAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  50240. if (sceneFilename === void 0) { sceneFilename = ""; }
  50241. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  50242. if (onProgress === void 0) { onProgress = null; }
  50243. if (pluginExtension === void 0) { pluginExtension = null; }
  50244. return new Promise(function (resolve, reject) {
  50245. SceneLoader.Append(rootUrl, sceneFilename, scene, function (scene) {
  50246. resolve(scene);
  50247. }, onProgress, function (scene, message, exception) {
  50248. reject(exception || new Error(message));
  50249. }, pluginExtension);
  50250. });
  50251. };
  50252. /**
  50253. * Load a scene into an asset container
  50254. * @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)
  50255. * @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)
  50256. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  50257. * @param onSuccess a callback with the scene when import succeeds
  50258. * @param onProgress a callback with a progress event for each file being loaded
  50259. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50260. * @param pluginExtension the extension used to determine the plugin
  50261. * @returns The loaded plugin
  50262. */
  50263. SceneLoader.LoadAssetContainer = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  50264. if (sceneFilename === void 0) { sceneFilename = ""; }
  50265. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  50266. if (onSuccess === void 0) { onSuccess = null; }
  50267. if (onProgress === void 0) { onProgress = null; }
  50268. if (onError === void 0) { onError = null; }
  50269. if (pluginExtension === void 0) { pluginExtension = null; }
  50270. if (!scene) {
  50271. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to load asset container to");
  50272. return null;
  50273. }
  50274. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  50275. if (!fileInfo) {
  50276. return null;
  50277. }
  50278. var loadingToken = {};
  50279. scene._addPendingData(loadingToken);
  50280. var disposeHandler = function () {
  50281. scene._removePendingData(loadingToken);
  50282. };
  50283. var errorHandler = function (message, exception) {
  50284. var errorMessage = "Unable to load assets from " + fileInfo.url + (message ? ": " + message : "");
  50285. if (onError) {
  50286. onError(scene, errorMessage, exception);
  50287. }
  50288. else {
  50289. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  50290. // should the exception be thrown?
  50291. }
  50292. disposeHandler();
  50293. };
  50294. var progressHandler = onProgress ? function (event) {
  50295. try {
  50296. onProgress(event);
  50297. }
  50298. catch (e) {
  50299. errorHandler("Error in onProgress callback", e);
  50300. }
  50301. } : undefined;
  50302. var successHandler = function (assets) {
  50303. if (onSuccess) {
  50304. try {
  50305. onSuccess(assets);
  50306. }
  50307. catch (e) {
  50308. errorHandler("Error in onSuccess callback", e);
  50309. }
  50310. }
  50311. scene._removePendingData(loadingToken);
  50312. };
  50313. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  50314. if (plugin.loadAssetContainer) {
  50315. var syncedPlugin = plugin;
  50316. var assetContainer = syncedPlugin.loadAssetContainer(scene, data, fileInfo.rootUrl, errorHandler);
  50317. if (!assetContainer) {
  50318. return;
  50319. }
  50320. scene.loadingPluginName = plugin.name;
  50321. successHandler(assetContainer);
  50322. }
  50323. else if (plugin.loadAssetContainerAsync) {
  50324. var asyncedPlugin = plugin;
  50325. asyncedPlugin.loadAssetContainerAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (assetContainer) {
  50326. scene.loadingPluginName = plugin.name;
  50327. successHandler(assetContainer);
  50328. }).catch(function (error) {
  50329. errorHandler(error.message, error);
  50330. });
  50331. }
  50332. else {
  50333. errorHandler("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.");
  50334. }
  50335. if (SceneLoader.ShowLoadingScreen) {
  50336. scene.executeWhenReady(function () {
  50337. scene.getEngine().hideLoadingUI();
  50338. });
  50339. }
  50340. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  50341. };
  50342. /**
  50343. * Load a scene into an asset container
  50344. * @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)
  50345. * @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)
  50346. * @param scene is the instance of Scene to append to
  50347. * @param onProgress a callback with a progress event for each file being loaded
  50348. * @param pluginExtension the extension used to determine the plugin
  50349. * @returns The loaded asset container
  50350. */
  50351. SceneLoader.LoadAssetContainerAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  50352. if (sceneFilename === void 0) { sceneFilename = ""; }
  50353. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  50354. if (onProgress === void 0) { onProgress = null; }
  50355. if (pluginExtension === void 0) { pluginExtension = null; }
  50356. return new Promise(function (resolve, reject) {
  50357. SceneLoader.LoadAssetContainer(rootUrl, sceneFilename, scene, function (assetContainer) {
  50358. resolve(assetContainer);
  50359. }, onProgress, function (scene, message, exception) {
  50360. reject(exception || new Error(message));
  50361. }, pluginExtension);
  50362. });
  50363. };
  50364. /**
  50365. * No logging while loading
  50366. */
  50367. SceneLoader.NO_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_NO_LOGGING;
  50368. /**
  50369. * Minimal logging while loading
  50370. */
  50371. SceneLoader.MINIMAL_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_MINIMAL_LOGGING;
  50372. /**
  50373. * Summary logging while loading
  50374. */
  50375. SceneLoader.SUMMARY_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_SUMMARY_LOGGING;
  50376. /**
  50377. * Detailled logging while loading
  50378. */
  50379. SceneLoader.DETAILED_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_DETAILED_LOGGING;
  50380. // Members
  50381. /**
  50382. * Event raised when a plugin is used to load a scene
  50383. */
  50384. SceneLoader.OnPluginActivatedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  50385. SceneLoader._registeredPlugins = {};
  50386. return SceneLoader;
  50387. }());
  50388. /***/ }),
  50389. /***/ "./Loading/sceneLoaderFlags.ts":
  50390. /*!*************************************!*\
  50391. !*** ./Loading/sceneLoaderFlags.ts ***!
  50392. \*************************************/
  50393. /*! exports provided: SceneLoaderFlags */
  50394. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50395. "use strict";
  50396. __webpack_require__.r(__webpack_exports__);
  50397. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return SceneLoaderFlags; });
  50398. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  50399. /**
  50400. * Class used to represent data loading progression
  50401. */
  50402. var SceneLoaderFlags = /** @class */ (function () {
  50403. function SceneLoaderFlags() {
  50404. }
  50405. Object.defineProperty(SceneLoaderFlags, "ForceFullSceneLoadingForIncremental", {
  50406. /**
  50407. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  50408. */
  50409. get: function () {
  50410. return SceneLoaderFlags._ForceFullSceneLoadingForIncremental;
  50411. },
  50412. set: function (value) {
  50413. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = value;
  50414. },
  50415. enumerable: true,
  50416. configurable: true
  50417. });
  50418. Object.defineProperty(SceneLoaderFlags, "ShowLoadingScreen", {
  50419. /**
  50420. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  50421. */
  50422. get: function () {
  50423. return SceneLoaderFlags._ShowLoadingScreen;
  50424. },
  50425. set: function (value) {
  50426. SceneLoaderFlags._ShowLoadingScreen = value;
  50427. },
  50428. enumerable: true,
  50429. configurable: true
  50430. });
  50431. Object.defineProperty(SceneLoaderFlags, "loggingLevel", {
  50432. /**
  50433. * Defines the current logging level (while loading the scene)
  50434. * @ignorenaming
  50435. */
  50436. get: function () {
  50437. return SceneLoaderFlags._loggingLevel;
  50438. },
  50439. set: function (value) {
  50440. SceneLoaderFlags._loggingLevel = value;
  50441. },
  50442. enumerable: true,
  50443. configurable: true
  50444. });
  50445. Object.defineProperty(SceneLoaderFlags, "CleanBoneMatrixWeights", {
  50446. /**
  50447. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  50448. */
  50449. get: function () {
  50450. return SceneLoaderFlags._CleanBoneMatrixWeights;
  50451. },
  50452. set: function (value) {
  50453. SceneLoaderFlags._CleanBoneMatrixWeights = value;
  50454. },
  50455. enumerable: true,
  50456. configurable: true
  50457. });
  50458. // Flags
  50459. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = false;
  50460. SceneLoaderFlags._ShowLoadingScreen = true;
  50461. SceneLoaderFlags._CleanBoneMatrixWeights = false;
  50462. SceneLoaderFlags._loggingLevel = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].SCENELOADER_NO_LOGGING;
  50463. return SceneLoaderFlags;
  50464. }());
  50465. /***/ }),
  50466. /***/ "./Materials/Background/backgroundMaterial.ts":
  50467. /*!****************************************************!*\
  50468. !*** ./Materials/Background/backgroundMaterial.ts ***!
  50469. \****************************************************/
  50470. /*! exports provided: BackgroundMaterial */
  50471. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50472. "use strict";
  50473. __webpack_require__.r(__webpack_exports__);
  50474. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return BackgroundMaterial; });
  50475. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  50476. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  50477. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  50478. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  50479. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  50480. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  50481. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  50482. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  50483. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  50484. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  50485. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  50486. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  50487. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  50488. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  50489. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  50490. /* harmony import */ var _Shaders_background_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Shaders/background.fragment */ "./Shaders/background.fragment.ts");
  50491. /* harmony import */ var _Shaders_background_vertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Shaders/background.vertex */ "./Shaders/background.vertex.ts");
  50492. /**
  50493. * Background material defines definition.
  50494. * @hidden Mainly internal Use
  50495. */
  50496. var BackgroundMaterialDefines = /** @class */ (function (_super) {
  50497. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterialDefines, _super);
  50498. /**
  50499. * Constructor of the defines.
  50500. */
  50501. function BackgroundMaterialDefines() {
  50502. var _this = _super.call(this) || this;
  50503. /**
  50504. * True if the diffuse texture is in use.
  50505. */
  50506. _this.DIFFUSE = false;
  50507. /**
  50508. * The direct UV channel to use.
  50509. */
  50510. _this.DIFFUSEDIRECTUV = 0;
  50511. /**
  50512. * True if the diffuse texture is in gamma space.
  50513. */
  50514. _this.GAMMADIFFUSE = false;
  50515. /**
  50516. * True if the diffuse texture has opacity in the alpha channel.
  50517. */
  50518. _this.DIFFUSEHASALPHA = false;
  50519. /**
  50520. * True if you want the material to fade to transparent at grazing angle.
  50521. */
  50522. _this.OPACITYFRESNEL = false;
  50523. /**
  50524. * True if an extra blur needs to be added in the reflection.
  50525. */
  50526. _this.REFLECTIONBLUR = false;
  50527. /**
  50528. * True if you want the material to fade to reflection at grazing angle.
  50529. */
  50530. _this.REFLECTIONFRESNEL = false;
  50531. /**
  50532. * True if you want the material to falloff as far as you move away from the scene center.
  50533. */
  50534. _this.REFLECTIONFALLOFF = false;
  50535. /**
  50536. * False if the current Webgl implementation does not support the texture lod extension.
  50537. */
  50538. _this.TEXTURELODSUPPORT = false;
  50539. /**
  50540. * True to ensure the data are premultiplied.
  50541. */
  50542. _this.PREMULTIPLYALPHA = false;
  50543. /**
  50544. * True if the texture contains cooked RGB values and not gray scaled multipliers.
  50545. */
  50546. _this.USERGBCOLOR = false;
  50547. /**
  50548. * True if highlight and shadow levels have been specified. It can help ensuring the main perceived color
  50549. * stays aligned with the desired configuration.
  50550. */
  50551. _this.USEHIGHLIGHTANDSHADOWCOLORS = false;
  50552. /**
  50553. * True to add noise in order to reduce the banding effect.
  50554. */
  50555. _this.NOISE = false;
  50556. /**
  50557. * is the reflection texture in BGR color scheme?
  50558. * Mainly used to solve a bug in ios10 video tag
  50559. */
  50560. _this.REFLECTIONBGR = false;
  50561. _this.IMAGEPROCESSING = false;
  50562. _this.VIGNETTE = false;
  50563. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  50564. _this.VIGNETTEBLENDMODEOPAQUE = false;
  50565. _this.TONEMAPPING = false;
  50566. _this.TONEMAPPING_ACES = false;
  50567. _this.CONTRAST = false;
  50568. _this.COLORCURVES = false;
  50569. _this.COLORGRADING = false;
  50570. _this.COLORGRADING3D = false;
  50571. _this.SAMPLER3DGREENDEPTH = false;
  50572. _this.SAMPLER3DBGRMAP = false;
  50573. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  50574. _this.EXPOSURE = false;
  50575. _this.MULTIVIEW = false;
  50576. // Reflection.
  50577. _this.REFLECTION = false;
  50578. _this.REFLECTIONMAP_3D = false;
  50579. _this.REFLECTIONMAP_SPHERICAL = false;
  50580. _this.REFLECTIONMAP_PLANAR = false;
  50581. _this.REFLECTIONMAP_CUBIC = false;
  50582. _this.REFLECTIONMAP_PROJECTION = false;
  50583. _this.REFLECTIONMAP_SKYBOX = false;
  50584. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  50585. _this.REFLECTIONMAP_EXPLICIT = false;
  50586. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  50587. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  50588. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  50589. _this.INVERTCUBICMAP = false;
  50590. _this.REFLECTIONMAP_OPPOSITEZ = false;
  50591. _this.LODINREFLECTIONALPHA = false;
  50592. _this.GAMMAREFLECTION = false;
  50593. _this.RGBDREFLECTION = false;
  50594. _this.EQUIRECTANGULAR_RELFECTION_FOV = false;
  50595. // Default BJS.
  50596. _this.MAINUV1 = false;
  50597. _this.MAINUV2 = false;
  50598. _this.UV1 = false;
  50599. _this.UV2 = false;
  50600. _this.CLIPPLANE = false;
  50601. _this.CLIPPLANE2 = false;
  50602. _this.CLIPPLANE3 = false;
  50603. _this.CLIPPLANE4 = false;
  50604. _this.POINTSIZE = false;
  50605. _this.FOG = false;
  50606. _this.NORMAL = false;
  50607. _this.NUM_BONE_INFLUENCERS = 0;
  50608. _this.BonesPerMesh = 0;
  50609. _this.INSTANCES = false;
  50610. _this.SHADOWFLOAT = false;
  50611. _this.rebuild();
  50612. return _this;
  50613. }
  50614. return BackgroundMaterialDefines;
  50615. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  50616. /**
  50617. * Background material used to create an efficient environement around your scene.
  50618. */
  50619. var BackgroundMaterial = /** @class */ (function (_super) {
  50620. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterial, _super);
  50621. /**
  50622. * Instantiates a Background Material in the given scene
  50623. * @param name The friendly name of the material
  50624. * @param scene The scene to add the material to
  50625. */
  50626. function BackgroundMaterial(name, scene) {
  50627. var _this = _super.call(this, name, scene) || this;
  50628. /**
  50629. * Key light Color (multiply against the environement texture)
  50630. */
  50631. _this.primaryColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  50632. _this._primaryColorShadowLevel = 0;
  50633. _this._primaryColorHighlightLevel = 0;
  50634. /**
  50635. * Reflection Texture used in the material.
  50636. * Should be author in a specific way for the best result (refer to the documentation).
  50637. */
  50638. _this.reflectionTexture = null;
  50639. /**
  50640. * Reflection Texture level of blur.
  50641. *
  50642. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  50643. * texture twice.
  50644. */
  50645. _this.reflectionBlur = 0;
  50646. /**
  50647. * Diffuse Texture used in the material.
  50648. * Should be author in a specific way for the best result (refer to the documentation).
  50649. */
  50650. _this.diffuseTexture = null;
  50651. _this._shadowLights = null;
  50652. /**
  50653. * Specify the list of lights casting shadow on the material.
  50654. * All scene shadow lights will be included if null.
  50655. */
  50656. _this.shadowLights = null;
  50657. /**
  50658. * Helps adjusting the shadow to a softer level if required.
  50659. * 0 means black shadows and 1 means no shadows.
  50660. */
  50661. _this.shadowLevel = 0;
  50662. /**
  50663. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  50664. * It is usually zero but might be interesting to modify according to your setup.
  50665. */
  50666. _this.sceneCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  50667. /**
  50668. * This helps specifying that the material is falling off to the sky box at grazing angle.
  50669. * This helps ensuring a nice transition when the camera goes under the ground.
  50670. */
  50671. _this.opacityFresnel = true;
  50672. /**
  50673. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  50674. * This helps adding a mirror texture on the ground.
  50675. */
  50676. _this.reflectionFresnel = false;
  50677. /**
  50678. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  50679. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  50680. */
  50681. _this.reflectionFalloffDistance = 0.0;
  50682. /**
  50683. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  50684. */
  50685. _this.reflectionAmount = 1.0;
  50686. /**
  50687. * This specifies the weight of the reflection at grazing angle.
  50688. */
  50689. _this.reflectionReflectance0 = 0.05;
  50690. /**
  50691. * This specifies the weight of the reflection at a perpendicular point of view.
  50692. */
  50693. _this.reflectionReflectance90 = 0.5;
  50694. /**
  50695. * Helps to directly use the maps channels instead of their level.
  50696. */
  50697. _this.useRGBColor = true;
  50698. /**
  50699. * This helps reducing the banding effect that could occur on the background.
  50700. */
  50701. _this.enableNoise = false;
  50702. _this._fovMultiplier = 1.0;
  50703. /**
  50704. * Enable the FOV adjustment feature controlled by fovMultiplier.
  50705. */
  50706. _this.useEquirectangularFOV = false;
  50707. _this._maxSimultaneousLights = 4;
  50708. /**
  50709. * Number of Simultaneous lights allowed on the material.
  50710. */
  50711. _this.maxSimultaneousLights = 4;
  50712. /**
  50713. * Keep track of the image processing observer to allow dispose and replace.
  50714. */
  50715. _this._imageProcessingObserver = null;
  50716. /**
  50717. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  50718. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  50719. */
  50720. _this.switchToBGR = false;
  50721. // Temp values kept as cache in the material.
  50722. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  50723. _this._reflectionControls = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector4"].Zero();
  50724. _this._white = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  50725. _this._primaryShadowColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  50726. _this._primaryHighlightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  50727. // Setup the default processing configuration to the scene.
  50728. _this._attachImageProcessingConfiguration(null);
  50729. _this.getRenderTargetTextures = function () {
  50730. _this._renderTargets.reset();
  50731. if (_this._diffuseTexture && _this._diffuseTexture.isRenderTarget) {
  50732. _this._renderTargets.push(_this._diffuseTexture);
  50733. }
  50734. if (_this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  50735. _this._renderTargets.push(_this._reflectionTexture);
  50736. }
  50737. return _this._renderTargets;
  50738. };
  50739. return _this;
  50740. }
  50741. Object.defineProperty(BackgroundMaterial.prototype, "_perceptualColor", {
  50742. /**
  50743. * Experimental Internal Use Only.
  50744. *
  50745. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  50746. * This acts as a helper to set the primary color to a more "human friendly" value.
  50747. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  50748. * output color as close as possible from the chosen value.
  50749. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  50750. * part of lighting setup.)
  50751. */
  50752. get: function () {
  50753. return this.__perceptualColor;
  50754. },
  50755. set: function (value) {
  50756. this.__perceptualColor = value;
  50757. this._computePrimaryColorFromPerceptualColor();
  50758. this._markAllSubMeshesAsLightsDirty();
  50759. },
  50760. enumerable: true,
  50761. configurable: true
  50762. });
  50763. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorShadowLevel", {
  50764. /**
  50765. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  50766. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  50767. */
  50768. get: function () {
  50769. return this._primaryColorShadowLevel;
  50770. },
  50771. set: function (value) {
  50772. this._primaryColorShadowLevel = value;
  50773. this._computePrimaryColors();
  50774. this._markAllSubMeshesAsLightsDirty();
  50775. },
  50776. enumerable: true,
  50777. configurable: true
  50778. });
  50779. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorHighlightLevel", {
  50780. /**
  50781. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  50782. * The primary color is used at the level chosen to define what the white area would look.
  50783. */
  50784. get: function () {
  50785. return this._primaryColorHighlightLevel;
  50786. },
  50787. set: function (value) {
  50788. this._primaryColorHighlightLevel = value;
  50789. this._computePrimaryColors();
  50790. this._markAllSubMeshesAsLightsDirty();
  50791. },
  50792. enumerable: true,
  50793. configurable: true
  50794. });
  50795. Object.defineProperty(BackgroundMaterial.prototype, "reflectionStandardFresnelWeight", {
  50796. /**
  50797. * Sets the reflection reflectance fresnel values according to the default standard
  50798. * empirically know to work well :-)
  50799. */
  50800. set: function (value) {
  50801. var reflectionWeight = value;
  50802. if (reflectionWeight < 0.5) {
  50803. reflectionWeight = reflectionWeight * 2.0;
  50804. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 * reflectionWeight;
  50805. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 * reflectionWeight;
  50806. }
  50807. else {
  50808. reflectionWeight = reflectionWeight * 2.0 - 1.0;
  50809. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 + (1.0 - BackgroundMaterial.StandardReflectance0) * reflectionWeight;
  50810. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 + (1.0 - BackgroundMaterial.StandardReflectance90) * reflectionWeight;
  50811. }
  50812. },
  50813. enumerable: true,
  50814. configurable: true
  50815. });
  50816. Object.defineProperty(BackgroundMaterial.prototype, "fovMultiplier", {
  50817. /**
  50818. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50819. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  50820. * Recommended to be keep at 1.0 except for special cases.
  50821. */
  50822. get: function () {
  50823. return this._fovMultiplier;
  50824. },
  50825. set: function (value) {
  50826. if (isNaN(value)) {
  50827. value = 1.0;
  50828. }
  50829. this._fovMultiplier = Math.max(0.0, Math.min(2.0, value));
  50830. },
  50831. enumerable: true,
  50832. configurable: true
  50833. });
  50834. /**
  50835. * Attaches a new image processing configuration to the PBR Material.
  50836. * @param configuration (if null the scene configuration will be use)
  50837. */
  50838. BackgroundMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  50839. var _this = this;
  50840. if (configuration === this._imageProcessingConfiguration) {
  50841. return;
  50842. }
  50843. // Detaches observer.
  50844. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  50845. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  50846. }
  50847. // Pick the scene configuration if needed.
  50848. if (!configuration) {
  50849. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  50850. }
  50851. else {
  50852. this._imageProcessingConfiguration = configuration;
  50853. }
  50854. // Attaches observer.
  50855. if (this._imageProcessingConfiguration) {
  50856. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  50857. _this._computePrimaryColorFromPerceptualColor();
  50858. _this._markAllSubMeshesAsImageProcessingDirty();
  50859. });
  50860. }
  50861. };
  50862. Object.defineProperty(BackgroundMaterial.prototype, "imageProcessingConfiguration", {
  50863. /**
  50864. * Gets the image processing configuration used either in this material.
  50865. */
  50866. get: function () {
  50867. return this._imageProcessingConfiguration;
  50868. },
  50869. /**
  50870. * Sets the Default image processing configuration used either in the this material.
  50871. *
  50872. * If sets to null, the scene one is in use.
  50873. */
  50874. set: function (value) {
  50875. this._attachImageProcessingConfiguration(value);
  50876. // Ensure the effect will be rebuilt.
  50877. this._markAllSubMeshesAsTexturesDirty();
  50878. },
  50879. enumerable: true,
  50880. configurable: true
  50881. });
  50882. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurvesEnabled", {
  50883. /**
  50884. * Gets wether the color curves effect is enabled.
  50885. */
  50886. get: function () {
  50887. return this.imageProcessingConfiguration.colorCurvesEnabled;
  50888. },
  50889. /**
  50890. * Sets wether the color curves effect is enabled.
  50891. */
  50892. set: function (value) {
  50893. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  50894. },
  50895. enumerable: true,
  50896. configurable: true
  50897. });
  50898. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingEnabled", {
  50899. /**
  50900. * Gets wether the color grading effect is enabled.
  50901. */
  50902. get: function () {
  50903. return this.imageProcessingConfiguration.colorGradingEnabled;
  50904. },
  50905. /**
  50906. * Gets wether the color grading effect is enabled.
  50907. */
  50908. set: function (value) {
  50909. this.imageProcessingConfiguration.colorGradingEnabled = value;
  50910. },
  50911. enumerable: true,
  50912. configurable: true
  50913. });
  50914. Object.defineProperty(BackgroundMaterial.prototype, "cameraToneMappingEnabled", {
  50915. /**
  50916. * Gets wether tonemapping is enabled or not.
  50917. */
  50918. get: function () {
  50919. return this._imageProcessingConfiguration.toneMappingEnabled;
  50920. },
  50921. /**
  50922. * Sets wether tonemapping is enabled or not
  50923. */
  50924. set: function (value) {
  50925. this._imageProcessingConfiguration.toneMappingEnabled = value;
  50926. },
  50927. enumerable: true,
  50928. configurable: true
  50929. });
  50930. Object.defineProperty(BackgroundMaterial.prototype, "cameraExposure", {
  50931. /**
  50932. * The camera exposure used on this material.
  50933. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50934. * This corresponds to a photographic exposure.
  50935. */
  50936. get: function () {
  50937. return this._imageProcessingConfiguration.exposure;
  50938. },
  50939. /**
  50940. * The camera exposure used on this material.
  50941. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50942. * This corresponds to a photographic exposure.
  50943. */
  50944. set: function (value) {
  50945. this._imageProcessingConfiguration.exposure = value;
  50946. },
  50947. enumerable: true,
  50948. configurable: true
  50949. });
  50950. Object.defineProperty(BackgroundMaterial.prototype, "cameraContrast", {
  50951. /**
  50952. * Gets The camera contrast used on this material.
  50953. */
  50954. get: function () {
  50955. return this._imageProcessingConfiguration.contrast;
  50956. },
  50957. /**
  50958. * Sets The camera contrast used on this material.
  50959. */
  50960. set: function (value) {
  50961. this._imageProcessingConfiguration.contrast = value;
  50962. },
  50963. enumerable: true,
  50964. configurable: true
  50965. });
  50966. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingTexture", {
  50967. /**
  50968. * Gets the Color Grading 2D Lookup Texture.
  50969. */
  50970. get: function () {
  50971. return this._imageProcessingConfiguration.colorGradingTexture;
  50972. },
  50973. /**
  50974. * Sets the Color Grading 2D Lookup Texture.
  50975. */
  50976. set: function (value) {
  50977. this.imageProcessingConfiguration.colorGradingTexture = value;
  50978. },
  50979. enumerable: true,
  50980. configurable: true
  50981. });
  50982. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurves", {
  50983. /**
  50984. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50985. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50986. * 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;
  50987. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50988. */
  50989. get: function () {
  50990. return this.imageProcessingConfiguration.colorCurves;
  50991. },
  50992. /**
  50993. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50994. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50995. * 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;
  50996. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50997. */
  50998. set: function (value) {
  50999. this.imageProcessingConfiguration.colorCurves = value;
  51000. },
  51001. enumerable: true,
  51002. configurable: true
  51003. });
  51004. Object.defineProperty(BackgroundMaterial.prototype, "hasRenderTargetTextures", {
  51005. /**
  51006. * Gets a boolean indicating that current material needs to register RTT
  51007. */
  51008. get: function () {
  51009. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  51010. return true;
  51011. }
  51012. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  51013. return true;
  51014. }
  51015. return false;
  51016. },
  51017. enumerable: true,
  51018. configurable: true
  51019. });
  51020. /**
  51021. * The entire material has been created in order to prevent overdraw.
  51022. * @returns false
  51023. */
  51024. BackgroundMaterial.prototype.needAlphaTesting = function () {
  51025. return true;
  51026. };
  51027. /**
  51028. * The entire material has been created in order to prevent overdraw.
  51029. * @returns true if blending is enable
  51030. */
  51031. BackgroundMaterial.prototype.needAlphaBlending = function () {
  51032. return ((this.alpha < 0) || (this._diffuseTexture != null && this._diffuseTexture.hasAlpha));
  51033. };
  51034. /**
  51035. * Checks wether the material is ready to be rendered for a given mesh.
  51036. * @param mesh The mesh to render
  51037. * @param subMesh The submesh to check against
  51038. * @param useInstances Specify wether or not the material is used with instances
  51039. * @returns true if all the dependencies are ready (Textures, Effects...)
  51040. */
  51041. BackgroundMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  51042. var _this = this;
  51043. if (useInstances === void 0) { useInstances = false; }
  51044. if (subMesh.effect && this.isFrozen) {
  51045. if (this._wasPreviouslyReady) {
  51046. return true;
  51047. }
  51048. }
  51049. if (!subMesh._materialDefines) {
  51050. subMesh._materialDefines = new BackgroundMaterialDefines();
  51051. }
  51052. var scene = this.getScene();
  51053. var defines = subMesh._materialDefines;
  51054. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  51055. if (defines._renderId === scene.getRenderId()) {
  51056. return true;
  51057. }
  51058. }
  51059. var engine = scene.getEngine();
  51060. // Lights
  51061. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights);
  51062. defines._needNormals = true;
  51063. // Multiview
  51064. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMultiview(scene, defines);
  51065. // Textures
  51066. if (defines._areTexturesDirty) {
  51067. defines._needUVs = false;
  51068. if (scene.texturesEnabled) {
  51069. if (scene.getEngine().getCaps().textureLOD) {
  51070. defines.TEXTURELODSUPPORT = true;
  51071. }
  51072. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51073. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  51074. return false;
  51075. }
  51076. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  51077. defines.DIFFUSEHASALPHA = this._diffuseTexture.hasAlpha;
  51078. defines.GAMMADIFFUSE = this._diffuseTexture.gammaSpace;
  51079. defines.OPACITYFRESNEL = this._opacityFresnel;
  51080. }
  51081. else {
  51082. defines.DIFFUSE = false;
  51083. defines.DIFFUSEHASALPHA = false;
  51084. defines.GAMMADIFFUSE = false;
  51085. defines.OPACITYFRESNEL = false;
  51086. }
  51087. var reflectionTexture = this._reflectionTexture;
  51088. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51089. if (!reflectionTexture.isReadyOrNotBlocking()) {
  51090. return false;
  51091. }
  51092. defines.REFLECTION = true;
  51093. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  51094. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  51095. defines.REFLECTIONBLUR = this._reflectionBlur > 0;
  51096. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  51097. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  51098. defines.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV;
  51099. defines.REFLECTIONBGR = this.switchToBGR;
  51100. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE) {
  51101. defines.INVERTCUBICMAP = true;
  51102. }
  51103. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  51104. switch (reflectionTexture.coordinatesMode) {
  51105. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  51106. defines.REFLECTIONMAP_EXPLICIT = true;
  51107. break;
  51108. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  51109. defines.REFLECTIONMAP_PLANAR = true;
  51110. break;
  51111. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  51112. defines.REFLECTIONMAP_PROJECTION = true;
  51113. break;
  51114. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  51115. defines.REFLECTIONMAP_SKYBOX = true;
  51116. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  51117. break;
  51118. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  51119. defines.REFLECTIONMAP_SPHERICAL = true;
  51120. break;
  51121. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  51122. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  51123. break;
  51124. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  51125. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  51126. break;
  51127. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  51128. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  51129. break;
  51130. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  51131. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  51132. default:
  51133. defines.REFLECTIONMAP_CUBIC = true;
  51134. break;
  51135. }
  51136. if (this.reflectionFresnel) {
  51137. defines.REFLECTIONFRESNEL = true;
  51138. defines.REFLECTIONFALLOFF = this.reflectionFalloffDistance > 0;
  51139. this._reflectionControls.x = this.reflectionAmount;
  51140. this._reflectionControls.y = this.reflectionReflectance0;
  51141. this._reflectionControls.z = this.reflectionReflectance90;
  51142. this._reflectionControls.w = 1 / this.reflectionFalloffDistance;
  51143. }
  51144. else {
  51145. defines.REFLECTIONFRESNEL = false;
  51146. defines.REFLECTIONFALLOFF = false;
  51147. }
  51148. }
  51149. else {
  51150. defines.REFLECTION = false;
  51151. defines.REFLECTIONFRESNEL = false;
  51152. defines.REFLECTIONFALLOFF = false;
  51153. defines.REFLECTIONBLUR = false;
  51154. defines.REFLECTIONMAP_3D = false;
  51155. defines.REFLECTIONMAP_SPHERICAL = false;
  51156. defines.REFLECTIONMAP_PLANAR = false;
  51157. defines.REFLECTIONMAP_CUBIC = false;
  51158. defines.REFLECTIONMAP_PROJECTION = false;
  51159. defines.REFLECTIONMAP_SKYBOX = false;
  51160. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  51161. defines.REFLECTIONMAP_EXPLICIT = false;
  51162. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  51163. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  51164. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  51165. defines.INVERTCUBICMAP = false;
  51166. defines.REFLECTIONMAP_OPPOSITEZ = false;
  51167. defines.LODINREFLECTIONALPHA = false;
  51168. defines.GAMMAREFLECTION = false;
  51169. defines.RGBDREFLECTION = false;
  51170. }
  51171. }
  51172. 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);
  51173. defines.USERGBCOLOR = this._useRGBColor;
  51174. defines.NOISE = this._enableNoise;
  51175. }
  51176. if (defines._areLightsDirty) {
  51177. defines.USEHIGHLIGHTANDSHADOWCOLORS = !this._useRGBColor && (this._primaryColorShadowLevel !== 0 || this._primaryColorHighlightLevel !== 0);
  51178. }
  51179. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  51180. if (!this._imageProcessingConfiguration.isReady()) {
  51181. return false;
  51182. }
  51183. this._imageProcessingConfiguration.prepareDefines(defines);
  51184. }
  51185. // Misc.
  51186. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  51187. // Values that need to be evaluated on every frame
  51188. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  51189. // Attribs
  51190. if (_Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, false, true, false)) {
  51191. if (mesh) {
  51192. if (!scene.getEngine().getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  51193. mesh.createNormals(true);
  51194. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Warn("BackgroundMaterial: Normals have been created for the mesh: " + mesh.name);
  51195. }
  51196. }
  51197. }
  51198. // Get correct effect
  51199. if (defines.isDirty) {
  51200. defines.markAsProcessed();
  51201. scene.resetCachedMaterial();
  51202. // Fallbacks
  51203. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  51204. if (defines.FOG) {
  51205. fallbacks.addFallback(0, "FOG");
  51206. }
  51207. if (defines.POINTSIZE) {
  51208. fallbacks.addFallback(1, "POINTSIZE");
  51209. }
  51210. if (defines.MULTIVIEW) {
  51211. fallbacks.addFallback(0, "MULTIVIEW");
  51212. }
  51213. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  51214. if (defines.NUM_BONE_INFLUENCERS > 0) {
  51215. fallbacks.addCPUSkinningFallback(0, mesh);
  51216. }
  51217. //Attributes
  51218. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  51219. if (defines.NORMAL) {
  51220. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  51221. }
  51222. if (defines.UV1) {
  51223. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  51224. }
  51225. if (defines.UV2) {
  51226. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  51227. }
  51228. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  51229. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  51230. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType",
  51231. "vFogInfos", "vFogColor", "pointSize",
  51232. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "mBones",
  51233. "vPrimaryColor", "vPrimaryColorShadow",
  51234. "vReflectionInfos", "reflectionMatrix", "vReflectionMicrosurfaceInfos", "fFovMultiplier",
  51235. "shadowLevel", "alpha",
  51236. "vBackgroundCenter", "vReflectionControl",
  51237. "vDiffuseInfos", "diffuseMatrix",
  51238. ];
  51239. var samplers = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"];
  51240. var uniformBuffers = ["Material", "Scene"];
  51241. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"]) {
  51242. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  51243. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  51244. }
  51245. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareUniformsAndSamplersList({
  51246. uniformsNames: uniforms,
  51247. uniformBuffersNames: uniformBuffers,
  51248. samplers: samplers,
  51249. defines: defines,
  51250. maxSimultaneousLights: this._maxSimultaneousLights
  51251. });
  51252. var onCompiled = function (effect) {
  51253. if (_this.onCompiled) {
  51254. _this.onCompiled(effect);
  51255. }
  51256. _this.bindSceneUniformBuffer(effect, scene.getSceneUniformBuffer());
  51257. };
  51258. var join = defines.toString();
  51259. subMesh.setEffect(scene.getEngine().createEffect("background", {
  51260. attributes: attribs,
  51261. uniformsNames: uniforms,
  51262. uniformBuffersNames: uniformBuffers,
  51263. samplers: samplers,
  51264. defines: join,
  51265. fallbacks: fallbacks,
  51266. onCompiled: onCompiled,
  51267. onError: this.onError,
  51268. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights }
  51269. }, engine), defines);
  51270. this.buildUniformLayout();
  51271. }
  51272. if (!subMesh.effect || !subMesh.effect.isReady()) {
  51273. return false;
  51274. }
  51275. defines._renderId = scene.getRenderId();
  51276. this._wasPreviouslyReady = true;
  51277. return true;
  51278. };
  51279. /**
  51280. * Compute the primary color according to the chosen perceptual color.
  51281. */
  51282. BackgroundMaterial.prototype._computePrimaryColorFromPerceptualColor = function () {
  51283. if (!this.__perceptualColor) {
  51284. return;
  51285. }
  51286. this._primaryColor.copyFrom(this.__perceptualColor);
  51287. // Revert gamma space.
  51288. this._primaryColor.toLinearSpaceToRef(this._primaryColor);
  51289. // Revert image processing configuration.
  51290. if (this._imageProcessingConfiguration) {
  51291. // Revert Exposure.
  51292. this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor);
  51293. }
  51294. this._computePrimaryColors();
  51295. };
  51296. /**
  51297. * Compute the highlights and shadow colors according to their chosen levels.
  51298. */
  51299. BackgroundMaterial.prototype._computePrimaryColors = function () {
  51300. if (this._primaryColorShadowLevel === 0 && this._primaryColorHighlightLevel === 0) {
  51301. return;
  51302. }
  51303. // Find the highlight color based on the configuration.
  51304. this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor);
  51305. this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor);
  51306. // Find the shadow color based on the configuration.
  51307. this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor);
  51308. this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor);
  51309. this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor);
  51310. };
  51311. /**
  51312. * Build the uniform buffer used in the material.
  51313. */
  51314. BackgroundMaterial.prototype.buildUniformLayout = function () {
  51315. // Order is important !
  51316. this._uniformBuffer.addUniform("vPrimaryColor", 4);
  51317. this._uniformBuffer.addUniform("vPrimaryColorShadow", 4);
  51318. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  51319. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  51320. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  51321. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  51322. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  51323. this._uniformBuffer.addUniform("fFovMultiplier", 1);
  51324. this._uniformBuffer.addUniform("pointSize", 1);
  51325. this._uniformBuffer.addUniform("shadowLevel", 1);
  51326. this._uniformBuffer.addUniform("alpha", 1);
  51327. this._uniformBuffer.addUniform("vBackgroundCenter", 3);
  51328. this._uniformBuffer.addUniform("vReflectionControl", 4);
  51329. this._uniformBuffer.create();
  51330. };
  51331. /**
  51332. * Unbind the material.
  51333. */
  51334. BackgroundMaterial.prototype.unbind = function () {
  51335. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  51336. this._uniformBuffer.setTexture("diffuseSampler", null);
  51337. }
  51338. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  51339. this._uniformBuffer.setTexture("reflectionSampler", null);
  51340. }
  51341. _super.prototype.unbind.call(this);
  51342. };
  51343. /**
  51344. * Bind only the world matrix to the material.
  51345. * @param world The world matrix to bind.
  51346. */
  51347. BackgroundMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  51348. this._activeEffect.setMatrix("world", world);
  51349. };
  51350. /**
  51351. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51352. * @param world The world matrix to bind.
  51353. * @param subMesh The submesh to bind for.
  51354. */
  51355. BackgroundMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  51356. var scene = this.getScene();
  51357. var defines = subMesh._materialDefines;
  51358. if (!defines) {
  51359. return;
  51360. }
  51361. var effect = subMesh.effect;
  51362. if (!effect) {
  51363. return;
  51364. }
  51365. this._activeEffect = effect;
  51366. // Matrices
  51367. this.bindOnlyWorldMatrix(world);
  51368. // Bones
  51369. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  51370. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  51371. if (mustRebind) {
  51372. this._uniformBuffer.bindToEffect(effect, "Material");
  51373. this.bindViewProjection(effect);
  51374. var reflectionTexture = this._reflectionTexture;
  51375. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  51376. // Texture uniforms
  51377. if (scene.texturesEnabled) {
  51378. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51379. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  51380. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  51381. }
  51382. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51383. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  51384. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, this._reflectionBlur);
  51385. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  51386. }
  51387. }
  51388. if (this.shadowLevel > 0) {
  51389. this._uniformBuffer.updateFloat("shadowLevel", this.shadowLevel);
  51390. }
  51391. this._uniformBuffer.updateFloat("alpha", this.alpha);
  51392. // Point size
  51393. if (this.pointsCloud) {
  51394. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  51395. }
  51396. if (defines.USEHIGHLIGHTANDSHADOWCOLORS) {
  51397. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryHighlightColor, 1.0);
  51398. this._uniformBuffer.updateColor4("vPrimaryColorShadow", this._primaryShadowColor, 1.0);
  51399. }
  51400. else {
  51401. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryColor, 1.0);
  51402. }
  51403. }
  51404. this._uniformBuffer.updateFloat("fFovMultiplier", this._fovMultiplier);
  51405. // Textures
  51406. if (scene.texturesEnabled) {
  51407. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51408. this._uniformBuffer.setTexture("diffuseSampler", this._diffuseTexture);
  51409. }
  51410. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51411. if (defines.REFLECTIONBLUR && defines.TEXTURELODSUPPORT) {
  51412. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  51413. }
  51414. else if (!defines.REFLECTIONBLUR) {
  51415. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  51416. }
  51417. else {
  51418. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  51419. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  51420. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  51421. }
  51422. if (defines.REFLECTIONFRESNEL) {
  51423. this._uniformBuffer.updateFloat3("vBackgroundCenter", this.sceneCenter.x, this.sceneCenter.y, this.sceneCenter.z);
  51424. this._uniformBuffer.updateFloat4("vReflectionControl", this._reflectionControls.x, this._reflectionControls.y, this._reflectionControls.z, this._reflectionControls.w);
  51425. }
  51426. }
  51427. }
  51428. // Clip plane
  51429. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  51430. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindEyePosition(effect, scene);
  51431. }
  51432. if (mustRebind || !this.isFrozen) {
  51433. if (scene.lightsEnabled) {
  51434. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, false);
  51435. }
  51436. // View
  51437. this.bindView(effect);
  51438. // Fog
  51439. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  51440. // image processing
  51441. if (this._imageProcessingConfiguration) {
  51442. this._imageProcessingConfiguration.bind(this._activeEffect);
  51443. }
  51444. }
  51445. this._uniformBuffer.update();
  51446. this._afterBind(mesh, this._activeEffect);
  51447. };
  51448. /**
  51449. * Dispose the material.
  51450. * @param forceDisposeEffect Force disposal of the associated effect.
  51451. * @param forceDisposeTextures Force disposal of the associated textures.
  51452. */
  51453. BackgroundMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  51454. if (forceDisposeEffect === void 0) { forceDisposeEffect = false; }
  51455. if (forceDisposeTextures === void 0) { forceDisposeTextures = false; }
  51456. if (forceDisposeTextures) {
  51457. if (this.diffuseTexture) {
  51458. this.diffuseTexture.dispose();
  51459. }
  51460. if (this.reflectionTexture) {
  51461. this.reflectionTexture.dispose();
  51462. }
  51463. }
  51464. this._renderTargets.dispose();
  51465. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  51466. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  51467. }
  51468. _super.prototype.dispose.call(this, forceDisposeEffect);
  51469. };
  51470. /**
  51471. * Clones the material.
  51472. * @param name The cloned name.
  51473. * @returns The cloned material.
  51474. */
  51475. BackgroundMaterial.prototype.clone = function (name) {
  51476. var _this = this;
  51477. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new BackgroundMaterial(name, _this.getScene()); }, this);
  51478. };
  51479. /**
  51480. * Serializes the current material to its JSON representation.
  51481. * @returns The JSON representation.
  51482. */
  51483. BackgroundMaterial.prototype.serialize = function () {
  51484. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  51485. serializationObject.customType = "BABYLON.BackgroundMaterial";
  51486. return serializationObject;
  51487. };
  51488. /**
  51489. * Gets the class name of the material
  51490. * @returns "BackgroundMaterial"
  51491. */
  51492. BackgroundMaterial.prototype.getClassName = function () {
  51493. return "BackgroundMaterial";
  51494. };
  51495. /**
  51496. * Parse a JSON input to create back a background material.
  51497. * @param source The JSON data to parse
  51498. * @param scene The scene to create the parsed material in
  51499. * @param rootUrl The root url of the assets the material depends upon
  51500. * @returns the instantiated BackgroundMaterial.
  51501. */
  51502. BackgroundMaterial.Parse = function (source, scene, rootUrl) {
  51503. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new BackgroundMaterial(source.name, scene); }, source, scene, rootUrl);
  51504. };
  51505. /**
  51506. * Standard reflectance value at parallel view angle.
  51507. */
  51508. BackgroundMaterial.StandardReflectance0 = 0.05;
  51509. /**
  51510. * Standard reflectance value at grazing angle.
  51511. */
  51512. BackgroundMaterial.StandardReflectance90 = 0.5;
  51513. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51514. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  51515. ], BackgroundMaterial.prototype, "_primaryColor", void 0);
  51516. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51517. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  51518. ], BackgroundMaterial.prototype, "primaryColor", void 0);
  51519. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51520. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  51521. ], BackgroundMaterial.prototype, "__perceptualColor", void 0);
  51522. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51523. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51524. ], BackgroundMaterial.prototype, "_primaryColorShadowLevel", void 0);
  51525. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51526. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51527. ], BackgroundMaterial.prototype, "_primaryColorHighlightLevel", void 0);
  51528. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51529. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  51530. ], BackgroundMaterial.prototype, "primaryColorHighlightLevel", null);
  51531. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51532. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  51533. ], BackgroundMaterial.prototype, "_reflectionTexture", void 0);
  51534. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51535. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51536. ], BackgroundMaterial.prototype, "reflectionTexture", void 0);
  51537. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51538. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51539. ], BackgroundMaterial.prototype, "_reflectionBlur", void 0);
  51540. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51541. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51542. ], BackgroundMaterial.prototype, "reflectionBlur", void 0);
  51543. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51544. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  51545. ], BackgroundMaterial.prototype, "_diffuseTexture", void 0);
  51546. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51547. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51548. ], BackgroundMaterial.prototype, "diffuseTexture", void 0);
  51549. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51550. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51551. ], BackgroundMaterial.prototype, "shadowLights", void 0);
  51552. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51553. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51554. ], BackgroundMaterial.prototype, "_shadowLevel", void 0);
  51555. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51556. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51557. ], BackgroundMaterial.prototype, "shadowLevel", void 0);
  51558. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51559. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  51560. ], BackgroundMaterial.prototype, "_sceneCenter", void 0);
  51561. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51562. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51563. ], BackgroundMaterial.prototype, "sceneCenter", void 0);
  51564. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51565. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51566. ], BackgroundMaterial.prototype, "_opacityFresnel", void 0);
  51567. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51568. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51569. ], BackgroundMaterial.prototype, "opacityFresnel", void 0);
  51570. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51571. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51572. ], BackgroundMaterial.prototype, "_reflectionFresnel", void 0);
  51573. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51574. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51575. ], BackgroundMaterial.prototype, "reflectionFresnel", void 0);
  51576. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51577. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51578. ], BackgroundMaterial.prototype, "_reflectionFalloffDistance", void 0);
  51579. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51580. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51581. ], BackgroundMaterial.prototype, "reflectionFalloffDistance", void 0);
  51582. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51583. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51584. ], BackgroundMaterial.prototype, "_reflectionAmount", void 0);
  51585. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51586. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51587. ], BackgroundMaterial.prototype, "reflectionAmount", void 0);
  51588. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51589. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51590. ], BackgroundMaterial.prototype, "_reflectionReflectance0", void 0);
  51591. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51592. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51593. ], BackgroundMaterial.prototype, "reflectionReflectance0", void 0);
  51594. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51595. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51596. ], BackgroundMaterial.prototype, "_reflectionReflectance90", void 0);
  51597. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51598. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51599. ], BackgroundMaterial.prototype, "reflectionReflectance90", void 0);
  51600. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51601. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51602. ], BackgroundMaterial.prototype, "_useRGBColor", void 0);
  51603. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51604. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51605. ], BackgroundMaterial.prototype, "useRGBColor", void 0);
  51606. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51607. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51608. ], BackgroundMaterial.prototype, "_enableNoise", void 0);
  51609. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51610. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51611. ], BackgroundMaterial.prototype, "enableNoise", void 0);
  51612. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51613. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51614. ], BackgroundMaterial.prototype, "_maxSimultaneousLights", void 0);
  51615. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51616. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51617. ], BackgroundMaterial.prototype, "maxSimultaneousLights", void 0);
  51618. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51619. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  51620. ], BackgroundMaterial.prototype, "_imageProcessingConfiguration", void 0);
  51621. return BackgroundMaterial;
  51622. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  51623. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__["_TypeStore"].RegisteredTypes["BABYLON.BackgroundMaterial"] = BackgroundMaterial;
  51624. /***/ }),
  51625. /***/ "./Materials/Background/index.ts":
  51626. /*!***************************************!*\
  51627. !*** ./Materials/Background/index.ts ***!
  51628. \***************************************/
  51629. /*! exports provided: BackgroundMaterial */
  51630. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51631. "use strict";
  51632. __webpack_require__.r(__webpack_exports__);
  51633. /* harmony import */ var _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  51634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  51635. /***/ }),
  51636. /***/ "./Materials/PBR/index.ts":
  51637. /*!********************************!*\
  51638. !*** ./Materials/PBR/index.ts ***!
  51639. \********************************/
  51640. /*! exports provided: PBRMaterialDefines, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial */
  51641. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51642. "use strict";
  51643. __webpack_require__.r(__webpack_exports__);
  51644. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  51645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRMaterialDefines"]; });
  51646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  51647. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  51648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__["PBRBaseSimpleMaterial"]; });
  51649. /* harmony import */ var _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  51650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRMaterial"]; });
  51651. /* harmony import */ var _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrMetallicRoughnessMaterial */ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts");
  51652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRMetallicRoughnessMaterial"]; });
  51653. /* harmony import */ var _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrSpecularGlossinessMaterial */ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts");
  51654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRSpecularGlossinessMaterial"]; });
  51655. /***/ }),
  51656. /***/ "./Materials/PBR/pbrAnisotropicConfiguration.ts":
  51657. /*!******************************************************!*\
  51658. !*** ./Materials/PBR/pbrAnisotropicConfiguration.ts ***!
  51659. \******************************************************/
  51660. /*! exports provided: PBRAnisotropicConfiguration */
  51661. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51662. "use strict";
  51663. __webpack_require__.r(__webpack_exports__);
  51664. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRAnisotropicConfiguration", function() { return PBRAnisotropicConfiguration; });
  51665. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51666. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51667. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  51668. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  51669. /* harmony import */ var _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialFlags */ "./Materials/materialFlags.ts");
  51670. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  51671. /**
  51672. * Define the code related to the anisotropic parameters of the pbr material.
  51673. */
  51674. var PBRAnisotropicConfiguration = /** @class */ (function () {
  51675. /**
  51676. * Instantiate a new istance of anisotropy configuration.
  51677. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51678. */
  51679. function PBRAnisotropicConfiguration(markAllSubMeshesAsTexturesDirty) {
  51680. this._isEnabled = false;
  51681. /**
  51682. * Defines if the anisotropy is enabled in the material.
  51683. */
  51684. this.isEnabled = false;
  51685. /**
  51686. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  51687. */
  51688. this.intensity = 1;
  51689. /**
  51690. * Defines if the effect is along the tangents, bitangents or in between.
  51691. * By default, the effect is "strectching" the highlights along the tangents.
  51692. */
  51693. this.direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 0);
  51694. this._texture = null;
  51695. /**
  51696. * Stores the anisotropy values in a texture.
  51697. * rg is direction (like normal from -1 to 1)
  51698. * b is a intensity
  51699. */
  51700. this.texture = null;
  51701. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  51702. }
  51703. /** @hidden */
  51704. PBRAnisotropicConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  51705. this._internalMarkAllSubMeshesAsTexturesDirty();
  51706. };
  51707. /**
  51708. * Specifies that the submesh is ready to be used.
  51709. * @param defines the list of "defines" to update.
  51710. * @param scene defines the scene the material belongs to.
  51711. * @returns - boolean indicating that the submesh is ready or not.
  51712. */
  51713. PBRAnisotropicConfiguration.prototype.isReadyForSubMesh = function (defines, scene) {
  51714. if (defines._areTexturesDirty) {
  51715. if (scene.texturesEnabled) {
  51716. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51717. if (!this._texture.isReadyOrNotBlocking()) {
  51718. return false;
  51719. }
  51720. }
  51721. }
  51722. }
  51723. return true;
  51724. };
  51725. /**
  51726. * Checks to see if a texture is used in the material.
  51727. * @param defines the list of "defines" to update.
  51728. * @param mesh the mesh we are preparing the defines for.
  51729. * @param scene defines the scene the material belongs to.
  51730. */
  51731. PBRAnisotropicConfiguration.prototype.prepareDefines = function (defines, mesh, scene) {
  51732. if (this._isEnabled) {
  51733. defines.ANISOTROPIC = this._isEnabled;
  51734. if (this._isEnabled && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  51735. defines._needUVs = true;
  51736. defines.MAINUV1 = true;
  51737. }
  51738. if (defines._areTexturesDirty) {
  51739. if (scene.texturesEnabled) {
  51740. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51741. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "ANISOTROPIC_TEXTURE");
  51742. }
  51743. else {
  51744. defines.ANISOTROPIC_TEXTURE = false;
  51745. }
  51746. }
  51747. }
  51748. }
  51749. else {
  51750. defines.ANISOTROPIC = false;
  51751. defines.ANISOTROPIC_TEXTURE = false;
  51752. }
  51753. };
  51754. /**
  51755. * Binds the material data.
  51756. * @param uniformBuffer defines the Uniform buffer to fill in.
  51757. * @param scene defines the scene the material belongs to.
  51758. * @param isFrozen defines wether the material is frozen or not.
  51759. */
  51760. PBRAnisotropicConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, isFrozen) {
  51761. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  51762. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51763. uniformBuffer.updateFloat2("vAnisotropyInfos", this._texture.coordinatesIndex, this._texture.level);
  51764. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "anisotropy");
  51765. }
  51766. // Anisotropy
  51767. uniformBuffer.updateFloat3("vAnisotropy", this.direction.x, this.direction.y, this.intensity);
  51768. }
  51769. // Textures
  51770. if (scene.texturesEnabled) {
  51771. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51772. uniformBuffer.setTexture("anisotropySampler", this._texture);
  51773. }
  51774. }
  51775. };
  51776. /**
  51777. * Checks to see if a texture is used in the material.
  51778. * @param texture - Base texture to use.
  51779. * @returns - Boolean specifying if a texture is used in the material.
  51780. */
  51781. PBRAnisotropicConfiguration.prototype.hasTexture = function (texture) {
  51782. if (this._texture === texture) {
  51783. return true;
  51784. }
  51785. return false;
  51786. };
  51787. /**
  51788. * Returns an array of the actively used textures.
  51789. * @param activeTextures Array of BaseTextures
  51790. */
  51791. PBRAnisotropicConfiguration.prototype.getActiveTextures = function (activeTextures) {
  51792. if (this._texture) {
  51793. activeTextures.push(this._texture);
  51794. }
  51795. };
  51796. /**
  51797. * Returns the animatable textures.
  51798. * @param animatables Array of animatable textures.
  51799. */
  51800. PBRAnisotropicConfiguration.prototype.getAnimatables = function (animatables) {
  51801. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  51802. animatables.push(this._texture);
  51803. }
  51804. };
  51805. /**
  51806. * Disposes the resources of the material.
  51807. * @param forceDisposeTextures - Forces the disposal of all textures.
  51808. */
  51809. PBRAnisotropicConfiguration.prototype.dispose = function (forceDisposeTextures) {
  51810. if (forceDisposeTextures) {
  51811. if (this._texture) {
  51812. this._texture.dispose();
  51813. }
  51814. }
  51815. };
  51816. /**
  51817. * Get the current class name of the texture useful for serialization or dynamic coding.
  51818. * @returns "PBRAnisotropicConfiguration"
  51819. */
  51820. PBRAnisotropicConfiguration.prototype.getClassName = function () {
  51821. return "PBRAnisotropicConfiguration";
  51822. };
  51823. /**
  51824. * Add fallbacks to the effect fallbacks list.
  51825. * @param defines defines the Base texture to use.
  51826. * @param fallbacks defines the current fallback list.
  51827. * @param currentRank defines the current fallback rank.
  51828. * @returns the new fallback rank.
  51829. */
  51830. PBRAnisotropicConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  51831. if (defines.ANISOTROPIC) {
  51832. fallbacks.addFallback(currentRank++, "ANISOTROPIC");
  51833. }
  51834. return currentRank;
  51835. };
  51836. /**
  51837. * Add the required uniforms to the current list.
  51838. * @param uniforms defines the current uniform list.
  51839. */
  51840. PBRAnisotropicConfiguration.AddUniforms = function (uniforms) {
  51841. uniforms.push("vAnisotropy", "vAnisotropyInfos", "anisotropyMatrix");
  51842. };
  51843. /**
  51844. * Add the required uniforms to the current buffer.
  51845. * @param uniformBuffer defines the current uniform buffer.
  51846. */
  51847. PBRAnisotropicConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  51848. uniformBuffer.addUniform("vAnisotropy", 3);
  51849. uniformBuffer.addUniform("vAnisotropyInfos", 2);
  51850. uniformBuffer.addUniform("anisotropyMatrix", 16);
  51851. };
  51852. /**
  51853. * Add the required samplers to the current list.
  51854. * @param samplers defines the current sampler list.
  51855. */
  51856. PBRAnisotropicConfiguration.AddSamplers = function (samplers) {
  51857. samplers.push("anisotropySampler");
  51858. };
  51859. /**
  51860. * Makes a duplicate of the current configuration into another one.
  51861. * @param anisotropicConfiguration define the config where to copy the info
  51862. */
  51863. PBRAnisotropicConfiguration.prototype.copyTo = function (anisotropicConfiguration) {
  51864. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return anisotropicConfiguration; }, this);
  51865. };
  51866. /**
  51867. * Serializes this anisotropy configuration.
  51868. * @returns - An object with the serialized config.
  51869. */
  51870. PBRAnisotropicConfiguration.prototype.serialize = function () {
  51871. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  51872. };
  51873. /**
  51874. * Parses a anisotropy Configuration from a serialized object.
  51875. * @param source - Serialized object.
  51876. */
  51877. PBRAnisotropicConfiguration.prototype.parse = function (source) {
  51878. var _this = this;
  51879. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  51880. };
  51881. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51882. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51883. ], PBRAnisotropicConfiguration.prototype, "_isEnabled", void 0);
  51884. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51885. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51886. ], PBRAnisotropicConfiguration.prototype, "isEnabled", void 0);
  51887. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51888. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51889. ], PBRAnisotropicConfiguration.prototype, "intensity", void 0);
  51890. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51891. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector2"])()
  51892. ], PBRAnisotropicConfiguration.prototype, "direction", void 0);
  51893. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51894. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  51895. ], PBRAnisotropicConfiguration.prototype, "_texture", void 0);
  51896. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51897. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51898. ], PBRAnisotropicConfiguration.prototype, "texture", void 0);
  51899. return PBRAnisotropicConfiguration;
  51900. }());
  51901. /***/ }),
  51902. /***/ "./Materials/PBR/pbrBRDFConfiguration.ts":
  51903. /*!***********************************************!*\
  51904. !*** ./Materials/PBR/pbrBRDFConfiguration.ts ***!
  51905. \***********************************************/
  51906. /*! exports provided: PBRBRDFConfiguration */
  51907. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51908. "use strict";
  51909. __webpack_require__.r(__webpack_exports__);
  51910. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBRDFConfiguration", function() { return PBRBRDFConfiguration; });
  51911. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51912. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51913. /**
  51914. * Define the code related to the BRDF parameters of the pbr material.
  51915. */
  51916. var PBRBRDFConfiguration = /** @class */ (function () {
  51917. /**
  51918. * Instantiate a new istance of clear coat configuration.
  51919. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  51920. */
  51921. function PBRBRDFConfiguration(markAllSubMeshesAsMiscDirty) {
  51922. this._useEnergyConservation = PBRBRDFConfiguration.DEFAULT_USE_ENERGY_CONSERVATION;
  51923. /**
  51924. * Defines if the material uses energy conservation.
  51925. */
  51926. this.useEnergyConservation = PBRBRDFConfiguration.DEFAULT_USE_ENERGY_CONSERVATION;
  51927. this._useSmithVisibilityHeightCorrelated = PBRBRDFConfiguration.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED;
  51928. /**
  51929. * LEGACY Mode set to false
  51930. * Defines if the material uses height smith correlated visibility term.
  51931. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  51932. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  51933. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  51934. * Not relying on height correlated will also disable energy conservation.
  51935. */
  51936. this.useSmithVisibilityHeightCorrelated = PBRBRDFConfiguration.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED;
  51937. this._internalMarkAllSubMeshesAsMiscDirty = markAllSubMeshesAsMiscDirty;
  51938. }
  51939. /** @hidden */
  51940. PBRBRDFConfiguration.prototype._markAllSubMeshesAsMiscDirty = function () {
  51941. this._internalMarkAllSubMeshesAsMiscDirty();
  51942. };
  51943. /**
  51944. * Checks to see if a texture is used in the material.
  51945. * @param defines the list of "defines" to update.
  51946. */
  51947. PBRBRDFConfiguration.prototype.prepareDefines = function (defines) {
  51948. defines.BRDF_V_HEIGHT_CORRELATED = this._useSmithVisibilityHeightCorrelated;
  51949. defines.MS_BRDF_ENERGY_CONSERVATION = this._useEnergyConservation && this._useSmithVisibilityHeightCorrelated;
  51950. };
  51951. /**
  51952. * Get the current class name of the texture useful for serialization or dynamic coding.
  51953. * @returns "PBRClearCoatConfiguration"
  51954. */
  51955. PBRBRDFConfiguration.prototype.getClassName = function () {
  51956. return "PBRClearCoatConfiguration";
  51957. };
  51958. /**
  51959. * Makes a duplicate of the current configuration into another one.
  51960. * @param brdfConfiguration define the config where to copy the info
  51961. */
  51962. PBRBRDFConfiguration.prototype.copyTo = function (brdfConfiguration) {
  51963. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return brdfConfiguration; }, this);
  51964. };
  51965. /**
  51966. * Serializes this BRDF configuration.
  51967. * @returns - An object with the serialized config.
  51968. */
  51969. PBRBRDFConfiguration.prototype.serialize = function () {
  51970. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  51971. };
  51972. /**
  51973. * Parses a BRDF Configuration from a serialized object.
  51974. * @param source - Serialized object.
  51975. */
  51976. PBRBRDFConfiguration.prototype.parse = function (source) {
  51977. var _this = this;
  51978. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  51979. };
  51980. /**
  51981. * Default value used for the energy conservation.
  51982. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  51983. */
  51984. PBRBRDFConfiguration.DEFAULT_USE_ENERGY_CONSERVATION = true;
  51985. /**
  51986. * Default value used for the Smith Visibility Height Correlated mode.
  51987. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  51988. */
  51989. PBRBRDFConfiguration.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED = true;
  51990. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51991. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51992. ], PBRBRDFConfiguration.prototype, "_useEnergyConservation", void 0);
  51993. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51994. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  51995. ], PBRBRDFConfiguration.prototype, "useEnergyConservation", void 0);
  51996. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51997. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51998. ], PBRBRDFConfiguration.prototype, "_useSmithVisibilityHeightCorrelated", void 0);
  51999. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52000. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  52001. ], PBRBRDFConfiguration.prototype, "useSmithVisibilityHeightCorrelated", void 0);
  52002. return PBRBRDFConfiguration;
  52003. }());
  52004. /***/ }),
  52005. /***/ "./Materials/PBR/pbrBaseMaterial.ts":
  52006. /*!******************************************!*\
  52007. !*** ./Materials/PBR/pbrBaseMaterial.ts ***!
  52008. \******************************************/
  52009. /*! exports provided: PBRMaterialDefines, PBRBaseMaterial */
  52010. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52011. "use strict";
  52012. __webpack_require__.r(__webpack_exports__);
  52013. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return PBRMaterialDefines; });
  52014. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return PBRBaseMaterial; });
  52015. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52016. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  52017. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  52018. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  52019. /* harmony import */ var _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/brdfTextureTools */ "./Misc/brdfTextureTools.ts");
  52020. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  52021. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  52022. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  52023. /* harmony import */ var _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./pbrClearCoatConfiguration */ "./Materials/PBR/pbrClearCoatConfiguration.ts");
  52024. /* harmony import */ var _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pbrAnisotropicConfiguration */ "./Materials/PBR/pbrAnisotropicConfiguration.ts");
  52025. /* harmony import */ var _pbrBRDFConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pbrBRDFConfiguration */ "./Materials/PBR/pbrBRDFConfiguration.ts");
  52026. /* harmony import */ var _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./pbrSheenConfiguration */ "./Materials/PBR/pbrSheenConfiguration.ts");
  52027. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  52028. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  52029. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  52030. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  52031. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  52032. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  52033. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  52034. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  52035. /* harmony import */ var _Shaders_pbr_fragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Shaders/pbr.fragment */ "./Shaders/pbr.fragment.ts");
  52036. /* harmony import */ var _Shaders_pbr_vertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Shaders/pbr.vertex */ "./Shaders/pbr.vertex.ts");
  52037. /**
  52038. * Manages the defines for the PBR Material.
  52039. * @hidden
  52040. */
  52041. var PBRMaterialDefines = /** @class */ (function (_super) {
  52042. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterialDefines, _super);
  52043. /**
  52044. * Initializes the PBR Material defines.
  52045. */
  52046. function PBRMaterialDefines() {
  52047. var _this = _super.call(this) || this;
  52048. _this.PBR = true;
  52049. _this.MAINUV1 = false;
  52050. _this.MAINUV2 = false;
  52051. _this.UV1 = false;
  52052. _this.UV2 = false;
  52053. _this.ALBEDO = false;
  52054. _this.ALBEDODIRECTUV = 0;
  52055. _this.VERTEXCOLOR = false;
  52056. _this.AMBIENT = false;
  52057. _this.AMBIENTDIRECTUV = 0;
  52058. _this.AMBIENTINGRAYSCALE = false;
  52059. _this.OPACITY = false;
  52060. _this.VERTEXALPHA = false;
  52061. _this.OPACITYDIRECTUV = 0;
  52062. _this.OPACITYRGB = false;
  52063. _this.ALPHATEST = false;
  52064. _this.DEPTHPREPASS = false;
  52065. _this.ALPHABLEND = false;
  52066. _this.ALPHAFROMALBEDO = false;
  52067. _this.ALPHATESTVALUE = "0.5";
  52068. _this.SPECULAROVERALPHA = false;
  52069. _this.RADIANCEOVERALPHA = false;
  52070. _this.ALPHAFRESNEL = false;
  52071. _this.LINEARALPHAFRESNEL = false;
  52072. _this.PREMULTIPLYALPHA = false;
  52073. _this.EMISSIVE = false;
  52074. _this.EMISSIVEDIRECTUV = 0;
  52075. _this.REFLECTIVITY = false;
  52076. _this.REFLECTIVITYDIRECTUV = 0;
  52077. _this.SPECULARTERM = false;
  52078. _this.MICROSURFACEFROMREFLECTIVITYMAP = false;
  52079. _this.MICROSURFACEAUTOMATIC = false;
  52080. _this.LODBASEDMICROSFURACE = false;
  52081. _this.MICROSURFACEMAP = false;
  52082. _this.MICROSURFACEMAPDIRECTUV = 0;
  52083. _this.METALLICWORKFLOW = false;
  52084. _this.ROUGHNESSSTOREINMETALMAPALPHA = false;
  52085. _this.ROUGHNESSSTOREINMETALMAPGREEN = false;
  52086. _this.METALLNESSSTOREINMETALMAPBLUE = false;
  52087. _this.AOSTOREINMETALMAPRED = false;
  52088. _this.ENVIRONMENTBRDF = false;
  52089. _this.ENVIRONMENTBRDF_RGBD = false;
  52090. _this.NORMAL = false;
  52091. _this.TANGENT = false;
  52092. _this.BUMP = false;
  52093. _this.BUMPDIRECTUV = 0;
  52094. _this.OBJECTSPACE_NORMALMAP = false;
  52095. _this.PARALLAX = false;
  52096. _this.PARALLAXOCCLUSION = false;
  52097. _this.NORMALXYSCALE = true;
  52098. _this.LIGHTMAP = false;
  52099. _this.LIGHTMAPDIRECTUV = 0;
  52100. _this.USELIGHTMAPASSHADOWMAP = false;
  52101. _this.GAMMALIGHTMAP = false;
  52102. _this.REFLECTION = false;
  52103. _this.REFLECTIONMAP_3D = false;
  52104. _this.REFLECTIONMAP_SPHERICAL = false;
  52105. _this.REFLECTIONMAP_PLANAR = false;
  52106. _this.REFLECTIONMAP_CUBIC = false;
  52107. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  52108. _this.REFLECTIONMAP_PROJECTION = false;
  52109. _this.REFLECTIONMAP_SKYBOX = false;
  52110. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  52111. _this.REFLECTIONMAP_EXPLICIT = false;
  52112. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  52113. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  52114. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  52115. _this.INVERTCUBICMAP = false;
  52116. _this.USESPHERICALFROMREFLECTIONMAP = false;
  52117. _this.USESPHERICALINVERTEX = false;
  52118. _this.REFLECTIONMAP_OPPOSITEZ = false;
  52119. _this.LODINREFLECTIONALPHA = false;
  52120. _this.GAMMAREFLECTION = false;
  52121. _this.RGBDREFLECTION = false;
  52122. _this.RADIANCEOCCLUSION = false;
  52123. _this.HORIZONOCCLUSION = false;
  52124. _this.REFRACTION = false;
  52125. _this.REFRACTIONMAP_3D = false;
  52126. _this.REFRACTIONMAP_OPPOSITEZ = false;
  52127. _this.LODINREFRACTIONALPHA = false;
  52128. _this.GAMMAREFRACTION = false;
  52129. _this.RGBDREFRACTION = false;
  52130. _this.LINKREFRACTIONTOTRANSPARENCY = false;
  52131. _this.INSTANCES = false;
  52132. _this.NUM_BONE_INFLUENCERS = 0;
  52133. _this.BonesPerMesh = 0;
  52134. _this.BONETEXTURE = false;
  52135. _this.NONUNIFORMSCALING = false;
  52136. _this.MORPHTARGETS = false;
  52137. _this.MORPHTARGETS_NORMAL = false;
  52138. _this.MORPHTARGETS_TANGENT = false;
  52139. _this.NUM_MORPH_INFLUENCERS = 0;
  52140. _this.IMAGEPROCESSING = false;
  52141. _this.VIGNETTE = false;
  52142. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  52143. _this.VIGNETTEBLENDMODEOPAQUE = false;
  52144. _this.TONEMAPPING = false;
  52145. _this.TONEMAPPING_ACES = false;
  52146. _this.CONTRAST = false;
  52147. _this.COLORCURVES = false;
  52148. _this.COLORGRADING = false;
  52149. _this.COLORGRADING3D = false;
  52150. _this.SAMPLER3DGREENDEPTH = false;
  52151. _this.SAMPLER3DBGRMAP = false;
  52152. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  52153. _this.EXPOSURE = false;
  52154. _this.MULTIVIEW = false;
  52155. _this.USEPHYSICALLIGHTFALLOFF = false;
  52156. _this.USEGLTFLIGHTFALLOFF = false;
  52157. _this.TWOSIDEDLIGHTING = false;
  52158. _this.SHADOWFLOAT = false;
  52159. _this.CLIPPLANE = false;
  52160. _this.CLIPPLANE2 = false;
  52161. _this.CLIPPLANE3 = false;
  52162. _this.CLIPPLANE4 = false;
  52163. _this.POINTSIZE = false;
  52164. _this.FOG = false;
  52165. _this.LOGARITHMICDEPTH = false;
  52166. _this.FORCENORMALFORWARD = false;
  52167. _this.SPECULARAA = false;
  52168. _this.CLEARCOAT = false;
  52169. _this.CLEARCOAT_DEFAULTIOR = false;
  52170. _this.CLEARCOAT_TEXTURE = false;
  52171. _this.CLEARCOAT_TEXTUREDIRECTUV = 0;
  52172. _this.CLEARCOAT_BUMP = false;
  52173. _this.CLEARCOAT_BUMPDIRECTUV = 0;
  52174. _this.CLEARCOAT_TINT = false;
  52175. _this.CLEARCOAT_TINT_TEXTURE = false;
  52176. _this.CLEARCOAT_TINT_TEXTUREDIRECTUV = 0;
  52177. _this.ANISOTROPIC = false;
  52178. _this.ANISOTROPIC_TEXTURE = false;
  52179. _this.ANISOTROPIC_TEXTUREDIRECTUV = 0;
  52180. _this.BRDF_V_HEIGHT_CORRELATED = false;
  52181. _this.MS_BRDF_ENERGY_CONSERVATION = false;
  52182. _this.SHEEN = false;
  52183. _this.SHEEN_TEXTURE = false;
  52184. _this.SHEEN_TEXTUREDIRECTUV = 0;
  52185. _this.SHEEN_LINKWITHALBEDO = false;
  52186. _this.UNLIT = false;
  52187. _this.DEBUGMODE = 0;
  52188. _this.rebuild();
  52189. return _this;
  52190. }
  52191. /**
  52192. * Resets the PBR Material defines.
  52193. */
  52194. PBRMaterialDefines.prototype.reset = function () {
  52195. _super.prototype.reset.call(this);
  52196. this.ALPHATESTVALUE = "0.5";
  52197. this.PBR = true;
  52198. };
  52199. return PBRMaterialDefines;
  52200. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_14__["MaterialDefines"]));
  52201. /**
  52202. * The Physically based material base class of BJS.
  52203. *
  52204. * This offers the main features of a standard PBR material.
  52205. * For more information, please refer to the documentation :
  52206. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  52207. */
  52208. var PBRBaseMaterial = /** @class */ (function (_super) {
  52209. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseMaterial, _super);
  52210. /**
  52211. * Instantiates a new PBRMaterial instance.
  52212. *
  52213. * @param name The material name
  52214. * @param scene The scene the material will be use in.
  52215. */
  52216. function PBRBaseMaterial(name, scene) {
  52217. var _this = _super.call(this, name, scene) || this;
  52218. /**
  52219. * Intensity of the direct lights e.g. the four lights available in your scene.
  52220. * This impacts both the direct diffuse and specular highlights.
  52221. */
  52222. _this._directIntensity = 1.0;
  52223. /**
  52224. * Intensity of the emissive part of the material.
  52225. * This helps controlling the emissive effect without modifying the emissive color.
  52226. */
  52227. _this._emissiveIntensity = 1.0;
  52228. /**
  52229. * Intensity of the environment e.g. how much the environment will light the object
  52230. * either through harmonics for rough material or through the refelction for shiny ones.
  52231. */
  52232. _this._environmentIntensity = 1.0;
  52233. /**
  52234. * This is a special control allowing the reduction of the specular highlights coming from the
  52235. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52236. */
  52237. _this._specularIntensity = 1.0;
  52238. /**
  52239. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  52240. */
  52241. _this._lightingInfos = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](_this._directIntensity, _this._emissiveIntensity, _this._environmentIntensity, _this._specularIntensity);
  52242. /**
  52243. * Debug Control allowing disabling the bump map on this material.
  52244. */
  52245. _this._disableBumpMap = false;
  52246. /**
  52247. * AKA Occlusion Texture Intensity in other nomenclature.
  52248. */
  52249. _this._ambientTextureStrength = 1.0;
  52250. /**
  52251. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52252. * 1 means it completely occludes it
  52253. * 0 mean it has no impact
  52254. */
  52255. _this._ambientTextureImpactOnAnalyticalLights = PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  52256. /**
  52257. * The color of a material in ambient lighting.
  52258. */
  52259. _this._ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  52260. /**
  52261. * AKA Diffuse Color in other nomenclature.
  52262. */
  52263. _this._albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  52264. /**
  52265. * AKA Specular Color in other nomenclature.
  52266. */
  52267. _this._reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  52268. /**
  52269. * The color applied when light is reflected from a material.
  52270. */
  52271. _this._reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  52272. /**
  52273. * The color applied when light is emitted from a material.
  52274. */
  52275. _this._emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  52276. /**
  52277. * AKA Glossiness in other nomenclature.
  52278. */
  52279. _this._microSurface = 0.9;
  52280. /**
  52281. * source material index of refraction (IOR)' / 'destination material IOR.
  52282. */
  52283. _this._indexOfRefraction = 0.66;
  52284. /**
  52285. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52286. */
  52287. _this._invertRefractionY = false;
  52288. /**
  52289. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52290. * Materials half opaque for instance using refraction could benefit from this control.
  52291. */
  52292. _this._linkRefractionWithTransparency = false;
  52293. /**
  52294. * Specifies that the material will use the light map as a show map.
  52295. */
  52296. _this._useLightmapAsShadowmap = false;
  52297. /**
  52298. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52299. * makes the reflect vector face the model (under horizon).
  52300. */
  52301. _this._useHorizonOcclusion = true;
  52302. /**
  52303. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52304. * too much the area relying on ambient texture to define their ambient occlusion.
  52305. */
  52306. _this._useRadianceOcclusion = true;
  52307. /**
  52308. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52309. */
  52310. _this._useAlphaFromAlbedoTexture = false;
  52311. /**
  52312. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  52313. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52314. */
  52315. _this._useSpecularOverAlpha = true;
  52316. /**
  52317. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52318. */
  52319. _this._useMicroSurfaceFromReflectivityMapAlpha = false;
  52320. /**
  52321. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52322. */
  52323. _this._useRoughnessFromMetallicTextureAlpha = true;
  52324. /**
  52325. * Specifies if the metallic texture contains the roughness information in its green channel.
  52326. */
  52327. _this._useRoughnessFromMetallicTextureGreen = false;
  52328. /**
  52329. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52330. */
  52331. _this._useMetallnessFromMetallicTextureBlue = false;
  52332. /**
  52333. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52334. */
  52335. _this._useAmbientOcclusionFromMetallicTextureRed = false;
  52336. /**
  52337. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52338. */
  52339. _this._useAmbientInGrayScale = false;
  52340. /**
  52341. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52342. * The material will try to infer what glossiness each pixel should be.
  52343. */
  52344. _this._useAutoMicroSurfaceFromReflectivityMap = false;
  52345. /**
  52346. * Defines the falloff type used in this material.
  52347. * It by default is Physical.
  52348. */
  52349. _this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL;
  52350. /**
  52351. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52352. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52353. */
  52354. _this._useRadianceOverAlpha = true;
  52355. /**
  52356. * Allows using an object space normal map (instead of tangent space).
  52357. */
  52358. _this._useObjectSpaceNormalMap = false;
  52359. /**
  52360. * Allows using the bump map in parallax mode.
  52361. */
  52362. _this._useParallax = false;
  52363. /**
  52364. * Allows using the bump map in parallax occlusion mode.
  52365. */
  52366. _this._useParallaxOcclusion = false;
  52367. /**
  52368. * Controls the scale bias of the parallax mode.
  52369. */
  52370. _this._parallaxScaleBias = 0.05;
  52371. /**
  52372. * If sets to true, disables all the lights affecting the material.
  52373. */
  52374. _this._disableLighting = false;
  52375. /**
  52376. * Number of Simultaneous lights allowed on the material.
  52377. */
  52378. _this._maxSimultaneousLights = 4;
  52379. /**
  52380. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52381. */
  52382. _this._invertNormalMapX = false;
  52383. /**
  52384. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52385. */
  52386. _this._invertNormalMapY = false;
  52387. /**
  52388. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52389. */
  52390. _this._twoSidedLighting = false;
  52391. /**
  52392. * Defines the alpha limits in alpha test mode.
  52393. */
  52394. _this._alphaCutOff = 0.4;
  52395. /**
  52396. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52397. */
  52398. _this._forceAlphaTest = false;
  52399. /**
  52400. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52401. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52402. */
  52403. _this._useAlphaFresnel = false;
  52404. /**
  52405. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52406. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52407. */
  52408. _this._useLinearAlphaFresnel = false;
  52409. /**
  52410. * The transparency mode of the material.
  52411. */
  52412. _this._transparencyMode = null;
  52413. /**
  52414. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  52415. * from cos thetav and roughness:
  52416. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  52417. */
  52418. _this._environmentBRDFTexture = null;
  52419. /**
  52420. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52421. */
  52422. _this._forceIrradianceInFragment = false;
  52423. /**
  52424. * Force normal to face away from face.
  52425. */
  52426. _this._forceNormalForward = false;
  52427. /**
  52428. * Enables specular anti aliasing in the PBR shader.
  52429. * It will both interacts on the Geometry for analytical and IBL lighting.
  52430. * It also prefilter the roughness map based on the bump values.
  52431. */
  52432. _this._enableSpecularAntiAliasing = false;
  52433. /**
  52434. * Stores the available render targets.
  52435. */
  52436. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__["SmartArray"](16);
  52437. /**
  52438. * Sets the global ambient color for the material used in lighting calculations.
  52439. */
  52440. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  52441. /**
  52442. * If set to true, no lighting calculations will be applied.
  52443. */
  52444. _this._unlit = false;
  52445. _this._debugMode = 0;
  52446. /**
  52447. * @hidden
  52448. * This is reserved for the inspector.
  52449. * Defines the material debug mode.
  52450. * It helps seeing only some components of the material while troubleshooting.
  52451. */
  52452. _this.debugMode = 0;
  52453. /**
  52454. * @hidden
  52455. * This is reserved for the inspector.
  52456. * Specify from where on screen the debug mode should start.
  52457. * The value goes from -1 (full screen) to 1 (not visible)
  52458. * It helps with side by side comparison against the final render
  52459. * This defaults to -1
  52460. */
  52461. _this.debugLimit = -1;
  52462. /**
  52463. * @hidden
  52464. * This is reserved for the inspector.
  52465. * As the default viewing range might not be enough (if the ambient is really small for instance)
  52466. * You can use the factor to better multiply the final value.
  52467. */
  52468. _this.debugFactor = 1;
  52469. /**
  52470. * Defines the clear coat layer parameters for the material.
  52471. */
  52472. _this.clearCoat = new _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  52473. /**
  52474. * Defines the anisotropic parameters for the material.
  52475. */
  52476. _this.anisotropy = new _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  52477. /**
  52478. * Defines the BRDF parameters for the material.
  52479. */
  52480. _this.brdf = new _pbrBRDFConfiguration__WEBPACK_IMPORTED_MODULE_10__["PBRBRDFConfiguration"](_this._markAllSubMeshesAsMiscDirty.bind(_this));
  52481. /**
  52482. * Defines the Sheen parameters for the material.
  52483. */
  52484. _this.sheen = new _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  52485. // Setup the default processing configuration to the scene.
  52486. _this._attachImageProcessingConfiguration(null);
  52487. _this.getRenderTargetTextures = function () {
  52488. _this._renderTargets.reset();
  52489. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  52490. _this._renderTargets.push(_this._reflectionTexture);
  52491. }
  52492. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  52493. _this._renderTargets.push(_this._refractionTexture);
  52494. }
  52495. return _this._renderTargets;
  52496. };
  52497. _this._environmentBRDFTexture = _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_4__["BRDFTextureTools"].GetEnvironmentBRDFTexture(scene);
  52498. return _this;
  52499. }
  52500. /**
  52501. * Attaches a new image processing configuration to the PBR Material.
  52502. * @param configuration
  52503. */
  52504. PBRBaseMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  52505. var _this = this;
  52506. if (configuration === this._imageProcessingConfiguration) {
  52507. return;
  52508. }
  52509. // Detaches observer.
  52510. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  52511. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  52512. }
  52513. // Pick the scene configuration if needed.
  52514. if (!configuration) {
  52515. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  52516. }
  52517. else {
  52518. this._imageProcessingConfiguration = configuration;
  52519. }
  52520. // Attaches observer.
  52521. if (this._imageProcessingConfiguration) {
  52522. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  52523. _this._markAllSubMeshesAsImageProcessingDirty();
  52524. });
  52525. }
  52526. };
  52527. Object.defineProperty(PBRBaseMaterial.prototype, "hasRenderTargetTextures", {
  52528. /**
  52529. * Gets a boolean indicating that current material needs to register RTT
  52530. */
  52531. get: function () {
  52532. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  52533. return true;
  52534. }
  52535. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  52536. return true;
  52537. }
  52538. return false;
  52539. },
  52540. enumerable: true,
  52541. configurable: true
  52542. });
  52543. /**
  52544. * Gets the name of the material class.
  52545. */
  52546. PBRBaseMaterial.prototype.getClassName = function () {
  52547. return "PBRBaseMaterial";
  52548. };
  52549. Object.defineProperty(PBRBaseMaterial.prototype, "useLogarithmicDepth", {
  52550. /**
  52551. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52552. */
  52553. get: function () {
  52554. return this._useLogarithmicDepth;
  52555. },
  52556. /**
  52557. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52558. */
  52559. set: function (value) {
  52560. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  52561. },
  52562. enumerable: true,
  52563. configurable: true
  52564. });
  52565. Object.defineProperty(PBRBaseMaterial.prototype, "transparencyMode", {
  52566. /**
  52567. * Gets the current transparency mode.
  52568. */
  52569. get: function () {
  52570. return this._transparencyMode;
  52571. },
  52572. /**
  52573. * Sets the transparency mode of the material.
  52574. *
  52575. * | Value | Type | Description |
  52576. * | ----- | ----------------------------------- | ----------- |
  52577. * | 0 | OPAQUE | |
  52578. * | 1 | ALPHATEST | |
  52579. * | 2 | ALPHABLEND | |
  52580. * | 3 | ALPHATESTANDBLEND | |
  52581. *
  52582. */
  52583. set: function (value) {
  52584. if (this._transparencyMode === value) {
  52585. return;
  52586. }
  52587. this._transparencyMode = value;
  52588. this._forceAlphaTest = (value === PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND);
  52589. this._markAllSubMeshesAsTexturesAndMiscDirty();
  52590. },
  52591. enumerable: true,
  52592. configurable: true
  52593. });
  52594. Object.defineProperty(PBRBaseMaterial.prototype, "_disableAlphaBlending", {
  52595. /**
  52596. * Returns true if alpha blending should be disabled.
  52597. */
  52598. get: function () {
  52599. return (this._linkRefractionWithTransparency ||
  52600. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_OPAQUE ||
  52601. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  52602. },
  52603. enumerable: true,
  52604. configurable: true
  52605. });
  52606. /**
  52607. * Specifies whether or not this material should be rendered in alpha blend mode.
  52608. */
  52609. PBRBaseMaterial.prototype.needAlphaBlending = function () {
  52610. if (this._disableAlphaBlending) {
  52611. return false;
  52612. }
  52613. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromAlbedoTexture();
  52614. };
  52615. /**
  52616. * Specifies if the mesh will require alpha blending.
  52617. * @param mesh - BJS mesh.
  52618. */
  52619. PBRBaseMaterial.prototype.needAlphaBlendingForMesh = function (mesh) {
  52620. if (this._disableAlphaBlending && mesh.visibility >= 1.0) {
  52621. return false;
  52622. }
  52623. return _super.prototype.needAlphaBlendingForMesh.call(this, mesh);
  52624. };
  52625. /**
  52626. * Specifies whether or not this material should be rendered in alpha test mode.
  52627. */
  52628. PBRBaseMaterial.prototype.needAlphaTesting = function () {
  52629. if (this._forceAlphaTest) {
  52630. return true;
  52631. }
  52632. if (this._linkRefractionWithTransparency) {
  52633. return false;
  52634. }
  52635. return this._albedoTexture != null && this._albedoTexture.hasAlpha && (this._transparencyMode == null || this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  52636. };
  52637. /**
  52638. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52639. */
  52640. PBRBaseMaterial.prototype._shouldUseAlphaFromAlbedoTexture = function () {
  52641. return this._albedoTexture != null && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE;
  52642. };
  52643. /**
  52644. * Gets the texture used for the alpha test.
  52645. */
  52646. PBRBaseMaterial.prototype.getAlphaTestTexture = function () {
  52647. return this._albedoTexture;
  52648. };
  52649. /**
  52650. * Specifies that the submesh is ready to be used.
  52651. * @param mesh - BJS mesh.
  52652. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52653. * @param useInstances - Specifies that instances should be used.
  52654. * @returns - boolean indicating that the submesh is ready or not.
  52655. */
  52656. PBRBaseMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  52657. if (subMesh.effect && this.isFrozen) {
  52658. if (this._wasPreviouslyReady) {
  52659. return true;
  52660. }
  52661. }
  52662. if (!subMesh._materialDefines) {
  52663. subMesh._materialDefines = new PBRMaterialDefines();
  52664. }
  52665. var defines = subMesh._materialDefines;
  52666. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  52667. if (defines._renderId === this.getScene().getRenderId()) {
  52668. return true;
  52669. }
  52670. }
  52671. var scene = this.getScene();
  52672. var engine = scene.getEngine();
  52673. if (defines._areTexturesDirty) {
  52674. if (scene.texturesEnabled) {
  52675. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].DiffuseTextureEnabled) {
  52676. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  52677. return false;
  52678. }
  52679. }
  52680. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].AmbientTextureEnabled) {
  52681. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  52682. return false;
  52683. }
  52684. }
  52685. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].OpacityTextureEnabled) {
  52686. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  52687. return false;
  52688. }
  52689. }
  52690. var reflectionTexture = this._getReflectionTexture();
  52691. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled) {
  52692. if (!reflectionTexture.isReadyOrNotBlocking()) {
  52693. return false;
  52694. }
  52695. }
  52696. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].LightmapTextureEnabled) {
  52697. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  52698. return false;
  52699. }
  52700. }
  52701. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].EmissiveTextureEnabled) {
  52702. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  52703. return false;
  52704. }
  52705. }
  52706. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].SpecularTextureEnabled) {
  52707. if (this._metallicTexture) {
  52708. if (!this._metallicTexture.isReadyOrNotBlocking()) {
  52709. return false;
  52710. }
  52711. }
  52712. else if (this._reflectivityTexture) {
  52713. if (!this._reflectivityTexture.isReadyOrNotBlocking()) {
  52714. return false;
  52715. }
  52716. }
  52717. if (this._microSurfaceTexture) {
  52718. if (!this._microSurfaceTexture.isReadyOrNotBlocking()) {
  52719. return false;
  52720. }
  52721. }
  52722. }
  52723. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  52724. // Bump texture cannot be not blocking.
  52725. if (!this._bumpTexture.isReady()) {
  52726. return false;
  52727. }
  52728. }
  52729. var refractionTexture = this._getRefractionTexture();
  52730. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].RefractionTextureEnabled) {
  52731. if (!refractionTexture.isReadyOrNotBlocking()) {
  52732. return false;
  52733. }
  52734. }
  52735. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled) {
  52736. // This is blocking.
  52737. if (!this._environmentBRDFTexture.isReady()) {
  52738. return false;
  52739. }
  52740. }
  52741. }
  52742. }
  52743. if (!this.clearCoat.isReadyForSubMesh(defines, scene, engine, this._disableBumpMap)) {
  52744. return false;
  52745. }
  52746. if (!this.sheen.isReadyForSubMesh(defines, scene)) {
  52747. return false;
  52748. }
  52749. if (!this.anisotropy.isReadyForSubMesh(defines, scene)) {
  52750. return false;
  52751. }
  52752. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  52753. if (!this._imageProcessingConfiguration.isReady()) {
  52754. return false;
  52755. }
  52756. }
  52757. if (!engine.getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  52758. mesh.createNormals(true);
  52759. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("PBRMaterial: Normals have been created for the mesh: " + mesh.name);
  52760. }
  52761. var previousEffect = subMesh.effect;
  52762. var effect = this._prepareEffect(mesh, defines, this.onCompiled, this.onError, useInstances);
  52763. if (effect) {
  52764. // Use previous effect while new one is compiling
  52765. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  52766. effect = previousEffect;
  52767. defines.markAsUnprocessed();
  52768. }
  52769. else {
  52770. scene.resetCachedMaterial();
  52771. subMesh.setEffect(effect, defines);
  52772. this.buildUniformLayout();
  52773. }
  52774. }
  52775. if (!subMesh.effect || !subMesh.effect.isReady()) {
  52776. return false;
  52777. }
  52778. defines._renderId = scene.getRenderId();
  52779. this._wasPreviouslyReady = true;
  52780. return true;
  52781. };
  52782. /**
  52783. * Specifies if the material uses metallic roughness workflow.
  52784. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52785. */
  52786. PBRBaseMaterial.prototype.isMetallicWorkflow = function () {
  52787. if (this._metallic != null || this._roughness != null || this._metallicTexture) {
  52788. return true;
  52789. }
  52790. return false;
  52791. };
  52792. PBRBaseMaterial.prototype._prepareEffect = function (mesh, defines, onCompiled, onError, useInstances, useClipPlane) {
  52793. if (onCompiled === void 0) { onCompiled = null; }
  52794. if (onError === void 0) { onError = null; }
  52795. if (useInstances === void 0) { useInstances = null; }
  52796. if (useClipPlane === void 0) { useClipPlane = null; }
  52797. this._prepareDefines(mesh, defines, useInstances, useClipPlane);
  52798. if (!defines.isDirty) {
  52799. return null;
  52800. }
  52801. defines.markAsProcessed();
  52802. var scene = this.getScene();
  52803. var engine = scene.getEngine();
  52804. // Fallbacks
  52805. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_13__["EffectFallbacks"]();
  52806. var fallbackRank = 0;
  52807. if (defines.USESPHERICALINVERTEX) {
  52808. fallbacks.addFallback(fallbackRank++, "USESPHERICALINVERTEX");
  52809. }
  52810. if (defines.FOG) {
  52811. fallbacks.addFallback(fallbackRank, "FOG");
  52812. }
  52813. if (defines.SPECULARAA) {
  52814. fallbacks.addFallback(fallbackRank, "SPECULARAA");
  52815. }
  52816. if (defines.POINTSIZE) {
  52817. fallbacks.addFallback(fallbackRank, "POINTSIZE");
  52818. }
  52819. if (defines.LOGARITHMICDEPTH) {
  52820. fallbacks.addFallback(fallbackRank, "LOGARITHMICDEPTH");
  52821. }
  52822. if (defines.PARALLAX) {
  52823. fallbacks.addFallback(fallbackRank, "PARALLAX");
  52824. }
  52825. if (defines.PARALLAXOCCLUSION) {
  52826. fallbacks.addFallback(fallbackRank++, "PARALLAXOCCLUSION");
  52827. }
  52828. fallbackRank = _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  52829. fallbackRank = _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  52830. fallbackRank = _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  52831. if (defines.ENVIRONMENTBRDF) {
  52832. fallbacks.addFallback(fallbackRank++, "ENVIRONMENTBRDF");
  52833. }
  52834. if (defines.TANGENT) {
  52835. fallbacks.addFallback(fallbackRank++, "TANGENT");
  52836. }
  52837. if (defines.BUMP) {
  52838. fallbacks.addFallback(fallbackRank++, "BUMP");
  52839. }
  52840. fallbackRank = _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights, fallbackRank++);
  52841. if (defines.SPECULARTERM) {
  52842. fallbacks.addFallback(fallbackRank++, "SPECULARTERM");
  52843. }
  52844. if (defines.USESPHERICALFROMREFLECTIONMAP) {
  52845. fallbacks.addFallback(fallbackRank++, "USESPHERICALFROMREFLECTIONMAP");
  52846. }
  52847. if (defines.LIGHTMAP) {
  52848. fallbacks.addFallback(fallbackRank++, "LIGHTMAP");
  52849. }
  52850. if (defines.NORMAL) {
  52851. fallbacks.addFallback(fallbackRank++, "NORMAL");
  52852. }
  52853. if (defines.AMBIENT) {
  52854. fallbacks.addFallback(fallbackRank++, "AMBIENT");
  52855. }
  52856. if (defines.EMISSIVE) {
  52857. fallbacks.addFallback(fallbackRank++, "EMISSIVE");
  52858. }
  52859. if (defines.VERTEXCOLOR) {
  52860. fallbacks.addFallback(fallbackRank++, "VERTEXCOLOR");
  52861. }
  52862. if (defines.NUM_BONE_INFLUENCERS > 0) {
  52863. fallbacks.addCPUSkinningFallback(fallbackRank++, mesh);
  52864. }
  52865. if (defines.MORPHTARGETS) {
  52866. fallbacks.addFallback(fallbackRank++, "MORPHTARGETS");
  52867. }
  52868. if (defines.MULTIVIEW) {
  52869. fallbacks.addFallback(0, "MULTIVIEW");
  52870. }
  52871. //Attributes
  52872. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  52873. if (defines.NORMAL) {
  52874. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  52875. }
  52876. if (defines.TANGENT) {
  52877. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind);
  52878. }
  52879. if (defines.UV1) {
  52880. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  52881. }
  52882. if (defines.UV2) {
  52883. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  52884. }
  52885. if (defines.VERTEXCOLOR) {
  52886. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  52887. }
  52888. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  52889. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  52890. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  52891. var shaderName = "pbr";
  52892. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vAlbedoColor", "vReflectivityColor", "vEmissiveColor", "visibility", "vReflectionColor",
  52893. "vFogInfos", "vFogColor", "pointSize",
  52894. "vAlbedoInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vReflectionPosition", "vReflectionSize", "vEmissiveInfos", "vReflectivityInfos",
  52895. "vMicroSurfaceSamplerInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  52896. "mBones",
  52897. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "albedoMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "reflectivityMatrix", "normalMatrix", "microSurfaceSamplerMatrix", "bumpMatrix", "lightmapMatrix", "refractionMatrix",
  52898. "vLightingIntensity",
  52899. "logarithmicDepthConstant",
  52900. "vSphericalX", "vSphericalY", "vSphericalZ",
  52901. "vSphericalXX", "vSphericalYY", "vSphericalZZ",
  52902. "vSphericalXY", "vSphericalYZ", "vSphericalZX",
  52903. "vReflectionMicrosurfaceInfos", "vRefractionMicrosurfaceInfos",
  52904. "vTangentSpaceParams", "boneTextureWidth",
  52905. "vDebugMode"
  52906. ];
  52907. var samplers = ["albedoSampler", "reflectivitySampler", "ambientSampler", "emissiveSampler",
  52908. "bumpSampler", "lightmapSampler", "opacitySampler",
  52909. "refractionSampler", "refractionSamplerLow", "refractionSamplerHigh",
  52910. "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh",
  52911. "microSurfaceSampler", "environmentBrdfSampler", "boneSampler"];
  52912. var uniformBuffers = ["Material", "Scene"];
  52913. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddUniforms(uniforms);
  52914. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddSamplers(samplers);
  52915. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddUniforms(uniforms);
  52916. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddSamplers(samplers);
  52917. _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].AddUniforms(uniforms);
  52918. _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].AddSamplers(samplers);
  52919. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]) {
  52920. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  52921. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  52922. }
  52923. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareUniformsAndSamplersList({
  52924. uniformsNames: uniforms,
  52925. uniformBuffersNames: uniformBuffers,
  52926. samplers: samplers,
  52927. defines: defines,
  52928. maxSimultaneousLights: this._maxSimultaneousLights
  52929. });
  52930. if (this.customShaderNameResolve) {
  52931. shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines);
  52932. }
  52933. var join = defines.toString();
  52934. return engine.createEffect(shaderName, {
  52935. attributes: attribs,
  52936. uniformsNames: uniforms,
  52937. uniformBuffersNames: uniformBuffers,
  52938. samplers: samplers,
  52939. defines: join,
  52940. fallbacks: fallbacks,
  52941. onCompiled: onCompiled,
  52942. onError: onError,
  52943. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  52944. }, engine);
  52945. };
  52946. PBRBaseMaterial.prototype._prepareDefines = function (mesh, defines, useInstances, useClipPlane) {
  52947. if (useInstances === void 0) { useInstances = null; }
  52948. if (useClipPlane === void 0) { useClipPlane = null; }
  52949. var scene = this.getScene();
  52950. var engine = scene.getEngine();
  52951. // Lights
  52952. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  52953. defines._needNormals = true;
  52954. // Multiview
  52955. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMultiview(scene, defines);
  52956. // Textures
  52957. defines.METALLICWORKFLOW = this.isMetallicWorkflow();
  52958. if (defines._areTexturesDirty) {
  52959. defines._needUVs = false;
  52960. if (scene.texturesEnabled) {
  52961. if (scene.getEngine().getCaps().textureLOD) {
  52962. defines.LODBASEDMICROSFURACE = true;
  52963. }
  52964. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].DiffuseTextureEnabled) {
  52965. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._albedoTexture, defines, "ALBEDO");
  52966. }
  52967. else {
  52968. defines.ALBEDO = false;
  52969. }
  52970. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].AmbientTextureEnabled) {
  52971. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  52972. defines.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale;
  52973. }
  52974. else {
  52975. defines.AMBIENT = false;
  52976. }
  52977. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].OpacityTextureEnabled) {
  52978. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  52979. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  52980. }
  52981. else {
  52982. defines.OPACITY = false;
  52983. }
  52984. var reflectionTexture = this._getReflectionTexture();
  52985. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled) {
  52986. defines.REFLECTION = true;
  52987. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  52988. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  52989. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  52990. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  52991. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].INVCUBIC_MODE) {
  52992. defines.INVERTCUBICMAP = true;
  52993. }
  52994. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  52995. defines.REFLECTIONMAP_CUBIC = false;
  52996. defines.REFLECTIONMAP_EXPLICIT = false;
  52997. defines.REFLECTIONMAP_PLANAR = false;
  52998. defines.REFLECTIONMAP_PROJECTION = false;
  52999. defines.REFLECTIONMAP_SKYBOX = false;
  53000. defines.REFLECTIONMAP_SPHERICAL = false;
  53001. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  53002. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  53003. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  53004. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  53005. switch (reflectionTexture.coordinatesMode) {
  53006. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].EXPLICIT_MODE:
  53007. defines.REFLECTIONMAP_EXPLICIT = true;
  53008. break;
  53009. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].PLANAR_MODE:
  53010. defines.REFLECTIONMAP_PLANAR = true;
  53011. break;
  53012. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].PROJECTION_MODE:
  53013. defines.REFLECTIONMAP_PROJECTION = true;
  53014. break;
  53015. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].SKYBOX_MODE:
  53016. defines.REFLECTIONMAP_SKYBOX = true;
  53017. break;
  53018. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].SPHERICAL_MODE:
  53019. defines.REFLECTIONMAP_SPHERICAL = true;
  53020. break;
  53021. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].EQUIRECTANGULAR_MODE:
  53022. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  53023. break;
  53024. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  53025. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  53026. break;
  53027. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  53028. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  53029. break;
  53030. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].CUBIC_MODE:
  53031. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].INVCUBIC_MODE:
  53032. default:
  53033. defines.REFLECTIONMAP_CUBIC = true;
  53034. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = reflectionTexture.boundingBoxSize ? true : false;
  53035. break;
  53036. }
  53037. if (reflectionTexture.coordinatesMode !== _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_17__["Texture"].SKYBOX_MODE) {
  53038. if (reflectionTexture.sphericalPolynomial) {
  53039. defines.USESPHERICALFROMREFLECTIONMAP = true;
  53040. if (this._forceIrradianceInFragment || scene.getEngine().getCaps().maxVaryingVectors <= 8) {
  53041. defines.USESPHERICALINVERTEX = false;
  53042. }
  53043. else {
  53044. defines.USESPHERICALINVERTEX = true;
  53045. }
  53046. }
  53047. }
  53048. else {
  53049. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  53050. }
  53051. }
  53052. else {
  53053. defines.REFLECTION = false;
  53054. defines.REFLECTIONMAP_3D = false;
  53055. defines.REFLECTIONMAP_SPHERICAL = false;
  53056. defines.REFLECTIONMAP_PLANAR = false;
  53057. defines.REFLECTIONMAP_CUBIC = false;
  53058. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  53059. defines.REFLECTIONMAP_PROJECTION = false;
  53060. defines.REFLECTIONMAP_SKYBOX = false;
  53061. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  53062. defines.REFLECTIONMAP_EXPLICIT = false;
  53063. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  53064. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  53065. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  53066. defines.INVERTCUBICMAP = false;
  53067. defines.USESPHERICALFROMREFLECTIONMAP = false;
  53068. defines.USESPHERICALINVERTEX = false;
  53069. defines.REFLECTIONMAP_OPPOSITEZ = false;
  53070. defines.LODINREFLECTIONALPHA = false;
  53071. defines.GAMMAREFLECTION = false;
  53072. defines.RGBDREFLECTION = false;
  53073. }
  53074. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].LightmapTextureEnabled) {
  53075. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  53076. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  53077. defines.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace;
  53078. }
  53079. else {
  53080. defines.LIGHTMAP = false;
  53081. }
  53082. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].EmissiveTextureEnabled) {
  53083. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  53084. }
  53085. else {
  53086. defines.EMISSIVE = false;
  53087. }
  53088. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].SpecularTextureEnabled) {
  53089. if (this._metallicTexture) {
  53090. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._metallicTexture, defines, "REFLECTIVITY");
  53091. defines.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha;
  53092. defines.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen;
  53093. defines.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue;
  53094. defines.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed;
  53095. }
  53096. else if (this._reflectivityTexture) {
  53097. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._reflectivityTexture, defines, "REFLECTIVITY");
  53098. defines.MICROSURFACEFROMREFLECTIVITYMAP = this._useMicroSurfaceFromReflectivityMapAlpha;
  53099. defines.MICROSURFACEAUTOMATIC = this._useAutoMicroSurfaceFromReflectivityMap;
  53100. }
  53101. else {
  53102. defines.REFLECTIVITY = false;
  53103. }
  53104. if (this._microSurfaceTexture) {
  53105. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._microSurfaceTexture, defines, "MICROSURFACEMAP");
  53106. }
  53107. else {
  53108. defines.MICROSURFACEMAP = false;
  53109. }
  53110. }
  53111. else {
  53112. defines.REFLECTIVITY = false;
  53113. defines.MICROSURFACEMAP = false;
  53114. }
  53115. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  53116. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  53117. if (this._useParallax && this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].DiffuseTextureEnabled) {
  53118. defines.PARALLAX = true;
  53119. defines.PARALLAXOCCLUSION = !!this._useParallaxOcclusion;
  53120. }
  53121. else {
  53122. defines.PARALLAX = false;
  53123. }
  53124. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  53125. }
  53126. else {
  53127. defines.BUMP = false;
  53128. }
  53129. var refractionTexture = this._getRefractionTexture();
  53130. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].RefractionTextureEnabled) {
  53131. defines.REFRACTION = true;
  53132. defines.REFRACTIONMAP_3D = refractionTexture.isCube;
  53133. defines.GAMMAREFRACTION = refractionTexture.gammaSpace;
  53134. defines.RGBDREFRACTION = refractionTexture.isRGBD;
  53135. defines.REFRACTIONMAP_OPPOSITEZ = refractionTexture.invertZ;
  53136. defines.LODINREFRACTIONALPHA = refractionTexture.lodLevelInAlpha;
  53137. if (this._linkRefractionWithTransparency) {
  53138. defines.LINKREFRACTIONTOTRANSPARENCY = true;
  53139. }
  53140. }
  53141. else {
  53142. defines.REFRACTION = false;
  53143. }
  53144. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled) {
  53145. defines.ENVIRONMENTBRDF = true;
  53146. // Not actual true RGBD, only the B chanel is encoded as RGBD for sheen.
  53147. defines.ENVIRONMENTBRDF_RGBD = this._environmentBRDFTexture.isRGBD;
  53148. }
  53149. else {
  53150. defines.ENVIRONMENTBRDF = false;
  53151. defines.ENVIRONMENTBRDF_RGBD = false;
  53152. }
  53153. if (this._shouldUseAlphaFromAlbedoTexture()) {
  53154. defines.ALPHAFROMALBEDO = true;
  53155. }
  53156. else {
  53157. defines.ALPHAFROMALBEDO = false;
  53158. }
  53159. }
  53160. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  53161. if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_STANDARD) {
  53162. defines.USEPHYSICALLIGHTFALLOFF = false;
  53163. defines.USEGLTFLIGHTFALLOFF = false;
  53164. }
  53165. else if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_GLTF) {
  53166. defines.USEPHYSICALLIGHTFALLOFF = false;
  53167. defines.USEGLTFLIGHTFALLOFF = true;
  53168. }
  53169. else {
  53170. defines.USEPHYSICALLIGHTFALLOFF = true;
  53171. defines.USEGLTFLIGHTFALLOFF = false;
  53172. }
  53173. defines.RADIANCEOVERALPHA = this._useRadianceOverAlpha;
  53174. if (!this.backFaceCulling && this._twoSidedLighting) {
  53175. defines.TWOSIDEDLIGHTING = true;
  53176. }
  53177. else {
  53178. defines.TWOSIDEDLIGHTING = false;
  53179. }
  53180. defines.ALPHATESTVALUE = "" + this._alphaCutOff + (this._alphaCutOff % 1 === 0 ? "." : "");
  53181. 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);
  53182. defines.ALPHABLEND = this.needAlphaBlendingForMesh(mesh);
  53183. defines.ALPHAFRESNEL = this._useAlphaFresnel || this._useLinearAlphaFresnel;
  53184. defines.LINEARALPHAFRESNEL = this._useLinearAlphaFresnel;
  53185. defines.SPECULARAA = scene.getEngine().getCaps().standardDerivatives && this._enableSpecularAntiAliasing;
  53186. }
  53187. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  53188. this._imageProcessingConfiguration.prepareDefines(defines);
  53189. }
  53190. defines.FORCENORMALFORWARD = this._forceNormalForward;
  53191. defines.RADIANCEOCCLUSION = this._useRadianceOcclusion;
  53192. defines.HORIZONOCCLUSION = this._useHorizonOcclusion;
  53193. // Misc.
  53194. if (defines._areMiscDirty) {
  53195. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest, defines);
  53196. defines.UNLIT = this._unlit || ((this.pointsCloud || this.wireframe) && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind));
  53197. defines.DEBUGMODE = this._debugMode;
  53198. }
  53199. // External config
  53200. this.clearCoat.prepareDefines(defines, scene);
  53201. this.anisotropy.prepareDefines(defines, mesh, scene);
  53202. this.brdf.prepareDefines(defines);
  53203. this.sheen.prepareDefines(defines, scene);
  53204. // Values that need to be evaluated on every frame
  53205. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, useClipPlane);
  53206. // Attribs
  53207. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true, this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE);
  53208. };
  53209. /**
  53210. * Force shader compilation
  53211. */
  53212. PBRBaseMaterial.prototype.forceCompilation = function (mesh, onCompiled, options) {
  53213. var _this = this;
  53214. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  53215. var defines = new PBRMaterialDefines();
  53216. var effect = this._prepareEffect(mesh, defines, undefined, undefined, undefined, localOptions.clipPlane);
  53217. if (effect.isReady()) {
  53218. if (onCompiled) {
  53219. onCompiled(this);
  53220. }
  53221. }
  53222. else {
  53223. effect.onCompileObservable.add(function () {
  53224. if (onCompiled) {
  53225. onCompiled(_this);
  53226. }
  53227. });
  53228. }
  53229. };
  53230. /**
  53231. * Initializes the uniform buffer layout for the shader.
  53232. */
  53233. PBRBaseMaterial.prototype.buildUniformLayout = function () {
  53234. // Order is important !
  53235. this._uniformBuffer.addUniform("vAlbedoInfos", 2);
  53236. this._uniformBuffer.addUniform("vAmbientInfos", 4);
  53237. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  53238. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  53239. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  53240. this._uniformBuffer.addUniform("vReflectivityInfos", 3);
  53241. this._uniformBuffer.addUniform("vMicroSurfaceSamplerInfos", 2);
  53242. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  53243. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  53244. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  53245. this._uniformBuffer.addUniform("vReflectionSize", 3);
  53246. this._uniformBuffer.addUniform("vBumpInfos", 3);
  53247. this._uniformBuffer.addUniform("albedoMatrix", 16);
  53248. this._uniformBuffer.addUniform("ambientMatrix", 16);
  53249. this._uniformBuffer.addUniform("opacityMatrix", 16);
  53250. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  53251. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  53252. this._uniformBuffer.addUniform("reflectivityMatrix", 16);
  53253. this._uniformBuffer.addUniform("microSurfaceSamplerMatrix", 16);
  53254. this._uniformBuffer.addUniform("bumpMatrix", 16);
  53255. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  53256. this._uniformBuffer.addUniform("refractionMatrix", 16);
  53257. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  53258. this._uniformBuffer.addUniform("vReflectionColor", 3);
  53259. this._uniformBuffer.addUniform("vAlbedoColor", 4);
  53260. this._uniformBuffer.addUniform("vLightingIntensity", 4);
  53261. this._uniformBuffer.addUniform("vRefractionMicrosurfaceInfos", 3);
  53262. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  53263. this._uniformBuffer.addUniform("pointSize", 1);
  53264. this._uniformBuffer.addUniform("vReflectivityColor", 4);
  53265. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  53266. this._uniformBuffer.addUniform("visibility", 1);
  53267. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].PrepareUniformBuffer(this._uniformBuffer);
  53268. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].PrepareUniformBuffer(this._uniformBuffer);
  53269. _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].PrepareUniformBuffer(this._uniformBuffer);
  53270. this._uniformBuffer.create();
  53271. };
  53272. /**
  53273. * Unbinds the textures.
  53274. */
  53275. PBRBaseMaterial.prototype.unbind = function () {
  53276. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  53277. this._uniformBuffer.setTexture("reflectionSampler", null);
  53278. }
  53279. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  53280. this._uniformBuffer.setTexture("refractionSampler", null);
  53281. }
  53282. _super.prototype.unbind.call(this);
  53283. };
  53284. /**
  53285. * Binds the submesh data.
  53286. * @param world - The world matrix.
  53287. * @param mesh - The BJS mesh.
  53288. * @param subMesh - A submesh of the BJS mesh.
  53289. */
  53290. PBRBaseMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  53291. var scene = this.getScene();
  53292. var defines = subMesh._materialDefines;
  53293. if (!defines) {
  53294. return;
  53295. }
  53296. var effect = subMesh.effect;
  53297. if (!effect) {
  53298. return;
  53299. }
  53300. this._activeEffect = effect;
  53301. // Matrices
  53302. this.bindOnlyWorldMatrix(world);
  53303. // Normal Matrix
  53304. if (defines.OBJECTSPACE_NORMALMAP) {
  53305. world.toNormalMatrix(this._normalMatrix);
  53306. this.bindOnlyNormalMatrix(this._normalMatrix);
  53307. }
  53308. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  53309. // Bones
  53310. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  53311. var reflectionTexture = null;
  53312. if (mustRebind) {
  53313. var engine = scene.getEngine();
  53314. this._uniformBuffer.bindToEffect(effect, "Material");
  53315. this.bindViewProjection(effect);
  53316. reflectionTexture = this._getReflectionTexture();
  53317. var refractionTexture = this._getRefractionTexture();
  53318. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  53319. // Texture uniforms
  53320. if (scene.texturesEnabled) {
  53321. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].DiffuseTextureEnabled) {
  53322. this._uniformBuffer.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level);
  53323. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._albedoTexture, this._uniformBuffer, "albedo");
  53324. }
  53325. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].AmbientTextureEnabled) {
  53326. this._uniformBuffer.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights);
  53327. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  53328. }
  53329. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].OpacityTextureEnabled) {
  53330. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  53331. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  53332. }
  53333. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled) {
  53334. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  53335. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, 0);
  53336. if (reflectionTexture.boundingBoxSize) {
  53337. var cubeTexture = reflectionTexture;
  53338. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  53339. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  53340. }
  53341. var polynomials = reflectionTexture.sphericalPolynomial;
  53342. if (defines.USESPHERICALFROMREFLECTIONMAP && polynomials) {
  53343. this._activeEffect.setFloat3("vSphericalX", polynomials.x.x, polynomials.x.y, polynomials.x.z);
  53344. this._activeEffect.setFloat3("vSphericalY", polynomials.y.x, polynomials.y.y, polynomials.y.z);
  53345. this._activeEffect.setFloat3("vSphericalZ", polynomials.z.x, polynomials.z.y, polynomials.z.z);
  53346. this._activeEffect.setFloat3("vSphericalXX_ZZ", polynomials.xx.x - polynomials.zz.x, polynomials.xx.y - polynomials.zz.y, polynomials.xx.z - polynomials.zz.z);
  53347. this._activeEffect.setFloat3("vSphericalYY_ZZ", polynomials.yy.x - polynomials.zz.x, polynomials.yy.y - polynomials.zz.y, polynomials.yy.z - polynomials.zz.z);
  53348. this._activeEffect.setFloat3("vSphericalZZ", polynomials.zz.x, polynomials.zz.y, polynomials.zz.z);
  53349. this._activeEffect.setFloat3("vSphericalXY", polynomials.xy.x, polynomials.xy.y, polynomials.xy.z);
  53350. this._activeEffect.setFloat3("vSphericalYZ", polynomials.yz.x, polynomials.yz.y, polynomials.yz.z);
  53351. this._activeEffect.setFloat3("vSphericalZX", polynomials.zx.x, polynomials.zx.y, polynomials.zx.z);
  53352. }
  53353. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  53354. }
  53355. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].EmissiveTextureEnabled) {
  53356. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  53357. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  53358. }
  53359. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].LightmapTextureEnabled) {
  53360. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  53361. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  53362. }
  53363. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].SpecularTextureEnabled) {
  53364. if (this._metallicTexture) {
  53365. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength);
  53366. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._metallicTexture, this._uniformBuffer, "reflectivity");
  53367. }
  53368. else if (this._reflectivityTexture) {
  53369. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1.0);
  53370. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._reflectivityTexture, this._uniformBuffer, "reflectivity");
  53371. }
  53372. if (this._microSurfaceTexture) {
  53373. this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level);
  53374. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._microSurfaceTexture, this._uniformBuffer, "microSurfaceSampler");
  53375. }
  53376. }
  53377. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  53378. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias);
  53379. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  53380. if (scene._mirroredCameraPosition) {
  53381. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  53382. }
  53383. else {
  53384. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  53385. }
  53386. }
  53387. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].RefractionTextureEnabled) {
  53388. this._uniformBuffer.updateMatrix("refractionMatrix", refractionTexture.getReflectionTextureMatrix());
  53389. var depth = 1.0;
  53390. if (!refractionTexture.isCube) {
  53391. if (refractionTexture.depth) {
  53392. depth = refractionTexture.depth;
  53393. }
  53394. }
  53395. this._uniformBuffer.updateFloat4("vRefractionInfos", refractionTexture.level, this._indexOfRefraction, depth, this._invertRefractionY ? -1 : 1);
  53396. this._uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos", refractionTexture.getSize().width, refractionTexture.lodGenerationScale, refractionTexture.lodGenerationOffset);
  53397. }
  53398. }
  53399. // Point size
  53400. if (this.pointsCloud) {
  53401. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  53402. }
  53403. // Colors
  53404. if (defines.METALLICWORKFLOW) {
  53405. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].r = (this._metallic === undefined || this._metallic === null) ? 1 : this._metallic;
  53406. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].g = (this._roughness === undefined || this._roughness === null) ? 1 : this._roughness;
  53407. this._uniformBuffer.updateColor4("vReflectivityColor", _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0], 0);
  53408. }
  53409. else {
  53410. this._uniformBuffer.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
  53411. }
  53412. this._uniformBuffer.updateColor3("vEmissiveColor", _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].EmissiveTextureEnabled ? this._emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"].BlackReadOnly);
  53413. this._uniformBuffer.updateColor3("vReflectionColor", this._reflectionColor);
  53414. this._uniformBuffer.updateColor4("vAlbedoColor", this._albedoColor, this.alpha);
  53415. // Visibility
  53416. this._uniformBuffer.updateFloat("visibility", mesh.visibility);
  53417. // Misc
  53418. this._lightingInfos.x = this._directIntensity;
  53419. this._lightingInfos.y = this._emissiveIntensity;
  53420. this._lightingInfos.z = this._environmentIntensity;
  53421. this._lightingInfos.w = this._specularIntensity;
  53422. this._uniformBuffer.updateVector4("vLightingIntensity", this._lightingInfos);
  53423. }
  53424. // Textures
  53425. if (scene.texturesEnabled) {
  53426. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].DiffuseTextureEnabled) {
  53427. this._uniformBuffer.setTexture("albedoSampler", this._albedoTexture);
  53428. }
  53429. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].AmbientTextureEnabled) {
  53430. this._uniformBuffer.setTexture("ambientSampler", this._ambientTexture);
  53431. }
  53432. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].OpacityTextureEnabled) {
  53433. this._uniformBuffer.setTexture("opacitySampler", this._opacityTexture);
  53434. }
  53435. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].ReflectionTextureEnabled) {
  53436. if (defines.LODBASEDMICROSFURACE) {
  53437. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  53438. }
  53439. else {
  53440. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  53441. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  53442. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  53443. }
  53444. }
  53445. if (defines.ENVIRONMENTBRDF) {
  53446. this._uniformBuffer.setTexture("environmentBrdfSampler", this._environmentBRDFTexture);
  53447. }
  53448. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].RefractionTextureEnabled) {
  53449. if (defines.LODBASEDMICROSFURACE) {
  53450. this._uniformBuffer.setTexture("refractionSampler", refractionTexture);
  53451. }
  53452. else {
  53453. this._uniformBuffer.setTexture("refractionSampler", refractionTexture._lodTextureMid || refractionTexture);
  53454. this._uniformBuffer.setTexture("refractionSamplerLow", refractionTexture._lodTextureLow || refractionTexture);
  53455. this._uniformBuffer.setTexture("refractionSamplerHigh", refractionTexture._lodTextureHigh || refractionTexture);
  53456. }
  53457. }
  53458. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].EmissiveTextureEnabled) {
  53459. this._uniformBuffer.setTexture("emissiveSampler", this._emissiveTexture);
  53460. }
  53461. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].LightmapTextureEnabled) {
  53462. this._uniformBuffer.setTexture("lightmapSampler", this._lightmapTexture);
  53463. }
  53464. if (_materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].SpecularTextureEnabled) {
  53465. if (this._metallicTexture) {
  53466. this._uniformBuffer.setTexture("reflectivitySampler", this._metallicTexture);
  53467. }
  53468. else if (this._reflectivityTexture) {
  53469. this._uniformBuffer.setTexture("reflectivitySampler", this._reflectivityTexture);
  53470. }
  53471. if (this._microSurfaceTexture) {
  53472. this._uniformBuffer.setTexture("microSurfaceSampler", this._microSurfaceTexture);
  53473. }
  53474. }
  53475. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_18__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  53476. this._uniformBuffer.setTexture("bumpSampler", this._bumpTexture);
  53477. }
  53478. }
  53479. this.clearCoat.bindForSubMesh(this._uniformBuffer, scene, engine, this._disableBumpMap, this.isFrozen, this._invertNormalMapX, this._invertNormalMapY);
  53480. this.anisotropy.bindForSubMesh(this._uniformBuffer, scene, this.isFrozen);
  53481. this.sheen.bindForSubMesh(this._uniformBuffer, scene, this.isFrozen);
  53482. // Clip plane
  53483. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  53484. // Colors
  53485. scene.ambientColor.multiplyToRef(this._ambientColor, this._globalAmbientColor);
  53486. var eyePosition = scene._forcedViewPosition ? scene._forcedViewPosition : (scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  53487. var invertNormal = (scene.useRightHandedSystem === (scene._mirroredCameraPosition != null));
  53488. effect.setFloat4("vEyePosition", eyePosition.x, eyePosition.y, eyePosition.z, invertNormal ? -1 : 1);
  53489. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  53490. effect.setFloat2("vDebugMode", this.debugLimit, this.debugFactor);
  53491. }
  53492. if (mustRebind || !this.isFrozen) {
  53493. // Lights
  53494. if (scene.lightsEnabled && !this._disableLighting) {
  53495. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, this._lightFalloff !== PBRBaseMaterial.LIGHTFALLOFF_STANDARD);
  53496. }
  53497. // View
  53498. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].FOGMODE_NONE || reflectionTexture) {
  53499. this.bindView(effect);
  53500. }
  53501. // Fog
  53502. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  53503. // Morph targets
  53504. if (defines.NUM_MORPH_INFLUENCERS) {
  53505. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindMorphTargetParameters(mesh, this._activeEffect);
  53506. }
  53507. // image processing
  53508. this._imageProcessingConfiguration.bind(this._activeEffect);
  53509. // Log. depth
  53510. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_16__["MaterialHelper"].BindLogDepth(defines, this._activeEffect, scene);
  53511. }
  53512. this._uniformBuffer.update();
  53513. this._afterBind(mesh, this._activeEffect);
  53514. };
  53515. /**
  53516. * Returns the animatable textures.
  53517. * @returns - Array of animatable textures.
  53518. */
  53519. PBRBaseMaterial.prototype.getAnimatables = function () {
  53520. var results = [];
  53521. if (this._albedoTexture && this._albedoTexture.animations && this._albedoTexture.animations.length > 0) {
  53522. results.push(this._albedoTexture);
  53523. }
  53524. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  53525. results.push(this._ambientTexture);
  53526. }
  53527. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  53528. results.push(this._opacityTexture);
  53529. }
  53530. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  53531. results.push(this._reflectionTexture);
  53532. }
  53533. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  53534. results.push(this._emissiveTexture);
  53535. }
  53536. if (this._metallicTexture && this._metallicTexture.animations && this._metallicTexture.animations.length > 0) {
  53537. results.push(this._metallicTexture);
  53538. }
  53539. else if (this._reflectivityTexture && this._reflectivityTexture.animations && this._reflectivityTexture.animations.length > 0) {
  53540. results.push(this._reflectivityTexture);
  53541. }
  53542. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  53543. results.push(this._bumpTexture);
  53544. }
  53545. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  53546. results.push(this._lightmapTexture);
  53547. }
  53548. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  53549. results.push(this._refractionTexture);
  53550. }
  53551. this.clearCoat.getAnimatables(results);
  53552. this.sheen.getAnimatables(results);
  53553. this.anisotropy.getAnimatables(results);
  53554. return results;
  53555. };
  53556. /**
  53557. * Returns the texture used for reflections.
  53558. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53559. */
  53560. PBRBaseMaterial.prototype._getReflectionTexture = function () {
  53561. if (this._reflectionTexture) {
  53562. return this._reflectionTexture;
  53563. }
  53564. return this.getScene().environmentTexture;
  53565. };
  53566. /**
  53567. * Returns the texture used for refraction or null if none is used.
  53568. * @returns - Refection texture if present. If no refraction texture and refraction
  53569. * is linked with transparency, returns environment texture. Otherwise, returns null.
  53570. */
  53571. PBRBaseMaterial.prototype._getRefractionTexture = function () {
  53572. if (this._refractionTexture) {
  53573. return this._refractionTexture;
  53574. }
  53575. if (this._linkRefractionWithTransparency) {
  53576. return this.getScene().environmentTexture;
  53577. }
  53578. return null;
  53579. };
  53580. /**
  53581. * Returns an array of the actively used textures.
  53582. * @returns - Array of BaseTextures
  53583. */
  53584. PBRBaseMaterial.prototype.getActiveTextures = function () {
  53585. var activeTextures = _super.prototype.getActiveTextures.call(this);
  53586. if (this._albedoTexture) {
  53587. activeTextures.push(this._albedoTexture);
  53588. }
  53589. if (this._ambientTexture) {
  53590. activeTextures.push(this._ambientTexture);
  53591. }
  53592. if (this._opacityTexture) {
  53593. activeTextures.push(this._opacityTexture);
  53594. }
  53595. if (this._reflectionTexture) {
  53596. activeTextures.push(this._reflectionTexture);
  53597. }
  53598. if (this._emissiveTexture) {
  53599. activeTextures.push(this._emissiveTexture);
  53600. }
  53601. if (this._reflectivityTexture) {
  53602. activeTextures.push(this._reflectivityTexture);
  53603. }
  53604. if (this._metallicTexture) {
  53605. activeTextures.push(this._metallicTexture);
  53606. }
  53607. if (this._microSurfaceTexture) {
  53608. activeTextures.push(this._microSurfaceTexture);
  53609. }
  53610. if (this._bumpTexture) {
  53611. activeTextures.push(this._bumpTexture);
  53612. }
  53613. if (this._lightmapTexture) {
  53614. activeTextures.push(this._lightmapTexture);
  53615. }
  53616. if (this._refractionTexture) {
  53617. activeTextures.push(this._refractionTexture);
  53618. }
  53619. this.clearCoat.getActiveTextures(activeTextures);
  53620. this.sheen.getActiveTextures(activeTextures);
  53621. this.anisotropy.getActiveTextures(activeTextures);
  53622. return activeTextures;
  53623. };
  53624. /**
  53625. * Checks to see if a texture is used in the material.
  53626. * @param texture - Base texture to use.
  53627. * @returns - Boolean specifying if a texture is used in the material.
  53628. */
  53629. PBRBaseMaterial.prototype.hasTexture = function (texture) {
  53630. if (_super.prototype.hasTexture.call(this, texture)) {
  53631. return true;
  53632. }
  53633. if (this._albedoTexture === texture) {
  53634. return true;
  53635. }
  53636. if (this._ambientTexture === texture) {
  53637. return true;
  53638. }
  53639. if (this._opacityTexture === texture) {
  53640. return true;
  53641. }
  53642. if (this._reflectionTexture === texture) {
  53643. return true;
  53644. }
  53645. if (this._reflectivityTexture === texture) {
  53646. return true;
  53647. }
  53648. if (this._metallicTexture === texture) {
  53649. return true;
  53650. }
  53651. if (this._microSurfaceTexture === texture) {
  53652. return true;
  53653. }
  53654. if (this._bumpTexture === texture) {
  53655. return true;
  53656. }
  53657. if (this._lightmapTexture === texture) {
  53658. return true;
  53659. }
  53660. return this.clearCoat.hasTexture(texture) ||
  53661. this.sheen.hasTexture(texture) ||
  53662. this.anisotropy.hasTexture(texture);
  53663. };
  53664. /**
  53665. * Disposes the resources of the material.
  53666. * @param forceDisposeEffect - Forces the disposal of effects.
  53667. * @param forceDisposeTextures - Forces the disposal of all textures.
  53668. */
  53669. PBRBaseMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  53670. if (forceDisposeTextures) {
  53671. if (this._albedoTexture) {
  53672. this._albedoTexture.dispose();
  53673. }
  53674. if (this._ambientTexture) {
  53675. this._ambientTexture.dispose();
  53676. }
  53677. if (this._opacityTexture) {
  53678. this._opacityTexture.dispose();
  53679. }
  53680. if (this._reflectionTexture) {
  53681. this._reflectionTexture.dispose();
  53682. }
  53683. if (this._environmentBRDFTexture && this.getScene().environmentBRDFTexture !== this._environmentBRDFTexture) {
  53684. this._environmentBRDFTexture.dispose();
  53685. }
  53686. if (this._emissiveTexture) {
  53687. this._emissiveTexture.dispose();
  53688. }
  53689. if (this._metallicTexture) {
  53690. this._metallicTexture.dispose();
  53691. }
  53692. if (this._reflectivityTexture) {
  53693. this._reflectivityTexture.dispose();
  53694. }
  53695. if (this._bumpTexture) {
  53696. this._bumpTexture.dispose();
  53697. }
  53698. if (this._lightmapTexture) {
  53699. this._lightmapTexture.dispose();
  53700. }
  53701. if (this._refractionTexture) {
  53702. this._refractionTexture.dispose();
  53703. }
  53704. }
  53705. this.clearCoat.dispose(forceDisposeTextures);
  53706. this.sheen.dispose(forceDisposeTextures);
  53707. this.anisotropy.dispose(forceDisposeTextures);
  53708. this._renderTargets.dispose();
  53709. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  53710. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  53711. }
  53712. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  53713. };
  53714. /**
  53715. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53716. */
  53717. PBRBaseMaterial.PBRMATERIAL_OPAQUE = 0;
  53718. /**
  53719. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53720. */
  53721. PBRBaseMaterial.PBRMATERIAL_ALPHATEST = 1;
  53722. /**
  53723. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53724. */
  53725. PBRBaseMaterial.PBRMATERIAL_ALPHABLEND = 2;
  53726. /**
  53727. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53728. * They are also discarded below the alpha cutoff threshold to improve performances.
  53729. */
  53730. PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND = 3;
  53731. /**
  53732. * Defines the default value of how much AO map is occluding the analytical lights
  53733. * (point spot...).
  53734. */
  53735. PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 0;
  53736. /**
  53737. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53738. */
  53739. PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL = 0;
  53740. /**
  53741. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53742. * to enhance interoperability with other engines.
  53743. */
  53744. PBRBaseMaterial.LIGHTFALLOFF_GLTF = 1;
  53745. /**
  53746. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53747. * to enhance interoperability with other materials.
  53748. */
  53749. PBRBaseMaterial.LIGHTFALLOFF_STANDARD = 2;
  53750. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53751. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  53752. ], PBRBaseMaterial.prototype, "_imageProcessingConfiguration", void 0);
  53753. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53754. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  53755. ], PBRBaseMaterial.prototype, "debugMode", void 0);
  53756. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53757. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53758. ], PBRBaseMaterial.prototype, "useLogarithmicDepth", null);
  53759. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53760. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53761. ], PBRBaseMaterial.prototype, "transparencyMode", null);
  53762. return PBRBaseMaterial;
  53763. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_15__["PushMaterial"]));
  53764. /***/ }),
  53765. /***/ "./Materials/PBR/pbrBaseSimpleMaterial.ts":
  53766. /*!************************************************!*\
  53767. !*** ./Materials/PBR/pbrBaseSimpleMaterial.ts ***!
  53768. \************************************************/
  53769. /*! exports provided: PBRBaseSimpleMaterial */
  53770. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53771. "use strict";
  53772. __webpack_require__.r(__webpack_exports__);
  53773. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return PBRBaseSimpleMaterial; });
  53774. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53775. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53776. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  53777. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  53778. /**
  53779. * The Physically based simple base material of BJS.
  53780. *
  53781. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53782. * It is used as the base class for both the specGloss and metalRough conventions.
  53783. */
  53784. var PBRBaseSimpleMaterial = /** @class */ (function (_super) {
  53785. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseSimpleMaterial, _super);
  53786. /**
  53787. * Instantiates a new PBRMaterial instance.
  53788. *
  53789. * @param name The material name
  53790. * @param scene The scene the material will be use in.
  53791. */
  53792. function PBRBaseSimpleMaterial(name, scene) {
  53793. var _this = _super.call(this, name, scene) || this;
  53794. /**
  53795. * Number of Simultaneous lights allowed on the material.
  53796. */
  53797. _this.maxSimultaneousLights = 4;
  53798. /**
  53799. * If sets to true, disables all the lights affecting the material.
  53800. */
  53801. _this.disableLighting = false;
  53802. /**
  53803. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53804. */
  53805. _this.invertNormalMapX = false;
  53806. /**
  53807. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53808. */
  53809. _this.invertNormalMapY = false;
  53810. /**
  53811. * Emissivie color used to self-illuminate the model.
  53812. */
  53813. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0, 0, 0);
  53814. /**
  53815. * Occlusion Channel Strenght.
  53816. */
  53817. _this.occlusionStrength = 1.0;
  53818. /**
  53819. * If true, the light map contains occlusion information instead of lighting info.
  53820. */
  53821. _this.useLightmapAsShadowmap = false;
  53822. _this._useAlphaFromAlbedoTexture = true;
  53823. _this._useAmbientInGrayScale = true;
  53824. return _this;
  53825. }
  53826. Object.defineProperty(PBRBaseSimpleMaterial.prototype, "doubleSided", {
  53827. /**
  53828. * Gets the current double sided mode.
  53829. */
  53830. get: function () {
  53831. return this._twoSidedLighting;
  53832. },
  53833. /**
  53834. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53835. */
  53836. set: function (value) {
  53837. if (this._twoSidedLighting === value) {
  53838. return;
  53839. }
  53840. this._twoSidedLighting = value;
  53841. this.backFaceCulling = !value;
  53842. this._markAllSubMeshesAsTexturesDirty();
  53843. },
  53844. enumerable: true,
  53845. configurable: true
  53846. });
  53847. PBRBaseSimpleMaterial.prototype.getClassName = function () {
  53848. return "PBRBaseSimpleMaterial";
  53849. };
  53850. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53851. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53852. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  53853. ], PBRBaseSimpleMaterial.prototype, "maxSimultaneousLights", void 0);
  53854. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53855. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53856. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  53857. ], PBRBaseSimpleMaterial.prototype, "disableLighting", void 0);
  53858. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53859. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53860. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectionTexture")
  53861. ], PBRBaseSimpleMaterial.prototype, "environmentTexture", void 0);
  53862. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53863. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53864. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53865. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapX", void 0);
  53866. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53867. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53868. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53869. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapY", void 0);
  53870. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53871. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53872. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_bumpTexture")
  53873. ], PBRBaseSimpleMaterial.prototype, "normalTexture", void 0);
  53874. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53875. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  53876. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53877. ], PBRBaseSimpleMaterial.prototype, "emissiveColor", void 0);
  53878. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53879. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53880. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53881. ], PBRBaseSimpleMaterial.prototype, "emissiveTexture", void 0);
  53882. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53883. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53884. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTextureStrength")
  53885. ], PBRBaseSimpleMaterial.prototype, "occlusionStrength", void 0);
  53886. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53887. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53888. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTexture")
  53889. ], PBRBaseSimpleMaterial.prototype, "occlusionTexture", void 0);
  53890. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53891. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53892. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_alphaCutOff")
  53893. ], PBRBaseSimpleMaterial.prototype, "alphaCutOff", void 0);
  53894. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53895. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53896. ], PBRBaseSimpleMaterial.prototype, "doubleSided", null);
  53897. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53898. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53899. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  53900. ], PBRBaseSimpleMaterial.prototype, "lightmapTexture", void 0);
  53901. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53902. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53903. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53904. ], PBRBaseSimpleMaterial.prototype, "useLightmapAsShadowmap", void 0);
  53905. return PBRBaseSimpleMaterial;
  53906. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRBaseMaterial"]));
  53907. /***/ }),
  53908. /***/ "./Materials/PBR/pbrClearCoatConfiguration.ts":
  53909. /*!****************************************************!*\
  53910. !*** ./Materials/PBR/pbrClearCoatConfiguration.ts ***!
  53911. \****************************************************/
  53912. /*! exports provided: PBRClearCoatConfiguration */
  53913. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53914. "use strict";
  53915. __webpack_require__.r(__webpack_exports__);
  53916. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRClearCoatConfiguration", function() { return PBRClearCoatConfiguration; });
  53917. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53918. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53919. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  53920. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  53921. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  53922. /**
  53923. * Define the code related to the clear coat parameters of the pbr material.
  53924. */
  53925. var PBRClearCoatConfiguration = /** @class */ (function () {
  53926. /**
  53927. * Instantiate a new istance of clear coat configuration.
  53928. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53929. */
  53930. function PBRClearCoatConfiguration(markAllSubMeshesAsTexturesDirty) {
  53931. this._isEnabled = false;
  53932. /**
  53933. * Defines if the clear coat is enabled in the material.
  53934. */
  53935. this.isEnabled = false;
  53936. /**
  53937. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53938. */
  53939. this.intensity = 1;
  53940. /**
  53941. * Defines the clear coat layer roughness.
  53942. */
  53943. this.roughness = 0;
  53944. this._indiceOfRefraction = PBRClearCoatConfiguration._DefaultIndiceOfRefraction;
  53945. /**
  53946. * Defines the indice of refraction of the clear coat.
  53947. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53948. * The default fits with a polyurethane material.
  53949. * Changing the default value is more performance intensive.
  53950. */
  53951. this.indiceOfRefraction = PBRClearCoatConfiguration._DefaultIndiceOfRefraction;
  53952. this._texture = null;
  53953. /**
  53954. * Stores the clear coat values in a texture.
  53955. */
  53956. this.texture = null;
  53957. this._bumpTexture = null;
  53958. /**
  53959. * Define the clear coat specific bump texture.
  53960. */
  53961. this.bumpTexture = null;
  53962. this._isTintEnabled = false;
  53963. /**
  53964. * Defines if the clear coat tint is enabled in the material.
  53965. */
  53966. this.isTintEnabled = false;
  53967. /**
  53968. * Defines if the clear coat tint is enabled in the material.
  53969. * This is only use if tint is enabled
  53970. */
  53971. this.tintColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  53972. /**
  53973. * Defines if the distance at which the tint color should be found in the
  53974. * clear coat media.
  53975. * This is only use if tint is enabled
  53976. */
  53977. this.tintColorAtDistance = 1;
  53978. /**
  53979. * Defines the clear coat layer thickness.
  53980. * This is only use if tint is enabled
  53981. */
  53982. this.tintThickness = 1;
  53983. this._tintTexture = null;
  53984. /**
  53985. * Stores the clear tint values in a texture.
  53986. * rgb is tint
  53987. * a is a thickness factor
  53988. */
  53989. this.tintTexture = null;
  53990. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  53991. }
  53992. /** @hidden */
  53993. PBRClearCoatConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  53994. this._internalMarkAllSubMeshesAsTexturesDirty();
  53995. };
  53996. /**
  53997. * Specifies that the submesh is ready to be used.
  53998. * @param defines the list of "defines" to update.
  53999. * @param scene defines the scene the material belongs to.
  54000. * @param engine defines the engine the material belongs to.
  54001. * @param disableBumpMap defines wether the material disables bump or not.
  54002. * @returns - boolean indicating that the submesh is ready or not.
  54003. */
  54004. PBRClearCoatConfiguration.prototype.isReadyForSubMesh = function (defines, scene, engine, disableBumpMap) {
  54005. if (defines._areTexturesDirty) {
  54006. if (scene.texturesEnabled) {
  54007. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  54008. if (!this._texture.isReadyOrNotBlocking()) {
  54009. return false;
  54010. }
  54011. }
  54012. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled && !disableBumpMap) {
  54013. // Bump texture cannot be not blocking.
  54014. if (!this._bumpTexture.isReady()) {
  54015. return false;
  54016. }
  54017. }
  54018. if (this._isTintEnabled && this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  54019. if (!this._tintTexture.isReadyOrNotBlocking()) {
  54020. return false;
  54021. }
  54022. }
  54023. }
  54024. }
  54025. return true;
  54026. };
  54027. /**
  54028. * Checks to see if a texture is used in the material.
  54029. * @param defines the list of "defines" to update.
  54030. * @param scene defines the scene to the material belongs to.
  54031. */
  54032. PBRClearCoatConfiguration.prototype.prepareDefines = function (defines, scene) {
  54033. if (this._isEnabled) {
  54034. defines.CLEARCOAT = true;
  54035. if (defines._areTexturesDirty) {
  54036. if (scene.texturesEnabled) {
  54037. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  54038. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "CLEARCOAT_TEXTURE");
  54039. }
  54040. else {
  54041. defines.CLEARCOAT_TEXTURE = false;
  54042. }
  54043. if (this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled) {
  54044. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "CLEARCOAT_BUMP");
  54045. }
  54046. else {
  54047. defines.CLEARCOAT_BUMP = false;
  54048. }
  54049. defines.CLEARCOAT_DEFAULTIOR = this._indiceOfRefraction === PBRClearCoatConfiguration._DefaultIndiceOfRefraction;
  54050. if (this._isTintEnabled) {
  54051. defines.CLEARCOAT_TINT = true;
  54052. if (this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  54053. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._tintTexture, defines, "CLEARCOAT_TINT_TEXTURE");
  54054. }
  54055. else {
  54056. defines.CLEARCOAT_TINT_TEXTURE = false;
  54057. }
  54058. }
  54059. else {
  54060. defines.CLEARCOAT_TINT = false;
  54061. defines.CLEARCOAT_TINT_TEXTURE = false;
  54062. }
  54063. }
  54064. }
  54065. }
  54066. else {
  54067. defines.CLEARCOAT = false;
  54068. defines.CLEARCOAT_TEXTURE = false;
  54069. defines.CLEARCOAT_BUMP = false;
  54070. defines.CLEARCOAT_TINT = false;
  54071. defines.CLEARCOAT_TINT_TEXTURE = false;
  54072. }
  54073. };
  54074. /**
  54075. * Binds the material data.
  54076. * @param uniformBuffer defines the Uniform buffer to fill in.
  54077. * @param scene defines the scene the material belongs to.
  54078. * @param engine defines the engine the material belongs to.
  54079. * @param disableBumpMap defines wether the material disables bump or not.
  54080. * @param isFrozen defines wether the material is frozen or not.
  54081. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54082. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54083. */
  54084. PBRClearCoatConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, engine, disableBumpMap, isFrozen, invertNormalMapX, invertNormalMapY) {
  54085. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  54086. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  54087. uniformBuffer.updateFloat2("vClearCoatInfos", this._texture.coordinatesIndex, this._texture.level);
  54088. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "clearCoat");
  54089. }
  54090. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled && !disableBumpMap) {
  54091. uniformBuffer.updateFloat2("vClearCoatBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level);
  54092. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, uniformBuffer, "clearCoatBump");
  54093. if (scene._mirroredCameraPosition) {
  54094. uniformBuffer.updateFloat2("vClearCoatTangentSpaceParams", invertNormalMapX ? 1.0 : -1.0, invertNormalMapY ? 1.0 : -1.0);
  54095. }
  54096. else {
  54097. uniformBuffer.updateFloat2("vClearCoatTangentSpaceParams", invertNormalMapX ? -1.0 : 1.0, invertNormalMapY ? -1.0 : 1.0);
  54098. }
  54099. }
  54100. if (this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  54101. uniformBuffer.updateFloat2("vClearCoatTintInfos", this._tintTexture.coordinatesIndex, this._tintTexture.level);
  54102. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._tintTexture, uniformBuffer, "clearCoatTint");
  54103. }
  54104. // Clear Coat General params
  54105. uniformBuffer.updateFloat2("vClearCoatParams", this.intensity, this.roughness);
  54106. // Clear Coat Refraction params
  54107. var a = 1 - this._indiceOfRefraction;
  54108. var b = 1 + this._indiceOfRefraction;
  54109. var f0 = Math.pow((-a / b), 2); // Schlicks approx: (ior1 - ior2) / (ior1 + ior2) where ior2 for air is close to vacuum = 1.
  54110. var eta = 1 / this._indiceOfRefraction;
  54111. uniformBuffer.updateFloat4("vClearCoatRefractionParams", f0, eta, a, b);
  54112. if (this._isTintEnabled) {
  54113. uniformBuffer.updateFloat4("vClearCoatTintParams", this.tintColor.r, this.tintColor.g, this.tintColor.b, Math.max(0.00001, this.tintThickness));
  54114. uniformBuffer.updateFloat("clearCoatColorAtDistance", Math.max(0.00001, this.tintColorAtDistance));
  54115. }
  54116. }
  54117. // Textures
  54118. if (scene.texturesEnabled) {
  54119. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  54120. uniformBuffer.setTexture("clearCoatSampler", this._texture);
  54121. }
  54122. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled && !disableBumpMap) {
  54123. uniformBuffer.setTexture("clearCoatBumpSampler", this._bumpTexture);
  54124. }
  54125. if (this._isTintEnabled && this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  54126. uniformBuffer.setTexture("clearCoatTintSampler", this._tintTexture);
  54127. }
  54128. }
  54129. };
  54130. /**
  54131. * Checks to see if a texture is used in the material.
  54132. * @param texture - Base texture to use.
  54133. * @returns - Boolean specifying if a texture is used in the material.
  54134. */
  54135. PBRClearCoatConfiguration.prototype.hasTexture = function (texture) {
  54136. if (this._texture === texture) {
  54137. return true;
  54138. }
  54139. if (this._bumpTexture === texture) {
  54140. return true;
  54141. }
  54142. if (this._tintTexture === texture) {
  54143. return true;
  54144. }
  54145. return false;
  54146. };
  54147. /**
  54148. * Returns an array of the actively used textures.
  54149. * @param activeTextures Array of BaseTextures
  54150. */
  54151. PBRClearCoatConfiguration.prototype.getActiveTextures = function (activeTextures) {
  54152. if (this._texture) {
  54153. activeTextures.push(this._texture);
  54154. }
  54155. if (this._bumpTexture) {
  54156. activeTextures.push(this._bumpTexture);
  54157. }
  54158. if (this._tintTexture) {
  54159. activeTextures.push(this._tintTexture);
  54160. }
  54161. };
  54162. /**
  54163. * Returns the animatable textures.
  54164. * @param animatables Array of animatable textures.
  54165. */
  54166. PBRClearCoatConfiguration.prototype.getAnimatables = function (animatables) {
  54167. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  54168. animatables.push(this._texture);
  54169. }
  54170. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  54171. animatables.push(this._bumpTexture);
  54172. }
  54173. if (this._tintTexture && this._tintTexture.animations && this._tintTexture.animations.length > 0) {
  54174. animatables.push(this._tintTexture);
  54175. }
  54176. };
  54177. /**
  54178. * Disposes the resources of the material.
  54179. * @param forceDisposeTextures - Forces the disposal of all textures.
  54180. */
  54181. PBRClearCoatConfiguration.prototype.dispose = function (forceDisposeTextures) {
  54182. if (forceDisposeTextures) {
  54183. if (this._texture) {
  54184. this._texture.dispose();
  54185. }
  54186. if (this._bumpTexture) {
  54187. this._bumpTexture.dispose();
  54188. }
  54189. if (this._tintTexture) {
  54190. this._tintTexture.dispose();
  54191. }
  54192. }
  54193. };
  54194. /**
  54195. * Get the current class name of the texture useful for serialization or dynamic coding.
  54196. * @returns "PBRClearCoatConfiguration"
  54197. */
  54198. PBRClearCoatConfiguration.prototype.getClassName = function () {
  54199. return "PBRClearCoatConfiguration";
  54200. };
  54201. /**
  54202. * Add fallbacks to the effect fallbacks list.
  54203. * @param defines defines the Base texture to use.
  54204. * @param fallbacks defines the current fallback list.
  54205. * @param currentRank defines the current fallback rank.
  54206. * @returns the new fallback rank.
  54207. */
  54208. PBRClearCoatConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  54209. if (defines.CLEARCOAT_BUMP) {
  54210. fallbacks.addFallback(currentRank++, "CLEARCOAT_BUMP");
  54211. }
  54212. if (defines.CLEARCOAT_TINT) {
  54213. fallbacks.addFallback(currentRank++, "CLEARCOAT_TINT");
  54214. }
  54215. if (defines.CLEARCOAT) {
  54216. fallbacks.addFallback(currentRank++, "CLEARCOAT");
  54217. }
  54218. return currentRank;
  54219. };
  54220. /**
  54221. * Add the required uniforms to the current list.
  54222. * @param uniforms defines the current uniform list.
  54223. */
  54224. PBRClearCoatConfiguration.AddUniforms = function (uniforms) {
  54225. uniforms.push("vClearCoatTangentSpaceParams", "vClearCoatParams", "vClearCoatRefractionParams", "vClearCoatTintParams", "clearCoatColorAtDistance", "clearCoatMatrix", "clearCoatBumpMatrix", "clearCoatTintMatrix", "vClearCoatInfos", "vClearCoatBumpInfos", "vClearCoatTintInfos");
  54226. };
  54227. /**
  54228. * Add the required samplers to the current list.
  54229. * @param samplers defines the current sampler list.
  54230. */
  54231. PBRClearCoatConfiguration.AddSamplers = function (samplers) {
  54232. samplers.push("clearCoatSampler", "clearCoatBumpSampler", "clearCoatTintSampler");
  54233. };
  54234. /**
  54235. * Add the required uniforms to the current buffer.
  54236. * @param uniformBuffer defines the current uniform buffer.
  54237. */
  54238. PBRClearCoatConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  54239. uniformBuffer.addUniform("vClearCoatParams", 2);
  54240. uniformBuffer.addUniform("vClearCoatRefractionParams", 4);
  54241. uniformBuffer.addUniform("vClearCoatInfos", 2);
  54242. uniformBuffer.addUniform("clearCoatMatrix", 16);
  54243. uniformBuffer.addUniform("vClearCoatBumpInfos", 2);
  54244. uniformBuffer.addUniform("vClearCoatTangentSpaceParams", 2);
  54245. uniformBuffer.addUniform("clearCoatBumpMatrix", 16);
  54246. uniformBuffer.addUniform("vClearCoatTintParams", 4);
  54247. uniformBuffer.addUniform("clearCoatColorAtDistance", 1);
  54248. uniformBuffer.addUniform("vClearCoatTintInfos", 2);
  54249. uniformBuffer.addUniform("clearCoatTintMatrix", 16);
  54250. };
  54251. /**
  54252. * Makes a duplicate of the current configuration into another one.
  54253. * @param clearCoatConfiguration define the config where to copy the info
  54254. */
  54255. PBRClearCoatConfiguration.prototype.copyTo = function (clearCoatConfiguration) {
  54256. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return clearCoatConfiguration; }, this);
  54257. };
  54258. /**
  54259. * Serializes this clear coat configuration.
  54260. * @returns - An object with the serialized config.
  54261. */
  54262. PBRClearCoatConfiguration.prototype.serialize = function () {
  54263. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  54264. };
  54265. /**
  54266. * Parses a Clear Coat Configuration from a serialized object.
  54267. * @param source - Serialized object.
  54268. */
  54269. PBRClearCoatConfiguration.prototype.parse = function (source) {
  54270. var _this = this;
  54271. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  54272. };
  54273. /**
  54274. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54275. * The default fits with a polyurethane material.
  54276. */
  54277. PBRClearCoatConfiguration._DefaultIndiceOfRefraction = 1.5;
  54278. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54279. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54280. ], PBRClearCoatConfiguration.prototype, "_isEnabled", void 0);
  54281. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54282. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54283. ], PBRClearCoatConfiguration.prototype, "isEnabled", void 0);
  54284. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54285. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54286. ], PBRClearCoatConfiguration.prototype, "intensity", void 0);
  54287. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54288. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54289. ], PBRClearCoatConfiguration.prototype, "roughness", void 0);
  54290. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54291. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54292. ], PBRClearCoatConfiguration.prototype, "_indiceOfRefraction", void 0);
  54293. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54294. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54295. ], PBRClearCoatConfiguration.prototype, "indiceOfRefraction", void 0);
  54296. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54297. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  54298. ], PBRClearCoatConfiguration.prototype, "_texture", void 0);
  54299. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54300. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54301. ], PBRClearCoatConfiguration.prototype, "texture", void 0);
  54302. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54303. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  54304. ], PBRClearCoatConfiguration.prototype, "_bumpTexture", void 0);
  54305. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54306. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54307. ], PBRClearCoatConfiguration.prototype, "bumpTexture", void 0);
  54308. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54309. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54310. ], PBRClearCoatConfiguration.prototype, "_isTintEnabled", void 0);
  54311. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54312. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54313. ], PBRClearCoatConfiguration.prototype, "isTintEnabled", void 0);
  54314. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54315. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  54316. ], PBRClearCoatConfiguration.prototype, "tintColor", void 0);
  54317. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54318. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54319. ], PBRClearCoatConfiguration.prototype, "tintColorAtDistance", void 0);
  54320. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54321. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54322. ], PBRClearCoatConfiguration.prototype, "tintThickness", void 0);
  54323. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54324. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  54325. ], PBRClearCoatConfiguration.prototype, "_tintTexture", void 0);
  54326. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54327. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54328. ], PBRClearCoatConfiguration.prototype, "tintTexture", void 0);
  54329. return PBRClearCoatConfiguration;
  54330. }());
  54331. /***/ }),
  54332. /***/ "./Materials/PBR/pbrMaterial.ts":
  54333. /*!**************************************!*\
  54334. !*** ./Materials/PBR/pbrMaterial.ts ***!
  54335. \**************************************/
  54336. /*! exports provided: PBRMaterial */
  54337. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54338. "use strict";
  54339. __webpack_require__.r(__webpack_exports__);
  54340. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return PBRMaterial; });
  54341. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54342. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  54343. /* harmony import */ var _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/brdfTextureTools */ "./Misc/brdfTextureTools.ts");
  54344. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  54345. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  54346. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  54347. /**
  54348. * The Physically based material of BJS.
  54349. *
  54350. * This offers the main features of a standard PBR material.
  54351. * For more information, please refer to the documentation :
  54352. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  54353. */
  54354. var PBRMaterial = /** @class */ (function (_super) {
  54355. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterial, _super);
  54356. /**
  54357. * Instantiates a new PBRMaterial instance.
  54358. *
  54359. * @param name The material name
  54360. * @param scene The scene the material will be use in.
  54361. */
  54362. function PBRMaterial(name, scene) {
  54363. var _this = _super.call(this, name, scene) || this;
  54364. /**
  54365. * Intensity of the direct lights e.g. the four lights available in your scene.
  54366. * This impacts both the direct diffuse and specular highlights.
  54367. */
  54368. _this.directIntensity = 1.0;
  54369. /**
  54370. * Intensity of the emissive part of the material.
  54371. * This helps controlling the emissive effect without modifying the emissive color.
  54372. */
  54373. _this.emissiveIntensity = 1.0;
  54374. /**
  54375. * Intensity of the environment e.g. how much the environment will light the object
  54376. * either through harmonics for rough material or through the refelction for shiny ones.
  54377. */
  54378. _this.environmentIntensity = 1.0;
  54379. /**
  54380. * This is a special control allowing the reduction of the specular highlights coming from the
  54381. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54382. */
  54383. _this.specularIntensity = 1.0;
  54384. /**
  54385. * Debug Control allowing disabling the bump map on this material.
  54386. */
  54387. _this.disableBumpMap = false;
  54388. /**
  54389. * AKA Occlusion Texture Intensity in other nomenclature.
  54390. */
  54391. _this.ambientTextureStrength = 1.0;
  54392. /**
  54393. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54394. * 1 means it completely occludes it
  54395. * 0 mean it has no impact
  54396. */
  54397. _this.ambientTextureImpactOnAnalyticalLights = PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  54398. /**
  54399. * The color of a material in ambient lighting.
  54400. */
  54401. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  54402. /**
  54403. * AKA Diffuse Color in other nomenclature.
  54404. */
  54405. _this.albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  54406. /**
  54407. * AKA Specular Color in other nomenclature.
  54408. */
  54409. _this.reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  54410. /**
  54411. * The color reflected from the material.
  54412. */
  54413. _this.reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1.0, 1.0, 1.0);
  54414. /**
  54415. * The color emitted from the material.
  54416. */
  54417. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  54418. /**
  54419. * AKA Glossiness in other nomenclature.
  54420. */
  54421. _this.microSurface = 1.0;
  54422. /**
  54423. * source material index of refraction (IOR)' / 'destination material IOR.
  54424. */
  54425. _this.indexOfRefraction = 0.66;
  54426. /**
  54427. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54428. */
  54429. _this.invertRefractionY = false;
  54430. /**
  54431. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54432. * Materials half opaque for instance using refraction could benefit from this control.
  54433. */
  54434. _this.linkRefractionWithTransparency = false;
  54435. /**
  54436. * If true, the light map contains occlusion information instead of lighting info.
  54437. */
  54438. _this.useLightmapAsShadowmap = false;
  54439. /**
  54440. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54441. */
  54442. _this.useAlphaFromAlbedoTexture = false;
  54443. /**
  54444. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54445. */
  54446. _this.forceAlphaTest = false;
  54447. /**
  54448. * Defines the alpha limits in alpha test mode.
  54449. */
  54450. _this.alphaCutOff = 0.4;
  54451. /**
  54452. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  54453. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54454. */
  54455. _this.useSpecularOverAlpha = true;
  54456. /**
  54457. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54458. */
  54459. _this.useMicroSurfaceFromReflectivityMapAlpha = false;
  54460. /**
  54461. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54462. */
  54463. _this.useRoughnessFromMetallicTextureAlpha = true;
  54464. /**
  54465. * Specifies if the metallic texture contains the roughness information in its green channel.
  54466. */
  54467. _this.useRoughnessFromMetallicTextureGreen = false;
  54468. /**
  54469. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54470. */
  54471. _this.useMetallnessFromMetallicTextureBlue = false;
  54472. /**
  54473. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54474. */
  54475. _this.useAmbientOcclusionFromMetallicTextureRed = false;
  54476. /**
  54477. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54478. */
  54479. _this.useAmbientInGrayScale = false;
  54480. /**
  54481. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54482. * The material will try to infer what glossiness each pixel should be.
  54483. */
  54484. _this.useAutoMicroSurfaceFromReflectivityMap = false;
  54485. /**
  54486. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54487. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54488. */
  54489. _this.useRadianceOverAlpha = true;
  54490. /**
  54491. * Allows using an object space normal map (instead of tangent space).
  54492. */
  54493. _this.useObjectSpaceNormalMap = false;
  54494. /**
  54495. * Allows using the bump map in parallax mode.
  54496. */
  54497. _this.useParallax = false;
  54498. /**
  54499. * Allows using the bump map in parallax occlusion mode.
  54500. */
  54501. _this.useParallaxOcclusion = false;
  54502. /**
  54503. * Controls the scale bias of the parallax mode.
  54504. */
  54505. _this.parallaxScaleBias = 0.05;
  54506. /**
  54507. * If sets to true, disables all the lights affecting the material.
  54508. */
  54509. _this.disableLighting = false;
  54510. /**
  54511. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54512. */
  54513. _this.forceIrradianceInFragment = false;
  54514. /**
  54515. * Number of Simultaneous lights allowed on the material.
  54516. */
  54517. _this.maxSimultaneousLights = 4;
  54518. /**
  54519. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54520. */
  54521. _this.invertNormalMapX = false;
  54522. /**
  54523. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54524. */
  54525. _this.invertNormalMapY = false;
  54526. /**
  54527. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54528. */
  54529. _this.twoSidedLighting = false;
  54530. /**
  54531. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54532. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54533. */
  54534. _this.useAlphaFresnel = false;
  54535. /**
  54536. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54537. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54538. */
  54539. _this.useLinearAlphaFresnel = false;
  54540. /**
  54541. * Let user defines the brdf lookup texture used for IBL.
  54542. * A default 8bit version is embedded but you could point at :
  54543. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  54544. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54545. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54546. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54547. */
  54548. _this.environmentBRDFTexture = null;
  54549. /**
  54550. * Force normal to face away from face.
  54551. */
  54552. _this.forceNormalForward = false;
  54553. /**
  54554. * Enables specular anti aliasing in the PBR shader.
  54555. * It will both interacts on the Geometry for analytical and IBL lighting.
  54556. * It also prefilter the roughness map based on the bump values.
  54557. */
  54558. _this.enableSpecularAntiAliasing = false;
  54559. /**
  54560. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54561. * makes the reflect vector face the model (under horizon).
  54562. */
  54563. _this.useHorizonOcclusion = true;
  54564. /**
  54565. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54566. * too much the area relying on ambient texture to define their ambient occlusion.
  54567. */
  54568. _this.useRadianceOcclusion = true;
  54569. /**
  54570. * If set to true, no lighting calculations will be applied.
  54571. */
  54572. _this.unlit = false;
  54573. _this._environmentBRDFTexture = _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_2__["BRDFTextureTools"].GetEnvironmentBRDFTexture(scene);
  54574. return _this;
  54575. }
  54576. Object.defineProperty(PBRMaterial.prototype, "usePhysicalLightFalloff", {
  54577. /**
  54578. * BJS is using an harcoded light falloff based on a manually sets up range.
  54579. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54580. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54581. */
  54582. get: function () {
  54583. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  54584. },
  54585. /**
  54586. * BJS is using an harcoded light falloff based on a manually sets up range.
  54587. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54588. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54589. */
  54590. set: function (value) {
  54591. if (value !== this.usePhysicalLightFalloff) {
  54592. // Ensure the effect will be rebuilt.
  54593. this._markAllSubMeshesAsTexturesDirty();
  54594. if (value) {
  54595. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  54596. }
  54597. else {
  54598. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  54599. }
  54600. }
  54601. },
  54602. enumerable: true,
  54603. configurable: true
  54604. });
  54605. Object.defineProperty(PBRMaterial.prototype, "useGLTFLightFalloff", {
  54606. /**
  54607. * In order to support the falloff compatibility with gltf, a special mode has been added
  54608. * to reproduce the gltf light falloff.
  54609. */
  54610. get: function () {
  54611. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  54612. },
  54613. /**
  54614. * In order to support the falloff compatibility with gltf, a special mode has been added
  54615. * to reproduce the gltf light falloff.
  54616. */
  54617. set: function (value) {
  54618. if (value !== this.useGLTFLightFalloff) {
  54619. // Ensure the effect will be rebuilt.
  54620. this._markAllSubMeshesAsTexturesDirty();
  54621. if (value) {
  54622. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  54623. }
  54624. else {
  54625. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  54626. }
  54627. }
  54628. },
  54629. enumerable: true,
  54630. configurable: true
  54631. });
  54632. Object.defineProperty(PBRMaterial.prototype, "imageProcessingConfiguration", {
  54633. /**
  54634. * Gets the image processing configuration used either in this material.
  54635. */
  54636. get: function () {
  54637. return this._imageProcessingConfiguration;
  54638. },
  54639. /**
  54640. * Sets the Default image processing configuration used either in the this material.
  54641. *
  54642. * If sets to null, the scene one is in use.
  54643. */
  54644. set: function (value) {
  54645. this._attachImageProcessingConfiguration(value);
  54646. // Ensure the effect will be rebuilt.
  54647. this._markAllSubMeshesAsTexturesDirty();
  54648. },
  54649. enumerable: true,
  54650. configurable: true
  54651. });
  54652. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurvesEnabled", {
  54653. /**
  54654. * Gets wether the color curves effect is enabled.
  54655. */
  54656. get: function () {
  54657. return this.imageProcessingConfiguration.colorCurvesEnabled;
  54658. },
  54659. /**
  54660. * Sets wether the color curves effect is enabled.
  54661. */
  54662. set: function (value) {
  54663. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  54664. },
  54665. enumerable: true,
  54666. configurable: true
  54667. });
  54668. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingEnabled", {
  54669. /**
  54670. * Gets wether the color grading effect is enabled.
  54671. */
  54672. get: function () {
  54673. return this.imageProcessingConfiguration.colorGradingEnabled;
  54674. },
  54675. /**
  54676. * Gets wether the color grading effect is enabled.
  54677. */
  54678. set: function (value) {
  54679. this.imageProcessingConfiguration.colorGradingEnabled = value;
  54680. },
  54681. enumerable: true,
  54682. configurable: true
  54683. });
  54684. Object.defineProperty(PBRMaterial.prototype, "cameraToneMappingEnabled", {
  54685. /**
  54686. * Gets wether tonemapping is enabled or not.
  54687. */
  54688. get: function () {
  54689. return this._imageProcessingConfiguration.toneMappingEnabled;
  54690. },
  54691. /**
  54692. * Sets wether tonemapping is enabled or not
  54693. */
  54694. set: function (value) {
  54695. this._imageProcessingConfiguration.toneMappingEnabled = value;
  54696. },
  54697. enumerable: true,
  54698. configurable: true
  54699. });
  54700. Object.defineProperty(PBRMaterial.prototype, "cameraExposure", {
  54701. /**
  54702. * The camera exposure used on this material.
  54703. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54704. * This corresponds to a photographic exposure.
  54705. */
  54706. get: function () {
  54707. return this._imageProcessingConfiguration.exposure;
  54708. },
  54709. /**
  54710. * The camera exposure used on this material.
  54711. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54712. * This corresponds to a photographic exposure.
  54713. */
  54714. set: function (value) {
  54715. this._imageProcessingConfiguration.exposure = value;
  54716. },
  54717. enumerable: true,
  54718. configurable: true
  54719. });
  54720. Object.defineProperty(PBRMaterial.prototype, "cameraContrast", {
  54721. /**
  54722. * Gets The camera contrast used on this material.
  54723. */
  54724. get: function () {
  54725. return this._imageProcessingConfiguration.contrast;
  54726. },
  54727. /**
  54728. * Sets The camera contrast used on this material.
  54729. */
  54730. set: function (value) {
  54731. this._imageProcessingConfiguration.contrast = value;
  54732. },
  54733. enumerable: true,
  54734. configurable: true
  54735. });
  54736. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingTexture", {
  54737. /**
  54738. * Gets the Color Grading 2D Lookup Texture.
  54739. */
  54740. get: function () {
  54741. return this._imageProcessingConfiguration.colorGradingTexture;
  54742. },
  54743. /**
  54744. * Sets the Color Grading 2D Lookup Texture.
  54745. */
  54746. set: function (value) {
  54747. this._imageProcessingConfiguration.colorGradingTexture = value;
  54748. },
  54749. enumerable: true,
  54750. configurable: true
  54751. });
  54752. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurves", {
  54753. /**
  54754. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54755. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54756. * 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;
  54757. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54758. */
  54759. get: function () {
  54760. return this._imageProcessingConfiguration.colorCurves;
  54761. },
  54762. /**
  54763. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54764. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54765. * 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;
  54766. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54767. */
  54768. set: function (value) {
  54769. this._imageProcessingConfiguration.colorCurves = value;
  54770. },
  54771. enumerable: true,
  54772. configurable: true
  54773. });
  54774. /**
  54775. * Returns the name of this material class.
  54776. */
  54777. PBRMaterial.prototype.getClassName = function () {
  54778. return "PBRMaterial";
  54779. };
  54780. /**
  54781. * Makes a duplicate of the current material.
  54782. * @param name - name to use for the new material.
  54783. */
  54784. PBRMaterial.prototype.clone = function (name) {
  54785. var _this = this;
  54786. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMaterial(name, _this.getScene()); }, this);
  54787. clone.id = name;
  54788. clone.name = name;
  54789. this.clearCoat.copyTo(clone.clearCoat);
  54790. this.anisotropy.copyTo(clone.anisotropy);
  54791. this.brdf.copyTo(clone.brdf);
  54792. this.sheen.copyTo(clone.sheen);
  54793. return clone;
  54794. };
  54795. /**
  54796. * Serializes this PBR Material.
  54797. * @returns - An object with the serialized material.
  54798. */
  54799. PBRMaterial.prototype.serialize = function () {
  54800. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  54801. serializationObject.customType = "BABYLON.PBRMaterial";
  54802. serializationObject.clearCoat = this.clearCoat.serialize();
  54803. serializationObject.anisotropy = this.anisotropy.serialize();
  54804. serializationObject.brdf = this.brdf.serialize();
  54805. serializationObject.sheen = this.sheen.serialize();
  54806. return serializationObject;
  54807. };
  54808. // Statics
  54809. /**
  54810. * Parses a PBR Material from a serialized object.
  54811. * @param source - Serialized object.
  54812. * @param scene - BJS scene instance.
  54813. * @param rootUrl - url for the scene object
  54814. * @returns - PBRMaterial
  54815. */
  54816. PBRMaterial.Parse = function (source, scene, rootUrl) {
  54817. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMaterial(source.name, scene); }, source, scene, rootUrl);
  54818. if (source.clearCoat) {
  54819. material.clearCoat.parse(source.clearCoat);
  54820. }
  54821. if (source.anisotropy) {
  54822. material.anisotropy.parse(source.anisotropy);
  54823. }
  54824. if (source.brdf) {
  54825. material.brdf.parse(source.brdf);
  54826. }
  54827. if (source.sheen) {
  54828. material.sheen.parse(source.brdf);
  54829. }
  54830. return material;
  54831. };
  54832. /**
  54833. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54834. */
  54835. PBRMaterial.PBRMATERIAL_OPAQUE = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_OPAQUE;
  54836. /**
  54837. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54838. */
  54839. PBRMaterial.PBRMATERIAL_ALPHATEST = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATEST;
  54840. /**
  54841. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54842. */
  54843. PBRMaterial.PBRMATERIAL_ALPHABLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHABLEND;
  54844. /**
  54845. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54846. * They are also discarded below the alpha cutoff threshold to improve performances.
  54847. */
  54848. PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATESTANDBLEND;
  54849. /**
  54850. * Defines the default value of how much AO map is occluding the analytical lights
  54851. * (point spot...).
  54852. */
  54853. PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  54854. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54855. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54856. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54857. ], PBRMaterial.prototype, "directIntensity", void 0);
  54858. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54859. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54860. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54861. ], PBRMaterial.prototype, "emissiveIntensity", void 0);
  54862. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54863. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54864. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54865. ], PBRMaterial.prototype, "environmentIntensity", void 0);
  54866. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54867. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54868. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54869. ], PBRMaterial.prototype, "specularIntensity", void 0);
  54870. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54871. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54872. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54873. ], PBRMaterial.prototype, "disableBumpMap", void 0);
  54874. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54875. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54876. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54877. ], PBRMaterial.prototype, "albedoTexture", void 0);
  54878. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54879. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54880. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54881. ], PBRMaterial.prototype, "ambientTexture", void 0);
  54882. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54883. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54884. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54885. ], PBRMaterial.prototype, "ambientTextureStrength", void 0);
  54886. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54887. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54888. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54889. ], PBRMaterial.prototype, "ambientTextureImpactOnAnalyticalLights", void 0);
  54890. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54891. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54892. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54893. ], PBRMaterial.prototype, "opacityTexture", void 0);
  54894. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54895. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54896. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54897. ], PBRMaterial.prototype, "reflectionTexture", void 0);
  54898. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54899. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54900. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54901. ], PBRMaterial.prototype, "emissiveTexture", void 0);
  54902. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54903. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54904. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54905. ], PBRMaterial.prototype, "reflectivityTexture", void 0);
  54906. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54907. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54908. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54909. ], PBRMaterial.prototype, "metallicTexture", void 0);
  54910. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54911. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54912. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54913. ], PBRMaterial.prototype, "metallic", void 0);
  54914. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54915. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54916. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54917. ], PBRMaterial.prototype, "roughness", void 0);
  54918. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54919. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54920. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54921. ], PBRMaterial.prototype, "microSurfaceTexture", void 0);
  54922. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54923. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54924. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54925. ], PBRMaterial.prototype, "bumpTexture", void 0);
  54926. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54927. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54928. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  54929. ], PBRMaterial.prototype, "lightmapTexture", void 0);
  54930. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54931. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54932. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54933. ], PBRMaterial.prototype, "refractionTexture", void 0);
  54934. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54935. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient"),
  54936. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54937. ], PBRMaterial.prototype, "ambientColor", void 0);
  54938. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54939. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("albedo"),
  54940. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54941. ], PBRMaterial.prototype, "albedoColor", void 0);
  54942. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54943. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflectivity"),
  54944. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54945. ], PBRMaterial.prototype, "reflectivityColor", void 0);
  54946. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54947. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflection"),
  54948. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54949. ], PBRMaterial.prototype, "reflectionColor", void 0);
  54950. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54951. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  54952. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54953. ], PBRMaterial.prototype, "emissiveColor", void 0);
  54954. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54955. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54956. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54957. ], PBRMaterial.prototype, "microSurface", void 0);
  54958. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54959. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54960. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54961. ], PBRMaterial.prototype, "indexOfRefraction", void 0);
  54962. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54963. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54964. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54965. ], PBRMaterial.prototype, "invertRefractionY", void 0);
  54966. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54967. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54968. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54969. ], PBRMaterial.prototype, "linkRefractionWithTransparency", void 0);
  54970. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54971. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54972. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54973. ], PBRMaterial.prototype, "useLightmapAsShadowmap", void 0);
  54974. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54975. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54976. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54977. ], PBRMaterial.prototype, "useAlphaFromAlbedoTexture", void 0);
  54978. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54979. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54980. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54981. ], PBRMaterial.prototype, "forceAlphaTest", void 0);
  54982. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54983. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54984. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54985. ], PBRMaterial.prototype, "alphaCutOff", void 0);
  54986. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54987. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54988. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54989. ], PBRMaterial.prototype, "useSpecularOverAlpha", void 0);
  54990. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54991. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54992. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54993. ], PBRMaterial.prototype, "useMicroSurfaceFromReflectivityMapAlpha", void 0);
  54994. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54995. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54996. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54997. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureAlpha", void 0);
  54998. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54999. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55000. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55001. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureGreen", void 0);
  55002. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55003. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55004. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55005. ], PBRMaterial.prototype, "useMetallnessFromMetallicTextureBlue", void 0);
  55006. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55007. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55008. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55009. ], PBRMaterial.prototype, "useAmbientOcclusionFromMetallicTextureRed", void 0);
  55010. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55011. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55012. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55013. ], PBRMaterial.prototype, "useAmbientInGrayScale", void 0);
  55014. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55015. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55016. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55017. ], PBRMaterial.prototype, "useAutoMicroSurfaceFromReflectivityMap", void 0);
  55018. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55019. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55020. ], PBRMaterial.prototype, "usePhysicalLightFalloff", null);
  55021. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55022. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55023. ], PBRMaterial.prototype, "useGLTFLightFalloff", null);
  55024. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55025. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55026. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55027. ], PBRMaterial.prototype, "useRadianceOverAlpha", void 0);
  55028. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55029. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55030. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55031. ], PBRMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  55032. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55033. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55034. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55035. ], PBRMaterial.prototype, "useParallax", void 0);
  55036. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55037. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55038. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55039. ], PBRMaterial.prototype, "useParallaxOcclusion", void 0);
  55040. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55041. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55042. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55043. ], PBRMaterial.prototype, "parallaxScaleBias", void 0);
  55044. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55045. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55046. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  55047. ], PBRMaterial.prototype, "disableLighting", void 0);
  55048. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55049. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55050. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55051. ], PBRMaterial.prototype, "forceIrradianceInFragment", void 0);
  55052. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55053. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55054. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  55055. ], PBRMaterial.prototype, "maxSimultaneousLights", void 0);
  55056. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55057. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55058. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55059. ], PBRMaterial.prototype, "invertNormalMapX", void 0);
  55060. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55061. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55062. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55063. ], PBRMaterial.prototype, "invertNormalMapY", void 0);
  55064. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55065. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55066. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55067. ], PBRMaterial.prototype, "twoSidedLighting", void 0);
  55068. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55069. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55070. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55071. ], PBRMaterial.prototype, "useAlphaFresnel", void 0);
  55072. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55073. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55074. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55075. ], PBRMaterial.prototype, "useLinearAlphaFresnel", void 0);
  55076. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55077. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55078. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55079. ], PBRMaterial.prototype, "environmentBRDFTexture", void 0);
  55080. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55081. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55082. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55083. ], PBRMaterial.prototype, "forceNormalForward", void 0);
  55084. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55085. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55086. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55087. ], PBRMaterial.prototype, "enableSpecularAntiAliasing", void 0);
  55088. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55089. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55090. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55091. ], PBRMaterial.prototype, "useHorizonOcclusion", void 0);
  55092. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55093. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55094. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55095. ], PBRMaterial.prototype, "useRadianceOcclusion", void 0);
  55096. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55097. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55098. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  55099. ], PBRMaterial.prototype, "unlit", void 0);
  55100. return PBRMaterial;
  55101. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"]));
  55102. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PBRMaterial"] = PBRMaterial;
  55103. /***/ }),
  55104. /***/ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts":
  55105. /*!*******************************************************!*\
  55106. !*** ./Materials/PBR/pbrMetallicRoughnessMaterial.ts ***!
  55107. \*******************************************************/
  55108. /*! exports provided: PBRMetallicRoughnessMaterial */
  55109. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55110. "use strict";
  55111. __webpack_require__.r(__webpack_exports__);
  55112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return PBRMetallicRoughnessMaterial; });
  55113. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55114. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  55115. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  55116. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  55117. /**
  55118. * The PBR material of BJS following the metal roughness convention.
  55119. *
  55120. * This fits to the PBR convention in the GLTF definition:
  55121. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55122. */
  55123. var PBRMetallicRoughnessMaterial = /** @class */ (function (_super) {
  55124. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMetallicRoughnessMaterial, _super);
  55125. /**
  55126. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55127. *
  55128. * @param name The material name
  55129. * @param scene The scene the material will be use in.
  55130. */
  55131. function PBRMetallicRoughnessMaterial(name, scene) {
  55132. var _this = _super.call(this, name, scene) || this;
  55133. _this._useRoughnessFromMetallicTextureAlpha = false;
  55134. _this._useRoughnessFromMetallicTextureGreen = true;
  55135. _this._useMetallnessFromMetallicTextureBlue = true;
  55136. _this.metallic = 1.0;
  55137. _this.roughness = 1.0;
  55138. return _this;
  55139. }
  55140. /**
  55141. * Return the currrent class name of the material.
  55142. */
  55143. PBRMetallicRoughnessMaterial.prototype.getClassName = function () {
  55144. return "PBRMetallicRoughnessMaterial";
  55145. };
  55146. /**
  55147. * Makes a duplicate of the current material.
  55148. * @param name - name to use for the new material.
  55149. */
  55150. PBRMetallicRoughnessMaterial.prototype.clone = function (name) {
  55151. var _this = this;
  55152. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMetallicRoughnessMaterial(name, _this.getScene()); }, this);
  55153. clone.id = name;
  55154. clone.name = name;
  55155. this.clearCoat.copyTo(clone.clearCoat);
  55156. this.anisotropy.copyTo(clone.anisotropy);
  55157. this.brdf.copyTo(clone.brdf);
  55158. this.sheen.copyTo(clone.sheen);
  55159. return clone;
  55160. };
  55161. /**
  55162. * Serialize the material to a parsable JSON object.
  55163. */
  55164. PBRMetallicRoughnessMaterial.prototype.serialize = function () {
  55165. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  55166. serializationObject.customType = "BABYLON.PBRMetallicRoughnessMaterial";
  55167. serializationObject.clearCoat = this.clearCoat.serialize();
  55168. serializationObject.anisotropy = this.anisotropy.serialize();
  55169. serializationObject.brdf = this.brdf.serialize();
  55170. serializationObject.sheen = this.sheen.serialize();
  55171. return serializationObject;
  55172. };
  55173. /**
  55174. * Parses a JSON object correponding to the serialize function.
  55175. */
  55176. PBRMetallicRoughnessMaterial.Parse = function (source, scene, rootUrl) {
  55177. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMetallicRoughnessMaterial(source.name, scene); }, source, scene, rootUrl);
  55178. if (source.clearCoat) {
  55179. material.clearCoat.parse(source.clearCoat);
  55180. }
  55181. if (source.anisotropy) {
  55182. material.anisotropy.parse(source.anisotropy);
  55183. }
  55184. if (source.brdf) {
  55185. material.brdf.parse(source.brdf);
  55186. }
  55187. if (source.sheen) {
  55188. material.sheen.parse(source.brdf);
  55189. }
  55190. return material;
  55191. };
  55192. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55193. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])(),
  55194. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  55195. ], PBRMetallicRoughnessMaterial.prototype, "baseColor", void 0);
  55196. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55197. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55198. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  55199. ], PBRMetallicRoughnessMaterial.prototype, "baseTexture", void 0);
  55200. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55201. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55202. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55203. ], PBRMetallicRoughnessMaterial.prototype, "metallic", void 0);
  55204. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55205. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55206. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55207. ], PBRMetallicRoughnessMaterial.prototype, "roughness", void 0);
  55208. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55209. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55210. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_metallicTexture")
  55211. ], PBRMetallicRoughnessMaterial.prototype, "metallicRoughnessTexture", void 0);
  55212. return PBRMetallicRoughnessMaterial;
  55213. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  55214. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRMetallicRoughnessMaterial"] = PBRMetallicRoughnessMaterial;
  55215. /***/ }),
  55216. /***/ "./Materials/PBR/pbrSheenConfiguration.ts":
  55217. /*!************************************************!*\
  55218. !*** ./Materials/PBR/pbrSheenConfiguration.ts ***!
  55219. \************************************************/
  55220. /*! exports provided: PBRSheenConfiguration */
  55221. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55222. "use strict";
  55223. __webpack_require__.r(__webpack_exports__);
  55224. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSheenConfiguration", function() { return PBRSheenConfiguration; });
  55225. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55226. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  55227. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55228. /* harmony import */ var _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/materialFlags */ "./Materials/materialFlags.ts");
  55229. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  55230. /**
  55231. * Define the code related to the Sheen parameters of the pbr material.
  55232. */
  55233. var PBRSheenConfiguration = /** @class */ (function () {
  55234. /**
  55235. * Instantiate a new istance of clear coat configuration.
  55236. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55237. */
  55238. function PBRSheenConfiguration(markAllSubMeshesAsTexturesDirty) {
  55239. this._isEnabled = false;
  55240. /**
  55241. * Defines if the material uses sheen.
  55242. */
  55243. this.isEnabled = false;
  55244. this._linkSheenWithAlbedo = false;
  55245. /**
  55246. * Defines if the sheen is linked to the sheen color.
  55247. */
  55248. this.linkSheenWithAlbedo = false;
  55249. /**
  55250. * Defines the sheen intensity.
  55251. */
  55252. this.intensity = 1;
  55253. /**
  55254. * Defines the sheen color.
  55255. */
  55256. this.color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  55257. this._texture = null;
  55258. /**
  55259. * Stores the sheen tint values in a texture.
  55260. * rgb is tint
  55261. * a is a intensity
  55262. */
  55263. this.texture = null;
  55264. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  55265. }
  55266. /** @hidden */
  55267. PBRSheenConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  55268. this._internalMarkAllSubMeshesAsTexturesDirty();
  55269. };
  55270. /**
  55271. * Specifies that the submesh is ready to be used.
  55272. * @param defines the list of "defines" to update.
  55273. * @param scene defines the scene the material belongs to.
  55274. * @returns - boolean indicating that the submesh is ready or not.
  55275. */
  55276. PBRSheenConfiguration.prototype.isReadyForSubMesh = function (defines, scene) {
  55277. if (defines._areTexturesDirty) {
  55278. if (scene.texturesEnabled) {
  55279. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  55280. if (!this._texture.isReadyOrNotBlocking()) {
  55281. return false;
  55282. }
  55283. }
  55284. }
  55285. }
  55286. return true;
  55287. };
  55288. /**
  55289. * Checks to see if a texture is used in the material.
  55290. * @param defines the list of "defines" to update.
  55291. * @param scene defines the scene the material belongs to.
  55292. */
  55293. PBRSheenConfiguration.prototype.prepareDefines = function (defines, scene) {
  55294. if (this._isEnabled) {
  55295. defines.SHEEN = this._isEnabled;
  55296. defines.SHEEN_LINKWITHALBEDO = this._linkSheenWithAlbedo;
  55297. if (defines._areTexturesDirty) {
  55298. if (scene.texturesEnabled) {
  55299. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  55300. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "SHEEN_TEXTURE");
  55301. }
  55302. else {
  55303. defines.SHEEN_TEXTURE = false;
  55304. }
  55305. }
  55306. }
  55307. }
  55308. else {
  55309. defines.SHEEN = false;
  55310. defines.SHEEN_TEXTURE = false;
  55311. defines.SHEEN_LINKWITHALBEDO = false;
  55312. }
  55313. };
  55314. /**
  55315. * Binds the material data.
  55316. * @param uniformBuffer defines the Uniform buffer to fill in.
  55317. * @param scene defines the scene the material belongs to.
  55318. * @param isFrozen defines wether the material is frozen or not.
  55319. */
  55320. PBRSheenConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, isFrozen) {
  55321. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  55322. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  55323. uniformBuffer.updateFloat2("vSheenInfos", this._texture.coordinatesIndex, this._texture.level);
  55324. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "sheen");
  55325. }
  55326. // Sheen
  55327. uniformBuffer.updateFloat4("vSheenColor", this.color.r, this.color.g, this.color.b, this.intensity);
  55328. }
  55329. // Textures
  55330. if (scene.texturesEnabled) {
  55331. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  55332. uniformBuffer.setTexture("sheenSampler", this._texture);
  55333. }
  55334. }
  55335. };
  55336. /**
  55337. * Checks to see if a texture is used in the material.
  55338. * @param texture - Base texture to use.
  55339. * @returns - Boolean specifying if a texture is used in the material.
  55340. */
  55341. PBRSheenConfiguration.prototype.hasTexture = function (texture) {
  55342. if (this._texture === texture) {
  55343. return true;
  55344. }
  55345. return false;
  55346. };
  55347. /**
  55348. * Returns an array of the actively used textures.
  55349. * @param activeTextures Array of BaseTextures
  55350. */
  55351. PBRSheenConfiguration.prototype.getActiveTextures = function (activeTextures) {
  55352. if (this._texture) {
  55353. activeTextures.push(this._texture);
  55354. }
  55355. };
  55356. /**
  55357. * Returns the animatable textures.
  55358. * @param animatables Array of animatable textures.
  55359. */
  55360. PBRSheenConfiguration.prototype.getAnimatables = function (animatables) {
  55361. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  55362. animatables.push(this._texture);
  55363. }
  55364. };
  55365. /**
  55366. * Disposes the resources of the material.
  55367. * @param forceDisposeTextures - Forces the disposal of all textures.
  55368. */
  55369. PBRSheenConfiguration.prototype.dispose = function (forceDisposeTextures) {
  55370. if (forceDisposeTextures) {
  55371. if (this._texture) {
  55372. this._texture.dispose();
  55373. }
  55374. }
  55375. };
  55376. /**
  55377. * Get the current class name of the texture useful for serialization or dynamic coding.
  55378. * @returns "PBRSheenConfiguration"
  55379. */
  55380. PBRSheenConfiguration.prototype.getClassName = function () {
  55381. return "PBRSheenConfiguration";
  55382. };
  55383. /**
  55384. * Add fallbacks to the effect fallbacks list.
  55385. * @param defines defines the Base texture to use.
  55386. * @param fallbacks defines the current fallback list.
  55387. * @param currentRank defines the current fallback rank.
  55388. * @returns the new fallback rank.
  55389. */
  55390. PBRSheenConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  55391. if (defines.SHEEN) {
  55392. fallbacks.addFallback(currentRank++, "SHEEN");
  55393. }
  55394. return currentRank;
  55395. };
  55396. /**
  55397. * Add the required uniforms to the current list.
  55398. * @param uniforms defines the current uniform list.
  55399. */
  55400. PBRSheenConfiguration.AddUniforms = function (uniforms) {
  55401. uniforms.push("vSheenColor", "vSheenInfos", "sheenMatrix");
  55402. };
  55403. /**
  55404. * Add the required uniforms to the current buffer.
  55405. * @param uniformBuffer defines the current uniform buffer.
  55406. */
  55407. PBRSheenConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  55408. uniformBuffer.addUniform("vSheenColor", 4);
  55409. uniformBuffer.addUniform("vSheenInfos", 2);
  55410. uniformBuffer.addUniform("sheenMatrix", 16);
  55411. };
  55412. /**
  55413. * Add the required samplers to the current list.
  55414. * @param samplers defines the current sampler list.
  55415. */
  55416. PBRSheenConfiguration.AddSamplers = function (samplers) {
  55417. samplers.push("sheenSampler");
  55418. };
  55419. /**
  55420. * Makes a duplicate of the current configuration into another one.
  55421. * @param sheenConfiguration define the config where to copy the info
  55422. */
  55423. PBRSheenConfiguration.prototype.copyTo = function (sheenConfiguration) {
  55424. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return sheenConfiguration; }, this);
  55425. };
  55426. /**
  55427. * Serializes this BRDF configuration.
  55428. * @returns - An object with the serialized config.
  55429. */
  55430. PBRSheenConfiguration.prototype.serialize = function () {
  55431. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  55432. };
  55433. /**
  55434. * Parses a Sheen Configuration from a serialized object.
  55435. * @param source - Serialized object.
  55436. */
  55437. PBRSheenConfiguration.prototype.parse = function (source) {
  55438. var _this = this;
  55439. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  55440. };
  55441. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55442. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55443. ], PBRSheenConfiguration.prototype, "_isEnabled", void 0);
  55444. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55445. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55446. ], PBRSheenConfiguration.prototype, "isEnabled", void 0);
  55447. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55448. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55449. ], PBRSheenConfiguration.prototype, "_linkSheenWithAlbedo", void 0);
  55450. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55451. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55452. ], PBRSheenConfiguration.prototype, "linkSheenWithAlbedo", void 0);
  55453. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55454. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55455. ], PBRSheenConfiguration.prototype, "intensity", void 0);
  55456. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55457. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  55458. ], PBRSheenConfiguration.prototype, "color", void 0);
  55459. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55460. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  55461. ], PBRSheenConfiguration.prototype, "_texture", void 0);
  55462. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55463. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55464. ], PBRSheenConfiguration.prototype, "texture", void 0);
  55465. return PBRSheenConfiguration;
  55466. }());
  55467. /***/ }),
  55468. /***/ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts":
  55469. /*!********************************************************!*\
  55470. !*** ./Materials/PBR/pbrSpecularGlossinessMaterial.ts ***!
  55471. \********************************************************/
  55472. /*! exports provided: PBRSpecularGlossinessMaterial */
  55473. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55474. "use strict";
  55475. __webpack_require__.r(__webpack_exports__);
  55476. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return PBRSpecularGlossinessMaterial; });
  55477. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55478. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  55479. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  55480. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  55481. /**
  55482. * The PBR material of BJS following the specular glossiness convention.
  55483. *
  55484. * This fits to the PBR convention in the GLTF definition:
  55485. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55486. */
  55487. var PBRSpecularGlossinessMaterial = /** @class */ (function (_super) {
  55488. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRSpecularGlossinessMaterial, _super);
  55489. /**
  55490. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55491. *
  55492. * @param name The material name
  55493. * @param scene The scene the material will be use in.
  55494. */
  55495. function PBRSpecularGlossinessMaterial(name, scene) {
  55496. var _this = _super.call(this, name, scene) || this;
  55497. _this._useMicroSurfaceFromReflectivityMapAlpha = true;
  55498. return _this;
  55499. }
  55500. /**
  55501. * Return the currrent class name of the material.
  55502. */
  55503. PBRSpecularGlossinessMaterial.prototype.getClassName = function () {
  55504. return "PBRSpecularGlossinessMaterial";
  55505. };
  55506. /**
  55507. * Makes a duplicate of the current material.
  55508. * @param name - name to use for the new material.
  55509. */
  55510. PBRSpecularGlossinessMaterial.prototype.clone = function (name) {
  55511. var _this = this;
  55512. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRSpecularGlossinessMaterial(name, _this.getScene()); }, this);
  55513. clone.id = name;
  55514. clone.name = name;
  55515. this.clearCoat.copyTo(clone.clearCoat);
  55516. this.anisotropy.copyTo(clone.anisotropy);
  55517. this.brdf.copyTo(clone.brdf);
  55518. this.sheen.copyTo(clone.sheen);
  55519. return clone;
  55520. };
  55521. /**
  55522. * Serialize the material to a parsable JSON object.
  55523. */
  55524. PBRSpecularGlossinessMaterial.prototype.serialize = function () {
  55525. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  55526. serializationObject.customType = "BABYLON.PBRSpecularGlossinessMaterial";
  55527. serializationObject.clearCoat = this.clearCoat.serialize();
  55528. serializationObject.anisotropy = this.anisotropy.serialize();
  55529. serializationObject.brdf = this.brdf.serialize();
  55530. serializationObject.sheen = this.sheen.serialize();
  55531. return serializationObject;
  55532. };
  55533. /**
  55534. * Parses a JSON object correponding to the serialize function.
  55535. */
  55536. PBRSpecularGlossinessMaterial.Parse = function (source, scene, rootUrl) {
  55537. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRSpecularGlossinessMaterial(source.name, scene); }, source, scene, rootUrl);
  55538. if (source.clearCoat) {
  55539. material.clearCoat.parse(source.clearCoat);
  55540. }
  55541. if (source.anisotropy) {
  55542. material.anisotropy.parse(source.anisotropy);
  55543. }
  55544. if (source.brdf) {
  55545. material.brdf.parse(source.brdf);
  55546. }
  55547. if (source.sheen) {
  55548. material.sheen.parse(source.brdf);
  55549. }
  55550. return material;
  55551. };
  55552. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55553. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse"),
  55554. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  55555. ], PBRSpecularGlossinessMaterial.prototype, "diffuseColor", void 0);
  55556. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55557. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55558. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  55559. ], PBRSpecularGlossinessMaterial.prototype, "diffuseTexture", void 0);
  55560. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55561. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular"),
  55562. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityColor")
  55563. ], PBRSpecularGlossinessMaterial.prototype, "specularColor", void 0);
  55564. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55565. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55566. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_microSurface")
  55567. ], PBRSpecularGlossinessMaterial.prototype, "glossiness", void 0);
  55568. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55569. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55570. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityTexture")
  55571. ], PBRSpecularGlossinessMaterial.prototype, "specularGlossinessTexture", void 0);
  55572. return PBRSpecularGlossinessMaterial;
  55573. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  55574. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRSpecularGlossinessMaterial"] = PBRSpecularGlossinessMaterial;
  55575. /***/ }),
  55576. /***/ "./Materials/Textures/Loaders/ddsTextureLoader.ts":
  55577. /*!********************************************************!*\
  55578. !*** ./Materials/Textures/Loaders/ddsTextureLoader.ts ***!
  55579. \********************************************************/
  55580. /*! exports provided: _DDSTextureLoader */
  55581. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55582. "use strict";
  55583. __webpack_require__.r(__webpack_exports__);
  55584. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _DDSTextureLoader; });
  55585. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  55586. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  55587. /* harmony import */ var _Misc_dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/dds */ "./Misc/dds.ts");
  55588. /**
  55589. * Implementation of the DDS Texture Loader.
  55590. * @hidden
  55591. */
  55592. var _DDSTextureLoader = /** @class */ (function () {
  55593. function _DDSTextureLoader() {
  55594. /**
  55595. * Defines wether the loader supports cascade loading the different faces.
  55596. */
  55597. this.supportCascades = true;
  55598. }
  55599. /**
  55600. * This returns if the loader support the current file information.
  55601. * @param extension defines the file extension of the file being loaded
  55602. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55603. * @param fallback defines the fallback internal texture if any
  55604. * @param isBase64 defines whether the texture is encoded as a base64
  55605. * @param isBuffer defines whether the texture data are stored as a buffer
  55606. * @returns true if the loader can load the specified file
  55607. */
  55608. _DDSTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  55609. return extension.indexOf(".dds") === 0;
  55610. };
  55611. /**
  55612. * Transform the url before loading if required.
  55613. * @param rootUrl the url of the texture
  55614. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55615. * @returns the transformed texture
  55616. */
  55617. _DDSTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  55618. return rootUrl;
  55619. };
  55620. /**
  55621. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55622. * @param rootUrl the url of the texture
  55623. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55624. * @returns the fallback texture
  55625. */
  55626. _DDSTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  55627. return null;
  55628. };
  55629. /**
  55630. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55631. * @param data contains the texture data
  55632. * @param texture defines the BabylonJS internal texture
  55633. * @param createPolynomials will be true if polynomials have been requested
  55634. * @param onLoad defines the callback to trigger once the texture is ready
  55635. * @param onError defines the callback to trigger in case of error
  55636. */
  55637. _DDSTextureLoader.prototype.loadCubeData = function (imgs, texture, createPolynomials, onLoad, onError) {
  55638. var engine = texture.getEngine();
  55639. var info;
  55640. var loadMipmap = false;
  55641. if (Array.isArray(imgs)) {
  55642. for (var index = 0; index < imgs.length; index++) {
  55643. var data_1 = imgs[index];
  55644. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data_1);
  55645. texture.width = info.width;
  55646. texture.height = info.height;
  55647. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  55648. engine._unpackFlipY(info.isCompressed);
  55649. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data_1, info, loadMipmap, 6, -1, index);
  55650. if (!info.isFourCC && info.mipmapCount === 1) {
  55651. engine.generateMipMapsForCubemap(texture);
  55652. }
  55653. }
  55654. }
  55655. else {
  55656. var data = imgs;
  55657. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  55658. texture.width = info.width;
  55659. texture.height = info.height;
  55660. if (createPolynomials) {
  55661. info.sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]();
  55662. }
  55663. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  55664. engine._unpackFlipY(info.isCompressed);
  55665. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data, info, loadMipmap, 6);
  55666. if (!info.isFourCC && info.mipmapCount === 1) {
  55667. engine.generateMipMapsForCubemap(texture);
  55668. }
  55669. }
  55670. engine._setCubeMapTextureParams(loadMipmap);
  55671. texture.isReady = true;
  55672. if (onLoad) {
  55673. onLoad({ isDDS: true, width: texture.width, info: info, data: imgs, texture: texture });
  55674. }
  55675. };
  55676. /**
  55677. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55678. * @param data contains the texture data
  55679. * @param texture defines the BabylonJS internal texture
  55680. * @param callback defines the method to call once ready to upload
  55681. */
  55682. _DDSTextureLoader.prototype.loadData = function (data, texture, callback) {
  55683. var info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  55684. var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps && ((info.width >> (info.mipmapCount - 1)) === 1);
  55685. callback(info.width, info.height, loadMipmap, info.isFourCC, function () {
  55686. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(texture.getEngine(), texture, data, info, loadMipmap, 1);
  55687. });
  55688. };
  55689. return _DDSTextureLoader;
  55690. }());
  55691. // Register the loader.
  55692. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _DDSTextureLoader());
  55693. /***/ }),
  55694. /***/ "./Materials/Textures/Loaders/envTextureLoader.ts":
  55695. /*!********************************************************!*\
  55696. !*** ./Materials/Textures/Loaders/envTextureLoader.ts ***!
  55697. \********************************************************/
  55698. /*! exports provided: _ENVTextureLoader */
  55699. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55700. "use strict";
  55701. __webpack_require__.r(__webpack_exports__);
  55702. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _ENVTextureLoader; });
  55703. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  55704. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  55705. /**
  55706. * Implementation of the ENV Texture Loader.
  55707. * @hidden
  55708. */
  55709. var _ENVTextureLoader = /** @class */ (function () {
  55710. function _ENVTextureLoader() {
  55711. /**
  55712. * Defines wether the loader supports cascade loading the different faces.
  55713. */
  55714. this.supportCascades = false;
  55715. }
  55716. /**
  55717. * This returns if the loader support the current file information.
  55718. * @param extension defines the file extension of the file being loaded
  55719. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55720. * @param fallback defines the fallback internal texture if any
  55721. * @param isBase64 defines whether the texture is encoded as a base64
  55722. * @param isBuffer defines whether the texture data are stored as a buffer
  55723. * @returns true if the loader can load the specified file
  55724. */
  55725. _ENVTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  55726. return extension.indexOf(".env") === 0;
  55727. };
  55728. /**
  55729. * Transform the url before loading if required.
  55730. * @param rootUrl the url of the texture
  55731. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55732. * @returns the transformed texture
  55733. */
  55734. _ENVTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  55735. return rootUrl;
  55736. };
  55737. /**
  55738. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55739. * @param rootUrl the url of the texture
  55740. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55741. * @returns the fallback texture
  55742. */
  55743. _ENVTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  55744. return null;
  55745. };
  55746. /**
  55747. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55748. * @param data contains the texture data
  55749. * @param texture defines the BabylonJS internal texture
  55750. * @param createPolynomials will be true if polynomials have been requested
  55751. * @param onLoad defines the callback to trigger once the texture is ready
  55752. * @param onError defines the callback to trigger in case of error
  55753. */
  55754. _ENVTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  55755. if (Array.isArray(data)) {
  55756. return;
  55757. }
  55758. data = data;
  55759. var info = _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].GetEnvInfo(data);
  55760. if (info) {
  55761. texture.width = info.width;
  55762. texture.height = info.width;
  55763. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvSpherical(texture, info);
  55764. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvLevelsAsync(texture, data, info).then(function () {
  55765. texture.isReady = true;
  55766. if (onLoad) {
  55767. onLoad();
  55768. }
  55769. });
  55770. }
  55771. else if (onError) {
  55772. onError("Can not parse the environment file", null);
  55773. }
  55774. };
  55775. /**
  55776. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55777. * @param data contains the texture data
  55778. * @param texture defines the BabylonJS internal texture
  55779. * @param callback defines the method to call once ready to upload
  55780. */
  55781. _ENVTextureLoader.prototype.loadData = function (data, texture, callback) {
  55782. throw ".env not supported in 2d.";
  55783. };
  55784. return _ENVTextureLoader;
  55785. }());
  55786. // Register the loader.
  55787. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _ENVTextureLoader());
  55788. /***/ }),
  55789. /***/ "./Materials/Textures/Loaders/index.ts":
  55790. /*!*********************************************!*\
  55791. !*** ./Materials/Textures/Loaders/index.ts ***!
  55792. \*********************************************/
  55793. /*! exports provided: _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader */
  55794. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55795. "use strict";
  55796. __webpack_require__.r(__webpack_exports__);
  55797. /* harmony import */ var _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  55798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  55799. /* harmony import */ var _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  55800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__["_ENVTextureLoader"]; });
  55801. /* harmony import */ var _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  55802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__["_KTXTextureLoader"]; });
  55803. /* harmony import */ var _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tgaTextureLoader */ "./Materials/Textures/Loaders/tgaTextureLoader.ts");
  55804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__["_TGATextureLoader"]; });
  55805. /***/ }),
  55806. /***/ "./Materials/Textures/Loaders/ktxTextureLoader.ts":
  55807. /*!********************************************************!*\
  55808. !*** ./Materials/Textures/Loaders/ktxTextureLoader.ts ***!
  55809. \********************************************************/
  55810. /*! exports provided: _KTXTextureLoader */
  55811. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55812. "use strict";
  55813. __webpack_require__.r(__webpack_exports__);
  55814. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _KTXTextureLoader; });
  55815. /* harmony import */ var _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  55816. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  55817. /**
  55818. * Implementation of the KTX Texture Loader.
  55819. * @hidden
  55820. */
  55821. var _KTXTextureLoader = /** @class */ (function () {
  55822. function _KTXTextureLoader() {
  55823. /**
  55824. * Defines wether the loader supports cascade loading the different faces.
  55825. */
  55826. this.supportCascades = false;
  55827. }
  55828. /**
  55829. * This returns if the loader support the current file information.
  55830. * @param extension defines the file extension of the file being loaded
  55831. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55832. * @param fallback defines the fallback internal texture if any
  55833. * @param isBase64 defines whether the texture is encoded as a base64
  55834. * @param isBuffer defines whether the texture data are stored as a buffer
  55835. * @returns true if the loader can load the specified file
  55836. */
  55837. _KTXTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  55838. if (textureFormatInUse && !isBase64 && !fallback && !isBuffer) {
  55839. return true;
  55840. }
  55841. return false;
  55842. };
  55843. /**
  55844. * Transform the url before loading if required.
  55845. * @param rootUrl the url of the texture
  55846. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55847. * @returns the transformed texture
  55848. */
  55849. _KTXTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  55850. var lastDot = rootUrl.lastIndexOf('.');
  55851. if (lastDot != -1 && rootUrl.substring(lastDot + 1) == "ktx") {
  55852. // Already transformed
  55853. return rootUrl;
  55854. }
  55855. return (lastDot > -1 ? rootUrl.substring(0, lastDot) : rootUrl) + textureFormatInUse;
  55856. };
  55857. /**
  55858. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55859. * @param rootUrl the url of the texture
  55860. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55861. * @returns the fallback texture
  55862. */
  55863. _KTXTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  55864. // remove the format appended to the rootUrl in the original createCubeTexture call.
  55865. var exp = new RegExp("" + textureFormatInUse + "$");
  55866. return rootUrl.replace(exp, "");
  55867. };
  55868. /**
  55869. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55870. * @param data contains the texture data
  55871. * @param texture defines the BabylonJS internal texture
  55872. * @param createPolynomials will be true if polynomials have been requested
  55873. * @param onLoad defines the callback to trigger once the texture is ready
  55874. * @param onError defines the callback to trigger in case of error
  55875. */
  55876. _KTXTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  55877. if (Array.isArray(data)) {
  55878. return;
  55879. }
  55880. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  55881. texture._invertVScale = !texture.invertY;
  55882. var engine = texture.getEngine();
  55883. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 6);
  55884. var loadMipmap = ktx.numberOfMipmapLevels > 1 && texture.generateMipMaps;
  55885. engine._unpackFlipY(true);
  55886. ktx.uploadLevels(texture, texture.generateMipMaps);
  55887. texture.width = ktx.pixelWidth;
  55888. texture.height = ktx.pixelHeight;
  55889. engine._setCubeMapTextureParams(loadMipmap);
  55890. texture.isReady = true;
  55891. };
  55892. /**
  55893. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55894. * @param data contains the texture data
  55895. * @param texture defines the BabylonJS internal texture
  55896. * @param callback defines the method to call once ready to upload
  55897. */
  55898. _KTXTextureLoader.prototype.loadData = function (data, texture, callback) {
  55899. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  55900. texture._invertVScale = !texture.invertY;
  55901. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 1);
  55902. callback(ktx.pixelWidth, ktx.pixelHeight, false, true, function () {
  55903. ktx.uploadLevels(texture, texture.generateMipMaps);
  55904. }, ktx.isInvalid);
  55905. };
  55906. return _KTXTextureLoader;
  55907. }());
  55908. // Register the loader.
  55909. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.unshift(new _KTXTextureLoader());
  55910. /***/ }),
  55911. /***/ "./Materials/Textures/Loaders/tgaTextureLoader.ts":
  55912. /*!********************************************************!*\
  55913. !*** ./Materials/Textures/Loaders/tgaTextureLoader.ts ***!
  55914. \********************************************************/
  55915. /*! exports provided: _TGATextureLoader */
  55916. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55917. "use strict";
  55918. __webpack_require__.r(__webpack_exports__);
  55919. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _TGATextureLoader; });
  55920. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tga */ "./Misc/tga.ts");
  55921. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  55922. /**
  55923. * Implementation of the TGA Texture Loader.
  55924. * @hidden
  55925. */
  55926. var _TGATextureLoader = /** @class */ (function () {
  55927. function _TGATextureLoader() {
  55928. /**
  55929. * Defines wether the loader supports cascade loading the different faces.
  55930. */
  55931. this.supportCascades = false;
  55932. }
  55933. /**
  55934. * This returns if the loader support the current file information.
  55935. * @param extension defines the file extension of the file being loaded
  55936. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55937. * @param fallback defines the fallback internal texture if any
  55938. * @param isBase64 defines whether the texture is encoded as a base64
  55939. * @param isBuffer defines whether the texture data are stored as a buffer
  55940. * @returns true if the loader can load the specified file
  55941. */
  55942. _TGATextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  55943. return extension.indexOf(".tga") === 0;
  55944. };
  55945. /**
  55946. * Transform the url before loading if required.
  55947. * @param rootUrl the url of the texture
  55948. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55949. * @returns the transformed texture
  55950. */
  55951. _TGATextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  55952. return rootUrl;
  55953. };
  55954. /**
  55955. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55956. * @param rootUrl the url of the texture
  55957. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55958. * @returns the fallback texture
  55959. */
  55960. _TGATextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  55961. return null;
  55962. };
  55963. /**
  55964. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55965. * @param data contains the texture data
  55966. * @param texture defines the BabylonJS internal texture
  55967. * @param createPolynomials will be true if polynomials have been requested
  55968. * @param onLoad defines the callback to trigger once the texture is ready
  55969. * @param onError defines the callback to trigger in case of error
  55970. */
  55971. _TGATextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  55972. throw ".env not supported in Cube.";
  55973. };
  55974. /**
  55975. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55976. * @param data contains the texture data
  55977. * @param texture defines the BabylonJS internal texture
  55978. * @param callback defines the method to call once ready to upload
  55979. */
  55980. _TGATextureLoader.prototype.loadData = function (data, texture, callback) {
  55981. var uintData = new Uint8Array(data);
  55982. var header = _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].GetTGAHeader(uintData);
  55983. callback(header.width, header.height, texture.generateMipMaps, false, function () {
  55984. _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].UploadContent(texture, uintData);
  55985. });
  55986. };
  55987. return _TGATextureLoader;
  55988. }());
  55989. // Register the loader.
  55990. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _TGATextureLoader());
  55991. /***/ }),
  55992. /***/ "./Materials/Textures/MultiviewRenderTarget.ts":
  55993. /*!*****************************************************!*\
  55994. !*** ./Materials/Textures/MultiviewRenderTarget.ts ***!
  55995. \*****************************************************/
  55996. /*! exports provided: MultiviewRenderTarget */
  55997. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55998. "use strict";
  55999. __webpack_require__.r(__webpack_exports__);
  56000. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiviewRenderTarget", function() { return MultiviewRenderTarget; });
  56001. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56002. /* harmony import */ var _Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56003. /* harmony import */ var _Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  56004. /**
  56005. * Renders to multiple views with a single draw call
  56006. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  56007. */
  56008. var MultiviewRenderTarget = /** @class */ (function (_super) {
  56009. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiviewRenderTarget, _super);
  56010. /**
  56011. * Creates a multiview render target
  56012. * @param scene scene used with the render target
  56013. * @param size the size of the render target (used for each view)
  56014. */
  56015. function MultiviewRenderTarget(scene, size) {
  56016. if (size === void 0) { size = 512; }
  56017. var _this = _super.call(this, "multiview rtt", size, scene, false, true, _Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__["InternalTexture"].DATASOURCE_UNKNOWN, false, undefined, false, false, true, undefined, true) || this;
  56018. var internalTexture = scene.getEngine().createMultiviewRenderTargetTexture(_this.getRenderWidth(), _this.getRenderHeight());
  56019. internalTexture.isMultiview = true;
  56020. _this._texture = internalTexture;
  56021. return _this;
  56022. }
  56023. /**
  56024. * @hidden
  56025. * @param faceIndex the face index, if its a cube texture
  56026. */
  56027. MultiviewRenderTarget.prototype._bindFrameBuffer = function (faceIndex) {
  56028. if (faceIndex === void 0) { faceIndex = 0; }
  56029. if (!this._texture) {
  56030. return;
  56031. }
  56032. this.getScene().getEngine().bindMultiviewFramebuffer(this._texture);
  56033. };
  56034. /**
  56035. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  56036. * @returns the view count
  56037. */
  56038. MultiviewRenderTarget.prototype.getViewCount = function () {
  56039. return 2;
  56040. };
  56041. return MultiviewRenderTarget;
  56042. }(_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__["RenderTargetTexture"]));
  56043. /***/ }),
  56044. /***/ "./Materials/Textures/Procedurals/customProceduralTexture.ts":
  56045. /*!*******************************************************************!*\
  56046. !*** ./Materials/Textures/Procedurals/customProceduralTexture.ts ***!
  56047. \*******************************************************************/
  56048. /*! exports provided: CustomProceduralTexture */
  56049. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56050. "use strict";
  56051. __webpack_require__.r(__webpack_exports__);
  56052. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return CustomProceduralTexture; });
  56053. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56054. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  56055. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  56056. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56057. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  56058. /* harmony import */ var _Misc_webRequest__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Misc/webRequest */ "./Misc/webRequest.ts");
  56059. /**
  56060. * 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.
  56061. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56062. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56063. */
  56064. var CustomProceduralTexture = /** @class */ (function (_super) {
  56065. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomProceduralTexture, _super);
  56066. /**
  56067. * Instantiates a new Custom Procedural Texture.
  56068. * 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.
  56069. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56070. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56071. * @param name Define the name of the texture
  56072. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56073. * @param size Define the size of the texture to create
  56074. * @param scene Define the scene the texture belongs to
  56075. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56076. * @param generateMipMaps Define if the texture should creates mip maps or not
  56077. */
  56078. function CustomProceduralTexture(name, texturePath, size, scene, fallbackTexture, generateMipMaps) {
  56079. var _this = _super.call(this, name, size, null, scene, fallbackTexture, generateMipMaps) || this;
  56080. _this._animate = true;
  56081. _this._time = 0;
  56082. _this._texturePath = texturePath;
  56083. //Try to load json
  56084. _this._loadJson(texturePath);
  56085. _this.refreshRate = 1;
  56086. return _this;
  56087. }
  56088. CustomProceduralTexture.prototype._loadJson = function (jsonUrl) {
  56089. var _this = this;
  56090. var noConfigFile = function () {
  56091. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log("No config file found in " + jsonUrl + " trying to use ShadersStore or DOM element");
  56092. try {
  56093. _this.setFragment(_this._texturePath);
  56094. }
  56095. catch (ex) {
  56096. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("No json or ShaderStore or DOM element found for CustomProceduralTexture");
  56097. }
  56098. };
  56099. var configFileUrl = jsonUrl + "/config.json";
  56100. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_5__["WebRequest"]();
  56101. xhr.open("GET", configFileUrl);
  56102. xhr.addEventListener("load", function () {
  56103. if (xhr.status === 200 || (xhr.responseText && xhr.responseText.length > 0)) {
  56104. try {
  56105. _this._config = JSON.parse(xhr.response);
  56106. _this.updateShaderUniforms();
  56107. _this.updateTextures();
  56108. _this.setFragment(_this._texturePath + "/custom");
  56109. _this._animate = _this._config.animate;
  56110. _this.refreshRate = _this._config.refreshrate;
  56111. }
  56112. catch (ex) {
  56113. noConfigFile();
  56114. }
  56115. }
  56116. else {
  56117. noConfigFile();
  56118. }
  56119. }, false);
  56120. xhr.addEventListener("error", function () {
  56121. noConfigFile();
  56122. }, false);
  56123. try {
  56124. xhr.send();
  56125. }
  56126. catch (ex) {
  56127. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("CustomProceduralTexture: Error on XHR send request.");
  56128. }
  56129. };
  56130. /**
  56131. * Is the texture ready to be used ? (rendered at least once)
  56132. * @returns true if ready, otherwise, false.
  56133. */
  56134. CustomProceduralTexture.prototype.isReady = function () {
  56135. if (!_super.prototype.isReady.call(this)) {
  56136. return false;
  56137. }
  56138. for (var name in this._textures) {
  56139. var texture = this._textures[name];
  56140. if (!texture.isReady()) {
  56141. return false;
  56142. }
  56143. }
  56144. return true;
  56145. };
  56146. /**
  56147. * Render the texture to its associated render target.
  56148. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56149. */
  56150. CustomProceduralTexture.prototype.render = function (useCameraPostProcess) {
  56151. var scene = this.getScene();
  56152. if (this._animate && scene) {
  56153. this._time += scene.getAnimationRatio() * 0.03;
  56154. this.updateShaderUniforms();
  56155. }
  56156. _super.prototype.render.call(this, useCameraPostProcess);
  56157. };
  56158. /**
  56159. * Update the list of dependant textures samplers in the shader.
  56160. */
  56161. CustomProceduralTexture.prototype.updateTextures = function () {
  56162. for (var i = 0; i < this._config.sampler2Ds.length; i++) {
  56163. this.setTexture(this._config.sampler2Ds[i].sample2Dname, new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"](this._texturePath + "/" + this._config.sampler2Ds[i].textureRelativeUrl, this.getScene()));
  56164. }
  56165. };
  56166. /**
  56167. * Update the uniform values of the procedural texture in the shader.
  56168. */
  56169. CustomProceduralTexture.prototype.updateShaderUniforms = function () {
  56170. if (this._config) {
  56171. for (var j = 0; j < this._config.uniforms.length; j++) {
  56172. var uniform = this._config.uniforms[j];
  56173. switch (uniform.type) {
  56174. case "float":
  56175. this.setFloat(uniform.name, uniform.value);
  56176. break;
  56177. case "color3":
  56178. this.setColor3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](uniform.r, uniform.g, uniform.b));
  56179. break;
  56180. case "color4":
  56181. this.setColor4(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](uniform.r, uniform.g, uniform.b, uniform.a));
  56182. break;
  56183. case "vector2":
  56184. this.setVector2(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](uniform.x, uniform.y));
  56185. break;
  56186. case "vector3":
  56187. this.setVector3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](uniform.x, uniform.y, uniform.z));
  56188. break;
  56189. }
  56190. }
  56191. }
  56192. this.setFloat("time", this._time);
  56193. };
  56194. Object.defineProperty(CustomProceduralTexture.prototype, "animate", {
  56195. /**
  56196. * Define if the texture animates or not.
  56197. */
  56198. get: function () {
  56199. return this._animate;
  56200. },
  56201. set: function (value) {
  56202. this._animate = value;
  56203. },
  56204. enumerable: true,
  56205. configurable: true
  56206. });
  56207. return CustomProceduralTexture;
  56208. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_4__["ProceduralTexture"]));
  56209. /***/ }),
  56210. /***/ "./Materials/Textures/Procedurals/index.ts":
  56211. /*!*************************************************!*\
  56212. !*** ./Materials/Textures/Procedurals/index.ts ***!
  56213. \*************************************************/
  56214. /*! exports provided: ProceduralTexture, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  56215. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56216. "use strict";
  56217. __webpack_require__.r(__webpack_exports__);
  56218. /* harmony import */ var _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./customProceduralTexture */ "./Materials/Textures/Procedurals/customProceduralTexture.ts");
  56219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  56220. /* harmony import */ var _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./noiseProceduralTexture */ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts");
  56221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__["NoiseProceduralTexture"]; });
  56222. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  56223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]; });
  56224. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  56225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__["ProceduralTextureSceneComponent"]; });
  56226. /***/ }),
  56227. /***/ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts":
  56228. /*!******************************************************************!*\
  56229. !*** ./Materials/Textures/Procedurals/noiseProceduralTexture.ts ***!
  56230. \******************************************************************/
  56231. /*! exports provided: NoiseProceduralTexture */
  56232. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56233. "use strict";
  56234. __webpack_require__.r(__webpack_exports__);
  56235. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return NoiseProceduralTexture; });
  56236. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56237. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  56238. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  56239. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  56240. /* harmony import */ var _Shaders_noise_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Shaders/noise.fragment */ "./Shaders/noise.fragment.ts");
  56241. /**
  56242. * Class used to generate noise procedural textures
  56243. */
  56244. var NoiseProceduralTexture = /** @class */ (function (_super) {
  56245. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NoiseProceduralTexture, _super);
  56246. /**
  56247. * Creates a new NoiseProceduralTexture
  56248. * @param name defines the name fo the texture
  56249. * @param size defines the size of the texture (default is 256)
  56250. * @param scene defines the hosting scene
  56251. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56252. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56253. */
  56254. function NoiseProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  56255. if (size === void 0) { size = 256; }
  56256. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene; }
  56257. var _this = _super.call(this, name, size, "noise", scene, fallbackTexture, generateMipMaps) || this;
  56258. _this._time = 0;
  56259. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56260. _this.brightness = 0.2;
  56261. /** Defines the number of octaves to process */
  56262. _this.octaves = 3;
  56263. /** Defines the level of persistence (0.8 by default) */
  56264. _this.persistence = 0.8;
  56265. /** Gets or sets animation speed factor (default is 1) */
  56266. _this.animationSpeedFactor = 1;
  56267. _this.autoClear = false;
  56268. _this._updateShaderUniforms();
  56269. return _this;
  56270. }
  56271. NoiseProceduralTexture.prototype._updateShaderUniforms = function () {
  56272. var scene = this.getScene();
  56273. if (!scene) {
  56274. return;
  56275. }
  56276. this._time += scene.getAnimationRatio() * this.animationSpeedFactor * 0.01;
  56277. this.setFloat("brightness", this.brightness);
  56278. this.setFloat("persistence", this.persistence);
  56279. this.setFloat("timeScale", this._time);
  56280. };
  56281. NoiseProceduralTexture.prototype._getDefines = function () {
  56282. return "#define OCTAVES " + (this.octaves | 0);
  56283. };
  56284. /** Generate the current state of the procedural texture */
  56285. NoiseProceduralTexture.prototype.render = function (useCameraPostProcess) {
  56286. this._updateShaderUniforms();
  56287. _super.prototype.render.call(this, useCameraPostProcess);
  56288. };
  56289. /**
  56290. * Serializes this noise procedural texture
  56291. * @returns a serialized noise procedural texture object
  56292. */
  56293. NoiseProceduralTexture.prototype.serialize = function () {
  56294. var serializationObject = {};
  56295. serializationObject.customType = "BABYLON.NoiseProceduralTexture";
  56296. serializationObject.brightness = this.brightness;
  56297. serializationObject.octaves = this.octaves;
  56298. serializationObject.persistence = this.persistence;
  56299. serializationObject.animationSpeedFactor = this.animationSpeedFactor;
  56300. serializationObject.size = this.getSize().width;
  56301. serializationObject.generateMipMaps = this._generateMipMaps;
  56302. return serializationObject;
  56303. };
  56304. /**
  56305. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56306. * @param parsedTexture defines parsed texture data
  56307. * @param scene defines the current scene
  56308. * @param rootUrl defines the root URL containing noise procedural texture information
  56309. * @returns a parsed NoiseProceduralTexture
  56310. */
  56311. NoiseProceduralTexture.Parse = function (parsedTexture, scene) {
  56312. var texture = new NoiseProceduralTexture(parsedTexture.name, parsedTexture.size, scene, undefined, parsedTexture.generateMipMaps);
  56313. texture.brightness = parsedTexture.brightness;
  56314. texture.octaves = parsedTexture.octaves;
  56315. texture.persistence = parsedTexture.persistence;
  56316. texture.animationSpeedFactor = parsedTexture.animationSpeedFactor;
  56317. return texture;
  56318. };
  56319. return NoiseProceduralTexture;
  56320. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]));
  56321. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.NoiseProceduralTexture"] = NoiseProceduralTexture;
  56322. /***/ }),
  56323. /***/ "./Materials/Textures/Procedurals/proceduralTexture.ts":
  56324. /*!*************************************************************!*\
  56325. !*** ./Materials/Textures/Procedurals/proceduralTexture.ts ***!
  56326. \*************************************************************/
  56327. /*! exports provided: ProceduralTexture */
  56328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56329. "use strict";
  56330. __webpack_require__.r(__webpack_exports__);
  56331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return ProceduralTexture; });
  56332. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56333. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  56334. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/observable */ "./Misc/observable.ts");
  56335. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Meshes/buffer */ "./Meshes/buffer.ts");
  56336. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  56337. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/material */ "./Materials/material.ts");
  56338. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56339. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56340. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  56341. /* harmony import */ var _Shaders_procedural_vertex__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Shaders/procedural.vertex */ "./Shaders/procedural.vertex.ts");
  56342. /**
  56343. * 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.
  56344. * This is the base class of any Procedural texture and contains most of the shareable code.
  56345. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  56346. */
  56347. var ProceduralTexture = /** @class */ (function (_super) {
  56348. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ProceduralTexture, _super);
  56349. /**
  56350. * Instantiates a new procedural texture.
  56351. * 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.
  56352. * This is the base class of any Procedural texture and contains most of the shareable code.
  56353. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  56354. * @param name Define the name of the texture
  56355. * @param size Define the size of the texture to create
  56356. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  56357. * @param scene Define the scene the texture belongs to
  56358. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56359. * @param generateMipMaps Define if the texture should creates mip maps or not
  56360. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  56361. */
  56362. function ProceduralTexture(name, size, fragment, scene, fallbackTexture, generateMipMaps, isCube) {
  56363. if (fallbackTexture === void 0) { fallbackTexture = null; }
  56364. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56365. if (isCube === void 0) { isCube = false; }
  56366. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  56367. _this.isCube = isCube;
  56368. /**
  56369. * Define if the texture is enabled or not (disabled texture will not render)
  56370. */
  56371. _this.isEnabled = true;
  56372. /**
  56373. * Define if the texture must be cleared before rendering (default is true)
  56374. */
  56375. _this.autoClear = true;
  56376. /**
  56377. * Event raised when the texture is generated
  56378. */
  56379. _this.onGeneratedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  56380. /** @hidden */
  56381. _this._textures = {};
  56382. _this._currentRefreshId = -1;
  56383. _this._refreshRate = 1;
  56384. _this._vertexBuffers = {};
  56385. _this._uniforms = new Array();
  56386. _this._samplers = new Array();
  56387. _this._floats = {};
  56388. _this._ints = {};
  56389. _this._floatsArrays = {};
  56390. _this._colors3 = {};
  56391. _this._colors4 = {};
  56392. _this._vectors2 = {};
  56393. _this._vectors3 = {};
  56394. _this._matrices = {};
  56395. _this._fallbackTextureUsed = false;
  56396. _this._cachedDefines = "";
  56397. _this._contentUpdateId = -1;
  56398. scene = _this.getScene();
  56399. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE);
  56400. if (!component) {
  56401. component = new _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__["ProceduralTextureSceneComponent"](scene);
  56402. scene._addComponent(component);
  56403. }
  56404. scene.proceduralTextures.push(_this);
  56405. _this._engine = scene.getEngine();
  56406. _this.name = name;
  56407. _this.isRenderTarget = true;
  56408. _this._size = size;
  56409. _this._generateMipMaps = generateMipMaps;
  56410. _this.setFragment(fragment);
  56411. _this._fallbackTexture = fallbackTexture;
  56412. if (isCube) {
  56413. _this._texture = _this._engine.createRenderTargetCubeTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  56414. _this.setFloat("face", 0);
  56415. }
  56416. else {
  56417. _this._texture = _this._engine.createRenderTargetTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  56418. }
  56419. // VBO
  56420. var vertices = [];
  56421. vertices.push(1, 1);
  56422. vertices.push(-1, 1);
  56423. vertices.push(-1, -1);
  56424. vertices.push(1, -1);
  56425. _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);
  56426. _this._createIndexBuffer();
  56427. return _this;
  56428. }
  56429. /**
  56430. * The effect that is created when initializing the post process.
  56431. * @returns The created effect corrisponding the the postprocess.
  56432. */
  56433. ProceduralTexture.prototype.getEffect = function () {
  56434. return this._effect;
  56435. };
  56436. /**
  56437. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  56438. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  56439. */
  56440. ProceduralTexture.prototype.getContent = function () {
  56441. if (this._contentData && this._currentRefreshId == this._contentUpdateId) {
  56442. return this._contentData;
  56443. }
  56444. this._contentData = this.readPixels(0, 0, this._contentData);
  56445. this._contentUpdateId = this._currentRefreshId;
  56446. return this._contentData;
  56447. };
  56448. ProceduralTexture.prototype._createIndexBuffer = function () {
  56449. var engine = this._engine;
  56450. // Indices
  56451. var indices = [];
  56452. indices.push(0);
  56453. indices.push(1);
  56454. indices.push(2);
  56455. indices.push(0);
  56456. indices.push(2);
  56457. indices.push(3);
  56458. this._indexBuffer = engine.createIndexBuffer(indices);
  56459. };
  56460. /** @hidden */
  56461. ProceduralTexture.prototype._rebuild = function () {
  56462. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  56463. if (vb) {
  56464. vb._rebuild();
  56465. }
  56466. this._createIndexBuffer();
  56467. if (this.refreshRate === _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE) {
  56468. this.refreshRate = _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE;
  56469. }
  56470. };
  56471. /**
  56472. * Resets the texture in order to recreate its associated resources.
  56473. * This can be called in case of context loss
  56474. */
  56475. ProceduralTexture.prototype.reset = function () {
  56476. if (this._effect === undefined) {
  56477. return;
  56478. }
  56479. var engine = this._engine;
  56480. engine._releaseEffect(this._effect);
  56481. };
  56482. ProceduralTexture.prototype._getDefines = function () {
  56483. return "";
  56484. };
  56485. /**
  56486. * Is the texture ready to be used ? (rendered at least once)
  56487. * @returns true if ready, otherwise, false.
  56488. */
  56489. ProceduralTexture.prototype.isReady = function () {
  56490. var _this = this;
  56491. var engine = this._engine;
  56492. var shaders;
  56493. if (!this._fragment) {
  56494. return false;
  56495. }
  56496. if (this._fallbackTextureUsed) {
  56497. return true;
  56498. }
  56499. var defines = this._getDefines();
  56500. if (this._effect && defines === this._cachedDefines && this._effect.isReady()) {
  56501. return true;
  56502. }
  56503. if (this._fragment.fragmentElement !== undefined) {
  56504. shaders = { vertex: "procedural", fragmentElement: this._fragment.fragmentElement };
  56505. }
  56506. else {
  56507. shaders = { vertex: "procedural", fragment: this._fragment };
  56508. }
  56509. this._cachedDefines = defines;
  56510. this._effect = engine.createEffect(shaders, [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], this._uniforms, this._samplers, defines, undefined, undefined, function () {
  56511. _this.releaseInternalTexture();
  56512. if (_this._fallbackTexture) {
  56513. _this._texture = _this._fallbackTexture._texture;
  56514. if (_this._texture) {
  56515. _this._texture.incrementReferences();
  56516. }
  56517. }
  56518. _this._fallbackTextureUsed = true;
  56519. });
  56520. return this._effect.isReady();
  56521. };
  56522. /**
  56523. * Resets the refresh counter of the texture and start bak from scratch.
  56524. * Could be useful to regenerate the texture if it is setup to render only once.
  56525. */
  56526. ProceduralTexture.prototype.resetRefreshCounter = function () {
  56527. this._currentRefreshId = -1;
  56528. };
  56529. /**
  56530. * Set the fragment shader to use in order to render the texture.
  56531. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  56532. */
  56533. ProceduralTexture.prototype.setFragment = function (fragment) {
  56534. this._fragment = fragment;
  56535. };
  56536. Object.defineProperty(ProceduralTexture.prototype, "refreshRate", {
  56537. /**
  56538. * Define the refresh rate of the texture or the rendering frequency.
  56539. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  56540. */
  56541. get: function () {
  56542. return this._refreshRate;
  56543. },
  56544. set: function (value) {
  56545. this._refreshRate = value;
  56546. this.resetRefreshCounter();
  56547. },
  56548. enumerable: true,
  56549. configurable: true
  56550. });
  56551. /** @hidden */
  56552. ProceduralTexture.prototype._shouldRender = function () {
  56553. if (!this.isEnabled || !this.isReady() || !this._texture) {
  56554. if (this._texture) {
  56555. this._texture.isReady = false;
  56556. }
  56557. return false;
  56558. }
  56559. if (this._fallbackTextureUsed) {
  56560. return false;
  56561. }
  56562. if (this._currentRefreshId === -1) { // At least render once
  56563. this._currentRefreshId = 1;
  56564. return true;
  56565. }
  56566. if (this.refreshRate === this._currentRefreshId) {
  56567. this._currentRefreshId = 1;
  56568. return true;
  56569. }
  56570. this._currentRefreshId++;
  56571. return false;
  56572. };
  56573. /**
  56574. * Get the size the texture is rendering at.
  56575. * @returns the size (texture is always squared)
  56576. */
  56577. ProceduralTexture.prototype.getRenderSize = function () {
  56578. return this._size;
  56579. };
  56580. /**
  56581. * Resize the texture to new value.
  56582. * @param size Define the new size the texture should have
  56583. * @param generateMipMaps Define whether the new texture should create mip maps
  56584. */
  56585. ProceduralTexture.prototype.resize = function (size, generateMipMaps) {
  56586. if (this._fallbackTextureUsed) {
  56587. return;
  56588. }
  56589. this.releaseInternalTexture();
  56590. this._texture = this._engine.createRenderTargetTexture(size, generateMipMaps);
  56591. // Update properties
  56592. this._size = size;
  56593. this._generateMipMaps = generateMipMaps;
  56594. };
  56595. ProceduralTexture.prototype._checkUniform = function (uniformName) {
  56596. if (this._uniforms.indexOf(uniformName) === -1) {
  56597. this._uniforms.push(uniformName);
  56598. }
  56599. };
  56600. /**
  56601. * Set a texture in the shader program used to render.
  56602. * @param name Define the name of the uniform samplers as defined in the shader
  56603. * @param texture Define the texture to bind to this sampler
  56604. * @return the texture itself allowing "fluent" like uniform updates
  56605. */
  56606. ProceduralTexture.prototype.setTexture = function (name, texture) {
  56607. if (this._samplers.indexOf(name) === -1) {
  56608. this._samplers.push(name);
  56609. }
  56610. this._textures[name] = texture;
  56611. return this;
  56612. };
  56613. /**
  56614. * Set a float in the shader.
  56615. * @param name Define the name of the uniform as defined in the shader
  56616. * @param value Define the value to give to the uniform
  56617. * @return the texture itself allowing "fluent" like uniform updates
  56618. */
  56619. ProceduralTexture.prototype.setFloat = function (name, value) {
  56620. this._checkUniform(name);
  56621. this._floats[name] = value;
  56622. return this;
  56623. };
  56624. /**
  56625. * Set a int in the shader.
  56626. * @param name Define the name of the uniform as defined in the shader
  56627. * @param value Define the value to give to the uniform
  56628. * @return the texture itself allowing "fluent" like uniform updates
  56629. */
  56630. ProceduralTexture.prototype.setInt = function (name, value) {
  56631. this._checkUniform(name);
  56632. this._ints[name] = value;
  56633. return this;
  56634. };
  56635. /**
  56636. * Set an array of floats in the shader.
  56637. * @param name Define the name of the uniform as defined in the shader
  56638. * @param value Define the value to give to the uniform
  56639. * @return the texture itself allowing "fluent" like uniform updates
  56640. */
  56641. ProceduralTexture.prototype.setFloats = function (name, value) {
  56642. this._checkUniform(name);
  56643. this._floatsArrays[name] = value;
  56644. return this;
  56645. };
  56646. /**
  56647. * Set a vec3 in the shader from a Color3.
  56648. * @param name Define the name of the uniform as defined in the shader
  56649. * @param value Define the value to give to the uniform
  56650. * @return the texture itself allowing "fluent" like uniform updates
  56651. */
  56652. ProceduralTexture.prototype.setColor3 = function (name, value) {
  56653. this._checkUniform(name);
  56654. this._colors3[name] = value;
  56655. return this;
  56656. };
  56657. /**
  56658. * Set a vec4 in the shader from a Color4.
  56659. * @param name Define the name of the uniform as defined in the shader
  56660. * @param value Define the value to give to the uniform
  56661. * @return the texture itself allowing "fluent" like uniform updates
  56662. */
  56663. ProceduralTexture.prototype.setColor4 = function (name, value) {
  56664. this._checkUniform(name);
  56665. this._colors4[name] = value;
  56666. return this;
  56667. };
  56668. /**
  56669. * Set a vec2 in the shader from a Vector2.
  56670. * @param name Define the name of the uniform as defined in the shader
  56671. * @param value Define the value to give to the uniform
  56672. * @return the texture itself allowing "fluent" like uniform updates
  56673. */
  56674. ProceduralTexture.prototype.setVector2 = function (name, value) {
  56675. this._checkUniform(name);
  56676. this._vectors2[name] = value;
  56677. return this;
  56678. };
  56679. /**
  56680. * Set a vec3 in the shader from a Vector3.
  56681. * @param name Define the name of the uniform as defined in the shader
  56682. * @param value Define the value to give to the uniform
  56683. * @return the texture itself allowing "fluent" like uniform updates
  56684. */
  56685. ProceduralTexture.prototype.setVector3 = function (name, value) {
  56686. this._checkUniform(name);
  56687. this._vectors3[name] = value;
  56688. return this;
  56689. };
  56690. /**
  56691. * Set a mat4 in the shader from a MAtrix.
  56692. * @param name Define the name of the uniform as defined in the shader
  56693. * @param value Define the value to give to the uniform
  56694. * @return the texture itself allowing "fluent" like uniform updates
  56695. */
  56696. ProceduralTexture.prototype.setMatrix = function (name, value) {
  56697. this._checkUniform(name);
  56698. this._matrices[name] = value;
  56699. return this;
  56700. };
  56701. /**
  56702. * Render the texture to its associated render target.
  56703. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56704. */
  56705. ProceduralTexture.prototype.render = function (useCameraPostProcess) {
  56706. var scene = this.getScene();
  56707. if (!scene) {
  56708. return;
  56709. }
  56710. var engine = this._engine;
  56711. // Render
  56712. engine.enableEffect(this._effect);
  56713. engine.setState(false);
  56714. // Texture
  56715. for (var name in this._textures) {
  56716. this._effect.setTexture(name, this._textures[name]);
  56717. }
  56718. // Float
  56719. for (name in this._ints) {
  56720. this._effect.setInt(name, this._ints[name]);
  56721. }
  56722. // Float
  56723. for (name in this._floats) {
  56724. this._effect.setFloat(name, this._floats[name]);
  56725. }
  56726. // Floats
  56727. for (name in this._floatsArrays) {
  56728. this._effect.setArray(name, this._floatsArrays[name]);
  56729. }
  56730. // Color3
  56731. for (name in this._colors3) {
  56732. this._effect.setColor3(name, this._colors3[name]);
  56733. }
  56734. // Color4
  56735. for (name in this._colors4) {
  56736. var color = this._colors4[name];
  56737. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  56738. }
  56739. // Vector2
  56740. for (name in this._vectors2) {
  56741. this._effect.setVector2(name, this._vectors2[name]);
  56742. }
  56743. // Vector3
  56744. for (name in this._vectors3) {
  56745. this._effect.setVector3(name, this._vectors3[name]);
  56746. }
  56747. // Matrix
  56748. for (name in this._matrices) {
  56749. this._effect.setMatrix(name, this._matrices[name]);
  56750. }
  56751. if (!this._texture) {
  56752. return;
  56753. }
  56754. if (this.isCube) {
  56755. for (var face = 0; face < 6; face++) {
  56756. engine.bindFramebuffer(this._texture, face, undefined, undefined, true);
  56757. // VBOs
  56758. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  56759. this._effect.setFloat("face", face);
  56760. // Clear
  56761. if (this.autoClear) {
  56762. engine.clear(scene.clearColor, true, false, false);
  56763. }
  56764. // Draw order
  56765. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  56766. // Mipmaps
  56767. if (face === 5) {
  56768. engine.generateMipMapsForCubemap(this._texture);
  56769. }
  56770. }
  56771. }
  56772. else {
  56773. engine.bindFramebuffer(this._texture, 0, undefined, undefined, true);
  56774. // VBOs
  56775. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  56776. // Clear
  56777. if (this.autoClear) {
  56778. engine.clear(scene.clearColor, true, false, false);
  56779. }
  56780. // Draw order
  56781. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  56782. }
  56783. // Unbind
  56784. engine.unBindFramebuffer(this._texture, this.isCube);
  56785. if (this.onGenerated) {
  56786. this.onGenerated();
  56787. }
  56788. this.onGeneratedObservable.notifyObservers(this);
  56789. };
  56790. /**
  56791. * Clone the texture.
  56792. * @returns the cloned texture
  56793. */
  56794. ProceduralTexture.prototype.clone = function () {
  56795. var textureSize = this.getSize();
  56796. var newTexture = new ProceduralTexture(this.name, textureSize.width, this._fragment, this.getScene(), this._fallbackTexture, this._generateMipMaps);
  56797. // Base texture
  56798. newTexture.hasAlpha = this.hasAlpha;
  56799. newTexture.level = this.level;
  56800. // RenderTarget Texture
  56801. newTexture.coordinatesMode = this.coordinatesMode;
  56802. return newTexture;
  56803. };
  56804. /**
  56805. * Dispose the texture and release its asoociated resources.
  56806. */
  56807. ProceduralTexture.prototype.dispose = function () {
  56808. var scene = this.getScene();
  56809. if (!scene) {
  56810. return;
  56811. }
  56812. var index = scene.proceduralTextures.indexOf(this);
  56813. if (index >= 0) {
  56814. scene.proceduralTextures.splice(index, 1);
  56815. }
  56816. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  56817. if (vertexBuffer) {
  56818. vertexBuffer.dispose();
  56819. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  56820. }
  56821. if (this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer)) {
  56822. this._indexBuffer = null;
  56823. }
  56824. _super.prototype.dispose.call(this);
  56825. };
  56826. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56827. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56828. ], ProceduralTexture.prototype, "isEnabled", void 0);
  56829. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56830. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56831. ], ProceduralTexture.prototype, "autoClear", void 0);
  56832. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56833. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56834. ], ProceduralTexture.prototype, "_generateMipMaps", void 0);
  56835. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56836. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56837. ], ProceduralTexture.prototype, "_size", void 0);
  56838. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56839. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56840. ], ProceduralTexture.prototype, "refreshRate", null);
  56841. return ProceduralTexture;
  56842. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"]));
  56843. /***/ }),
  56844. /***/ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts":
  56845. /*!***************************************************************************!*\
  56846. !*** ./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts ***!
  56847. \***************************************************************************/
  56848. /*! exports provided: ProceduralTextureSceneComponent */
  56849. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56850. "use strict";
  56851. __webpack_require__.r(__webpack_exports__);
  56852. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return ProceduralTextureSceneComponent; });
  56853. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  56854. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  56855. /**
  56856. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  56857. * in a given scene.
  56858. */
  56859. var ProceduralTextureSceneComponent = /** @class */ (function () {
  56860. /**
  56861. * Creates a new instance of the component for the given scene
  56862. * @param scene Defines the scene to register the component in
  56863. */
  56864. function ProceduralTextureSceneComponent(scene) {
  56865. /**
  56866. * The component name helpfull to identify the component in the list of scene components.
  56867. */
  56868. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE;
  56869. this.scene = scene;
  56870. this.scene.proceduralTextures = new Array();
  56871. scene.layers = new Array();
  56872. }
  56873. /**
  56874. * Registers the component in a given scene
  56875. */
  56876. ProceduralTextureSceneComponent.prototype.register = function () {
  56877. this.scene._beforeClearStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear);
  56878. };
  56879. /**
  56880. * Rebuilds the elements related to this component in case of
  56881. * context lost for instance.
  56882. */
  56883. ProceduralTextureSceneComponent.prototype.rebuild = function () {
  56884. // Nothing to do here.
  56885. };
  56886. /**
  56887. * Disposes the component and the associated ressources.
  56888. */
  56889. ProceduralTextureSceneComponent.prototype.dispose = function () {
  56890. // Nothing to do here.
  56891. };
  56892. ProceduralTextureSceneComponent.prototype._beforeClear = function () {
  56893. if (this.scene.proceduralTexturesEnabled) {
  56894. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  56895. for (var proceduralIndex = 0; proceduralIndex < this.scene.proceduralTextures.length; proceduralIndex++) {
  56896. var proceduralTexture = this.scene.proceduralTextures[proceduralIndex];
  56897. if (proceduralTexture._shouldRender()) {
  56898. proceduralTexture.render();
  56899. }
  56900. }
  56901. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  56902. }
  56903. };
  56904. return ProceduralTextureSceneComponent;
  56905. }());
  56906. /***/ }),
  56907. /***/ "./Materials/Textures/baseTexture.ts":
  56908. /*!*******************************************!*\
  56909. !*** ./Materials/Textures/baseTexture.ts ***!
  56910. \*******************************************/
  56911. /*! exports provided: BaseTexture */
  56912. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56913. "use strict";
  56914. __webpack_require__.r(__webpack_exports__);
  56915. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return BaseTexture; });
  56916. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56917. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  56918. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  56919. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  56920. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  56921. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  56922. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  56923. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56924. /**
  56925. * Base class of all the textures in babylon.
  56926. * It groups all the common properties the materials, post process, lights... might need
  56927. * in order to make a correct use of the texture.
  56928. */
  56929. var BaseTexture = /** @class */ (function () {
  56930. /**
  56931. * Instantiates a new BaseTexture.
  56932. * Base class of all the textures in babylon.
  56933. * It groups all the common properties the materials, post process, lights... might need
  56934. * in order to make a correct use of the texture.
  56935. * @param scene Define the scene the texture blongs to
  56936. */
  56937. function BaseTexture(scene) {
  56938. /**
  56939. * Gets or sets an object used to store user defined information.
  56940. */
  56941. this.metadata = null;
  56942. /**
  56943. * For internal use only. Please do not use.
  56944. */
  56945. this.reservedDataStore = null;
  56946. this._hasAlpha = false;
  56947. /**
  56948. * Defines if the alpha value should be determined via the rgb values.
  56949. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  56950. */
  56951. this.getAlphaFromRGB = false;
  56952. /**
  56953. * Intensity or strength of the texture.
  56954. * It is commonly used by materials to fine tune the intensity of the texture
  56955. */
  56956. this.level = 1;
  56957. /**
  56958. * Define the UV chanel to use starting from 0 and defaulting to 0.
  56959. * This is part of the texture as textures usually maps to one uv set.
  56960. */
  56961. this.coordinatesIndex = 0;
  56962. this._coordinatesMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_EXPLICIT_MODE;
  56963. /**
  56964. * | Value | Type | Description |
  56965. * | ----- | ------------------ | ----------- |
  56966. * | 0 | CLAMP_ADDRESSMODE | |
  56967. * | 1 | WRAP_ADDRESSMODE | |
  56968. * | 2 | MIRROR_ADDRESSMODE | |
  56969. */
  56970. this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  56971. /**
  56972. * | Value | Type | Description |
  56973. * | ----- | ------------------ | ----------- |
  56974. * | 0 | CLAMP_ADDRESSMODE | |
  56975. * | 1 | WRAP_ADDRESSMODE | |
  56976. * | 2 | MIRROR_ADDRESSMODE | |
  56977. */
  56978. this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  56979. /**
  56980. * | Value | Type | Description |
  56981. * | ----- | ------------------ | ----------- |
  56982. * | 0 | CLAMP_ADDRESSMODE | |
  56983. * | 1 | WRAP_ADDRESSMODE | |
  56984. * | 2 | MIRROR_ADDRESSMODE | |
  56985. */
  56986. this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  56987. /**
  56988. * With compliant hardware and browser (supporting anisotropic filtering)
  56989. * this defines the level of anisotropic filtering in the texture.
  56990. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  56991. */
  56992. this.anisotropicFilteringLevel = BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL;
  56993. /**
  56994. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  56995. * HDR texture are usually stored in linear space.
  56996. * This only impacts the PBR and Background materials
  56997. */
  56998. this.gammaSpace = true;
  56999. /**
  57000. * Is Z inverted in the texture (useful in a cube texture).
  57001. */
  57002. this.invertZ = false;
  57003. /**
  57004. * @hidden
  57005. */
  57006. this.lodLevelInAlpha = false;
  57007. /**
  57008. * Define if the texture is a render target.
  57009. */
  57010. this.isRenderTarget = false;
  57011. /**
  57012. * Define the list of animation attached to the texture.
  57013. */
  57014. this.animations = new Array();
  57015. /**
  57016. * An event triggered when the texture is disposed.
  57017. */
  57018. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  57019. /**
  57020. * Define the current state of the loading sequence when in delayed load mode.
  57021. */
  57022. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  57023. this._cachedSize = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  57024. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  57025. if (this._scene) {
  57026. this.uniqueId = this._scene.getUniqueId();
  57027. this._scene.addTexture(this);
  57028. }
  57029. this._uid = null;
  57030. }
  57031. Object.defineProperty(BaseTexture.prototype, "hasAlpha", {
  57032. get: function () {
  57033. return this._hasAlpha;
  57034. },
  57035. /**
  57036. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  57037. */
  57038. set: function (value) {
  57039. if (this._hasAlpha === value) {
  57040. return;
  57041. }
  57042. this._hasAlpha = value;
  57043. if (this._scene) {
  57044. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag | _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_MiscDirtyFlag);
  57045. }
  57046. },
  57047. enumerable: true,
  57048. configurable: true
  57049. });
  57050. Object.defineProperty(BaseTexture.prototype, "coordinatesMode", {
  57051. get: function () {
  57052. return this._coordinatesMode;
  57053. },
  57054. /**
  57055. * How a texture is mapped.
  57056. *
  57057. * | Value | Type | Description |
  57058. * | ----- | ----------------------------------- | ----------- |
  57059. * | 0 | EXPLICIT_MODE | |
  57060. * | 1 | SPHERICAL_MODE | |
  57061. * | 2 | PLANAR_MODE | |
  57062. * | 3 | CUBIC_MODE | |
  57063. * | 4 | PROJECTION_MODE | |
  57064. * | 5 | SKYBOX_MODE | |
  57065. * | 6 | INVCUBIC_MODE | |
  57066. * | 7 | EQUIRECTANGULAR_MODE | |
  57067. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  57068. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  57069. */
  57070. set: function (value) {
  57071. if (this._coordinatesMode === value) {
  57072. return;
  57073. }
  57074. this._coordinatesMode = value;
  57075. if (this._scene) {
  57076. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  57077. }
  57078. },
  57079. enumerable: true,
  57080. configurable: true
  57081. });
  57082. Object.defineProperty(BaseTexture.prototype, "isCube", {
  57083. /**
  57084. * Define if the texture is a cube texture or if false a 2d texture.
  57085. */
  57086. get: function () {
  57087. if (!this._texture) {
  57088. return false;
  57089. }
  57090. return this._texture.isCube;
  57091. },
  57092. set: function (value) {
  57093. if (!this._texture) {
  57094. return;
  57095. }
  57096. this._texture.isCube = value;
  57097. },
  57098. enumerable: true,
  57099. configurable: true
  57100. });
  57101. Object.defineProperty(BaseTexture.prototype, "is3D", {
  57102. /**
  57103. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  57104. */
  57105. get: function () {
  57106. if (!this._texture) {
  57107. return false;
  57108. }
  57109. return this._texture.is3D;
  57110. },
  57111. set: function (value) {
  57112. if (!this._texture) {
  57113. return;
  57114. }
  57115. this._texture.is3D = value;
  57116. },
  57117. enumerable: true,
  57118. configurable: true
  57119. });
  57120. Object.defineProperty(BaseTexture.prototype, "isRGBD", {
  57121. /**
  57122. * Gets whether or not the texture contains RGBD data.
  57123. */
  57124. get: function () {
  57125. return this._texture != null && this._texture._isRGBD;
  57126. },
  57127. enumerable: true,
  57128. configurable: true
  57129. });
  57130. Object.defineProperty(BaseTexture.prototype, "noMipmap", {
  57131. /**
  57132. * Are mip maps generated for this texture or not.
  57133. */
  57134. get: function () {
  57135. return false;
  57136. },
  57137. enumerable: true,
  57138. configurable: true
  57139. });
  57140. Object.defineProperty(BaseTexture.prototype, "lodGenerationOffset", {
  57141. /**
  57142. * With prefiltered texture, defined the offset used during the prefiltering steps.
  57143. */
  57144. get: function () {
  57145. if (this._texture) {
  57146. return this._texture._lodGenerationOffset;
  57147. }
  57148. return 0.0;
  57149. },
  57150. set: function (value) {
  57151. if (this._texture) {
  57152. this._texture._lodGenerationOffset = value;
  57153. }
  57154. },
  57155. enumerable: true,
  57156. configurable: true
  57157. });
  57158. Object.defineProperty(BaseTexture.prototype, "lodGenerationScale", {
  57159. /**
  57160. * With prefiltered texture, defined the scale used during the prefiltering steps.
  57161. */
  57162. get: function () {
  57163. if (this._texture) {
  57164. return this._texture._lodGenerationScale;
  57165. }
  57166. return 0.0;
  57167. },
  57168. set: function (value) {
  57169. if (this._texture) {
  57170. this._texture._lodGenerationScale = value;
  57171. }
  57172. },
  57173. enumerable: true,
  57174. configurable: true
  57175. });
  57176. Object.defineProperty(BaseTexture.prototype, "uid", {
  57177. /**
  57178. * Define the unique id of the texture in the scene.
  57179. */
  57180. get: function () {
  57181. if (!this._uid) {
  57182. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].RandomId();
  57183. }
  57184. return this._uid;
  57185. },
  57186. enumerable: true,
  57187. configurable: true
  57188. });
  57189. /**
  57190. * Return a string representation of the texture.
  57191. * @returns the texture as a string
  57192. */
  57193. BaseTexture.prototype.toString = function () {
  57194. return this.name;
  57195. };
  57196. /**
  57197. * Get the class name of the texture.
  57198. * @returns "BaseTexture"
  57199. */
  57200. BaseTexture.prototype.getClassName = function () {
  57201. return "BaseTexture";
  57202. };
  57203. Object.defineProperty(BaseTexture.prototype, "onDispose", {
  57204. /**
  57205. * Callback triggered when the texture has been disposed.
  57206. * Kept for back compatibility, you can use the onDisposeObservable instead.
  57207. */
  57208. set: function (callback) {
  57209. if (this._onDisposeObserver) {
  57210. this.onDisposeObservable.remove(this._onDisposeObserver);
  57211. }
  57212. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  57213. },
  57214. enumerable: true,
  57215. configurable: true
  57216. });
  57217. Object.defineProperty(BaseTexture.prototype, "isBlocking", {
  57218. /**
  57219. * Define if the texture is preventinga material to render or not.
  57220. * If not and the texture is not ready, the engine will use a default black texture instead.
  57221. */
  57222. get: function () {
  57223. return true;
  57224. },
  57225. enumerable: true,
  57226. configurable: true
  57227. });
  57228. /**
  57229. * Get the scene the texture belongs to.
  57230. * @returns the scene or null if undefined
  57231. */
  57232. BaseTexture.prototype.getScene = function () {
  57233. return this._scene;
  57234. };
  57235. /**
  57236. * Get the texture transform matrix used to offset tile the texture for istance.
  57237. * @returns the transformation matrix
  57238. */
  57239. BaseTexture.prototype.getTextureMatrix = function () {
  57240. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  57241. };
  57242. /**
  57243. * Get the texture reflection matrix used to rotate/transform the reflection.
  57244. * @returns the reflection matrix
  57245. */
  57246. BaseTexture.prototype.getReflectionTextureMatrix = function () {
  57247. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  57248. };
  57249. /**
  57250. * Get the underlying lower level texture from Babylon.
  57251. * @returns the insternal texture
  57252. */
  57253. BaseTexture.prototype.getInternalTexture = function () {
  57254. return this._texture;
  57255. };
  57256. /**
  57257. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  57258. * @returns true if ready or not blocking
  57259. */
  57260. BaseTexture.prototype.isReadyOrNotBlocking = function () {
  57261. return !this.isBlocking || this.isReady();
  57262. };
  57263. /**
  57264. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  57265. * @returns true if fully ready
  57266. */
  57267. BaseTexture.prototype.isReady = function () {
  57268. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  57269. this.delayLoad();
  57270. return false;
  57271. }
  57272. if (this._texture) {
  57273. return this._texture.isReady;
  57274. }
  57275. return false;
  57276. };
  57277. /**
  57278. * Get the size of the texture.
  57279. * @returns the texture size.
  57280. */
  57281. BaseTexture.prototype.getSize = function () {
  57282. if (this._texture) {
  57283. if (this._texture.width) {
  57284. this._cachedSize.width = this._texture.width;
  57285. this._cachedSize.height = this._texture.height;
  57286. return this._cachedSize;
  57287. }
  57288. if (this._texture._size) {
  57289. this._cachedSize.width = this._texture._size;
  57290. this._cachedSize.height = this._texture._size;
  57291. return this._cachedSize;
  57292. }
  57293. }
  57294. return this._cachedSize;
  57295. };
  57296. /**
  57297. * Get the base size of the texture.
  57298. * It can be different from the size if the texture has been resized for POT for instance
  57299. * @returns the base size
  57300. */
  57301. BaseTexture.prototype.getBaseSize = function () {
  57302. if (!this.isReady() || !this._texture) {
  57303. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  57304. }
  57305. if (this._texture._size) {
  57306. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture._size, this._texture._size);
  57307. }
  57308. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture.baseWidth, this._texture.baseHeight);
  57309. };
  57310. /**
  57311. * Update the sampling mode of the texture.
  57312. * Default is Trilinear mode.
  57313. *
  57314. * | Value | Type | Description |
  57315. * | ----- | ------------------ | ----------- |
  57316. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  57317. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  57318. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  57319. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  57320. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  57321. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  57322. * | 7 | NEAREST_LINEAR | |
  57323. * | 8 | NEAREST_NEAREST | |
  57324. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  57325. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  57326. * | 11 | LINEAR_LINEAR | |
  57327. * | 12 | LINEAR_NEAREST | |
  57328. *
  57329. * > _mag_: magnification filter (close to the viewer)
  57330. * > _min_: minification filter (far from the viewer)
  57331. * > _mip_: filter used between mip map levels
  57332. *@param samplingMode Define the new sampling mode of the texture
  57333. */
  57334. BaseTexture.prototype.updateSamplingMode = function (samplingMode) {
  57335. if (!this._texture) {
  57336. return;
  57337. }
  57338. var scene = this.getScene();
  57339. if (!scene) {
  57340. return;
  57341. }
  57342. scene.getEngine().updateTextureSamplingMode(samplingMode, this._texture);
  57343. };
  57344. /**
  57345. * Scales the texture if is `canRescale()`
  57346. * @param ratio the resize factor we want to use to rescale
  57347. */
  57348. BaseTexture.prototype.scale = function (ratio) {
  57349. };
  57350. Object.defineProperty(BaseTexture.prototype, "canRescale", {
  57351. /**
  57352. * Get if the texture can rescale.
  57353. */
  57354. get: function () {
  57355. return false;
  57356. },
  57357. enumerable: true,
  57358. configurable: true
  57359. });
  57360. /** @hidden */
  57361. BaseTexture.prototype._getFromCache = function (url, noMipmap, sampling, invertY) {
  57362. if (!this._scene) {
  57363. return null;
  57364. }
  57365. var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
  57366. for (var index = 0; index < texturesCache.length; index++) {
  57367. var texturesCacheEntry = texturesCache[index];
  57368. if (invertY === undefined || invertY === texturesCacheEntry.invertY) {
  57369. if (texturesCacheEntry.url === url && texturesCacheEntry.generateMipMaps === !noMipmap) {
  57370. if (!sampling || sampling === texturesCacheEntry.samplingMode) {
  57371. texturesCacheEntry.incrementReferences();
  57372. return texturesCacheEntry;
  57373. }
  57374. }
  57375. }
  57376. }
  57377. return null;
  57378. };
  57379. /** @hidden */
  57380. BaseTexture.prototype._rebuild = function () {
  57381. };
  57382. /**
  57383. * Triggers the load sequence in delayed load mode.
  57384. */
  57385. BaseTexture.prototype.delayLoad = function () {
  57386. };
  57387. /**
  57388. * Clones the texture.
  57389. * @returns the cloned texture
  57390. */
  57391. BaseTexture.prototype.clone = function () {
  57392. return null;
  57393. };
  57394. Object.defineProperty(BaseTexture.prototype, "textureType", {
  57395. /**
  57396. * Get the texture underlying type (INT, FLOAT...)
  57397. */
  57398. get: function () {
  57399. if (!this._texture) {
  57400. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  57401. }
  57402. return (this._texture.type !== undefined) ? this._texture.type : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  57403. },
  57404. enumerable: true,
  57405. configurable: true
  57406. });
  57407. Object.defineProperty(BaseTexture.prototype, "textureFormat", {
  57408. /**
  57409. * Get the texture underlying format (RGB, RGBA...)
  57410. */
  57411. get: function () {
  57412. if (!this._texture) {
  57413. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  57414. }
  57415. return (this._texture.format !== undefined) ? this._texture.format : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  57416. },
  57417. enumerable: true,
  57418. configurable: true
  57419. });
  57420. /**
  57421. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  57422. * This will returns an RGBA array buffer containing either in values (0-255) or
  57423. * float values (0-1) depending of the underlying buffer type.
  57424. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  57425. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  57426. * @param buffer defines a user defined buffer to fill with data (can be null)
  57427. * @returns The Array buffer containing the pixels data.
  57428. */
  57429. BaseTexture.prototype.readPixels = function (faceIndex, level, buffer) {
  57430. if (faceIndex === void 0) { faceIndex = 0; }
  57431. if (level === void 0) { level = 0; }
  57432. if (buffer === void 0) { buffer = null; }
  57433. if (!this._texture) {
  57434. return null;
  57435. }
  57436. var size = this.getSize();
  57437. var width = size.width;
  57438. var height = size.height;
  57439. var scene = this.getScene();
  57440. if (!scene) {
  57441. return null;
  57442. }
  57443. var engine = scene.getEngine();
  57444. if (level != 0) {
  57445. width = width / Math.pow(2, level);
  57446. height = height / Math.pow(2, level);
  57447. width = Math.round(width);
  57448. height = Math.round(height);
  57449. }
  57450. if (this._texture.isCube) {
  57451. return engine._readTexturePixels(this._texture, width, height, faceIndex, level, buffer);
  57452. }
  57453. return engine._readTexturePixels(this._texture, width, height, -1, level, buffer);
  57454. };
  57455. /**
  57456. * Release and destroy the underlying lower level texture aka internalTexture.
  57457. */
  57458. BaseTexture.prototype.releaseInternalTexture = function () {
  57459. if (this._texture) {
  57460. this._texture.dispose();
  57461. this._texture = null;
  57462. }
  57463. };
  57464. Object.defineProperty(BaseTexture.prototype, "sphericalPolynomial", {
  57465. /**
  57466. * Get the polynomial representation of the texture data.
  57467. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  57468. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  57469. */
  57470. get: function () {
  57471. if (!this._texture || !_Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"] || !this.isReady()) {
  57472. return null;
  57473. }
  57474. if (!this._texture._sphericalPolynomial) {
  57475. this._texture._sphericalPolynomial =
  57476. _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapTextureToSphericalPolynomial(this);
  57477. }
  57478. return this._texture._sphericalPolynomial;
  57479. },
  57480. set: function (value) {
  57481. if (this._texture) {
  57482. this._texture._sphericalPolynomial = value;
  57483. }
  57484. },
  57485. enumerable: true,
  57486. configurable: true
  57487. });
  57488. Object.defineProperty(BaseTexture.prototype, "_lodTextureHigh", {
  57489. /** @hidden */
  57490. get: function () {
  57491. if (this._texture) {
  57492. return this._texture._lodTextureHigh;
  57493. }
  57494. return null;
  57495. },
  57496. enumerable: true,
  57497. configurable: true
  57498. });
  57499. Object.defineProperty(BaseTexture.prototype, "_lodTextureMid", {
  57500. /** @hidden */
  57501. get: function () {
  57502. if (this._texture) {
  57503. return this._texture._lodTextureMid;
  57504. }
  57505. return null;
  57506. },
  57507. enumerable: true,
  57508. configurable: true
  57509. });
  57510. Object.defineProperty(BaseTexture.prototype, "_lodTextureLow", {
  57511. /** @hidden */
  57512. get: function () {
  57513. if (this._texture) {
  57514. return this._texture._lodTextureLow;
  57515. }
  57516. return null;
  57517. },
  57518. enumerable: true,
  57519. configurable: true
  57520. });
  57521. /**
  57522. * Dispose the texture and release its associated resources.
  57523. */
  57524. BaseTexture.prototype.dispose = function () {
  57525. if (!this._scene) {
  57526. return;
  57527. }
  57528. // Animations
  57529. this._scene.stopAnimation(this);
  57530. // Remove from scene
  57531. this._scene._removePendingData(this);
  57532. var index = this._scene.textures.indexOf(this);
  57533. if (index >= 0) {
  57534. this._scene.textures.splice(index, 1);
  57535. }
  57536. this._scene.onTextureRemovedObservable.notifyObservers(this);
  57537. if (this._texture === undefined) {
  57538. return;
  57539. }
  57540. // Release
  57541. this.releaseInternalTexture();
  57542. // Callback
  57543. this.onDisposeObservable.notifyObservers(this);
  57544. this.onDisposeObservable.clear();
  57545. };
  57546. /**
  57547. * Serialize the texture into a JSON representation that can be parsed later on.
  57548. * @returns the JSON representation of the texture
  57549. */
  57550. BaseTexture.prototype.serialize = function () {
  57551. if (!this.name) {
  57552. return null;
  57553. }
  57554. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  57555. // Animations
  57556. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  57557. return serializationObject;
  57558. };
  57559. /**
  57560. * Helper function to be called back once a list of texture contains only ready textures.
  57561. * @param textures Define the list of textures to wait for
  57562. * @param callback Define the callback triggered once the entire list will be ready
  57563. */
  57564. BaseTexture.WhenAllReady = function (textures, callback) {
  57565. var numRemaining = textures.length;
  57566. if (numRemaining === 0) {
  57567. callback();
  57568. return;
  57569. }
  57570. var _loop_1 = function () {
  57571. texture = textures[i];
  57572. if (texture.isReady()) {
  57573. if (--numRemaining === 0) {
  57574. callback();
  57575. }
  57576. }
  57577. else {
  57578. onLoadObservable = texture.onLoadObservable;
  57579. var onLoadCallback_1 = function () {
  57580. onLoadObservable.removeCallback(onLoadCallback_1);
  57581. if (--numRemaining === 0) {
  57582. callback();
  57583. }
  57584. };
  57585. onLoadObservable.add(onLoadCallback_1);
  57586. }
  57587. };
  57588. var texture, onLoadObservable;
  57589. for (var i = 0; i < textures.length; i++) {
  57590. _loop_1();
  57591. }
  57592. };
  57593. /**
  57594. * Default anisotropic filtering level for the application.
  57595. * It is set to 4 as a good tradeoff between perf and quality.
  57596. */
  57597. BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4;
  57598. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57599. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57600. ], BaseTexture.prototype, "uniqueId", void 0);
  57601. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57602. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57603. ], BaseTexture.prototype, "name", void 0);
  57604. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57605. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57606. ], BaseTexture.prototype, "metadata", void 0);
  57607. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57608. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("hasAlpha")
  57609. ], BaseTexture.prototype, "_hasAlpha", void 0);
  57610. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57611. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57612. ], BaseTexture.prototype, "getAlphaFromRGB", void 0);
  57613. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57614. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57615. ], BaseTexture.prototype, "level", void 0);
  57616. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57617. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57618. ], BaseTexture.prototype, "coordinatesIndex", void 0);
  57619. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57620. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("coordinatesMode")
  57621. ], BaseTexture.prototype, "_coordinatesMode", void 0);
  57622. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57623. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57624. ], BaseTexture.prototype, "wrapU", void 0);
  57625. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57626. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57627. ], BaseTexture.prototype, "wrapV", void 0);
  57628. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57629. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57630. ], BaseTexture.prototype, "wrapR", void 0);
  57631. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57632. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57633. ], BaseTexture.prototype, "anisotropicFilteringLevel", void 0);
  57634. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57635. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57636. ], BaseTexture.prototype, "isCube", null);
  57637. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57638. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57639. ], BaseTexture.prototype, "is3D", null);
  57640. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57641. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57642. ], BaseTexture.prototype, "gammaSpace", void 0);
  57643. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57644. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57645. ], BaseTexture.prototype, "invertZ", void 0);
  57646. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57647. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57648. ], BaseTexture.prototype, "lodLevelInAlpha", void 0);
  57649. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57650. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57651. ], BaseTexture.prototype, "lodGenerationOffset", null);
  57652. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57653. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57654. ], BaseTexture.prototype, "lodGenerationScale", null);
  57655. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57656. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57657. ], BaseTexture.prototype, "isRenderTarget", void 0);
  57658. return BaseTexture;
  57659. }());
  57660. /***/ }),
  57661. /***/ "./Materials/Textures/colorGradingTexture.ts":
  57662. /*!***************************************************!*\
  57663. !*** ./Materials/Textures/colorGradingTexture.ts ***!
  57664. \***************************************************/
  57665. /*! exports provided: ColorGradingTexture */
  57666. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57667. "use strict";
  57668. __webpack_require__.r(__webpack_exports__);
  57669. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return ColorGradingTexture; });
  57670. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57671. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  57672. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  57673. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57674. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  57675. /**
  57676. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  57677. * It can help converting any input color in a desired output one. This can then be used to create effects
  57678. * from sepia, black and white to sixties or futuristic rendering...
  57679. *
  57680. * The only supported format is currently 3dl.
  57681. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  57682. */
  57683. var ColorGradingTexture = /** @class */ (function (_super) {
  57684. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorGradingTexture, _super);
  57685. /**
  57686. * Instantiates a ColorGradingTexture from the following parameters.
  57687. *
  57688. * @param url The location of the color gradind data (currently only supporting 3dl)
  57689. * @param scene The scene the texture will be used in
  57690. */
  57691. function ColorGradingTexture(url, scene) {
  57692. var _this = _super.call(this, scene) || this;
  57693. if (!url) {
  57694. return _this;
  57695. }
  57696. _this._engine = scene.getEngine();
  57697. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  57698. _this.name = url;
  57699. _this.url = url;
  57700. _this.hasAlpha = false;
  57701. _this.isCube = false;
  57702. _this.is3D = _this._engine.webGLVersion > 1;
  57703. _this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  57704. _this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  57705. _this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  57706. _this.anisotropicFilteringLevel = 1;
  57707. _this._texture = _this._getFromCache(url, true);
  57708. if (!_this._texture) {
  57709. if (!scene.useDelayedTextureLoading) {
  57710. _this.loadTexture();
  57711. }
  57712. else {
  57713. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED;
  57714. }
  57715. }
  57716. return _this;
  57717. }
  57718. /**
  57719. * Returns the texture matrix used in most of the material.
  57720. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  57721. */
  57722. ColorGradingTexture.prototype.getTextureMatrix = function () {
  57723. return this._textureMatrix;
  57724. };
  57725. /**
  57726. * Occurs when the file being loaded is a .3dl LUT file.
  57727. */
  57728. ColorGradingTexture.prototype.load3dlTexture = function () {
  57729. var engine = this._engine;
  57730. var texture;
  57731. if (engine.webGLVersion === 1) {
  57732. 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);
  57733. }
  57734. else {
  57735. 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);
  57736. }
  57737. this._texture = texture;
  57738. var callback = function (text) {
  57739. if (typeof text !== "string") {
  57740. return;
  57741. }
  57742. var data = null;
  57743. var tempData = null;
  57744. var line;
  57745. var lines = text.split('\n');
  57746. var size = 0, pixelIndexW = 0, pixelIndexH = 0, pixelIndexSlice = 0;
  57747. var maxColor = 0;
  57748. for (var i = 0; i < lines.length; i++) {
  57749. line = lines[i];
  57750. if (!ColorGradingTexture._noneEmptyLineRegex.test(line)) {
  57751. continue;
  57752. }
  57753. if (line.indexOf('#') === 0) {
  57754. continue;
  57755. }
  57756. var words = line.split(" ");
  57757. if (size === 0) {
  57758. // Number of space + one
  57759. size = words.length;
  57760. data = new Uint8Array(size * size * size * 4); // volume texture of side size and rgb 8
  57761. tempData = new Float32Array(size * size * size * 4);
  57762. continue;
  57763. }
  57764. if (size != 0) {
  57765. var r = Math.max(parseInt(words[0]), 0);
  57766. var g = Math.max(parseInt(words[1]), 0);
  57767. var b = Math.max(parseInt(words[2]), 0);
  57768. maxColor = Math.max(r, maxColor);
  57769. maxColor = Math.max(g, maxColor);
  57770. maxColor = Math.max(b, maxColor);
  57771. var pixelStorageIndex = (pixelIndexW + pixelIndexSlice * size + pixelIndexH * size * size) * 4;
  57772. if (tempData) {
  57773. tempData[pixelStorageIndex + 0] = r;
  57774. tempData[pixelStorageIndex + 1] = g;
  57775. tempData[pixelStorageIndex + 2] = b;
  57776. }
  57777. // Keep for reference in case of back compat problems.
  57778. // pixelIndexSlice++;
  57779. // if (pixelIndexSlice % size == 0) {
  57780. // pixelIndexH++;
  57781. // pixelIndexSlice = 0;
  57782. // if (pixelIndexH % size == 0) {
  57783. // pixelIndexW++;
  57784. // pixelIndexH = 0;
  57785. // }
  57786. // }
  57787. pixelIndexH++;
  57788. if (pixelIndexH % size == 0) {
  57789. pixelIndexSlice++;
  57790. pixelIndexH = 0;
  57791. if (pixelIndexSlice % size == 0) {
  57792. pixelIndexW++;
  57793. pixelIndexSlice = 0;
  57794. }
  57795. }
  57796. }
  57797. }
  57798. if (tempData && data) {
  57799. for (var i = 0; i < tempData.length; i++) {
  57800. if (i > 0 && (i + 1) % 4 === 0) {
  57801. data[i] = 255;
  57802. }
  57803. else {
  57804. var value = tempData[i];
  57805. data[i] = (value / maxColor * 255);
  57806. }
  57807. }
  57808. }
  57809. if (texture.is3D) {
  57810. texture.updateSize(size, size, size);
  57811. engine.updateRawTexture3D(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  57812. }
  57813. else {
  57814. texture.updateSize(size * size, size);
  57815. engine.updateRawTexture(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  57816. }
  57817. };
  57818. var scene = this.getScene();
  57819. if (scene) {
  57820. scene._loadFile(this.url, callback);
  57821. }
  57822. else {
  57823. this._engine._loadFile(this.url, callback);
  57824. }
  57825. return this._texture;
  57826. };
  57827. /**
  57828. * Starts the loading process of the texture.
  57829. */
  57830. ColorGradingTexture.prototype.loadTexture = function () {
  57831. if (this.url && this.url.toLocaleLowerCase().indexOf(".3dl") == (this.url.length - 4)) {
  57832. this.load3dlTexture();
  57833. }
  57834. };
  57835. /**
  57836. * Clones the color gradind texture.
  57837. */
  57838. ColorGradingTexture.prototype.clone = function () {
  57839. var newTexture = new ColorGradingTexture(this.url, this.getScene());
  57840. // Base texture
  57841. newTexture.level = this.level;
  57842. return newTexture;
  57843. };
  57844. /**
  57845. * Called during delayed load for textures.
  57846. */
  57847. ColorGradingTexture.prototype.delayLoad = function () {
  57848. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  57849. return;
  57850. }
  57851. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_LOADED;
  57852. this._texture = this._getFromCache(this.url, true);
  57853. if (!this._texture) {
  57854. this.loadTexture();
  57855. }
  57856. };
  57857. /**
  57858. * Parses a color grading texture serialized by Babylon.
  57859. * @param parsedTexture The texture information being parsedTexture
  57860. * @param scene The scene to load the texture in
  57861. * @param rootUrl The root url of the data assets to load
  57862. * @return A color gradind texture
  57863. */
  57864. ColorGradingTexture.Parse = function (parsedTexture, scene) {
  57865. var texture = null;
  57866. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  57867. texture = new ColorGradingTexture(parsedTexture.name, scene);
  57868. texture.name = parsedTexture.name;
  57869. texture.level = parsedTexture.level;
  57870. }
  57871. return texture;
  57872. };
  57873. /**
  57874. * Serializes the LUT texture to json format.
  57875. */
  57876. ColorGradingTexture.prototype.serialize = function () {
  57877. if (!this.name) {
  57878. return null;
  57879. }
  57880. var serializationObject = {};
  57881. serializationObject.name = this.name;
  57882. serializationObject.level = this.level;
  57883. serializationObject.customType = "BABYLON.ColorGradingTexture";
  57884. return serializationObject;
  57885. };
  57886. /**
  57887. * Empty line regex stored for GC.
  57888. */
  57889. ColorGradingTexture._noneEmptyLineRegex = /\S+/;
  57890. return ColorGradingTexture;
  57891. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__["BaseTexture"]));
  57892. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.ColorGradingTexture"] = ColorGradingTexture;
  57893. /***/ }),
  57894. /***/ "./Materials/Textures/cubeTexture.ts":
  57895. /*!*******************************************!*\
  57896. !*** ./Materials/Textures/cubeTexture.ts ***!
  57897. \*******************************************/
  57898. /*! exports provided: CubeTexture */
  57899. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57900. "use strict";
  57901. __webpack_require__.r(__webpack_exports__);
  57902. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return CubeTexture; });
  57903. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57904. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  57905. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  57906. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  57907. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  57908. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57909. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57910. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  57911. /**
  57912. * Class for creating a cube texture
  57913. */
  57914. var CubeTexture = /** @class */ (function (_super) {
  57915. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTexture, _super);
  57916. /**
  57917. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  57918. * as prefiltered data.
  57919. * @param rootUrl defines the url of the texture or the root name of the six images
  57920. * @param scene defines the scene the texture is attached to
  57921. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  57922. * @param noMipmap defines if mipmaps should be created or not
  57923. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  57924. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  57925. * @param onError defines a callback triggered in case of error during load
  57926. * @param format defines the internal format to use for the texture once loaded
  57927. * @param prefiltered defines whether or not the texture is created from prefiltered data
  57928. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  57929. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  57930. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57931. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57932. * @return the cube texture
  57933. */
  57934. function CubeTexture(rootUrl, scene, extensions, noMipmap, files, onLoad, onError, format, prefiltered, forcedExtension, createPolynomials, lodScale, lodOffset) {
  57935. if (extensions === void 0) { extensions = null; }
  57936. if (noMipmap === void 0) { noMipmap = false; }
  57937. if (files === void 0) { files = null; }
  57938. if (onLoad === void 0) { onLoad = null; }
  57939. if (onError === void 0) { onError = null; }
  57940. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  57941. if (prefiltered === void 0) { prefiltered = false; }
  57942. if (forcedExtension === void 0) { forcedExtension = null; }
  57943. if (createPolynomials === void 0) { createPolynomials = false; }
  57944. if (lodScale === void 0) { lodScale = 0.8; }
  57945. if (lodOffset === void 0) { lodOffset = 0; }
  57946. var _this = _super.call(this, scene) || this;
  57947. /**
  57948. * Gets or sets the center of the bounding box associated with the cube texture.
  57949. * It must define where the camera used to render the texture was set
  57950. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  57951. */
  57952. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  57953. _this._rotationY = 0;
  57954. /** @hidden */
  57955. _this._prefiltered = false;
  57956. _this.name = rootUrl;
  57957. _this.url = rootUrl;
  57958. _this._noMipmap = noMipmap;
  57959. _this.hasAlpha = false;
  57960. _this._format = format;
  57961. _this.isCube = true;
  57962. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  57963. _this._createPolynomials = createPolynomials;
  57964. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CUBIC_MODE;
  57965. if (!rootUrl && !files) {
  57966. return _this;
  57967. }
  57968. var lastDot = rootUrl.lastIndexOf(".");
  57969. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  57970. var isDDS = (extension === ".dds");
  57971. var isEnv = (extension === ".env");
  57972. if (isEnv) {
  57973. _this.gammaSpace = false;
  57974. _this._prefiltered = false;
  57975. }
  57976. else {
  57977. _this._prefiltered = prefiltered;
  57978. if (prefiltered) {
  57979. _this.gammaSpace = false;
  57980. }
  57981. }
  57982. _this._texture = _this._getFromCache(rootUrl, noMipmap);
  57983. if (!files) {
  57984. if (!isEnv && !isDDS && !extensions) {
  57985. extensions = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"];
  57986. }
  57987. files = [];
  57988. if (extensions) {
  57989. for (var index = 0; index < extensions.length; index++) {
  57990. files.push(rootUrl + extensions[index]);
  57991. }
  57992. }
  57993. }
  57994. _this._files = files;
  57995. if (!_this._texture) {
  57996. if (!scene.useDelayedTextureLoading) {
  57997. if (prefiltered) {
  57998. _this._texture = scene.getEngine().createPrefilteredCubeTexture(rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, _this._createPolynomials);
  57999. }
  58000. else {
  58001. _this._texture = scene.getEngine().createCubeTexture(rootUrl, scene, files, noMipmap, onLoad, onError, _this._format, forcedExtension, false, lodScale, lodOffset);
  58002. }
  58003. }
  58004. else {
  58005. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  58006. }
  58007. }
  58008. else if (onLoad) {
  58009. if (_this._texture.isReady) {
  58010. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetImmediate(function () { return onLoad(); });
  58011. }
  58012. else {
  58013. _this._texture.onLoadedObservable.add(onLoad);
  58014. }
  58015. }
  58016. return _this;
  58017. }
  58018. Object.defineProperty(CubeTexture.prototype, "boundingBoxSize", {
  58019. /**
  58020. * Returns the bounding box size
  58021. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  58022. */
  58023. get: function () {
  58024. return this._boundingBoxSize;
  58025. },
  58026. /**
  58027. * Gets or sets the size of the bounding box associated with the cube texture
  58028. * When defined, the cubemap will switch to local mode
  58029. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  58030. * @example https://www.babylonjs-playground.com/#RNASML
  58031. */
  58032. set: function (value) {
  58033. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  58034. return;
  58035. }
  58036. this._boundingBoxSize = value;
  58037. var scene = this.getScene();
  58038. if (scene) {
  58039. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  58040. }
  58041. },
  58042. enumerable: true,
  58043. configurable: true
  58044. });
  58045. Object.defineProperty(CubeTexture.prototype, "rotationY", {
  58046. /**
  58047. * Gets texture matrix rotation angle around Y axis radians.
  58048. */
  58049. get: function () {
  58050. return this._rotationY;
  58051. },
  58052. /**
  58053. * Sets texture matrix rotation angle around Y axis in radians.
  58054. */
  58055. set: function (value) {
  58056. this._rotationY = value;
  58057. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(this._rotationY));
  58058. },
  58059. enumerable: true,
  58060. configurable: true
  58061. });
  58062. Object.defineProperty(CubeTexture.prototype, "noMipmap", {
  58063. /**
  58064. * Are mip maps generated for this texture or not.
  58065. */
  58066. get: function () {
  58067. return this._noMipmap;
  58068. },
  58069. enumerable: true,
  58070. configurable: true
  58071. });
  58072. /**
  58073. * Creates a cube texture from an array of image urls
  58074. * @param files defines an array of image urls
  58075. * @param scene defines the hosting scene
  58076. * @param noMipmap specifies if mip maps are not used
  58077. * @returns a cube texture
  58078. */
  58079. CubeTexture.CreateFromImages = function (files, scene, noMipmap) {
  58080. var rootUrlKey = "";
  58081. files.forEach(function (url) { return rootUrlKey += url; });
  58082. return new CubeTexture(rootUrlKey, scene, null, noMipmap, files);
  58083. };
  58084. /**
  58085. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  58086. * @param url defines the url of the prefiltered texture
  58087. * @param scene defines the scene the texture is attached to
  58088. * @param forcedExtension defines the extension of the file if different from the url
  58089. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  58090. * @return the prefiltered texture
  58091. */
  58092. CubeTexture.CreateFromPrefilteredData = function (url, scene, forcedExtension, createPolynomials) {
  58093. if (forcedExtension === void 0) { forcedExtension = null; }
  58094. if (createPolynomials === void 0) { createPolynomials = true; }
  58095. return new CubeTexture(url, scene, null, false, null, null, null, undefined, true, forcedExtension, createPolynomials);
  58096. };
  58097. /**
  58098. * Get the current class name of the texture useful for serialization or dynamic coding.
  58099. * @returns "CubeTexture"
  58100. */
  58101. CubeTexture.prototype.getClassName = function () {
  58102. return "CubeTexture";
  58103. };
  58104. /**
  58105. * Update the url (and optional buffer) of this texture if url was null during construction.
  58106. * @param url the url of the texture
  58107. * @param forcedExtension defines the extension to use
  58108. * @param onLoad callback called when the texture is loaded (defaults to null)
  58109. */
  58110. CubeTexture.prototype.updateURL = function (url, forcedExtension, onLoad) {
  58111. if (this.url) {
  58112. this.releaseInternalTexture();
  58113. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  58114. }
  58115. this.url = url;
  58116. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  58117. this._prefiltered = false;
  58118. if (onLoad) {
  58119. this._delayedOnLoad = onLoad;
  58120. }
  58121. this.delayLoad(forcedExtension);
  58122. };
  58123. /**
  58124. * Delays loading of the cube texture
  58125. * @param forcedExtension defines the extension to use
  58126. */
  58127. CubeTexture.prototype.delayLoad = function (forcedExtension) {
  58128. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  58129. return;
  58130. }
  58131. var scene = this.getScene();
  58132. if (!scene) {
  58133. return;
  58134. }
  58135. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  58136. this._texture = this._getFromCache(this.url, this._noMipmap);
  58137. if (!this._texture) {
  58138. if (this._prefiltered) {
  58139. this._texture = scene.getEngine().createPrefilteredCubeTexture(this.url, scene, this.lodGenerationScale, this.lodGenerationOffset, this._delayedOnLoad, undefined, this._format, undefined, this._createPolynomials);
  58140. }
  58141. else {
  58142. this._texture = scene.getEngine().createCubeTexture(this.url, scene, this._files, this._noMipmap, this._delayedOnLoad, undefined, this._format, forcedExtension);
  58143. }
  58144. }
  58145. };
  58146. /**
  58147. * Returns the reflection texture matrix
  58148. * @returns the reflection texture matrix
  58149. */
  58150. CubeTexture.prototype.getReflectionTextureMatrix = function () {
  58151. return this._textureMatrix;
  58152. };
  58153. /**
  58154. * Sets the reflection texture matrix
  58155. * @param value Reflection texture matrix
  58156. */
  58157. CubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  58158. var _this = this;
  58159. if (value.updateFlag === this._textureMatrix.updateFlag) {
  58160. return;
  58161. }
  58162. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  58163. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  58164. }
  58165. this._textureMatrix = value;
  58166. };
  58167. /**
  58168. * Parses text to create a cube texture
  58169. * @param parsedTexture define the serialized text to read from
  58170. * @param scene defines the hosting scene
  58171. * @param rootUrl defines the root url of the cube texture
  58172. * @returns a cube texture
  58173. */
  58174. CubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  58175. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  58176. var prefiltered = false;
  58177. if (parsedTexture.prefiltered) {
  58178. prefiltered = parsedTexture.prefiltered;
  58179. }
  58180. return new CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions, false, null, null, null, undefined, prefiltered);
  58181. }, parsedTexture, scene);
  58182. // Local Cubemaps
  58183. if (parsedTexture.boundingBoxPosition) {
  58184. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  58185. }
  58186. if (parsedTexture.boundingBoxSize) {
  58187. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  58188. }
  58189. // Animations
  58190. if (parsedTexture.animations) {
  58191. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  58192. var parsedAnimation = parsedTexture.animations[animationIndex];
  58193. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  58194. if (internalClass) {
  58195. texture.animations.push(internalClass.Parse(parsedAnimation));
  58196. }
  58197. }
  58198. }
  58199. return texture;
  58200. };
  58201. /**
  58202. * Makes a clone, or deep copy, of the cube texture
  58203. * @returns a new cube texture
  58204. */
  58205. CubeTexture.prototype.clone = function () {
  58206. var _this = this;
  58207. var scene = this.getScene();
  58208. var uniqueId = 0;
  58209. var newCubeTexture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  58210. if (!scene) {
  58211. return _this;
  58212. }
  58213. var cubeTexture = new CubeTexture(_this.url, scene, _this._extensions, _this._noMipmap, _this._files);
  58214. uniqueId = cubeTexture.uniqueId;
  58215. return cubeTexture;
  58216. }, this);
  58217. newCubeTexture.uniqueId = uniqueId;
  58218. return newCubeTexture;
  58219. };
  58220. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58221. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("rotationY")
  58222. ], CubeTexture.prototype, "rotationY", null);
  58223. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58224. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMatrix"])("textureMatrix")
  58225. ], CubeTexture.prototype, "_textureMatrix", void 0);
  58226. return CubeTexture;
  58227. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__["BaseTexture"]));
  58228. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"]._CubeTextureParser = CubeTexture.Parse;
  58229. // Some exporters relies on Tools.Instantiate
  58230. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.CubeTexture"] = CubeTexture;
  58231. /***/ }),
  58232. /***/ "./Materials/Textures/dynamicTexture.ts":
  58233. /*!**********************************************!*\
  58234. !*** ./Materials/Textures/dynamicTexture.ts ***!
  58235. \**********************************************/
  58236. /*! exports provided: DynamicTexture */
  58237. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58238. "use strict";
  58239. __webpack_require__.r(__webpack_exports__);
  58240. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return DynamicTexture; });
  58241. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58242. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  58243. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  58244. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58245. /**
  58246. * A class extending Texture allowing drawing on a texture
  58247. * @see http://doc.babylonjs.com/how_to/dynamictexture
  58248. */
  58249. var DynamicTexture = /** @class */ (function (_super) {
  58250. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DynamicTexture, _super);
  58251. /**
  58252. * Creates a DynamicTexture
  58253. * @param name defines the name of the texture
  58254. * @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
  58255. * @param scene defines the scene where you want the texture
  58256. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  58257. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58258. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  58259. */
  58260. function DynamicTexture(name, options, scene, generateMipMaps, samplingMode, format) {
  58261. if (scene === void 0) { scene = null; }
  58262. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  58263. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA; }
  58264. var _this = _super.call(this, null, scene, !generateMipMaps, undefined, samplingMode, undefined, undefined, undefined, undefined, format) || this;
  58265. _this.name = name;
  58266. _this._engine = _this.getScene().getEngine();
  58267. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  58268. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  58269. _this._generateMipMaps = generateMipMaps;
  58270. if (options.getContext) {
  58271. _this._canvas = options;
  58272. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  58273. }
  58274. else {
  58275. _this._canvas = document.createElement("canvas");
  58276. if (options.width || options.width === 0) {
  58277. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  58278. }
  58279. else {
  58280. _this._texture = _this._engine.createDynamicTexture(options, options, generateMipMaps, samplingMode);
  58281. }
  58282. }
  58283. var textureSize = _this.getSize();
  58284. _this._canvas.width = textureSize.width;
  58285. _this._canvas.height = textureSize.height;
  58286. _this._context = _this._canvas.getContext("2d");
  58287. return _this;
  58288. }
  58289. /**
  58290. * Get the current class name of the texture useful for serialization or dynamic coding.
  58291. * @returns "DynamicTexture"
  58292. */
  58293. DynamicTexture.prototype.getClassName = function () {
  58294. return "DynamicTexture";
  58295. };
  58296. Object.defineProperty(DynamicTexture.prototype, "canRescale", {
  58297. /**
  58298. * Gets the current state of canRescale
  58299. */
  58300. get: function () {
  58301. return true;
  58302. },
  58303. enumerable: true,
  58304. configurable: true
  58305. });
  58306. DynamicTexture.prototype._recreate = function (textureSize) {
  58307. this._canvas.width = textureSize.width;
  58308. this._canvas.height = textureSize.height;
  58309. this.releaseInternalTexture();
  58310. this._texture = this._engine.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this.samplingMode);
  58311. };
  58312. /**
  58313. * Scales the texture
  58314. * @param ratio the scale factor to apply to both width and height
  58315. */
  58316. DynamicTexture.prototype.scale = function (ratio) {
  58317. var textureSize = this.getSize();
  58318. textureSize.width *= ratio;
  58319. textureSize.height *= ratio;
  58320. this._recreate(textureSize);
  58321. };
  58322. /**
  58323. * Resizes the texture
  58324. * @param width the new width
  58325. * @param height the new height
  58326. */
  58327. DynamicTexture.prototype.scaleTo = function (width, height) {
  58328. var textureSize = this.getSize();
  58329. textureSize.width = width;
  58330. textureSize.height = height;
  58331. this._recreate(textureSize);
  58332. };
  58333. /**
  58334. * Gets the context of the canvas used by the texture
  58335. * @returns the canvas context of the dynamic texture
  58336. */
  58337. DynamicTexture.prototype.getContext = function () {
  58338. return this._context;
  58339. };
  58340. /**
  58341. * Clears the texture
  58342. */
  58343. DynamicTexture.prototype.clear = function () {
  58344. var size = this.getSize();
  58345. this._context.fillRect(0, 0, size.width, size.height);
  58346. };
  58347. /**
  58348. * Updates the texture
  58349. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  58350. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  58351. */
  58352. DynamicTexture.prototype.update = function (invertY, premulAlpha) {
  58353. if (premulAlpha === void 0) { premulAlpha = false; }
  58354. this._engine.updateDynamicTexture(this._texture, this._canvas, invertY === undefined ? true : invertY, premulAlpha, this._format || undefined);
  58355. };
  58356. /**
  58357. * Draws text onto the texture
  58358. * @param text defines the text to be drawn
  58359. * @param x defines the placement of the text from the left
  58360. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  58361. * @param font defines the font to be used with font-style, font-size, font-name
  58362. * @param color defines the color used for the text
  58363. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  58364. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  58365. * @param update defines whether texture is immediately update (default is true)
  58366. */
  58367. DynamicTexture.prototype.drawText = function (text, x, y, font, color, clearColor, invertY, update) {
  58368. if (update === void 0) { update = true; }
  58369. var size = this.getSize();
  58370. if (clearColor) {
  58371. this._context.fillStyle = clearColor;
  58372. this._context.fillRect(0, 0, size.width, size.height);
  58373. }
  58374. this._context.font = font;
  58375. if (x === null || x === undefined) {
  58376. var textSize = this._context.measureText(text);
  58377. x = (size.width - textSize.width) / 2;
  58378. }
  58379. if (y === null || y === undefined) {
  58380. var fontSize = parseInt((font.replace(/\D/g, '')));
  58381. y = (size.height / 2) + (fontSize / 3.65);
  58382. }
  58383. this._context.fillStyle = color;
  58384. this._context.fillText(text, x, y);
  58385. if (update) {
  58386. this.update(invertY);
  58387. }
  58388. };
  58389. /**
  58390. * Clones the texture
  58391. * @returns the clone of the texture.
  58392. */
  58393. DynamicTexture.prototype.clone = function () {
  58394. var scene = this.getScene();
  58395. if (!scene) {
  58396. return this;
  58397. }
  58398. var textureSize = this.getSize();
  58399. var newTexture = new DynamicTexture(this.name, textureSize, scene, this._generateMipMaps);
  58400. // Base texture
  58401. newTexture.hasAlpha = this.hasAlpha;
  58402. newTexture.level = this.level;
  58403. // Dynamic Texture
  58404. newTexture.wrapU = this.wrapU;
  58405. newTexture.wrapV = this.wrapV;
  58406. return newTexture;
  58407. };
  58408. /**
  58409. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  58410. * @returns a serialized dynamic texture object
  58411. */
  58412. DynamicTexture.prototype.serialize = function () {
  58413. var scene = this.getScene();
  58414. if (scene && !scene.isReady()) {
  58415. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The scene must be ready before serializing the dynamic texture");
  58416. }
  58417. var serializationObject = _super.prototype.serialize.call(this);
  58418. serializationObject.base64String = this._canvas.toDataURL();
  58419. serializationObject.invertY = this._invertY;
  58420. serializationObject.samplingMode = this.samplingMode;
  58421. return serializationObject;
  58422. };
  58423. /** @hidden */
  58424. DynamicTexture.prototype._rebuild = function () {
  58425. this.update();
  58426. };
  58427. return DynamicTexture;
  58428. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]));
  58429. /***/ }),
  58430. /***/ "./Materials/Textures/equiRectangularCubeTexture.ts":
  58431. /*!**********************************************************!*\
  58432. !*** ./Materials/Textures/equiRectangularCubeTexture.ts ***!
  58433. \**********************************************************/
  58434. /*! exports provided: EquiRectangularCubeTexture */
  58435. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58436. "use strict";
  58437. __webpack_require__.r(__webpack_exports__);
  58438. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return EquiRectangularCubeTexture; });
  58439. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58440. /* harmony import */ var _Misc_HighDynamicRange_panoramaToCubemap__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  58441. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  58442. /* harmony import */ var _baseTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./baseTexture */ "./Materials/Textures/baseTexture.ts");
  58443. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  58444. /**
  58445. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58446. */
  58447. var EquiRectangularCubeTexture = /** @class */ (function (_super) {
  58448. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](EquiRectangularCubeTexture, _super);
  58449. /**
  58450. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58451. * @param url The location of the image
  58452. * @param scene The scene the texture will be used in
  58453. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58454. * @param noMipmap Forces to not generate the mipmap if true
  58455. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58456. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58457. * @param onLoad — defines a callback called when texture is loaded
  58458. * @param onError — defines a callback called if there is an error
  58459. */
  58460. function EquiRectangularCubeTexture(url, scene, size, noMipmap, gammaSpace, onLoad, onError) {
  58461. if (noMipmap === void 0) { noMipmap = false; }
  58462. if (gammaSpace === void 0) { gammaSpace = true; }
  58463. if (onLoad === void 0) { onLoad = null; }
  58464. if (onError === void 0) { onError = null; }
  58465. var _this = _super.call(this, scene) || this;
  58466. _this._onLoad = null;
  58467. _this._onError = null;
  58468. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58469. _this.coordinatesMode = _texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CUBIC_MODE;
  58470. if (!url) {
  58471. throw new Error('Image url is not set');
  58472. }
  58473. _this.name = url;
  58474. _this.url = url;
  58475. _this._size = size;
  58476. _this._noMipmap = noMipmap;
  58477. _this.gammaSpace = gammaSpace;
  58478. _this._onLoad = onLoad;
  58479. _this._onError = onError;
  58480. _this.hasAlpha = false;
  58481. _this.isCube = true;
  58482. _this._texture = _this._getFromCache(url, _this._noMipmap);
  58483. if (!_this._texture) {
  58484. if (!scene.useDelayedTextureLoading) {
  58485. _this.loadImage(_this.loadTexture.bind(_this));
  58486. }
  58487. else {
  58488. _this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED;
  58489. }
  58490. }
  58491. return _this;
  58492. }
  58493. /**
  58494. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58495. */
  58496. EquiRectangularCubeTexture.prototype.loadImage = function (loadTextureCallback) {
  58497. var _this = this;
  58498. var canvas = document.createElement('canvas');
  58499. var image = new Image();
  58500. image.addEventListener('load', function () {
  58501. _this._width = image.width;
  58502. _this._height = image.height;
  58503. canvas.width = _this._width;
  58504. canvas.height = _this._height;
  58505. var ctx = canvas.getContext('2d');
  58506. ctx.drawImage(image, 0, 0);
  58507. var imageData = ctx.getImageData(0, 0, image.width, image.height);
  58508. _this._buffer = imageData.data.buffer;
  58509. canvas.remove();
  58510. loadTextureCallback();
  58511. });
  58512. image.src = this.url;
  58513. };
  58514. /**
  58515. * Convert the image buffer into a cubemap and create a CubeTexture.
  58516. */
  58517. EquiRectangularCubeTexture.prototype.loadTexture = function () {
  58518. var _this = this;
  58519. var scene = this.getScene();
  58520. var callback = function () {
  58521. var imageData = _this.getFloat32ArrayFromArrayBuffer(_this._buffer);
  58522. // Extract the raw linear data.
  58523. var data = _Misc_HighDynamicRange_panoramaToCubemap__WEBPACK_IMPORTED_MODULE_1__["PanoramaToCubeMapTools"].ConvertPanoramaToCubemap(imageData, _this._width, _this._height, _this._size);
  58524. var results = [];
  58525. // Push each faces.
  58526. for (var i = 0; i < 6; i++) {
  58527. var dataFace = data[EquiRectangularCubeTexture._FacesMapping[i]];
  58528. results.push(dataFace);
  58529. }
  58530. return results;
  58531. };
  58532. if (!scene) {
  58533. return;
  58534. }
  58535. this._texture = scene
  58536. .getEngine()
  58537. .createRawCubeTextureFromUrl(this.url, scene, this._size, _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].TEXTUREFORMAT_RGB, scene.getEngine().getCaps().textureFloat
  58538. ? _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].TEXTURETYPE_FLOAT
  58539. : _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].TEXTURETYPE_UNSIGNED_INTEGER, this._noMipmap, callback, null, this._onLoad, this._onError);
  58540. };
  58541. /**
  58542. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58543. * @param buffer The ArrayBuffer that should be converted.
  58544. * @returns The buffer as Float32Array.
  58545. */
  58546. EquiRectangularCubeTexture.prototype.getFloat32ArrayFromArrayBuffer = function (buffer) {
  58547. var dataView = new DataView(buffer);
  58548. var floatImageData = new Float32Array((buffer.byteLength * 3) / 4);
  58549. var k = 0;
  58550. for (var i = 0; i < buffer.byteLength; i++) {
  58551. // We drop the transparency channel, because we do not need/want it
  58552. if ((i + 1) % 4 !== 0) {
  58553. floatImageData[k++] = dataView.getUint8(i) / 255;
  58554. }
  58555. }
  58556. return floatImageData;
  58557. };
  58558. /**
  58559. * Get the current class name of the texture useful for serialization or dynamic coding.
  58560. * @returns "EquiRectangularCubeTexture"
  58561. */
  58562. EquiRectangularCubeTexture.prototype.getClassName = function () {
  58563. return "EquiRectangularCubeTexture";
  58564. };
  58565. /**
  58566. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58567. * @returns A clone of the current EquiRectangularCubeTexture.
  58568. */
  58569. EquiRectangularCubeTexture.prototype.clone = function () {
  58570. var scene = this.getScene();
  58571. if (!scene) {
  58572. return this;
  58573. }
  58574. var newTexture = new EquiRectangularCubeTexture(this.url, scene, this._size, this._noMipmap, this.gammaSpace);
  58575. // Base texture
  58576. newTexture.level = this.level;
  58577. newTexture.wrapU = this.wrapU;
  58578. newTexture.wrapV = this.wrapV;
  58579. newTexture.coordinatesIndex = this.coordinatesIndex;
  58580. newTexture.coordinatesMode = this.coordinatesMode;
  58581. return newTexture;
  58582. };
  58583. /** The six faces of the cube. */
  58584. EquiRectangularCubeTexture._FacesMapping = ['right', 'left', 'up', 'down', 'front', 'back'];
  58585. return EquiRectangularCubeTexture;
  58586. }(_baseTexture__WEBPACK_IMPORTED_MODULE_3__["BaseTexture"]));
  58587. /***/ }),
  58588. /***/ "./Materials/Textures/hdrCubeTexture.ts":
  58589. /*!**********************************************!*\
  58590. !*** ./Materials/Textures/hdrCubeTexture.ts ***!
  58591. \**********************************************/
  58592. /*! exports provided: HDRCubeTexture */
  58593. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58594. "use strict";
  58595. __webpack_require__.r(__webpack_exports__);
  58596. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return HDRCubeTexture; });
  58597. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58598. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  58599. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  58600. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  58601. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  58602. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58603. /* harmony import */ var _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/hdr */ "./Misc/HighDynamicRange/hdr.ts");
  58604. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  58605. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  58606. /**
  58607. * This represents a texture coming from an HDR input.
  58608. *
  58609. * The only supported format is currently panorama picture stored in RGBE format.
  58610. * Example of such files can be found on HDRLib: http://hdrlib.com/
  58611. */
  58612. var HDRCubeTexture = /** @class */ (function (_super) {
  58613. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTexture, _super);
  58614. /**
  58615. * Instantiates an HDRTexture from the following parameters.
  58616. *
  58617. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  58618. * @param scene The scene the texture will be used in
  58619. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58620. * @param noMipmap Forces to not generate the mipmap if true
  58621. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  58622. * @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)
  58623. * @param reserved Reserved flag for internal use.
  58624. */
  58625. function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, gammaSpace, reserved, onLoad, onError) {
  58626. if (noMipmap === void 0) { noMipmap = false; }
  58627. if (generateHarmonics === void 0) { generateHarmonics = true; }
  58628. if (gammaSpace === void 0) { gammaSpace = false; }
  58629. if (reserved === void 0) { reserved = false; }
  58630. if (onLoad === void 0) { onLoad = null; }
  58631. if (onError === void 0) { onError = null; }
  58632. var _this = _super.call(this, scene) || this;
  58633. _this._generateHarmonics = true;
  58634. _this._onLoad = null;
  58635. _this._onError = null;
  58636. /**
  58637. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  58638. */
  58639. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CUBIC_MODE;
  58640. _this._isBlocking = true;
  58641. _this._rotationY = 0;
  58642. /**
  58643. * Gets or sets the center of the bounding box associated with the cube texture
  58644. * It must define where the camera used to render the texture was set
  58645. */
  58646. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  58647. if (!url) {
  58648. return _this;
  58649. }
  58650. _this.name = url;
  58651. _this.url = url;
  58652. _this.hasAlpha = false;
  58653. _this.isCube = true;
  58654. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  58655. _this._onLoad = onLoad;
  58656. _this._onError = onError;
  58657. _this.gammaSpace = gammaSpace;
  58658. _this._noMipmap = noMipmap;
  58659. _this._size = size;
  58660. _this._texture = _this._getFromCache(url, _this._noMipmap);
  58661. if (!_this._texture) {
  58662. if (!scene.useDelayedTextureLoading) {
  58663. _this.loadTexture();
  58664. }
  58665. else {
  58666. _this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED;
  58667. }
  58668. }
  58669. return _this;
  58670. }
  58671. Object.defineProperty(HDRCubeTexture.prototype, "isBlocking", {
  58672. /**
  58673. * Gets wether or not the texture is blocking during loading.
  58674. */
  58675. get: function () {
  58676. return this._isBlocking;
  58677. },
  58678. /**
  58679. * Sets wether or not the texture is blocking during loading.
  58680. */
  58681. set: function (value) {
  58682. this._isBlocking = value;
  58683. },
  58684. enumerable: true,
  58685. configurable: true
  58686. });
  58687. Object.defineProperty(HDRCubeTexture.prototype, "rotationY", {
  58688. /**
  58689. * Gets texture matrix rotation angle around Y axis radians.
  58690. */
  58691. get: function () {
  58692. return this._rotationY;
  58693. },
  58694. /**
  58695. * Sets texture matrix rotation angle around Y axis in radians.
  58696. */
  58697. set: function (value) {
  58698. this._rotationY = value;
  58699. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationY(this._rotationY));
  58700. },
  58701. enumerable: true,
  58702. configurable: true
  58703. });
  58704. Object.defineProperty(HDRCubeTexture.prototype, "boundingBoxSize", {
  58705. get: function () {
  58706. return this._boundingBoxSize;
  58707. },
  58708. /**
  58709. * Gets or sets the size of the bounding box associated with the cube texture
  58710. * When defined, the cubemap will switch to local mode
  58711. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  58712. * @example https://www.babylonjs-playground.com/#RNASML
  58713. */
  58714. set: function (value) {
  58715. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  58716. return;
  58717. }
  58718. this._boundingBoxSize = value;
  58719. var scene = this.getScene();
  58720. if (scene) {
  58721. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag);
  58722. }
  58723. },
  58724. enumerable: true,
  58725. configurable: true
  58726. });
  58727. /**
  58728. * Get the current class name of the texture useful for serialization or dynamic coding.
  58729. * @returns "HDRCubeTexture"
  58730. */
  58731. HDRCubeTexture.prototype.getClassName = function () {
  58732. return "HDRCubeTexture";
  58733. };
  58734. /**
  58735. * Occurs when the file is raw .hdr file.
  58736. */
  58737. HDRCubeTexture.prototype.loadTexture = function () {
  58738. var _this = this;
  58739. var callback = function (buffer) {
  58740. _this.lodGenerationOffset = 0.0;
  58741. _this.lodGenerationScale = 0.8;
  58742. var scene = _this.getScene();
  58743. if (!scene) {
  58744. return null;
  58745. }
  58746. // Extract the raw linear data.
  58747. var data = _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__["HDRTools"].GetCubeMapTextureData(buffer, _this._size);
  58748. // Generate harmonics if needed.
  58749. if (_this._generateHarmonics) {
  58750. var sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial(data);
  58751. _this.sphericalPolynomial = sphericalPolynomial;
  58752. }
  58753. var results = [];
  58754. var byteArray = null;
  58755. // Push each faces.
  58756. for (var j = 0; j < 6; j++) {
  58757. // Create uintarray fallback.
  58758. if (!scene.getEngine().getCaps().textureFloat) {
  58759. // 3 channels of 1 bytes per pixel in bytes.
  58760. var byteBuffer = new ArrayBuffer(_this._size * _this._size * 3);
  58761. byteArray = new Uint8Array(byteBuffer);
  58762. }
  58763. var dataFace = (data[HDRCubeTexture._facesMapping[j]]);
  58764. // If special cases.
  58765. if (_this.gammaSpace || byteArray) {
  58766. for (var i = 0; i < _this._size * _this._size; i++) {
  58767. // Put in gamma space if requested.
  58768. if (_this.gammaSpace) {
  58769. dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  58770. dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  58771. dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  58772. }
  58773. // Convert to int texture for fallback.
  58774. if (byteArray) {
  58775. var r = Math.max(dataFace[(i * 3) + 0] * 255, 0);
  58776. var g = Math.max(dataFace[(i * 3) + 1] * 255, 0);
  58777. var b = Math.max(dataFace[(i * 3) + 2] * 255, 0);
  58778. // May use luminance instead if the result is not accurate.
  58779. var max = Math.max(Math.max(r, g), b);
  58780. if (max > 255) {
  58781. var scale = 255 / max;
  58782. r *= scale;
  58783. g *= scale;
  58784. b *= scale;
  58785. }
  58786. byteArray[(i * 3) + 0] = r;
  58787. byteArray[(i * 3) + 1] = g;
  58788. byteArray[(i * 3) + 2] = b;
  58789. }
  58790. }
  58791. }
  58792. if (byteArray) {
  58793. results.push(byteArray);
  58794. }
  58795. else {
  58796. results.push(dataFace);
  58797. }
  58798. }
  58799. return results;
  58800. };
  58801. var scene = this.getScene();
  58802. if (scene) {
  58803. 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);
  58804. }
  58805. };
  58806. HDRCubeTexture.prototype.clone = function () {
  58807. var scene = this.getScene();
  58808. if (!scene) {
  58809. return this;
  58810. }
  58811. var newTexture = new HDRCubeTexture(this.url, scene, this._size, this._noMipmap, this._generateHarmonics, this.gammaSpace);
  58812. // Base texture
  58813. newTexture.level = this.level;
  58814. newTexture.wrapU = this.wrapU;
  58815. newTexture.wrapV = this.wrapV;
  58816. newTexture.coordinatesIndex = this.coordinatesIndex;
  58817. newTexture.coordinatesMode = this.coordinatesMode;
  58818. return newTexture;
  58819. };
  58820. // Methods
  58821. HDRCubeTexture.prototype.delayLoad = function () {
  58822. if (this.delayLoadState !== _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED) {
  58823. return;
  58824. }
  58825. this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_LOADED;
  58826. this._texture = this._getFromCache(this.url, this._noMipmap);
  58827. if (!this._texture) {
  58828. this.loadTexture();
  58829. }
  58830. };
  58831. /**
  58832. * Get the texture reflection matrix used to rotate/transform the reflection.
  58833. * @returns the reflection matrix
  58834. */
  58835. HDRCubeTexture.prototype.getReflectionTextureMatrix = function () {
  58836. return this._textureMatrix;
  58837. };
  58838. /**
  58839. * Set the texture reflection matrix used to rotate/transform the reflection.
  58840. * @param value Define the reflection matrix to set
  58841. */
  58842. HDRCubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  58843. var _this = this;
  58844. this._textureMatrix = value;
  58845. if (value.updateFlag === this._textureMatrix.updateFlag) {
  58846. return;
  58847. }
  58848. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  58849. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  58850. }
  58851. };
  58852. /**
  58853. * Parses a JSON representation of an HDR Texture in order to create the texture
  58854. * @param parsedTexture Define the JSON representation
  58855. * @param scene Define the scene the texture should be created in
  58856. * @param rootUrl Define the root url in case we need to load relative dependencies
  58857. * @returns the newly created texture after parsing
  58858. */
  58859. HDRCubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  58860. var texture = null;
  58861. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  58862. texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.size, parsedTexture.noMipmap, parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace);
  58863. texture.name = parsedTexture.name;
  58864. texture.hasAlpha = parsedTexture.hasAlpha;
  58865. texture.level = parsedTexture.level;
  58866. texture.coordinatesMode = parsedTexture.coordinatesMode;
  58867. texture.isBlocking = parsedTexture.isBlocking;
  58868. }
  58869. if (texture) {
  58870. if (parsedTexture.boundingBoxPosition) {
  58871. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  58872. }
  58873. if (parsedTexture.boundingBoxSize) {
  58874. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  58875. }
  58876. if (parsedTexture.rotationY) {
  58877. texture.rotationY = parsedTexture.rotationY;
  58878. }
  58879. }
  58880. return texture;
  58881. };
  58882. HDRCubeTexture.prototype.serialize = function () {
  58883. if (!this.name) {
  58884. return null;
  58885. }
  58886. var serializationObject = {};
  58887. serializationObject.name = this.name;
  58888. serializationObject.hasAlpha = this.hasAlpha;
  58889. serializationObject.isCube = true;
  58890. serializationObject.level = this.level;
  58891. serializationObject.size = this._size;
  58892. serializationObject.coordinatesMode = this.coordinatesMode;
  58893. serializationObject.useInGammaSpace = this.gammaSpace;
  58894. serializationObject.generateHarmonics = this._generateHarmonics;
  58895. serializationObject.customType = "BABYLON.HDRCubeTexture";
  58896. serializationObject.noMipmap = this._noMipmap;
  58897. serializationObject.isBlocking = this._isBlocking;
  58898. serializationObject.rotationY = this._rotationY;
  58899. return serializationObject;
  58900. };
  58901. HDRCubeTexture._facesMapping = [
  58902. "right",
  58903. "left",
  58904. "up",
  58905. "down",
  58906. "front",
  58907. "back"
  58908. ];
  58909. return HDRCubeTexture;
  58910. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__["BaseTexture"]));
  58911. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.HDRCubeTexture"] = HDRCubeTexture;
  58912. /***/ }),
  58913. /***/ "./Materials/Textures/index.ts":
  58914. /*!*************************************!*\
  58915. !*** ./Materials/Textures/index.ts ***!
  58916. \*************************************/
  58917. /*! exports provided: BaseTexture, CubeTexture, EquiRectangularCubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  58918. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58919. "use strict";
  58920. __webpack_require__.r(__webpack_exports__);
  58921. /* harmony import */ var _baseTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseTexture */ "./Materials/Textures/baseTexture.ts");
  58922. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _baseTexture__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  58923. /* harmony import */ var _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorGradingTexture */ "./Materials/Textures/colorGradingTexture.ts");
  58924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__["ColorGradingTexture"]; });
  58925. /* harmony import */ var _cubeTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  58926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _cubeTexture__WEBPACK_IMPORTED_MODULE_2__["CubeTexture"]; });
  58927. /* harmony import */ var _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  58928. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__["DynamicTexture"]; });
  58929. /* harmony import */ var _equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./equiRectangularCubeTexture */ "./Materials/Textures/equiRectangularCubeTexture.ts");
  58930. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_4__["EquiRectangularCubeTexture"]; });
  58931. /* harmony import */ var _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  58932. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_5__["HDRCubeTexture"]; });
  58933. /* harmony import */ var _internalTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./internalTexture */ "./Materials/Textures/internalTexture.ts");
  58934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _internalTexture__WEBPACK_IMPORTED_MODULE_6__["InternalTexture"]; });
  58935. /* harmony import */ var _internalTextureTracker__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  58936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _internalTextureTracker__WEBPACK_IMPORTED_MODULE_7__["DummyInternalTextureTracker"]; });
  58937. /* harmony import */ var _Loaders_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Loaders/index */ "./Materials/Textures/Loaders/index.ts");
  58938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_8__["_DDSTextureLoader"]; });
  58939. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_8__["_ENVTextureLoader"]; });
  58940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_8__["_KTXTextureLoader"]; });
  58941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_8__["_TGATextureLoader"]; });
  58942. /* harmony import */ var _mirrorTexture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  58943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _mirrorTexture__WEBPACK_IMPORTED_MODULE_9__["MirrorTexture"]; });
  58944. /* harmony import */ var _multiRenderTarget__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  58945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _multiRenderTarget__WEBPACK_IMPORTED_MODULE_10__["MultiRenderTarget"]; });
  58946. /* harmony import */ var _Procedurals_index__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Procedurals/index */ "./Materials/Textures/Procedurals/index.ts");
  58947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_11__["ProceduralTexture"]; });
  58948. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_11__["CustomProceduralTexture"]; });
  58949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_11__["NoiseProceduralTexture"]; });
  58950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_11__["ProceduralTextureSceneComponent"]; });
  58951. /* harmony import */ var _rawCubeTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./rawCubeTexture */ "./Materials/Textures/rawCubeTexture.ts");
  58952. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _rawCubeTexture__WEBPACK_IMPORTED_MODULE_12__["RawCubeTexture"]; });
  58953. /* harmony import */ var _rawTexture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./rawTexture */ "./Materials/Textures/rawTexture.ts");
  58954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _rawTexture__WEBPACK_IMPORTED_MODULE_13__["RawTexture"]; });
  58955. /* harmony import */ var _rawTexture3D__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./rawTexture3D */ "./Materials/Textures/rawTexture3D.ts");
  58956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _rawTexture3D__WEBPACK_IMPORTED_MODULE_14__["RawTexture3D"]; });
  58957. /* harmony import */ var _refractionTexture__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./refractionTexture */ "./Materials/Textures/refractionTexture.ts");
  58958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _refractionTexture__WEBPACK_IMPORTED_MODULE_15__["RefractionTexture"]; });
  58959. /* harmony import */ var _renderTargetTexture__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  58960. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _renderTargetTexture__WEBPACK_IMPORTED_MODULE_16__["RenderTargetTexture"]; });
  58961. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  58962. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _texture__WEBPACK_IMPORTED_MODULE_17__["Texture"]; });
  58963. /* harmony import */ var _videoTexture__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./videoTexture */ "./Materials/Textures/videoTexture.ts");
  58964. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _videoTexture__WEBPACK_IMPORTED_MODULE_18__["VideoTexture"]; });
  58965. /***/ }),
  58966. /***/ "./Materials/Textures/internalTexture.ts":
  58967. /*!***********************************************!*\
  58968. !*** ./Materials/Textures/internalTexture.ts ***!
  58969. \***********************************************/
  58970. /*! exports provided: InternalTexture */
  58971. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58972. "use strict";
  58973. __webpack_require__.r(__webpack_exports__);
  58974. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return InternalTexture; });
  58975. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  58976. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  58977. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58978. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  58979. /**
  58980. * Class used to store data associated with WebGL texture data for the engine
  58981. * This class should not be used directly
  58982. */
  58983. var InternalTexture = /** @class */ (function () {
  58984. /**
  58985. * Creates a new InternalTexture
  58986. * @param engine defines the engine to use
  58987. * @param dataSource defines the type of data that will be used
  58988. * @param delayAllocation if the texture allocation should be delayed (default: false)
  58989. */
  58990. function InternalTexture(engine, dataSource, delayAllocation) {
  58991. if (delayAllocation === void 0) { delayAllocation = false; }
  58992. /**
  58993. * Observable called when the texture is loaded
  58994. */
  58995. this.onLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  58996. /**
  58997. * Gets or set the previous tracker in the list
  58998. */
  58999. this.previous = null;
  59000. /**
  59001. * Gets or set the next tracker in the list
  59002. */
  59003. this.next = null;
  59004. // Private
  59005. /** @hidden */
  59006. this._invertVScale = false;
  59007. /** @hidden */
  59008. this._initialSlot = -1;
  59009. /** @hidden */
  59010. this._designatedSlot = -1;
  59011. /** @hidden */
  59012. this._dataSource = InternalTexture.DATASOURCE_UNKNOWN;
  59013. /** @hidden */
  59014. this._comparisonFunction = 0;
  59015. /** @hidden */
  59016. this._sphericalPolynomial = null;
  59017. /** @hidden */
  59018. this._lodGenerationScale = 0;
  59019. /** @hidden */
  59020. this._lodGenerationOffset = 0;
  59021. /** @hidden */
  59022. this._isRGBD = false;
  59023. /** @hidden */
  59024. this._references = 1;
  59025. this._engine = engine;
  59026. this._dataSource = dataSource;
  59027. if (!delayAllocation) {
  59028. this._webGLTexture = engine._createTexture();
  59029. }
  59030. }
  59031. /**
  59032. * Gets the Engine the texture belongs to.
  59033. * @returns The babylon engine
  59034. */
  59035. InternalTexture.prototype.getEngine = function () {
  59036. return this._engine;
  59037. };
  59038. Object.defineProperty(InternalTexture.prototype, "dataSource", {
  59039. /**
  59040. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  59041. */
  59042. get: function () {
  59043. return this._dataSource;
  59044. },
  59045. enumerable: true,
  59046. configurable: true
  59047. });
  59048. /**
  59049. * Increments the number of references (ie. the number of Texture that point to it)
  59050. */
  59051. InternalTexture.prototype.incrementReferences = function () {
  59052. this._references++;
  59053. };
  59054. /**
  59055. * Change the size of the texture (not the size of the content)
  59056. * @param width defines the new width
  59057. * @param height defines the new height
  59058. * @param depth defines the new depth (1 by default)
  59059. */
  59060. InternalTexture.prototype.updateSize = function (width, height, depth) {
  59061. if (depth === void 0) { depth = 1; }
  59062. this.width = width;
  59063. this.height = height;
  59064. this.depth = depth;
  59065. this.baseWidth = width;
  59066. this.baseHeight = height;
  59067. this.baseDepth = depth;
  59068. this._size = width * height * depth;
  59069. };
  59070. /** @hidden */
  59071. InternalTexture.prototype._rebuild = function () {
  59072. var _this = this;
  59073. var proxy;
  59074. this.isReady = false;
  59075. this._cachedCoordinatesMode = null;
  59076. this._cachedWrapU = null;
  59077. this._cachedWrapV = null;
  59078. this._cachedAnisotropicFilteringLevel = null;
  59079. switch (this._dataSource) {
  59080. case InternalTexture.DATASOURCE_TEMP:
  59081. return;
  59082. case InternalTexture.DATASOURCE_URL:
  59083. proxy = this._engine.createTexture(this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, function () {
  59084. proxy._swapAndDie(_this);
  59085. _this.isReady = true;
  59086. }, null, this._buffer, undefined, this.format);
  59087. return;
  59088. case InternalTexture.DATASOURCE_RAW:
  59089. proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  59090. proxy._swapAndDie(this);
  59091. this.isReady = true;
  59092. return;
  59093. case InternalTexture.DATASOURCE_RAW3D:
  59094. proxy = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  59095. proxy._swapAndDie(this);
  59096. this.isReady = true;
  59097. return;
  59098. case InternalTexture.DATASOURCE_DYNAMIC:
  59099. proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);
  59100. proxy._swapAndDie(this);
  59101. this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, undefined, undefined, true);
  59102. // The engine will make sure to update content so no need to flag it as isReady = true
  59103. return;
  59104. case InternalTexture.DATASOURCE_RENDERTARGET:
  59105. var options = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__["RenderTargetCreationOptions"]();
  59106. options.generateDepthBuffer = this._generateDepthBuffer;
  59107. options.generateMipMaps = this.generateMipMaps;
  59108. options.generateStencilBuffer = this._generateStencilBuffer;
  59109. options.samplingMode = this.samplingMode;
  59110. options.type = this.type;
  59111. if (this.isCube) {
  59112. proxy = this._engine.createRenderTargetCubeTexture(this.width, options);
  59113. }
  59114. else {
  59115. var size = {
  59116. width: this.width,
  59117. height: this.height
  59118. };
  59119. proxy = this._engine.createRenderTargetTexture(size, options);
  59120. }
  59121. proxy._swapAndDie(this);
  59122. this.isReady = true;
  59123. return;
  59124. case InternalTexture.DATASOURCE_DEPTHTEXTURE:
  59125. var depthTextureOptions = {
  59126. bilinearFiltering: this.samplingMode !== _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  59127. comparisonFunction: this._comparisonFunction,
  59128. generateStencil: this._generateStencilBuffer,
  59129. isCube: this.isCube
  59130. };
  59131. proxy = this._engine.createDepthStencilTexture({ width: this.width, height: this.height }, depthTextureOptions);
  59132. proxy._swapAndDie(this);
  59133. this.isReady = true;
  59134. return;
  59135. case InternalTexture.DATASOURCE_CUBE:
  59136. proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function () {
  59137. proxy._swapAndDie(_this);
  59138. _this.isReady = true;
  59139. }, null, this.format, this._extension);
  59140. return;
  59141. case InternalTexture.DATASOURCE_CUBERAW:
  59142. proxy = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  59143. proxy._swapAndDie(this);
  59144. this.isReady = true;
  59145. return;
  59146. case InternalTexture.DATASOURCE_CUBERAW_RGBD:
  59147. proxy = this._engine.createRawCubeTexture(null, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  59148. InternalTexture._UpdateRGBDAsync(proxy, this._bufferViewArrayArray, this._sphericalPolynomial, this._lodGenerationScale, this._lodGenerationOffset).then(function () {
  59149. proxy._swapAndDie(_this);
  59150. _this.isReady = true;
  59151. });
  59152. return;
  59153. case InternalTexture.DATASOURCE_CUBEPREFILTERED:
  59154. proxy = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, function (proxy) {
  59155. if (proxy) {
  59156. proxy._swapAndDie(_this);
  59157. }
  59158. _this.isReady = true;
  59159. }, null, this.format, this._extension);
  59160. proxy._sphericalPolynomial = this._sphericalPolynomial;
  59161. return;
  59162. }
  59163. };
  59164. /** @hidden */
  59165. InternalTexture.prototype._swapAndDie = function (target) {
  59166. target._webGLTexture = this._webGLTexture;
  59167. target._isRGBD = this._isRGBD;
  59168. if (this._framebuffer) {
  59169. target._framebuffer = this._framebuffer;
  59170. }
  59171. if (this._depthStencilBuffer) {
  59172. target._depthStencilBuffer = this._depthStencilBuffer;
  59173. }
  59174. if (this._lodTextureHigh) {
  59175. if (target._lodTextureHigh) {
  59176. target._lodTextureHigh.dispose();
  59177. }
  59178. target._lodTextureHigh = this._lodTextureHigh;
  59179. }
  59180. if (this._lodTextureMid) {
  59181. if (target._lodTextureMid) {
  59182. target._lodTextureMid.dispose();
  59183. }
  59184. target._lodTextureMid = this._lodTextureMid;
  59185. }
  59186. if (this._lodTextureLow) {
  59187. if (target._lodTextureLow) {
  59188. target._lodTextureLow.dispose();
  59189. }
  59190. target._lodTextureLow = this._lodTextureLow;
  59191. }
  59192. var cache = this._engine.getLoadedTexturesCache();
  59193. var index = cache.indexOf(this);
  59194. if (index !== -1) {
  59195. cache.splice(index, 1);
  59196. }
  59197. };
  59198. /**
  59199. * Dispose the current allocated resources
  59200. */
  59201. InternalTexture.prototype.dispose = function () {
  59202. if (!this._webGLTexture) {
  59203. return;
  59204. }
  59205. this._references--;
  59206. if (this._references === 0) {
  59207. this._engine._releaseTexture(this);
  59208. this._webGLTexture = null;
  59209. this.previous = null;
  59210. this.next = null;
  59211. }
  59212. };
  59213. /** hidden */
  59214. InternalTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  59215. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("environmentTextureTools");
  59216. };
  59217. /**
  59218. * The source of the texture data is unknown
  59219. */
  59220. InternalTexture.DATASOURCE_UNKNOWN = 0;
  59221. /**
  59222. * Texture data comes from an URL
  59223. */
  59224. InternalTexture.DATASOURCE_URL = 1;
  59225. /**
  59226. * Texture data is only used for temporary storage
  59227. */
  59228. InternalTexture.DATASOURCE_TEMP = 2;
  59229. /**
  59230. * Texture data comes from raw data (ArrayBuffer)
  59231. */
  59232. InternalTexture.DATASOURCE_RAW = 3;
  59233. /**
  59234. * Texture content is dynamic (video or dynamic texture)
  59235. */
  59236. InternalTexture.DATASOURCE_DYNAMIC = 4;
  59237. /**
  59238. * Texture content is generated by rendering to it
  59239. */
  59240. InternalTexture.DATASOURCE_RENDERTARGET = 5;
  59241. /**
  59242. * Texture content is part of a multi render target process
  59243. */
  59244. InternalTexture.DATASOURCE_MULTIRENDERTARGET = 6;
  59245. /**
  59246. * Texture data comes from a cube data file
  59247. */
  59248. InternalTexture.DATASOURCE_CUBE = 7;
  59249. /**
  59250. * Texture data comes from a raw cube data
  59251. */
  59252. InternalTexture.DATASOURCE_CUBERAW = 8;
  59253. /**
  59254. * Texture data come from a prefiltered cube data file
  59255. */
  59256. InternalTexture.DATASOURCE_CUBEPREFILTERED = 9;
  59257. /**
  59258. * Texture content is raw 3D data
  59259. */
  59260. InternalTexture.DATASOURCE_RAW3D = 10;
  59261. /**
  59262. * Texture content is a depth texture
  59263. */
  59264. InternalTexture.DATASOURCE_DEPTHTEXTURE = 11;
  59265. /**
  59266. * Texture data comes from a raw cube data encoded with RGBD
  59267. */
  59268. InternalTexture.DATASOURCE_CUBERAW_RGBD = 12;
  59269. return InternalTexture;
  59270. }());
  59271. /***/ }),
  59272. /***/ "./Materials/Textures/internalTextureTracker.ts":
  59273. /*!******************************************************!*\
  59274. !*** ./Materials/Textures/internalTextureTracker.ts ***!
  59275. \******************************************************/
  59276. /*! exports provided: DummyInternalTextureTracker */
  59277. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59278. "use strict";
  59279. __webpack_require__.r(__webpack_exports__);
  59280. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return DummyInternalTextureTracker; });
  59281. /**
  59282. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  59283. */
  59284. var DummyInternalTextureTracker = /** @class */ (function () {
  59285. function DummyInternalTextureTracker() {
  59286. /**
  59287. * Gets or set the previous tracker in the list
  59288. */
  59289. this.previous = null;
  59290. /**
  59291. * Gets or set the next tracker in the list
  59292. */
  59293. this.next = null;
  59294. }
  59295. return DummyInternalTextureTracker;
  59296. }());
  59297. /***/ }),
  59298. /***/ "./Materials/Textures/mirrorTexture.ts":
  59299. /*!*********************************************!*\
  59300. !*** ./Materials/Textures/mirrorTexture.ts ***!
  59301. \*********************************************/
  59302. /*! exports provided: MirrorTexture */
  59303. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59304. "use strict";
  59305. __webpack_require__.r(__webpack_exports__);
  59306. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return MirrorTexture; });
  59307. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59308. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  59309. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  59310. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  59311. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  59312. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  59313. /**
  59314. * Mirror texture can be used to simulate the view from a mirror in a scene.
  59315. * It will dynamically be rendered every frame to adapt to the camera point of view.
  59316. * You can then easily use it as a reflectionTexture on a flat surface.
  59317. * In case the surface is not a plane, please consider relying on reflection probes.
  59318. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  59319. */
  59320. var MirrorTexture = /** @class */ (function (_super) {
  59321. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MirrorTexture, _super);
  59322. /**
  59323. * Instantiates a Mirror Texture.
  59324. * Mirror texture can be used to simulate the view from a mirror in a scene.
  59325. * It will dynamically be rendered every frame to adapt to the camera point of view.
  59326. * You can then easily use it as a reflectionTexture on a flat surface.
  59327. * In case the surface is not a plane, please consider relying on reflection probes.
  59328. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  59329. * @param name
  59330. * @param size
  59331. * @param scene
  59332. * @param generateMipMaps
  59333. * @param type
  59334. * @param samplingMode
  59335. * @param generateDepthBuffer
  59336. */
  59337. function MirrorTexture(name, size, scene, generateMipMaps, type, samplingMode, generateDepthBuffer) {
  59338. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  59339. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  59340. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  59341. var _this = _super.call(this, name, size, scene, generateMipMaps, true, type, false, samplingMode, generateDepthBuffer) || this;
  59342. _this.scene = scene;
  59343. /**
  59344. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  59345. * 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.
  59346. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  59347. */
  59348. _this.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  59349. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  59350. _this._mirrorMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  59351. _this._adaptiveBlurKernel = 0;
  59352. _this._blurKernelX = 0;
  59353. _this._blurKernelY = 0;
  59354. _this._blurRatio = 1.0;
  59355. _this.ignoreCameraViewport = true;
  59356. _this._updateGammaSpace();
  59357. _this._imageProcessingConfigChangeObserver = scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  59358. _this._updateGammaSpace;
  59359. });
  59360. _this.onBeforeRenderObservable.add(function () {
  59361. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ReflectionToRef(_this.mirrorPlane, _this._mirrorMatrix);
  59362. _this._savedViewMatrix = scene.getViewMatrix();
  59363. _this._mirrorMatrix.multiplyToRef(_this._savedViewMatrix, _this._transformMatrix);
  59364. scene.setTransformMatrix(_this._transformMatrix, scene.getProjectionMatrix());
  59365. scene.clipPlane = _this.mirrorPlane;
  59366. scene.getEngine().cullBackFaces = false;
  59367. scene._mirroredCameraPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(scene.activeCamera.globalPosition, _this._mirrorMatrix);
  59368. });
  59369. _this.onAfterRenderObservable.add(function () {
  59370. scene.setTransformMatrix(_this._savedViewMatrix, scene.getProjectionMatrix());
  59371. scene.getEngine().cullBackFaces = true;
  59372. scene._mirroredCameraPosition = null;
  59373. delete scene.clipPlane;
  59374. });
  59375. return _this;
  59376. }
  59377. Object.defineProperty(MirrorTexture.prototype, "blurRatio", {
  59378. get: function () {
  59379. return this._blurRatio;
  59380. },
  59381. /**
  59382. * Define the blur ratio used to blur the reflection if needed.
  59383. */
  59384. set: function (value) {
  59385. if (this._blurRatio === value) {
  59386. return;
  59387. }
  59388. this._blurRatio = value;
  59389. this._preparePostProcesses();
  59390. },
  59391. enumerable: true,
  59392. configurable: true
  59393. });
  59394. Object.defineProperty(MirrorTexture.prototype, "adaptiveBlurKernel", {
  59395. /**
  59396. * Define the adaptive blur kernel used to blur the reflection if needed.
  59397. * This will autocompute the closest best match for the `blurKernel`
  59398. */
  59399. set: function (value) {
  59400. this._adaptiveBlurKernel = value;
  59401. this._autoComputeBlurKernel();
  59402. },
  59403. enumerable: true,
  59404. configurable: true
  59405. });
  59406. Object.defineProperty(MirrorTexture.prototype, "blurKernel", {
  59407. /**
  59408. * Define the blur kernel used to blur the reflection if needed.
  59409. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  59410. */
  59411. set: function (value) {
  59412. this.blurKernelX = value;
  59413. this.blurKernelY = value;
  59414. },
  59415. enumerable: true,
  59416. configurable: true
  59417. });
  59418. Object.defineProperty(MirrorTexture.prototype, "blurKernelX", {
  59419. get: function () {
  59420. return this._blurKernelX;
  59421. },
  59422. /**
  59423. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  59424. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  59425. */
  59426. set: function (value) {
  59427. if (this._blurKernelX === value) {
  59428. return;
  59429. }
  59430. this._blurKernelX = value;
  59431. this._preparePostProcesses();
  59432. },
  59433. enumerable: true,
  59434. configurable: true
  59435. });
  59436. Object.defineProperty(MirrorTexture.prototype, "blurKernelY", {
  59437. get: function () {
  59438. return this._blurKernelY;
  59439. },
  59440. /**
  59441. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  59442. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  59443. */
  59444. set: function (value) {
  59445. if (this._blurKernelY === value) {
  59446. return;
  59447. }
  59448. this._blurKernelY = value;
  59449. this._preparePostProcesses();
  59450. },
  59451. enumerable: true,
  59452. configurable: true
  59453. });
  59454. MirrorTexture.prototype._autoComputeBlurKernel = function () {
  59455. var engine = this.getScene().getEngine();
  59456. var dw = this.getRenderWidth() / engine.getRenderWidth();
  59457. var dh = this.getRenderHeight() / engine.getRenderHeight();
  59458. this.blurKernelX = this._adaptiveBlurKernel * dw;
  59459. this.blurKernelY = this._adaptiveBlurKernel * dh;
  59460. };
  59461. MirrorTexture.prototype._onRatioRescale = function () {
  59462. if (this._sizeRatio) {
  59463. this.resize(this._initialSizeParameter);
  59464. if (!this._adaptiveBlurKernel) {
  59465. this._preparePostProcesses();
  59466. }
  59467. }
  59468. if (this._adaptiveBlurKernel) {
  59469. this._autoComputeBlurKernel();
  59470. }
  59471. };
  59472. MirrorTexture.prototype._updateGammaSpace = function () {
  59473. this.gammaSpace = !this.scene.imageProcessingConfiguration.isEnabled || !this.scene.imageProcessingConfiguration.applyByPostProcess;
  59474. };
  59475. MirrorTexture.prototype._preparePostProcesses = function () {
  59476. this.clearPostProcesses(true);
  59477. if (this._blurKernelX && this._blurKernelY) {
  59478. var engine = this.getScene().getEngine();
  59479. var textureType = engine.getCaps().textureFloatRender ? _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT : _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_HALF_FLOAT;
  59480. 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);
  59481. this._blurX.autoClear = false;
  59482. if (this._blurRatio === 1 && this.samples < 2 && this._texture) {
  59483. this._blurX.inputTexture = this._texture;
  59484. }
  59485. else {
  59486. this._blurX.alwaysForcePOT = true;
  59487. }
  59488. 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);
  59489. this._blurY.autoClear = false;
  59490. this._blurY.alwaysForcePOT = this._blurRatio !== 1;
  59491. this.addPostProcess(this._blurX);
  59492. this.addPostProcess(this._blurY);
  59493. }
  59494. else {
  59495. if (this._blurY) {
  59496. this.removePostProcess(this._blurY);
  59497. this._blurY.dispose();
  59498. this._blurY = null;
  59499. }
  59500. if (this._blurX) {
  59501. this.removePostProcess(this._blurX);
  59502. this._blurX.dispose();
  59503. this._blurX = null;
  59504. }
  59505. }
  59506. };
  59507. /**
  59508. * Clone the mirror texture.
  59509. * @returns the cloned texture
  59510. */
  59511. MirrorTexture.prototype.clone = function () {
  59512. var scene = this.getScene();
  59513. if (!scene) {
  59514. return this;
  59515. }
  59516. var textureSize = this.getSize();
  59517. var newTexture = new MirrorTexture(this.name, textureSize.width, scene, this._renderTargetOptions.generateMipMaps, this._renderTargetOptions.type, this._renderTargetOptions.samplingMode, this._renderTargetOptions.generateDepthBuffer);
  59518. // Base texture
  59519. newTexture.hasAlpha = this.hasAlpha;
  59520. newTexture.level = this.level;
  59521. // Mirror Texture
  59522. newTexture.mirrorPlane = this.mirrorPlane.clone();
  59523. if (this.renderList) {
  59524. newTexture.renderList = this.renderList.slice(0);
  59525. }
  59526. return newTexture;
  59527. };
  59528. /**
  59529. * Serialize the texture to a JSON representation you could use in Parse later on
  59530. * @returns the serialized JSON representation
  59531. */
  59532. MirrorTexture.prototype.serialize = function () {
  59533. if (!this.name) {
  59534. return null;
  59535. }
  59536. var serializationObject = _super.prototype.serialize.call(this);
  59537. serializationObject.mirrorPlane = this.mirrorPlane.asArray();
  59538. return serializationObject;
  59539. };
  59540. /**
  59541. * Dispose the texture and release its associated resources.
  59542. */
  59543. MirrorTexture.prototype.dispose = function () {
  59544. _super.prototype.dispose.call(this);
  59545. this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver);
  59546. };
  59547. return MirrorTexture;
  59548. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]));
  59549. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  59550. return new MirrorTexture(name, renderTargetSize, scene, generateMipMaps);
  59551. };
  59552. /***/ }),
  59553. /***/ "./Materials/Textures/multiRenderTarget.ts":
  59554. /*!*************************************************!*\
  59555. !*** ./Materials/Textures/multiRenderTarget.ts ***!
  59556. \*************************************************/
  59557. /*! exports provided: MultiRenderTarget */
  59558. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59559. "use strict";
  59560. __webpack_require__.r(__webpack_exports__);
  59561. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return MultiRenderTarget; });
  59562. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59563. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  59564. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  59565. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  59566. /**
  59567. * A multi render target, like a render target provides the ability to render to a texture.
  59568. * Unlike the render target, it can render to several draw buffers in one draw.
  59569. * This is specially interesting in deferred rendering or for any effects requiring more than
  59570. * just one color from a single pass.
  59571. */
  59572. var MultiRenderTarget = /** @class */ (function (_super) {
  59573. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiRenderTarget, _super);
  59574. /**
  59575. * Instantiate a new multi render target texture.
  59576. * A multi render target, like a render target provides the ability to render to a texture.
  59577. * Unlike the render target, it can render to several draw buffers in one draw.
  59578. * This is specially interesting in deferred rendering or for any effects requiring more than
  59579. * just one color from a single pass.
  59580. * @param name Define the name of the texture
  59581. * @param size Define the size of the buffers to render to
  59582. * @param count Define the number of target we are rendering into
  59583. * @param scene Define the scene the texture belongs to
  59584. * @param options Define the options used to create the multi render target
  59585. */
  59586. function MultiRenderTarget(name, size, count, scene, options) {
  59587. var _this = this;
  59588. var generateMipMaps = options && options.generateMipMaps ? options.generateMipMaps : false;
  59589. var generateDepthTexture = options && options.generateDepthTexture ? options.generateDepthTexture : false;
  59590. var doNotChangeAspectRatio = !options || options.doNotChangeAspectRatio === undefined ? true : options.doNotChangeAspectRatio;
  59591. _this = _super.call(this, name, size, scene, generateMipMaps, doNotChangeAspectRatio) || this;
  59592. _this._engine = scene.getEngine();
  59593. if (!_this.isSupported) {
  59594. _this.dispose();
  59595. return;
  59596. }
  59597. var types = [];
  59598. var samplingModes = [];
  59599. for (var i = 0; i < count; i++) {
  59600. if (options && options.types && options.types[i] !== undefined) {
  59601. types.push(options.types[i]);
  59602. }
  59603. else {
  59604. types.push(options && options.defaultType ? options.defaultType : _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  59605. }
  59606. if (options && options.samplingModes && options.samplingModes[i] !== undefined) {
  59607. samplingModes.push(options.samplingModes[i]);
  59608. }
  59609. else {
  59610. samplingModes.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE);
  59611. }
  59612. }
  59613. var generateDepthBuffer = !options || options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  59614. var generateStencilBuffer = !options || options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  59615. _this._size = size;
  59616. _this._multiRenderTargetOptions = {
  59617. samplingModes: samplingModes,
  59618. generateMipMaps: generateMipMaps,
  59619. generateDepthBuffer: generateDepthBuffer,
  59620. generateStencilBuffer: generateStencilBuffer,
  59621. generateDepthTexture: generateDepthTexture,
  59622. types: types,
  59623. textureCount: count
  59624. };
  59625. _this._createInternalTextures();
  59626. _this._createTextures();
  59627. return _this;
  59628. }
  59629. Object.defineProperty(MultiRenderTarget.prototype, "isSupported", {
  59630. /**
  59631. * Get if draw buffers are currently supported by the used hardware and browser.
  59632. */
  59633. get: function () {
  59634. return this._engine.webGLVersion > 1 || this._engine.getCaps().drawBuffersExtension;
  59635. },
  59636. enumerable: true,
  59637. configurable: true
  59638. });
  59639. Object.defineProperty(MultiRenderTarget.prototype, "textures", {
  59640. /**
  59641. * Get the list of textures generated by the multi render target.
  59642. */
  59643. get: function () {
  59644. return this._textures;
  59645. },
  59646. enumerable: true,
  59647. configurable: true
  59648. });
  59649. Object.defineProperty(MultiRenderTarget.prototype, "depthTexture", {
  59650. /**
  59651. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  59652. */
  59653. get: function () {
  59654. return this._textures[this._textures.length - 1];
  59655. },
  59656. enumerable: true,
  59657. configurable: true
  59658. });
  59659. Object.defineProperty(MultiRenderTarget.prototype, "wrapU", {
  59660. /**
  59661. * Set the wrapping mode on U of all the textures we are rendering to.
  59662. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  59663. */
  59664. set: function (wrap) {
  59665. if (this._textures) {
  59666. for (var i = 0; i < this._textures.length; i++) {
  59667. this._textures[i].wrapU = wrap;
  59668. }
  59669. }
  59670. },
  59671. enumerable: true,
  59672. configurable: true
  59673. });
  59674. Object.defineProperty(MultiRenderTarget.prototype, "wrapV", {
  59675. /**
  59676. * Set the wrapping mode on V of all the textures we are rendering to.
  59677. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  59678. */
  59679. set: function (wrap) {
  59680. if (this._textures) {
  59681. for (var i = 0; i < this._textures.length; i++) {
  59682. this._textures[i].wrapV = wrap;
  59683. }
  59684. }
  59685. },
  59686. enumerable: true,
  59687. configurable: true
  59688. });
  59689. /** @hidden */
  59690. MultiRenderTarget.prototype._rebuild = function () {
  59691. this.releaseInternalTextures();
  59692. this._createInternalTextures();
  59693. for (var i = 0; i < this._internalTextures.length; i++) {
  59694. var texture = this._textures[i];
  59695. texture._texture = this._internalTextures[i];
  59696. }
  59697. // Keeps references to frame buffer and stencil/depth buffer
  59698. this._texture = this._internalTextures[0];
  59699. };
  59700. MultiRenderTarget.prototype._createInternalTextures = function () {
  59701. this._internalTextures = this._engine.createMultipleRenderTarget(this._size, this._multiRenderTargetOptions);
  59702. };
  59703. MultiRenderTarget.prototype._createTextures = function () {
  59704. this._textures = [];
  59705. for (var i = 0; i < this._internalTextures.length; i++) {
  59706. var texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](null, this.getScene());
  59707. texture._texture = this._internalTextures[i];
  59708. this._textures.push(texture);
  59709. }
  59710. // Keeps references to frame buffer and stencil/depth buffer
  59711. this._texture = this._internalTextures[0];
  59712. };
  59713. Object.defineProperty(MultiRenderTarget.prototype, "samples", {
  59714. /**
  59715. * Define the number of samples used if MSAA is enabled.
  59716. */
  59717. get: function () {
  59718. return this._samples;
  59719. },
  59720. set: function (value) {
  59721. if (this._samples === value) {
  59722. return;
  59723. }
  59724. this._samples = this._engine.updateMultipleRenderTargetTextureSampleCount(this._internalTextures, value);
  59725. },
  59726. enumerable: true,
  59727. configurable: true
  59728. });
  59729. /**
  59730. * Resize all the textures in the multi render target.
  59731. * Be carrefull as it will recreate all the data in the new texture.
  59732. * @param size Define the new size
  59733. */
  59734. MultiRenderTarget.prototype.resize = function (size) {
  59735. this.releaseInternalTextures();
  59736. this._internalTextures = this._engine.createMultipleRenderTarget(size, this._multiRenderTargetOptions);
  59737. this._createInternalTextures();
  59738. };
  59739. MultiRenderTarget.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  59740. var _this = this;
  59741. engine.unBindMultiColorAttachmentFramebuffer(this._internalTextures, this.isCube, function () {
  59742. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  59743. });
  59744. };
  59745. /**
  59746. * Dispose the render targets and their associated resources
  59747. */
  59748. MultiRenderTarget.prototype.dispose = function () {
  59749. this.releaseInternalTextures();
  59750. _super.prototype.dispose.call(this);
  59751. };
  59752. /**
  59753. * Release all the underlying texture used as draw buffers.
  59754. */
  59755. MultiRenderTarget.prototype.releaseInternalTextures = function () {
  59756. if (!this._internalTextures) {
  59757. return;
  59758. }
  59759. for (var i = this._internalTextures.length - 1; i >= 0; i--) {
  59760. if (this._internalTextures[i] !== undefined) {
  59761. this._internalTextures[i].dispose();
  59762. this._internalTextures.splice(i, 1);
  59763. }
  59764. }
  59765. };
  59766. return MultiRenderTarget;
  59767. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  59768. /***/ }),
  59769. /***/ "./Materials/Textures/rawCubeTexture.ts":
  59770. /*!**********************************************!*\
  59771. !*** ./Materials/Textures/rawCubeTexture.ts ***!
  59772. \**********************************************/
  59773. /*! exports provided: RawCubeTexture */
  59774. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59775. "use strict";
  59776. __webpack_require__.r(__webpack_exports__);
  59777. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return RawCubeTexture; });
  59778. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59779. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  59780. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  59781. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  59782. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  59783. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  59784. /**
  59785. * Raw cube texture where the raw buffers are passed in
  59786. */
  59787. var RawCubeTexture = /** @class */ (function (_super) {
  59788. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawCubeTexture, _super);
  59789. /**
  59790. * Creates a cube texture where the raw buffers are passed in.
  59791. * @param scene defines the scene the texture is attached to
  59792. * @param data defines the array of data to use to create each face
  59793. * @param size defines the size of the textures
  59794. * @param format defines the format of the data
  59795. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  59796. * @param generateMipMaps defines if the engine should generate the mip levels
  59797. * @param invertY defines if data must be stored with Y axis inverted
  59798. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  59799. * @param compression defines the compression used (null by default)
  59800. */
  59801. function RawCubeTexture(scene, data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  59802. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTUREFORMAT_RGBA; }
  59803. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  59804. if (generateMipMaps === void 0) { generateMipMaps = false; }
  59805. if (invertY === void 0) { invertY = false; }
  59806. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  59807. if (compression === void 0) { compression = null; }
  59808. var _this = _super.call(this, "", scene) || this;
  59809. _this._texture = scene.getEngine().createRawCubeTexture(data, size, format, type, generateMipMaps, invertY, samplingMode, compression);
  59810. return _this;
  59811. }
  59812. /**
  59813. * Updates the raw cube texture.
  59814. * @param data defines the data to store
  59815. * @param format defines the data format
  59816. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59817. * @param invertY defines if data must be stored with Y axis inverted
  59818. * @param compression defines the compression used (null by default)
  59819. * @param level defines which level of the texture to update
  59820. */
  59821. RawCubeTexture.prototype.update = function (data, format, type, invertY, compression) {
  59822. if (compression === void 0) { compression = null; }
  59823. this._texture.getEngine().updateRawCubeTexture(this._texture, data, format, type, invertY, compression);
  59824. };
  59825. /**
  59826. * Updates a raw cube texture with RGBD encoded data.
  59827. * @param data defines the array of data [mipmap][face] to use to create each face
  59828. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  59829. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59830. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59831. * @returns a promsie that resolves when the operation is complete
  59832. */
  59833. RawCubeTexture.prototype.updateRGBDAsync = function (data, sphericalPolynomial, lodScale, lodOffset) {
  59834. if (sphericalPolynomial === void 0) { sphericalPolynomial = null; }
  59835. if (lodScale === void 0) { lodScale = 0.8; }
  59836. if (lodOffset === void 0) { lodOffset = 0; }
  59837. return RawCubeTexture._UpdateRGBDAsync(this._texture, data, sphericalPolynomial, lodScale, lodOffset);
  59838. };
  59839. /**
  59840. * Clones the raw cube texture.
  59841. * @return a new cube texture
  59842. */
  59843. RawCubeTexture.prototype.clone = function () {
  59844. var _this = this;
  59845. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  59846. var scene = _this.getScene();
  59847. var internalTexture = _this._texture;
  59848. var texture = new RawCubeTexture(scene, internalTexture._bufferViewArray, internalTexture.width, internalTexture.format, internalTexture.type, internalTexture.generateMipMaps, internalTexture.invertY, internalTexture.samplingMode, internalTexture._compression);
  59849. if (internalTexture.dataSource === _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD) {
  59850. texture.updateRGBDAsync(internalTexture._bufferViewArrayArray, internalTexture._sphericalPolynomial, internalTexture._lodGenerationScale, internalTexture._lodGenerationOffset);
  59851. }
  59852. return texture;
  59853. }, this);
  59854. };
  59855. /** @hidden */
  59856. RawCubeTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  59857. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  59858. internalTexture._bufferViewArrayArray = data;
  59859. internalTexture._lodGenerationScale = lodScale;
  59860. internalTexture._lodGenerationOffset = lodOffset;
  59861. internalTexture._sphericalPolynomial = sphericalPolynomial;
  59862. return _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__["EnvironmentTextureTools"].UploadLevelsAsync(internalTexture, data).then(function () {
  59863. internalTexture.isReady = true;
  59864. });
  59865. };
  59866. return RawCubeTexture;
  59867. }(_Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__["CubeTexture"]));
  59868. /***/ }),
  59869. /***/ "./Materials/Textures/rawTexture.ts":
  59870. /*!******************************************!*\
  59871. !*** ./Materials/Textures/rawTexture.ts ***!
  59872. \******************************************/
  59873. /*! exports provided: RawTexture */
  59874. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59875. "use strict";
  59876. __webpack_require__.r(__webpack_exports__);
  59877. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return RawTexture; });
  59878. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59879. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  59880. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  59881. /**
  59882. * Raw texture can help creating a texture directly from an array of data.
  59883. * This can be super useful if you either get the data from an uncompressed source or
  59884. * if you wish to create your texture pixel by pixel.
  59885. */
  59886. var RawTexture = /** @class */ (function (_super) {
  59887. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture, _super);
  59888. /**
  59889. * Instantiates a new RawTexture.
  59890. * Raw texture can help creating a texture directly from an array of data.
  59891. * This can be super useful if you either get the data from an uncompressed source or
  59892. * if you wish to create your texture pixel by pixel.
  59893. * @param data define the array of data to use to create the texture
  59894. * @param width define the width of the texture
  59895. * @param height define the height of the texture
  59896. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  59897. * @param scene define the scene the texture belongs to
  59898. * @param generateMipMaps define whether mip maps should be generated or not
  59899. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  59900. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  59901. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  59902. */
  59903. function RawTexture(data, width, height,
  59904. /**
  59905. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  59906. */
  59907. format, scene, generateMipMaps, invertY, samplingMode, type) {
  59908. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59909. if (invertY === void 0) { invertY = false; }
  59910. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  59911. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  59912. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  59913. _this.format = format;
  59914. _this._engine = scene.getEngine();
  59915. _this._texture = scene.getEngine().createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type);
  59916. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  59917. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  59918. return _this;
  59919. }
  59920. /**
  59921. * Updates the texture underlying data.
  59922. * @param data Define the new data of the texture
  59923. */
  59924. RawTexture.prototype.update = function (data) {
  59925. this._engine.updateRawTexture(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  59926. };
  59927. /**
  59928. * Creates a luminance texture from some data.
  59929. * @param data Define the texture data
  59930. * @param width Define the width of the texture
  59931. * @param height Define the height of the texture
  59932. * @param scene Define the scene the texture belongs to
  59933. * @param generateMipMaps Define whether or not to create mip maps for the texture
  59934. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  59935. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  59936. * @returns the luminance texture
  59937. */
  59938. RawTexture.CreateLuminanceTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  59939. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59940. if (invertY === void 0) { invertY = false; }
  59941. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  59942. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE, scene, generateMipMaps, invertY, samplingMode);
  59943. };
  59944. /**
  59945. * Creates a luminance alpha texture from some data.
  59946. * @param data Define the texture data
  59947. * @param width Define the width of the texture
  59948. * @param height Define the height of the texture
  59949. * @param scene Define the scene the texture belongs to
  59950. * @param generateMipMaps Define whether or not to create mip maps for the texture
  59951. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  59952. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  59953. * @returns the luminance alpha texture
  59954. */
  59955. RawTexture.CreateLuminanceAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  59956. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59957. if (invertY === void 0) { invertY = false; }
  59958. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  59959. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  59960. };
  59961. /**
  59962. * Creates an alpha texture from some data.
  59963. * @param data Define the texture data
  59964. * @param width Define the width of the texture
  59965. * @param height Define the height of the texture
  59966. * @param scene Define the scene the texture belongs to
  59967. * @param generateMipMaps Define whether or not to create mip maps for the texture
  59968. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  59969. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  59970. * @returns the alpha texture
  59971. */
  59972. RawTexture.CreateAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  59973. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59974. if (invertY === void 0) { invertY = false; }
  59975. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  59976. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  59977. };
  59978. /**
  59979. * Creates a RGB texture from some data.
  59980. * @param data Define the texture data
  59981. * @param width Define the width of the texture
  59982. * @param height Define the height of the texture
  59983. * @param scene Define the scene the texture belongs to
  59984. * @param generateMipMaps Define whether or not to create mip maps for the texture
  59985. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  59986. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  59987. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  59988. * @returns the RGB alpha texture
  59989. */
  59990. RawTexture.CreateRGBTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  59991. if (generateMipMaps === void 0) { generateMipMaps = true; }
  59992. if (invertY === void 0) { invertY = false; }
  59993. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  59994. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  59995. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB, scene, generateMipMaps, invertY, samplingMode, type);
  59996. };
  59997. /**
  59998. * Creates a RGBA texture from some data.
  59999. * @param data Define the texture data
  60000. * @param width Define the width of the texture
  60001. * @param height Define the height of the texture
  60002. * @param scene Define the scene the texture belongs to
  60003. * @param generateMipMaps Define whether or not to create mip maps for the texture
  60004. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  60005. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  60006. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  60007. * @returns the RGBA texture
  60008. */
  60009. RawTexture.CreateRGBATexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  60010. if (generateMipMaps === void 0) { generateMipMaps = true; }
  60011. if (invertY === void 0) { invertY = false; }
  60012. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  60013. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  60014. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA, scene, generateMipMaps, invertY, samplingMode, type);
  60015. };
  60016. /**
  60017. * Creates a R texture from some data.
  60018. * @param data Define the texture data
  60019. * @param width Define the width of the texture
  60020. * @param height Define the height of the texture
  60021. * @param scene Define the scene the texture belongs to
  60022. * @param generateMipMaps Define whether or not to create mip maps for the texture
  60023. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  60024. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  60025. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  60026. * @returns the R texture
  60027. */
  60028. RawTexture.CreateRTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  60029. if (generateMipMaps === void 0) { generateMipMaps = true; }
  60030. if (invertY === void 0) { invertY = false; }
  60031. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  60032. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT; }
  60033. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_R, scene, generateMipMaps, invertY, samplingMode, type);
  60034. };
  60035. return RawTexture;
  60036. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  60037. /***/ }),
  60038. /***/ "./Materials/Textures/rawTexture3D.ts":
  60039. /*!********************************************!*\
  60040. !*** ./Materials/Textures/rawTexture3D.ts ***!
  60041. \********************************************/
  60042. /*! exports provided: RawTexture3D */
  60043. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60044. "use strict";
  60045. __webpack_require__.r(__webpack_exports__);
  60046. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return RawTexture3D; });
  60047. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60048. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  60049. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  60050. /**
  60051. * Class used to store 3D textures containing user data
  60052. */
  60053. var RawTexture3D = /** @class */ (function (_super) {
  60054. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture3D, _super);
  60055. /**
  60056. * Create a new RawTexture3D
  60057. * @param data defines the data of the texture
  60058. * @param width defines the width of the texture
  60059. * @param height defines the height of the texture
  60060. * @param depth defines the depth of the texture
  60061. * @param format defines the texture format to use
  60062. * @param scene defines the hosting scene
  60063. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60064. * @param invertY defines if texture must be stored with Y axis inverted
  60065. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60066. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60067. */
  60068. function RawTexture3D(data, width, height, depth,
  60069. /** Gets or sets the texture format to use */
  60070. format, scene, generateMipMaps, invertY, samplingMode, textureType) {
  60071. if (generateMipMaps === void 0) { generateMipMaps = true; }
  60072. if (invertY === void 0) { invertY = false; }
  60073. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  60074. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  60075. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  60076. _this.format = format;
  60077. _this._engine = scene.getEngine();
  60078. _this._texture = scene.getEngine().createRawTexture3D(data, width, height, depth, format, generateMipMaps, invertY, samplingMode, undefined, textureType);
  60079. _this.is3D = true;
  60080. return _this;
  60081. }
  60082. /**
  60083. * Update the texture with new data
  60084. * @param data defines the data to store in the texture
  60085. */
  60086. RawTexture3D.prototype.update = function (data) {
  60087. if (!this._texture) {
  60088. return;
  60089. }
  60090. this._engine.updateRawTexture3D(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  60091. };
  60092. return RawTexture3D;
  60093. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  60094. /***/ }),
  60095. /***/ "./Materials/Textures/refractionTexture.ts":
  60096. /*!*************************************************!*\
  60097. !*** ./Materials/Textures/refractionTexture.ts ***!
  60098. \*************************************************/
  60099. /*! exports provided: RefractionTexture */
  60100. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60101. "use strict";
  60102. __webpack_require__.r(__webpack_exports__);
  60103. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return RefractionTexture; });
  60104. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60105. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  60106. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  60107. /**
  60108. * Creates a refraction texture used by refraction channel of the standard material.
  60109. * It is like a mirror but to see through a material.
  60110. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60111. */
  60112. var RefractionTexture = /** @class */ (function (_super) {
  60113. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionTexture, _super);
  60114. /**
  60115. * Creates a refraction texture used by refraction channel of the standard material.
  60116. * It is like a mirror but to see through a material.
  60117. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60118. * @param name Define the texture name
  60119. * @param size Define the size of the underlying texture
  60120. * @param scene Define the scene the refraction belongs to
  60121. * @param generateMipMaps Define if we need to generate mips level for the refraction
  60122. */
  60123. function RefractionTexture(name, size, scene, generateMipMaps) {
  60124. var _this = _super.call(this, name, size, scene, generateMipMaps, true) || this;
  60125. /**
  60126. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  60127. * 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.
  60128. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60129. */
  60130. _this.refractionPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  60131. /**
  60132. * Define how deep under the surface we should see.
  60133. */
  60134. _this.depth = 2.0;
  60135. _this.onBeforeRenderObservable.add(function () {
  60136. scene.clipPlane = _this.refractionPlane;
  60137. });
  60138. _this.onAfterRenderObservable.add(function () {
  60139. delete scene.clipPlane;
  60140. });
  60141. return _this;
  60142. }
  60143. /**
  60144. * Clone the refraction texture.
  60145. * @returns the cloned texture
  60146. */
  60147. RefractionTexture.prototype.clone = function () {
  60148. var scene = this.getScene();
  60149. if (!scene) {
  60150. return this;
  60151. }
  60152. var textureSize = this.getSize();
  60153. var newTexture = new RefractionTexture(this.name, textureSize.width, scene, this._generateMipMaps);
  60154. // Base texture
  60155. newTexture.hasAlpha = this.hasAlpha;
  60156. newTexture.level = this.level;
  60157. // Refraction Texture
  60158. newTexture.refractionPlane = this.refractionPlane.clone();
  60159. if (this.renderList) {
  60160. newTexture.renderList = this.renderList.slice(0);
  60161. }
  60162. newTexture.depth = this.depth;
  60163. return newTexture;
  60164. };
  60165. /**
  60166. * Serialize the texture to a JSON representation you could use in Parse later on
  60167. * @returns the serialized JSON representation
  60168. */
  60169. RefractionTexture.prototype.serialize = function () {
  60170. if (!this.name) {
  60171. return null;
  60172. }
  60173. var serializationObject = _super.prototype.serialize.call(this);
  60174. serializationObject.mirrorPlane = this.refractionPlane.asArray();
  60175. serializationObject.depth = this.depth;
  60176. return serializationObject;
  60177. };
  60178. return RefractionTexture;
  60179. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  60180. /***/ }),
  60181. /***/ "./Materials/Textures/renderTargetCreationOptions.ts":
  60182. /*!***********************************************************!*\
  60183. !*** ./Materials/Textures/renderTargetCreationOptions.ts ***!
  60184. \***********************************************************/
  60185. /*! exports provided: RenderTargetCreationOptions */
  60186. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60187. "use strict";
  60188. __webpack_require__.r(__webpack_exports__);
  60189. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetCreationOptions", function() { return RenderTargetCreationOptions; });
  60190. /**
  60191. * Define options used to create a render target texture
  60192. */
  60193. var RenderTargetCreationOptions = /** @class */ (function () {
  60194. function RenderTargetCreationOptions() {
  60195. }
  60196. return RenderTargetCreationOptions;
  60197. }());
  60198. /***/ }),
  60199. /***/ "./Materials/Textures/renderTargetTexture.ts":
  60200. /*!***************************************************!*\
  60201. !*** ./Materials/Textures/renderTargetTexture.ts ***!
  60202. \***************************************************/
  60203. /*! exports provided: RenderTargetTexture */
  60204. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60205. "use strict";
  60206. __webpack_require__.r(__webpack_exports__);
  60207. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return RenderTargetTexture; });
  60208. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60209. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  60210. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  60211. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  60212. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  60213. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  60214. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  60215. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  60216. /**
  60217. * This Helps creating a texture that will be created from a camera in your scene.
  60218. * It is basically a dynamic texture that could be used to create special effects for instance.
  60219. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  60220. */
  60221. var RenderTargetTexture = /** @class */ (function (_super) {
  60222. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetTexture, _super);
  60223. /**
  60224. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  60225. * or used a shadow, depth texture...
  60226. * @param name The friendly name of the texture
  60227. * @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)
  60228. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  60229. * @param generateMipMaps True if mip maps need to be generated after render.
  60230. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  60231. * @param type The type of the buffer in the RTT (int, half float, float...)
  60232. * @param isCube True if a cube texture needs to be created
  60233. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  60234. * @param generateDepthBuffer True to generate a depth buffer
  60235. * @param generateStencilBuffer True to generate a stencil buffer
  60236. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  60237. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  60238. * @param delayAllocation if the texture allocation should be delayed (default: false)
  60239. */
  60240. function RenderTargetTexture(name, size, scene, generateMipMaps, doNotChangeAspectRatio, type, isCube, samplingMode, generateDepthBuffer, generateStencilBuffer, isMulti, format, delayAllocation) {
  60241. if (doNotChangeAspectRatio === void 0) { doNotChangeAspectRatio = true; }
  60242. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  60243. if (isCube === void 0) { isCube = false; }
  60244. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  60245. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  60246. if (generateStencilBuffer === void 0) { generateStencilBuffer = false; }
  60247. if (isMulti === void 0) { isMulti = false; }
  60248. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA; }
  60249. if (delayAllocation === void 0) { delayAllocation = false; }
  60250. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  60251. _this.isCube = isCube;
  60252. /**
  60253. * Define if particles should be rendered in your texture.
  60254. */
  60255. _this.renderParticles = true;
  60256. /**
  60257. * Define if sprites should be rendered in your texture.
  60258. */
  60259. _this.renderSprites = false;
  60260. /**
  60261. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  60262. */
  60263. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].PROJECTION_MODE;
  60264. /**
  60265. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  60266. */
  60267. _this.ignoreCameraViewport = false;
  60268. /**
  60269. * An event triggered when the texture is unbind.
  60270. */
  60271. _this.onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  60272. /**
  60273. * An event triggered when the texture is unbind.
  60274. */
  60275. _this.onAfterUnbindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  60276. /**
  60277. * An event triggered before rendering the texture
  60278. */
  60279. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  60280. /**
  60281. * An event triggered after rendering the texture
  60282. */
  60283. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  60284. /**
  60285. * An event triggered after the texture clear
  60286. */
  60287. _this.onClearObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  60288. _this._currentRefreshId = -1;
  60289. _this._refreshRate = 1;
  60290. _this._samples = 1;
  60291. /**
  60292. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  60293. * It must define where the camera used to render the texture is set
  60294. */
  60295. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  60296. scene = _this.getScene();
  60297. if (!scene) {
  60298. return _this;
  60299. }
  60300. _this.renderList = new Array();
  60301. _this._engine = scene.getEngine();
  60302. _this.name = name;
  60303. _this.isRenderTarget = true;
  60304. _this._initialSizeParameter = size;
  60305. _this._processSizeParameter(size);
  60306. _this._resizeObserver = _this.getScene().getEngine().onResizeObservable.add(function () {
  60307. });
  60308. _this._generateMipMaps = generateMipMaps ? true : false;
  60309. _this._doNotChangeAspectRatio = doNotChangeAspectRatio;
  60310. // Rendering groups
  60311. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__["RenderingManager"](scene);
  60312. _this._renderingManager._useSceneAutoClearSetup = true;
  60313. if (isMulti) {
  60314. return _this;
  60315. }
  60316. _this._renderTargetOptions = {
  60317. generateMipMaps: generateMipMaps,
  60318. type: type,
  60319. format: format,
  60320. samplingMode: samplingMode,
  60321. generateDepthBuffer: generateDepthBuffer,
  60322. generateStencilBuffer: generateStencilBuffer
  60323. };
  60324. if (samplingMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].NEAREST_SAMPLINGMODE) {
  60325. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  60326. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  60327. }
  60328. if (!delayAllocation) {
  60329. if (isCube) {
  60330. _this._texture = scene.getEngine().createRenderTargetCubeTexture(_this.getRenderSize(), _this._renderTargetOptions);
  60331. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].INVCUBIC_MODE;
  60332. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  60333. }
  60334. else {
  60335. _this._texture = scene.getEngine().createRenderTargetTexture(_this._size, _this._renderTargetOptions);
  60336. }
  60337. }
  60338. return _this;
  60339. }
  60340. Object.defineProperty(RenderTargetTexture.prototype, "renderList", {
  60341. /**
  60342. * Use this list to define the list of mesh you want to render.
  60343. */
  60344. get: function () {
  60345. return this._renderList;
  60346. },
  60347. set: function (value) {
  60348. this._renderList = value;
  60349. if (this._renderList) {
  60350. this._hookArray(this._renderList);
  60351. }
  60352. },
  60353. enumerable: true,
  60354. configurable: true
  60355. });
  60356. RenderTargetTexture.prototype._hookArray = function (array) {
  60357. var _this = this;
  60358. var oldPush = array.push;
  60359. array.push = function () {
  60360. var items = [];
  60361. for (var _i = 0; _i < arguments.length; _i++) {
  60362. items[_i] = arguments[_i];
  60363. }
  60364. var wasEmpty = array.length === 0;
  60365. var result = oldPush.apply(array, items);
  60366. if (wasEmpty) {
  60367. _this.getScene().meshes.forEach(function (mesh) {
  60368. mesh._markSubMeshesAsLightDirty();
  60369. });
  60370. }
  60371. return result;
  60372. };
  60373. var oldSplice = array.splice;
  60374. array.splice = function (index, deleteCount) {
  60375. var deleted = oldSplice.apply(array, [index, deleteCount]);
  60376. if (array.length === 0) {
  60377. _this.getScene().meshes.forEach(function (mesh) {
  60378. mesh._markSubMeshesAsLightDirty();
  60379. });
  60380. }
  60381. return deleted;
  60382. };
  60383. };
  60384. Object.defineProperty(RenderTargetTexture.prototype, "onAfterUnbind", {
  60385. /**
  60386. * Set a after unbind callback in the texture.
  60387. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  60388. */
  60389. set: function (callback) {
  60390. if (this._onAfterUnbindObserver) {
  60391. this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver);
  60392. }
  60393. this._onAfterUnbindObserver = this.onAfterUnbindObservable.add(callback);
  60394. },
  60395. enumerable: true,
  60396. configurable: true
  60397. });
  60398. Object.defineProperty(RenderTargetTexture.prototype, "onBeforeRender", {
  60399. /**
  60400. * Set a before render callback in the texture.
  60401. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  60402. */
  60403. set: function (callback) {
  60404. if (this._onBeforeRenderObserver) {
  60405. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  60406. }
  60407. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  60408. },
  60409. enumerable: true,
  60410. configurable: true
  60411. });
  60412. Object.defineProperty(RenderTargetTexture.prototype, "onAfterRender", {
  60413. /**
  60414. * Set a after render callback in the texture.
  60415. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  60416. */
  60417. set: function (callback) {
  60418. if (this._onAfterRenderObserver) {
  60419. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  60420. }
  60421. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  60422. },
  60423. enumerable: true,
  60424. configurable: true
  60425. });
  60426. Object.defineProperty(RenderTargetTexture.prototype, "onClear", {
  60427. /**
  60428. * Set a clear callback in the texture.
  60429. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  60430. */
  60431. set: function (callback) {
  60432. if (this._onClearObserver) {
  60433. this.onClearObservable.remove(this._onClearObserver);
  60434. }
  60435. this._onClearObserver = this.onClearObservable.add(callback);
  60436. },
  60437. enumerable: true,
  60438. configurable: true
  60439. });
  60440. Object.defineProperty(RenderTargetTexture.prototype, "renderTargetOptions", {
  60441. /**
  60442. * Gets render target creation options that were used.
  60443. */
  60444. get: function () {
  60445. return this._renderTargetOptions;
  60446. },
  60447. enumerable: true,
  60448. configurable: true
  60449. });
  60450. RenderTargetTexture.prototype._onRatioRescale = function () {
  60451. if (this._sizeRatio) {
  60452. this.resize(this._initialSizeParameter);
  60453. }
  60454. };
  60455. Object.defineProperty(RenderTargetTexture.prototype, "boundingBoxSize", {
  60456. get: function () {
  60457. return this._boundingBoxSize;
  60458. },
  60459. /**
  60460. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  60461. * When defined, the cubemap will switch to local mode
  60462. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  60463. * @example https://www.babylonjs-playground.com/#RNASML
  60464. */
  60465. set: function (value) {
  60466. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  60467. return;
  60468. }
  60469. this._boundingBoxSize = value;
  60470. var scene = this.getScene();
  60471. if (scene) {
  60472. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  60473. }
  60474. },
  60475. enumerable: true,
  60476. configurable: true
  60477. });
  60478. /**
  60479. * Creates a depth stencil texture.
  60480. * This is only available in WebGL 2 or with the depth texture extension available.
  60481. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  60482. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  60483. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  60484. */
  60485. RenderTargetTexture.prototype.createDepthStencilTexture = function (comparisonFunction, bilinearFiltering, generateStencil) {
  60486. if (comparisonFunction === void 0) { comparisonFunction = 0; }
  60487. if (bilinearFiltering === void 0) { bilinearFiltering = true; }
  60488. if (generateStencil === void 0) { generateStencil = false; }
  60489. if (!this.getScene()) {
  60490. return;
  60491. }
  60492. var engine = this.getScene().getEngine();
  60493. this.depthStencilTexture = engine.createDepthStencilTexture(this._size, {
  60494. bilinearFiltering: bilinearFiltering,
  60495. comparisonFunction: comparisonFunction,
  60496. generateStencil: generateStencil,
  60497. isCube: this.isCube
  60498. });
  60499. engine.setFrameBufferDepthStencilTexture(this);
  60500. };
  60501. RenderTargetTexture.prototype._processSizeParameter = function (size) {
  60502. if (size.ratio) {
  60503. this._sizeRatio = size.ratio;
  60504. this._size = {
  60505. width: this._bestReflectionRenderTargetDimension(this._engine.getRenderWidth(), this._sizeRatio),
  60506. height: this._bestReflectionRenderTargetDimension(this._engine.getRenderHeight(), this._sizeRatio)
  60507. };
  60508. }
  60509. else {
  60510. this._size = size;
  60511. }
  60512. };
  60513. Object.defineProperty(RenderTargetTexture.prototype, "samples", {
  60514. /**
  60515. * Define the number of samples to use in case of MSAA.
  60516. * It defaults to one meaning no MSAA has been enabled.
  60517. */
  60518. get: function () {
  60519. return this._samples;
  60520. },
  60521. set: function (value) {
  60522. if (this._samples === value) {
  60523. return;
  60524. }
  60525. var scene = this.getScene();
  60526. if (!scene) {
  60527. return;
  60528. }
  60529. this._samples = scene.getEngine().updateRenderTargetTextureSampleCount(this._texture, value);
  60530. },
  60531. enumerable: true,
  60532. configurable: true
  60533. });
  60534. /**
  60535. * Resets the refresh counter of the texture and start bak from scratch.
  60536. * Could be useful to regenerate the texture if it is setup to render only once.
  60537. */
  60538. RenderTargetTexture.prototype.resetRefreshCounter = function () {
  60539. this._currentRefreshId = -1;
  60540. };
  60541. Object.defineProperty(RenderTargetTexture.prototype, "refreshRate", {
  60542. /**
  60543. * Define the refresh rate of the texture or the rendering frequency.
  60544. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  60545. */
  60546. get: function () {
  60547. return this._refreshRate;
  60548. },
  60549. set: function (value) {
  60550. this._refreshRate = value;
  60551. this.resetRefreshCounter();
  60552. },
  60553. enumerable: true,
  60554. configurable: true
  60555. });
  60556. /**
  60557. * Adds a post process to the render target rendering passes.
  60558. * @param postProcess define the post process to add
  60559. */
  60560. RenderTargetTexture.prototype.addPostProcess = function (postProcess) {
  60561. if (!this._postProcessManager) {
  60562. var scene = this.getScene();
  60563. if (!scene) {
  60564. return;
  60565. }
  60566. this._postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__["PostProcessManager"](scene);
  60567. this._postProcesses = new Array();
  60568. }
  60569. this._postProcesses.push(postProcess);
  60570. this._postProcesses[0].autoClear = false;
  60571. };
  60572. /**
  60573. * Clear all the post processes attached to the render target
  60574. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  60575. */
  60576. RenderTargetTexture.prototype.clearPostProcesses = function (dispose) {
  60577. if (dispose === void 0) { dispose = false; }
  60578. if (!this._postProcesses) {
  60579. return;
  60580. }
  60581. if (dispose) {
  60582. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  60583. var postProcess = _a[_i];
  60584. postProcess.dispose();
  60585. }
  60586. }
  60587. this._postProcesses = [];
  60588. };
  60589. /**
  60590. * Remove one of the post process from the list of attached post processes to the texture
  60591. * @param postProcess define the post process to remove from the list
  60592. */
  60593. RenderTargetTexture.prototype.removePostProcess = function (postProcess) {
  60594. if (!this._postProcesses) {
  60595. return;
  60596. }
  60597. var index = this._postProcesses.indexOf(postProcess);
  60598. if (index === -1) {
  60599. return;
  60600. }
  60601. this._postProcesses.splice(index, 1);
  60602. if (this._postProcesses.length > 0) {
  60603. this._postProcesses[0].autoClear = false;
  60604. }
  60605. };
  60606. /** @hidden */
  60607. RenderTargetTexture.prototype._shouldRender = function () {
  60608. if (this._currentRefreshId === -1) { // At least render once
  60609. this._currentRefreshId = 1;
  60610. return true;
  60611. }
  60612. if (this.refreshRate === this._currentRefreshId) {
  60613. this._currentRefreshId = 1;
  60614. return true;
  60615. }
  60616. this._currentRefreshId++;
  60617. return false;
  60618. };
  60619. /**
  60620. * Gets the actual render size of the texture.
  60621. * @returns the width of the render size
  60622. */
  60623. RenderTargetTexture.prototype.getRenderSize = function () {
  60624. return this.getRenderWidth();
  60625. };
  60626. /**
  60627. * Gets the actual render width of the texture.
  60628. * @returns the width of the render size
  60629. */
  60630. RenderTargetTexture.prototype.getRenderWidth = function () {
  60631. if (this._size.width) {
  60632. return this._size.width;
  60633. }
  60634. return this._size;
  60635. };
  60636. /**
  60637. * Gets the actual render height of the texture.
  60638. * @returns the height of the render size
  60639. */
  60640. RenderTargetTexture.prototype.getRenderHeight = function () {
  60641. if (this._size.width) {
  60642. return this._size.height;
  60643. }
  60644. return this._size;
  60645. };
  60646. Object.defineProperty(RenderTargetTexture.prototype, "canRescale", {
  60647. /**
  60648. * Get if the texture can be rescaled or not.
  60649. */
  60650. get: function () {
  60651. return true;
  60652. },
  60653. enumerable: true,
  60654. configurable: true
  60655. });
  60656. /**
  60657. * Resize the texture using a ratio.
  60658. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  60659. */
  60660. RenderTargetTexture.prototype.scale = function (ratio) {
  60661. var newSize = this.getRenderSize() * ratio;
  60662. this.resize(newSize);
  60663. };
  60664. /**
  60665. * Get the texture reflection matrix used to rotate/transform the reflection.
  60666. * @returns the reflection matrix
  60667. */
  60668. RenderTargetTexture.prototype.getReflectionTextureMatrix = function () {
  60669. if (this.isCube) {
  60670. return this._textureMatrix;
  60671. }
  60672. return _super.prototype.getReflectionTextureMatrix.call(this);
  60673. };
  60674. /**
  60675. * Resize the texture to a new desired size.
  60676. * Be carrefull as it will recreate all the data in the new texture.
  60677. * @param size Define the new size. It can be:
  60678. * - a number for squared texture,
  60679. * - an object containing { width: number, height: number }
  60680. * - or an object containing a ratio { ratio: number }
  60681. */
  60682. RenderTargetTexture.prototype.resize = function (size) {
  60683. var wasCube = this.isCube;
  60684. this.releaseInternalTexture();
  60685. var scene = this.getScene();
  60686. if (!scene) {
  60687. return;
  60688. }
  60689. this._processSizeParameter(size);
  60690. if (wasCube) {
  60691. this._texture = scene.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions);
  60692. }
  60693. else {
  60694. this._texture = scene.getEngine().createRenderTargetTexture(this._size, this._renderTargetOptions);
  60695. }
  60696. };
  60697. /**
  60698. * Renders all the objects from the render list into the texture.
  60699. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  60700. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  60701. */
  60702. RenderTargetTexture.prototype.render = function (useCameraPostProcess, dumpForDebug) {
  60703. if (useCameraPostProcess === void 0) { useCameraPostProcess = false; }
  60704. if (dumpForDebug === void 0) { dumpForDebug = false; }
  60705. var scene = this.getScene();
  60706. if (!scene) {
  60707. return;
  60708. }
  60709. var engine = scene.getEngine();
  60710. if (this.useCameraPostProcesses !== undefined) {
  60711. useCameraPostProcess = this.useCameraPostProcesses;
  60712. }
  60713. if (this._waitingRenderList) {
  60714. this.renderList = [];
  60715. for (var index = 0; index < this._waitingRenderList.length; index++) {
  60716. var id = this._waitingRenderList[index];
  60717. var mesh_1 = scene.getMeshByID(id);
  60718. if (mesh_1) {
  60719. this.renderList.push(mesh_1);
  60720. }
  60721. }
  60722. delete this._waitingRenderList;
  60723. }
  60724. // Is predicate defined?
  60725. if (this.renderListPredicate) {
  60726. if (this.renderList) {
  60727. this.renderList.length = 0; // Clear previous renderList
  60728. }
  60729. else {
  60730. this.renderList = [];
  60731. }
  60732. var scene = this.getScene();
  60733. if (!scene) {
  60734. return;
  60735. }
  60736. var sceneMeshes = scene.meshes;
  60737. for (var index = 0; index < sceneMeshes.length; index++) {
  60738. var mesh = sceneMeshes[index];
  60739. if (this.renderListPredicate(mesh)) {
  60740. this.renderList.push(mesh);
  60741. }
  60742. }
  60743. }
  60744. this.onBeforeBindObservable.notifyObservers(this);
  60745. // Set custom projection.
  60746. // Needs to be before binding to prevent changing the aspect ratio.
  60747. var camera;
  60748. if (this.activeCamera) {
  60749. camera = this.activeCamera;
  60750. engine.setViewport(this.activeCamera.viewport, this.getRenderWidth(), this.getRenderHeight());
  60751. if (this.activeCamera !== scene.activeCamera) {
  60752. scene.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(true));
  60753. }
  60754. }
  60755. else {
  60756. camera = scene.activeCamera;
  60757. if (camera) {
  60758. engine.setViewport(camera.viewport, this.getRenderWidth(), this.getRenderHeight());
  60759. }
  60760. }
  60761. // Prepare renderingManager
  60762. this._renderingManager.reset();
  60763. var currentRenderList = this.renderList ? this.renderList : scene.getActiveMeshes().data;
  60764. var currentRenderListLength = this.renderList ? this.renderList.length : scene.getActiveMeshes().length;
  60765. var sceneRenderId = scene.getRenderId();
  60766. for (var meshIndex = 0; meshIndex < currentRenderListLength; meshIndex++) {
  60767. var mesh = currentRenderList[meshIndex];
  60768. if (mesh) {
  60769. if (!mesh.isReady(this.refreshRate === 0)) {
  60770. this.resetRefreshCounter();
  60771. continue;
  60772. }
  60773. mesh._preActivateForIntermediateRendering(sceneRenderId);
  60774. var isMasked = void 0;
  60775. if (!this.renderList && camera) {
  60776. isMasked = ((mesh.layerMask & camera.layerMask) === 0);
  60777. }
  60778. else {
  60779. isMasked = false;
  60780. }
  60781. if (mesh.isEnabled() && mesh.isVisible && mesh.subMeshes && !isMasked) {
  60782. mesh._activate(sceneRenderId);
  60783. for (var subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  60784. var subMesh = mesh.subMeshes[subIndex];
  60785. scene._activeIndices.addCount(subMesh.indexCount, false);
  60786. this._renderingManager.dispatch(subMesh, mesh);
  60787. }
  60788. }
  60789. }
  60790. }
  60791. for (var particleIndex = 0; particleIndex < scene.particleSystems.length; particleIndex++) {
  60792. var particleSystem = scene.particleSystems[particleIndex];
  60793. var emitter = particleSystem.emitter;
  60794. if (!particleSystem.isStarted() || !emitter || !emitter.position || !emitter.isEnabled()) {
  60795. continue;
  60796. }
  60797. if (currentRenderList.indexOf(emitter) >= 0) {
  60798. this._renderingManager.dispatchParticles(particleSystem);
  60799. }
  60800. }
  60801. if (this.isCube) {
  60802. for (var face = 0; face < 6; face++) {
  60803. this.renderToTarget(face, currentRenderList, useCameraPostProcess, dumpForDebug);
  60804. scene.incrementRenderId();
  60805. scene.resetCachedMaterial();
  60806. }
  60807. }
  60808. else {
  60809. this.renderToTarget(0, currentRenderList, useCameraPostProcess, dumpForDebug);
  60810. }
  60811. this.onAfterUnbindObservable.notifyObservers(this);
  60812. if (scene.activeCamera) {
  60813. if (this.activeCamera && this.activeCamera !== scene.activeCamera) {
  60814. scene.setTransformMatrix(scene.activeCamera.getViewMatrix(), scene.activeCamera.getProjectionMatrix(true));
  60815. }
  60816. engine.setViewport(scene.activeCamera.viewport);
  60817. }
  60818. scene.resetCachedMaterial();
  60819. };
  60820. RenderTargetTexture.prototype._bestReflectionRenderTargetDimension = function (renderDimension, scale) {
  60821. var minimum = 128;
  60822. var x = renderDimension * scale;
  60823. var curved = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].NearestPOT(x + (minimum * minimum / (minimum + x)));
  60824. // Ensure we don't exceed the render dimension (while staying POT)
  60825. return Math.min(_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].FloorPOT(renderDimension), curved);
  60826. };
  60827. /**
  60828. * @hidden
  60829. * @param faceIndex face index to bind to if this is a cubetexture
  60830. */
  60831. RenderTargetTexture.prototype._bindFrameBuffer = function (faceIndex) {
  60832. if (faceIndex === void 0) { faceIndex = 0; }
  60833. var scene = this.getScene();
  60834. if (!scene) {
  60835. return;
  60836. }
  60837. var engine = scene.getEngine();
  60838. if (this._texture) {
  60839. engine.bindFramebuffer(this._texture, this.isCube ? faceIndex : undefined, undefined, undefined, this.ignoreCameraViewport, this.depthStencilTexture ? this.depthStencilTexture : undefined);
  60840. }
  60841. };
  60842. RenderTargetTexture.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  60843. var _this = this;
  60844. if (!this._texture) {
  60845. return;
  60846. }
  60847. engine.unBindFramebuffer(this._texture, this.isCube, function () {
  60848. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  60849. });
  60850. };
  60851. RenderTargetTexture.prototype.renderToTarget = function (faceIndex, currentRenderList, useCameraPostProcess, dumpForDebug) {
  60852. var scene = this.getScene();
  60853. if (!scene) {
  60854. return;
  60855. }
  60856. var engine = scene.getEngine();
  60857. if (!this._texture) {
  60858. return;
  60859. }
  60860. // Bind
  60861. if (this._postProcessManager) {
  60862. this._postProcessManager._prepareFrame(this._texture, this._postProcesses);
  60863. }
  60864. else if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(this._texture)) {
  60865. this._bindFrameBuffer(faceIndex);
  60866. }
  60867. this.onBeforeRenderObservable.notifyObservers(faceIndex);
  60868. // Clear
  60869. if (this.onClearObservable.hasObservers()) {
  60870. this.onClearObservable.notifyObservers(engine);
  60871. }
  60872. else {
  60873. engine.clear(this.clearColor || scene.clearColor, true, true, true);
  60874. }
  60875. if (!this._doNotChangeAspectRatio) {
  60876. scene.updateTransformMatrix(true);
  60877. }
  60878. // Before Camera Draw
  60879. for (var _i = 0, _a = scene._beforeRenderTargetDrawStage; _i < _a.length; _i++) {
  60880. var step = _a[_i];
  60881. step.action(this);
  60882. }
  60883. // Render
  60884. this._renderingManager.render(this.customRenderFunction, currentRenderList, this.renderParticles, this.renderSprites);
  60885. // After Camera Draw
  60886. for (var _b = 0, _c = scene._afterRenderTargetDrawStage; _b < _c.length; _b++) {
  60887. var step = _c[_b];
  60888. step.action(this);
  60889. }
  60890. if (this._postProcessManager) {
  60891. this._postProcessManager._finalizeFrame(false, this._texture, faceIndex, this._postProcesses, this.ignoreCameraViewport);
  60892. }
  60893. else if (useCameraPostProcess) {
  60894. scene.postProcessManager._finalizeFrame(false, this._texture, faceIndex);
  60895. }
  60896. if (!this._doNotChangeAspectRatio) {
  60897. scene.updateTransformMatrix(true);
  60898. }
  60899. // Dump ?
  60900. if (dumpForDebug) {
  60901. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), engine);
  60902. }
  60903. // Unbind
  60904. if (!this.isCube || faceIndex === 5) {
  60905. if (this.isCube) {
  60906. if (faceIndex === 5) {
  60907. engine.generateMipMapsForCubemap(this._texture);
  60908. }
  60909. }
  60910. this.unbindFrameBuffer(engine, faceIndex);
  60911. }
  60912. else {
  60913. this.onAfterRenderObservable.notifyObservers(faceIndex);
  60914. }
  60915. };
  60916. /**
  60917. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  60918. * This allowed control for front to back rendering or reversly depending of the special needs.
  60919. *
  60920. * @param renderingGroupId The rendering group id corresponding to its index
  60921. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  60922. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  60923. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  60924. */
  60925. RenderTargetTexture.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  60926. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  60927. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  60928. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  60929. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  60930. };
  60931. /**
  60932. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  60933. *
  60934. * @param renderingGroupId The rendering group id corresponding to its index
  60935. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  60936. */
  60937. RenderTargetTexture.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  60938. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  60939. this._renderingManager._useSceneAutoClearSetup = false;
  60940. };
  60941. /**
  60942. * Clones the texture.
  60943. * @returns the cloned texture
  60944. */
  60945. RenderTargetTexture.prototype.clone = function () {
  60946. var textureSize = this.getSize();
  60947. 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);
  60948. // Base texture
  60949. newTexture.hasAlpha = this.hasAlpha;
  60950. newTexture.level = this.level;
  60951. // RenderTarget Texture
  60952. newTexture.coordinatesMode = this.coordinatesMode;
  60953. if (this.renderList) {
  60954. newTexture.renderList = this.renderList.slice(0);
  60955. }
  60956. return newTexture;
  60957. };
  60958. /**
  60959. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  60960. * @returns The JSON representation of the texture
  60961. */
  60962. RenderTargetTexture.prototype.serialize = function () {
  60963. if (!this.name) {
  60964. return null;
  60965. }
  60966. var serializationObject = _super.prototype.serialize.call(this);
  60967. serializationObject.renderTargetSize = this.getRenderSize();
  60968. serializationObject.renderList = [];
  60969. if (this.renderList) {
  60970. for (var index = 0; index < this.renderList.length; index++) {
  60971. serializationObject.renderList.push(this.renderList[index].id);
  60972. }
  60973. }
  60974. return serializationObject;
  60975. };
  60976. /**
  60977. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  60978. */
  60979. RenderTargetTexture.prototype.disposeFramebufferObjects = function () {
  60980. var objBuffer = this.getInternalTexture();
  60981. var scene = this.getScene();
  60982. if (objBuffer && scene) {
  60983. scene.getEngine()._releaseFramebufferObjects(objBuffer);
  60984. }
  60985. };
  60986. /**
  60987. * Dispose the texture and release its associated resources.
  60988. */
  60989. RenderTargetTexture.prototype.dispose = function () {
  60990. if (this._postProcessManager) {
  60991. this._postProcessManager.dispose();
  60992. this._postProcessManager = null;
  60993. }
  60994. this.clearPostProcesses(true);
  60995. if (this._resizeObserver) {
  60996. this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver);
  60997. this._resizeObserver = null;
  60998. }
  60999. this.renderList = null;
  61000. // Remove from custom render targets
  61001. var scene = this.getScene();
  61002. if (!scene) {
  61003. return;
  61004. }
  61005. var index = scene.customRenderTargets.indexOf(this);
  61006. if (index >= 0) {
  61007. scene.customRenderTargets.splice(index, 1);
  61008. }
  61009. for (var _i = 0, _a = scene.cameras; _i < _a.length; _i++) {
  61010. var camera = _a[_i];
  61011. index = camera.customRenderTargets.indexOf(this);
  61012. if (index >= 0) {
  61013. camera.customRenderTargets.splice(index, 1);
  61014. }
  61015. }
  61016. _super.prototype.dispose.call(this);
  61017. };
  61018. /** @hidden */
  61019. RenderTargetTexture.prototype._rebuild = function () {
  61020. if (this.refreshRate === RenderTargetTexture.REFRESHRATE_RENDER_ONCE) {
  61021. this.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;
  61022. }
  61023. if (this._postProcessManager) {
  61024. this._postProcessManager._rebuild();
  61025. }
  61026. };
  61027. /**
  61028. * Clear the info related to rendering groups preventing retention point in material dispose.
  61029. */
  61030. RenderTargetTexture.prototype.freeRenderingGroups = function () {
  61031. if (this._renderingManager) {
  61032. this._renderingManager.freeRenderingGroups();
  61033. }
  61034. };
  61035. /**
  61036. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  61037. * @returns the view count
  61038. */
  61039. RenderTargetTexture.prototype.getViewCount = function () {
  61040. return 1;
  61041. };
  61042. /**
  61043. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  61044. */
  61045. RenderTargetTexture.REFRESHRATE_RENDER_ONCE = 0;
  61046. /**
  61047. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  61048. */
  61049. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME = 1;
  61050. /**
  61051. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  61052. * the central point of your effect and can save a lot of performances.
  61053. */
  61054. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2;
  61055. return RenderTargetTexture;
  61056. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  61057. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  61058. return new RenderTargetTexture(name, renderTargetSize, scene, generateMipMaps);
  61059. };
  61060. /***/ }),
  61061. /***/ "./Materials/Textures/texture.ts":
  61062. /*!***************************************!*\
  61063. !*** ./Materials/Textures/texture.ts ***!
  61064. \***************************************/
  61065. /*! exports provided: Texture */
  61066. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61067. "use strict";
  61068. __webpack_require__.r(__webpack_exports__);
  61069. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return Texture; });
  61070. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  61071. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  61072. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  61073. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  61074. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  61075. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  61076. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  61077. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  61078. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  61079. /**
  61080. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  61081. * @see http://doc.babylonjs.com/babylon101/materials#texture
  61082. */
  61083. var Texture = /** @class */ (function (_super) {
  61084. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Texture, _super);
  61085. /**
  61086. * Instantiates a new texture.
  61087. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  61088. * @see http://doc.babylonjs.com/babylon101/materials#texture
  61089. * @param url define the url of the picture to load as a texture
  61090. * @param scene define the scene the texture will belong to
  61091. * @param noMipmap define if the texture will require mip maps or not
  61092. * @param invertY define if the texture needs to be inverted on the y axis during loading
  61093. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  61094. * @param onLoad define a callback triggered when the texture has been loaded
  61095. * @param onError define a callback triggered when an error occurred during the loading session
  61096. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  61097. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  61098. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  61099. */
  61100. function Texture(url, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format) {
  61101. if (noMipmap === void 0) { noMipmap = false; }
  61102. if (invertY === void 0) { invertY = true; }
  61103. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  61104. if (onLoad === void 0) { onLoad = null; }
  61105. if (onError === void 0) { onError = null; }
  61106. if (buffer === void 0) { buffer = null; }
  61107. if (deleteBuffer === void 0) { deleteBuffer = false; }
  61108. var _this = _super.call(this, scene) || this;
  61109. /**
  61110. * Define an offset on the texture to offset the u coordinates of the UVs
  61111. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  61112. */
  61113. _this.uOffset = 0;
  61114. /**
  61115. * Define an offset on the texture to offset the v coordinates of the UVs
  61116. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  61117. */
  61118. _this.vOffset = 0;
  61119. /**
  61120. * Define an offset on the texture to scale the u coordinates of the UVs
  61121. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  61122. */
  61123. _this.uScale = 1.0;
  61124. /**
  61125. * Define an offset on the texture to scale the v coordinates of the UVs
  61126. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  61127. */
  61128. _this.vScale = 1.0;
  61129. /**
  61130. * Define an offset on the texture to rotate around the u coordinates of the UVs
  61131. * @see http://doc.babylonjs.com/how_to/more_materials
  61132. */
  61133. _this.uAng = 0;
  61134. /**
  61135. * Define an offset on the texture to rotate around the v coordinates of the UVs
  61136. * @see http://doc.babylonjs.com/how_to/more_materials
  61137. */
  61138. _this.vAng = 0;
  61139. /**
  61140. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  61141. * @see http://doc.babylonjs.com/how_to/more_materials
  61142. */
  61143. _this.wAng = 0;
  61144. /**
  61145. * Defines the center of rotation (U)
  61146. */
  61147. _this.uRotationCenter = 0.5;
  61148. /**
  61149. * Defines the center of rotation (V)
  61150. */
  61151. _this.vRotationCenter = 0.5;
  61152. /**
  61153. * Defines the center of rotation (W)
  61154. */
  61155. _this.wRotationCenter = 0.5;
  61156. /** @hidden */
  61157. _this._initialSamplingMode = Texture.BILINEAR_SAMPLINGMODE;
  61158. /**
  61159. * Observable triggered once the texture has been loaded.
  61160. */
  61161. _this.onLoadObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  61162. _this._isBlocking = true;
  61163. _this.name = url || "";
  61164. _this.url = url;
  61165. _this._noMipmap = noMipmap;
  61166. _this._invertY = invertY;
  61167. _this._initialSamplingMode = samplingMode;
  61168. _this._buffer = buffer;
  61169. _this._deleteBuffer = deleteBuffer;
  61170. if (format) {
  61171. _this._format = format;
  61172. }
  61173. scene = _this.getScene();
  61174. if (!scene) {
  61175. return _this;
  61176. }
  61177. scene.getEngine().onBeforeTextureInitObservable.notifyObservers(_this);
  61178. var load = function () {
  61179. if (_this._texture && _this._texture._invertVScale) {
  61180. _this.vScale = -1;
  61181. }
  61182. if (_this.onLoadObservable.hasObservers()) {
  61183. _this.onLoadObservable.notifyObservers(_this);
  61184. }
  61185. if (onLoad) {
  61186. onLoad();
  61187. }
  61188. if (!_this.isBlocking && scene) {
  61189. scene.resetCachedMaterial();
  61190. }
  61191. };
  61192. if (!_this.url) {
  61193. _this._delayedOnLoad = load;
  61194. _this._delayedOnError = onError;
  61195. return _this;
  61196. }
  61197. _this._texture = _this._getFromCache(_this.url, noMipmap, samplingMode, invertY);
  61198. if (!_this._texture) {
  61199. if (!scene.useDelayedTextureLoading) {
  61200. _this._texture = scene.getEngine().createTexture(_this.url, noMipmap, invertY, scene, samplingMode, load, onError, _this._buffer, undefined, _this._format);
  61201. if (deleteBuffer) {
  61202. delete _this._buffer;
  61203. }
  61204. }
  61205. else {
  61206. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  61207. _this._delayedOnLoad = load;
  61208. _this._delayedOnError = onError;
  61209. }
  61210. }
  61211. else {
  61212. if (_this._texture.isReady) {
  61213. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(function () { return load(); });
  61214. }
  61215. else {
  61216. _this._texture.onLoadedObservable.add(load);
  61217. }
  61218. }
  61219. return _this;
  61220. }
  61221. Object.defineProperty(Texture.prototype, "noMipmap", {
  61222. /**
  61223. * Are mip maps generated for this texture or not.
  61224. */
  61225. get: function () {
  61226. return this._noMipmap;
  61227. },
  61228. enumerable: true,
  61229. configurable: true
  61230. });
  61231. Object.defineProperty(Texture.prototype, "isBlocking", {
  61232. get: function () {
  61233. return this._isBlocking;
  61234. },
  61235. /**
  61236. * Is the texture preventing material to render while loading.
  61237. * If false, a default texture will be used instead of the loading one during the preparation step.
  61238. */
  61239. set: function (value) {
  61240. this._isBlocking = value;
  61241. },
  61242. enumerable: true,
  61243. configurable: true
  61244. });
  61245. Object.defineProperty(Texture.prototype, "samplingMode", {
  61246. /**
  61247. * Get the current sampling mode associated with the texture.
  61248. */
  61249. get: function () {
  61250. if (!this._texture) {
  61251. return this._initialSamplingMode;
  61252. }
  61253. return this._texture.samplingMode;
  61254. },
  61255. enumerable: true,
  61256. configurable: true
  61257. });
  61258. Object.defineProperty(Texture.prototype, "invertY", {
  61259. /**
  61260. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  61261. */
  61262. get: function () {
  61263. return this._invertY;
  61264. },
  61265. enumerable: true,
  61266. configurable: true
  61267. });
  61268. /**
  61269. * Update the url (and optional buffer) of this texture if url was null during construction.
  61270. * @param url the url of the texture
  61271. * @param buffer the buffer of the texture (defaults to null)
  61272. * @param onLoad callback called when the texture is loaded (defaults to null)
  61273. */
  61274. Texture.prototype.updateURL = function (url, buffer, onLoad) {
  61275. if (buffer === void 0) { buffer = null; }
  61276. if (this.url) {
  61277. this.releaseInternalTexture();
  61278. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  61279. }
  61280. this.url = url;
  61281. this._buffer = buffer;
  61282. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  61283. if (onLoad) {
  61284. this._delayedOnLoad = onLoad;
  61285. }
  61286. this.delayLoad();
  61287. };
  61288. /**
  61289. * Finish the loading sequence of a texture flagged as delayed load.
  61290. * @hidden
  61291. */
  61292. Texture.prototype.delayLoad = function () {
  61293. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  61294. return;
  61295. }
  61296. var scene = this.getScene();
  61297. if (!scene) {
  61298. return;
  61299. }
  61300. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  61301. this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode, this._invertY);
  61302. if (!this._texture) {
  61303. this._texture = scene.getEngine().createTexture(this.url, this._noMipmap, this._invertY, scene, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format);
  61304. if (this._deleteBuffer) {
  61305. delete this._buffer;
  61306. }
  61307. }
  61308. else {
  61309. if (this._delayedOnLoad) {
  61310. if (this._texture.isReady) {
  61311. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(this._delayedOnLoad);
  61312. }
  61313. else {
  61314. this._texture.onLoadedObservable.add(this._delayedOnLoad);
  61315. }
  61316. }
  61317. }
  61318. this._delayedOnLoad = null;
  61319. this._delayedOnError = null;
  61320. };
  61321. Texture.prototype._prepareRowForTextureGeneration = function (x, y, z, t) {
  61322. x *= this.uScale;
  61323. y *= this.vScale;
  61324. x -= this.uRotationCenter * this.uScale;
  61325. y -= this.vRotationCenter * this.vScale;
  61326. z -= this.wRotationCenter;
  61327. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, this._rowGenerationMatrix, t);
  61328. t.x += this.uRotationCenter * this.uScale + this.uOffset;
  61329. t.y += this.vRotationCenter * this.vScale + this.vOffset;
  61330. t.z += this.wRotationCenter;
  61331. };
  61332. /**
  61333. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  61334. * @returns the transform matrix of the texture.
  61335. */
  61336. Texture.prototype.getTextureMatrix = function () {
  61337. var _this = this;
  61338. if (this.uOffset === this._cachedUOffset &&
  61339. this.vOffset === this._cachedVOffset &&
  61340. this.uScale === this._cachedUScale &&
  61341. this.vScale === this._cachedVScale &&
  61342. this.uAng === this._cachedUAng &&
  61343. this.vAng === this._cachedVAng &&
  61344. this.wAng === this._cachedWAng) {
  61345. return this._cachedTextureMatrix;
  61346. }
  61347. this._cachedUOffset = this.uOffset;
  61348. this._cachedVOffset = this.vOffset;
  61349. this._cachedUScale = this.uScale;
  61350. this._cachedVScale = this.vScale;
  61351. this._cachedUAng = this.uAng;
  61352. this._cachedVAng = this.vAng;
  61353. this._cachedWAng = this.wAng;
  61354. if (!this._cachedTextureMatrix) {
  61355. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  61356. this._rowGenerationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  61357. this._t0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  61358. this._t1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  61359. this._t2 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  61360. }
  61361. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(this.vAng, this.uAng, this.wAng, this._rowGenerationMatrix);
  61362. this._prepareRowForTextureGeneration(0, 0, 0, this._t0);
  61363. this._prepareRowForTextureGeneration(1.0, 0, 0, this._t1);
  61364. this._prepareRowForTextureGeneration(0, 1.0, 0, this._t2);
  61365. this._t1.subtractInPlace(this._t0);
  61366. this._t2.subtractInPlace(this._t0);
  61367. _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);
  61368. var scene = this.getScene();
  61369. if (!scene) {
  61370. return this._cachedTextureMatrix;
  61371. }
  61372. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  61373. return mat.hasTexture(_this);
  61374. });
  61375. return this._cachedTextureMatrix;
  61376. };
  61377. /**
  61378. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  61379. * @returns The reflection texture transform
  61380. */
  61381. Texture.prototype.getReflectionTextureMatrix = function () {
  61382. var _this = this;
  61383. var scene = this.getScene();
  61384. if (!scene) {
  61385. return this._cachedTextureMatrix;
  61386. }
  61387. if (this.uOffset === this._cachedUOffset &&
  61388. this.vOffset === this._cachedVOffset &&
  61389. this.uScale === this._cachedUScale &&
  61390. this.vScale === this._cachedVScale &&
  61391. this.coordinatesMode === this._cachedCoordinatesMode) {
  61392. if (this.coordinatesMode === Texture.PROJECTION_MODE) {
  61393. if (this._cachedProjectionMatrixId === scene.getProjectionMatrix().updateFlag) {
  61394. return this._cachedTextureMatrix;
  61395. }
  61396. }
  61397. else {
  61398. return this._cachedTextureMatrix;
  61399. }
  61400. }
  61401. if (!this._cachedTextureMatrix) {
  61402. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  61403. }
  61404. if (!this._projectionModeMatrix) {
  61405. this._projectionModeMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  61406. }
  61407. this._cachedUOffset = this.uOffset;
  61408. this._cachedVOffset = this.vOffset;
  61409. this._cachedUScale = this.uScale;
  61410. this._cachedVScale = this.vScale;
  61411. this._cachedCoordinatesMode = this.coordinatesMode;
  61412. switch (this.coordinatesMode) {
  61413. case Texture.PLANAR_MODE:
  61414. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  61415. this._cachedTextureMatrix[0] = this.uScale;
  61416. this._cachedTextureMatrix[5] = this.vScale;
  61417. this._cachedTextureMatrix[12] = this.uOffset;
  61418. this._cachedTextureMatrix[13] = this.vOffset;
  61419. break;
  61420. case Texture.PROJECTION_MODE:
  61421. _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);
  61422. var projectionMatrix = scene.getProjectionMatrix();
  61423. this._cachedProjectionMatrixId = projectionMatrix.updateFlag;
  61424. projectionMatrix.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
  61425. break;
  61426. default:
  61427. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  61428. break;
  61429. }
  61430. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  61431. return (mat.getActiveTextures().indexOf(_this) !== -1);
  61432. });
  61433. return this._cachedTextureMatrix;
  61434. };
  61435. /**
  61436. * Clones the texture.
  61437. * @returns the cloned texture
  61438. */
  61439. Texture.prototype.clone = function () {
  61440. var _this = this;
  61441. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  61442. return new Texture(_this._texture ? _this._texture.url : null, _this.getScene(), _this._noMipmap, _this._invertY, _this.samplingMode, undefined, undefined, _this._texture ? _this._texture._buffer : undefined);
  61443. }, this);
  61444. };
  61445. /**
  61446. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  61447. * @returns The JSON representation of the texture
  61448. */
  61449. Texture.prototype.serialize = function () {
  61450. var serializationObject = _super.prototype.serialize.call(this);
  61451. if (typeof this._buffer === "string" && this._buffer.substr(0, 5) === "data:") {
  61452. serializationObject.base64String = this._buffer;
  61453. serializationObject.name = serializationObject.name.replace("data:", "");
  61454. }
  61455. serializationObject.invertY = this._invertY;
  61456. serializationObject.samplingMode = this.samplingMode;
  61457. return serializationObject;
  61458. };
  61459. /**
  61460. * Get the current class name of the texture useful for serialization or dynamic coding.
  61461. * @returns "Texture"
  61462. */
  61463. Texture.prototype.getClassName = function () {
  61464. return "Texture";
  61465. };
  61466. /**
  61467. * Dispose the texture and release its associated resources.
  61468. */
  61469. Texture.prototype.dispose = function () {
  61470. _super.prototype.dispose.call(this);
  61471. this.onLoadObservable.clear();
  61472. this._delayedOnLoad = null;
  61473. this._delayedOnError = null;
  61474. };
  61475. /**
  61476. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  61477. * @param parsedTexture Define the JSON representation of the texture
  61478. * @param scene Define the scene the parsed texture should be instantiated in
  61479. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  61480. * @returns The parsed texture if successful
  61481. */
  61482. Texture.Parse = function (parsedTexture, scene, rootUrl) {
  61483. if (parsedTexture.customType) {
  61484. var customTexture = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Instantiate(parsedTexture.customType);
  61485. // Update Sampling Mode
  61486. var parsedCustomTexture = customTexture.Parse(parsedTexture, scene, rootUrl);
  61487. if (parsedTexture.samplingMode && parsedCustomTexture.updateSamplingMode && parsedCustomTexture._samplingMode) {
  61488. if (parsedCustomTexture._samplingMode !== parsedTexture.samplingMode) {
  61489. parsedCustomTexture.updateSamplingMode(parsedTexture.samplingMode);
  61490. }
  61491. }
  61492. return parsedCustomTexture;
  61493. }
  61494. if (parsedTexture.isCube && !parsedTexture.isRenderTarget) {
  61495. return Texture._CubeTextureParser(parsedTexture, scene, rootUrl);
  61496. }
  61497. if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
  61498. return null;
  61499. }
  61500. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  61501. var generateMipMaps = true;
  61502. if (parsedTexture.noMipmap) {
  61503. generateMipMaps = false;
  61504. }
  61505. if (parsedTexture.mirrorPlane) {
  61506. var mirrorTexture = Texture._CreateMirror(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  61507. mirrorTexture._waitingRenderList = parsedTexture.renderList;
  61508. mirrorTexture.mirrorPlane = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"].FromArray(parsedTexture.mirrorPlane);
  61509. return mirrorTexture;
  61510. }
  61511. else if (parsedTexture.isRenderTarget) {
  61512. var renderTargetTexture = null;
  61513. if (parsedTexture.isCube) {
  61514. // Search for an existing reflection probe (which contains a cube render target texture)
  61515. if (scene.reflectionProbes) {
  61516. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  61517. var probe = scene.reflectionProbes[index];
  61518. if (probe.name === parsedTexture.name) {
  61519. return probe.cubeTexture;
  61520. }
  61521. }
  61522. }
  61523. }
  61524. else {
  61525. renderTargetTexture = Texture._CreateRenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  61526. renderTargetTexture._waitingRenderList = parsedTexture.renderList;
  61527. }
  61528. return renderTargetTexture;
  61529. }
  61530. else {
  61531. var texture;
  61532. if (parsedTexture.base64String) {
  61533. texture = Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene, !generateMipMaps);
  61534. }
  61535. else {
  61536. var url = rootUrl + parsedTexture.name;
  61537. if (Texture.UseSerializedUrlIfAny && parsedTexture.url) {
  61538. url = parsedTexture.url;
  61539. }
  61540. texture = new Texture(url, scene, !generateMipMaps, parsedTexture.invertY);
  61541. }
  61542. return texture;
  61543. }
  61544. }, parsedTexture, scene);
  61545. // Update Sampling Mode
  61546. if (parsedTexture.samplingMode) {
  61547. var sampling = parsedTexture.samplingMode;
  61548. if (texture && texture.samplingMode !== sampling) {
  61549. texture.updateSamplingMode(sampling);
  61550. }
  61551. }
  61552. // Animations
  61553. if (texture && parsedTexture.animations) {
  61554. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  61555. var parsedAnimation = parsedTexture.animations[animationIndex];
  61556. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  61557. if (internalClass) {
  61558. texture.animations.push(internalClass.Parse(parsedAnimation));
  61559. }
  61560. }
  61561. }
  61562. return texture;
  61563. };
  61564. /**
  61565. * Creates a texture from its base 64 representation.
  61566. * @param data Define the base64 payload without the data: prefix
  61567. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  61568. * @param scene Define the scene the texture should belong to
  61569. * @param noMipmap Forces the texture to not create mip map information if true
  61570. * @param invertY define if the texture needs to be inverted on the y axis during loading
  61571. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  61572. * @param onLoad define a callback triggered when the texture has been loaded
  61573. * @param onError define a callback triggered when an error occurred during the loading session
  61574. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  61575. * @returns the created texture
  61576. */
  61577. Texture.CreateFromBase64String = function (data, name, scene, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  61578. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  61579. if (onLoad === void 0) { onLoad = null; }
  61580. if (onError === void 0) { onError = null; }
  61581. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  61582. return new Texture("data:" + name, scene, noMipmap, invertY, samplingMode, onLoad, onError, data, false, format);
  61583. };
  61584. /**
  61585. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  61586. * @param data Define the base64 payload without the data: prefix
  61587. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  61588. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  61589. * @param scene Define the scene the texture should belong to
  61590. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  61591. * @param noMipmap Forces the texture to not create mip map information if true
  61592. * @param invertY define if the texture needs to be inverted on the y axis during loading
  61593. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  61594. * @param onLoad define a callback triggered when the texture has been loaded
  61595. * @param onError define a callback triggered when an error occurred during the loading session
  61596. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  61597. * @returns the created texture
  61598. */
  61599. Texture.LoadFromDataString = function (name, buffer, scene, deleteBuffer, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  61600. if (deleteBuffer === void 0) { deleteBuffer = false; }
  61601. if (noMipmap === void 0) { noMipmap = false; }
  61602. if (invertY === void 0) { invertY = true; }
  61603. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  61604. if (onLoad === void 0) { onLoad = null; }
  61605. if (onError === void 0) { onError = null; }
  61606. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  61607. if (name.substr(0, 5) !== "data:") {
  61608. name = "data:" + name;
  61609. }
  61610. return new Texture(name, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format);
  61611. };
  61612. /** @hidden */
  61613. Texture._CubeTextureParser = function (jsonTexture, scene, rootUrl) {
  61614. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("CubeTexture");
  61615. };
  61616. /** @hidden */
  61617. Texture._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  61618. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("MirrorTexture");
  61619. };
  61620. /** @hidden */
  61621. Texture._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  61622. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("RenderTargetTexture");
  61623. };
  61624. /** nearest is mag = nearest and min = nearest and mip = linear */
  61625. Texture.NEAREST_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  61626. /** nearest is mag = nearest and min = nearest and mip = linear */
  61627. 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
  61628. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61629. Texture.BILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  61630. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61631. 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
  61632. /** Trilinear is mag = linear and min = linear and mip = linear */
  61633. Texture.TRILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  61634. /** Trilinear is mag = linear and min = linear and mip = linear */
  61635. 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
  61636. /** mag = nearest and min = nearest and mip = nearest */
  61637. Texture.NEAREST_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  61638. /** mag = nearest and min = linear and mip = nearest */
  61639. Texture.NEAREST_LINEAR_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  61640. /** mag = nearest and min = linear and mip = linear */
  61641. Texture.NEAREST_LINEAR_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  61642. /** mag = nearest and min = linear and mip = none */
  61643. Texture.NEAREST_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR;
  61644. /** mag = nearest and min = nearest and mip = none */
  61645. Texture.NEAREST_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST;
  61646. /** mag = linear and min = nearest and mip = nearest */
  61647. Texture.LINEAR_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  61648. /** mag = linear and min = nearest and mip = linear */
  61649. Texture.LINEAR_NEAREST_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  61650. /** mag = linear and min = linear and mip = none */
  61651. Texture.LINEAR_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR;
  61652. /** mag = linear and min = nearest and mip = none */
  61653. Texture.LINEAR_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST;
  61654. /** Explicit coordinates mode */
  61655. Texture.EXPLICIT_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EXPLICIT_MODE;
  61656. /** Spherical coordinates mode */
  61657. Texture.SPHERICAL_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SPHERICAL_MODE;
  61658. /** Planar coordinates mode */
  61659. Texture.PLANAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PLANAR_MODE;
  61660. /** Cubic coordinates mode */
  61661. Texture.CUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CUBIC_MODE;
  61662. /** Projection coordinates mode */
  61663. Texture.PROJECTION_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PROJECTION_MODE;
  61664. /** Inverse Cubic coordinates mode */
  61665. Texture.SKYBOX_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SKYBOX_MODE;
  61666. /** Inverse Cubic coordinates mode */
  61667. Texture.INVCUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_INVCUBIC_MODE;
  61668. /** Equirectangular coordinates mode */
  61669. Texture.EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  61670. /** Equirectangular Fixed coordinates mode */
  61671. Texture.FIXED_EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  61672. /** Equirectangular Fixed Mirrored coordinates mode */
  61673. Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  61674. /** Texture is not repeating outside of 0..1 UVs */
  61675. Texture.CLAMP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  61676. /** Texture is repeating outside of 0..1 UVs */
  61677. Texture.WRAP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  61678. /** Texture is repeating and mirrored */
  61679. Texture.MIRROR_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  61680. /**
  61681. * 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
  61682. */
  61683. Texture.UseSerializedUrlIfAny = false;
  61684. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61685. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61686. ], Texture.prototype, "url", void 0);
  61687. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61688. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61689. ], Texture.prototype, "uOffset", void 0);
  61690. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61691. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61692. ], Texture.prototype, "vOffset", void 0);
  61693. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61694. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61695. ], Texture.prototype, "uScale", void 0);
  61696. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61697. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61698. ], Texture.prototype, "vScale", void 0);
  61699. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61700. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61701. ], Texture.prototype, "uAng", void 0);
  61702. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61703. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61704. ], Texture.prototype, "vAng", void 0);
  61705. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61706. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61707. ], Texture.prototype, "wAng", void 0);
  61708. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61709. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61710. ], Texture.prototype, "uRotationCenter", void 0);
  61711. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61712. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61713. ], Texture.prototype, "vRotationCenter", void 0);
  61714. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61715. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61716. ], Texture.prototype, "wRotationCenter", void 0);
  61717. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61718. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61719. ], Texture.prototype, "isBlocking", null);
  61720. return Texture;
  61721. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]));
  61722. // References the dependencies.
  61723. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._TextureParser = Texture.Parse;
  61724. /***/ }),
  61725. /***/ "./Materials/Textures/videoTexture.ts":
  61726. /*!********************************************!*\
  61727. !*** ./Materials/Textures/videoTexture.ts ***!
  61728. \********************************************/
  61729. /*! exports provided: VideoTexture */
  61730. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61731. "use strict";
  61732. __webpack_require__.r(__webpack_exports__);
  61733. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return VideoTexture; });
  61734. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  61735. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  61736. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  61737. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  61738. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  61739. /**
  61740. * If you want to display a video in your scene, this is the special texture for that.
  61741. * This special texture works similar to other textures, with the exception of a few parameters.
  61742. * @see https://doc.babylonjs.com/how_to/video_texture
  61743. */
  61744. var VideoTexture = /** @class */ (function (_super) {
  61745. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoTexture, _super);
  61746. /**
  61747. * Creates a video texture.
  61748. * If you want to display a video in your scene, this is the special texture for that.
  61749. * This special texture works similar to other textures, with the exception of a few parameters.
  61750. * @see https://doc.babylonjs.com/how_to/video_texture
  61751. * @param name optional name, will detect from video source, if not defined
  61752. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  61753. * @param scene is obviously the current scene.
  61754. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  61755. * @param invertY is false by default but can be used to invert video on Y axis
  61756. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  61757. * @param settings allows finer control over video usage
  61758. */
  61759. function VideoTexture(name, src, scene, generateMipMaps, invertY, samplingMode, settings) {
  61760. if (generateMipMaps === void 0) { generateMipMaps = false; }
  61761. if (invertY === void 0) { invertY = false; }
  61762. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  61763. if (settings === void 0) { settings = {
  61764. autoPlay: true,
  61765. loop: true,
  61766. autoUpdateTexture: true,
  61767. }; }
  61768. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  61769. _this._onUserActionRequestedObservable = null;
  61770. _this._stillImageCaptured = false;
  61771. _this._displayingPosterTexture = false;
  61772. _this._createInternalTexture = function () {
  61773. if (_this._texture != null) {
  61774. if (_this._displayingPosterTexture) {
  61775. _this._texture.dispose();
  61776. _this._displayingPosterTexture = false;
  61777. }
  61778. else {
  61779. return;
  61780. }
  61781. }
  61782. if (!_this._engine.needPOTTextures ||
  61783. (_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoWidth) && _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoHeight))) {
  61784. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  61785. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  61786. }
  61787. else {
  61788. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  61789. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  61790. _this._generateMipMaps = false;
  61791. }
  61792. _this._texture = _this._engine.createDynamicTexture(_this.video.videoWidth, _this.video.videoHeight, _this._generateMipMaps, _this.samplingMode);
  61793. if (!_this.video.autoplay && !_this._settings.poster) {
  61794. var oldHandler_1 = _this.video.onplaying;
  61795. var error_1 = false;
  61796. var oldMuted_1 = _this.video.muted;
  61797. _this.video.muted = true;
  61798. _this.video.onplaying = function () {
  61799. _this.video.muted = oldMuted_1;
  61800. _this.video.onplaying = oldHandler_1;
  61801. _this._texture.isReady = true;
  61802. _this._updateInternalTexture();
  61803. if (!error_1) {
  61804. _this.video.pause();
  61805. }
  61806. if (_this.onLoadObservable.hasObservers()) {
  61807. _this.onLoadObservable.notifyObservers(_this);
  61808. }
  61809. };
  61810. var playing = _this.video.play();
  61811. if (playing) {
  61812. playing.then(function () {
  61813. // Everything is good.
  61814. })
  61815. .catch(function () {
  61816. error_1 = true;
  61817. // On Chrome for instance, new policies might prevent playing without user interaction.
  61818. if (_this._onUserActionRequestedObservable && _this._onUserActionRequestedObservable.hasObservers()) {
  61819. _this._onUserActionRequestedObservable.notifyObservers(_this);
  61820. }
  61821. });
  61822. }
  61823. else {
  61824. _this.video.onplaying = oldHandler_1;
  61825. _this._texture.isReady = true;
  61826. _this._updateInternalTexture();
  61827. if (_this.onLoadObservable.hasObservers()) {
  61828. _this.onLoadObservable.notifyObservers(_this);
  61829. }
  61830. }
  61831. }
  61832. else {
  61833. _this._texture.isReady = true;
  61834. _this._updateInternalTexture();
  61835. if (_this.onLoadObservable.hasObservers()) {
  61836. _this.onLoadObservable.notifyObservers(_this);
  61837. }
  61838. }
  61839. };
  61840. _this.reset = function () {
  61841. if (_this._texture == null) {
  61842. return;
  61843. }
  61844. if (!_this._displayingPosterTexture) {
  61845. _this._texture.dispose();
  61846. _this._texture = null;
  61847. }
  61848. };
  61849. _this._updateInternalTexture = function () {
  61850. if (_this._texture == null || !_this._texture.isReady) {
  61851. return;
  61852. }
  61853. if (_this.video.readyState < _this.video.HAVE_CURRENT_DATA) {
  61854. return;
  61855. }
  61856. if (_this._displayingPosterTexture) {
  61857. return;
  61858. }
  61859. _this._engine.updateVideoTexture(_this._texture, _this.video, _this._invertY);
  61860. };
  61861. _this._engine = _this.getScene().getEngine();
  61862. _this._generateMipMaps = generateMipMaps;
  61863. _this._initialSamplingMode = samplingMode;
  61864. _this.autoUpdateTexture = settings.autoUpdateTexture;
  61865. _this.name = name || _this._getName(src);
  61866. _this.video = _this._getVideo(src);
  61867. _this._settings = settings;
  61868. if (settings.poster) {
  61869. _this.video.poster = settings.poster;
  61870. }
  61871. if (settings.autoPlay !== undefined) {
  61872. _this.video.autoplay = settings.autoPlay;
  61873. }
  61874. if (settings.loop !== undefined) {
  61875. _this.video.loop = settings.loop;
  61876. }
  61877. _this.video.setAttribute("playsinline", "");
  61878. _this.video.addEventListener("paused", _this._updateInternalTexture);
  61879. _this.video.addEventListener("seeked", _this._updateInternalTexture);
  61880. _this.video.addEventListener("emptied", _this.reset);
  61881. _this._createInternalTextureOnEvent = (settings.poster && !settings.autoPlay) ? "play" : "canplay";
  61882. _this.video.addEventListener(_this._createInternalTextureOnEvent, _this._createInternalTexture);
  61883. var videoHasEnoughData = (_this.video.readyState >= _this.video.HAVE_CURRENT_DATA);
  61884. if (settings.poster &&
  61885. (!settings.autoPlay || !videoHasEnoughData)) {
  61886. _this._texture = _this._engine.createTexture(settings.poster, false, true, scene);
  61887. _this._displayingPosterTexture = true;
  61888. }
  61889. else if (videoHasEnoughData) {
  61890. _this._createInternalTexture();
  61891. }
  61892. return _this;
  61893. }
  61894. Object.defineProperty(VideoTexture.prototype, "onUserActionRequestedObservable", {
  61895. /**
  61896. * Event triggerd when a dom action is required by the user to play the video.
  61897. * This happens due to recent changes in browser policies preventing video to auto start.
  61898. */
  61899. get: function () {
  61900. if (!this._onUserActionRequestedObservable) {
  61901. this._onUserActionRequestedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  61902. }
  61903. return this._onUserActionRequestedObservable;
  61904. },
  61905. enumerable: true,
  61906. configurable: true
  61907. });
  61908. VideoTexture.prototype._getName = function (src) {
  61909. if (src instanceof HTMLVideoElement) {
  61910. return src.currentSrc;
  61911. }
  61912. if (typeof src === "object") {
  61913. return src.toString();
  61914. }
  61915. return src;
  61916. };
  61917. VideoTexture.prototype._getVideo = function (src) {
  61918. if (src instanceof HTMLVideoElement) {
  61919. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src.currentSrc, src);
  61920. return src;
  61921. }
  61922. var video = document.createElement("video");
  61923. if (typeof src === "string") {
  61924. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src, video);
  61925. video.src = src;
  61926. }
  61927. else {
  61928. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src[0], video);
  61929. src.forEach(function (url) {
  61930. var source = document.createElement("source");
  61931. source.src = url;
  61932. video.appendChild(source);
  61933. });
  61934. }
  61935. return video;
  61936. };
  61937. /**
  61938. * @hidden Internal method to initiate `update`.
  61939. */
  61940. VideoTexture.prototype._rebuild = function () {
  61941. this.update();
  61942. };
  61943. /**
  61944. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  61945. */
  61946. VideoTexture.prototype.update = function () {
  61947. if (!this.autoUpdateTexture) {
  61948. // Expecting user to call `updateTexture` manually
  61949. return;
  61950. }
  61951. this.updateTexture(true);
  61952. };
  61953. /**
  61954. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  61955. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  61956. */
  61957. VideoTexture.prototype.updateTexture = function (isVisible) {
  61958. if (!isVisible) {
  61959. return;
  61960. }
  61961. if (this.video.paused && this._stillImageCaptured) {
  61962. return;
  61963. }
  61964. this._stillImageCaptured = true;
  61965. this._updateInternalTexture();
  61966. };
  61967. /**
  61968. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  61969. * @param url New url.
  61970. */
  61971. VideoTexture.prototype.updateURL = function (url) {
  61972. this.video.src = url;
  61973. };
  61974. /**
  61975. * Dispose the texture and release its associated resources.
  61976. */
  61977. VideoTexture.prototype.dispose = function () {
  61978. _super.prototype.dispose.call(this);
  61979. if (this._onUserActionRequestedObservable) {
  61980. this._onUserActionRequestedObservable.clear();
  61981. this._onUserActionRequestedObservable = null;
  61982. }
  61983. this.video.removeEventListener(this._createInternalTextureOnEvent, this._createInternalTexture);
  61984. this.video.removeEventListener("paused", this._updateInternalTexture);
  61985. this.video.removeEventListener("seeked", this._updateInternalTexture);
  61986. this.video.removeEventListener("emptied", this.reset);
  61987. this.video.pause();
  61988. };
  61989. /**
  61990. * Creates a video texture straight from a stream.
  61991. * @param scene Define the scene the texture should be created in
  61992. * @param stream Define the stream the texture should be created from
  61993. * @returns The created video texture as a promise
  61994. */
  61995. VideoTexture.CreateFromStreamAsync = function (scene, stream) {
  61996. var video = document.createElement("video");
  61997. video.setAttribute('autoplay', '');
  61998. video.setAttribute('muted', 'true');
  61999. video.setAttribute('playsinline', '');
  62000. video.muted = true;
  62001. if (video.mozSrcObject !== undefined) {
  62002. // hack for Firefox < 19
  62003. video.mozSrcObject = stream;
  62004. }
  62005. else {
  62006. if (typeof video.srcObject == "object") {
  62007. video.srcObject = stream;
  62008. }
  62009. else {
  62010. window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
  62011. video.src = (window.URL && window.URL.createObjectURL(stream));
  62012. }
  62013. }
  62014. return new Promise(function (resolve) {
  62015. var onPlaying = function () {
  62016. resolve(new VideoTexture("video", video, scene, true, true));
  62017. video.removeEventListener("playing", onPlaying);
  62018. };
  62019. video.addEventListener("playing", onPlaying);
  62020. video.play();
  62021. });
  62022. };
  62023. /**
  62024. * Creates a video texture straight from your WebCam video feed.
  62025. * @param scene Define the scene the texture should be created in
  62026. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  62027. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  62028. * @returns The created video texture as a promise
  62029. */
  62030. VideoTexture.CreateFromWebCamAsync = function (scene, constraints, audioConstaints) {
  62031. var _this = this;
  62032. if (audioConstaints === void 0) { audioConstaints = false; }
  62033. var constraintsDeviceId;
  62034. if (constraints && constraints.deviceId) {
  62035. constraintsDeviceId = {
  62036. exact: constraints.deviceId,
  62037. };
  62038. }
  62039. if (navigator.mediaDevices) {
  62040. return navigator.mediaDevices.getUserMedia({
  62041. video: constraints,
  62042. audio: audioConstaints
  62043. })
  62044. .then(function (stream) {
  62045. return _this.CreateFromStreamAsync(scene, stream);
  62046. });
  62047. }
  62048. else {
  62049. navigator.getUserMedia =
  62050. navigator.getUserMedia ||
  62051. navigator.webkitGetUserMedia ||
  62052. navigator.mozGetUserMedia ||
  62053. navigator.msGetUserMedia;
  62054. if (navigator.getUserMedia) {
  62055. navigator.getUserMedia({
  62056. video: {
  62057. deviceId: constraintsDeviceId,
  62058. width: {
  62059. min: (constraints && constraints.minWidth) || 256,
  62060. max: (constraints && constraints.maxWidth) || 640,
  62061. },
  62062. height: {
  62063. min: (constraints && constraints.minHeight) || 256,
  62064. max: (constraints && constraints.maxHeight) || 480,
  62065. },
  62066. },
  62067. audio: audioConstaints
  62068. }, function (stream) {
  62069. return _this.CreateFromStreamAsync(scene, stream);
  62070. }, function (e) {
  62071. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(e.name);
  62072. });
  62073. }
  62074. }
  62075. return Promise.reject("No support for userMedia on this device");
  62076. };
  62077. /**
  62078. * Creates a video texture straight from your WebCam video feed.
  62079. * @param scene Define the scene the texture should be created in
  62080. * @param onReady Define a callback to triggered once the texture will be ready
  62081. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  62082. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  62083. */
  62084. VideoTexture.CreateFromWebCam = function (scene, onReady, constraints, audioConstaints) {
  62085. if (audioConstaints === void 0) { audioConstaints = false; }
  62086. this.CreateFromWebCamAsync(scene, constraints, audioConstaints)
  62087. .then(function (videoTexture) {
  62088. if (onReady) {
  62089. onReady(videoTexture);
  62090. }
  62091. })
  62092. .catch(function (err) {
  62093. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(err.name);
  62094. });
  62095. };
  62096. return VideoTexture;
  62097. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  62098. /***/ }),
  62099. /***/ "./Materials/colorCurves.ts":
  62100. /*!**********************************!*\
  62101. !*** ./Materials/colorCurves.ts ***!
  62102. \**********************************/
  62103. /*! exports provided: ColorCurves */
  62104. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62105. "use strict";
  62106. __webpack_require__.r(__webpack_exports__);
  62107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return ColorCurves; });
  62108. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  62109. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  62110. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  62111. /**
  62112. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  62113. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  62114. * 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;
  62115. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  62116. */
  62117. var ColorCurves = /** @class */ (function () {
  62118. function ColorCurves() {
  62119. this._dirty = true;
  62120. this._tempColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62121. this._globalCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62122. this._highlightsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62123. this._midtonesCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62124. this._shadowsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62125. this._positiveCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62126. this._negativeCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62127. this._globalHue = 30;
  62128. this._globalDensity = 0;
  62129. this._globalSaturation = 0;
  62130. this._globalExposure = 0;
  62131. this._highlightsHue = 30;
  62132. this._highlightsDensity = 0;
  62133. this._highlightsSaturation = 0;
  62134. this._highlightsExposure = 0;
  62135. this._midtonesHue = 30;
  62136. this._midtonesDensity = 0;
  62137. this._midtonesSaturation = 0;
  62138. this._midtonesExposure = 0;
  62139. this._shadowsHue = 30;
  62140. this._shadowsDensity = 0;
  62141. this._shadowsSaturation = 0;
  62142. this._shadowsExposure = 0;
  62143. }
  62144. Object.defineProperty(ColorCurves.prototype, "globalHue", {
  62145. /**
  62146. * Gets the global Hue value.
  62147. * 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).
  62148. */
  62149. get: function () {
  62150. return this._globalHue;
  62151. },
  62152. /**
  62153. * Sets the global Hue value.
  62154. * 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).
  62155. */
  62156. set: function (value) {
  62157. this._globalHue = value;
  62158. this._dirty = true;
  62159. },
  62160. enumerable: true,
  62161. configurable: true
  62162. });
  62163. Object.defineProperty(ColorCurves.prototype, "globalDensity", {
  62164. /**
  62165. * Gets the global Density value.
  62166. * 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.
  62167. * Values less than zero provide a filter of opposite hue.
  62168. */
  62169. get: function () {
  62170. return this._globalDensity;
  62171. },
  62172. /**
  62173. * Sets the global Density value.
  62174. * 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.
  62175. * Values less than zero provide a filter of opposite hue.
  62176. */
  62177. set: function (value) {
  62178. this._globalDensity = value;
  62179. this._dirty = true;
  62180. },
  62181. enumerable: true,
  62182. configurable: true
  62183. });
  62184. Object.defineProperty(ColorCurves.prototype, "globalSaturation", {
  62185. /**
  62186. * Gets the global Saturation value.
  62187. * 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.
  62188. */
  62189. get: function () {
  62190. return this._globalSaturation;
  62191. },
  62192. /**
  62193. * Sets the global Saturation value.
  62194. * 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.
  62195. */
  62196. set: function (value) {
  62197. this._globalSaturation = value;
  62198. this._dirty = true;
  62199. },
  62200. enumerable: true,
  62201. configurable: true
  62202. });
  62203. Object.defineProperty(ColorCurves.prototype, "globalExposure", {
  62204. /**
  62205. * Gets the global Exposure value.
  62206. * 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.
  62207. */
  62208. get: function () {
  62209. return this._globalExposure;
  62210. },
  62211. /**
  62212. * Sets the global Exposure value.
  62213. * 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.
  62214. */
  62215. set: function (value) {
  62216. this._globalExposure = value;
  62217. this._dirty = true;
  62218. },
  62219. enumerable: true,
  62220. configurable: true
  62221. });
  62222. Object.defineProperty(ColorCurves.prototype, "highlightsHue", {
  62223. /**
  62224. * Gets the highlights Hue value.
  62225. * 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).
  62226. */
  62227. get: function () {
  62228. return this._highlightsHue;
  62229. },
  62230. /**
  62231. * Sets the highlights Hue value.
  62232. * 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).
  62233. */
  62234. set: function (value) {
  62235. this._highlightsHue = value;
  62236. this._dirty = true;
  62237. },
  62238. enumerable: true,
  62239. configurable: true
  62240. });
  62241. Object.defineProperty(ColorCurves.prototype, "highlightsDensity", {
  62242. /**
  62243. * Gets the highlights Density value.
  62244. * 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.
  62245. * Values less than zero provide a filter of opposite hue.
  62246. */
  62247. get: function () {
  62248. return this._highlightsDensity;
  62249. },
  62250. /**
  62251. * Sets the highlights Density value.
  62252. * 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.
  62253. * Values less than zero provide a filter of opposite hue.
  62254. */
  62255. set: function (value) {
  62256. this._highlightsDensity = value;
  62257. this._dirty = true;
  62258. },
  62259. enumerable: true,
  62260. configurable: true
  62261. });
  62262. Object.defineProperty(ColorCurves.prototype, "highlightsSaturation", {
  62263. /**
  62264. * Gets the highlights Saturation value.
  62265. * 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.
  62266. */
  62267. get: function () {
  62268. return this._highlightsSaturation;
  62269. },
  62270. /**
  62271. * Sets the highlights Saturation value.
  62272. * 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.
  62273. */
  62274. set: function (value) {
  62275. this._highlightsSaturation = value;
  62276. this._dirty = true;
  62277. },
  62278. enumerable: true,
  62279. configurable: true
  62280. });
  62281. Object.defineProperty(ColorCurves.prototype, "highlightsExposure", {
  62282. /**
  62283. * Gets the highlights Exposure value.
  62284. * 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.
  62285. */
  62286. get: function () {
  62287. return this._highlightsExposure;
  62288. },
  62289. /**
  62290. * Sets the highlights Exposure value.
  62291. * 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.
  62292. */
  62293. set: function (value) {
  62294. this._highlightsExposure = value;
  62295. this._dirty = true;
  62296. },
  62297. enumerable: true,
  62298. configurable: true
  62299. });
  62300. Object.defineProperty(ColorCurves.prototype, "midtonesHue", {
  62301. /**
  62302. * Gets the midtones Hue value.
  62303. * 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).
  62304. */
  62305. get: function () {
  62306. return this._midtonesHue;
  62307. },
  62308. /**
  62309. * Sets the midtones Hue value.
  62310. * 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).
  62311. */
  62312. set: function (value) {
  62313. this._midtonesHue = value;
  62314. this._dirty = true;
  62315. },
  62316. enumerable: true,
  62317. configurable: true
  62318. });
  62319. Object.defineProperty(ColorCurves.prototype, "midtonesDensity", {
  62320. /**
  62321. * Gets the midtones Density value.
  62322. * 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.
  62323. * Values less than zero provide a filter of opposite hue.
  62324. */
  62325. get: function () {
  62326. return this._midtonesDensity;
  62327. },
  62328. /**
  62329. * Sets the midtones Density value.
  62330. * 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.
  62331. * Values less than zero provide a filter of opposite hue.
  62332. */
  62333. set: function (value) {
  62334. this._midtonesDensity = value;
  62335. this._dirty = true;
  62336. },
  62337. enumerable: true,
  62338. configurable: true
  62339. });
  62340. Object.defineProperty(ColorCurves.prototype, "midtonesSaturation", {
  62341. /**
  62342. * Gets the midtones Saturation value.
  62343. * 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.
  62344. */
  62345. get: function () {
  62346. return this._midtonesSaturation;
  62347. },
  62348. /**
  62349. * Sets the midtones Saturation value.
  62350. * 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.
  62351. */
  62352. set: function (value) {
  62353. this._midtonesSaturation = value;
  62354. this._dirty = true;
  62355. },
  62356. enumerable: true,
  62357. configurable: true
  62358. });
  62359. Object.defineProperty(ColorCurves.prototype, "midtonesExposure", {
  62360. /**
  62361. * Gets the midtones Exposure value.
  62362. * 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.
  62363. */
  62364. get: function () {
  62365. return this._midtonesExposure;
  62366. },
  62367. /**
  62368. * Sets the midtones Exposure value.
  62369. * 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.
  62370. */
  62371. set: function (value) {
  62372. this._midtonesExposure = value;
  62373. this._dirty = true;
  62374. },
  62375. enumerable: true,
  62376. configurable: true
  62377. });
  62378. Object.defineProperty(ColorCurves.prototype, "shadowsHue", {
  62379. /**
  62380. * Gets the shadows Hue value.
  62381. * 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).
  62382. */
  62383. get: function () {
  62384. return this._shadowsHue;
  62385. },
  62386. /**
  62387. * Sets the shadows Hue value.
  62388. * 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).
  62389. */
  62390. set: function (value) {
  62391. this._shadowsHue = value;
  62392. this._dirty = true;
  62393. },
  62394. enumerable: true,
  62395. configurable: true
  62396. });
  62397. Object.defineProperty(ColorCurves.prototype, "shadowsDensity", {
  62398. /**
  62399. * Gets the shadows Density value.
  62400. * 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.
  62401. * Values less than zero provide a filter of opposite hue.
  62402. */
  62403. get: function () {
  62404. return this._shadowsDensity;
  62405. },
  62406. /**
  62407. * Sets the shadows Density value.
  62408. * 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.
  62409. * Values less than zero provide a filter of opposite hue.
  62410. */
  62411. set: function (value) {
  62412. this._shadowsDensity = value;
  62413. this._dirty = true;
  62414. },
  62415. enumerable: true,
  62416. configurable: true
  62417. });
  62418. Object.defineProperty(ColorCurves.prototype, "shadowsSaturation", {
  62419. /**
  62420. * Gets the shadows Saturation value.
  62421. * 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.
  62422. */
  62423. get: function () {
  62424. return this._shadowsSaturation;
  62425. },
  62426. /**
  62427. * Sets the shadows Saturation value.
  62428. * 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.
  62429. */
  62430. set: function (value) {
  62431. this._shadowsSaturation = value;
  62432. this._dirty = true;
  62433. },
  62434. enumerable: true,
  62435. configurable: true
  62436. });
  62437. Object.defineProperty(ColorCurves.prototype, "shadowsExposure", {
  62438. /**
  62439. * Gets the shadows Exposure value.
  62440. * 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.
  62441. */
  62442. get: function () {
  62443. return this._shadowsExposure;
  62444. },
  62445. /**
  62446. * Sets the shadows Exposure value.
  62447. * 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.
  62448. */
  62449. set: function (value) {
  62450. this._shadowsExposure = value;
  62451. this._dirty = true;
  62452. },
  62453. enumerable: true,
  62454. configurable: true
  62455. });
  62456. /**
  62457. * Returns the class name
  62458. * @returns The class name
  62459. */
  62460. ColorCurves.prototype.getClassName = function () {
  62461. return "ColorCurves";
  62462. };
  62463. /**
  62464. * Binds the color curves to the shader.
  62465. * @param colorCurves The color curve to bind
  62466. * @param effect The effect to bind to
  62467. * @param positiveUniform The positive uniform shader parameter
  62468. * @param neutralUniform The neutral uniform shader parameter
  62469. * @param negativeUniform The negative uniform shader parameter
  62470. */
  62471. ColorCurves.Bind = function (colorCurves, effect, positiveUniform, neutralUniform, negativeUniform) {
  62472. if (positiveUniform === void 0) { positiveUniform = "vCameraColorCurvePositive"; }
  62473. if (neutralUniform === void 0) { neutralUniform = "vCameraColorCurveNeutral"; }
  62474. if (negativeUniform === void 0) { negativeUniform = "vCameraColorCurveNegative"; }
  62475. if (colorCurves._dirty) {
  62476. colorCurves._dirty = false;
  62477. // Fill in global info.
  62478. colorCurves.getColorGradingDataToRef(colorCurves._globalHue, colorCurves._globalDensity, colorCurves._globalSaturation, colorCurves._globalExposure, colorCurves._globalCurve);
  62479. // Compute highlights info.
  62480. colorCurves.getColorGradingDataToRef(colorCurves._highlightsHue, colorCurves._highlightsDensity, colorCurves._highlightsSaturation, colorCurves._highlightsExposure, colorCurves._tempColor);
  62481. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._highlightsCurve);
  62482. // Compute midtones info.
  62483. colorCurves.getColorGradingDataToRef(colorCurves._midtonesHue, colorCurves._midtonesDensity, colorCurves._midtonesSaturation, colorCurves._midtonesExposure, colorCurves._tempColor);
  62484. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._midtonesCurve);
  62485. // Compute shadows info.
  62486. colorCurves.getColorGradingDataToRef(colorCurves._shadowsHue, colorCurves._shadowsDensity, colorCurves._shadowsSaturation, colorCurves._shadowsExposure, colorCurves._tempColor);
  62487. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._shadowsCurve);
  62488. // Compute deltas (neutral is midtones).
  62489. colorCurves._highlightsCurve.subtractToRef(colorCurves._midtonesCurve, colorCurves._positiveCurve);
  62490. colorCurves._midtonesCurve.subtractToRef(colorCurves._shadowsCurve, colorCurves._negativeCurve);
  62491. }
  62492. if (effect) {
  62493. effect.setFloat4(positiveUniform, colorCurves._positiveCurve.r, colorCurves._positiveCurve.g, colorCurves._positiveCurve.b, colorCurves._positiveCurve.a);
  62494. effect.setFloat4(neutralUniform, colorCurves._midtonesCurve.r, colorCurves._midtonesCurve.g, colorCurves._midtonesCurve.b, colorCurves._midtonesCurve.a);
  62495. effect.setFloat4(negativeUniform, colorCurves._negativeCurve.r, colorCurves._negativeCurve.g, colorCurves._negativeCurve.b, colorCurves._negativeCurve.a);
  62496. }
  62497. };
  62498. /**
  62499. * Prepare the list of uniforms associated with the ColorCurves effects.
  62500. * @param uniformsList The list of uniforms used in the effect
  62501. */
  62502. ColorCurves.PrepareUniforms = function (uniformsList) {
  62503. uniformsList.push("vCameraColorCurveNeutral", "vCameraColorCurvePositive", "vCameraColorCurveNegative");
  62504. };
  62505. /**
  62506. * Returns color grading data based on a hue, density, saturation and exposure value.
  62507. * @param filterHue The hue of the color filter.
  62508. * @param filterDensity The density of the color filter.
  62509. * @param saturation The saturation.
  62510. * @param exposure The exposure.
  62511. * @param result The result data container.
  62512. */
  62513. ColorCurves.prototype.getColorGradingDataToRef = function (hue, density, saturation, exposure, result) {
  62514. if (hue == null) {
  62515. return;
  62516. }
  62517. hue = ColorCurves.clamp(hue, 0, 360);
  62518. density = ColorCurves.clamp(density, -100, 100);
  62519. saturation = ColorCurves.clamp(saturation, -100, 100);
  62520. exposure = ColorCurves.clamp(exposure, -100, 100);
  62521. // Remap the slider/config filter density with non-linear mapping and also scale by half
  62522. // so that the maximum filter density is only 50% control. This provides fine control
  62523. // for small values and reasonable range.
  62524. density = ColorCurves.applyColorGradingSliderNonlinear(density);
  62525. density *= 0.5;
  62526. exposure = ColorCurves.applyColorGradingSliderNonlinear(exposure);
  62527. if (density < 0) {
  62528. density *= -1;
  62529. hue = (hue + 180) % 360;
  62530. }
  62531. ColorCurves.fromHSBToRef(hue, density, 50 + 0.25 * exposure, result);
  62532. result.scaleToRef(2, result);
  62533. result.a = 1 + 0.01 * saturation;
  62534. };
  62535. /**
  62536. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  62537. * @param value The input slider value in range [-100,100].
  62538. * @returns Adjusted value.
  62539. */
  62540. ColorCurves.applyColorGradingSliderNonlinear = function (value) {
  62541. value /= 100;
  62542. var x = Math.abs(value);
  62543. x = Math.pow(x, 2);
  62544. if (value < 0) {
  62545. x *= -1;
  62546. }
  62547. x *= 100;
  62548. return x;
  62549. };
  62550. /**
  62551. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  62552. * @param hue The hue (H) input.
  62553. * @param saturation The saturation (S) input.
  62554. * @param brightness The brightness (B) input.
  62555. * @result An RGBA color represented as Vector4.
  62556. */
  62557. ColorCurves.fromHSBToRef = function (hue, saturation, brightness, result) {
  62558. var h = ColorCurves.clamp(hue, 0, 360);
  62559. var s = ColorCurves.clamp(saturation / 100, 0, 1);
  62560. var v = ColorCurves.clamp(brightness / 100, 0, 1);
  62561. if (s === 0) {
  62562. result.r = v;
  62563. result.g = v;
  62564. result.b = v;
  62565. }
  62566. else {
  62567. // sector 0 to 5
  62568. h /= 60;
  62569. var i = Math.floor(h);
  62570. // fractional part of h
  62571. var f = h - i;
  62572. var p = v * (1 - s);
  62573. var q = v * (1 - s * f);
  62574. var t = v * (1 - s * (1 - f));
  62575. switch (i) {
  62576. case 0:
  62577. result.r = v;
  62578. result.g = t;
  62579. result.b = p;
  62580. break;
  62581. case 1:
  62582. result.r = q;
  62583. result.g = v;
  62584. result.b = p;
  62585. break;
  62586. case 2:
  62587. result.r = p;
  62588. result.g = v;
  62589. result.b = t;
  62590. break;
  62591. case 3:
  62592. result.r = p;
  62593. result.g = q;
  62594. result.b = v;
  62595. break;
  62596. case 4:
  62597. result.r = t;
  62598. result.g = p;
  62599. result.b = v;
  62600. break;
  62601. default: // case 5:
  62602. result.r = v;
  62603. result.g = p;
  62604. result.b = q;
  62605. break;
  62606. }
  62607. }
  62608. result.a = 1;
  62609. };
  62610. /**
  62611. * Returns a value clamped between min and max
  62612. * @param value The value to clamp
  62613. * @param min The minimum of value
  62614. * @param max The maximum of value
  62615. * @returns The clamped value.
  62616. */
  62617. ColorCurves.clamp = function (value, min, max) {
  62618. return Math.min(Math.max(value, min), max);
  62619. };
  62620. /**
  62621. * Clones the current color curve instance.
  62622. * @return The cloned curves
  62623. */
  62624. ColorCurves.prototype.clone = function () {
  62625. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ColorCurves(); }, this);
  62626. };
  62627. /**
  62628. * Serializes the current color curve instance to a json representation.
  62629. * @return a JSON representation
  62630. */
  62631. ColorCurves.prototype.serialize = function () {
  62632. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  62633. };
  62634. /**
  62635. * Parses the color curve from a json representation.
  62636. * @param source the JSON source to parse
  62637. * @return The parsed curves
  62638. */
  62639. ColorCurves.Parse = function (source) {
  62640. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ColorCurves(); }, source, null, null);
  62641. };
  62642. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62643. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62644. ], ColorCurves.prototype, "_globalHue", void 0);
  62645. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62646. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62647. ], ColorCurves.prototype, "_globalDensity", void 0);
  62648. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62649. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62650. ], ColorCurves.prototype, "_globalSaturation", void 0);
  62651. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62652. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62653. ], ColorCurves.prototype, "_globalExposure", void 0);
  62654. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62655. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62656. ], ColorCurves.prototype, "_highlightsHue", void 0);
  62657. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62658. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62659. ], ColorCurves.prototype, "_highlightsDensity", void 0);
  62660. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62661. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62662. ], ColorCurves.prototype, "_highlightsSaturation", void 0);
  62663. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62664. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62665. ], ColorCurves.prototype, "_highlightsExposure", void 0);
  62666. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62667. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62668. ], ColorCurves.prototype, "_midtonesHue", void 0);
  62669. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62670. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62671. ], ColorCurves.prototype, "_midtonesDensity", void 0);
  62672. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62673. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62674. ], ColorCurves.prototype, "_midtonesSaturation", void 0);
  62675. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62676. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62677. ], ColorCurves.prototype, "_midtonesExposure", void 0);
  62678. return ColorCurves;
  62679. }());
  62680. // References the dependencies.
  62681. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ColorCurvesParser = ColorCurves.Parse;
  62682. /***/ }),
  62683. /***/ "./Materials/effect.ts":
  62684. /*!*****************************!*\
  62685. !*** ./Materials/effect.ts ***!
  62686. \*****************************/
  62687. /*! exports provided: EffectFallbacks, EffectCreationOptions, Effect */
  62688. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62689. "use strict";
  62690. __webpack_require__.r(__webpack_exports__);
  62691. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return EffectFallbacks; });
  62692. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return EffectCreationOptions; });
  62693. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return Effect; });
  62694. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  62695. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  62696. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  62697. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  62698. /**
  62699. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  62700. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  62701. */
  62702. var EffectFallbacks = /** @class */ (function () {
  62703. function EffectFallbacks() {
  62704. this._defines = {};
  62705. this._currentRank = 32;
  62706. this._maxRank = -1;
  62707. }
  62708. /**
  62709. * Removes the fallback from the bound mesh.
  62710. */
  62711. EffectFallbacks.prototype.unBindMesh = function () {
  62712. this._mesh = null;
  62713. };
  62714. /**
  62715. * Adds a fallback on the specified property.
  62716. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  62717. * @param define The name of the define in the shader
  62718. */
  62719. EffectFallbacks.prototype.addFallback = function (rank, define) {
  62720. if (!this._defines[rank]) {
  62721. if (rank < this._currentRank) {
  62722. this._currentRank = rank;
  62723. }
  62724. if (rank > this._maxRank) {
  62725. this._maxRank = rank;
  62726. }
  62727. this._defines[rank] = new Array();
  62728. }
  62729. this._defines[rank].push(define);
  62730. };
  62731. /**
  62732. * Sets the mesh to use CPU skinning when needing to fallback.
  62733. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  62734. * @param mesh The mesh to use the fallbacks.
  62735. */
  62736. EffectFallbacks.prototype.addCPUSkinningFallback = function (rank, mesh) {
  62737. this._mesh = mesh;
  62738. if (rank < this._currentRank) {
  62739. this._currentRank = rank;
  62740. }
  62741. if (rank > this._maxRank) {
  62742. this._maxRank = rank;
  62743. }
  62744. };
  62745. Object.defineProperty(EffectFallbacks.prototype, "isMoreFallbacks", {
  62746. /**
  62747. * Checks to see if more fallbacks are still availible.
  62748. */
  62749. get: function () {
  62750. return this._currentRank <= this._maxRank;
  62751. },
  62752. enumerable: true,
  62753. configurable: true
  62754. });
  62755. /**
  62756. * Removes the defines that shoould be removed when falling back.
  62757. * @param currentDefines defines the current define statements for the shader.
  62758. * @param effect defines the current effect we try to compile
  62759. * @returns The resulting defines with defines of the current rank removed.
  62760. */
  62761. EffectFallbacks.prototype.reduce = function (currentDefines, effect) {
  62762. // First we try to switch to CPU skinning
  62763. if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0 && this._mesh.material) {
  62764. this._mesh.computeBonesUsingShaders = false;
  62765. currentDefines = currentDefines.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0");
  62766. effect._bonesComputationForcedToCPU = true;
  62767. var scene = this._mesh.getScene();
  62768. for (var index = 0; index < scene.meshes.length; index++) {
  62769. var otherMesh = scene.meshes[index];
  62770. if (!otherMesh.material) {
  62771. continue;
  62772. }
  62773. if (!otherMesh.computeBonesUsingShaders || otherMesh.numBoneInfluencers === 0) {
  62774. continue;
  62775. }
  62776. if (otherMesh.material.getEffect() === effect) {
  62777. otherMesh.computeBonesUsingShaders = false;
  62778. }
  62779. else if (otherMesh.subMeshes) {
  62780. for (var _i = 0, _a = otherMesh.subMeshes; _i < _a.length; _i++) {
  62781. var subMesh = _a[_i];
  62782. var subMeshEffect = subMesh.effect;
  62783. if (subMeshEffect === effect) {
  62784. otherMesh.computeBonesUsingShaders = false;
  62785. break;
  62786. }
  62787. }
  62788. }
  62789. }
  62790. }
  62791. else {
  62792. var currentFallbacks = this._defines[this._currentRank];
  62793. if (currentFallbacks) {
  62794. for (var index = 0; index < currentFallbacks.length; index++) {
  62795. currentDefines = currentDefines.replace("#define " + currentFallbacks[index], "");
  62796. }
  62797. }
  62798. this._currentRank++;
  62799. }
  62800. return currentDefines;
  62801. };
  62802. return EffectFallbacks;
  62803. }());
  62804. /**
  62805. * Options to be used when creating an effect.
  62806. */
  62807. var EffectCreationOptions = /** @class */ (function () {
  62808. function EffectCreationOptions() {
  62809. }
  62810. return EffectCreationOptions;
  62811. }());
  62812. /**
  62813. * Effect containing vertex and fragment shader that can be executed on an object.
  62814. */
  62815. var Effect = /** @class */ (function () {
  62816. /**
  62817. * Instantiates an effect.
  62818. * An effect can be used to create/manage/execute vertex and fragment shaders.
  62819. * @param baseName Name of the effect.
  62820. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  62821. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  62822. * @param samplers List of sampler variables that will be passed to the shader.
  62823. * @param engine Engine to be used to render the effect
  62824. * @param defines Define statements to be added to the shader.
  62825. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  62826. * @param onCompiled Callback that will be called when the shader is compiled.
  62827. * @param onError Callback that will be called if an error occurs during shader compilation.
  62828. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  62829. */
  62830. function Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, engine, defines, fallbacks, onCompiled, onError, indexParameters) {
  62831. if (samplers === void 0) { samplers = null; }
  62832. if (defines === void 0) { defines = null; }
  62833. if (fallbacks === void 0) { fallbacks = null; }
  62834. if (onCompiled === void 0) { onCompiled = null; }
  62835. if (onError === void 0) { onError = null; }
  62836. var _this = this;
  62837. /**
  62838. * Unique ID of the effect.
  62839. */
  62840. this.uniqueId = 0;
  62841. /**
  62842. * Observable that will be called when the shader is compiled.
  62843. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  62844. */
  62845. this.onCompileObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  62846. /**
  62847. * Observable that will be called if an error occurs during shader compilation.
  62848. */
  62849. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  62850. /** @hidden */
  62851. this._bonesComputationForcedToCPU = false;
  62852. this._uniformBuffersNames = {};
  62853. this._isReady = false;
  62854. this._compilationError = "";
  62855. this.name = baseName;
  62856. if (attributesNamesOrOptions.attributes) {
  62857. var options = attributesNamesOrOptions;
  62858. this._engine = uniformsNamesOrEngine;
  62859. this._attributesNames = options.attributes;
  62860. this._uniformsNames = options.uniformsNames.concat(options.samplers);
  62861. this._samplers = options.samplers.slice();
  62862. this.defines = options.defines;
  62863. this.onError = options.onError;
  62864. this.onCompiled = options.onCompiled;
  62865. this._fallbacks = options.fallbacks;
  62866. this._indexParameters = options.indexParameters;
  62867. this._transformFeedbackVaryings = options.transformFeedbackVaryings;
  62868. if (options.uniformBuffersNames) {
  62869. for (var i = 0; i < options.uniformBuffersNames.length; i++) {
  62870. this._uniformBuffersNames[options.uniformBuffersNames[i]] = i;
  62871. }
  62872. }
  62873. }
  62874. else {
  62875. this._engine = engine;
  62876. this.defines = (defines == null ? "" : defines);
  62877. this._uniformsNames = uniformsNamesOrEngine.concat(samplers);
  62878. this._samplers = samplers ? samplers.slice() : [];
  62879. this._attributesNames = attributesNamesOrOptions;
  62880. this.onError = onError;
  62881. this.onCompiled = onCompiled;
  62882. this._indexParameters = indexParameters;
  62883. this._fallbacks = fallbacks;
  62884. }
  62885. this.uniqueId = Effect._uniqueIdSeed++;
  62886. var vertexSource;
  62887. var fragmentSource;
  62888. if (baseName.vertexElement) {
  62889. vertexSource = document.getElementById(baseName.vertexElement);
  62890. if (!vertexSource) {
  62891. vertexSource = baseName.vertexElement;
  62892. }
  62893. }
  62894. else {
  62895. vertexSource = baseName.vertex || baseName;
  62896. }
  62897. if (baseName.fragmentElement) {
  62898. fragmentSource = document.getElementById(baseName.fragmentElement);
  62899. if (!fragmentSource) {
  62900. fragmentSource = baseName.fragmentElement;
  62901. }
  62902. }
  62903. else {
  62904. fragmentSource = baseName.fragment || baseName;
  62905. }
  62906. this._loadVertexShader(vertexSource, function (vertexCode) {
  62907. _this._processIncludes(vertexCode, function (vertexCodeWithIncludes) {
  62908. _this._processShaderConversion(vertexCodeWithIncludes, false, function (migratedVertexCode) {
  62909. _this._loadFragmentShader(fragmentSource, function (fragmentCode) {
  62910. _this._processIncludes(fragmentCode, function (fragmentCodeWithIncludes) {
  62911. _this._processShaderConversion(fragmentCodeWithIncludes, true, function (migratedFragmentCode) {
  62912. if (baseName) {
  62913. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  62914. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  62915. _this._vertexSourceCode = "#define SHADER_NAME vertex:" + vertex + "\n" + migratedVertexCode;
  62916. _this._fragmentSourceCode = "#define SHADER_NAME fragment:" + fragment + "\n" + migratedFragmentCode;
  62917. }
  62918. else {
  62919. _this._vertexSourceCode = migratedVertexCode;
  62920. _this._fragmentSourceCode = migratedFragmentCode;
  62921. }
  62922. _this._prepareEffect();
  62923. });
  62924. });
  62925. });
  62926. });
  62927. });
  62928. });
  62929. }
  62930. Object.defineProperty(Effect.prototype, "onBindObservable", {
  62931. /**
  62932. * Observable that will be called when effect is bound.
  62933. */
  62934. get: function () {
  62935. if (!this._onBindObservable) {
  62936. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  62937. }
  62938. return this._onBindObservable;
  62939. },
  62940. enumerable: true,
  62941. configurable: true
  62942. });
  62943. Object.defineProperty(Effect.prototype, "key", {
  62944. /**
  62945. * Unique key for this effect
  62946. */
  62947. get: function () {
  62948. return this._key;
  62949. },
  62950. enumerable: true,
  62951. configurable: true
  62952. });
  62953. /**
  62954. * If the effect has been compiled and prepared.
  62955. * @returns if the effect is compiled and prepared.
  62956. */
  62957. Effect.prototype.isReady = function () {
  62958. if (!this._isReady && this._program && this._program.isParallelCompiled) {
  62959. return this._engine._isProgramCompiled(this._program);
  62960. }
  62961. return this._isReady;
  62962. };
  62963. /**
  62964. * The engine the effect was initialized with.
  62965. * @returns the engine.
  62966. */
  62967. Effect.prototype.getEngine = function () {
  62968. return this._engine;
  62969. };
  62970. /**
  62971. * The compiled webGL program for the effect
  62972. * @returns the webGL program.
  62973. */
  62974. Effect.prototype.getProgram = function () {
  62975. return this._program;
  62976. };
  62977. /**
  62978. * The set of names of attribute variables for the shader.
  62979. * @returns An array of attribute names.
  62980. */
  62981. Effect.prototype.getAttributesNames = function () {
  62982. return this._attributesNames;
  62983. };
  62984. /**
  62985. * Returns the attribute at the given index.
  62986. * @param index The index of the attribute.
  62987. * @returns The location of the attribute.
  62988. */
  62989. Effect.prototype.getAttributeLocation = function (index) {
  62990. return this._attributes[index];
  62991. };
  62992. /**
  62993. * Returns the attribute based on the name of the variable.
  62994. * @param name of the attribute to look up.
  62995. * @returns the attribute location.
  62996. */
  62997. Effect.prototype.getAttributeLocationByName = function (name) {
  62998. var index = this._attributesNames.indexOf(name);
  62999. return this._attributes[index];
  63000. };
  63001. /**
  63002. * The number of attributes.
  63003. * @returns the numnber of attributes.
  63004. */
  63005. Effect.prototype.getAttributesCount = function () {
  63006. return this._attributes.length;
  63007. };
  63008. /**
  63009. * Gets the index of a uniform variable.
  63010. * @param uniformName of the uniform to look up.
  63011. * @returns the index.
  63012. */
  63013. Effect.prototype.getUniformIndex = function (uniformName) {
  63014. return this._uniformsNames.indexOf(uniformName);
  63015. };
  63016. /**
  63017. * Returns the attribute based on the name of the variable.
  63018. * @param uniformName of the uniform to look up.
  63019. * @returns the location of the uniform.
  63020. */
  63021. Effect.prototype.getUniform = function (uniformName) {
  63022. return this._uniforms[this._uniformsNames.indexOf(uniformName)];
  63023. };
  63024. /**
  63025. * Returns an array of sampler variable names
  63026. * @returns The array of sampler variable neames.
  63027. */
  63028. Effect.prototype.getSamplers = function () {
  63029. return this._samplers;
  63030. };
  63031. /**
  63032. * The error from the last compilation.
  63033. * @returns the error string.
  63034. */
  63035. Effect.prototype.getCompilationError = function () {
  63036. return this._compilationError;
  63037. };
  63038. /**
  63039. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  63040. * @param func The callback to be used.
  63041. */
  63042. Effect.prototype.executeWhenCompiled = function (func) {
  63043. var _this = this;
  63044. if (this.isReady()) {
  63045. func(this);
  63046. return;
  63047. }
  63048. this.onCompileObservable.add(function (effect) {
  63049. func(effect);
  63050. });
  63051. if (!this._program || this._program.isParallelCompiled) {
  63052. setTimeout(function () {
  63053. _this._checkIsReady();
  63054. }, 16);
  63055. }
  63056. };
  63057. Effect.prototype._checkIsReady = function () {
  63058. var _this = this;
  63059. if (this.isReady()) {
  63060. return;
  63061. }
  63062. setTimeout(function () {
  63063. _this._checkIsReady();
  63064. }, 16);
  63065. };
  63066. /** @hidden */
  63067. Effect.prototype._loadVertexShader = function (vertex, callback) {
  63068. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  63069. // DOM element ?
  63070. if (vertex instanceof HTMLElement) {
  63071. var vertexCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(vertex);
  63072. callback(vertexCode);
  63073. return;
  63074. }
  63075. }
  63076. // Base64 encoded ?
  63077. if (vertex.substr(0, 7) === "base64:") {
  63078. var vertexBinary = window.atob(vertex.substr(7));
  63079. callback(vertexBinary);
  63080. return;
  63081. }
  63082. // Is in local store ?
  63083. if (Effect.ShadersStore[vertex + "VertexShader"]) {
  63084. callback(Effect.ShadersStore[vertex + "VertexShader"]);
  63085. return;
  63086. }
  63087. var vertexShaderUrl;
  63088. if (vertex[0] === "." || vertex[0] === "/" || vertex.indexOf("http") > -1) {
  63089. vertexShaderUrl = vertex;
  63090. }
  63091. else {
  63092. vertexShaderUrl = Effect.ShadersRepository + vertex;
  63093. }
  63094. // Vertex shader
  63095. this._engine._loadFile(vertexShaderUrl + ".vertex.fx", callback);
  63096. };
  63097. /** @hidden */
  63098. Effect.prototype._loadFragmentShader = function (fragment, callback) {
  63099. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  63100. // DOM element ?
  63101. if (fragment instanceof HTMLElement) {
  63102. var fragmentCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(fragment);
  63103. callback(fragmentCode);
  63104. return;
  63105. }
  63106. }
  63107. // Base64 encoded ?
  63108. if (fragment.substr(0, 7) === "base64:") {
  63109. var fragmentBinary = window.atob(fragment.substr(7));
  63110. callback(fragmentBinary);
  63111. return;
  63112. }
  63113. // Is in local store ?
  63114. if (Effect.ShadersStore[fragment + "PixelShader"]) {
  63115. callback(Effect.ShadersStore[fragment + "PixelShader"]);
  63116. return;
  63117. }
  63118. if (Effect.ShadersStore[fragment + "FragmentShader"]) {
  63119. callback(Effect.ShadersStore[fragment + "FragmentShader"]);
  63120. return;
  63121. }
  63122. var fragmentShaderUrl;
  63123. if (fragment[0] === "." || fragment[0] === "/" || fragment.indexOf("http") > -1) {
  63124. fragmentShaderUrl = fragment;
  63125. }
  63126. else {
  63127. fragmentShaderUrl = Effect.ShadersRepository + fragment;
  63128. }
  63129. // Fragment shader
  63130. this._engine._loadFile(fragmentShaderUrl + ".fragment.fx", callback);
  63131. };
  63132. /** @hidden */
  63133. Effect.prototype._dumpShadersSource = function (vertexCode, fragmentCode, defines) {
  63134. // Rebuild shaders source code
  63135. var shaderVersion = (this._engine.webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  63136. var prefix = shaderVersion + (defines ? defines + "\n" : "");
  63137. vertexCode = prefix + vertexCode;
  63138. fragmentCode = prefix + fragmentCode;
  63139. // Number lines of shaders source code
  63140. var i = 2;
  63141. var regex = /\n/gm;
  63142. var formattedVertexCode = "\n1\t" + vertexCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  63143. i = 2;
  63144. var formattedFragmentCode = "\n1\t" + fragmentCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  63145. // Dump shaders name and formatted source code
  63146. if (this.name.vertexElement) {
  63147. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertexElement + formattedVertexCode);
  63148. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragmentElement + formattedFragmentCode);
  63149. }
  63150. else if (this.name.vertex) {
  63151. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertex + formattedVertexCode);
  63152. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragment + formattedFragmentCode);
  63153. }
  63154. else {
  63155. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name + formattedVertexCode);
  63156. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name + formattedFragmentCode);
  63157. }
  63158. };
  63159. Effect.prototype._processShaderConversion = function (sourceCode, isFragment, callback) {
  63160. var preparedSourceCode = this._processPrecision(sourceCode);
  63161. if (this._engine.webGLVersion == 1) {
  63162. callback(preparedSourceCode);
  63163. return;
  63164. }
  63165. // Already converted
  63166. if (preparedSourceCode.indexOf("#version 3") !== -1) {
  63167. callback(preparedSourceCode.replace("#version 300 es", ""));
  63168. return;
  63169. }
  63170. var hasDrawBuffersExtension = preparedSourceCode.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1;
  63171. // Remove extensions
  63172. // #extension GL_OES_standard_derivatives : enable
  63173. // #extension GL_EXT_shader_texture_lod : enable
  63174. // #extension GL_EXT_frag_depth : enable
  63175. // #extension GL_EXT_draw_buffers : require
  63176. var regex = /#extension.+(GL_OVR_multiview|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;
  63177. var result = preparedSourceCode.replace(regex, "");
  63178. // Migrate to GLSL v300
  63179. result = result.replace(/varying(?![\n\r])\s/g, isFragment ? "in " : "out ");
  63180. result = result.replace(/attribute[ \t]/g, "in ");
  63181. result = result.replace(/[ \t]attribute/g, " in");
  63182. result = result.replace(/texture2D\s*\(/g, "texture(");
  63183. if (isFragment) {
  63184. result = result.replace(/texture2DLodEXT\s*\(/g, "textureLod(");
  63185. result = result.replace(/textureCubeLodEXT\s*\(/g, "textureLod(");
  63186. result = result.replace(/textureCube\s*\(/g, "texture(");
  63187. result = result.replace(/gl_FragDepthEXT/g, "gl_FragDepth");
  63188. result = result.replace(/gl_FragColor/g, "glFragColor");
  63189. result = result.replace(/gl_FragData/g, "glFragData");
  63190. result = result.replace(/void\s+?main\s*\(/g, (hasDrawBuffersExtension ? "" : "out vec4 glFragColor;\n") + "void main(");
  63191. }
  63192. // Add multiview setup to top of file when defined
  63193. var hasMultiviewExtension = this.defines.indexOf("#define MULTIVIEW\n") !== -1;
  63194. if (hasMultiviewExtension && !isFragment) {
  63195. result = "#extension GL_OVR_multiview : require\nlayout (num_views = 2) in;\n" + result;
  63196. }
  63197. callback(result);
  63198. };
  63199. Effect.prototype._processIncludes = function (sourceCode, callback) {
  63200. var _this = this;
  63201. var regex = /#include<(.+)>(\((.*)\))*(\[(.*)\])*/g;
  63202. var match = regex.exec(sourceCode);
  63203. var returnValue = new String(sourceCode);
  63204. while (match != null) {
  63205. var includeFile = match[1];
  63206. // Uniform declaration
  63207. if (includeFile.indexOf("__decl__") !== -1) {
  63208. includeFile = includeFile.replace(/__decl__/, "");
  63209. if (this._engine.supportsUniformBuffers) {
  63210. includeFile = includeFile.replace(/Vertex/, "Ubo");
  63211. includeFile = includeFile.replace(/Fragment/, "Ubo");
  63212. }
  63213. includeFile = includeFile + "Declaration";
  63214. }
  63215. if (Effect.IncludesShadersStore[includeFile]) {
  63216. // Substitution
  63217. var includeContent = Effect.IncludesShadersStore[includeFile];
  63218. if (match[2]) {
  63219. var splits = match[3].split(",");
  63220. for (var index = 0; index < splits.length; index += 2) {
  63221. var source = new RegExp(splits[index], "g");
  63222. var dest = splits[index + 1];
  63223. includeContent = includeContent.replace(source, dest);
  63224. }
  63225. }
  63226. if (match[4]) {
  63227. var indexString = match[5];
  63228. if (indexString.indexOf("..") !== -1) {
  63229. var indexSplits = indexString.split("..");
  63230. var minIndex = parseInt(indexSplits[0]);
  63231. var maxIndex = parseInt(indexSplits[1]);
  63232. var sourceIncludeContent = includeContent.slice(0);
  63233. includeContent = "";
  63234. if (isNaN(maxIndex)) {
  63235. maxIndex = this._indexParameters[indexSplits[1]];
  63236. }
  63237. for (var i = minIndex; i < maxIndex; i++) {
  63238. if (!this._engine.supportsUniformBuffers) {
  63239. // Ubo replacement
  63240. sourceIncludeContent = sourceIncludeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  63241. return p1 + "{X}";
  63242. });
  63243. }
  63244. includeContent += sourceIncludeContent.replace(/\{X\}/g, i.toString()) + "\n";
  63245. }
  63246. }
  63247. else {
  63248. if (!this._engine.supportsUniformBuffers) {
  63249. // Ubo replacement
  63250. includeContent = includeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  63251. return p1 + "{X}";
  63252. });
  63253. }
  63254. includeContent = includeContent.replace(/\{X\}/g, indexString);
  63255. }
  63256. }
  63257. // Replace
  63258. returnValue = returnValue.replace(match[0], includeContent);
  63259. }
  63260. else {
  63261. var includeShaderUrl = Effect.ShadersRepository + "ShadersInclude/" + includeFile + ".fx";
  63262. this._engine._loadFile(includeShaderUrl, function (fileContent) {
  63263. Effect.IncludesShadersStore[includeFile] = fileContent;
  63264. _this._processIncludes(returnValue, callback);
  63265. });
  63266. return;
  63267. }
  63268. match = regex.exec(sourceCode);
  63269. }
  63270. callback(returnValue);
  63271. };
  63272. Effect.prototype._processPrecision = function (source) {
  63273. var shouldUseHighPrecisionShader = this._engine._shouldUseHighPrecisionShader;
  63274. if (source.indexOf("precision highp float") === -1) {
  63275. if (!shouldUseHighPrecisionShader) {
  63276. source = "precision mediump float;\n" + source;
  63277. }
  63278. else {
  63279. source = "precision highp float;\n" + source;
  63280. }
  63281. }
  63282. else {
  63283. if (!shouldUseHighPrecisionShader) { // Moving highp to mediump
  63284. source = source.replace("precision highp float", "precision mediump float");
  63285. }
  63286. }
  63287. return source;
  63288. };
  63289. /**
  63290. * Recompiles the webGL program
  63291. * @param vertexSourceCode The source code for the vertex shader.
  63292. * @param fragmentSourceCode The source code for the fragment shader.
  63293. * @param onCompiled Callback called when completed.
  63294. * @param onError Callback called on error.
  63295. * @hidden
  63296. */
  63297. Effect.prototype._rebuildProgram = function (vertexSourceCode, fragmentSourceCode, onCompiled, onError) {
  63298. var _this = this;
  63299. this._isReady = false;
  63300. this._vertexSourceCodeOverride = vertexSourceCode;
  63301. this._fragmentSourceCodeOverride = fragmentSourceCode;
  63302. this.onError = function (effect, error) {
  63303. if (onError) {
  63304. onError(error);
  63305. }
  63306. };
  63307. this.onCompiled = function () {
  63308. var scenes = _this.getEngine().scenes;
  63309. for (var i = 0; i < scenes.length; i++) {
  63310. scenes[i].markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_AllDirtyFlag);
  63311. }
  63312. if (onCompiled) {
  63313. onCompiled(_this._program);
  63314. }
  63315. };
  63316. this._fallbacks = null;
  63317. this._prepareEffect();
  63318. };
  63319. /**
  63320. * Gets the uniform locations of the the specified variable names
  63321. * @param names THe names of the variables to lookup.
  63322. * @returns Array of locations in the same order as variable names.
  63323. */
  63324. Effect.prototype.getSpecificUniformLocations = function (names) {
  63325. var engine = this._engine;
  63326. return engine.getUniforms(this._program, names);
  63327. };
  63328. /**
  63329. * Prepares the effect
  63330. * @hidden
  63331. */
  63332. Effect.prototype._prepareEffect = function () {
  63333. var _this = this;
  63334. var attributesNames = this._attributesNames;
  63335. var defines = this.defines;
  63336. var fallbacks = this._fallbacks;
  63337. this._valueCache = {};
  63338. var previousProgram = this._program;
  63339. try {
  63340. var engine_1 = this._engine;
  63341. if (this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride) {
  63342. this._program = engine_1.createRawShaderProgram(this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, undefined, this._transformFeedbackVaryings);
  63343. }
  63344. else {
  63345. this._program = engine_1.createShaderProgram(this._vertexSourceCode, this._fragmentSourceCode, defines, undefined, this._transformFeedbackVaryings);
  63346. }
  63347. this._program.__SPECTOR_rebuildProgram = this._rebuildProgram.bind(this);
  63348. engine_1._executeWhenProgramIsCompiled(this._program, function () {
  63349. if (engine_1.supportsUniformBuffers) {
  63350. for (var name in _this._uniformBuffersNames) {
  63351. _this.bindUniformBlock(name, _this._uniformBuffersNames[name]);
  63352. }
  63353. }
  63354. _this._uniforms = engine_1.getUniforms(_this._program, _this._uniformsNames);
  63355. _this._attributes = engine_1.getAttributes(_this._program, attributesNames);
  63356. var index;
  63357. for (index = 0; index < _this._samplers.length; index++) {
  63358. var sampler = _this.getUniform(_this._samplers[index]);
  63359. if (sampler == null) {
  63360. _this._samplers.splice(index, 1);
  63361. index--;
  63362. }
  63363. }
  63364. engine_1.bindSamplers(_this);
  63365. _this._compilationError = "";
  63366. _this._isReady = true;
  63367. if (_this.onCompiled) {
  63368. _this.onCompiled(_this);
  63369. }
  63370. _this.onCompileObservable.notifyObservers(_this);
  63371. _this.onCompileObservable.clear();
  63372. // Unbind mesh reference in fallbacks
  63373. if (_this._fallbacks) {
  63374. _this._fallbacks.unBindMesh();
  63375. }
  63376. if (previousProgram) {
  63377. _this.getEngine()._deleteProgram(previousProgram);
  63378. }
  63379. });
  63380. if (this._program.isParallelCompiled) {
  63381. this._checkIsReady();
  63382. }
  63383. }
  63384. catch (e) {
  63385. this._compilationError = e.message;
  63386. // Let's go through fallbacks then
  63387. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Unable to compile effect:");
  63388. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Uniforms: " + this._uniformsNames.map(function (uniform) {
  63389. return " " + uniform;
  63390. }));
  63391. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Attributes: " + attributesNames.map(function (attribute) {
  63392. return " " + attribute;
  63393. }));
  63394. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Error: " + this._compilationError);
  63395. if (previousProgram) {
  63396. this._program = previousProgram;
  63397. this._isReady = true;
  63398. if (this.onError) {
  63399. this.onError(this, this._compilationError);
  63400. }
  63401. this.onErrorObservable.notifyObservers(this);
  63402. }
  63403. if (fallbacks && fallbacks.isMoreFallbacks) {
  63404. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Trying next fallback.");
  63405. this.defines = fallbacks.reduce(this.defines, this);
  63406. this._prepareEffect();
  63407. }
  63408. else { // Sorry we did everything we can
  63409. if (this.onError) {
  63410. this.onError(this, this._compilationError);
  63411. }
  63412. this.onErrorObservable.notifyObservers(this);
  63413. this.onErrorObservable.clear();
  63414. // Unbind mesh reference in fallbacks
  63415. if (this._fallbacks) {
  63416. this._fallbacks.unBindMesh();
  63417. }
  63418. }
  63419. }
  63420. };
  63421. Object.defineProperty(Effect.prototype, "isSupported", {
  63422. /**
  63423. * Checks if the effect is supported. (Must be called after compilation)
  63424. */
  63425. get: function () {
  63426. return this._compilationError === "";
  63427. },
  63428. enumerable: true,
  63429. configurable: true
  63430. });
  63431. /**
  63432. * Binds a texture to the engine to be used as output of the shader.
  63433. * @param channel Name of the output variable.
  63434. * @param texture Texture to bind.
  63435. * @hidden
  63436. */
  63437. Effect.prototype._bindTexture = function (channel, texture) {
  63438. this._engine._bindTexture(this._samplers.indexOf(channel), texture);
  63439. };
  63440. /**
  63441. * Sets a texture on the engine to be used in the shader.
  63442. * @param channel Name of the sampler variable.
  63443. * @param texture Texture to set.
  63444. */
  63445. Effect.prototype.setTexture = function (channel, texture) {
  63446. this._engine.setTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  63447. };
  63448. /**
  63449. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  63450. * @param channel Name of the sampler variable.
  63451. * @param texture Texture to set.
  63452. */
  63453. Effect.prototype.setDepthStencilTexture = function (channel, texture) {
  63454. this._engine.setDepthStencilTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  63455. };
  63456. /**
  63457. * Sets an array of textures on the engine to be used in the shader.
  63458. * @param channel Name of the variable.
  63459. * @param textures Textures to set.
  63460. */
  63461. Effect.prototype.setTextureArray = function (channel, textures) {
  63462. if (this._samplers.indexOf(channel + "Ex") === -1) {
  63463. var initialPos = this._samplers.indexOf(channel);
  63464. for (var index = 1; index < textures.length; index++) {
  63465. this._samplers.splice(initialPos + index, 0, channel + "Ex");
  63466. }
  63467. }
  63468. this._engine.setTextureArray(this._samplers.indexOf(channel), this.getUniform(channel), textures);
  63469. };
  63470. /**
  63471. * 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)
  63472. * @param channel Name of the sampler variable.
  63473. * @param postProcess Post process to get the input texture from.
  63474. */
  63475. Effect.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  63476. this._engine.setTextureFromPostProcess(this._samplers.indexOf(channel), postProcess);
  63477. };
  63478. /**
  63479. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  63480. * 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)
  63481. * @param channel Name of the sampler variable.
  63482. * @param postProcess Post process to get the output texture from.
  63483. */
  63484. Effect.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  63485. this._engine.setTextureFromPostProcessOutput(this._samplers.indexOf(channel), postProcess);
  63486. };
  63487. /** @hidden */
  63488. Effect.prototype._cacheMatrix = function (uniformName, matrix) {
  63489. var cache = this._valueCache[uniformName];
  63490. var flag = matrix.updateFlag;
  63491. if (cache !== undefined && cache === flag) {
  63492. return false;
  63493. }
  63494. this._valueCache[uniformName] = flag;
  63495. return true;
  63496. };
  63497. /** @hidden */
  63498. Effect.prototype._cacheFloat2 = function (uniformName, x, y) {
  63499. var cache = this._valueCache[uniformName];
  63500. if (!cache) {
  63501. cache = [x, y];
  63502. this._valueCache[uniformName] = cache;
  63503. return true;
  63504. }
  63505. var changed = false;
  63506. if (cache[0] !== x) {
  63507. cache[0] = x;
  63508. changed = true;
  63509. }
  63510. if (cache[1] !== y) {
  63511. cache[1] = y;
  63512. changed = true;
  63513. }
  63514. return changed;
  63515. };
  63516. /** @hidden */
  63517. Effect.prototype._cacheFloat3 = function (uniformName, x, y, z) {
  63518. var cache = this._valueCache[uniformName];
  63519. if (!cache) {
  63520. cache = [x, y, z];
  63521. this._valueCache[uniformName] = cache;
  63522. return true;
  63523. }
  63524. var changed = false;
  63525. if (cache[0] !== x) {
  63526. cache[0] = x;
  63527. changed = true;
  63528. }
  63529. if (cache[1] !== y) {
  63530. cache[1] = y;
  63531. changed = true;
  63532. }
  63533. if (cache[2] !== z) {
  63534. cache[2] = z;
  63535. changed = true;
  63536. }
  63537. return changed;
  63538. };
  63539. /** @hidden */
  63540. Effect.prototype._cacheFloat4 = function (uniformName, x, y, z, w) {
  63541. var cache = this._valueCache[uniformName];
  63542. if (!cache) {
  63543. cache = [x, y, z, w];
  63544. this._valueCache[uniformName] = cache;
  63545. return true;
  63546. }
  63547. var changed = false;
  63548. if (cache[0] !== x) {
  63549. cache[0] = x;
  63550. changed = true;
  63551. }
  63552. if (cache[1] !== y) {
  63553. cache[1] = y;
  63554. changed = true;
  63555. }
  63556. if (cache[2] !== z) {
  63557. cache[2] = z;
  63558. changed = true;
  63559. }
  63560. if (cache[3] !== w) {
  63561. cache[3] = w;
  63562. changed = true;
  63563. }
  63564. return changed;
  63565. };
  63566. /**
  63567. * Binds a buffer to a uniform.
  63568. * @param buffer Buffer to bind.
  63569. * @param name Name of the uniform variable to bind to.
  63570. */
  63571. Effect.prototype.bindUniformBuffer = function (buffer, name) {
  63572. var bufferName = this._uniformBuffersNames[name];
  63573. if (bufferName === undefined || Effect._baseCache[bufferName] === buffer) {
  63574. return;
  63575. }
  63576. Effect._baseCache[bufferName] = buffer;
  63577. this._engine.bindUniformBufferBase(buffer, bufferName);
  63578. };
  63579. /**
  63580. * Binds block to a uniform.
  63581. * @param blockName Name of the block to bind.
  63582. * @param index Index to bind.
  63583. */
  63584. Effect.prototype.bindUniformBlock = function (blockName, index) {
  63585. this._engine.bindUniformBlock(this._program, blockName, index);
  63586. };
  63587. /**
  63588. * Sets an interger value on a uniform variable.
  63589. * @param uniformName Name of the variable.
  63590. * @param value Value to be set.
  63591. * @returns this effect.
  63592. */
  63593. Effect.prototype.setInt = function (uniformName, value) {
  63594. var cache = this._valueCache[uniformName];
  63595. if (cache !== undefined && cache === value) {
  63596. return this;
  63597. }
  63598. this._valueCache[uniformName] = value;
  63599. this._engine.setInt(this.getUniform(uniformName), value);
  63600. return this;
  63601. };
  63602. /**
  63603. * Sets an int array on a uniform variable.
  63604. * @param uniformName Name of the variable.
  63605. * @param array array to be set.
  63606. * @returns this effect.
  63607. */
  63608. Effect.prototype.setIntArray = function (uniformName, array) {
  63609. this._valueCache[uniformName] = null;
  63610. this._engine.setIntArray(this.getUniform(uniformName), array);
  63611. return this;
  63612. };
  63613. /**
  63614. * 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)
  63615. * @param uniformName Name of the variable.
  63616. * @param array array to be set.
  63617. * @returns this effect.
  63618. */
  63619. Effect.prototype.setIntArray2 = function (uniformName, array) {
  63620. this._valueCache[uniformName] = null;
  63621. this._engine.setIntArray2(this.getUniform(uniformName), array);
  63622. return this;
  63623. };
  63624. /**
  63625. * 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)
  63626. * @param uniformName Name of the variable.
  63627. * @param array array to be set.
  63628. * @returns this effect.
  63629. */
  63630. Effect.prototype.setIntArray3 = function (uniformName, array) {
  63631. this._valueCache[uniformName] = null;
  63632. this._engine.setIntArray3(this.getUniform(uniformName), array);
  63633. return this;
  63634. };
  63635. /**
  63636. * 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)
  63637. * @param uniformName Name of the variable.
  63638. * @param array array to be set.
  63639. * @returns this effect.
  63640. */
  63641. Effect.prototype.setIntArray4 = function (uniformName, array) {
  63642. this._valueCache[uniformName] = null;
  63643. this._engine.setIntArray4(this.getUniform(uniformName), array);
  63644. return this;
  63645. };
  63646. /**
  63647. * Sets an float array on a uniform variable.
  63648. * @param uniformName Name of the variable.
  63649. * @param array array to be set.
  63650. * @returns this effect.
  63651. */
  63652. Effect.prototype.setFloatArray = function (uniformName, array) {
  63653. this._valueCache[uniformName] = null;
  63654. this._engine.setFloatArray(this.getUniform(uniformName), array);
  63655. return this;
  63656. };
  63657. /**
  63658. * 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)
  63659. * @param uniformName Name of the variable.
  63660. * @param array array to be set.
  63661. * @returns this effect.
  63662. */
  63663. Effect.prototype.setFloatArray2 = function (uniformName, array) {
  63664. this._valueCache[uniformName] = null;
  63665. this._engine.setFloatArray2(this.getUniform(uniformName), array);
  63666. return this;
  63667. };
  63668. /**
  63669. * 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)
  63670. * @param uniformName Name of the variable.
  63671. * @param array array to be set.
  63672. * @returns this effect.
  63673. */
  63674. Effect.prototype.setFloatArray3 = function (uniformName, array) {
  63675. this._valueCache[uniformName] = null;
  63676. this._engine.setFloatArray3(this.getUniform(uniformName), array);
  63677. return this;
  63678. };
  63679. /**
  63680. * 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)
  63681. * @param uniformName Name of the variable.
  63682. * @param array array to be set.
  63683. * @returns this effect.
  63684. */
  63685. Effect.prototype.setFloatArray4 = function (uniformName, array) {
  63686. this._valueCache[uniformName] = null;
  63687. this._engine.setFloatArray4(this.getUniform(uniformName), array);
  63688. return this;
  63689. };
  63690. /**
  63691. * Sets an array on a uniform variable.
  63692. * @param uniformName Name of the variable.
  63693. * @param array array to be set.
  63694. * @returns this effect.
  63695. */
  63696. Effect.prototype.setArray = function (uniformName, array) {
  63697. this._valueCache[uniformName] = null;
  63698. this._engine.setArray(this.getUniform(uniformName), array);
  63699. return this;
  63700. };
  63701. /**
  63702. * 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)
  63703. * @param uniformName Name of the variable.
  63704. * @param array array to be set.
  63705. * @returns this effect.
  63706. */
  63707. Effect.prototype.setArray2 = function (uniformName, array) {
  63708. this._valueCache[uniformName] = null;
  63709. this._engine.setArray2(this.getUniform(uniformName), array);
  63710. return this;
  63711. };
  63712. /**
  63713. * 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)
  63714. * @param uniformName Name of the variable.
  63715. * @param array array to be set.
  63716. * @returns this effect.
  63717. */
  63718. Effect.prototype.setArray3 = function (uniformName, array) {
  63719. this._valueCache[uniformName] = null;
  63720. this._engine.setArray3(this.getUniform(uniformName), array);
  63721. return this;
  63722. };
  63723. /**
  63724. * 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)
  63725. * @param uniformName Name of the variable.
  63726. * @param array array to be set.
  63727. * @returns this effect.
  63728. */
  63729. Effect.prototype.setArray4 = function (uniformName, array) {
  63730. this._valueCache[uniformName] = null;
  63731. this._engine.setArray4(this.getUniform(uniformName), array);
  63732. return this;
  63733. };
  63734. /**
  63735. * Sets matrices on a uniform variable.
  63736. * @param uniformName Name of the variable.
  63737. * @param matrices matrices to be set.
  63738. * @returns this effect.
  63739. */
  63740. Effect.prototype.setMatrices = function (uniformName, matrices) {
  63741. if (!matrices) {
  63742. return this;
  63743. }
  63744. this._valueCache[uniformName] = null;
  63745. this._engine.setMatrices(this.getUniform(uniformName), matrices);
  63746. return this;
  63747. };
  63748. /**
  63749. * Sets matrix on a uniform variable.
  63750. * @param uniformName Name of the variable.
  63751. * @param matrix matrix to be set.
  63752. * @returns this effect.
  63753. */
  63754. Effect.prototype.setMatrix = function (uniformName, matrix) {
  63755. if (this._cacheMatrix(uniformName, matrix)) {
  63756. this._engine.setMatrix(this.getUniform(uniformName), matrix);
  63757. }
  63758. return this;
  63759. };
  63760. /**
  63761. * 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)
  63762. * @param uniformName Name of the variable.
  63763. * @param matrix matrix to be set.
  63764. * @returns this effect.
  63765. */
  63766. Effect.prototype.setMatrix3x3 = function (uniformName, matrix) {
  63767. this._valueCache[uniformName] = null;
  63768. this._engine.setMatrix3x3(this.getUniform(uniformName), matrix);
  63769. return this;
  63770. };
  63771. /**
  63772. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  63773. * @param uniformName Name of the variable.
  63774. * @param matrix matrix to be set.
  63775. * @returns this effect.
  63776. */
  63777. Effect.prototype.setMatrix2x2 = function (uniformName, matrix) {
  63778. this._valueCache[uniformName] = null;
  63779. this._engine.setMatrix2x2(this.getUniform(uniformName), matrix);
  63780. return this;
  63781. };
  63782. /**
  63783. * Sets a float on a uniform variable.
  63784. * @param uniformName Name of the variable.
  63785. * @param value value to be set.
  63786. * @returns this effect.
  63787. */
  63788. Effect.prototype.setFloat = function (uniformName, value) {
  63789. var cache = this._valueCache[uniformName];
  63790. if (cache !== undefined && cache === value) {
  63791. return this;
  63792. }
  63793. this._valueCache[uniformName] = value;
  63794. this._engine.setFloat(this.getUniform(uniformName), value);
  63795. return this;
  63796. };
  63797. /**
  63798. * Sets a boolean on a uniform variable.
  63799. * @param uniformName Name of the variable.
  63800. * @param bool value to be set.
  63801. * @returns this effect.
  63802. */
  63803. Effect.prototype.setBool = function (uniformName, bool) {
  63804. var cache = this._valueCache[uniformName];
  63805. if (cache !== undefined && cache === bool) {
  63806. return this;
  63807. }
  63808. this._valueCache[uniformName] = bool;
  63809. this._engine.setBool(this.getUniform(uniformName), bool ? 1 : 0);
  63810. return this;
  63811. };
  63812. /**
  63813. * Sets a Vector2 on a uniform variable.
  63814. * @param uniformName Name of the variable.
  63815. * @param vector2 vector2 to be set.
  63816. * @returns this effect.
  63817. */
  63818. Effect.prototype.setVector2 = function (uniformName, vector2) {
  63819. if (this._cacheFloat2(uniformName, vector2.x, vector2.y)) {
  63820. this._engine.setFloat2(this.getUniform(uniformName), vector2.x, vector2.y);
  63821. }
  63822. return this;
  63823. };
  63824. /**
  63825. * Sets a float2 on a uniform variable.
  63826. * @param uniformName Name of the variable.
  63827. * @param x First float in float2.
  63828. * @param y Second float in float2.
  63829. * @returns this effect.
  63830. */
  63831. Effect.prototype.setFloat2 = function (uniformName, x, y) {
  63832. if (this._cacheFloat2(uniformName, x, y)) {
  63833. this._engine.setFloat2(this.getUniform(uniformName), x, y);
  63834. }
  63835. return this;
  63836. };
  63837. /**
  63838. * Sets a Vector3 on a uniform variable.
  63839. * @param uniformName Name of the variable.
  63840. * @param vector3 Value to be set.
  63841. * @returns this effect.
  63842. */
  63843. Effect.prototype.setVector3 = function (uniformName, vector3) {
  63844. if (this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z)) {
  63845. this._engine.setFloat3(this.getUniform(uniformName), vector3.x, vector3.y, vector3.z);
  63846. }
  63847. return this;
  63848. };
  63849. /**
  63850. * Sets a float3 on a uniform variable.
  63851. * @param uniformName Name of the variable.
  63852. * @param x First float in float3.
  63853. * @param y Second float in float3.
  63854. * @param z Third float in float3.
  63855. * @returns this effect.
  63856. */
  63857. Effect.prototype.setFloat3 = function (uniformName, x, y, z) {
  63858. if (this._cacheFloat3(uniformName, x, y, z)) {
  63859. this._engine.setFloat3(this.getUniform(uniformName), x, y, z);
  63860. }
  63861. return this;
  63862. };
  63863. /**
  63864. * Sets a Vector4 on a uniform variable.
  63865. * @param uniformName Name of the variable.
  63866. * @param vector4 Value to be set.
  63867. * @returns this effect.
  63868. */
  63869. Effect.prototype.setVector4 = function (uniformName, vector4) {
  63870. if (this._cacheFloat4(uniformName, vector4.x, vector4.y, vector4.z, vector4.w)) {
  63871. this._engine.setFloat4(this.getUniform(uniformName), vector4.x, vector4.y, vector4.z, vector4.w);
  63872. }
  63873. return this;
  63874. };
  63875. /**
  63876. * Sets a float4 on a uniform variable.
  63877. * @param uniformName Name of the variable.
  63878. * @param x First float in float4.
  63879. * @param y Second float in float4.
  63880. * @param z Third float in float4.
  63881. * @param w Fourth float in float4.
  63882. * @returns this effect.
  63883. */
  63884. Effect.prototype.setFloat4 = function (uniformName, x, y, z, w) {
  63885. if (this._cacheFloat4(uniformName, x, y, z, w)) {
  63886. this._engine.setFloat4(this.getUniform(uniformName), x, y, z, w);
  63887. }
  63888. return this;
  63889. };
  63890. /**
  63891. * Sets a Color3 on a uniform variable.
  63892. * @param uniformName Name of the variable.
  63893. * @param color3 Value to be set.
  63894. * @returns this effect.
  63895. */
  63896. Effect.prototype.setColor3 = function (uniformName, color3) {
  63897. if (this._cacheFloat3(uniformName, color3.r, color3.g, color3.b)) {
  63898. this._engine.setColor3(this.getUniform(uniformName), color3);
  63899. }
  63900. return this;
  63901. };
  63902. /**
  63903. * Sets a Color4 on a uniform variable.
  63904. * @param uniformName Name of the variable.
  63905. * @param color3 Value to be set.
  63906. * @param alpha Alpha value to be set.
  63907. * @returns this effect.
  63908. */
  63909. Effect.prototype.setColor4 = function (uniformName, color3, alpha) {
  63910. if (this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha)) {
  63911. this._engine.setColor4(this.getUniform(uniformName), color3, alpha);
  63912. }
  63913. return this;
  63914. };
  63915. /**
  63916. * Sets a Color4 on a uniform variable
  63917. * @param uniformName defines the name of the variable
  63918. * @param color4 defines the value to be set
  63919. * @returns this effect.
  63920. */
  63921. Effect.prototype.setDirectColor4 = function (uniformName, color4) {
  63922. if (this._cacheFloat4(uniformName, color4.r, color4.g, color4.b, color4.a)) {
  63923. this._engine.setDirectColor4(this.getUniform(uniformName), color4);
  63924. }
  63925. return this;
  63926. };
  63927. /**
  63928. * This function will add a new shader to the shader store
  63929. * @param name the name of the shader
  63930. * @param pixelShader optional pixel shader content
  63931. * @param vertexShader optional vertex shader content
  63932. */
  63933. Effect.RegisterShader = function (name, pixelShader, vertexShader) {
  63934. if (pixelShader) {
  63935. Effect.ShadersStore[name + "PixelShader"] = pixelShader;
  63936. }
  63937. if (vertexShader) {
  63938. Effect.ShadersStore[name + "VertexShader"] = vertexShader;
  63939. }
  63940. };
  63941. /**
  63942. * Resets the cache of effects.
  63943. */
  63944. Effect.ResetCache = function () {
  63945. Effect._baseCache = {};
  63946. };
  63947. /**
  63948. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  63949. */
  63950. Effect.ShadersRepository = "src/Shaders/";
  63951. Effect._uniqueIdSeed = 0;
  63952. Effect._baseCache = {};
  63953. /**
  63954. * Store of each shader (The can be looked up using effect.key)
  63955. */
  63956. Effect.ShadersStore = {};
  63957. /**
  63958. * Store of each included file for a shader (The can be looked up using effect.key)
  63959. */
  63960. Effect.IncludesShadersStore = {};
  63961. return Effect;
  63962. }());
  63963. /***/ }),
  63964. /***/ "./Materials/fresnelParameters.ts":
  63965. /*!****************************************!*\
  63966. !*** ./Materials/fresnelParameters.ts ***!
  63967. \****************************************/
  63968. /*! exports provided: FresnelParameters */
  63969. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63970. "use strict";
  63971. __webpack_require__.r(__webpack_exports__);
  63972. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return FresnelParameters; });
  63973. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  63974. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  63975. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  63976. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  63977. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  63978. /**
  63979. * This represents all the required information to add a fresnel effect on a material:
  63980. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  63981. */
  63982. var FresnelParameters = /** @class */ (function () {
  63983. function FresnelParameters() {
  63984. this._isEnabled = true;
  63985. /**
  63986. * Define the color used on edges (grazing angle)
  63987. */
  63988. this.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].White();
  63989. /**
  63990. * Define the color used on center
  63991. */
  63992. this.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  63993. /**
  63994. * Define bias applied to computed fresnel term
  63995. */
  63996. this.bias = 0;
  63997. /**
  63998. * Defined the power exponent applied to fresnel term
  63999. */
  64000. this.power = 1;
  64001. }
  64002. Object.defineProperty(FresnelParameters.prototype, "isEnabled", {
  64003. /**
  64004. * Define if the fresnel effect is enable or not.
  64005. */
  64006. get: function () {
  64007. return this._isEnabled;
  64008. },
  64009. set: function (value) {
  64010. if (this._isEnabled === value) {
  64011. return;
  64012. }
  64013. this._isEnabled = value;
  64014. _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);
  64015. },
  64016. enumerable: true,
  64017. configurable: true
  64018. });
  64019. /**
  64020. * Clones the current fresnel and its valuues
  64021. * @returns a clone fresnel configuration
  64022. */
  64023. FresnelParameters.prototype.clone = function () {
  64024. var newFresnelParameters = new FresnelParameters();
  64025. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newFresnelParameters);
  64026. return newFresnelParameters;
  64027. };
  64028. /**
  64029. * Serializes the current fresnel parameters to a JSON representation.
  64030. * @return the JSON serialization
  64031. */
  64032. FresnelParameters.prototype.serialize = function () {
  64033. var serializationObject = {};
  64034. serializationObject.isEnabled = this.isEnabled;
  64035. serializationObject.leftColor = this.leftColor.asArray();
  64036. serializationObject.rightColor = this.rightColor.asArray();
  64037. serializationObject.bias = this.bias;
  64038. serializationObject.power = this.power;
  64039. return serializationObject;
  64040. };
  64041. /**
  64042. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  64043. * @param parsedFresnelParameters Define the JSON representation
  64044. * @returns the parsed parameters
  64045. */
  64046. FresnelParameters.Parse = function (parsedFresnelParameters) {
  64047. var fresnelParameters = new FresnelParameters();
  64048. fresnelParameters.isEnabled = parsedFresnelParameters.isEnabled;
  64049. fresnelParameters.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.leftColor);
  64050. fresnelParameters.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.rightColor);
  64051. fresnelParameters.bias = parsedFresnelParameters.bias;
  64052. fresnelParameters.power = parsedFresnelParameters.power || 1.0;
  64053. return fresnelParameters;
  64054. };
  64055. return FresnelParameters;
  64056. }());
  64057. // References the dependencies.
  64058. _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]._FresnelParametersParser = FresnelParameters.Parse;
  64059. /***/ }),
  64060. /***/ "./Materials/imageProcessingConfiguration.ts":
  64061. /*!***************************************************!*\
  64062. !*** ./Materials/imageProcessingConfiguration.ts ***!
  64063. \***************************************************/
  64064. /*! exports provided: ImageProcessingConfigurationDefines, ImageProcessingConfiguration */
  64065. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64066. "use strict";
  64067. __webpack_require__.r(__webpack_exports__);
  64068. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return ImageProcessingConfigurationDefines; });
  64069. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return ImageProcessingConfiguration; });
  64070. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64071. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  64072. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  64073. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  64074. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  64075. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  64076. /* harmony import */ var _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/colorCurves */ "./Materials/colorCurves.ts");
  64077. /**
  64078. * @hidden
  64079. */
  64080. var ImageProcessingConfigurationDefines = /** @class */ (function (_super) {
  64081. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingConfigurationDefines, _super);
  64082. function ImageProcessingConfigurationDefines() {
  64083. var _this = _super.call(this) || this;
  64084. _this.IMAGEPROCESSING = false;
  64085. _this.VIGNETTE = false;
  64086. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  64087. _this.VIGNETTEBLENDMODEOPAQUE = false;
  64088. _this.TONEMAPPING = false;
  64089. _this.TONEMAPPING_ACES = false;
  64090. _this.CONTRAST = false;
  64091. _this.COLORCURVES = false;
  64092. _this.COLORGRADING = false;
  64093. _this.COLORGRADING3D = false;
  64094. _this.SAMPLER3DGREENDEPTH = false;
  64095. _this.SAMPLER3DBGRMAP = false;
  64096. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  64097. _this.EXPOSURE = false;
  64098. _this.rebuild();
  64099. return _this;
  64100. }
  64101. return ImageProcessingConfigurationDefines;
  64102. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__["MaterialDefines"]));
  64103. /**
  64104. * This groups together the common properties used for image processing either in direct forward pass
  64105. * or through post processing effect depending on the use of the image processing pipeline in your scene
  64106. * or not.
  64107. */
  64108. var ImageProcessingConfiguration = /** @class */ (function () {
  64109. function ImageProcessingConfiguration() {
  64110. /**
  64111. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  64112. */
  64113. this.colorCurves = new _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"]();
  64114. this._colorCurvesEnabled = false;
  64115. this._colorGradingEnabled = false;
  64116. this._colorGradingWithGreenDepth = true;
  64117. this._colorGradingBGR = true;
  64118. /** @hidden */
  64119. this._exposure = 1.0;
  64120. this._toneMappingEnabled = false;
  64121. this._toneMappingType = ImageProcessingConfiguration.TONEMAPPING_STANDARD;
  64122. this._contrast = 1.0;
  64123. /**
  64124. * Vignette stretch size.
  64125. */
  64126. this.vignetteStretch = 0;
  64127. /**
  64128. * Vignette centre X Offset.
  64129. */
  64130. this.vignetteCentreX = 0;
  64131. /**
  64132. * Vignette centre Y Offset.
  64133. */
  64134. this.vignetteCentreY = 0;
  64135. /**
  64136. * Vignette weight or intensity of the vignette effect.
  64137. */
  64138. this.vignetteWeight = 1.5;
  64139. /**
  64140. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  64141. * if vignetteEnabled is set to true.
  64142. */
  64143. this.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  64144. /**
  64145. * Camera field of view used by the Vignette effect.
  64146. */
  64147. this.vignetteCameraFov = 0.5;
  64148. this._vignetteBlendMode = ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;
  64149. this._vignetteEnabled = false;
  64150. this._applyByPostProcess = false;
  64151. this._isEnabled = true;
  64152. /**
  64153. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  64154. */
  64155. this.onUpdateParameters = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  64156. }
  64157. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorCurvesEnabled", {
  64158. /**
  64159. * Gets wether the color curves effect is enabled.
  64160. */
  64161. get: function () {
  64162. return this._colorCurvesEnabled;
  64163. },
  64164. /**
  64165. * Sets wether the color curves effect is enabled.
  64166. */
  64167. set: function (value) {
  64168. if (this._colorCurvesEnabled === value) {
  64169. return;
  64170. }
  64171. this._colorCurvesEnabled = value;
  64172. this._updateParameters();
  64173. },
  64174. enumerable: true,
  64175. configurable: true
  64176. });
  64177. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingTexture", {
  64178. /**
  64179. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  64180. */
  64181. get: function () {
  64182. return this._colorGradingTexture;
  64183. },
  64184. /**
  64185. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  64186. */
  64187. set: function (value) {
  64188. if (this._colorGradingTexture === value) {
  64189. return;
  64190. }
  64191. this._colorGradingTexture = value;
  64192. this._updateParameters();
  64193. },
  64194. enumerable: true,
  64195. configurable: true
  64196. });
  64197. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingEnabled", {
  64198. /**
  64199. * Gets wether the color grading effect is enabled.
  64200. */
  64201. get: function () {
  64202. return this._colorGradingEnabled;
  64203. },
  64204. /**
  64205. * Sets wether the color grading effect is enabled.
  64206. */
  64207. set: function (value) {
  64208. if (this._colorGradingEnabled === value) {
  64209. return;
  64210. }
  64211. this._colorGradingEnabled = value;
  64212. this._updateParameters();
  64213. },
  64214. enumerable: true,
  64215. configurable: true
  64216. });
  64217. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingWithGreenDepth", {
  64218. /**
  64219. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  64220. */
  64221. get: function () {
  64222. return this._colorGradingWithGreenDepth;
  64223. },
  64224. /**
  64225. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  64226. */
  64227. set: function (value) {
  64228. if (this._colorGradingWithGreenDepth === value) {
  64229. return;
  64230. }
  64231. this._colorGradingWithGreenDepth = value;
  64232. this._updateParameters();
  64233. },
  64234. enumerable: true,
  64235. configurable: true
  64236. });
  64237. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingBGR", {
  64238. /**
  64239. * Gets wether the color grading texture contains BGR values.
  64240. */
  64241. get: function () {
  64242. return this._colorGradingBGR;
  64243. },
  64244. /**
  64245. * Sets wether the color grading texture contains BGR values.
  64246. */
  64247. set: function (value) {
  64248. if (this._colorGradingBGR === value) {
  64249. return;
  64250. }
  64251. this._colorGradingBGR = value;
  64252. this._updateParameters();
  64253. },
  64254. enumerable: true,
  64255. configurable: true
  64256. });
  64257. Object.defineProperty(ImageProcessingConfiguration.prototype, "exposure", {
  64258. /**
  64259. * Gets the Exposure used in the effect.
  64260. */
  64261. get: function () {
  64262. return this._exposure;
  64263. },
  64264. /**
  64265. * Sets the Exposure used in the effect.
  64266. */
  64267. set: function (value) {
  64268. if (this._exposure === value) {
  64269. return;
  64270. }
  64271. this._exposure = value;
  64272. this._updateParameters();
  64273. },
  64274. enumerable: true,
  64275. configurable: true
  64276. });
  64277. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingEnabled", {
  64278. /**
  64279. * Gets wether the tone mapping effect is enabled.
  64280. */
  64281. get: function () {
  64282. return this._toneMappingEnabled;
  64283. },
  64284. /**
  64285. * Sets wether the tone mapping effect is enabled.
  64286. */
  64287. set: function (value) {
  64288. if (this._toneMappingEnabled === value) {
  64289. return;
  64290. }
  64291. this._toneMappingEnabled = value;
  64292. this._updateParameters();
  64293. },
  64294. enumerable: true,
  64295. configurable: true
  64296. });
  64297. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingType", {
  64298. /**
  64299. * Gets the type of tone mapping effect.
  64300. */
  64301. get: function () {
  64302. return this._toneMappingType;
  64303. },
  64304. /**
  64305. * Sets the type of tone mapping effect used in BabylonJS.
  64306. */
  64307. set: function (value) {
  64308. if (this._toneMappingType === value) {
  64309. return;
  64310. }
  64311. this._toneMappingType = value;
  64312. this._updateParameters();
  64313. },
  64314. enumerable: true,
  64315. configurable: true
  64316. });
  64317. Object.defineProperty(ImageProcessingConfiguration.prototype, "contrast", {
  64318. /**
  64319. * Gets the contrast used in the effect.
  64320. */
  64321. get: function () {
  64322. return this._contrast;
  64323. },
  64324. /**
  64325. * Sets the contrast used in the effect.
  64326. */
  64327. set: function (value) {
  64328. if (this._contrast === value) {
  64329. return;
  64330. }
  64331. this._contrast = value;
  64332. this._updateParameters();
  64333. },
  64334. enumerable: true,
  64335. configurable: true
  64336. });
  64337. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteBlendMode", {
  64338. /**
  64339. * Gets the vignette blend mode allowing different kind of effect.
  64340. */
  64341. get: function () {
  64342. return this._vignetteBlendMode;
  64343. },
  64344. /**
  64345. * Sets the vignette blend mode allowing different kind of effect.
  64346. */
  64347. set: function (value) {
  64348. if (this._vignetteBlendMode === value) {
  64349. return;
  64350. }
  64351. this._vignetteBlendMode = value;
  64352. this._updateParameters();
  64353. },
  64354. enumerable: true,
  64355. configurable: true
  64356. });
  64357. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteEnabled", {
  64358. /**
  64359. * Gets wether the vignette effect is enabled.
  64360. */
  64361. get: function () {
  64362. return this._vignetteEnabled;
  64363. },
  64364. /**
  64365. * Sets wether the vignette effect is enabled.
  64366. */
  64367. set: function (value) {
  64368. if (this._vignetteEnabled === value) {
  64369. return;
  64370. }
  64371. this._vignetteEnabled = value;
  64372. this._updateParameters();
  64373. },
  64374. enumerable: true,
  64375. configurable: true
  64376. });
  64377. Object.defineProperty(ImageProcessingConfiguration.prototype, "applyByPostProcess", {
  64378. /**
  64379. * Gets wether the image processing is applied through a post process or not.
  64380. */
  64381. get: function () {
  64382. return this._applyByPostProcess;
  64383. },
  64384. /**
  64385. * Sets wether the image processing is applied through a post process or not.
  64386. */
  64387. set: function (value) {
  64388. if (this._applyByPostProcess === value) {
  64389. return;
  64390. }
  64391. this._applyByPostProcess = value;
  64392. this._updateParameters();
  64393. },
  64394. enumerable: true,
  64395. configurable: true
  64396. });
  64397. Object.defineProperty(ImageProcessingConfiguration.prototype, "isEnabled", {
  64398. /**
  64399. * Gets wether the image processing is enabled or not.
  64400. */
  64401. get: function () {
  64402. return this._isEnabled;
  64403. },
  64404. /**
  64405. * Sets wether the image processing is enabled or not.
  64406. */
  64407. set: function (value) {
  64408. if (this._isEnabled === value) {
  64409. return;
  64410. }
  64411. this._isEnabled = value;
  64412. this._updateParameters();
  64413. },
  64414. enumerable: true,
  64415. configurable: true
  64416. });
  64417. /**
  64418. * Method called each time the image processing information changes requires to recompile the effect.
  64419. */
  64420. ImageProcessingConfiguration.prototype._updateParameters = function () {
  64421. this.onUpdateParameters.notifyObservers(this);
  64422. };
  64423. /**
  64424. * Gets the current class name.
  64425. * @return "ImageProcessingConfiguration"
  64426. */
  64427. ImageProcessingConfiguration.prototype.getClassName = function () {
  64428. return "ImageProcessingConfiguration";
  64429. };
  64430. /**
  64431. * Prepare the list of uniforms associated with the Image Processing effects.
  64432. * @param uniforms The list of uniforms used in the effect
  64433. * @param defines the list of defines currently in use
  64434. */
  64435. ImageProcessingConfiguration.PrepareUniforms = function (uniforms, defines) {
  64436. if (defines.EXPOSURE) {
  64437. uniforms.push("exposureLinear");
  64438. }
  64439. if (defines.CONTRAST) {
  64440. uniforms.push("contrast");
  64441. }
  64442. if (defines.COLORGRADING) {
  64443. uniforms.push("colorTransformSettings");
  64444. }
  64445. if (defines.VIGNETTE) {
  64446. uniforms.push("vInverseScreenSize");
  64447. uniforms.push("vignetteSettings1");
  64448. uniforms.push("vignetteSettings2");
  64449. }
  64450. if (defines.COLORCURVES) {
  64451. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].PrepareUniforms(uniforms);
  64452. }
  64453. };
  64454. /**
  64455. * Prepare the list of samplers associated with the Image Processing effects.
  64456. * @param samplersList The list of uniforms used in the effect
  64457. * @param defines the list of defines currently in use
  64458. */
  64459. ImageProcessingConfiguration.PrepareSamplers = function (samplersList, defines) {
  64460. if (defines.COLORGRADING) {
  64461. samplersList.push("txColorTransform");
  64462. }
  64463. };
  64464. /**
  64465. * Prepare the list of defines associated to the shader.
  64466. * @param defines the list of defines to complete
  64467. * @param forPostProcess Define if we are currently in post process mode or not
  64468. */
  64469. ImageProcessingConfiguration.prototype.prepareDefines = function (defines, forPostProcess) {
  64470. if (forPostProcess === void 0) { forPostProcess = false; }
  64471. if (forPostProcess !== this.applyByPostProcess || !this._isEnabled) {
  64472. defines.VIGNETTE = false;
  64473. defines.TONEMAPPING = false;
  64474. defines.TONEMAPPING_ACES = false;
  64475. defines.CONTRAST = false;
  64476. defines.EXPOSURE = false;
  64477. defines.COLORCURVES = false;
  64478. defines.COLORGRADING = false;
  64479. defines.COLORGRADING3D = false;
  64480. defines.IMAGEPROCESSING = false;
  64481. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess && this._isEnabled;
  64482. return;
  64483. }
  64484. defines.VIGNETTE = this.vignetteEnabled;
  64485. defines.VIGNETTEBLENDMODEMULTIPLY = (this.vignetteBlendMode === ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY);
  64486. defines.VIGNETTEBLENDMODEOPAQUE = !defines.VIGNETTEBLENDMODEMULTIPLY;
  64487. defines.TONEMAPPING = this.toneMappingEnabled;
  64488. switch (this._toneMappingType) {
  64489. case ImageProcessingConfiguration.TONEMAPPING_ACES:
  64490. defines.TONEMAPPING_ACES = true;
  64491. break;
  64492. default:
  64493. defines.TONEMAPPING_ACES = false;
  64494. break;
  64495. }
  64496. defines.CONTRAST = (this.contrast !== 1.0);
  64497. defines.EXPOSURE = (this.exposure !== 1.0);
  64498. defines.COLORCURVES = (this.colorCurvesEnabled && !!this.colorCurves);
  64499. defines.COLORGRADING = (this.colorGradingEnabled && !!this.colorGradingTexture);
  64500. if (defines.COLORGRADING) {
  64501. defines.COLORGRADING3D = this.colorGradingTexture.is3D;
  64502. }
  64503. else {
  64504. defines.COLORGRADING3D = false;
  64505. }
  64506. defines.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth;
  64507. defines.SAMPLER3DBGRMAP = this.colorGradingBGR;
  64508. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess;
  64509. defines.IMAGEPROCESSING = defines.VIGNETTE || defines.TONEMAPPING || defines.CONTRAST || defines.EXPOSURE || defines.COLORCURVES || defines.COLORGRADING;
  64510. };
  64511. /**
  64512. * Returns true if all the image processing information are ready.
  64513. * @returns True if ready, otherwise, false
  64514. */
  64515. ImageProcessingConfiguration.prototype.isReady = function () {
  64516. // Color Grading texure can not be none blocking.
  64517. return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady();
  64518. };
  64519. /**
  64520. * Binds the image processing to the shader.
  64521. * @param effect The effect to bind to
  64522. * @param aspectRatio Define the current aspect ratio of the effect
  64523. */
  64524. ImageProcessingConfiguration.prototype.bind = function (effect, aspectRatio) {
  64525. if (aspectRatio === void 0) { aspectRatio = 1; }
  64526. // Color Curves
  64527. if (this._colorCurvesEnabled && this.colorCurves) {
  64528. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].Bind(this.colorCurves, effect);
  64529. }
  64530. // Vignette
  64531. if (this._vignetteEnabled) {
  64532. var inverseWidth = 1 / effect.getEngine().getRenderWidth();
  64533. var inverseHeight = 1 / effect.getEngine().getRenderHeight();
  64534. effect.setFloat2("vInverseScreenSize", inverseWidth, inverseHeight);
  64535. var vignetteScaleY = Math.tan(this.vignetteCameraFov * 0.5);
  64536. var vignetteScaleX = vignetteScaleY * aspectRatio;
  64537. var vignetteScaleGeometricMean = Math.sqrt(vignetteScaleX * vignetteScaleY);
  64538. vignetteScaleX = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleX, vignetteScaleGeometricMean, this.vignetteStretch);
  64539. vignetteScaleY = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleY, vignetteScaleGeometricMean, this.vignetteStretch);
  64540. effect.setFloat4("vignetteSettings1", vignetteScaleX, vignetteScaleY, -vignetteScaleX * this.vignetteCentreX, -vignetteScaleY * this.vignetteCentreY);
  64541. var vignettePower = -2.0 * this.vignetteWeight;
  64542. effect.setFloat4("vignetteSettings2", this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, vignettePower);
  64543. }
  64544. // Exposure
  64545. effect.setFloat("exposureLinear", this.exposure);
  64546. // Contrast
  64547. effect.setFloat("contrast", this.contrast);
  64548. // Color transform settings
  64549. if (this.colorGradingTexture) {
  64550. effect.setTexture("txColorTransform", this.colorGradingTexture);
  64551. var textureSize = this.colorGradingTexture.getSize().height;
  64552. effect.setFloat4("colorTransformSettings", (textureSize - 1) / textureSize, // textureScale
  64553. 0.5 / textureSize, // textureOffset
  64554. textureSize, // textureSize
  64555. this.colorGradingTexture.level // weight
  64556. );
  64557. }
  64558. };
  64559. /**
  64560. * Clones the current image processing instance.
  64561. * @return The cloned image processing
  64562. */
  64563. ImageProcessingConfiguration.prototype.clone = function () {
  64564. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ImageProcessingConfiguration(); }, this);
  64565. };
  64566. /**
  64567. * Serializes the current image processing instance to a json representation.
  64568. * @return a JSON representation
  64569. */
  64570. ImageProcessingConfiguration.prototype.serialize = function () {
  64571. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  64572. };
  64573. /**
  64574. * Parses the image processing from a json representation.
  64575. * @param source the JSON source to parse
  64576. * @return The parsed image processing
  64577. */
  64578. ImageProcessingConfiguration.Parse = function (source) {
  64579. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ImageProcessingConfiguration(); }, source, null, null);
  64580. };
  64581. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_MULTIPLY", {
  64582. /**
  64583. * Used to apply the vignette as a mix with the pixel color.
  64584. */
  64585. get: function () {
  64586. return this._VIGNETTEMODE_MULTIPLY;
  64587. },
  64588. enumerable: true,
  64589. configurable: true
  64590. });
  64591. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_OPAQUE", {
  64592. /**
  64593. * Used to apply the vignette as a replacement of the pixel color.
  64594. */
  64595. get: function () {
  64596. return this._VIGNETTEMODE_OPAQUE;
  64597. },
  64598. enumerable: true,
  64599. configurable: true
  64600. });
  64601. /**
  64602. * Default tone mapping applied in BabylonJS.
  64603. */
  64604. ImageProcessingConfiguration.TONEMAPPING_STANDARD = 0;
  64605. /**
  64606. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  64607. * to other engines rendering to increase portability.
  64608. */
  64609. ImageProcessingConfiguration.TONEMAPPING_ACES = 1;
  64610. // Static constants associated to the image processing.
  64611. ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY = 0;
  64612. ImageProcessingConfiguration._VIGNETTEMODE_OPAQUE = 1;
  64613. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64614. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColorCurves"])()
  64615. ], ImageProcessingConfiguration.prototype, "colorCurves", void 0);
  64616. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64617. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64618. ], ImageProcessingConfiguration.prototype, "_colorCurvesEnabled", void 0);
  64619. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64620. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("colorGradingTexture")
  64621. ], ImageProcessingConfiguration.prototype, "_colorGradingTexture", void 0);
  64622. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64623. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64624. ], ImageProcessingConfiguration.prototype, "_colorGradingEnabled", void 0);
  64625. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64626. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64627. ], ImageProcessingConfiguration.prototype, "_colorGradingWithGreenDepth", void 0);
  64628. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64629. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64630. ], ImageProcessingConfiguration.prototype, "_colorGradingBGR", void 0);
  64631. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64632. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64633. ], ImageProcessingConfiguration.prototype, "_exposure", void 0);
  64634. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64635. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64636. ], ImageProcessingConfiguration.prototype, "_toneMappingEnabled", void 0);
  64637. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64638. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64639. ], ImageProcessingConfiguration.prototype, "_toneMappingType", void 0);
  64640. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64641. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64642. ], ImageProcessingConfiguration.prototype, "_contrast", void 0);
  64643. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64644. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64645. ], ImageProcessingConfiguration.prototype, "vignetteStretch", void 0);
  64646. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64647. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64648. ], ImageProcessingConfiguration.prototype, "vignetteCentreX", void 0);
  64649. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64650. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64651. ], ImageProcessingConfiguration.prototype, "vignetteCentreY", void 0);
  64652. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64653. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64654. ], ImageProcessingConfiguration.prototype, "vignetteWeight", void 0);
  64655. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64656. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  64657. ], ImageProcessingConfiguration.prototype, "vignetteColor", void 0);
  64658. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64659. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64660. ], ImageProcessingConfiguration.prototype, "vignetteCameraFov", void 0);
  64661. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64662. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64663. ], ImageProcessingConfiguration.prototype, "_vignetteBlendMode", void 0);
  64664. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64665. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64666. ], ImageProcessingConfiguration.prototype, "_vignetteEnabled", void 0);
  64667. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64668. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64669. ], ImageProcessingConfiguration.prototype, "_applyByPostProcess", void 0);
  64670. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64671. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64672. ], ImageProcessingConfiguration.prototype, "_isEnabled", void 0);
  64673. return ImageProcessingConfiguration;
  64674. }());
  64675. // References the dependencies.
  64676. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ImageProcessingConfigurationParser = ImageProcessingConfiguration.Parse;
  64677. /***/ }),
  64678. /***/ "./Materials/index.ts":
  64679. /*!****************************!*\
  64680. !*** ./Materials/index.ts ***!
  64681. \****************************/
  64682. /*! exports provided: ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, EquiRectangularCubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, BackgroundMaterial, PBRMaterialDefines, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  64683. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64684. "use strict";
  64685. __webpack_require__.r(__webpack_exports__);
  64686. /* harmony import */ var _Background_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Background/index */ "./Materials/Background/index.ts");
  64687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Background_index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  64688. /* harmony import */ var _colorCurves__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorCurves */ "./Materials/colorCurves.ts");
  64689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _colorCurves__WEBPACK_IMPORTED_MODULE_1__["ColorCurves"]; });
  64690. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  64691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectFallbacks"]; });
  64692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectCreationOptions"]; });
  64693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["Effect"]; });
  64694. /* harmony import */ var _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fresnelParameters */ "./Materials/fresnelParameters.ts");
  64695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__["FresnelParameters"]; });
  64696. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  64697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfigurationDefines"]; });
  64698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfiguration"]; });
  64699. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  64700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _material__WEBPACK_IMPORTED_MODULE_5__["Material"]; });
  64701. /* harmony import */ var _materialDefines__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./materialDefines */ "./Materials/materialDefines.ts");
  64702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _materialDefines__WEBPACK_IMPORTED_MODULE_6__["MaterialDefines"]; });
  64703. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  64704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"]; });
  64705. /* harmony import */ var _multiMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./multiMaterial */ "./Materials/multiMaterial.ts");
  64706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _multiMaterial__WEBPACK_IMPORTED_MODULE_8__["MultiMaterial"]; });
  64707. /* harmony import */ var _PBR_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./PBR/index */ "./Materials/PBR/index.ts");
  64708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMaterialDefines"]; });
  64709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseMaterial"]; });
  64710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseSimpleMaterial"]; });
  64711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMaterial"]; });
  64712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMetallicRoughnessMaterial"]; });
  64713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRSpecularGlossinessMaterial"]; });
  64714. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  64715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _pushMaterial__WEBPACK_IMPORTED_MODULE_10__["PushMaterial"]; });
  64716. /* harmony import */ var _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./shaderMaterial */ "./Materials/shaderMaterial.ts");
  64717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__["ShaderMaterial"]; });
  64718. /* harmony import */ var _standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./standardMaterial */ "./Materials/standardMaterial.ts");
  64719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterialDefines"]; });
  64720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]; });
  64721. /* harmony import */ var _Textures_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Textures/index */ "./Materials/Textures/index.ts");
  64722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["BaseTexture"]; });
  64723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CubeTexture"]; });
  64724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["EquiRectangularCubeTexture"]; });
  64725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["HDRCubeTexture"]; });
  64726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["InternalTexture"]; });
  64727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DummyInternalTextureTracker"]; });
  64728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MirrorTexture"]; });
  64729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MultiRenderTarget"]; });
  64730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture"]; });
  64731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RenderTargetTexture"]; });
  64732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["Texture"]; });
  64733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ColorGradingTexture"]; });
  64734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DynamicTexture"]; });
  64735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTexture"]; });
  64736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawCubeTexture"]; });
  64737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  64738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RefractionTexture"]; });
  64739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["VideoTexture"]; });
  64740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_DDSTextureLoader"]; });
  64741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_ENVTextureLoader"]; });
  64742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_KTXTextureLoader"]; });
  64743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_TGATextureLoader"]; });
  64744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CustomProceduralTexture"]; });
  64745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["NoiseProceduralTexture"]; });
  64746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTextureSceneComponent"]; });
  64747. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  64748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__["UniformBuffer"]; });
  64749. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  64750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _materialFlags__WEBPACK_IMPORTED_MODULE_15__["MaterialFlags"]; });
  64751. /***/ }),
  64752. /***/ "./Materials/material.ts":
  64753. /*!*******************************!*\
  64754. !*** ./Materials/material.ts ***!
  64755. \*******************************/
  64756. /*! exports provided: Material */
  64757. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64758. "use strict";
  64759. __webpack_require__.r(__webpack_exports__);
  64760. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return Material; });
  64761. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64762. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  64763. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  64764. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  64765. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  64766. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  64767. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  64768. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  64769. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  64770. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  64771. /**
  64772. * Base class for the main features of a material in Babylon.js
  64773. */
  64774. var Material = /** @class */ (function () {
  64775. /**
  64776. * Creates a material instance
  64777. * @param name defines the name of the material
  64778. * @param scene defines the scene to reference
  64779. * @param doNotAdd specifies if the material should be added to the scene
  64780. */
  64781. function Material(name, scene, doNotAdd) {
  64782. /**
  64783. * Gets or sets user defined metadata
  64784. */
  64785. this.metadata = null;
  64786. /**
  64787. * For internal use only. Please do not use.
  64788. */
  64789. this.reservedDataStore = null;
  64790. /**
  64791. * Specifies if the ready state should be checked on each call
  64792. */
  64793. this.checkReadyOnEveryCall = false;
  64794. /**
  64795. * Specifies if the ready state should be checked once
  64796. */
  64797. this.checkReadyOnlyOnce = false;
  64798. /**
  64799. * The state of the material
  64800. */
  64801. this.state = "";
  64802. /**
  64803. * The alpha value of the material
  64804. */
  64805. this._alpha = 1.0;
  64806. /**
  64807. * Specifies if back face culling is enabled
  64808. */
  64809. this._backFaceCulling = true;
  64810. /**
  64811. * Specifies if the material should be serialized
  64812. */
  64813. this.doNotSerialize = false;
  64814. /**
  64815. * @hidden
  64816. */
  64817. this._storeEffectOnSubMeshes = false;
  64818. /**
  64819. * An event triggered when the material is disposed
  64820. */
  64821. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  64822. /**
  64823. * Stores the value of the alpha mode
  64824. */
  64825. this._alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  64826. /**
  64827. * Stores the state of the need depth pre-pass value
  64828. */
  64829. this._needDepthPrePass = false;
  64830. /**
  64831. * Specifies if depth writing should be disabled
  64832. */
  64833. this.disableDepthWrite = false;
  64834. /**
  64835. * Specifies if depth writing should be forced
  64836. */
  64837. this.forceDepthWrite = false;
  64838. /**
  64839. * Specifies if there should be a separate pass for culling
  64840. */
  64841. this.separateCullingPass = false;
  64842. /**
  64843. * Stores the state specifing if fog should be enabled
  64844. */
  64845. this._fogEnabled = true;
  64846. /**
  64847. * Stores the size of points
  64848. */
  64849. this.pointSize = 1.0;
  64850. /**
  64851. * Stores the z offset value
  64852. */
  64853. this.zOffset = 0;
  64854. /**
  64855. * @hidden
  64856. * Specifies if the material was previously ready
  64857. */
  64858. this._wasPreviouslyReady = false;
  64859. /**
  64860. * Stores the fill mode state
  64861. */
  64862. this._fillMode = Material.TriangleFillMode;
  64863. /** @hidden */
  64864. this._indexInSceneMaterialArray = -1;
  64865. this.name = name;
  64866. this.id = name || _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RandomId();
  64867. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  64868. this.uniqueId = this._scene.getUniqueId();
  64869. if (this._scene.useRightHandedSystem) {
  64870. this.sideOrientation = Material.ClockWiseSideOrientation;
  64871. }
  64872. else {
  64873. this.sideOrientation = Material.CounterClockWiseSideOrientation;
  64874. }
  64875. this._uniformBuffer = new _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__["UniformBuffer"](this._scene.getEngine());
  64876. this._useUBO = this.getScene().getEngine().supportsUniformBuffers;
  64877. if (!doNotAdd) {
  64878. this._scene.addMaterial(this);
  64879. }
  64880. if (this._scene.useMaterialMeshMap) {
  64881. this.meshMap = {};
  64882. }
  64883. }
  64884. Object.defineProperty(Material.prototype, "alpha", {
  64885. /**
  64886. * Gets the alpha value of the material
  64887. */
  64888. get: function () {
  64889. return this._alpha;
  64890. },
  64891. /**
  64892. * Sets the alpha value of the material
  64893. */
  64894. set: function (value) {
  64895. if (this._alpha === value) {
  64896. return;
  64897. }
  64898. this._alpha = value;
  64899. this.markAsDirty(Material.MiscDirtyFlag);
  64900. },
  64901. enumerable: true,
  64902. configurable: true
  64903. });
  64904. Object.defineProperty(Material.prototype, "backFaceCulling", {
  64905. /**
  64906. * Gets the back-face culling state
  64907. */
  64908. get: function () {
  64909. return this._backFaceCulling;
  64910. },
  64911. /**
  64912. * Sets the back-face culling state
  64913. */
  64914. set: function (value) {
  64915. if (this._backFaceCulling === value) {
  64916. return;
  64917. }
  64918. this._backFaceCulling = value;
  64919. this.markAsDirty(Material.TextureDirtyFlag);
  64920. },
  64921. enumerable: true,
  64922. configurable: true
  64923. });
  64924. Object.defineProperty(Material.prototype, "hasRenderTargetTextures", {
  64925. /**
  64926. * Gets a boolean indicating that current material needs to register RTT
  64927. */
  64928. get: function () {
  64929. return false;
  64930. },
  64931. enumerable: true,
  64932. configurable: true
  64933. });
  64934. Object.defineProperty(Material.prototype, "onDispose", {
  64935. /**
  64936. * Called during a dispose event
  64937. */
  64938. set: function (callback) {
  64939. if (this._onDisposeObserver) {
  64940. this.onDisposeObservable.remove(this._onDisposeObserver);
  64941. }
  64942. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  64943. },
  64944. enumerable: true,
  64945. configurable: true
  64946. });
  64947. Object.defineProperty(Material.prototype, "onBindObservable", {
  64948. /**
  64949. * An event triggered when the material is bound
  64950. */
  64951. get: function () {
  64952. if (!this._onBindObservable) {
  64953. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  64954. }
  64955. return this._onBindObservable;
  64956. },
  64957. enumerable: true,
  64958. configurable: true
  64959. });
  64960. Object.defineProperty(Material.prototype, "onBind", {
  64961. /**
  64962. * Called during a bind event
  64963. */
  64964. set: function (callback) {
  64965. if (this._onBindObserver) {
  64966. this.onBindObservable.remove(this._onBindObserver);
  64967. }
  64968. this._onBindObserver = this.onBindObservable.add(callback);
  64969. },
  64970. enumerable: true,
  64971. configurable: true
  64972. });
  64973. Object.defineProperty(Material.prototype, "onUnBindObservable", {
  64974. /**
  64975. * An event triggered when the material is unbound
  64976. */
  64977. get: function () {
  64978. if (!this._onUnBindObservable) {
  64979. this._onUnBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  64980. }
  64981. return this._onUnBindObservable;
  64982. },
  64983. enumerable: true,
  64984. configurable: true
  64985. });
  64986. Object.defineProperty(Material.prototype, "alphaMode", {
  64987. /**
  64988. * Gets the value of the alpha mode
  64989. */
  64990. get: function () {
  64991. return this._alphaMode;
  64992. },
  64993. /**
  64994. * Sets the value of the alpha mode.
  64995. *
  64996. * | Value | Type | Description |
  64997. * | --- | --- | --- |
  64998. * | 0 | ALPHA_DISABLE | |
  64999. * | 1 | ALPHA_ADD | |
  65000. * | 2 | ALPHA_COMBINE | |
  65001. * | 3 | ALPHA_SUBTRACT | |
  65002. * | 4 | ALPHA_MULTIPLY | |
  65003. * | 5 | ALPHA_MAXIMIZED | |
  65004. * | 6 | ALPHA_ONEONE | |
  65005. * | 7 | ALPHA_PREMULTIPLIED | |
  65006. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  65007. * | 9 | ALPHA_INTERPOLATE | |
  65008. * | 10 | ALPHA_SCREENMODE | |
  65009. *
  65010. */
  65011. set: function (value) {
  65012. if (this._alphaMode === value) {
  65013. return;
  65014. }
  65015. this._alphaMode = value;
  65016. this.markAsDirty(Material.TextureDirtyFlag);
  65017. },
  65018. enumerable: true,
  65019. configurable: true
  65020. });
  65021. Object.defineProperty(Material.prototype, "needDepthPrePass", {
  65022. /**
  65023. * Gets the depth pre-pass value
  65024. */
  65025. get: function () {
  65026. return this._needDepthPrePass;
  65027. },
  65028. /**
  65029. * Sets the need depth pre-pass value
  65030. */
  65031. set: function (value) {
  65032. if (this._needDepthPrePass === value) {
  65033. return;
  65034. }
  65035. this._needDepthPrePass = value;
  65036. if (this._needDepthPrePass) {
  65037. this.checkReadyOnEveryCall = true;
  65038. }
  65039. },
  65040. enumerable: true,
  65041. configurable: true
  65042. });
  65043. Object.defineProperty(Material.prototype, "fogEnabled", {
  65044. /**
  65045. * Gets the value of the fog enabled state
  65046. */
  65047. get: function () {
  65048. return this._fogEnabled;
  65049. },
  65050. /**
  65051. * Sets the state for enabling fog
  65052. */
  65053. set: function (value) {
  65054. if (this._fogEnabled === value) {
  65055. return;
  65056. }
  65057. this._fogEnabled = value;
  65058. this.markAsDirty(Material.MiscDirtyFlag);
  65059. },
  65060. enumerable: true,
  65061. configurable: true
  65062. });
  65063. Object.defineProperty(Material.prototype, "wireframe", {
  65064. /**
  65065. * Gets a value specifying if wireframe mode is enabled
  65066. */
  65067. get: function () {
  65068. switch (this._fillMode) {
  65069. case Material.WireFrameFillMode:
  65070. case Material.LineListDrawMode:
  65071. case Material.LineLoopDrawMode:
  65072. case Material.LineStripDrawMode:
  65073. return true;
  65074. }
  65075. return this._scene.forceWireframe;
  65076. },
  65077. /**
  65078. * Sets the state of wireframe mode
  65079. */
  65080. set: function (value) {
  65081. this.fillMode = (value ? Material.WireFrameFillMode : Material.TriangleFillMode);
  65082. },
  65083. enumerable: true,
  65084. configurable: true
  65085. });
  65086. Object.defineProperty(Material.prototype, "pointsCloud", {
  65087. /**
  65088. * Gets the value specifying if point clouds are enabled
  65089. */
  65090. get: function () {
  65091. switch (this._fillMode) {
  65092. case Material.PointFillMode:
  65093. case Material.PointListDrawMode:
  65094. return true;
  65095. }
  65096. return this._scene.forcePointsCloud;
  65097. },
  65098. /**
  65099. * Sets the state of point cloud mode
  65100. */
  65101. set: function (value) {
  65102. this.fillMode = (value ? Material.PointFillMode : Material.TriangleFillMode);
  65103. },
  65104. enumerable: true,
  65105. configurable: true
  65106. });
  65107. Object.defineProperty(Material.prototype, "fillMode", {
  65108. /**
  65109. * Gets the material fill mode
  65110. */
  65111. get: function () {
  65112. return this._fillMode;
  65113. },
  65114. /**
  65115. * Sets the material fill mode
  65116. */
  65117. set: function (value) {
  65118. if (this._fillMode === value) {
  65119. return;
  65120. }
  65121. this._fillMode = value;
  65122. this.markAsDirty(Material.MiscDirtyFlag);
  65123. },
  65124. enumerable: true,
  65125. configurable: true
  65126. });
  65127. /**
  65128. * Returns a string representation of the current material
  65129. * @param fullDetails defines a boolean indicating which levels of logging is desired
  65130. * @returns a string with material information
  65131. */
  65132. Material.prototype.toString = function (fullDetails) {
  65133. var ret = "Name: " + this.name;
  65134. if (fullDetails) {
  65135. }
  65136. return ret;
  65137. };
  65138. /**
  65139. * Gets the class name of the material
  65140. * @returns a string with the class name of the material
  65141. */
  65142. Material.prototype.getClassName = function () {
  65143. return "Material";
  65144. };
  65145. Object.defineProperty(Material.prototype, "isFrozen", {
  65146. /**
  65147. * Specifies if updates for the material been locked
  65148. */
  65149. get: function () {
  65150. return this.checkReadyOnlyOnce;
  65151. },
  65152. enumerable: true,
  65153. configurable: true
  65154. });
  65155. /**
  65156. * Locks updates for the material
  65157. */
  65158. Material.prototype.freeze = function () {
  65159. this.checkReadyOnlyOnce = true;
  65160. };
  65161. /**
  65162. * Unlocks updates for the material
  65163. */
  65164. Material.prototype.unfreeze = function () {
  65165. this.checkReadyOnlyOnce = false;
  65166. };
  65167. /**
  65168. * Specifies if the material is ready to be used
  65169. * @param mesh defines the mesh to check
  65170. * @param useInstances specifies if instances should be used
  65171. * @returns a boolean indicating if the material is ready to be used
  65172. */
  65173. Material.prototype.isReady = function (mesh, useInstances) {
  65174. return true;
  65175. };
  65176. /**
  65177. * Specifies that the submesh is ready to be used
  65178. * @param mesh defines the mesh to check
  65179. * @param subMesh defines which submesh to check
  65180. * @param useInstances specifies that instances should be used
  65181. * @returns a boolean indicating that the submesh is ready or not
  65182. */
  65183. Material.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  65184. return false;
  65185. };
  65186. /**
  65187. * Returns the material effect
  65188. * @returns the effect associated with the material
  65189. */
  65190. Material.prototype.getEffect = function () {
  65191. return this._effect;
  65192. };
  65193. /**
  65194. * Returns the current scene
  65195. * @returns a Scene
  65196. */
  65197. Material.prototype.getScene = function () {
  65198. return this._scene;
  65199. };
  65200. /**
  65201. * Specifies if the material will require alpha blending
  65202. * @returns a boolean specifying if alpha blending is needed
  65203. */
  65204. Material.prototype.needAlphaBlending = function () {
  65205. return (this.alpha < 1.0);
  65206. };
  65207. /**
  65208. * Specifies if the mesh will require alpha blending
  65209. * @param mesh defines the mesh to check
  65210. * @returns a boolean specifying if alpha blending is needed for the mesh
  65211. */
  65212. Material.prototype.needAlphaBlendingForMesh = function (mesh) {
  65213. return this.needAlphaBlending() || (mesh.visibility < 1.0) || mesh.hasVertexAlpha;
  65214. };
  65215. /**
  65216. * Specifies if this material should be rendered in alpha test mode
  65217. * @returns a boolean specifying if an alpha test is needed.
  65218. */
  65219. Material.prototype.needAlphaTesting = function () {
  65220. return false;
  65221. };
  65222. /**
  65223. * Gets the texture used for the alpha test
  65224. * @returns the texture to use for alpha testing
  65225. */
  65226. Material.prototype.getAlphaTestTexture = function () {
  65227. return null;
  65228. };
  65229. /**
  65230. * Marks the material to indicate that it needs to be re-calculated
  65231. */
  65232. Material.prototype.markDirty = function () {
  65233. this._wasPreviouslyReady = false;
  65234. };
  65235. /** @hidden */
  65236. Material.prototype._preBind = function (effect, overrideOrientation) {
  65237. if (overrideOrientation === void 0) { overrideOrientation = null; }
  65238. var engine = this._scene.getEngine();
  65239. var orientation = (overrideOrientation == null) ? this.sideOrientation : overrideOrientation;
  65240. var reverse = orientation === Material.ClockWiseSideOrientation;
  65241. engine.enableEffect(effect ? effect : this._effect);
  65242. engine.setState(this.backFaceCulling, this.zOffset, false, reverse);
  65243. return reverse;
  65244. };
  65245. /**
  65246. * Binds the material to the mesh
  65247. * @param world defines the world transformation matrix
  65248. * @param mesh defines the mesh to bind the material to
  65249. */
  65250. Material.prototype.bind = function (world, mesh) {
  65251. };
  65252. /**
  65253. * Binds the submesh to the material
  65254. * @param world defines the world transformation matrix
  65255. * @param mesh defines the mesh containing the submesh
  65256. * @param subMesh defines the submesh to bind the material to
  65257. */
  65258. Material.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  65259. };
  65260. /**
  65261. * Binds the world matrix to the material
  65262. * @param world defines the world transformation matrix
  65263. */
  65264. Material.prototype.bindOnlyWorldMatrix = function (world) {
  65265. };
  65266. /**
  65267. * Binds the scene's uniform buffer to the effect.
  65268. * @param effect defines the effect to bind to the scene uniform buffer
  65269. * @param sceneUbo defines the uniform buffer storing scene data
  65270. */
  65271. Material.prototype.bindSceneUniformBuffer = function (effect, sceneUbo) {
  65272. sceneUbo.bindToEffect(effect, "Scene");
  65273. };
  65274. /**
  65275. * Binds the view matrix to the effect
  65276. * @param effect defines the effect to bind the view matrix to
  65277. */
  65278. Material.prototype.bindView = function (effect) {
  65279. if (!this._useUBO) {
  65280. effect.setMatrix("view", this.getScene().getViewMatrix());
  65281. }
  65282. else {
  65283. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  65284. }
  65285. };
  65286. /**
  65287. * Binds the view projection matrix to the effect
  65288. * @param effect defines the effect to bind the view projection matrix to
  65289. */
  65290. Material.prototype.bindViewProjection = function (effect) {
  65291. if (!this._useUBO) {
  65292. effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  65293. }
  65294. else {
  65295. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  65296. }
  65297. };
  65298. /**
  65299. * Specifies if material alpha testing should be turned on for the mesh
  65300. * @param mesh defines the mesh to check
  65301. */
  65302. Material.prototype._shouldTurnAlphaTestOn = function (mesh) {
  65303. return (!this.needAlphaBlendingForMesh(mesh) && this.needAlphaTesting());
  65304. };
  65305. /**
  65306. * Processes to execute after binding the material to a mesh
  65307. * @param mesh defines the rendered mesh
  65308. */
  65309. Material.prototype._afterBind = function (mesh) {
  65310. this._scene._cachedMaterial = this;
  65311. if (mesh) {
  65312. this._scene._cachedVisibility = mesh.visibility;
  65313. }
  65314. else {
  65315. this._scene._cachedVisibility = 1;
  65316. }
  65317. if (this._onBindObservable && mesh) {
  65318. this._onBindObservable.notifyObservers(mesh);
  65319. }
  65320. if (this.disableDepthWrite) {
  65321. var engine = this._scene.getEngine();
  65322. this._cachedDepthWriteState = engine.getDepthWrite();
  65323. engine.setDepthWrite(false);
  65324. }
  65325. };
  65326. /**
  65327. * Unbinds the material from the mesh
  65328. */
  65329. Material.prototype.unbind = function () {
  65330. if (this._onUnBindObservable) {
  65331. this._onUnBindObservable.notifyObservers(this);
  65332. }
  65333. if (this.disableDepthWrite) {
  65334. var engine = this._scene.getEngine();
  65335. engine.setDepthWrite(this._cachedDepthWriteState);
  65336. }
  65337. };
  65338. /**
  65339. * Gets the active textures from the material
  65340. * @returns an array of textures
  65341. */
  65342. Material.prototype.getActiveTextures = function () {
  65343. return [];
  65344. };
  65345. /**
  65346. * Specifies if the material uses a texture
  65347. * @param texture defines the texture to check against the material
  65348. * @returns a boolean specifying if the material uses the texture
  65349. */
  65350. Material.prototype.hasTexture = function (texture) {
  65351. return false;
  65352. };
  65353. /**
  65354. * Makes a duplicate of the material, and gives it a new name
  65355. * @param name defines the new name for the duplicated material
  65356. * @returns the cloned material
  65357. */
  65358. Material.prototype.clone = function (name) {
  65359. return null;
  65360. };
  65361. /**
  65362. * Gets the meshes bound to the material
  65363. * @returns an array of meshes bound to the material
  65364. */
  65365. Material.prototype.getBindedMeshes = function () {
  65366. var _this = this;
  65367. if (this.meshMap) {
  65368. var result = new Array();
  65369. for (var meshId in this.meshMap) {
  65370. var mesh = this.meshMap[meshId];
  65371. if (mesh) {
  65372. result.push(mesh);
  65373. }
  65374. }
  65375. return result;
  65376. }
  65377. else {
  65378. var meshes = this._scene.meshes;
  65379. return meshes.filter(function (mesh) { return mesh.material === _this; });
  65380. }
  65381. };
  65382. /**
  65383. * Force shader compilation
  65384. * @param mesh defines the mesh associated with this material
  65385. * @param onCompiled defines a function to execute once the material is compiled
  65386. * @param options defines the options to configure the compilation
  65387. */
  65388. Material.prototype.forceCompilation = function (mesh, onCompiled, options) {
  65389. var _this = this;
  65390. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  65391. var subMesh = new _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__["BaseSubMesh"]();
  65392. var scene = this.getScene();
  65393. var checkReady = function () {
  65394. if (!_this._scene || !_this._scene.getEngine()) {
  65395. return;
  65396. }
  65397. if (subMesh._materialDefines) {
  65398. subMesh._materialDefines._renderId = -1;
  65399. }
  65400. var clipPlaneState = scene.clipPlane;
  65401. if (localOptions.clipPlane) {
  65402. scene.clipPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"](0, 0, 0, 1);
  65403. }
  65404. if (_this._storeEffectOnSubMeshes) {
  65405. if (_this.isReadyForSubMesh(mesh, subMesh)) {
  65406. if (onCompiled) {
  65407. onCompiled(_this);
  65408. }
  65409. }
  65410. else {
  65411. setTimeout(checkReady, 16);
  65412. }
  65413. }
  65414. else {
  65415. if (_this.isReady()) {
  65416. if (onCompiled) {
  65417. onCompiled(_this);
  65418. }
  65419. }
  65420. else {
  65421. setTimeout(checkReady, 16);
  65422. }
  65423. }
  65424. if (localOptions.clipPlane) {
  65425. scene.clipPlane = clipPlaneState;
  65426. }
  65427. };
  65428. checkReady();
  65429. };
  65430. /**
  65431. * Force shader compilation
  65432. * @param mesh defines the mesh that will use this material
  65433. * @param options defines additional options for compiling the shaders
  65434. * @returns a promise that resolves when the compilation completes
  65435. */
  65436. Material.prototype.forceCompilationAsync = function (mesh, options) {
  65437. var _this = this;
  65438. return new Promise(function (resolve) {
  65439. _this.forceCompilation(mesh, function () {
  65440. resolve();
  65441. }, options);
  65442. });
  65443. };
  65444. /**
  65445. * Marks a define in the material to indicate that it needs to be re-computed
  65446. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  65447. */
  65448. Material.prototype.markAsDirty = function (flag) {
  65449. if (this.getScene().blockMaterialDirtyMechanism) {
  65450. return;
  65451. }
  65452. Material._DirtyCallbackArray.length = 0;
  65453. if (flag & Material.TextureDirtyFlag) {
  65454. Material._DirtyCallbackArray.push(Material._TextureDirtyCallBack);
  65455. }
  65456. if (flag & Material.LightDirtyFlag) {
  65457. Material._DirtyCallbackArray.push(Material._LightsDirtyCallBack);
  65458. }
  65459. if (flag & Material.FresnelDirtyFlag) {
  65460. Material._DirtyCallbackArray.push(Material._FresnelDirtyCallBack);
  65461. }
  65462. if (flag & Material.AttributesDirtyFlag) {
  65463. Material._DirtyCallbackArray.push(Material._AttributeDirtyCallBack);
  65464. }
  65465. if (flag & Material.MiscDirtyFlag) {
  65466. Material._DirtyCallbackArray.push(Material._MiscDirtyCallBack);
  65467. }
  65468. if (Material._DirtyCallbackArray.length) {
  65469. this._markAllSubMeshesAsDirty(Material._RunDirtyCallBacks);
  65470. }
  65471. this.getScene().resetCachedMaterial();
  65472. };
  65473. /**
  65474. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  65475. * @param func defines a function which checks material defines against the submeshes
  65476. */
  65477. Material.prototype._markAllSubMeshesAsDirty = function (func) {
  65478. if (this.getScene().blockMaterialDirtyMechanism) {
  65479. return;
  65480. }
  65481. var meshes = this.getScene().meshes;
  65482. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  65483. var mesh = meshes_1[_i];
  65484. if (!mesh.subMeshes) {
  65485. continue;
  65486. }
  65487. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  65488. var subMesh = _b[_a];
  65489. if (subMesh.getMaterial() !== this) {
  65490. continue;
  65491. }
  65492. if (!subMesh._materialDefines) {
  65493. continue;
  65494. }
  65495. func(subMesh._materialDefines);
  65496. }
  65497. }
  65498. };
  65499. /**
  65500. * Indicates that image processing needs to be re-calculated for all submeshes
  65501. */
  65502. Material.prototype._markAllSubMeshesAsImageProcessingDirty = function () {
  65503. this._markAllSubMeshesAsDirty(Material._ImageProcessingDirtyCallBack);
  65504. };
  65505. /**
  65506. * Indicates that textures need to be re-calculated for all submeshes
  65507. */
  65508. Material.prototype._markAllSubMeshesAsTexturesDirty = function () {
  65509. this._markAllSubMeshesAsDirty(Material._TextureDirtyCallBack);
  65510. };
  65511. /**
  65512. * Indicates that fresnel needs to be re-calculated for all submeshes
  65513. */
  65514. Material.prototype._markAllSubMeshesAsFresnelDirty = function () {
  65515. this._markAllSubMeshesAsDirty(Material._FresnelDirtyCallBack);
  65516. };
  65517. /**
  65518. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  65519. */
  65520. Material.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function () {
  65521. this._markAllSubMeshesAsDirty(Material._FresnelAndMiscDirtyCallBack);
  65522. };
  65523. /**
  65524. * Indicates that lights need to be re-calculated for all submeshes
  65525. */
  65526. Material.prototype._markAllSubMeshesAsLightsDirty = function () {
  65527. this._markAllSubMeshesAsDirty(Material._LightsDirtyCallBack);
  65528. };
  65529. /**
  65530. * Indicates that attributes need to be re-calculated for all submeshes
  65531. */
  65532. Material.prototype._markAllSubMeshesAsAttributesDirty = function () {
  65533. this._markAllSubMeshesAsDirty(Material._AttributeDirtyCallBack);
  65534. };
  65535. /**
  65536. * Indicates that misc needs to be re-calculated for all submeshes
  65537. */
  65538. Material.prototype._markAllSubMeshesAsMiscDirty = function () {
  65539. this._markAllSubMeshesAsDirty(Material._MiscDirtyCallBack);
  65540. };
  65541. /**
  65542. * Indicates that textures and misc need to be re-calculated for all submeshes
  65543. */
  65544. Material.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function () {
  65545. this._markAllSubMeshesAsDirty(Material._TextureAndMiscDirtyCallBack);
  65546. };
  65547. /**
  65548. * Disposes the material
  65549. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  65550. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  65551. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  65552. */
  65553. Material.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  65554. var scene = this.getScene();
  65555. // Animations
  65556. scene.stopAnimation(this);
  65557. scene.freeProcessedMaterials();
  65558. // Remove from scene
  65559. scene.removeMaterial(this);
  65560. if (notBoundToMesh !== true) {
  65561. // Remove from meshes
  65562. if (this.meshMap) {
  65563. for (var meshId in this.meshMap) {
  65564. var mesh = this.meshMap[meshId];
  65565. if (mesh) {
  65566. mesh.material = null; // will set the entry in the map to undefined
  65567. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  65568. }
  65569. }
  65570. }
  65571. else {
  65572. var meshes = scene.meshes;
  65573. for (var _i = 0, meshes_2 = meshes; _i < meshes_2.length; _i++) {
  65574. var mesh = meshes_2[_i];
  65575. if (mesh.material === this) {
  65576. mesh.material = null;
  65577. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  65578. }
  65579. }
  65580. }
  65581. }
  65582. this._uniformBuffer.dispose();
  65583. // Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
  65584. if (forceDisposeEffect && this._effect) {
  65585. if (!this._storeEffectOnSubMeshes) {
  65586. scene.getEngine()._releaseEffect(this._effect);
  65587. }
  65588. this._effect = null;
  65589. }
  65590. // Callback
  65591. this.onDisposeObservable.notifyObservers(this);
  65592. this.onDisposeObservable.clear();
  65593. if (this._onBindObservable) {
  65594. this._onBindObservable.clear();
  65595. }
  65596. if (this._onUnBindObservable) {
  65597. this._onUnBindObservable.clear();
  65598. }
  65599. };
  65600. /** @hidden */
  65601. Material.prototype.releaseVertexArrayObject = function (mesh, forceDisposeEffect) {
  65602. if (mesh.geometry) {
  65603. var geometry = (mesh.geometry);
  65604. var scene = this.getScene();
  65605. if (this._storeEffectOnSubMeshes) {
  65606. for (var _i = 0, _a = mesh.subMeshes; _i < _a.length; _i++) {
  65607. var subMesh = _a[_i];
  65608. geometry._releaseVertexArrayObject(subMesh._materialEffect);
  65609. if (forceDisposeEffect && subMesh._materialEffect) {
  65610. scene.getEngine()._releaseEffect(subMesh._materialEffect);
  65611. }
  65612. }
  65613. }
  65614. else {
  65615. geometry._releaseVertexArrayObject(this._effect);
  65616. }
  65617. }
  65618. };
  65619. /**
  65620. * Serializes this material
  65621. * @returns the serialized material object
  65622. */
  65623. Material.prototype.serialize = function () {
  65624. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  65625. };
  65626. /**
  65627. * Creates a material from parsed material data
  65628. * @param parsedMaterial defines parsed material data
  65629. * @param scene defines the hosting scene
  65630. * @param rootUrl defines the root URL to use to load textures
  65631. * @returns a new material
  65632. */
  65633. Material.Parse = function (parsedMaterial, scene, rootUrl) {
  65634. if (!parsedMaterial.customType) {
  65635. parsedMaterial.customType = "BABYLON.StandardMaterial";
  65636. }
  65637. else if (parsedMaterial.customType === "BABYLON.PBRMaterial" && parsedMaterial.overloadedAlbedo) {
  65638. parsedMaterial.customType = "BABYLON.LegacyPBRMaterial";
  65639. if (!BABYLON.LegacyPBRMaterial) {
  65640. _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.");
  65641. return;
  65642. }
  65643. }
  65644. var materialType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedMaterial.customType);
  65645. return materialType.Parse(parsedMaterial, scene, rootUrl);
  65646. };
  65647. /**
  65648. * Returns the triangle fill mode
  65649. */
  65650. Material.TriangleFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFillMode;
  65651. /**
  65652. * Returns the wireframe mode
  65653. */
  65654. Material.WireFrameFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_WireFrameFillMode;
  65655. /**
  65656. * Returns the point fill mode
  65657. */
  65658. Material.PointFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointFillMode;
  65659. /**
  65660. * Returns the point list draw mode
  65661. */
  65662. Material.PointListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointListDrawMode;
  65663. /**
  65664. * Returns the line list draw mode
  65665. */
  65666. Material.LineListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineListDrawMode;
  65667. /**
  65668. * Returns the line loop draw mode
  65669. */
  65670. Material.LineLoopDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineLoopDrawMode;
  65671. /**
  65672. * Returns the line strip draw mode
  65673. */
  65674. Material.LineStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineStripDrawMode;
  65675. /**
  65676. * Returns the triangle strip draw mode
  65677. */
  65678. Material.TriangleStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleStripDrawMode;
  65679. /**
  65680. * Returns the triangle fan draw mode
  65681. */
  65682. Material.TriangleFanDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFanDrawMode;
  65683. /**
  65684. * Stores the clock-wise side orientation
  65685. */
  65686. Material.ClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_ClockWiseSideOrientation;
  65687. /**
  65688. * Stores the counter clock-wise side orientation
  65689. */
  65690. Material.CounterClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_CounterClockWiseSideOrientation;
  65691. /**
  65692. * The dirty texture flag value
  65693. */
  65694. Material.TextureDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TextureDirtyFlag;
  65695. /**
  65696. * The dirty light flag value
  65697. */
  65698. Material.LightDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LightDirtyFlag;
  65699. /**
  65700. * The dirty fresnel flag value
  65701. */
  65702. Material.FresnelDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_FresnelDirtyFlag;
  65703. /**
  65704. * The dirty attribute flag value
  65705. */
  65706. Material.AttributesDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AttributesDirtyFlag;
  65707. /**
  65708. * The dirty misc flag value
  65709. */
  65710. Material.MiscDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_MiscDirtyFlag;
  65711. /**
  65712. * The all dirty flag value
  65713. */
  65714. Material.AllDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AllDirtyFlag;
  65715. Material._ImageProcessingDirtyCallBack = function (defines) { return defines.markAsImageProcessingDirty(); };
  65716. Material._TextureDirtyCallBack = function (defines) { return defines.markAsTexturesDirty(); };
  65717. Material._FresnelDirtyCallBack = function (defines) { return defines.markAsFresnelDirty(); };
  65718. Material._MiscDirtyCallBack = function (defines) { return defines.markAsMiscDirty(); };
  65719. Material._LightsDirtyCallBack = function (defines) { return defines.markAsLightDirty(); };
  65720. Material._AttributeDirtyCallBack = function (defines) { return defines.markAsAttributesDirty(); };
  65721. Material._FresnelAndMiscDirtyCallBack = function (defines) {
  65722. Material._FresnelDirtyCallBack(defines);
  65723. Material._MiscDirtyCallBack(defines);
  65724. };
  65725. Material._TextureAndMiscDirtyCallBack = function (defines) {
  65726. Material._TextureDirtyCallBack(defines);
  65727. Material._MiscDirtyCallBack(defines);
  65728. };
  65729. Material._DirtyCallbackArray = [];
  65730. Material._RunDirtyCallBacks = function (defines) {
  65731. for (var _i = 0, _a = Material._DirtyCallbackArray; _i < _a.length; _i++) {
  65732. var cb = _a[_i];
  65733. cb(defines);
  65734. }
  65735. };
  65736. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65737. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65738. ], Material.prototype, "id", void 0);
  65739. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65740. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65741. ], Material.prototype, "uniqueId", void 0);
  65742. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65743. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65744. ], Material.prototype, "name", void 0);
  65745. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65746. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65747. ], Material.prototype, "checkReadyOnEveryCall", void 0);
  65748. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65749. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65750. ], Material.prototype, "checkReadyOnlyOnce", void 0);
  65751. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65752. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65753. ], Material.prototype, "state", void 0);
  65754. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65755. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alpha")
  65756. ], Material.prototype, "_alpha", void 0);
  65757. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65758. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("backFaceCulling")
  65759. ], Material.prototype, "_backFaceCulling", void 0);
  65760. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65761. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65762. ], Material.prototype, "sideOrientation", void 0);
  65763. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65764. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alphaMode")
  65765. ], Material.prototype, "_alphaMode", void 0);
  65766. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65767. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65768. ], Material.prototype, "_needDepthPrePass", void 0);
  65769. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65770. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65771. ], Material.prototype, "disableDepthWrite", void 0);
  65772. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65773. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65774. ], Material.prototype, "forceDepthWrite", void 0);
  65775. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65776. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65777. ], Material.prototype, "separateCullingPass", void 0);
  65778. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65779. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("fogEnabled")
  65780. ], Material.prototype, "_fogEnabled", void 0);
  65781. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65782. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65783. ], Material.prototype, "pointSize", void 0);
  65784. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65785. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65786. ], Material.prototype, "zOffset", void 0);
  65787. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65788. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65789. ], Material.prototype, "wireframe", null);
  65790. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65791. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65792. ], Material.prototype, "pointsCloud", null);
  65793. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65794. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65795. ], Material.prototype, "fillMode", null);
  65796. return Material;
  65797. }());
  65798. /***/ }),
  65799. /***/ "./Materials/materialDefines.ts":
  65800. /*!**************************************!*\
  65801. !*** ./Materials/materialDefines.ts ***!
  65802. \**************************************/
  65803. /*! exports provided: MaterialDefines */
  65804. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65805. "use strict";
  65806. __webpack_require__.r(__webpack_exports__);
  65807. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return MaterialDefines; });
  65808. /**
  65809. * Manages the defines for the Material
  65810. */
  65811. var MaterialDefines = /** @class */ (function () {
  65812. function MaterialDefines() {
  65813. this._isDirty = true;
  65814. /** @hidden */
  65815. this._areLightsDirty = true;
  65816. /** @hidden */
  65817. this._areAttributesDirty = true;
  65818. /** @hidden */
  65819. this._areTexturesDirty = true;
  65820. /** @hidden */
  65821. this._areFresnelDirty = true;
  65822. /** @hidden */
  65823. this._areMiscDirty = true;
  65824. /** @hidden */
  65825. this._areImageProcessingDirty = true;
  65826. /** @hidden */
  65827. this._normals = false;
  65828. /** @hidden */
  65829. this._uvs = false;
  65830. /** @hidden */
  65831. this._needNormals = false;
  65832. /** @hidden */
  65833. this._needUVs = false;
  65834. }
  65835. Object.defineProperty(MaterialDefines.prototype, "isDirty", {
  65836. /**
  65837. * Specifies if the material needs to be re-calculated
  65838. */
  65839. get: function () {
  65840. return this._isDirty;
  65841. },
  65842. enumerable: true,
  65843. configurable: true
  65844. });
  65845. /**
  65846. * Marks the material to indicate that it has been re-calculated
  65847. */
  65848. MaterialDefines.prototype.markAsProcessed = function () {
  65849. this._isDirty = false;
  65850. this._areAttributesDirty = false;
  65851. this._areTexturesDirty = false;
  65852. this._areFresnelDirty = false;
  65853. this._areLightsDirty = false;
  65854. this._areMiscDirty = false;
  65855. this._areImageProcessingDirty = false;
  65856. };
  65857. /**
  65858. * Marks the material to indicate that it needs to be re-calculated
  65859. */
  65860. MaterialDefines.prototype.markAsUnprocessed = function () {
  65861. this._isDirty = true;
  65862. };
  65863. /**
  65864. * Marks the material to indicate all of its defines need to be re-calculated
  65865. */
  65866. MaterialDefines.prototype.markAllAsDirty = function () {
  65867. this._areTexturesDirty = true;
  65868. this._areAttributesDirty = true;
  65869. this._areLightsDirty = true;
  65870. this._areFresnelDirty = true;
  65871. this._areMiscDirty = true;
  65872. this._areImageProcessingDirty = true;
  65873. this._isDirty = true;
  65874. };
  65875. /**
  65876. * Marks the material to indicate that image processing needs to be re-calculated
  65877. */
  65878. MaterialDefines.prototype.markAsImageProcessingDirty = function () {
  65879. this._areImageProcessingDirty = true;
  65880. this._isDirty = true;
  65881. };
  65882. /**
  65883. * Marks the material to indicate the lights need to be re-calculated
  65884. */
  65885. MaterialDefines.prototype.markAsLightDirty = function () {
  65886. this._areLightsDirty = true;
  65887. this._isDirty = true;
  65888. };
  65889. /**
  65890. * Marks the attribute state as changed
  65891. */
  65892. MaterialDefines.prototype.markAsAttributesDirty = function () {
  65893. this._areAttributesDirty = true;
  65894. this._isDirty = true;
  65895. };
  65896. /**
  65897. * Marks the texture state as changed
  65898. */
  65899. MaterialDefines.prototype.markAsTexturesDirty = function () {
  65900. this._areTexturesDirty = true;
  65901. this._isDirty = true;
  65902. };
  65903. /**
  65904. * Marks the fresnel state as changed
  65905. */
  65906. MaterialDefines.prototype.markAsFresnelDirty = function () {
  65907. this._areFresnelDirty = true;
  65908. this._isDirty = true;
  65909. };
  65910. /**
  65911. * Marks the misc state as changed
  65912. */
  65913. MaterialDefines.prototype.markAsMiscDirty = function () {
  65914. this._areMiscDirty = true;
  65915. this._isDirty = true;
  65916. };
  65917. /**
  65918. * Rebuilds the material defines
  65919. */
  65920. MaterialDefines.prototype.rebuild = function () {
  65921. if (this._keys) {
  65922. delete this._keys;
  65923. }
  65924. this._keys = [];
  65925. for (var _i = 0, _a = Object.keys(this); _i < _a.length; _i++) {
  65926. var key = _a[_i];
  65927. if (key[0] === "_") {
  65928. continue;
  65929. }
  65930. this._keys.push(key);
  65931. }
  65932. };
  65933. /**
  65934. * Specifies if two material defines are equal
  65935. * @param other - A material define instance to compare to
  65936. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  65937. */
  65938. MaterialDefines.prototype.isEqual = function (other) {
  65939. if (this._keys.length !== other._keys.length) {
  65940. return false;
  65941. }
  65942. for (var index = 0; index < this._keys.length; index++) {
  65943. var prop = this._keys[index];
  65944. if (this[prop] !== other[prop]) {
  65945. return false;
  65946. }
  65947. }
  65948. return true;
  65949. };
  65950. /**
  65951. * Clones this instance's defines to another instance
  65952. * @param other - material defines to clone values to
  65953. */
  65954. MaterialDefines.prototype.cloneTo = function (other) {
  65955. if (this._keys.length !== other._keys.length) {
  65956. other._keys = this._keys.slice(0);
  65957. }
  65958. for (var index = 0; index < this._keys.length; index++) {
  65959. var prop = this._keys[index];
  65960. other[prop] = this[prop];
  65961. }
  65962. };
  65963. /**
  65964. * Resets the material define values
  65965. */
  65966. MaterialDefines.prototype.reset = function () {
  65967. for (var index = 0; index < this._keys.length; index++) {
  65968. var prop = this._keys[index];
  65969. var type = typeof this[prop];
  65970. switch (type) {
  65971. case "number":
  65972. this[prop] = 0;
  65973. break;
  65974. case "string":
  65975. this[prop] = "";
  65976. break;
  65977. default:
  65978. this[prop] = false;
  65979. break;
  65980. }
  65981. }
  65982. };
  65983. /**
  65984. * Converts the material define values to a string
  65985. * @returns - String of material define information
  65986. */
  65987. MaterialDefines.prototype.toString = function () {
  65988. var result = "";
  65989. for (var index = 0; index < this._keys.length; index++) {
  65990. var prop = this._keys[index];
  65991. var value = this[prop];
  65992. var type = typeof value;
  65993. switch (type) {
  65994. case "number":
  65995. case "string":
  65996. result += "#define " + prop + " " + value + "\n";
  65997. break;
  65998. default:
  65999. if (value) {
  66000. result += "#define " + prop + "\n";
  66001. }
  66002. break;
  66003. }
  66004. }
  66005. return result;
  66006. };
  66007. return MaterialDefines;
  66008. }());
  66009. /***/ }),
  66010. /***/ "./Materials/materialFlags.ts":
  66011. /*!************************************!*\
  66012. !*** ./Materials/materialFlags.ts ***!
  66013. \************************************/
  66014. /*! exports provided: MaterialFlags */
  66015. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66016. "use strict";
  66017. __webpack_require__.r(__webpack_exports__);
  66018. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return MaterialFlags; });
  66019. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  66020. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  66021. /**
  66022. * This groups all the flags used to control the materials channel.
  66023. */
  66024. var MaterialFlags = /** @class */ (function () {
  66025. function MaterialFlags() {
  66026. }
  66027. Object.defineProperty(MaterialFlags, "DiffuseTextureEnabled", {
  66028. /**
  66029. * Are diffuse textures enabled in the application.
  66030. */
  66031. get: function () {
  66032. return this._DiffuseTextureEnabled;
  66033. },
  66034. set: function (value) {
  66035. if (this._DiffuseTextureEnabled === value) {
  66036. return;
  66037. }
  66038. this._DiffuseTextureEnabled = value;
  66039. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66040. },
  66041. enumerable: true,
  66042. configurable: true
  66043. });
  66044. Object.defineProperty(MaterialFlags, "AmbientTextureEnabled", {
  66045. /**
  66046. * Are ambient textures enabled in the application.
  66047. */
  66048. get: function () {
  66049. return this._AmbientTextureEnabled;
  66050. },
  66051. set: function (value) {
  66052. if (this._AmbientTextureEnabled === value) {
  66053. return;
  66054. }
  66055. this._AmbientTextureEnabled = value;
  66056. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66057. },
  66058. enumerable: true,
  66059. configurable: true
  66060. });
  66061. Object.defineProperty(MaterialFlags, "OpacityTextureEnabled", {
  66062. /**
  66063. * Are opacity textures enabled in the application.
  66064. */
  66065. get: function () {
  66066. return this._OpacityTextureEnabled;
  66067. },
  66068. set: function (value) {
  66069. if (this._OpacityTextureEnabled === value) {
  66070. return;
  66071. }
  66072. this._OpacityTextureEnabled = value;
  66073. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66074. },
  66075. enumerable: true,
  66076. configurable: true
  66077. });
  66078. Object.defineProperty(MaterialFlags, "ReflectionTextureEnabled", {
  66079. /**
  66080. * Are reflection textures enabled in the application.
  66081. */
  66082. get: function () {
  66083. return this._ReflectionTextureEnabled;
  66084. },
  66085. set: function (value) {
  66086. if (this._ReflectionTextureEnabled === value) {
  66087. return;
  66088. }
  66089. this._ReflectionTextureEnabled = value;
  66090. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66091. },
  66092. enumerable: true,
  66093. configurable: true
  66094. });
  66095. Object.defineProperty(MaterialFlags, "EmissiveTextureEnabled", {
  66096. /**
  66097. * Are emissive textures enabled in the application.
  66098. */
  66099. get: function () {
  66100. return this._EmissiveTextureEnabled;
  66101. },
  66102. set: function (value) {
  66103. if (this._EmissiveTextureEnabled === value) {
  66104. return;
  66105. }
  66106. this._EmissiveTextureEnabled = value;
  66107. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66108. },
  66109. enumerable: true,
  66110. configurable: true
  66111. });
  66112. Object.defineProperty(MaterialFlags, "SpecularTextureEnabled", {
  66113. /**
  66114. * Are specular textures enabled in the application.
  66115. */
  66116. get: function () {
  66117. return this._SpecularTextureEnabled;
  66118. },
  66119. set: function (value) {
  66120. if (this._SpecularTextureEnabled === value) {
  66121. return;
  66122. }
  66123. this._SpecularTextureEnabled = value;
  66124. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66125. },
  66126. enumerable: true,
  66127. configurable: true
  66128. });
  66129. Object.defineProperty(MaterialFlags, "BumpTextureEnabled", {
  66130. /**
  66131. * Are bump textures enabled in the application.
  66132. */
  66133. get: function () {
  66134. return this._BumpTextureEnabled;
  66135. },
  66136. set: function (value) {
  66137. if (this._BumpTextureEnabled === value) {
  66138. return;
  66139. }
  66140. this._BumpTextureEnabled = value;
  66141. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66142. },
  66143. enumerable: true,
  66144. configurable: true
  66145. });
  66146. Object.defineProperty(MaterialFlags, "LightmapTextureEnabled", {
  66147. /**
  66148. * Are lightmap textures enabled in the application.
  66149. */
  66150. get: function () {
  66151. return this._LightmapTextureEnabled;
  66152. },
  66153. set: function (value) {
  66154. if (this._LightmapTextureEnabled === value) {
  66155. return;
  66156. }
  66157. this._LightmapTextureEnabled = value;
  66158. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66159. },
  66160. enumerable: true,
  66161. configurable: true
  66162. });
  66163. Object.defineProperty(MaterialFlags, "RefractionTextureEnabled", {
  66164. /**
  66165. * Are refraction textures enabled in the application.
  66166. */
  66167. get: function () {
  66168. return this._RefractionTextureEnabled;
  66169. },
  66170. set: function (value) {
  66171. if (this._RefractionTextureEnabled === value) {
  66172. return;
  66173. }
  66174. this._RefractionTextureEnabled = value;
  66175. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66176. },
  66177. enumerable: true,
  66178. configurable: true
  66179. });
  66180. Object.defineProperty(MaterialFlags, "ColorGradingTextureEnabled", {
  66181. /**
  66182. * Are color grading textures enabled in the application.
  66183. */
  66184. get: function () {
  66185. return this._ColorGradingTextureEnabled;
  66186. },
  66187. set: function (value) {
  66188. if (this._ColorGradingTextureEnabled === value) {
  66189. return;
  66190. }
  66191. this._ColorGradingTextureEnabled = value;
  66192. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66193. },
  66194. enumerable: true,
  66195. configurable: true
  66196. });
  66197. Object.defineProperty(MaterialFlags, "FresnelEnabled", {
  66198. /**
  66199. * Are fresnels enabled in the application.
  66200. */
  66201. get: function () {
  66202. return this._FresnelEnabled;
  66203. },
  66204. set: function (value) {
  66205. if (this._FresnelEnabled === value) {
  66206. return;
  66207. }
  66208. this._FresnelEnabled = value;
  66209. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_FresnelDirtyFlag);
  66210. },
  66211. enumerable: true,
  66212. configurable: true
  66213. });
  66214. Object.defineProperty(MaterialFlags, "ClearCoatTextureEnabled", {
  66215. /**
  66216. * Are clear coat textures enabled in the application.
  66217. */
  66218. get: function () {
  66219. return this._ClearCoatTextureEnabled;
  66220. },
  66221. set: function (value) {
  66222. if (this._ClearCoatTextureEnabled === value) {
  66223. return;
  66224. }
  66225. this._ClearCoatTextureEnabled = value;
  66226. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66227. },
  66228. enumerable: true,
  66229. configurable: true
  66230. });
  66231. Object.defineProperty(MaterialFlags, "ClearCoatBumpTextureEnabled", {
  66232. /**
  66233. * Are clear coat bump textures enabled in the application.
  66234. */
  66235. get: function () {
  66236. return this._ClearCoatBumpTextureEnabled;
  66237. },
  66238. set: function (value) {
  66239. if (this._ClearCoatBumpTextureEnabled === value) {
  66240. return;
  66241. }
  66242. this._ClearCoatBumpTextureEnabled = value;
  66243. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66244. },
  66245. enumerable: true,
  66246. configurable: true
  66247. });
  66248. Object.defineProperty(MaterialFlags, "ClearCoatTintTextureEnabled", {
  66249. /**
  66250. * Are clear coat tint textures enabled in the application.
  66251. */
  66252. get: function () {
  66253. return this._ClearCoatTintTextureEnabled;
  66254. },
  66255. set: function (value) {
  66256. if (this._ClearCoatTintTextureEnabled === value) {
  66257. return;
  66258. }
  66259. this._ClearCoatTintTextureEnabled = value;
  66260. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66261. },
  66262. enumerable: true,
  66263. configurable: true
  66264. });
  66265. Object.defineProperty(MaterialFlags, "SheenTextureEnabled", {
  66266. /**
  66267. * Are sheen textures enabled in the application.
  66268. */
  66269. get: function () {
  66270. return this._SheenTextureEnabled;
  66271. },
  66272. set: function (value) {
  66273. if (this._SheenTextureEnabled === value) {
  66274. return;
  66275. }
  66276. this._SheenTextureEnabled = value;
  66277. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66278. },
  66279. enumerable: true,
  66280. configurable: true
  66281. });
  66282. Object.defineProperty(MaterialFlags, "AnisotropicTextureEnabled", {
  66283. /**
  66284. * Are anisotropic textures enabled in the application.
  66285. */
  66286. get: function () {
  66287. return this._AnisotropicTextureEnabled;
  66288. },
  66289. set: function (value) {
  66290. if (this._AnisotropicTextureEnabled === value) {
  66291. return;
  66292. }
  66293. this._AnisotropicTextureEnabled = value;
  66294. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66295. },
  66296. enumerable: true,
  66297. configurable: true
  66298. });
  66299. // Flags used to enable or disable a type of texture for all Standard Materials
  66300. MaterialFlags._DiffuseTextureEnabled = true;
  66301. MaterialFlags._AmbientTextureEnabled = true;
  66302. MaterialFlags._OpacityTextureEnabled = true;
  66303. MaterialFlags._ReflectionTextureEnabled = true;
  66304. MaterialFlags._EmissiveTextureEnabled = true;
  66305. MaterialFlags._SpecularTextureEnabled = true;
  66306. MaterialFlags._BumpTextureEnabled = true;
  66307. MaterialFlags._LightmapTextureEnabled = true;
  66308. MaterialFlags._RefractionTextureEnabled = true;
  66309. MaterialFlags._ColorGradingTextureEnabled = true;
  66310. MaterialFlags._FresnelEnabled = true;
  66311. MaterialFlags._ClearCoatTextureEnabled = true;
  66312. MaterialFlags._ClearCoatBumpTextureEnabled = true;
  66313. MaterialFlags._ClearCoatTintTextureEnabled = true;
  66314. MaterialFlags._SheenTextureEnabled = true;
  66315. MaterialFlags._AnisotropicTextureEnabled = true;
  66316. return MaterialFlags;
  66317. }());
  66318. /***/ }),
  66319. /***/ "./Materials/materialHelper.ts":
  66320. /*!*************************************!*\
  66321. !*** ./Materials/materialHelper.ts ***!
  66322. \*************************************/
  66323. /*! exports provided: MaterialHelper */
  66324. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66325. "use strict";
  66326. __webpack_require__.r(__webpack_exports__);
  66327. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return MaterialHelper; });
  66328. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  66329. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  66330. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  66331. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  66332. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  66333. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Lights/light */ "./Lights/light.ts");
  66334. /**
  66335. * "Static Class" containing the most commonly used helper while dealing with material for
  66336. * rendering purpose.
  66337. *
  66338. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  66339. *
  66340. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  66341. */
  66342. var MaterialHelper = /** @class */ (function () {
  66343. function MaterialHelper() {
  66344. }
  66345. /**
  66346. * Bind the current view position to an effect.
  66347. * @param effect The effect to be bound
  66348. * @param scene The scene the eyes position is used from
  66349. */
  66350. MaterialHelper.BindEyePosition = function (effect, scene) {
  66351. if (scene._forcedViewPosition) {
  66352. effect.setVector3("vEyePosition", scene._forcedViewPosition);
  66353. return;
  66354. }
  66355. var globalPosition = scene.activeCamera.globalPosition;
  66356. if (!globalPosition) {
  66357. // Use WebVRFreecamera's device position as global position is not it's actual position in babylon space
  66358. globalPosition = scene.activeCamera.devicePosition;
  66359. }
  66360. effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : globalPosition);
  66361. };
  66362. /**
  66363. * Helps preparing the defines values about the UVs in used in the effect.
  66364. * UVs are shared as much as we can accross channels in the shaders.
  66365. * @param texture The texture we are preparing the UVs for
  66366. * @param defines The defines to update
  66367. * @param key The channel key "diffuse", "specular"... used in the shader
  66368. */
  66369. MaterialHelper.PrepareDefinesForMergedUV = function (texture, defines, key) {
  66370. defines._needUVs = true;
  66371. defines[key] = true;
  66372. if (texture.getTextureMatrix().isIdentityAs3x2()) {
  66373. defines[key + "DIRECTUV"] = texture.coordinatesIndex + 1;
  66374. if (texture.coordinatesIndex === 0) {
  66375. defines["MAINUV1"] = true;
  66376. }
  66377. else {
  66378. defines["MAINUV2"] = true;
  66379. }
  66380. }
  66381. else {
  66382. defines[key + "DIRECTUV"] = 0;
  66383. }
  66384. };
  66385. /**
  66386. * Binds a texture matrix value to its corrsponding uniform
  66387. * @param texture The texture to bind the matrix for
  66388. * @param uniformBuffer The uniform buffer receivin the data
  66389. * @param key The channel key "diffuse", "specular"... used in the shader
  66390. */
  66391. MaterialHelper.BindTextureMatrix = function (texture, uniformBuffer, key) {
  66392. var matrix = texture.getTextureMatrix();
  66393. if (!matrix.isIdentityAs3x2()) {
  66394. uniformBuffer.updateMatrix(key + "Matrix", matrix);
  66395. }
  66396. };
  66397. /**
  66398. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  66399. * @param mesh defines the current mesh
  66400. * @param scene defines the current scene
  66401. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  66402. * @param pointsCloud defines if point cloud rendering has to be turned on
  66403. * @param fogEnabled defines if fog has to be turned on
  66404. * @param alphaTest defines if alpha testing has to be turned on
  66405. * @param defines defines the current list of defines
  66406. */
  66407. MaterialHelper.PrepareDefinesForMisc = function (mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, alphaTest, defines) {
  66408. if (defines._areMiscDirty) {
  66409. defines["LOGARITHMICDEPTH"] = useLogarithmicDepth;
  66410. defines["POINTSIZE"] = pointsCloud;
  66411. defines["FOG"] = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE && fogEnabled);
  66412. defines["NONUNIFORMSCALING"] = mesh.nonUniformScaling;
  66413. defines["ALPHATEST"] = alphaTest;
  66414. }
  66415. };
  66416. /**
  66417. * Helper used to prepare the list of defines associated with frame values for shader compilation
  66418. * @param scene defines the current scene
  66419. * @param engine defines the current engine
  66420. * @param defines specifies the list of active defines
  66421. * @param useInstances defines if instances have to be turned on
  66422. * @param useClipPlane defines if clip plane have to be turned on
  66423. */
  66424. MaterialHelper.PrepareDefinesForFrameBoundValues = function (scene, engine, defines, useInstances, useClipPlane) {
  66425. if (useClipPlane === void 0) { useClipPlane = null; }
  66426. var changed = false;
  66427. var useClipPlane1 = false;
  66428. var useClipPlane2 = false;
  66429. var useClipPlane3 = false;
  66430. var useClipPlane4 = false;
  66431. useClipPlane1 = useClipPlane == null ? (scene.clipPlane !== undefined && scene.clipPlane !== null) : useClipPlane;
  66432. useClipPlane2 = useClipPlane == null ? (scene.clipPlane2 !== undefined && scene.clipPlane2 !== null) : useClipPlane;
  66433. useClipPlane3 = useClipPlane == null ? (scene.clipPlane3 !== undefined && scene.clipPlane3 !== null) : useClipPlane;
  66434. useClipPlane4 = useClipPlane == null ? (scene.clipPlane4 !== undefined && scene.clipPlane4 !== null) : useClipPlane;
  66435. if (defines["CLIPPLANE"] !== useClipPlane1) {
  66436. defines["CLIPPLANE"] = useClipPlane1;
  66437. changed = true;
  66438. }
  66439. if (defines["CLIPPLANE2"] !== useClipPlane2) {
  66440. defines["CLIPPLANE2"] = useClipPlane2;
  66441. changed = true;
  66442. }
  66443. if (defines["CLIPPLANE3"] !== useClipPlane3) {
  66444. defines["CLIPPLANE3"] = useClipPlane3;
  66445. changed = true;
  66446. }
  66447. if (defines["CLIPPLANE4"] !== useClipPlane4) {
  66448. defines["CLIPPLANE4"] = useClipPlane4;
  66449. changed = true;
  66450. }
  66451. if (defines["DEPTHPREPASS"] !== !engine.getColorWrite()) {
  66452. defines["DEPTHPREPASS"] = !defines["DEPTHPREPASS"];
  66453. changed = true;
  66454. }
  66455. if (defines["INSTANCES"] !== useInstances) {
  66456. defines["INSTANCES"] = useInstances;
  66457. changed = true;
  66458. }
  66459. if (changed) {
  66460. defines.markAsUnprocessed();
  66461. }
  66462. };
  66463. /**
  66464. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  66465. * @param mesh The mesh containing the geometry data we will draw
  66466. * @param defines The defines to update
  66467. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  66468. * @param useBones Precise whether bones should be used or not (override mesh info)
  66469. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  66470. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  66471. * @returns false if defines are considered not dirty and have not been checked
  66472. */
  66473. MaterialHelper.PrepareDefinesForAttributes = function (mesh, defines, useVertexColor, useBones, useMorphTargets, useVertexAlpha) {
  66474. if (useMorphTargets === void 0) { useMorphTargets = false; }
  66475. if (useVertexAlpha === void 0) { useVertexAlpha = true; }
  66476. if (!defines._areAttributesDirty && defines._needNormals === defines._normals && defines._needUVs === defines._uvs) {
  66477. return false;
  66478. }
  66479. defines._normals = defines._needNormals;
  66480. defines._uvs = defines._needUVs;
  66481. defines["NORMAL"] = (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind));
  66482. if (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind)) {
  66483. defines["TANGENT"] = true;
  66484. }
  66485. if (defines._needUVs) {
  66486. defines["UV1"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  66487. defines["UV2"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  66488. }
  66489. else {
  66490. defines["UV1"] = false;
  66491. defines["UV2"] = false;
  66492. }
  66493. if (useVertexColor) {
  66494. var hasVertexColors = mesh.useVertexColors && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  66495. defines["VERTEXCOLOR"] = hasVertexColors;
  66496. defines["VERTEXALPHA"] = mesh.hasVertexAlpha && hasVertexColors && useVertexAlpha;
  66497. }
  66498. if (useBones) {
  66499. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  66500. defines["NUM_BONE_INFLUENCERS"] = mesh.numBoneInfluencers;
  66501. var materialSupportsBoneTexture = defines["BONETEXTURE"] !== undefined;
  66502. if (mesh.skeleton.isUsingTextureForMatrices && materialSupportsBoneTexture) {
  66503. defines["BONETEXTURE"] = true;
  66504. }
  66505. else {
  66506. defines["BonesPerMesh"] = (mesh.skeleton.bones.length + 1);
  66507. defines["BONETEXTURE"] = materialSupportsBoneTexture ? false : undefined;
  66508. }
  66509. }
  66510. else {
  66511. defines["NUM_BONE_INFLUENCERS"] = 0;
  66512. defines["BonesPerMesh"] = 0;
  66513. }
  66514. }
  66515. if (useMorphTargets) {
  66516. var manager = mesh.morphTargetManager;
  66517. if (manager) {
  66518. defines["MORPHTARGETS_TANGENT"] = manager.supportsTangents && defines["TANGENT"];
  66519. defines["MORPHTARGETS_NORMAL"] = manager.supportsNormals && defines["NORMAL"];
  66520. defines["MORPHTARGETS"] = (manager.numInfluencers > 0);
  66521. defines["NUM_MORPH_INFLUENCERS"] = manager.numInfluencers;
  66522. }
  66523. else {
  66524. defines["MORPHTARGETS_TANGENT"] = false;
  66525. defines["MORPHTARGETS_NORMAL"] = false;
  66526. defines["MORPHTARGETS"] = false;
  66527. defines["NUM_MORPH_INFLUENCERS"] = 0;
  66528. }
  66529. }
  66530. return true;
  66531. };
  66532. /**
  66533. * Prepares the defines related to multiview
  66534. * @param scene The scene we are intending to draw
  66535. * @param defines The defines to update
  66536. */
  66537. MaterialHelper.PrepareDefinesForMultiview = function (scene, defines) {
  66538. if (scene.activeCamera) {
  66539. var previousMultiview = defines.MULTIVIEW;
  66540. defines.MULTIVIEW = (scene.activeCamera.outputRenderTarget !== null && scene.activeCamera.outputRenderTarget.getViewCount() > 1);
  66541. if (defines.MULTIVIEW != previousMultiview) {
  66542. defines.markAsUnprocessed();
  66543. }
  66544. }
  66545. };
  66546. /**
  66547. * Prepares the defines related to the light information passed in parameter
  66548. * @param scene The scene we are intending to draw
  66549. * @param mesh The mesh the effect is compiling for
  66550. * @param defines The defines to update
  66551. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  66552. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  66553. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  66554. * @returns true if normals will be required for the rest of the effect
  66555. */
  66556. MaterialHelper.PrepareDefinesForLights = function (scene, mesh, defines, specularSupported, maxSimultaneousLights, disableLighting) {
  66557. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  66558. if (disableLighting === void 0) { disableLighting = false; }
  66559. if (!defines._areLightsDirty) {
  66560. return defines._needNormals;
  66561. }
  66562. var lightIndex = 0;
  66563. var needNormals = false;
  66564. var needRebuild = false;
  66565. var lightmapMode = false;
  66566. var shadowEnabled = false;
  66567. var specularEnabled = false;
  66568. if (scene.lightsEnabled && !disableLighting) {
  66569. for (var _i = 0, _a = mesh._lightSources; _i < _a.length; _i++) {
  66570. var light = _a[_i];
  66571. needNormals = true;
  66572. if (defines["LIGHT" + lightIndex] === undefined) {
  66573. needRebuild = true;
  66574. }
  66575. defines["LIGHT" + lightIndex] = true;
  66576. defines["SPOTLIGHT" + lightIndex] = false;
  66577. defines["HEMILIGHT" + lightIndex] = false;
  66578. defines["POINTLIGHT" + lightIndex] = false;
  66579. defines["DIRLIGHT" + lightIndex] = false;
  66580. light.prepareLightSpecificDefines(defines, lightIndex);
  66581. // FallOff.
  66582. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = false;
  66583. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = false;
  66584. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = false;
  66585. switch (light.falloffType) {
  66586. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_GLTF:
  66587. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = true;
  66588. break;
  66589. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_PHYSICAL:
  66590. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = true;
  66591. break;
  66592. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_STANDARD:
  66593. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = true;
  66594. break;
  66595. }
  66596. // Specular
  66597. if (specularSupported && !light.specular.equalsFloats(0, 0, 0)) {
  66598. specularEnabled = true;
  66599. }
  66600. // Shadows
  66601. defines["SHADOW" + lightIndex] = false;
  66602. defines["SHADOWPCF" + lightIndex] = false;
  66603. defines["SHADOWPCSS" + lightIndex] = false;
  66604. defines["SHADOWPOISSON" + lightIndex] = false;
  66605. defines["SHADOWESM" + lightIndex] = false;
  66606. defines["SHADOWCUBE" + lightIndex] = false;
  66607. defines["SHADOWLOWQUALITY" + lightIndex] = false;
  66608. defines["SHADOWMEDIUMQUALITY" + lightIndex] = false;
  66609. if (mesh && mesh.receiveShadows && scene.shadowsEnabled && light.shadowEnabled) {
  66610. var shadowGenerator = light.getShadowGenerator();
  66611. if (shadowGenerator) {
  66612. var shadowMap = shadowGenerator.getShadowMap();
  66613. if (shadowMap) {
  66614. if (shadowMap.renderList && shadowMap.renderList.length > 0) {
  66615. shadowEnabled = true;
  66616. shadowGenerator.prepareDefines(defines, lightIndex);
  66617. }
  66618. }
  66619. }
  66620. }
  66621. if (light.lightmapMode != _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_DEFAULT) {
  66622. lightmapMode = true;
  66623. defines["LIGHTMAPEXCLUDED" + lightIndex] = true;
  66624. defines["LIGHTMAPNOSPECULAR" + lightIndex] = (light.lightmapMode == _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_SHADOWSONLY);
  66625. }
  66626. else {
  66627. defines["LIGHTMAPEXCLUDED" + lightIndex] = false;
  66628. defines["LIGHTMAPNOSPECULAR" + lightIndex] = false;
  66629. }
  66630. lightIndex++;
  66631. if (lightIndex === maxSimultaneousLights) {
  66632. break;
  66633. }
  66634. }
  66635. }
  66636. defines["SPECULARTERM"] = specularEnabled;
  66637. defines["SHADOWS"] = shadowEnabled;
  66638. // Resetting all other lights if any
  66639. for (var index = lightIndex; index < maxSimultaneousLights; index++) {
  66640. if (defines["LIGHT" + index] !== undefined) {
  66641. defines["LIGHT" + index] = false;
  66642. defines["HEMILIGHT" + index] = false;
  66643. defines["POINTLIGHT" + index] = false;
  66644. defines["DIRLIGHT" + index] = false;
  66645. defines["SPOTLIGHT" + index] = false;
  66646. defines["SHADOW" + index] = false;
  66647. defines["SHADOWPCF" + index] = false;
  66648. defines["SHADOWPCSS" + index] = false;
  66649. defines["SHADOWPOISSON" + index] = false;
  66650. defines["SHADOWESM" + index] = false;
  66651. defines["SHADOWCUBE" + index] = false;
  66652. defines["SHADOWLOWQUALITY" + index] = false;
  66653. defines["SHADOWMEDIUMQUALITY" + index] = false;
  66654. }
  66655. }
  66656. var caps = scene.getEngine().getCaps();
  66657. if (defines["SHADOWFLOAT"] === undefined) {
  66658. needRebuild = true;
  66659. }
  66660. defines["SHADOWFLOAT"] = shadowEnabled &&
  66661. ((caps.textureFloatRender && caps.textureFloatLinearFiltering) ||
  66662. (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering));
  66663. defines["LIGHTMAPEXCLUDED"] = lightmapMode;
  66664. if (needRebuild) {
  66665. defines.rebuild();
  66666. }
  66667. return needNormals;
  66668. };
  66669. /**
  66670. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  66671. * that won t be acctive due to defines being turned off.
  66672. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  66673. * @param samplersList The samplers list
  66674. * @param defines The defines helping in the list generation
  66675. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  66676. */
  66677. MaterialHelper.PrepareUniformsAndSamplersList = function (uniformsListOrOptions, samplersList, defines, maxSimultaneousLights) {
  66678. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  66679. var uniformsList;
  66680. var uniformBuffersList = null;
  66681. if (uniformsListOrOptions.uniformsNames) {
  66682. var options = uniformsListOrOptions;
  66683. uniformsList = options.uniformsNames;
  66684. uniformBuffersList = options.uniformBuffersNames;
  66685. samplersList = options.samplers;
  66686. defines = options.defines;
  66687. maxSimultaneousLights = options.maxSimultaneousLights;
  66688. }
  66689. else {
  66690. uniformsList = uniformsListOrOptions;
  66691. if (!samplersList) {
  66692. samplersList = [];
  66693. }
  66694. }
  66695. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  66696. if (!defines["LIGHT" + lightIndex]) {
  66697. break;
  66698. }
  66699. uniformsList.push("vLightData" + lightIndex, "vLightDiffuse" + lightIndex, "vLightSpecular" + lightIndex, "vLightDirection" + lightIndex, "vLightFalloff" + lightIndex, "vLightGround" + lightIndex, "lightMatrix" + lightIndex, "shadowsInfo" + lightIndex, "depthValues" + lightIndex);
  66700. if (uniformBuffersList) {
  66701. uniformBuffersList.push("Light" + lightIndex);
  66702. }
  66703. samplersList.push("shadowSampler" + lightIndex);
  66704. samplersList.push("depthSampler" + lightIndex);
  66705. if (defines["PROJECTEDLIGHTTEXTURE" + lightIndex]) {
  66706. samplersList.push("projectionLightSampler" + lightIndex);
  66707. uniformsList.push("textureProjectionMatrix" + lightIndex);
  66708. }
  66709. }
  66710. if (defines["NUM_MORPH_INFLUENCERS"]) {
  66711. uniformsList.push("morphTargetInfluences");
  66712. }
  66713. };
  66714. /**
  66715. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  66716. * @param defines The defines to update while falling back
  66717. * @param fallbacks The authorized effect fallbacks
  66718. * @param maxSimultaneousLights The maximum number of lights allowed
  66719. * @param rank the current rank of the Effect
  66720. * @returns The newly affected rank
  66721. */
  66722. MaterialHelper.HandleFallbacksForShadows = function (defines, fallbacks, maxSimultaneousLights, rank) {
  66723. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  66724. if (rank === void 0) { rank = 0; }
  66725. var lightFallbackRank = 0;
  66726. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  66727. if (!defines["LIGHT" + lightIndex]) {
  66728. break;
  66729. }
  66730. if (lightIndex > 0) {
  66731. lightFallbackRank = rank + lightIndex;
  66732. fallbacks.addFallback(lightFallbackRank, "LIGHT" + lightIndex);
  66733. }
  66734. if (!defines["SHADOWS"]) {
  66735. if (defines["SHADOW" + lightIndex]) {
  66736. fallbacks.addFallback(rank, "SHADOW" + lightIndex);
  66737. }
  66738. if (defines["SHADOWPCF" + lightIndex]) {
  66739. fallbacks.addFallback(rank, "SHADOWPCF" + lightIndex);
  66740. }
  66741. if (defines["SHADOWPCSS" + lightIndex]) {
  66742. fallbacks.addFallback(rank, "SHADOWPCSS" + lightIndex);
  66743. }
  66744. if (defines["SHADOWPOISSON" + lightIndex]) {
  66745. fallbacks.addFallback(rank, "SHADOWPOISSON" + lightIndex);
  66746. }
  66747. if (defines["SHADOWESM" + lightIndex]) {
  66748. fallbacks.addFallback(rank, "SHADOWESM" + lightIndex);
  66749. }
  66750. }
  66751. }
  66752. return lightFallbackRank++;
  66753. };
  66754. /**
  66755. * Prepares the list of attributes required for morph targets according to the effect defines.
  66756. * @param attribs The current list of supported attribs
  66757. * @param mesh The mesh to prepare the morph targets attributes for
  66758. * @param defines The current Defines of the effect
  66759. */
  66760. MaterialHelper.PrepareAttributesForMorphTargets = function (attribs, mesh, defines) {
  66761. var influencers = defines["NUM_MORPH_INFLUENCERS"];
  66762. if (influencers > 0 && _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine) {
  66763. var maxAttributesCount = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine.getCaps().maxVertexAttribs;
  66764. var manager = mesh.morphTargetManager;
  66765. var normal = manager && manager.supportsNormals && defines["NORMAL"];
  66766. var tangent = manager && manager.supportsTangents && defines["TANGENT"];
  66767. for (var index = 0; index < influencers; index++) {
  66768. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind + index);
  66769. if (normal) {
  66770. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind + index);
  66771. }
  66772. if (tangent) {
  66773. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind + index);
  66774. }
  66775. if (attribs.length > maxAttributesCount) {
  66776. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add more vertex attributes for mesh " + mesh.name);
  66777. }
  66778. }
  66779. }
  66780. };
  66781. /**
  66782. * Prepares the list of attributes required for bones according to the effect defines.
  66783. * @param attribs The current list of supported attribs
  66784. * @param mesh The mesh to prepare the bones attributes for
  66785. * @param defines The current Defines of the effect
  66786. * @param fallbacks The current efffect fallback strategy
  66787. */
  66788. MaterialHelper.PrepareAttributesForBones = function (attribs, mesh, defines, fallbacks) {
  66789. if (defines["NUM_BONE_INFLUENCERS"] > 0) {
  66790. fallbacks.addCPUSkinningFallback(0, mesh);
  66791. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  66792. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  66793. if (defines["NUM_BONE_INFLUENCERS"] > 4) {
  66794. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesExtraKind);
  66795. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsExtraKind);
  66796. }
  66797. }
  66798. };
  66799. /**
  66800. * Prepares the list of attributes required for instances according to the effect defines.
  66801. * @param attribs The current list of supported attribs
  66802. * @param defines The current Defines of the effect
  66803. */
  66804. MaterialHelper.PrepareAttributesForInstances = function (attribs, defines) {
  66805. if (defines["INSTANCES"]) {
  66806. attribs.push("world0");
  66807. attribs.push("world1");
  66808. attribs.push("world2");
  66809. attribs.push("world3");
  66810. }
  66811. };
  66812. /**
  66813. * Binds the light shadow information to the effect for the given mesh.
  66814. * @param light The light containing the generator
  66815. * @param scene The scene the lights belongs to
  66816. * @param mesh The mesh we are binding the information to render
  66817. * @param lightIndex The light index in the effect used to render the mesh
  66818. * @param effect The effect we are binding the data to
  66819. */
  66820. MaterialHelper.BindLightShadow = function (light, mesh, lightIndex, effect) {
  66821. if (light.shadowEnabled && mesh.receiveShadows) {
  66822. var shadowGenerator = light.getShadowGenerator();
  66823. if (shadowGenerator) {
  66824. shadowGenerator.bindShadowLight(lightIndex, effect);
  66825. }
  66826. }
  66827. };
  66828. /**
  66829. * Binds the light information to the effect.
  66830. * @param light The light containing the generator
  66831. * @param effect The effect we are binding the data to
  66832. * @param lightIndex The light index in the effect used to render
  66833. */
  66834. MaterialHelper.BindLightProperties = function (light, effect, lightIndex) {
  66835. light.transferToEffect(effect, lightIndex + "");
  66836. };
  66837. /**
  66838. * Binds the lights information from the scene to the effect for the given mesh.
  66839. * @param scene The scene the lights belongs to
  66840. * @param mesh The mesh we are binding the information to render
  66841. * @param effect The effect we are binding the data to
  66842. * @param defines The generated defines for the effect
  66843. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  66844. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  66845. */
  66846. MaterialHelper.BindLights = function (scene, mesh, effect, defines, maxSimultaneousLights, usePhysicalLightFalloff) {
  66847. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  66848. if (usePhysicalLightFalloff === void 0) { usePhysicalLightFalloff = false; }
  66849. var len = Math.min(mesh._lightSources.length, maxSimultaneousLights);
  66850. for (var i = 0; i < len; i++) {
  66851. var light = mesh._lightSources[i];
  66852. var iAsString = i.toString();
  66853. var scaledIntensity = light.getScaledIntensity();
  66854. light._uniformBuffer.bindToEffect(effect, "Light" + i);
  66855. MaterialHelper.BindLightProperties(light, effect, i);
  66856. light.diffuse.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0]);
  66857. light._uniformBuffer.updateColor4("vLightDiffuse", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0], usePhysicalLightFalloff ? light.radius : light.range, iAsString);
  66858. if (defines["SPECULARTERM"]) {
  66859. light.specular.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1]);
  66860. light._uniformBuffer.updateColor3("vLightSpecular", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1], iAsString);
  66861. }
  66862. // Shadows
  66863. if (scene.shadowsEnabled) {
  66864. this.BindLightShadow(light, mesh, iAsString, effect);
  66865. }
  66866. light._uniformBuffer.update();
  66867. }
  66868. };
  66869. /**
  66870. * Binds the fog information from the scene to the effect for the given mesh.
  66871. * @param scene The scene the lights belongs to
  66872. * @param mesh The mesh we are binding the information to render
  66873. * @param effect The effect we are binding the data to
  66874. * @param linearSpace Defines if the fog effect is applied in linear space
  66875. */
  66876. MaterialHelper.BindFogParameters = function (scene, mesh, effect, linearSpace) {
  66877. if (linearSpace === void 0) { linearSpace = false; }
  66878. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
  66879. effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
  66880. // Convert fog color to linear space if used in a linear space computed shader.
  66881. if (linearSpace) {
  66882. scene.fogColor.toLinearSpaceToRef(this._tempFogColor);
  66883. effect.setColor3("vFogColor", this._tempFogColor);
  66884. }
  66885. else {
  66886. effect.setColor3("vFogColor", scene.fogColor);
  66887. }
  66888. }
  66889. };
  66890. /**
  66891. * Binds the bones information from the mesh to the effect.
  66892. * @param mesh The mesh we are binding the information to render
  66893. * @param effect The effect we are binding the data to
  66894. */
  66895. MaterialHelper.BindBonesParameters = function (mesh, effect) {
  66896. if (!effect || !mesh) {
  66897. return;
  66898. }
  66899. if (mesh.computeBonesUsingShaders && effect._bonesComputationForcedToCPU) {
  66900. mesh.computeBonesUsingShaders = false;
  66901. }
  66902. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  66903. var skeleton = mesh.skeleton;
  66904. if (skeleton.isUsingTextureForMatrices && effect.getUniformIndex("boneTextureWidth") > -1) {
  66905. var boneTexture = skeleton.getTransformMatrixTexture();
  66906. effect.setTexture("boneSampler", boneTexture);
  66907. effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  66908. }
  66909. else {
  66910. var matrices = skeleton.getTransformMatrices(mesh);
  66911. if (matrices) {
  66912. effect.setMatrices("mBones", matrices);
  66913. }
  66914. }
  66915. }
  66916. };
  66917. /**
  66918. * Binds the morph targets information from the mesh to the effect.
  66919. * @param abstractMesh The mesh we are binding the information to render
  66920. * @param effect The effect we are binding the data to
  66921. */
  66922. MaterialHelper.BindMorphTargetParameters = function (abstractMesh, effect) {
  66923. var manager = abstractMesh.morphTargetManager;
  66924. if (!abstractMesh || !manager) {
  66925. return;
  66926. }
  66927. effect.setFloatArray("morphTargetInfluences", manager.influences);
  66928. };
  66929. /**
  66930. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  66931. * @param defines The generated defines used in the effect
  66932. * @param effect The effect we are binding the data to
  66933. * @param scene The scene we are willing to render with logarithmic scale for
  66934. */
  66935. MaterialHelper.BindLogDepth = function (defines, effect, scene) {
  66936. if (defines["LOGARITHMICDEPTH"]) {
  66937. effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  66938. }
  66939. };
  66940. /**
  66941. * Binds the clip plane information from the scene to the effect.
  66942. * @param scene The scene the clip plane information are extracted from
  66943. * @param effect The effect we are binding the data to
  66944. */
  66945. MaterialHelper.BindClipPlane = function (effect, scene) {
  66946. if (scene.clipPlane) {
  66947. var clipPlane = scene.clipPlane;
  66948. effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  66949. }
  66950. if (scene.clipPlane2) {
  66951. var clipPlane = scene.clipPlane2;
  66952. effect.setFloat4("vClipPlane2", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  66953. }
  66954. if (scene.clipPlane3) {
  66955. var clipPlane = scene.clipPlane3;
  66956. effect.setFloat4("vClipPlane3", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  66957. }
  66958. if (scene.clipPlane4) {
  66959. var clipPlane = scene.clipPlane4;
  66960. effect.setFloat4("vClipPlane4", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  66961. }
  66962. };
  66963. MaterialHelper._tempFogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  66964. return MaterialHelper;
  66965. }());
  66966. /***/ }),
  66967. /***/ "./Materials/multiMaterial.ts":
  66968. /*!************************************!*\
  66969. !*** ./Materials/multiMaterial.ts ***!
  66970. \************************************/
  66971. /*! exports provided: MultiMaterial */
  66972. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66973. "use strict";
  66974. __webpack_require__.r(__webpack_exports__);
  66975. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return MultiMaterial; });
  66976. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  66977. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  66978. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  66979. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  66980. /**
  66981. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66982. * separate meshes. This can be use to improve performances.
  66983. * @see http://doc.babylonjs.com/how_to/multi_materials
  66984. */
  66985. var MultiMaterial = /** @class */ (function (_super) {
  66986. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiMaterial, _super);
  66987. /**
  66988. * Instantiates a new Multi Material
  66989. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66990. * separate meshes. This can be use to improve performances.
  66991. * @see http://doc.babylonjs.com/how_to/multi_materials
  66992. * @param name Define the name in the scene
  66993. * @param scene Define the scene the material belongs to
  66994. */
  66995. function MultiMaterial(name, scene) {
  66996. var _this = _super.call(this, name, scene, true) || this;
  66997. scene.multiMaterials.push(_this);
  66998. _this.subMaterials = new Array();
  66999. _this._storeEffectOnSubMeshes = true; // multimaterial is considered like a push material
  67000. return _this;
  67001. }
  67002. Object.defineProperty(MultiMaterial.prototype, "subMaterials", {
  67003. /**
  67004. * Gets or Sets the list of Materials used within the multi material.
  67005. * They need to be ordered according to the submeshes order in the associated mesh
  67006. */
  67007. get: function () {
  67008. return this._subMaterials;
  67009. },
  67010. set: function (value) {
  67011. this._subMaterials = value;
  67012. this._hookArray(value);
  67013. },
  67014. enumerable: true,
  67015. configurable: true
  67016. });
  67017. /**
  67018. * Function used to align with Node.getChildren()
  67019. * @returns the list of Materials used within the multi material
  67020. */
  67021. MultiMaterial.prototype.getChildren = function () {
  67022. return this.subMaterials;
  67023. };
  67024. MultiMaterial.prototype._hookArray = function (array) {
  67025. var _this = this;
  67026. var oldPush = array.push;
  67027. array.push = function () {
  67028. var items = [];
  67029. for (var _i = 0; _i < arguments.length; _i++) {
  67030. items[_i] = arguments[_i];
  67031. }
  67032. var result = oldPush.apply(array, items);
  67033. _this._markAllSubMeshesAsTexturesDirty();
  67034. return result;
  67035. };
  67036. var oldSplice = array.splice;
  67037. array.splice = function (index, deleteCount) {
  67038. var deleted = oldSplice.apply(array, [index, deleteCount]);
  67039. _this._markAllSubMeshesAsTexturesDirty();
  67040. return deleted;
  67041. };
  67042. };
  67043. /**
  67044. * Get one of the submaterial by its index in the submaterials array
  67045. * @param index The index to look the sub material at
  67046. * @returns The Material if the index has been defined
  67047. */
  67048. MultiMaterial.prototype.getSubMaterial = function (index) {
  67049. if (index < 0 || index >= this.subMaterials.length) {
  67050. return this.getScene().defaultMaterial;
  67051. }
  67052. return this.subMaterials[index];
  67053. };
  67054. /**
  67055. * Get the list of active textures for the whole sub materials list.
  67056. * @returns All the textures that will be used during the rendering
  67057. */
  67058. MultiMaterial.prototype.getActiveTextures = function () {
  67059. var _a;
  67060. return (_a = _super.prototype.getActiveTextures.call(this)).concat.apply(_a, this.subMaterials.map(function (subMaterial) {
  67061. if (subMaterial) {
  67062. return subMaterial.getActiveTextures();
  67063. }
  67064. else {
  67065. return [];
  67066. }
  67067. }));
  67068. };
  67069. /**
  67070. * Gets the current class name of the material e.g. "MultiMaterial"
  67071. * Mainly use in serialization.
  67072. * @returns the class name
  67073. */
  67074. MultiMaterial.prototype.getClassName = function () {
  67075. return "MultiMaterial";
  67076. };
  67077. /**
  67078. * Checks if the material is ready to render the requested sub mesh
  67079. * @param mesh Define the mesh the submesh belongs to
  67080. * @param subMesh Define the sub mesh to look readyness for
  67081. * @param useInstances Define whether or not the material is used with instances
  67082. * @returns true if ready, otherwise false
  67083. */
  67084. MultiMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  67085. for (var index = 0; index < this.subMaterials.length; index++) {
  67086. var subMaterial = this.subMaterials[index];
  67087. if (subMaterial) {
  67088. if (subMaterial._storeEffectOnSubMeshes) {
  67089. if (!subMaterial.isReadyForSubMesh(mesh, subMesh, useInstances)) {
  67090. return false;
  67091. }
  67092. continue;
  67093. }
  67094. if (!subMaterial.isReady(mesh)) {
  67095. return false;
  67096. }
  67097. }
  67098. }
  67099. return true;
  67100. };
  67101. /**
  67102. * Clones the current material and its related sub materials
  67103. * @param name Define the name of the newly cloned material
  67104. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  67105. * @returns the cloned material
  67106. */
  67107. MultiMaterial.prototype.clone = function (name, cloneChildren) {
  67108. var newMultiMaterial = new MultiMaterial(name, this.getScene());
  67109. for (var index = 0; index < this.subMaterials.length; index++) {
  67110. var subMaterial = null;
  67111. var current = this.subMaterials[index];
  67112. if (cloneChildren && current) {
  67113. subMaterial = current.clone(name + "-" + current.name);
  67114. }
  67115. else {
  67116. subMaterial = this.subMaterials[index];
  67117. }
  67118. newMultiMaterial.subMaterials.push(subMaterial);
  67119. }
  67120. return newMultiMaterial;
  67121. };
  67122. /**
  67123. * Serializes the materials into a JSON representation.
  67124. * @returns the JSON representation
  67125. */
  67126. MultiMaterial.prototype.serialize = function () {
  67127. var serializationObject = {};
  67128. serializationObject.name = this.name;
  67129. serializationObject.id = this.id;
  67130. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  67131. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].GetTags(this);
  67132. }
  67133. serializationObject.materials = [];
  67134. for (var matIndex = 0; matIndex < this.subMaterials.length; matIndex++) {
  67135. var subMat = this.subMaterials[matIndex];
  67136. if (subMat) {
  67137. serializationObject.materials.push(subMat.id);
  67138. }
  67139. else {
  67140. serializationObject.materials.push(null);
  67141. }
  67142. }
  67143. return serializationObject;
  67144. };
  67145. /**
  67146. * Dispose the material and release its associated resources
  67147. * @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)
  67148. * @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)
  67149. * @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)
  67150. */
  67151. MultiMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, forceDisposeChildren) {
  67152. var scene = this.getScene();
  67153. if (!scene) {
  67154. return;
  67155. }
  67156. if (forceDisposeChildren) {
  67157. for (var index = 0; index < this.subMaterials.length; index++) {
  67158. var subMaterial = this.subMaterials[index];
  67159. if (subMaterial) {
  67160. subMaterial.dispose(forceDisposeEffect, forceDisposeTextures);
  67161. }
  67162. }
  67163. }
  67164. var index = scene.multiMaterials.indexOf(this);
  67165. if (index >= 0) {
  67166. scene.multiMaterials.splice(index, 1);
  67167. }
  67168. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  67169. };
  67170. /**
  67171. * Creates a MultiMaterial from parsed MultiMaterial data.
  67172. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  67173. * @param scene defines the hosting scene
  67174. * @returns a new MultiMaterial
  67175. */
  67176. MultiMaterial.ParseMultiMaterial = function (parsedMultiMaterial, scene) {
  67177. var multiMaterial = new MultiMaterial(parsedMultiMaterial.name, scene);
  67178. multiMaterial.id = parsedMultiMaterial.id;
  67179. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  67180. _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].AddTagsTo(multiMaterial, parsedMultiMaterial.tags);
  67181. }
  67182. for (var matIndex = 0; matIndex < parsedMultiMaterial.materials.length; matIndex++) {
  67183. var subMatId = parsedMultiMaterial.materials[matIndex];
  67184. if (subMatId) {
  67185. multiMaterial.subMaterials.push(scene.getMaterialByID(subMatId));
  67186. }
  67187. else {
  67188. multiMaterial.subMaterials.push(null);
  67189. }
  67190. }
  67191. return multiMaterial;
  67192. };
  67193. return MultiMaterial;
  67194. }(_Materials_material__WEBPACK_IMPORTED_MODULE_1__["Material"]));
  67195. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.MultiMaterial"] = MultiMaterial;
  67196. /***/ }),
  67197. /***/ "./Materials/pushMaterial.ts":
  67198. /*!***********************************!*\
  67199. !*** ./Materials/pushMaterial.ts ***!
  67200. \***********************************/
  67201. /*! exports provided: PushMaterial */
  67202. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67203. "use strict";
  67204. __webpack_require__.r(__webpack_exports__);
  67205. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return PushMaterial; });
  67206. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  67207. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  67208. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  67209. /**
  67210. * Base class of materials working in push mode in babylon JS
  67211. * @hidden
  67212. */
  67213. var PushMaterial = /** @class */ (function (_super) {
  67214. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PushMaterial, _super);
  67215. function PushMaterial(name, scene) {
  67216. var _this = _super.call(this, name, scene) || this;
  67217. _this._normalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  67218. /**
  67219. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  67220. * This means that the material can keep using a previous shader while a new one is being compiled.
  67221. * This is mostly used when shader parallel compilation is supported (true by default)
  67222. */
  67223. _this.allowShaderHotSwapping = true;
  67224. _this._storeEffectOnSubMeshes = true;
  67225. return _this;
  67226. }
  67227. PushMaterial.prototype.getEffect = function () {
  67228. return this._activeEffect;
  67229. };
  67230. PushMaterial.prototype.isReady = function (mesh, useInstances) {
  67231. if (!mesh) {
  67232. return false;
  67233. }
  67234. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  67235. return true;
  67236. }
  67237. return this.isReadyForSubMesh(mesh, mesh.subMeshes[0], useInstances);
  67238. };
  67239. /**
  67240. * Binds the given world matrix to the active effect
  67241. *
  67242. * @param world the matrix to bind
  67243. */
  67244. PushMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  67245. this._activeEffect.setMatrix("world", world);
  67246. };
  67247. /**
  67248. * Binds the given normal matrix to the active effect
  67249. *
  67250. * @param normalMatrix the matrix to bind
  67251. */
  67252. PushMaterial.prototype.bindOnlyNormalMatrix = function (normalMatrix) {
  67253. this._activeEffect.setMatrix("normalMatrix", normalMatrix);
  67254. };
  67255. PushMaterial.prototype.bind = function (world, mesh) {
  67256. if (!mesh) {
  67257. return;
  67258. }
  67259. this.bindForSubMesh(world, mesh, mesh.subMeshes[0]);
  67260. };
  67261. PushMaterial.prototype._afterBind = function (mesh, effect) {
  67262. if (effect === void 0) { effect = null; }
  67263. _super.prototype._afterBind.call(this, mesh);
  67264. this.getScene()._cachedEffect = effect;
  67265. };
  67266. PushMaterial.prototype._mustRebind = function (scene, effect, visibility) {
  67267. if (visibility === void 0) { visibility = 1; }
  67268. return scene.isCachedMaterialInvalid(this, effect, visibility);
  67269. };
  67270. return PushMaterial;
  67271. }(_Materials_material__WEBPACK_IMPORTED_MODULE_2__["Material"]));
  67272. /***/ }),
  67273. /***/ "./Materials/shaderMaterial.ts":
  67274. /*!*************************************!*\
  67275. !*** ./Materials/shaderMaterial.ts ***!
  67276. \*************************************/
  67277. /*! exports provided: ShaderMaterial */
  67278. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67279. "use strict";
  67280. __webpack_require__.r(__webpack_exports__);
  67281. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return ShaderMaterial; });
  67282. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  67283. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  67284. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  67285. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  67286. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  67287. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  67288. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  67289. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  67290. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  67291. /**
  67292. * 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.
  67293. *
  67294. * This returned material effects how the mesh will look based on the code in the shaders.
  67295. *
  67296. * @see http://doc.babylonjs.com/how_to/shader_material
  67297. */
  67298. var ShaderMaterial = /** @class */ (function (_super) {
  67299. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShaderMaterial, _super);
  67300. /**
  67301. * Instantiate a new shader material.
  67302. * 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.
  67303. * This returned material effects how the mesh will look based on the code in the shaders.
  67304. * @see http://doc.babylonjs.com/how_to/shader_material
  67305. * @param name Define the name of the material in the scene
  67306. * @param scene Define the scene the material belongs to
  67307. * @param shaderPath Defines the route to the shader code in one of three ways:
  67308. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  67309. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  67310. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  67311. * @param options Define the options used to create the shader
  67312. */
  67313. function ShaderMaterial(name, scene, shaderPath, options) {
  67314. if (options === void 0) { options = {}; }
  67315. var _this = _super.call(this, name, scene) || this;
  67316. _this._textures = {};
  67317. _this._textureArrays = {};
  67318. _this._floats = {};
  67319. _this._ints = {};
  67320. _this._floatsArrays = {};
  67321. _this._colors3 = {};
  67322. _this._colors3Arrays = {};
  67323. _this._colors4 = {};
  67324. _this._vectors2 = {};
  67325. _this._vectors3 = {};
  67326. _this._vectors4 = {};
  67327. _this._matrices = {};
  67328. _this._matrices3x3 = {};
  67329. _this._matrices2x2 = {};
  67330. _this._vectors2Arrays = {};
  67331. _this._vectors3Arrays = {};
  67332. _this._cachedWorldViewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  67333. _this._shaderPath = shaderPath;
  67334. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ needAlphaBlending: false, needAlphaTesting: false, attributes: ["position", "normal", "uv"], uniforms: ["worldViewProjection"], uniformBuffers: [], samplers: [], defines: [] }, options);
  67335. return _this;
  67336. }
  67337. Object.defineProperty(ShaderMaterial.prototype, "options", {
  67338. /**
  67339. * Gets the options used to compile the shader.
  67340. * They can be modified to trigger a new compilation
  67341. */
  67342. get: function () {
  67343. return this._options;
  67344. },
  67345. enumerable: true,
  67346. configurable: true
  67347. });
  67348. /**
  67349. * Gets the current class name of the material e.g. "ShaderMaterial"
  67350. * Mainly use in serialization.
  67351. * @returns the class name
  67352. */
  67353. ShaderMaterial.prototype.getClassName = function () {
  67354. return "ShaderMaterial";
  67355. };
  67356. /**
  67357. * Specifies if the material will require alpha blending
  67358. * @returns a boolean specifying if alpha blending is needed
  67359. */
  67360. ShaderMaterial.prototype.needAlphaBlending = function () {
  67361. return (this.alpha < 1.0) || this._options.needAlphaBlending;
  67362. };
  67363. /**
  67364. * Specifies if this material should be rendered in alpha test mode
  67365. * @returns a boolean specifying if an alpha test is needed.
  67366. */
  67367. ShaderMaterial.prototype.needAlphaTesting = function () {
  67368. return this._options.needAlphaTesting;
  67369. };
  67370. ShaderMaterial.prototype._checkUniform = function (uniformName) {
  67371. if (this._options.uniforms.indexOf(uniformName) === -1) {
  67372. this._options.uniforms.push(uniformName);
  67373. }
  67374. };
  67375. /**
  67376. * Set a texture in the shader.
  67377. * @param name Define the name of the uniform samplers as defined in the shader
  67378. * @param texture Define the texture to bind to this sampler
  67379. * @return the material itself allowing "fluent" like uniform updates
  67380. */
  67381. ShaderMaterial.prototype.setTexture = function (name, texture) {
  67382. if (this._options.samplers.indexOf(name) === -1) {
  67383. this._options.samplers.push(name);
  67384. }
  67385. this._textures[name] = texture;
  67386. return this;
  67387. };
  67388. /**
  67389. * Set a texture array in the shader.
  67390. * @param name Define the name of the uniform sampler array as defined in the shader
  67391. * @param textures Define the list of textures to bind to this sampler
  67392. * @return the material itself allowing "fluent" like uniform updates
  67393. */
  67394. ShaderMaterial.prototype.setTextureArray = function (name, textures) {
  67395. if (this._options.samplers.indexOf(name) === -1) {
  67396. this._options.samplers.push(name);
  67397. }
  67398. this._checkUniform(name);
  67399. this._textureArrays[name] = textures;
  67400. return this;
  67401. };
  67402. /**
  67403. * Set a float in the shader.
  67404. * @param name Define the name of the uniform as defined in the shader
  67405. * @param value Define the value to give to the uniform
  67406. * @return the material itself allowing "fluent" like uniform updates
  67407. */
  67408. ShaderMaterial.prototype.setFloat = function (name, value) {
  67409. this._checkUniform(name);
  67410. this._floats[name] = value;
  67411. return this;
  67412. };
  67413. /**
  67414. * Set a int in the shader.
  67415. * @param name Define the name of the uniform as defined in the shader
  67416. * @param value Define the value to give to the uniform
  67417. * @return the material itself allowing "fluent" like uniform updates
  67418. */
  67419. ShaderMaterial.prototype.setInt = function (name, value) {
  67420. this._checkUniform(name);
  67421. this._ints[name] = value;
  67422. return this;
  67423. };
  67424. /**
  67425. * Set an array of floats in the shader.
  67426. * @param name Define the name of the uniform as defined in the shader
  67427. * @param value Define the value to give to the uniform
  67428. * @return the material itself allowing "fluent" like uniform updates
  67429. */
  67430. ShaderMaterial.prototype.setFloats = function (name, value) {
  67431. this._checkUniform(name);
  67432. this._floatsArrays[name] = value;
  67433. return this;
  67434. };
  67435. /**
  67436. * Set a vec3 in the shader from a Color3.
  67437. * @param name Define the name of the uniform as defined in the shader
  67438. * @param value Define the value to give to the uniform
  67439. * @return the material itself allowing "fluent" like uniform updates
  67440. */
  67441. ShaderMaterial.prototype.setColor3 = function (name, value) {
  67442. this._checkUniform(name);
  67443. this._colors3[name] = value;
  67444. return this;
  67445. };
  67446. /**
  67447. * Set a vec3 array in the shader from a Color3 array.
  67448. * @param name Define the name of the uniform as defined in the shader
  67449. * @param value Define the value to give to the uniform
  67450. * @return the material itself allowing "fluent" like uniform updates
  67451. */
  67452. ShaderMaterial.prototype.setColor3Array = function (name, value) {
  67453. this._checkUniform(name);
  67454. this._colors3Arrays[name] = value.reduce(function (arr, color) {
  67455. color.toArray(arr, arr.length);
  67456. return arr;
  67457. }, []);
  67458. return this;
  67459. };
  67460. /**
  67461. * Set a vec4 in the shader from a Color4.
  67462. * @param name Define the name of the uniform as defined in the shader
  67463. * @param value Define the value to give to the uniform
  67464. * @return the material itself allowing "fluent" like uniform updates
  67465. */
  67466. ShaderMaterial.prototype.setColor4 = function (name, value) {
  67467. this._checkUniform(name);
  67468. this._colors4[name] = value;
  67469. return this;
  67470. };
  67471. /**
  67472. * Set a vec2 in the shader from a Vector2.
  67473. * @param name Define the name of the uniform as defined in the shader
  67474. * @param value Define the value to give to the uniform
  67475. * @return the material itself allowing "fluent" like uniform updates
  67476. */
  67477. ShaderMaterial.prototype.setVector2 = function (name, value) {
  67478. this._checkUniform(name);
  67479. this._vectors2[name] = value;
  67480. return this;
  67481. };
  67482. /**
  67483. * Set a vec3 in the shader from a Vector3.
  67484. * @param name Define the name of the uniform as defined in the shader
  67485. * @param value Define the value to give to the uniform
  67486. * @return the material itself allowing "fluent" like uniform updates
  67487. */
  67488. ShaderMaterial.prototype.setVector3 = function (name, value) {
  67489. this._checkUniform(name);
  67490. this._vectors3[name] = value;
  67491. return this;
  67492. };
  67493. /**
  67494. * Set a vec4 in the shader from a Vector4.
  67495. * @param name Define the name of the uniform as defined in the shader
  67496. * @param value Define the value to give to the uniform
  67497. * @return the material itself allowing "fluent" like uniform updates
  67498. */
  67499. ShaderMaterial.prototype.setVector4 = function (name, value) {
  67500. this._checkUniform(name);
  67501. this._vectors4[name] = value;
  67502. return this;
  67503. };
  67504. /**
  67505. * Set a mat4 in the shader from a Matrix.
  67506. * @param name Define the name of the uniform as defined in the shader
  67507. * @param value Define the value to give to the uniform
  67508. * @return the material itself allowing "fluent" like uniform updates
  67509. */
  67510. ShaderMaterial.prototype.setMatrix = function (name, value) {
  67511. this._checkUniform(name);
  67512. this._matrices[name] = value;
  67513. return this;
  67514. };
  67515. /**
  67516. * Set a mat3 in the shader from a Float32Array.
  67517. * @param name Define the name of the uniform as defined in the shader
  67518. * @param value Define the value to give to the uniform
  67519. * @return the material itself allowing "fluent" like uniform updates
  67520. */
  67521. ShaderMaterial.prototype.setMatrix3x3 = function (name, value) {
  67522. this._checkUniform(name);
  67523. this._matrices3x3[name] = value;
  67524. return this;
  67525. };
  67526. /**
  67527. * Set a mat2 in the shader from a Float32Array.
  67528. * @param name Define the name of the uniform as defined in the shader
  67529. * @param value Define the value to give to the uniform
  67530. * @return the material itself allowing "fluent" like uniform updates
  67531. */
  67532. ShaderMaterial.prototype.setMatrix2x2 = function (name, value) {
  67533. this._checkUniform(name);
  67534. this._matrices2x2[name] = value;
  67535. return this;
  67536. };
  67537. /**
  67538. * Set a vec2 array in the shader from a number array.
  67539. * @param name Define the name of the uniform as defined in the shader
  67540. * @param value Define the value to give to the uniform
  67541. * @return the material itself allowing "fluent" like uniform updates
  67542. */
  67543. ShaderMaterial.prototype.setArray2 = function (name, value) {
  67544. this._checkUniform(name);
  67545. this._vectors2Arrays[name] = value;
  67546. return this;
  67547. };
  67548. /**
  67549. * Set a vec3 array in the shader from a number array.
  67550. * @param name Define the name of the uniform as defined in the shader
  67551. * @param value Define the value to give to the uniform
  67552. * @return the material itself allowing "fluent" like uniform updates
  67553. */
  67554. ShaderMaterial.prototype.setArray3 = function (name, value) {
  67555. this._checkUniform(name);
  67556. this._vectors3Arrays[name] = value;
  67557. return this;
  67558. };
  67559. ShaderMaterial.prototype._checkCache = function (mesh, useInstances) {
  67560. if (!mesh) {
  67561. return true;
  67562. }
  67563. if (this._effect && (this._effect.defines.indexOf("#define INSTANCES") !== -1) !== useInstances) {
  67564. return false;
  67565. }
  67566. return false;
  67567. };
  67568. /**
  67569. * Specifies that the submesh is ready to be used
  67570. * @param mesh defines the mesh to check
  67571. * @param subMesh defines which submesh to check
  67572. * @param useInstances specifies that instances should be used
  67573. * @returns a boolean indicating that the submesh is ready or not
  67574. */
  67575. ShaderMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  67576. return this.isReady(mesh, useInstances);
  67577. };
  67578. /**
  67579. * Checks if the material is ready to render the requested mesh
  67580. * @param mesh Define the mesh to render
  67581. * @param useInstances Define whether or not the material is used with instances
  67582. * @returns true if ready, otherwise false
  67583. */
  67584. ShaderMaterial.prototype.isReady = function (mesh, useInstances) {
  67585. var scene = this.getScene();
  67586. var engine = scene.getEngine();
  67587. if (!this.checkReadyOnEveryCall) {
  67588. if (this._renderId === scene.getRenderId()) {
  67589. if (this._checkCache(mesh, useInstances)) {
  67590. return true;
  67591. }
  67592. }
  67593. }
  67594. // Instances
  67595. var defines = [];
  67596. var attribs = [];
  67597. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  67598. for (var index = 0; index < this._options.defines.length; index++) {
  67599. defines.push(this._options.defines[index]);
  67600. }
  67601. for (var index = 0; index < this._options.attributes.length; index++) {
  67602. attribs.push(this._options.attributes[index]);
  67603. }
  67604. if (mesh && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind)) {
  67605. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind);
  67606. defines.push("#define VERTEXCOLOR");
  67607. }
  67608. if (useInstances) {
  67609. defines.push("#define INSTANCES");
  67610. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  67611. }
  67612. // Bones
  67613. if (mesh && mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  67614. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  67615. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind);
  67616. if (mesh.numBoneInfluencers > 4) {
  67617. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind);
  67618. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsExtraKind);
  67619. }
  67620. var skeleton = mesh.skeleton;
  67621. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  67622. fallbacks.addCPUSkinningFallback(0, mesh);
  67623. if (skeleton.isUsingTextureForMatrices) {
  67624. defines.push("#define BONETEXTURE");
  67625. if (this._options.uniforms.indexOf("boneTextureWidth") === -1) {
  67626. this._options.uniforms.push("boneTextureWidth");
  67627. }
  67628. if (this._options.samplers.indexOf("boneSampler") === -1) {
  67629. this._options.samplers.push("boneSampler");
  67630. }
  67631. }
  67632. else {
  67633. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  67634. if (this._options.uniforms.indexOf("mBones") === -1) {
  67635. this._options.uniforms.push("mBones");
  67636. }
  67637. }
  67638. }
  67639. else {
  67640. defines.push("#define NUM_BONE_INFLUENCERS 0");
  67641. }
  67642. // Textures
  67643. for (var name in this._textures) {
  67644. if (!this._textures[name].isReady()) {
  67645. return false;
  67646. }
  67647. }
  67648. // Alpha test
  67649. if (mesh && this._shouldTurnAlphaTestOn(mesh)) {
  67650. defines.push("#define ALPHATEST");
  67651. }
  67652. var previousEffect = this._effect;
  67653. var join = defines.join("\n");
  67654. this._effect = engine.createEffect(this._shaderPath, {
  67655. attributes: attribs,
  67656. uniformsNames: this._options.uniforms,
  67657. uniformBuffersNames: this._options.uniformBuffers,
  67658. samplers: this._options.samplers,
  67659. defines: join,
  67660. fallbacks: fallbacks,
  67661. onCompiled: this.onCompiled,
  67662. onError: this.onError
  67663. }, engine);
  67664. if (!this._effect.isReady()) {
  67665. return false;
  67666. }
  67667. if (previousEffect !== this._effect) {
  67668. scene.resetCachedMaterial();
  67669. }
  67670. this._renderId = scene.getRenderId();
  67671. return true;
  67672. };
  67673. /**
  67674. * Binds the world matrix to the material
  67675. * @param world defines the world transformation matrix
  67676. */
  67677. ShaderMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  67678. var scene = this.getScene();
  67679. if (!this._effect) {
  67680. return;
  67681. }
  67682. if (this._options.uniforms.indexOf("world") !== -1) {
  67683. this._effect.setMatrix("world", world);
  67684. }
  67685. if (this._options.uniforms.indexOf("worldView") !== -1) {
  67686. world.multiplyToRef(scene.getViewMatrix(), this._cachedWorldViewMatrix);
  67687. this._effect.setMatrix("worldView", this._cachedWorldViewMatrix);
  67688. }
  67689. if (this._options.uniforms.indexOf("worldViewProjection") !== -1) {
  67690. this._effect.setMatrix("worldViewProjection", world.multiply(scene.getTransformMatrix()));
  67691. }
  67692. };
  67693. /**
  67694. * Binds the material to the mesh
  67695. * @param world defines the world transformation matrix
  67696. * @param mesh defines the mesh to bind the material to
  67697. */
  67698. ShaderMaterial.prototype.bind = function (world, mesh) {
  67699. // Std values
  67700. this.bindOnlyWorldMatrix(world);
  67701. if (this._effect && this.getScene().getCachedMaterial() !== this) {
  67702. if (this._options.uniforms.indexOf("view") !== -1) {
  67703. this._effect.setMatrix("view", this.getScene().getViewMatrix());
  67704. }
  67705. if (this._options.uniforms.indexOf("projection") !== -1) {
  67706. this._effect.setMatrix("projection", this.getScene().getProjectionMatrix());
  67707. }
  67708. if (this._options.uniforms.indexOf("viewProjection") !== -1) {
  67709. this._effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  67710. }
  67711. // Bones
  67712. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindBonesParameters(mesh, this._effect);
  67713. var name;
  67714. // Texture
  67715. for (name in this._textures) {
  67716. this._effect.setTexture(name, this._textures[name]);
  67717. }
  67718. // Texture arrays
  67719. for (name in this._textureArrays) {
  67720. this._effect.setTextureArray(name, this._textureArrays[name]);
  67721. }
  67722. // Int
  67723. for (name in this._ints) {
  67724. this._effect.setInt(name, this._ints[name]);
  67725. }
  67726. // Float
  67727. for (name in this._floats) {
  67728. this._effect.setFloat(name, this._floats[name]);
  67729. }
  67730. // Floats
  67731. for (name in this._floatsArrays) {
  67732. this._effect.setArray(name, this._floatsArrays[name]);
  67733. }
  67734. // Color3
  67735. for (name in this._colors3) {
  67736. this._effect.setColor3(name, this._colors3[name]);
  67737. }
  67738. for (name in this._colors3Arrays) {
  67739. this._effect.setArray3(name, this._colors3Arrays[name]);
  67740. }
  67741. // Color4
  67742. for (name in this._colors4) {
  67743. var color = this._colors4[name];
  67744. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  67745. }
  67746. // Vector2
  67747. for (name in this._vectors2) {
  67748. this._effect.setVector2(name, this._vectors2[name]);
  67749. }
  67750. // Vector3
  67751. for (name in this._vectors3) {
  67752. this._effect.setVector3(name, this._vectors3[name]);
  67753. }
  67754. // Vector4
  67755. for (name in this._vectors4) {
  67756. this._effect.setVector4(name, this._vectors4[name]);
  67757. }
  67758. // Matrix
  67759. for (name in this._matrices) {
  67760. this._effect.setMatrix(name, this._matrices[name]);
  67761. }
  67762. // Matrix 3x3
  67763. for (name in this._matrices3x3) {
  67764. this._effect.setMatrix3x3(name, this._matrices3x3[name]);
  67765. }
  67766. // Matrix 2x2
  67767. for (name in this._matrices2x2) {
  67768. this._effect.setMatrix2x2(name, this._matrices2x2[name]);
  67769. }
  67770. // Vector2Array
  67771. for (name in this._vectors2Arrays) {
  67772. this._effect.setArray2(name, this._vectors2Arrays[name]);
  67773. }
  67774. // Vector3Array
  67775. for (name in this._vectors3Arrays) {
  67776. this._effect.setArray3(name, this._vectors3Arrays[name]);
  67777. }
  67778. }
  67779. this._afterBind(mesh);
  67780. };
  67781. /**
  67782. * Gets the active textures from the material
  67783. * @returns an array of textures
  67784. */
  67785. ShaderMaterial.prototype.getActiveTextures = function () {
  67786. var activeTextures = _super.prototype.getActiveTextures.call(this);
  67787. for (var name in this._textures) {
  67788. activeTextures.push(this._textures[name]);
  67789. }
  67790. for (var name in this._textureArrays) {
  67791. var array = this._textureArrays[name];
  67792. for (var index = 0; index < array.length; index++) {
  67793. activeTextures.push(array[index]);
  67794. }
  67795. }
  67796. return activeTextures;
  67797. };
  67798. /**
  67799. * Specifies if the material uses a texture
  67800. * @param texture defines the texture to check against the material
  67801. * @returns a boolean specifying if the material uses the texture
  67802. */
  67803. ShaderMaterial.prototype.hasTexture = function (texture) {
  67804. if (_super.prototype.hasTexture.call(this, texture)) {
  67805. return true;
  67806. }
  67807. for (var name in this._textures) {
  67808. if (this._textures[name] === texture) {
  67809. return true;
  67810. }
  67811. }
  67812. for (var name in this._textureArrays) {
  67813. var array = this._textureArrays[name];
  67814. for (var index = 0; index < array.length; index++) {
  67815. if (array[index] === texture) {
  67816. return true;
  67817. }
  67818. }
  67819. }
  67820. return false;
  67821. };
  67822. /**
  67823. * Makes a duplicate of the material, and gives it a new name
  67824. * @param name defines the new name for the duplicated material
  67825. * @returns the cloned material
  67826. */
  67827. ShaderMaterial.prototype.clone = function (name) {
  67828. var newShaderMaterial = new ShaderMaterial(name, this.getScene(), this._shaderPath, this._options);
  67829. return newShaderMaterial;
  67830. };
  67831. /**
  67832. * Disposes the material
  67833. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  67834. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  67835. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  67836. */
  67837. ShaderMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  67838. if (forceDisposeTextures) {
  67839. var name;
  67840. for (name in this._textures) {
  67841. this._textures[name].dispose();
  67842. }
  67843. for (name in this._textureArrays) {
  67844. var array = this._textureArrays[name];
  67845. for (var index = 0; index < array.length; index++) {
  67846. array[index].dispose();
  67847. }
  67848. }
  67849. }
  67850. this._textures = {};
  67851. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures, notBoundToMesh);
  67852. };
  67853. /**
  67854. * Serializes this material in a JSON representation
  67855. * @returns the serialized material object
  67856. */
  67857. ShaderMaterial.prototype.serialize = function () {
  67858. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  67859. serializationObject.customType = "ShaderMaterial";
  67860. serializationObject.options = this._options;
  67861. serializationObject.shaderPath = this._shaderPath;
  67862. var name;
  67863. // Texture
  67864. serializationObject.textures = {};
  67865. for (name in this._textures) {
  67866. serializationObject.textures[name] = this._textures[name].serialize();
  67867. }
  67868. // Texture arrays
  67869. serializationObject.textureArrays = {};
  67870. for (name in this._textureArrays) {
  67871. serializationObject.textureArrays[name] = [];
  67872. var array = this._textureArrays[name];
  67873. for (var index = 0; index < array.length; index++) {
  67874. serializationObject.textureArrays[name].push(array[index].serialize());
  67875. }
  67876. }
  67877. // Float
  67878. serializationObject.floats = {};
  67879. for (name in this._floats) {
  67880. serializationObject.floats[name] = this._floats[name];
  67881. }
  67882. // Float s
  67883. serializationObject.FloatArrays = {};
  67884. for (name in this._floatsArrays) {
  67885. serializationObject.FloatArrays[name] = this._floatsArrays[name];
  67886. }
  67887. // Color3
  67888. serializationObject.colors3 = {};
  67889. for (name in this._colors3) {
  67890. serializationObject.colors3[name] = this._colors3[name].asArray();
  67891. }
  67892. // Color3 array
  67893. serializationObject.colors3Arrays = {};
  67894. for (name in this._colors3Arrays) {
  67895. serializationObject.colors3Arrays[name] = this._colors3Arrays[name];
  67896. }
  67897. // Color4
  67898. serializationObject.colors4 = {};
  67899. for (name in this._colors4) {
  67900. serializationObject.colors4[name] = this._colors4[name].asArray();
  67901. }
  67902. // Vector2
  67903. serializationObject.vectors2 = {};
  67904. for (name in this._vectors2) {
  67905. serializationObject.vectors2[name] = this._vectors2[name].asArray();
  67906. }
  67907. // Vector3
  67908. serializationObject.vectors3 = {};
  67909. for (name in this._vectors3) {
  67910. serializationObject.vectors3[name] = this._vectors3[name].asArray();
  67911. }
  67912. // Vector4
  67913. serializationObject.vectors4 = {};
  67914. for (name in this._vectors4) {
  67915. serializationObject.vectors4[name] = this._vectors4[name].asArray();
  67916. }
  67917. // Matrix
  67918. serializationObject.matrices = {};
  67919. for (name in this._matrices) {
  67920. serializationObject.matrices[name] = this._matrices[name].asArray();
  67921. }
  67922. // Matrix 3x3
  67923. serializationObject.matrices3x3 = {};
  67924. for (name in this._matrices3x3) {
  67925. serializationObject.matrices3x3[name] = this._matrices3x3[name];
  67926. }
  67927. // Matrix 2x2
  67928. serializationObject.matrices2x2 = {};
  67929. for (name in this._matrices2x2) {
  67930. serializationObject.matrices2x2[name] = this._matrices2x2[name];
  67931. }
  67932. // Vector2Array
  67933. serializationObject.vectors2Arrays = {};
  67934. for (name in this._vectors2Arrays) {
  67935. serializationObject.vectors2Arrays[name] = this._vectors2Arrays[name];
  67936. }
  67937. // Vector3Array
  67938. serializationObject.vectors3Arrays = {};
  67939. for (name in this._vectors3Arrays) {
  67940. serializationObject.vectors3Arrays[name] = this._vectors3Arrays[name];
  67941. }
  67942. return serializationObject;
  67943. };
  67944. /**
  67945. * Creates a shader material from parsed shader material data
  67946. * @param source defines the JSON represnetation of the material
  67947. * @param scene defines the hosting scene
  67948. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67949. * @returns a new material
  67950. */
  67951. ShaderMaterial.Parse = function (source, scene, rootUrl) {
  67952. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ShaderMaterial(source.name, scene, source.shaderPath, source.options); }, source, scene, rootUrl);
  67953. var name;
  67954. // Texture
  67955. for (name in source.textures) {
  67956. material.setTexture(name, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(source.textures[name], scene, rootUrl));
  67957. }
  67958. // Texture arrays
  67959. for (name in source.textureArrays) {
  67960. var array = source.textureArrays[name];
  67961. var textureArray = new Array();
  67962. for (var index = 0; index < array.length; index++) {
  67963. textureArray.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(array[index], scene, rootUrl));
  67964. }
  67965. material.setTextureArray(name, textureArray);
  67966. }
  67967. // Float
  67968. for (name in source.floats) {
  67969. material.setFloat(name, source.floats[name]);
  67970. }
  67971. // Float s
  67972. for (name in source.floatsArrays) {
  67973. material.setFloats(name, source.floatsArrays[name]);
  67974. }
  67975. // Color3
  67976. for (name in source.colors3) {
  67977. material.setColor3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(source.colors3[name]));
  67978. }
  67979. // Color3 arrays
  67980. for (name in source.colors3Arrays) {
  67981. var colors = source.colors3Arrays[name].reduce(function (arr, num, i) {
  67982. if (i % 3 === 0) {
  67983. arr.push([num]);
  67984. }
  67985. else {
  67986. arr[arr.length - 1].push(num);
  67987. }
  67988. return arr;
  67989. }, []).map(function (color) { return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(color); });
  67990. material.setColor3Array(name, colors);
  67991. }
  67992. // Color4
  67993. for (name in source.colors4) {
  67994. material.setColor4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(source.colors4[name]));
  67995. }
  67996. // Vector2
  67997. for (name in source.vectors2) {
  67998. material.setVector2(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"].FromArray(source.vectors2[name]));
  67999. }
  68000. // Vector3
  68001. for (name in source.vectors3) {
  68002. material.setVector3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(source.vectors3[name]));
  68003. }
  68004. // Vector4
  68005. for (name in source.vectors4) {
  68006. material.setVector4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector4"].FromArray(source.vectors4[name]));
  68007. }
  68008. // Matrix
  68009. for (name in source.matrices) {
  68010. material.setMatrix(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(source.matrices[name]));
  68011. }
  68012. // Matrix 3x3
  68013. for (name in source.matrices3x3) {
  68014. material.setMatrix3x3(name, source.matrices3x3[name]);
  68015. }
  68016. // Matrix 2x2
  68017. for (name in source.matrices2x2) {
  68018. material.setMatrix2x2(name, source.matrices2x2[name]);
  68019. }
  68020. // Vector2Array
  68021. for (name in source.vectors2Arrays) {
  68022. material.setArray2(name, source.vectors2Arrays[name]);
  68023. }
  68024. // Vector3Array
  68025. for (name in source.vectors3Arrays) {
  68026. material.setArray3(name, source.vectors3Arrays[name]);
  68027. }
  68028. return material;
  68029. };
  68030. return ShaderMaterial;
  68031. }(_material__WEBPACK_IMPORTED_MODULE_7__["Material"]));
  68032. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.ShaderMaterial"] = ShaderMaterial;
  68033. /***/ }),
  68034. /***/ "./Materials/standardMaterial.ts":
  68035. /*!***************************************!*\
  68036. !*** ./Materials/standardMaterial.ts ***!
  68037. \***************************************/
  68038. /*! exports provided: StandardMaterialDefines, StandardMaterial */
  68039. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  68040. "use strict";
  68041. __webpack_require__.r(__webpack_exports__);
  68042. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return StandardMaterialDefines; });
  68043. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return StandardMaterial; });
  68044. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  68045. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  68046. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  68047. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  68048. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  68049. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  68050. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  68051. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  68052. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  68053. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  68054. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  68055. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  68056. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  68057. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  68058. /* harmony import */ var _Shaders_default_fragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/default.fragment */ "./Shaders/default.fragment.ts");
  68059. /* harmony import */ var _Shaders_default_vertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/default.vertex */ "./Shaders/default.vertex.ts");
  68060. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  68061. /** @hidden */
  68062. var StandardMaterialDefines = /** @class */ (function (_super) {
  68063. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterialDefines, _super);
  68064. function StandardMaterialDefines() {
  68065. var _this = _super.call(this) || this;
  68066. _this.MAINUV1 = false;
  68067. _this.MAINUV2 = false;
  68068. _this.DIFFUSE = false;
  68069. _this.DIFFUSEDIRECTUV = 0;
  68070. _this.AMBIENT = false;
  68071. _this.AMBIENTDIRECTUV = 0;
  68072. _this.OPACITY = false;
  68073. _this.OPACITYDIRECTUV = 0;
  68074. _this.OPACITYRGB = false;
  68075. _this.REFLECTION = false;
  68076. _this.EMISSIVE = false;
  68077. _this.EMISSIVEDIRECTUV = 0;
  68078. _this.SPECULAR = false;
  68079. _this.SPECULARDIRECTUV = 0;
  68080. _this.BUMP = false;
  68081. _this.BUMPDIRECTUV = 0;
  68082. _this.PARALLAX = false;
  68083. _this.PARALLAXOCCLUSION = false;
  68084. _this.SPECULAROVERALPHA = false;
  68085. _this.CLIPPLANE = false;
  68086. _this.CLIPPLANE2 = false;
  68087. _this.CLIPPLANE3 = false;
  68088. _this.CLIPPLANE4 = false;
  68089. _this.ALPHATEST = false;
  68090. _this.DEPTHPREPASS = false;
  68091. _this.ALPHAFROMDIFFUSE = false;
  68092. _this.POINTSIZE = false;
  68093. _this.FOG = false;
  68094. _this.SPECULARTERM = false;
  68095. _this.DIFFUSEFRESNEL = false;
  68096. _this.OPACITYFRESNEL = false;
  68097. _this.REFLECTIONFRESNEL = false;
  68098. _this.REFRACTIONFRESNEL = false;
  68099. _this.EMISSIVEFRESNEL = false;
  68100. _this.FRESNEL = false;
  68101. _this.NORMAL = false;
  68102. _this.UV1 = false;
  68103. _this.UV2 = false;
  68104. _this.VERTEXCOLOR = false;
  68105. _this.VERTEXALPHA = false;
  68106. _this.NUM_BONE_INFLUENCERS = 0;
  68107. _this.BonesPerMesh = 0;
  68108. _this.BONETEXTURE = false;
  68109. _this.INSTANCES = false;
  68110. _this.GLOSSINESS = false;
  68111. _this.ROUGHNESS = false;
  68112. _this.EMISSIVEASILLUMINATION = false;
  68113. _this.LINKEMISSIVEWITHDIFFUSE = false;
  68114. _this.REFLECTIONFRESNELFROMSPECULAR = false;
  68115. _this.LIGHTMAP = false;
  68116. _this.LIGHTMAPDIRECTUV = 0;
  68117. _this.OBJECTSPACE_NORMALMAP = false;
  68118. _this.USELIGHTMAPASSHADOWMAP = false;
  68119. _this.REFLECTIONMAP_3D = false;
  68120. _this.REFLECTIONMAP_SPHERICAL = false;
  68121. _this.REFLECTIONMAP_PLANAR = false;
  68122. _this.REFLECTIONMAP_CUBIC = false;
  68123. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  68124. _this.REFLECTIONMAP_PROJECTION = false;
  68125. _this.REFLECTIONMAP_SKYBOX = false;
  68126. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  68127. _this.REFLECTIONMAP_EXPLICIT = false;
  68128. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  68129. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  68130. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  68131. _this.INVERTCUBICMAP = false;
  68132. _this.LOGARITHMICDEPTH = false;
  68133. _this.REFRACTION = false;
  68134. _this.REFRACTIONMAP_3D = false;
  68135. _this.REFLECTIONOVERALPHA = false;
  68136. _this.TWOSIDEDLIGHTING = false;
  68137. _this.SHADOWFLOAT = false;
  68138. _this.MORPHTARGETS = false;
  68139. _this.MORPHTARGETS_NORMAL = false;
  68140. _this.MORPHTARGETS_TANGENT = false;
  68141. _this.NUM_MORPH_INFLUENCERS = 0;
  68142. _this.NONUNIFORMSCALING = false; // https://playground.babylonjs.com#V6DWIH
  68143. _this.PREMULTIPLYALPHA = false; // https://playground.babylonjs.com#LNVJJ7
  68144. _this.IMAGEPROCESSING = false;
  68145. _this.VIGNETTE = false;
  68146. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  68147. _this.VIGNETTEBLENDMODEOPAQUE = false;
  68148. _this.TONEMAPPING = false;
  68149. _this.TONEMAPPING_ACES = false;
  68150. _this.CONTRAST = false;
  68151. _this.COLORCURVES = false;
  68152. _this.COLORGRADING = false;
  68153. _this.COLORGRADING3D = false;
  68154. _this.SAMPLER3DGREENDEPTH = false;
  68155. _this.SAMPLER3DBGRMAP = false;
  68156. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  68157. _this.MULTIVIEW = false;
  68158. /**
  68159. * If the reflection texture on this material is in linear color space
  68160. * @hidden
  68161. */
  68162. _this.IS_REFLECTION_LINEAR = false;
  68163. /**
  68164. * If the refraction texture on this material is in linear color space
  68165. * @hidden
  68166. */
  68167. _this.IS_REFRACTION_LINEAR = false;
  68168. _this.EXPOSURE = false;
  68169. _this.rebuild();
  68170. return _this;
  68171. }
  68172. StandardMaterialDefines.prototype.setReflectionMode = function (modeToEnable) {
  68173. var modes = [
  68174. "REFLECTIONMAP_CUBIC", "REFLECTIONMAP_EXPLICIT", "REFLECTIONMAP_PLANAR",
  68175. "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_SKYBOX",
  68176. "REFLECTIONMAP_SPHERICAL", "REFLECTIONMAP_EQUIRECTANGULAR", "REFLECTIONMAP_EQUIRECTANGULAR_FIXED",
  68177. "REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"
  68178. ];
  68179. for (var _i = 0, modes_1 = modes; _i < modes_1.length; _i++) {
  68180. var mode = modes_1[_i];
  68181. this[mode] = (mode === modeToEnable);
  68182. }
  68183. };
  68184. return StandardMaterialDefines;
  68185. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  68186. /**
  68187. * This is the default material used in Babylon. It is the best trade off between quality
  68188. * and performances.
  68189. * @see http://doc.babylonjs.com/babylon101/materials
  68190. */
  68191. var StandardMaterial = /** @class */ (function (_super) {
  68192. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterial, _super);
  68193. /**
  68194. * Instantiates a new standard material.
  68195. * This is the default material used in Babylon. It is the best trade off between quality
  68196. * and performances.
  68197. * @see http://doc.babylonjs.com/babylon101/materials
  68198. * @param name Define the name of the material in the scene
  68199. * @param scene Define the scene the material belong to
  68200. */
  68201. function StandardMaterial(name, scene) {
  68202. var _this = _super.call(this, name, scene) || this;
  68203. /**
  68204. * The color of the material lit by the environmental background lighting.
  68205. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  68206. */
  68207. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  68208. /**
  68209. * The basic color of the material as viewed under a light.
  68210. */
  68211. _this.diffuseColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  68212. /**
  68213. * Define how the color and intensity of the highlight given by the light in the material.
  68214. */
  68215. _this.specularColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  68216. /**
  68217. * Define the color of the material as if self lit.
  68218. * This will be mixed in the final result even in the absence of light.
  68219. */
  68220. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  68221. /**
  68222. * Defines how sharp are the highlights in the material.
  68223. * The bigger the value the sharper giving a more glossy feeling to the result.
  68224. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  68225. */
  68226. _this.specularPower = 64;
  68227. _this._useAlphaFromDiffuseTexture = false;
  68228. _this._useEmissiveAsIllumination = false;
  68229. _this._linkEmissiveWithDiffuse = false;
  68230. _this._useSpecularOverAlpha = false;
  68231. _this._useReflectionOverAlpha = false;
  68232. _this._disableLighting = false;
  68233. _this._useObjectSpaceNormalMap = false;
  68234. _this._useParallax = false;
  68235. _this._useParallaxOcclusion = false;
  68236. /**
  68237. * 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.
  68238. */
  68239. _this.parallaxScaleBias = 0.05;
  68240. _this._roughness = 0;
  68241. /**
  68242. * In case of refraction, define the value of the indice of refraction.
  68243. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  68244. */
  68245. _this.indexOfRefraction = 0.98;
  68246. /**
  68247. * Invert the refraction texture alongside the y axis.
  68248. * It can be useful with procedural textures or probe for instance.
  68249. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  68250. */
  68251. _this.invertRefractionY = true;
  68252. /**
  68253. * Defines the alpha limits in alpha test mode.
  68254. */
  68255. _this.alphaCutOff = 0.4;
  68256. _this._useLightmapAsShadowmap = false;
  68257. _this._useReflectionFresnelFromSpecular = false;
  68258. _this._useGlossinessFromSpecularMapAlpha = false;
  68259. _this._maxSimultaneousLights = 4;
  68260. _this._invertNormalMapX = false;
  68261. _this._invertNormalMapY = false;
  68262. _this._twoSidedLighting = false;
  68263. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  68264. _this._worldViewProjectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  68265. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  68266. // Setup the default processing configuration to the scene.
  68267. _this._attachImageProcessingConfiguration(null);
  68268. _this.getRenderTargetTextures = function () {
  68269. _this._renderTargets.reset();
  68270. if (StandardMaterial.ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  68271. _this._renderTargets.push(_this._reflectionTexture);
  68272. }
  68273. if (StandardMaterial.RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  68274. _this._renderTargets.push(_this._refractionTexture);
  68275. }
  68276. return _this._renderTargets;
  68277. };
  68278. return _this;
  68279. }
  68280. Object.defineProperty(StandardMaterial.prototype, "imageProcessingConfiguration", {
  68281. /**
  68282. * Gets the image processing configuration used either in this material.
  68283. */
  68284. get: function () {
  68285. return this._imageProcessingConfiguration;
  68286. },
  68287. /**
  68288. * Sets the Default image processing configuration used either in the this material.
  68289. *
  68290. * If sets to null, the scene one is in use.
  68291. */
  68292. set: function (value) {
  68293. this._attachImageProcessingConfiguration(value);
  68294. // Ensure the effect will be rebuilt.
  68295. this._markAllSubMeshesAsTexturesDirty();
  68296. },
  68297. enumerable: true,
  68298. configurable: true
  68299. });
  68300. /**
  68301. * Attaches a new image processing configuration to the Standard Material.
  68302. * @param configuration
  68303. */
  68304. StandardMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  68305. var _this = this;
  68306. if (configuration === this._imageProcessingConfiguration) {
  68307. return;
  68308. }
  68309. // Detaches observer.
  68310. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  68311. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  68312. }
  68313. // Pick the scene configuration if needed.
  68314. if (!configuration) {
  68315. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  68316. }
  68317. else {
  68318. this._imageProcessingConfiguration = configuration;
  68319. }
  68320. // Attaches observer.
  68321. if (this._imageProcessingConfiguration) {
  68322. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  68323. _this._markAllSubMeshesAsImageProcessingDirty();
  68324. });
  68325. }
  68326. };
  68327. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurvesEnabled", {
  68328. /**
  68329. * Gets wether the color curves effect is enabled.
  68330. */
  68331. get: function () {
  68332. return this.imageProcessingConfiguration.colorCurvesEnabled;
  68333. },
  68334. /**
  68335. * Sets wether the color curves effect is enabled.
  68336. */
  68337. set: function (value) {
  68338. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  68339. },
  68340. enumerable: true,
  68341. configurable: true
  68342. });
  68343. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingEnabled", {
  68344. /**
  68345. * Gets wether the color grading effect is enabled.
  68346. */
  68347. get: function () {
  68348. return this.imageProcessingConfiguration.colorGradingEnabled;
  68349. },
  68350. /**
  68351. * Gets wether the color grading effect is enabled.
  68352. */
  68353. set: function (value) {
  68354. this.imageProcessingConfiguration.colorGradingEnabled = value;
  68355. },
  68356. enumerable: true,
  68357. configurable: true
  68358. });
  68359. Object.defineProperty(StandardMaterial.prototype, "cameraToneMappingEnabled", {
  68360. /**
  68361. * Gets wether tonemapping is enabled or not.
  68362. */
  68363. get: function () {
  68364. return this._imageProcessingConfiguration.toneMappingEnabled;
  68365. },
  68366. /**
  68367. * Sets wether tonemapping is enabled or not
  68368. */
  68369. set: function (value) {
  68370. this._imageProcessingConfiguration.toneMappingEnabled = value;
  68371. },
  68372. enumerable: true,
  68373. configurable: true
  68374. });
  68375. Object.defineProperty(StandardMaterial.prototype, "cameraExposure", {
  68376. /**
  68377. * The camera exposure used on this material.
  68378. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  68379. * This corresponds to a photographic exposure.
  68380. */
  68381. get: function () {
  68382. return this._imageProcessingConfiguration.exposure;
  68383. },
  68384. /**
  68385. * The camera exposure used on this material.
  68386. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  68387. * This corresponds to a photographic exposure.
  68388. */
  68389. set: function (value) {
  68390. this._imageProcessingConfiguration.exposure = value;
  68391. },
  68392. enumerable: true,
  68393. configurable: true
  68394. });
  68395. Object.defineProperty(StandardMaterial.prototype, "cameraContrast", {
  68396. /**
  68397. * Gets The camera contrast used on this material.
  68398. */
  68399. get: function () {
  68400. return this._imageProcessingConfiguration.contrast;
  68401. },
  68402. /**
  68403. * Sets The camera contrast used on this material.
  68404. */
  68405. set: function (value) {
  68406. this._imageProcessingConfiguration.contrast = value;
  68407. },
  68408. enumerable: true,
  68409. configurable: true
  68410. });
  68411. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingTexture", {
  68412. /**
  68413. * Gets the Color Grading 2D Lookup Texture.
  68414. */
  68415. get: function () {
  68416. return this._imageProcessingConfiguration.colorGradingTexture;
  68417. },
  68418. /**
  68419. * Sets the Color Grading 2D Lookup Texture.
  68420. */
  68421. set: function (value) {
  68422. this._imageProcessingConfiguration.colorGradingTexture = value;
  68423. },
  68424. enumerable: true,
  68425. configurable: true
  68426. });
  68427. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurves", {
  68428. /**
  68429. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  68430. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  68431. * 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;
  68432. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  68433. */
  68434. get: function () {
  68435. return this._imageProcessingConfiguration.colorCurves;
  68436. },
  68437. /**
  68438. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  68439. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  68440. * 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;
  68441. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  68442. */
  68443. set: function (value) {
  68444. this._imageProcessingConfiguration.colorCurves = value;
  68445. },
  68446. enumerable: true,
  68447. configurable: true
  68448. });
  68449. Object.defineProperty(StandardMaterial.prototype, "hasRenderTargetTextures", {
  68450. /**
  68451. * Gets a boolean indicating that current material needs to register RTT
  68452. */
  68453. get: function () {
  68454. if (StandardMaterial.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  68455. return true;
  68456. }
  68457. if (StandardMaterial.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  68458. return true;
  68459. }
  68460. return false;
  68461. },
  68462. enumerable: true,
  68463. configurable: true
  68464. });
  68465. /**
  68466. * Gets the current class name of the material e.g. "StandardMaterial"
  68467. * Mainly use in serialization.
  68468. * @returns the class name
  68469. */
  68470. StandardMaterial.prototype.getClassName = function () {
  68471. return "StandardMaterial";
  68472. };
  68473. Object.defineProperty(StandardMaterial.prototype, "useLogarithmicDepth", {
  68474. /**
  68475. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  68476. * You can try switching to logarithmic depth.
  68477. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  68478. */
  68479. get: function () {
  68480. return this._useLogarithmicDepth;
  68481. },
  68482. set: function (value) {
  68483. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  68484. this._markAllSubMeshesAsMiscDirty();
  68485. },
  68486. enumerable: true,
  68487. configurable: true
  68488. });
  68489. /**
  68490. * Specifies if the material will require alpha blending
  68491. * @returns a boolean specifying if alpha blending is needed
  68492. */
  68493. StandardMaterial.prototype.needAlphaBlending = function () {
  68494. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled;
  68495. };
  68496. /**
  68497. * Specifies if this material should be rendered in alpha test mode
  68498. * @returns a boolean specifying if an alpha test is needed.
  68499. */
  68500. StandardMaterial.prototype.needAlphaTesting = function () {
  68501. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha;
  68502. };
  68503. StandardMaterial.prototype._shouldUseAlphaFromDiffuseTexture = function () {
  68504. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture;
  68505. };
  68506. /**
  68507. * Get the texture used for alpha test purpose.
  68508. * @returns the diffuse texture in case of the standard material.
  68509. */
  68510. StandardMaterial.prototype.getAlphaTestTexture = function () {
  68511. return this._diffuseTexture;
  68512. };
  68513. /**
  68514. * Get if the submesh is ready to be used and all its information available.
  68515. * Child classes can use it to update shaders
  68516. * @param mesh defines the mesh to check
  68517. * @param subMesh defines which submesh to check
  68518. * @param useInstances specifies that instances should be used
  68519. * @returns a boolean indicating that the submesh is ready or not
  68520. */
  68521. StandardMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  68522. if (useInstances === void 0) { useInstances = false; }
  68523. if (subMesh.effect && this.isFrozen) {
  68524. if (this._wasPreviouslyReady) {
  68525. return true;
  68526. }
  68527. }
  68528. if (!subMesh._materialDefines) {
  68529. subMesh._materialDefines = new StandardMaterialDefines();
  68530. }
  68531. var scene = this.getScene();
  68532. var defines = subMesh._materialDefines;
  68533. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  68534. if (defines._renderId === scene.getRenderId()) {
  68535. return true;
  68536. }
  68537. }
  68538. var engine = scene.getEngine();
  68539. // Lights
  68540. defines._needNormals = _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  68541. // Multiview
  68542. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMultiview(scene, defines);
  68543. // Textures
  68544. if (defines._areTexturesDirty) {
  68545. defines._needUVs = false;
  68546. defines.MAINUV1 = false;
  68547. defines.MAINUV2 = false;
  68548. if (scene.texturesEnabled) {
  68549. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  68550. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  68551. return false;
  68552. }
  68553. else {
  68554. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  68555. }
  68556. }
  68557. else {
  68558. defines.DIFFUSE = false;
  68559. }
  68560. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  68561. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  68562. return false;
  68563. }
  68564. else {
  68565. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  68566. }
  68567. }
  68568. else {
  68569. defines.AMBIENT = false;
  68570. }
  68571. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  68572. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  68573. return false;
  68574. }
  68575. else {
  68576. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  68577. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  68578. }
  68579. }
  68580. else {
  68581. defines.OPACITY = false;
  68582. }
  68583. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  68584. if (!this._reflectionTexture.isReadyOrNotBlocking()) {
  68585. return false;
  68586. }
  68587. else {
  68588. defines._needNormals = true;
  68589. defines.REFLECTION = true;
  68590. defines.ROUGHNESS = (this._roughness > 0);
  68591. defines.REFLECTIONOVERALPHA = this._useReflectionOverAlpha;
  68592. defines.INVERTCUBICMAP = (this._reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE);
  68593. defines.REFLECTIONMAP_3D = this._reflectionTexture.isCube;
  68594. switch (this._reflectionTexture.coordinatesMode) {
  68595. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  68596. defines.setReflectionMode("REFLECTIONMAP_EXPLICIT");
  68597. break;
  68598. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  68599. defines.setReflectionMode("REFLECTIONMAP_PLANAR");
  68600. break;
  68601. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  68602. defines.setReflectionMode("REFLECTIONMAP_PROJECTION");
  68603. break;
  68604. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  68605. defines.setReflectionMode("REFLECTIONMAP_SKYBOX");
  68606. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !this._reflectionTexture.getReflectionTextureMatrix().isIdentity();
  68607. break;
  68608. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  68609. defines.setReflectionMode("REFLECTIONMAP_SPHERICAL");
  68610. break;
  68611. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  68612. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");
  68613. break;
  68614. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  68615. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
  68616. break;
  68617. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  68618. defines.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
  68619. break;
  68620. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  68621. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  68622. default:
  68623. defines.setReflectionMode("REFLECTIONMAP_CUBIC");
  68624. break;
  68625. }
  68626. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = this._reflectionTexture.boundingBoxSize ? true : false;
  68627. }
  68628. }
  68629. else {
  68630. defines.REFLECTION = false;
  68631. }
  68632. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  68633. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  68634. return false;
  68635. }
  68636. else {
  68637. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  68638. }
  68639. }
  68640. else {
  68641. defines.EMISSIVE = false;
  68642. }
  68643. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  68644. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  68645. return false;
  68646. }
  68647. else {
  68648. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  68649. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  68650. }
  68651. }
  68652. else {
  68653. defines.LIGHTMAP = false;
  68654. }
  68655. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  68656. if (!this._specularTexture.isReadyOrNotBlocking()) {
  68657. return false;
  68658. }
  68659. else {
  68660. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._specularTexture, defines, "SPECULAR");
  68661. defines.GLOSSINESS = this._useGlossinessFromSpecularMapAlpha;
  68662. }
  68663. }
  68664. else {
  68665. defines.SPECULAR = false;
  68666. }
  68667. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && StandardMaterial.BumpTextureEnabled) {
  68668. // Bump texure can not be not blocking.
  68669. if (!this._bumpTexture.isReady()) {
  68670. return false;
  68671. }
  68672. else {
  68673. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  68674. defines.PARALLAX = this._useParallax;
  68675. defines.PARALLAXOCCLUSION = this._useParallaxOcclusion;
  68676. }
  68677. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  68678. }
  68679. else {
  68680. defines.BUMP = false;
  68681. }
  68682. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  68683. if (!this._refractionTexture.isReadyOrNotBlocking()) {
  68684. return false;
  68685. }
  68686. else {
  68687. defines._needUVs = true;
  68688. defines.REFRACTION = true;
  68689. defines.REFRACTIONMAP_3D = this._refractionTexture.isCube;
  68690. }
  68691. }
  68692. else {
  68693. defines.REFRACTION = false;
  68694. }
  68695. defines.TWOSIDEDLIGHTING = !this._backFaceCulling && this._twoSidedLighting;
  68696. }
  68697. else {
  68698. defines.DIFFUSE = false;
  68699. defines.AMBIENT = false;
  68700. defines.OPACITY = false;
  68701. defines.REFLECTION = false;
  68702. defines.EMISSIVE = false;
  68703. defines.LIGHTMAP = false;
  68704. defines.BUMP = false;
  68705. defines.REFRACTION = false;
  68706. }
  68707. defines.ALPHAFROMDIFFUSE = this._shouldUseAlphaFromDiffuseTexture();
  68708. defines.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination;
  68709. defines.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse;
  68710. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  68711. 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);
  68712. }
  68713. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  68714. if (!this._imageProcessingConfiguration.isReady()) {
  68715. return false;
  68716. }
  68717. this._imageProcessingConfiguration.prepareDefines(defines);
  68718. defines.IS_REFLECTION_LINEAR = (this.reflectionTexture != null && !this.reflectionTexture.gammaSpace);
  68719. defines.IS_REFRACTION_LINEAR = (this.refractionTexture != null && !this.refractionTexture.gammaSpace);
  68720. }
  68721. if (defines._areFresnelDirty) {
  68722. if (StandardMaterial.FresnelEnabled) {
  68723. // Fresnel
  68724. if (this._diffuseFresnelParameters || this._opacityFresnelParameters ||
  68725. this._emissiveFresnelParameters || this._refractionFresnelParameters ||
  68726. this._reflectionFresnelParameters) {
  68727. defines.DIFFUSEFRESNEL = (this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled);
  68728. defines.OPACITYFRESNEL = (this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled);
  68729. defines.REFLECTIONFRESNEL = (this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled);
  68730. defines.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular;
  68731. defines.REFRACTIONFRESNEL = (this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled);
  68732. defines.EMISSIVEFRESNEL = (this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled);
  68733. defines._needNormals = true;
  68734. defines.FRESNEL = true;
  68735. }
  68736. }
  68737. else {
  68738. defines.FRESNEL = false;
  68739. }
  68740. }
  68741. // Misc.
  68742. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  68743. // Attribs
  68744. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true);
  68745. // Values that need to be evaluated on every frame
  68746. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  68747. // Get correct effect
  68748. if (defines.isDirty) {
  68749. defines.markAsProcessed();
  68750. // Fallbacks
  68751. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_7__["EffectFallbacks"]();
  68752. if (defines.REFLECTION) {
  68753. fallbacks.addFallback(0, "REFLECTION");
  68754. }
  68755. if (defines.SPECULAR) {
  68756. fallbacks.addFallback(0, "SPECULAR");
  68757. }
  68758. if (defines.BUMP) {
  68759. fallbacks.addFallback(0, "BUMP");
  68760. }
  68761. if (defines.PARALLAX) {
  68762. fallbacks.addFallback(1, "PARALLAX");
  68763. }
  68764. if (defines.PARALLAXOCCLUSION) {
  68765. fallbacks.addFallback(0, "PARALLAXOCCLUSION");
  68766. }
  68767. if (defines.SPECULAROVERALPHA) {
  68768. fallbacks.addFallback(0, "SPECULAROVERALPHA");
  68769. }
  68770. if (defines.FOG) {
  68771. fallbacks.addFallback(1, "FOG");
  68772. }
  68773. if (defines.POINTSIZE) {
  68774. fallbacks.addFallback(0, "POINTSIZE");
  68775. }
  68776. if (defines.LOGARITHMICDEPTH) {
  68777. fallbacks.addFallback(0, "LOGARITHMICDEPTH");
  68778. }
  68779. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  68780. if (defines.SPECULARTERM) {
  68781. fallbacks.addFallback(0, "SPECULARTERM");
  68782. }
  68783. if (defines.DIFFUSEFRESNEL) {
  68784. fallbacks.addFallback(1, "DIFFUSEFRESNEL");
  68785. }
  68786. if (defines.OPACITYFRESNEL) {
  68787. fallbacks.addFallback(2, "OPACITYFRESNEL");
  68788. }
  68789. if (defines.REFLECTIONFRESNEL) {
  68790. fallbacks.addFallback(3, "REFLECTIONFRESNEL");
  68791. }
  68792. if (defines.EMISSIVEFRESNEL) {
  68793. fallbacks.addFallback(4, "EMISSIVEFRESNEL");
  68794. }
  68795. if (defines.FRESNEL) {
  68796. fallbacks.addFallback(4, "FRESNEL");
  68797. }
  68798. if (defines.MULTIVIEW) {
  68799. fallbacks.addFallback(0, "MULTIVIEW");
  68800. }
  68801. //Attributes
  68802. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  68803. if (defines.NORMAL) {
  68804. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  68805. }
  68806. if (defines.UV1) {
  68807. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  68808. }
  68809. if (defines.UV2) {
  68810. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  68811. }
  68812. if (defines.VERTEXCOLOR) {
  68813. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind);
  68814. }
  68815. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  68816. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  68817. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  68818. var shaderName = "default";
  68819. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor", "visibility",
  68820. "vFogInfos", "vFogColor", "pointSize",
  68821. "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  68822. "mBones",
  68823. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "normalMatrix", "lightmapMatrix", "refractionMatrix",
  68824. "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
  68825. "vReflectionPosition", "vReflectionSize",
  68826. "logarithmicDepthConstant", "vTangentSpaceParams", "alphaCutOff", "boneTextureWidth"
  68827. ];
  68828. var samplers = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler",
  68829. "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler",
  68830. "refractionCubeSampler", "refraction2DSampler", "boneSampler"];
  68831. var uniformBuffers = ["Material", "Scene"];
  68832. if (_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"]) {
  68833. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  68834. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  68835. }
  68836. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareUniformsAndSamplersList({
  68837. uniformsNames: uniforms,
  68838. uniformBuffersNames: uniformBuffers,
  68839. samplers: samplers,
  68840. defines: defines,
  68841. maxSimultaneousLights: this._maxSimultaneousLights
  68842. });
  68843. if (this.customShaderNameResolve) {
  68844. shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines);
  68845. }
  68846. var join = defines.toString();
  68847. var previousEffect = subMesh.effect;
  68848. var effect = scene.getEngine().createEffect(shaderName, {
  68849. attributes: attribs,
  68850. uniformsNames: uniforms,
  68851. uniformBuffersNames: uniformBuffers,
  68852. samplers: samplers,
  68853. defines: join,
  68854. fallbacks: fallbacks,
  68855. onCompiled: this.onCompiled,
  68856. onError: this.onError,
  68857. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  68858. }, engine);
  68859. if (effect) {
  68860. // Use previous effect while new one is compiling
  68861. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  68862. effect = previousEffect;
  68863. defines.markAsUnprocessed();
  68864. }
  68865. else {
  68866. scene.resetCachedMaterial();
  68867. subMesh.setEffect(effect, defines);
  68868. this.buildUniformLayout();
  68869. }
  68870. }
  68871. }
  68872. if (!subMesh.effect || !subMesh.effect.isReady()) {
  68873. return false;
  68874. }
  68875. defines._renderId = scene.getRenderId();
  68876. this._wasPreviouslyReady = true;
  68877. return true;
  68878. };
  68879. /**
  68880. * Builds the material UBO layouts.
  68881. * Used internally during the effect preparation.
  68882. */
  68883. StandardMaterial.prototype.buildUniformLayout = function () {
  68884. // Order is important !
  68885. this._uniformBuffer.addUniform("diffuseLeftColor", 4);
  68886. this._uniformBuffer.addUniform("diffuseRightColor", 4);
  68887. this._uniformBuffer.addUniform("opacityParts", 4);
  68888. this._uniformBuffer.addUniform("reflectionLeftColor", 4);
  68889. this._uniformBuffer.addUniform("reflectionRightColor", 4);
  68890. this._uniformBuffer.addUniform("refractionLeftColor", 4);
  68891. this._uniformBuffer.addUniform("refractionRightColor", 4);
  68892. this._uniformBuffer.addUniform("emissiveLeftColor", 4);
  68893. this._uniformBuffer.addUniform("emissiveRightColor", 4);
  68894. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  68895. this._uniformBuffer.addUniform("vAmbientInfos", 2);
  68896. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  68897. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  68898. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  68899. this._uniformBuffer.addUniform("vReflectionSize", 3);
  68900. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  68901. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  68902. this._uniformBuffer.addUniform("vSpecularInfos", 2);
  68903. this._uniformBuffer.addUniform("vBumpInfos", 3);
  68904. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  68905. this._uniformBuffer.addUniform("ambientMatrix", 16);
  68906. this._uniformBuffer.addUniform("opacityMatrix", 16);
  68907. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  68908. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  68909. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  68910. this._uniformBuffer.addUniform("specularMatrix", 16);
  68911. this._uniformBuffer.addUniform("bumpMatrix", 16);
  68912. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  68913. this._uniformBuffer.addUniform("pointSize", 1);
  68914. this._uniformBuffer.addUniform("refractionMatrix", 16);
  68915. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  68916. this._uniformBuffer.addUniform("vSpecularColor", 4);
  68917. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  68918. this._uniformBuffer.addUniform("visibility", 1);
  68919. this._uniformBuffer.addUniform("vDiffuseColor", 4);
  68920. this._uniformBuffer.create();
  68921. };
  68922. /**
  68923. * Unbinds the material from the mesh
  68924. */
  68925. StandardMaterial.prototype.unbind = function () {
  68926. if (this._activeEffect) {
  68927. var needFlag = false;
  68928. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  68929. this._activeEffect.setTexture("reflection2DSampler", null);
  68930. needFlag = true;
  68931. }
  68932. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  68933. this._activeEffect.setTexture("refraction2DSampler", null);
  68934. needFlag = true;
  68935. }
  68936. if (needFlag) {
  68937. this._markAllSubMeshesAsTexturesDirty();
  68938. }
  68939. }
  68940. _super.prototype.unbind.call(this);
  68941. };
  68942. /**
  68943. * Binds the submesh to this material by preparing the effect and shader to draw
  68944. * @param world defines the world transformation matrix
  68945. * @param mesh defines the mesh containing the submesh
  68946. * @param subMesh defines the submesh to bind the material to
  68947. */
  68948. StandardMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  68949. var scene = this.getScene();
  68950. var defines = subMesh._materialDefines;
  68951. if (!defines) {
  68952. return;
  68953. }
  68954. var effect = subMesh.effect;
  68955. if (!effect) {
  68956. return;
  68957. }
  68958. this._activeEffect = effect;
  68959. // Matrices
  68960. this.bindOnlyWorldMatrix(world);
  68961. // Normal Matrix
  68962. if (defines.OBJECTSPACE_NORMALMAP) {
  68963. world.toNormalMatrix(this._normalMatrix);
  68964. this.bindOnlyNormalMatrix(this._normalMatrix);
  68965. }
  68966. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  68967. // Bones
  68968. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindBonesParameters(mesh, effect);
  68969. if (mustRebind) {
  68970. this._uniformBuffer.bindToEffect(effect, "Material");
  68971. this.bindViewProjection(effect);
  68972. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  68973. if (StandardMaterial.FresnelEnabled && defines.FRESNEL) {
  68974. // Fresnel
  68975. if (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled) {
  68976. this._uniformBuffer.updateColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power);
  68977. this._uniformBuffer.updateColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias);
  68978. }
  68979. if (this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled) {
  68980. 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);
  68981. }
  68982. if (this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled) {
  68983. this._uniformBuffer.updateColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power);
  68984. this._uniformBuffer.updateColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias);
  68985. }
  68986. if (this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled) {
  68987. this._uniformBuffer.updateColor4("refractionLeftColor", this.refractionFresnelParameters.leftColor, this.refractionFresnelParameters.power);
  68988. this._uniformBuffer.updateColor4("refractionRightColor", this.refractionFresnelParameters.rightColor, this.refractionFresnelParameters.bias);
  68989. }
  68990. if (this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled) {
  68991. this._uniformBuffer.updateColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power);
  68992. this._uniformBuffer.updateColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias);
  68993. }
  68994. }
  68995. // Textures
  68996. if (scene.texturesEnabled) {
  68997. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  68998. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  68999. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  69000. if (this._diffuseTexture.hasAlpha) {
  69001. effect.setFloat("alphaCutOff", this.alphaCutOff);
  69002. }
  69003. }
  69004. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  69005. this._uniformBuffer.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level);
  69006. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  69007. }
  69008. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  69009. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  69010. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  69011. }
  69012. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  69013. this._uniformBuffer.updateFloat2("vReflectionInfos", this._reflectionTexture.level, this.roughness);
  69014. this._uniformBuffer.updateMatrix("reflectionMatrix", this._reflectionTexture.getReflectionTextureMatrix());
  69015. if (this._reflectionTexture.boundingBoxSize) {
  69016. var cubeTexture = this._reflectionTexture;
  69017. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  69018. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  69019. }
  69020. }
  69021. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  69022. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  69023. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  69024. }
  69025. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  69026. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  69027. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  69028. }
  69029. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  69030. this._uniformBuffer.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level);
  69031. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._specularTexture, this._uniformBuffer, "specular");
  69032. }
  69033. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  69034. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1.0 / this._bumpTexture.level, this.parallaxScaleBias);
  69035. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  69036. if (scene._mirroredCameraPosition) {
  69037. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  69038. }
  69039. else {
  69040. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  69041. }
  69042. }
  69043. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  69044. var depth = 1.0;
  69045. if (!this._refractionTexture.isCube) {
  69046. this._uniformBuffer.updateMatrix("refractionMatrix", this._refractionTexture.getReflectionTextureMatrix());
  69047. if (this._refractionTexture.depth) {
  69048. depth = this._refractionTexture.depth;
  69049. }
  69050. }
  69051. this._uniformBuffer.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, depth, this.invertRefractionY ? -1 : 1);
  69052. }
  69053. }
  69054. // Point size
  69055. if (this.pointsCloud) {
  69056. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  69057. }
  69058. if (defines.SPECULARTERM) {
  69059. this._uniformBuffer.updateColor4("vSpecularColor", this.specularColor, this.specularPower);
  69060. }
  69061. this._uniformBuffer.updateColor3("vEmissiveColor", StandardMaterial.EmissiveTextureEnabled ? this.emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].BlackReadOnly);
  69062. // Visibility
  69063. this._uniformBuffer.updateFloat("visibility", mesh.visibility);
  69064. // Diffuse
  69065. this._uniformBuffer.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha);
  69066. }
  69067. // Textures
  69068. if (scene.texturesEnabled) {
  69069. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  69070. effect.setTexture("diffuseSampler", this._diffuseTexture);
  69071. }
  69072. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  69073. effect.setTexture("ambientSampler", this._ambientTexture);
  69074. }
  69075. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  69076. effect.setTexture("opacitySampler", this._opacityTexture);
  69077. }
  69078. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  69079. if (this._reflectionTexture.isCube) {
  69080. effect.setTexture("reflectionCubeSampler", this._reflectionTexture);
  69081. }
  69082. else {
  69083. effect.setTexture("reflection2DSampler", this._reflectionTexture);
  69084. }
  69085. }
  69086. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  69087. effect.setTexture("emissiveSampler", this._emissiveTexture);
  69088. }
  69089. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  69090. effect.setTexture("lightmapSampler", this._lightmapTexture);
  69091. }
  69092. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  69093. effect.setTexture("specularSampler", this._specularTexture);
  69094. }
  69095. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  69096. effect.setTexture("bumpSampler", this._bumpTexture);
  69097. }
  69098. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  69099. var depth = 1.0;
  69100. if (this._refractionTexture.isCube) {
  69101. effect.setTexture("refractionCubeSampler", this._refractionTexture);
  69102. }
  69103. else {
  69104. effect.setTexture("refraction2DSampler", this._refractionTexture);
  69105. }
  69106. }
  69107. }
  69108. // Clip plane
  69109. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindClipPlane(effect, scene);
  69110. // Colors
  69111. scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
  69112. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindEyePosition(effect, scene);
  69113. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  69114. }
  69115. if (mustRebind || !this.isFrozen) {
  69116. // Lights
  69117. if (scene.lightsEnabled && !this._disableLighting) {
  69118. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLights(scene, mesh, effect, defines, this._maxSimultaneousLights);
  69119. }
  69120. // View
  69121. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].FOGMODE_NONE || this._reflectionTexture || this._refractionTexture) {
  69122. this.bindView(effect);
  69123. }
  69124. // Fog
  69125. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindFogParameters(scene, mesh, effect);
  69126. // Morph targets
  69127. if (defines.NUM_MORPH_INFLUENCERS) {
  69128. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, effect);
  69129. }
  69130. // Log. depth
  69131. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLogDepth(defines, effect, scene);
  69132. // image processing
  69133. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  69134. this._imageProcessingConfiguration.bind(this._activeEffect);
  69135. }
  69136. }
  69137. this._uniformBuffer.update();
  69138. this._afterBind(mesh, this._activeEffect);
  69139. };
  69140. /**
  69141. * Get the list of animatables in the material.
  69142. * @returns the list of animatables object used in the material
  69143. */
  69144. StandardMaterial.prototype.getAnimatables = function () {
  69145. var results = [];
  69146. if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
  69147. results.push(this._diffuseTexture);
  69148. }
  69149. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  69150. results.push(this._ambientTexture);
  69151. }
  69152. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  69153. results.push(this._opacityTexture);
  69154. }
  69155. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  69156. results.push(this._reflectionTexture);
  69157. }
  69158. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  69159. results.push(this._emissiveTexture);
  69160. }
  69161. if (this._specularTexture && this._specularTexture.animations && this._specularTexture.animations.length > 0) {
  69162. results.push(this._specularTexture);
  69163. }
  69164. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  69165. results.push(this._bumpTexture);
  69166. }
  69167. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  69168. results.push(this._lightmapTexture);
  69169. }
  69170. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  69171. results.push(this._refractionTexture);
  69172. }
  69173. return results;
  69174. };
  69175. /**
  69176. * Gets the active textures from the material
  69177. * @returns an array of textures
  69178. */
  69179. StandardMaterial.prototype.getActiveTextures = function () {
  69180. var activeTextures = _super.prototype.getActiveTextures.call(this);
  69181. if (this._diffuseTexture) {
  69182. activeTextures.push(this._diffuseTexture);
  69183. }
  69184. if (this._ambientTexture) {
  69185. activeTextures.push(this._ambientTexture);
  69186. }
  69187. if (this._opacityTexture) {
  69188. activeTextures.push(this._opacityTexture);
  69189. }
  69190. if (this._reflectionTexture) {
  69191. activeTextures.push(this._reflectionTexture);
  69192. }
  69193. if (this._emissiveTexture) {
  69194. activeTextures.push(this._emissiveTexture);
  69195. }
  69196. if (this._specularTexture) {
  69197. activeTextures.push(this._specularTexture);
  69198. }
  69199. if (this._bumpTexture) {
  69200. activeTextures.push(this._bumpTexture);
  69201. }
  69202. if (this._lightmapTexture) {
  69203. activeTextures.push(this._lightmapTexture);
  69204. }
  69205. if (this._refractionTexture) {
  69206. activeTextures.push(this._refractionTexture);
  69207. }
  69208. return activeTextures;
  69209. };
  69210. /**
  69211. * Specifies if the material uses a texture
  69212. * @param texture defines the texture to check against the material
  69213. * @returns a boolean specifying if the material uses the texture
  69214. */
  69215. StandardMaterial.prototype.hasTexture = function (texture) {
  69216. if (_super.prototype.hasTexture.call(this, texture)) {
  69217. return true;
  69218. }
  69219. if (this._diffuseTexture === texture) {
  69220. return true;
  69221. }
  69222. if (this._ambientTexture === texture) {
  69223. return true;
  69224. }
  69225. if (this._opacityTexture === texture) {
  69226. return true;
  69227. }
  69228. if (this._reflectionTexture === texture) {
  69229. return true;
  69230. }
  69231. if (this._emissiveTexture === texture) {
  69232. return true;
  69233. }
  69234. if (this._specularTexture === texture) {
  69235. return true;
  69236. }
  69237. if (this._bumpTexture === texture) {
  69238. return true;
  69239. }
  69240. if (this._lightmapTexture === texture) {
  69241. return true;
  69242. }
  69243. if (this._refractionTexture === texture) {
  69244. return true;
  69245. }
  69246. return false;
  69247. };
  69248. /**
  69249. * Disposes the material
  69250. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  69251. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  69252. */
  69253. StandardMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  69254. if (forceDisposeTextures) {
  69255. if (this._diffuseTexture) {
  69256. this._diffuseTexture.dispose();
  69257. }
  69258. if (this._ambientTexture) {
  69259. this._ambientTexture.dispose();
  69260. }
  69261. if (this._opacityTexture) {
  69262. this._opacityTexture.dispose();
  69263. }
  69264. if (this._reflectionTexture) {
  69265. this._reflectionTexture.dispose();
  69266. }
  69267. if (this._emissiveTexture) {
  69268. this._emissiveTexture.dispose();
  69269. }
  69270. if (this._specularTexture) {
  69271. this._specularTexture.dispose();
  69272. }
  69273. if (this._bumpTexture) {
  69274. this._bumpTexture.dispose();
  69275. }
  69276. if (this._lightmapTexture) {
  69277. this._lightmapTexture.dispose();
  69278. }
  69279. if (this._refractionTexture) {
  69280. this._refractionTexture.dispose();
  69281. }
  69282. }
  69283. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  69284. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  69285. }
  69286. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  69287. };
  69288. /**
  69289. * Makes a duplicate of the material, and gives it a new name
  69290. * @param name defines the new name for the duplicated material
  69291. * @returns the cloned material
  69292. */
  69293. StandardMaterial.prototype.clone = function (name) {
  69294. var _this = this;
  69295. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new StandardMaterial(name, _this.getScene()); }, this);
  69296. result.name = name;
  69297. result.id = name;
  69298. return result;
  69299. };
  69300. /**
  69301. * Serializes this material in a JSON representation
  69302. * @returns the serialized material object
  69303. */
  69304. StandardMaterial.prototype.serialize = function () {
  69305. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  69306. };
  69307. /**
  69308. * Creates a standard material from parsed material data
  69309. * @param source defines the JSON representation of the material
  69310. * @param scene defines the hosting scene
  69311. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69312. * @returns a new standard material
  69313. */
  69314. StandardMaterial.Parse = function (source, scene, rootUrl) {
  69315. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardMaterial(source.name, scene); }, source, scene, rootUrl);
  69316. };
  69317. Object.defineProperty(StandardMaterial, "DiffuseTextureEnabled", {
  69318. // Flags used to enable or disable a type of texture for all Standard Materials
  69319. /**
  69320. * Are diffuse textures enabled in the application.
  69321. */
  69322. get: function () {
  69323. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled;
  69324. },
  69325. set: function (value) {
  69326. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled = value;
  69327. },
  69328. enumerable: true,
  69329. configurable: true
  69330. });
  69331. Object.defineProperty(StandardMaterial, "AmbientTextureEnabled", {
  69332. /**
  69333. * Are ambient textures enabled in the application.
  69334. */
  69335. get: function () {
  69336. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled;
  69337. },
  69338. set: function (value) {
  69339. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled = value;
  69340. },
  69341. enumerable: true,
  69342. configurable: true
  69343. });
  69344. Object.defineProperty(StandardMaterial, "OpacityTextureEnabled", {
  69345. /**
  69346. * Are opacity textures enabled in the application.
  69347. */
  69348. get: function () {
  69349. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled;
  69350. },
  69351. set: function (value) {
  69352. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled = value;
  69353. },
  69354. enumerable: true,
  69355. configurable: true
  69356. });
  69357. Object.defineProperty(StandardMaterial, "ReflectionTextureEnabled", {
  69358. /**
  69359. * Are reflection textures enabled in the application.
  69360. */
  69361. get: function () {
  69362. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled;
  69363. },
  69364. set: function (value) {
  69365. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled = value;
  69366. },
  69367. enumerable: true,
  69368. configurable: true
  69369. });
  69370. Object.defineProperty(StandardMaterial, "EmissiveTextureEnabled", {
  69371. /**
  69372. * Are emissive textures enabled in the application.
  69373. */
  69374. get: function () {
  69375. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled;
  69376. },
  69377. set: function (value) {
  69378. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled = value;
  69379. },
  69380. enumerable: true,
  69381. configurable: true
  69382. });
  69383. Object.defineProperty(StandardMaterial, "SpecularTextureEnabled", {
  69384. /**
  69385. * Are specular textures enabled in the application.
  69386. */
  69387. get: function () {
  69388. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled;
  69389. },
  69390. set: function (value) {
  69391. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled = value;
  69392. },
  69393. enumerable: true,
  69394. configurable: true
  69395. });
  69396. Object.defineProperty(StandardMaterial, "BumpTextureEnabled", {
  69397. /**
  69398. * Are bump textures enabled in the application.
  69399. */
  69400. get: function () {
  69401. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled;
  69402. },
  69403. set: function (value) {
  69404. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled = value;
  69405. },
  69406. enumerable: true,
  69407. configurable: true
  69408. });
  69409. Object.defineProperty(StandardMaterial, "LightmapTextureEnabled", {
  69410. /**
  69411. * Are lightmap textures enabled in the application.
  69412. */
  69413. get: function () {
  69414. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled;
  69415. },
  69416. set: function (value) {
  69417. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled = value;
  69418. },
  69419. enumerable: true,
  69420. configurable: true
  69421. });
  69422. Object.defineProperty(StandardMaterial, "RefractionTextureEnabled", {
  69423. /**
  69424. * Are refraction textures enabled in the application.
  69425. */
  69426. get: function () {
  69427. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled;
  69428. },
  69429. set: function (value) {
  69430. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled = value;
  69431. },
  69432. enumerable: true,
  69433. configurable: true
  69434. });
  69435. Object.defineProperty(StandardMaterial, "ColorGradingTextureEnabled", {
  69436. /**
  69437. * Are color grading textures enabled in the application.
  69438. */
  69439. get: function () {
  69440. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled;
  69441. },
  69442. set: function (value) {
  69443. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled = value;
  69444. },
  69445. enumerable: true,
  69446. configurable: true
  69447. });
  69448. Object.defineProperty(StandardMaterial, "FresnelEnabled", {
  69449. /**
  69450. * Are fresnels enabled in the application.
  69451. */
  69452. get: function () {
  69453. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled;
  69454. },
  69455. set: function (value) {
  69456. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled = value;
  69457. },
  69458. enumerable: true,
  69459. configurable: true
  69460. });
  69461. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69462. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture")
  69463. ], StandardMaterial.prototype, "_diffuseTexture", void 0);
  69464. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69465. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  69466. ], StandardMaterial.prototype, "diffuseTexture", void 0);
  69467. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69468. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("ambientTexture")
  69469. ], StandardMaterial.prototype, "_ambientTexture", void 0);
  69470. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69471. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69472. ], StandardMaterial.prototype, "ambientTexture", void 0);
  69473. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69474. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("opacityTexture")
  69475. ], StandardMaterial.prototype, "_opacityTexture", void 0);
  69476. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69477. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  69478. ], StandardMaterial.prototype, "opacityTexture", void 0);
  69479. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69480. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("reflectionTexture")
  69481. ], StandardMaterial.prototype, "_reflectionTexture", void 0);
  69482. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69483. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69484. ], StandardMaterial.prototype, "reflectionTexture", void 0);
  69485. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69486. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("emissiveTexture")
  69487. ], StandardMaterial.prototype, "_emissiveTexture", void 0);
  69488. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69489. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69490. ], StandardMaterial.prototype, "emissiveTexture", void 0);
  69491. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69492. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("specularTexture")
  69493. ], StandardMaterial.prototype, "_specularTexture", void 0);
  69494. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69495. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69496. ], StandardMaterial.prototype, "specularTexture", void 0);
  69497. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69498. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("bumpTexture")
  69499. ], StandardMaterial.prototype, "_bumpTexture", void 0);
  69500. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69501. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69502. ], StandardMaterial.prototype, "bumpTexture", void 0);
  69503. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69504. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lightmapTexture")
  69505. ], StandardMaterial.prototype, "_lightmapTexture", void 0);
  69506. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69507. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69508. ], StandardMaterial.prototype, "lightmapTexture", void 0);
  69509. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69510. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("refractionTexture")
  69511. ], StandardMaterial.prototype, "_refractionTexture", void 0);
  69512. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69513. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69514. ], StandardMaterial.prototype, "refractionTexture", void 0);
  69515. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69516. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient")
  69517. ], StandardMaterial.prototype, "ambientColor", void 0);
  69518. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69519. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse")
  69520. ], StandardMaterial.prototype, "diffuseColor", void 0);
  69521. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69522. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular")
  69523. ], StandardMaterial.prototype, "specularColor", void 0);
  69524. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69525. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive")
  69526. ], StandardMaterial.prototype, "emissiveColor", void 0);
  69527. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69528. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  69529. ], StandardMaterial.prototype, "specularPower", void 0);
  69530. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69531. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useAlphaFromDiffuseTexture")
  69532. ], StandardMaterial.prototype, "_useAlphaFromDiffuseTexture", void 0);
  69533. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69534. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69535. ], StandardMaterial.prototype, "useAlphaFromDiffuseTexture", void 0);
  69536. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69537. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useEmissiveAsIllumination")
  69538. ], StandardMaterial.prototype, "_useEmissiveAsIllumination", void 0);
  69539. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69540. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69541. ], StandardMaterial.prototype, "useEmissiveAsIllumination", void 0);
  69542. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69543. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("linkEmissiveWithDiffuse")
  69544. ], StandardMaterial.prototype, "_linkEmissiveWithDiffuse", void 0);
  69545. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69546. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69547. ], StandardMaterial.prototype, "linkEmissiveWithDiffuse", void 0);
  69548. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69549. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useSpecularOverAlpha")
  69550. ], StandardMaterial.prototype, "_useSpecularOverAlpha", void 0);
  69551. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69552. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69553. ], StandardMaterial.prototype, "useSpecularOverAlpha", void 0);
  69554. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69555. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionOverAlpha")
  69556. ], StandardMaterial.prototype, "_useReflectionOverAlpha", void 0);
  69557. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69558. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69559. ], StandardMaterial.prototype, "useReflectionOverAlpha", void 0);
  69560. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69561. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
  69562. ], StandardMaterial.prototype, "_disableLighting", void 0);
  69563. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69564. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  69565. ], StandardMaterial.prototype, "disableLighting", void 0);
  69566. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69567. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useObjectSpaceNormalMap")
  69568. ], StandardMaterial.prototype, "_useObjectSpaceNormalMap", void 0);
  69569. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69570. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69571. ], StandardMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  69572. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69573. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallax")
  69574. ], StandardMaterial.prototype, "_useParallax", void 0);
  69575. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69576. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69577. ], StandardMaterial.prototype, "useParallax", void 0);
  69578. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69579. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallaxOcclusion")
  69580. ], StandardMaterial.prototype, "_useParallaxOcclusion", void 0);
  69581. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69582. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69583. ], StandardMaterial.prototype, "useParallaxOcclusion", void 0);
  69584. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69585. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  69586. ], StandardMaterial.prototype, "parallaxScaleBias", void 0);
  69587. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69588. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("roughness")
  69589. ], StandardMaterial.prototype, "_roughness", void 0);
  69590. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69591. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69592. ], StandardMaterial.prototype, "roughness", void 0);
  69593. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69594. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  69595. ], StandardMaterial.prototype, "indexOfRefraction", void 0);
  69596. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69597. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  69598. ], StandardMaterial.prototype, "invertRefractionY", void 0);
  69599. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69600. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  69601. ], StandardMaterial.prototype, "alphaCutOff", void 0);
  69602. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69603. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useLightmapAsShadowmap")
  69604. ], StandardMaterial.prototype, "_useLightmapAsShadowmap", void 0);
  69605. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69606. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69607. ], StandardMaterial.prototype, "useLightmapAsShadowmap", void 0);
  69608. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69609. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("diffuseFresnelParameters")
  69610. ], StandardMaterial.prototype, "_diffuseFresnelParameters", void 0);
  69611. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69612. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  69613. ], StandardMaterial.prototype, "diffuseFresnelParameters", void 0);
  69614. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69615. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("opacityFresnelParameters")
  69616. ], StandardMaterial.prototype, "_opacityFresnelParameters", void 0);
  69617. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69618. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelAndMiscDirty")
  69619. ], StandardMaterial.prototype, "opacityFresnelParameters", void 0);
  69620. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69621. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("reflectionFresnelParameters")
  69622. ], StandardMaterial.prototype, "_reflectionFresnelParameters", void 0);
  69623. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69624. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  69625. ], StandardMaterial.prototype, "reflectionFresnelParameters", void 0);
  69626. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69627. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("refractionFresnelParameters")
  69628. ], StandardMaterial.prototype, "_refractionFresnelParameters", void 0);
  69629. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69630. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  69631. ], StandardMaterial.prototype, "refractionFresnelParameters", void 0);
  69632. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69633. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("emissiveFresnelParameters")
  69634. ], StandardMaterial.prototype, "_emissiveFresnelParameters", void 0);
  69635. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69636. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  69637. ], StandardMaterial.prototype, "emissiveFresnelParameters", void 0);
  69638. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69639. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionFresnelFromSpecular")
  69640. ], StandardMaterial.prototype, "_useReflectionFresnelFromSpecular", void 0);
  69641. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69642. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  69643. ], StandardMaterial.prototype, "useReflectionFresnelFromSpecular", void 0);
  69644. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69645. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useGlossinessFromSpecularMapAlpha")
  69646. ], StandardMaterial.prototype, "_useGlossinessFromSpecularMapAlpha", void 0);
  69647. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69648. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69649. ], StandardMaterial.prototype, "useGlossinessFromSpecularMapAlpha", void 0);
  69650. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69651. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
  69652. ], StandardMaterial.prototype, "_maxSimultaneousLights", void 0);
  69653. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69654. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  69655. ], StandardMaterial.prototype, "maxSimultaneousLights", void 0);
  69656. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69657. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapX")
  69658. ], StandardMaterial.prototype, "_invertNormalMapX", void 0);
  69659. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69660. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69661. ], StandardMaterial.prototype, "invertNormalMapX", void 0);
  69662. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69663. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapY")
  69664. ], StandardMaterial.prototype, "_invertNormalMapY", void 0);
  69665. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69666. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69667. ], StandardMaterial.prototype, "invertNormalMapY", void 0);
  69668. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69669. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("twoSidedLighting")
  69670. ], StandardMaterial.prototype, "_twoSidedLighting", void 0);
  69671. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69672. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69673. ], StandardMaterial.prototype, "twoSidedLighting", void 0);
  69674. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69675. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  69676. ], StandardMaterial.prototype, "useLogarithmicDepth", null);
  69677. return StandardMaterial;
  69678. }(_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  69679. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardMaterial"] = StandardMaterial;
  69680. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].DefaultMaterialFactory = function (scene) {
  69681. return new StandardMaterial("default material", scene);
  69682. };
  69683. /***/ }),
  69684. /***/ "./Materials/uniformBuffer.ts":
  69685. /*!************************************!*\
  69686. !*** ./Materials/uniformBuffer.ts ***!
  69687. \************************************/
  69688. /*! exports provided: UniformBuffer */
  69689. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  69690. "use strict";
  69691. __webpack_require__.r(__webpack_exports__);
  69692. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return UniformBuffer; });
  69693. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  69694. /**
  69695. * Uniform buffer objects.
  69696. *
  69697. * Handles blocks of uniform on the GPU.
  69698. *
  69699. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  69700. *
  69701. * For more information, please refer to :
  69702. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  69703. */
  69704. var UniformBuffer = /** @class */ (function () {
  69705. /**
  69706. * Instantiates a new Uniform buffer objects.
  69707. *
  69708. * Handles blocks of uniform on the GPU.
  69709. *
  69710. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  69711. *
  69712. * For more information, please refer to :
  69713. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  69714. * @param engine Define the engine the buffer is associated with
  69715. * @param data Define the data contained in the buffer
  69716. * @param dynamic Define if the buffer is updatable
  69717. */
  69718. function UniformBuffer(engine, data, dynamic) {
  69719. this._engine = engine;
  69720. this._noUBO = !engine.supportsUniformBuffers;
  69721. this._dynamic = dynamic;
  69722. this._data = data || [];
  69723. this._uniformLocations = {};
  69724. this._uniformSizes = {};
  69725. this._uniformLocationPointer = 0;
  69726. this._needSync = false;
  69727. if (this._noUBO) {
  69728. this.updateMatrix3x3 = this._updateMatrix3x3ForEffect;
  69729. this.updateMatrix2x2 = this._updateMatrix2x2ForEffect;
  69730. this.updateFloat = this._updateFloatForEffect;
  69731. this.updateFloat2 = this._updateFloat2ForEffect;
  69732. this.updateFloat3 = this._updateFloat3ForEffect;
  69733. this.updateFloat4 = this._updateFloat4ForEffect;
  69734. this.updateMatrix = this._updateMatrixForEffect;
  69735. this.updateVector3 = this._updateVector3ForEffect;
  69736. this.updateVector4 = this._updateVector4ForEffect;
  69737. this.updateColor3 = this._updateColor3ForEffect;
  69738. this.updateColor4 = this._updateColor4ForEffect;
  69739. }
  69740. else {
  69741. this._engine._uniformBuffers.push(this);
  69742. this.updateMatrix3x3 = this._updateMatrix3x3ForUniform;
  69743. this.updateMatrix2x2 = this._updateMatrix2x2ForUniform;
  69744. this.updateFloat = this._updateFloatForUniform;
  69745. this.updateFloat2 = this._updateFloat2ForUniform;
  69746. this.updateFloat3 = this._updateFloat3ForUniform;
  69747. this.updateFloat4 = this._updateFloat4ForUniform;
  69748. this.updateMatrix = this._updateMatrixForUniform;
  69749. this.updateVector3 = this._updateVector3ForUniform;
  69750. this.updateVector4 = this._updateVector4ForUniform;
  69751. this.updateColor3 = this._updateColor3ForUniform;
  69752. this.updateColor4 = this._updateColor4ForUniform;
  69753. }
  69754. }
  69755. Object.defineProperty(UniformBuffer.prototype, "useUbo", {
  69756. /**
  69757. * Indicates if the buffer is using the WebGL2 UBO implementation,
  69758. * or just falling back on setUniformXXX calls.
  69759. */
  69760. get: function () {
  69761. return !this._noUBO;
  69762. },
  69763. enumerable: true,
  69764. configurable: true
  69765. });
  69766. Object.defineProperty(UniformBuffer.prototype, "isSync", {
  69767. /**
  69768. * Indicates if the WebGL underlying uniform buffer is in sync
  69769. * with the javascript cache data.
  69770. */
  69771. get: function () {
  69772. return !this._needSync;
  69773. },
  69774. enumerable: true,
  69775. configurable: true
  69776. });
  69777. /**
  69778. * Indicates if the WebGL underlying uniform buffer is dynamic.
  69779. * Also, a dynamic UniformBuffer will disable cache verification and always
  69780. * update the underlying WebGL uniform buffer to the GPU.
  69781. * @returns if Dynamic, otherwise false
  69782. */
  69783. UniformBuffer.prototype.isDynamic = function () {
  69784. return this._dynamic !== undefined;
  69785. };
  69786. /**
  69787. * The data cache on JS side.
  69788. * @returns the underlying data as a float array
  69789. */
  69790. UniformBuffer.prototype.getData = function () {
  69791. return this._bufferData;
  69792. };
  69793. /**
  69794. * The underlying WebGL Uniform buffer.
  69795. * @returns the webgl buffer
  69796. */
  69797. UniformBuffer.prototype.getBuffer = function () {
  69798. return this._buffer;
  69799. };
  69800. /**
  69801. * std140 layout specifies how to align data within an UBO structure.
  69802. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  69803. * for specs.
  69804. */
  69805. UniformBuffer.prototype._fillAlignment = function (size) {
  69806. // This code has been simplified because we only use floats, vectors of 1, 2, 3, 4 components
  69807. // and 4x4 matrices
  69808. // TODO : change if other types are used
  69809. var alignment;
  69810. if (size <= 2) {
  69811. alignment = size;
  69812. }
  69813. else {
  69814. alignment = 4;
  69815. }
  69816. if ((this._uniformLocationPointer % alignment) !== 0) {
  69817. var oldPointer = this._uniformLocationPointer;
  69818. this._uniformLocationPointer += alignment - (this._uniformLocationPointer % alignment);
  69819. var diff = this._uniformLocationPointer - oldPointer;
  69820. for (var i = 0; i < diff; i++) {
  69821. this._data.push(0);
  69822. }
  69823. }
  69824. };
  69825. /**
  69826. * Adds an uniform in the buffer.
  69827. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  69828. * for the layout to be correct !
  69829. * @param name Name of the uniform, as used in the uniform block in the shader.
  69830. * @param size Data size, or data directly.
  69831. */
  69832. UniformBuffer.prototype.addUniform = function (name, size) {
  69833. if (this._noUBO) {
  69834. return;
  69835. }
  69836. if (this._uniformLocations[name] !== undefined) {
  69837. // Already existing uniform
  69838. return;
  69839. }
  69840. // This function must be called in the order of the shader layout !
  69841. // size can be the size of the uniform, or data directly
  69842. var data;
  69843. if (size instanceof Array) {
  69844. data = size;
  69845. size = data.length;
  69846. }
  69847. else {
  69848. size = size;
  69849. data = [];
  69850. // Fill with zeros
  69851. for (var i = 0; i < size; i++) {
  69852. data.push(0);
  69853. }
  69854. }
  69855. this._fillAlignment(size);
  69856. this._uniformSizes[name] = size;
  69857. this._uniformLocations[name] = this._uniformLocationPointer;
  69858. this._uniformLocationPointer += size;
  69859. for (var i = 0; i < size; i++) {
  69860. this._data.push(data[i]);
  69861. }
  69862. this._needSync = true;
  69863. };
  69864. /**
  69865. * Adds a Matrix 4x4 to the uniform buffer.
  69866. * @param name Name of the uniform, as used in the uniform block in the shader.
  69867. * @param mat A 4x4 matrix.
  69868. */
  69869. UniformBuffer.prototype.addMatrix = function (name, mat) {
  69870. this.addUniform(name, Array.prototype.slice.call(mat.toArray()));
  69871. };
  69872. /**
  69873. * Adds a vec2 to the uniform buffer.
  69874. * @param name Name of the uniform, as used in the uniform block in the shader.
  69875. * @param x Define the x component value of the vec2
  69876. * @param y Define the y component value of the vec2
  69877. */
  69878. UniformBuffer.prototype.addFloat2 = function (name, x, y) {
  69879. var temp = [x, y];
  69880. this.addUniform(name, temp);
  69881. };
  69882. /**
  69883. * Adds a vec3 to the uniform buffer.
  69884. * @param name Name of the uniform, as used in the uniform block in the shader.
  69885. * @param x Define the x component value of the vec3
  69886. * @param y Define the y component value of the vec3
  69887. * @param z Define the z component value of the vec3
  69888. */
  69889. UniformBuffer.prototype.addFloat3 = function (name, x, y, z) {
  69890. var temp = [x, y, z];
  69891. this.addUniform(name, temp);
  69892. };
  69893. /**
  69894. * Adds a vec3 to the uniform buffer.
  69895. * @param name Name of the uniform, as used in the uniform block in the shader.
  69896. * @param color Define the vec3 from a Color
  69897. */
  69898. UniformBuffer.prototype.addColor3 = function (name, color) {
  69899. var temp = new Array();
  69900. color.toArray(temp);
  69901. this.addUniform(name, temp);
  69902. };
  69903. /**
  69904. * Adds a vec4 to the uniform buffer.
  69905. * @param name Name of the uniform, as used in the uniform block in the shader.
  69906. * @param color Define the rgb components from a Color
  69907. * @param alpha Define the a component of the vec4
  69908. */
  69909. UniformBuffer.prototype.addColor4 = function (name, color, alpha) {
  69910. var temp = new Array();
  69911. color.toArray(temp);
  69912. temp.push(alpha);
  69913. this.addUniform(name, temp);
  69914. };
  69915. /**
  69916. * Adds a vec3 to the uniform buffer.
  69917. * @param name Name of the uniform, as used in the uniform block in the shader.
  69918. * @param vector Define the vec3 components from a Vector
  69919. */
  69920. UniformBuffer.prototype.addVector3 = function (name, vector) {
  69921. var temp = new Array();
  69922. vector.toArray(temp);
  69923. this.addUniform(name, temp);
  69924. };
  69925. /**
  69926. * Adds a Matrix 3x3 to the uniform buffer.
  69927. * @param name Name of the uniform, as used in the uniform block in the shader.
  69928. */
  69929. UniformBuffer.prototype.addMatrix3x3 = function (name) {
  69930. this.addUniform(name, 12);
  69931. };
  69932. /**
  69933. * Adds a Matrix 2x2 to the uniform buffer.
  69934. * @param name Name of the uniform, as used in the uniform block in the shader.
  69935. */
  69936. UniformBuffer.prototype.addMatrix2x2 = function (name) {
  69937. this.addUniform(name, 8);
  69938. };
  69939. /**
  69940. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  69941. */
  69942. UniformBuffer.prototype.create = function () {
  69943. if (this._noUBO) {
  69944. return;
  69945. }
  69946. if (this._buffer) {
  69947. return; // nothing to do
  69948. }
  69949. // See spec, alignment must be filled as a vec4
  69950. this._fillAlignment(4);
  69951. this._bufferData = new Float32Array(this._data);
  69952. this._rebuild();
  69953. this._needSync = true;
  69954. };
  69955. /** @hidden */
  69956. UniformBuffer.prototype._rebuild = function () {
  69957. if (this._noUBO) {
  69958. return;
  69959. }
  69960. if (this._dynamic) {
  69961. this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData);
  69962. }
  69963. else {
  69964. this._buffer = this._engine.createUniformBuffer(this._bufferData);
  69965. }
  69966. };
  69967. /**
  69968. * Updates the WebGL Uniform Buffer on the GPU.
  69969. * If the `dynamic` flag is set to true, no cache comparison is done.
  69970. * Otherwise, the buffer will be updated only if the cache differs.
  69971. */
  69972. UniformBuffer.prototype.update = function () {
  69973. if (!this._buffer) {
  69974. this.create();
  69975. return;
  69976. }
  69977. if (!this._dynamic && !this._needSync) {
  69978. return;
  69979. }
  69980. this._engine.updateUniformBuffer(this._buffer, this._bufferData);
  69981. this._needSync = false;
  69982. };
  69983. /**
  69984. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  69985. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  69986. * @param data Define the flattened data
  69987. * @param size Define the size of the data.
  69988. */
  69989. UniformBuffer.prototype.updateUniform = function (uniformName, data, size) {
  69990. var location = this._uniformLocations[uniformName];
  69991. if (location === undefined) {
  69992. if (this._buffer) {
  69993. // Cannot add an uniform if the buffer is already created
  69994. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add an uniform after UBO has been created.");
  69995. return;
  69996. }
  69997. this.addUniform(uniformName, size);
  69998. location = this._uniformLocations[uniformName];
  69999. }
  70000. if (!this._buffer) {
  70001. this.create();
  70002. }
  70003. if (!this._dynamic) {
  70004. // Cache for static uniform buffers
  70005. var changed = false;
  70006. for (var i = 0; i < size; i++) {
  70007. if (this._bufferData[location + i] !== data[i]) {
  70008. changed = true;
  70009. this._bufferData[location + i] = data[i];
  70010. }
  70011. }
  70012. this._needSync = this._needSync || changed;
  70013. }
  70014. else {
  70015. // No cache for dynamic
  70016. for (var i = 0; i < size; i++) {
  70017. this._bufferData[location + i] = data[i];
  70018. }
  70019. }
  70020. };
  70021. // Update methods
  70022. UniformBuffer.prototype._updateMatrix3x3ForUniform = function (name, matrix) {
  70023. // To match std140, matrix must be realigned
  70024. for (var i = 0; i < 3; i++) {
  70025. UniformBuffer._tempBuffer[i * 4] = matrix[i * 3];
  70026. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 3 + 1];
  70027. UniformBuffer._tempBuffer[i * 4 + 2] = matrix[i * 3 + 2];
  70028. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  70029. }
  70030. this.updateUniform(name, UniformBuffer._tempBuffer, 12);
  70031. };
  70032. UniformBuffer.prototype._updateMatrix3x3ForEffect = function (name, matrix) {
  70033. this._currentEffect.setMatrix3x3(name, matrix);
  70034. };
  70035. UniformBuffer.prototype._updateMatrix2x2ForEffect = function (name, matrix) {
  70036. this._currentEffect.setMatrix2x2(name, matrix);
  70037. };
  70038. UniformBuffer.prototype._updateMatrix2x2ForUniform = function (name, matrix) {
  70039. // To match std140, matrix must be realigned
  70040. for (var i = 0; i < 2; i++) {
  70041. UniformBuffer._tempBuffer[i * 4] = matrix[i * 2];
  70042. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 2 + 1];
  70043. UniformBuffer._tempBuffer[i * 4 + 2] = 0.0;
  70044. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  70045. }
  70046. this.updateUniform(name, UniformBuffer._tempBuffer, 8);
  70047. };
  70048. UniformBuffer.prototype._updateFloatForEffect = function (name, x) {
  70049. this._currentEffect.setFloat(name, x);
  70050. };
  70051. UniformBuffer.prototype._updateFloatForUniform = function (name, x) {
  70052. UniformBuffer._tempBuffer[0] = x;
  70053. this.updateUniform(name, UniformBuffer._tempBuffer, 1);
  70054. };
  70055. UniformBuffer.prototype._updateFloat2ForEffect = function (name, x, y, suffix) {
  70056. if (suffix === void 0) { suffix = ""; }
  70057. this._currentEffect.setFloat2(name + suffix, x, y);
  70058. };
  70059. UniformBuffer.prototype._updateFloat2ForUniform = function (name, x, y) {
  70060. UniformBuffer._tempBuffer[0] = x;
  70061. UniformBuffer._tempBuffer[1] = y;
  70062. this.updateUniform(name, UniformBuffer._tempBuffer, 2);
  70063. };
  70064. UniformBuffer.prototype._updateFloat3ForEffect = function (name, x, y, z, suffix) {
  70065. if (suffix === void 0) { suffix = ""; }
  70066. this._currentEffect.setFloat3(name + suffix, x, y, z);
  70067. };
  70068. UniformBuffer.prototype._updateFloat3ForUniform = function (name, x, y, z) {
  70069. UniformBuffer._tempBuffer[0] = x;
  70070. UniformBuffer._tempBuffer[1] = y;
  70071. UniformBuffer._tempBuffer[2] = z;
  70072. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  70073. };
  70074. UniformBuffer.prototype._updateFloat4ForEffect = function (name, x, y, z, w, suffix) {
  70075. if (suffix === void 0) { suffix = ""; }
  70076. this._currentEffect.setFloat4(name + suffix, x, y, z, w);
  70077. };
  70078. UniformBuffer.prototype._updateFloat4ForUniform = function (name, x, y, z, w) {
  70079. UniformBuffer._tempBuffer[0] = x;
  70080. UniformBuffer._tempBuffer[1] = y;
  70081. UniformBuffer._tempBuffer[2] = z;
  70082. UniformBuffer._tempBuffer[3] = w;
  70083. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  70084. };
  70085. UniformBuffer.prototype._updateMatrixForEffect = function (name, mat) {
  70086. this._currentEffect.setMatrix(name, mat);
  70087. };
  70088. UniformBuffer.prototype._updateMatrixForUniform = function (name, mat) {
  70089. this.updateUniform(name, mat.toArray(), 16);
  70090. };
  70091. UniformBuffer.prototype._updateVector3ForEffect = function (name, vector) {
  70092. this._currentEffect.setVector3(name, vector);
  70093. };
  70094. UniformBuffer.prototype._updateVector3ForUniform = function (name, vector) {
  70095. vector.toArray(UniformBuffer._tempBuffer);
  70096. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  70097. };
  70098. UniformBuffer.prototype._updateVector4ForEffect = function (name, vector) {
  70099. this._currentEffect.setVector4(name, vector);
  70100. };
  70101. UniformBuffer.prototype._updateVector4ForUniform = function (name, vector) {
  70102. vector.toArray(UniformBuffer._tempBuffer);
  70103. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  70104. };
  70105. UniformBuffer.prototype._updateColor3ForEffect = function (name, color, suffix) {
  70106. if (suffix === void 0) { suffix = ""; }
  70107. this._currentEffect.setColor3(name + suffix, color);
  70108. };
  70109. UniformBuffer.prototype._updateColor3ForUniform = function (name, color) {
  70110. color.toArray(UniformBuffer._tempBuffer);
  70111. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  70112. };
  70113. UniformBuffer.prototype._updateColor4ForEffect = function (name, color, alpha, suffix) {
  70114. if (suffix === void 0) { suffix = ""; }
  70115. this._currentEffect.setColor4(name + suffix, color, alpha);
  70116. };
  70117. UniformBuffer.prototype._updateColor4ForUniform = function (name, color, alpha) {
  70118. color.toArray(UniformBuffer._tempBuffer);
  70119. UniformBuffer._tempBuffer[3] = alpha;
  70120. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  70121. };
  70122. /**
  70123. * Sets a sampler uniform on the effect.
  70124. * @param name Define the name of the sampler.
  70125. * @param texture Define the texture to set in the sampler
  70126. */
  70127. UniformBuffer.prototype.setTexture = function (name, texture) {
  70128. this._currentEffect.setTexture(name, texture);
  70129. };
  70130. /**
  70131. * Directly updates the value of the uniform in the cache AND on the GPU.
  70132. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  70133. * @param data Define the flattened data
  70134. */
  70135. UniformBuffer.prototype.updateUniformDirectly = function (uniformName, data) {
  70136. this.updateUniform(uniformName, data, data.length);
  70137. this.update();
  70138. };
  70139. /**
  70140. * Binds this uniform buffer to an effect.
  70141. * @param effect Define the effect to bind the buffer to
  70142. * @param name Name of the uniform block in the shader.
  70143. */
  70144. UniformBuffer.prototype.bindToEffect = function (effect, name) {
  70145. this._currentEffect = effect;
  70146. if (this._noUBO || !this._buffer) {
  70147. return;
  70148. }
  70149. effect.bindUniformBuffer(this._buffer, name);
  70150. };
  70151. /**
  70152. * Disposes the uniform buffer.
  70153. */
  70154. UniformBuffer.prototype.dispose = function () {
  70155. if (this._noUBO) {
  70156. return;
  70157. }
  70158. var uniformBuffers = this._engine._uniformBuffers;
  70159. var index = uniformBuffers.indexOf(this);
  70160. if (index !== -1) {
  70161. uniformBuffers[index] = uniformBuffers[uniformBuffers.length - 1];
  70162. uniformBuffers.pop();
  70163. }
  70164. if (!this._buffer) {
  70165. return;
  70166. }
  70167. if (this._engine._releaseBuffer(this._buffer)) {
  70168. this._buffer = null;
  70169. }
  70170. };
  70171. // Pool for avoiding memory leaks
  70172. UniformBuffer._MAX_UNIFORM_SIZE = 256;
  70173. UniformBuffer._tempBuffer = new Float32Array(UniformBuffer._MAX_UNIFORM_SIZE);
  70174. return UniformBuffer;
  70175. }());
  70176. /***/ }),
  70177. /***/ "./Maths/index.ts":
  70178. /*!************************!*\
  70179. !*** ./Maths/index.ts ***!
  70180. \************************/
  70181. /*! 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 */
  70182. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  70183. "use strict";
  70184. __webpack_require__.r(__webpack_exports__);
  70185. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  70186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  70187. /* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math */ "./Maths/math.ts");
  70188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]; });
  70189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToLinearSpace"]; });
  70190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"]; });
  70191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color3"]; });
  70192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color4"]; });
  70193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]; });
  70194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]; });
  70195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]; });
  70196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Size"]; });
  70197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]; });
  70198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]; });
  70199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Plane"]; });
  70200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Viewport"]; });
  70201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Frustum"]; });
  70202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Space"]; });
  70203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Axis"]; });
  70204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"]; });
  70205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Orientation"]; });
  70206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Angle"]; });
  70207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Arc2"]; });
  70208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path2"]; });
  70209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path3D"]; });
  70210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Curve3"]; });
  70211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalVertex"]; });
  70212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalTextureVertex"]; });
  70213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Tmp"]; });
  70214. /* harmony import */ var _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  70215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"]; });
  70216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]; });
  70217. /***/ }),
  70218. /***/ "./Maths/math.scalar.ts":
  70219. /*!******************************!*\
  70220. !*** ./Maths/math.scalar.ts ***!
  70221. \******************************/
  70222. /*! exports provided: Scalar */
  70223. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  70224. "use strict";
  70225. __webpack_require__.r(__webpack_exports__);
  70226. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return Scalar; });
  70227. /**
  70228. * Scalar computation library
  70229. */
  70230. var Scalar = /** @class */ (function () {
  70231. function Scalar() {
  70232. }
  70233. /**
  70234. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  70235. * @param a number
  70236. * @param b number
  70237. * @param epsilon (default = 1.401298E-45)
  70238. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  70239. */
  70240. Scalar.WithinEpsilon = function (a, b, epsilon) {
  70241. if (epsilon === void 0) { epsilon = 1.401298E-45; }
  70242. var num = a - b;
  70243. return -epsilon <= num && num <= epsilon;
  70244. };
  70245. /**
  70246. * Returns a string : the upper case translation of the number i to hexadecimal.
  70247. * @param i number
  70248. * @returns the upper case translation of the number i to hexadecimal.
  70249. */
  70250. Scalar.ToHex = function (i) {
  70251. var str = i.toString(16);
  70252. if (i <= 15) {
  70253. return ("0" + str).toUpperCase();
  70254. }
  70255. return str.toUpperCase();
  70256. };
  70257. /**
  70258. * Returns -1 if value is negative and +1 is value is positive.
  70259. * @param value the value
  70260. * @returns the value itself if it's equal to zero.
  70261. */
  70262. Scalar.Sign = function (value) {
  70263. value = +value; // convert to a number
  70264. if (value === 0 || isNaN(value)) {
  70265. return value;
  70266. }
  70267. return value > 0 ? 1 : -1;
  70268. };
  70269. /**
  70270. * Returns the value itself if it's between min and max.
  70271. * Returns min if the value is lower than min.
  70272. * Returns max if the value is greater than max.
  70273. * @param value the value to clmap
  70274. * @param min the min value to clamp to (default: 0)
  70275. * @param max the max value to clamp to (default: 1)
  70276. * @returns the clamped value
  70277. */
  70278. Scalar.Clamp = function (value, min, max) {
  70279. if (min === void 0) { min = 0; }
  70280. if (max === void 0) { max = 1; }
  70281. return Math.min(max, Math.max(min, value));
  70282. };
  70283. /**
  70284. * the log2 of value.
  70285. * @param value the value to compute log2 of
  70286. * @returns the log2 of value.
  70287. */
  70288. Scalar.Log2 = function (value) {
  70289. return Math.log(value) * Math.LOG2E;
  70290. };
  70291. /**
  70292. * Loops the value, so that it is never larger than length and never smaller than 0.
  70293. *
  70294. * This is similar to the modulo operator but it works with floating point numbers.
  70295. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  70296. * With t = 5 and length = 2.5, the result would be 0.0.
  70297. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  70298. * @param value the value
  70299. * @param length the length
  70300. * @returns the looped value
  70301. */
  70302. Scalar.Repeat = function (value, length) {
  70303. return value - Math.floor(value / length) * length;
  70304. };
  70305. /**
  70306. * Normalize the value between 0.0 and 1.0 using min and max values
  70307. * @param value value to normalize
  70308. * @param min max to normalize between
  70309. * @param max min to normalize between
  70310. * @returns the normalized value
  70311. */
  70312. Scalar.Normalize = function (value, min, max) {
  70313. return (value - min) / (max - min);
  70314. };
  70315. /**
  70316. * Denormalize the value from 0.0 and 1.0 using min and max values
  70317. * @param normalized value to denormalize
  70318. * @param min max to denormalize between
  70319. * @param max min to denormalize between
  70320. * @returns the denormalized value
  70321. */
  70322. Scalar.Denormalize = function (normalized, min, max) {
  70323. return (normalized * (max - min) + min);
  70324. };
  70325. /**
  70326. * Calculates the shortest difference between two given angles given in degrees.
  70327. * @param current current angle in degrees
  70328. * @param target target angle in degrees
  70329. * @returns the delta
  70330. */
  70331. Scalar.DeltaAngle = function (current, target) {
  70332. var num = Scalar.Repeat(target - current, 360.0);
  70333. if (num > 180.0) {
  70334. num -= 360.0;
  70335. }
  70336. return num;
  70337. };
  70338. /**
  70339. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  70340. * @param tx value
  70341. * @param length length
  70342. * @returns The returned value will move back and forth between 0 and length
  70343. */
  70344. Scalar.PingPong = function (tx, length) {
  70345. var t = Scalar.Repeat(tx, length * 2.0);
  70346. return length - Math.abs(t - length);
  70347. };
  70348. /**
  70349. * Interpolates between min and max with smoothing at the limits.
  70350. *
  70351. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  70352. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  70353. * @param from from
  70354. * @param to to
  70355. * @param tx value
  70356. * @returns the smooth stepped value
  70357. */
  70358. Scalar.SmoothStep = function (from, to, tx) {
  70359. var t = Scalar.Clamp(tx);
  70360. t = -2.0 * t * t * t + 3.0 * t * t;
  70361. return to * t + from * (1.0 - t);
  70362. };
  70363. /**
  70364. * Moves a value current towards target.
  70365. *
  70366. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  70367. * Negative values of maxDelta pushes the value away from target.
  70368. * @param current current value
  70369. * @param target target value
  70370. * @param maxDelta max distance to move
  70371. * @returns resulting value
  70372. */
  70373. Scalar.MoveTowards = function (current, target, maxDelta) {
  70374. var result = 0;
  70375. if (Math.abs(target - current) <= maxDelta) {
  70376. result = target;
  70377. }
  70378. else {
  70379. result = current + Scalar.Sign(target - current) * maxDelta;
  70380. }
  70381. return result;
  70382. };
  70383. /**
  70384. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70385. *
  70386. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  70387. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  70388. * @param current current value
  70389. * @param target target value
  70390. * @param maxDelta max distance to move
  70391. * @returns resulting angle
  70392. */
  70393. Scalar.MoveTowardsAngle = function (current, target, maxDelta) {
  70394. var num = Scalar.DeltaAngle(current, target);
  70395. var result = 0;
  70396. if (-maxDelta < num && num < maxDelta) {
  70397. result = target;
  70398. }
  70399. else {
  70400. target = current + num;
  70401. result = Scalar.MoveTowards(current, target, maxDelta);
  70402. }
  70403. return result;
  70404. };
  70405. /**
  70406. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  70407. * @param start start value
  70408. * @param end target value
  70409. * @param amount amount to lerp between
  70410. * @returns the lerped value
  70411. */
  70412. Scalar.Lerp = function (start, end, amount) {
  70413. return start + ((end - start) * amount);
  70414. };
  70415. /**
  70416. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70417. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  70418. * @param start start value
  70419. * @param end target value
  70420. * @param amount amount to lerp between
  70421. * @returns the lerped value
  70422. */
  70423. Scalar.LerpAngle = function (start, end, amount) {
  70424. var num = Scalar.Repeat(end - start, 360.0);
  70425. if (num > 180.0) {
  70426. num -= 360.0;
  70427. }
  70428. return start + num * Scalar.Clamp(amount);
  70429. };
  70430. /**
  70431. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  70432. * @param a start value
  70433. * @param b target value
  70434. * @param value value between a and b
  70435. * @returns the inverseLerp value
  70436. */
  70437. Scalar.InverseLerp = function (a, b, value) {
  70438. var result = 0;
  70439. if (a != b) {
  70440. result = Scalar.Clamp((value - a) / (b - a));
  70441. }
  70442. else {
  70443. result = 0.0;
  70444. }
  70445. return result;
  70446. };
  70447. /**
  70448. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  70449. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  70450. * @param value1 spline value
  70451. * @param tangent1 spline value
  70452. * @param value2 spline value
  70453. * @param tangent2 spline value
  70454. * @param amount input value
  70455. * @returns hermite result
  70456. */
  70457. Scalar.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  70458. var squared = amount * amount;
  70459. var cubed = amount * squared;
  70460. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  70461. var part2 = (-2.0 * cubed) + (3.0 * squared);
  70462. var part3 = (cubed - (2.0 * squared)) + amount;
  70463. var part4 = cubed - squared;
  70464. return (((value1 * part1) + (value2 * part2)) + (tangent1 * part3)) + (tangent2 * part4);
  70465. };
  70466. /**
  70467. * Returns a random float number between and min and max values
  70468. * @param min min value of random
  70469. * @param max max value of random
  70470. * @returns random value
  70471. */
  70472. Scalar.RandomRange = function (min, max) {
  70473. if (min === max) {
  70474. return min;
  70475. }
  70476. return ((Math.random() * (max - min)) + min);
  70477. };
  70478. /**
  70479. * This function returns percentage of a number in a given range.
  70480. *
  70481. * RangeToPercent(40,20,60) will return 0.5 (50%)
  70482. * RangeToPercent(34,0,100) will return 0.34 (34%)
  70483. * @param number to convert to percentage
  70484. * @param min min range
  70485. * @param max max range
  70486. * @returns the percentage
  70487. */
  70488. Scalar.RangeToPercent = function (number, min, max) {
  70489. return ((number - min) / (max - min));
  70490. };
  70491. /**
  70492. * This function returns number that corresponds to the percentage in a given range.
  70493. *
  70494. * PercentToRange(0.34,0,100) will return 34.
  70495. * @param percent to convert to number
  70496. * @param min min range
  70497. * @param max max range
  70498. * @returns the number
  70499. */
  70500. Scalar.PercentToRange = function (percent, min, max) {
  70501. return ((max - min) * percent + min);
  70502. };
  70503. /**
  70504. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  70505. * @param angle The angle to normalize in radian.
  70506. * @return The converted angle.
  70507. */
  70508. Scalar.NormalizeRadians = function (angle) {
  70509. // More precise but slower version kept for reference.
  70510. // angle = angle % Tools.TwoPi;
  70511. // angle = (angle + Tools.TwoPi) % Tools.TwoPi;
  70512. //if (angle > Math.PI) {
  70513. // angle -= Tools.TwoPi;
  70514. //}
  70515. angle -= (Scalar.TwoPi * Math.floor((angle + Math.PI) / Scalar.TwoPi));
  70516. return angle;
  70517. };
  70518. /**
  70519. * Two pi constants convenient for computation.
  70520. */
  70521. Scalar.TwoPi = Math.PI * 2;
  70522. return Scalar;
  70523. }());
  70524. /***/ }),
  70525. /***/ "./Maths/math.ts":
  70526. /*!***********************!*\
  70527. !*** ./Maths/math.ts ***!
  70528. \***********************/
  70529. /*! 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 */
  70530. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  70531. "use strict";
  70532. __webpack_require__.r(__webpack_exports__);
  70533. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return ToGammaSpace; });
  70534. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return ToLinearSpace; });
  70535. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return Epsilon; });
  70536. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return Color3; });
  70537. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return Color4; });
  70538. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return Vector2; });
  70539. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return Vector3; });
  70540. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return Vector4; });
  70541. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return Size; });
  70542. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return Quaternion; });
  70543. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return Matrix; });
  70544. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return Plane; });
  70545. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return Viewport; });
  70546. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return Frustum; });
  70547. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return Space; });
  70548. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return Axis; });
  70549. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return BezierCurve; });
  70550. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return Orientation; });
  70551. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return Angle; });
  70552. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return Arc2; });
  70553. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return Path2; });
  70554. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return Path3D; });
  70555. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return Curve3; });
  70556. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return PositionNormalVertex; });
  70557. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return PositionNormalTextureVertex; });
  70558. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return Tmp; });
  70559. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  70560. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  70561. /**
  70562. * Constant used to convert a value to gamma space
  70563. * @ignorenaming
  70564. */
  70565. var ToGammaSpace = 1 / 2.2;
  70566. /**
  70567. * Constant used to convert a value to linear space
  70568. * @ignorenaming
  70569. */
  70570. var ToLinearSpace = 2.2;
  70571. /**
  70572. * Constant used to define the minimal number value in Babylon.js
  70573. * @ignorenaming
  70574. */
  70575. var Epsilon = 0.001;
  70576. /**
  70577. * Class used to hold a RBG color
  70578. */
  70579. var Color3 = /** @class */ (function () {
  70580. /**
  70581. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  70582. * @param r defines the red component (between 0 and 1, default is 0)
  70583. * @param g defines the green component (between 0 and 1, default is 0)
  70584. * @param b defines the blue component (between 0 and 1, default is 0)
  70585. */
  70586. function Color3(
  70587. /**
  70588. * Defines the red component (between 0 and 1, default is 0)
  70589. */
  70590. r,
  70591. /**
  70592. * Defines the green component (between 0 and 1, default is 0)
  70593. */
  70594. g,
  70595. /**
  70596. * Defines the blue component (between 0 and 1, default is 0)
  70597. */
  70598. b) {
  70599. if (r === void 0) { r = 0; }
  70600. if (g === void 0) { g = 0; }
  70601. if (b === void 0) { b = 0; }
  70602. this.r = r;
  70603. this.g = g;
  70604. this.b = b;
  70605. }
  70606. /**
  70607. * Creates a string with the Color3 current values
  70608. * @returns the string representation of the Color3 object
  70609. */
  70610. Color3.prototype.toString = function () {
  70611. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + "}";
  70612. };
  70613. /**
  70614. * Returns the string "Color3"
  70615. * @returns "Color3"
  70616. */
  70617. Color3.prototype.getClassName = function () {
  70618. return "Color3";
  70619. };
  70620. /**
  70621. * Compute the Color3 hash code
  70622. * @returns an unique number that can be used to hash Color3 objects
  70623. */
  70624. Color3.prototype.getHashCode = function () {
  70625. var hash = this.r || 0;
  70626. hash = (hash * 397) ^ (this.g || 0);
  70627. hash = (hash * 397) ^ (this.b || 0);
  70628. return hash;
  70629. };
  70630. // Operators
  70631. /**
  70632. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  70633. * @param array defines the array where to store the r,g,b components
  70634. * @param index defines an optional index in the target array to define where to start storing values
  70635. * @returns the current Color3 object
  70636. */
  70637. Color3.prototype.toArray = function (array, index) {
  70638. if (index === void 0) { index = 0; }
  70639. array[index] = this.r;
  70640. array[index + 1] = this.g;
  70641. array[index + 2] = this.b;
  70642. return this;
  70643. };
  70644. /**
  70645. * Returns a new Color4 object from the current Color3 and the given alpha
  70646. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  70647. * @returns a new Color4 object
  70648. */
  70649. Color3.prototype.toColor4 = function (alpha) {
  70650. if (alpha === void 0) { alpha = 1; }
  70651. return new Color4(this.r, this.g, this.b, alpha);
  70652. };
  70653. /**
  70654. * Returns a new array populated with 3 numeric elements : red, green and blue values
  70655. * @returns the new array
  70656. */
  70657. Color3.prototype.asArray = function () {
  70658. var result = new Array();
  70659. this.toArray(result, 0);
  70660. return result;
  70661. };
  70662. /**
  70663. * Returns the luminance value
  70664. * @returns a float value
  70665. */
  70666. Color3.prototype.toLuminance = function () {
  70667. return this.r * 0.3 + this.g * 0.59 + this.b * 0.11;
  70668. };
  70669. /**
  70670. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  70671. * @param otherColor defines the second operand
  70672. * @returns the new Color3 object
  70673. */
  70674. Color3.prototype.multiply = function (otherColor) {
  70675. return new Color3(this.r * otherColor.r, this.g * otherColor.g, this.b * otherColor.b);
  70676. };
  70677. /**
  70678. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  70679. * @param otherColor defines the second operand
  70680. * @param result defines the Color3 object where to store the result
  70681. * @returns the current Color3
  70682. */
  70683. Color3.prototype.multiplyToRef = function (otherColor, result) {
  70684. result.r = this.r * otherColor.r;
  70685. result.g = this.g * otherColor.g;
  70686. result.b = this.b * otherColor.b;
  70687. return this;
  70688. };
  70689. /**
  70690. * Determines equality between Color3 objects
  70691. * @param otherColor defines the second operand
  70692. * @returns true if the rgb values are equal to the given ones
  70693. */
  70694. Color3.prototype.equals = function (otherColor) {
  70695. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b;
  70696. };
  70697. /**
  70698. * Determines equality between the current Color3 object and a set of r,b,g values
  70699. * @param r defines the red component to check
  70700. * @param g defines the green component to check
  70701. * @param b defines the blue component to check
  70702. * @returns true if the rgb values are equal to the given ones
  70703. */
  70704. Color3.prototype.equalsFloats = function (r, g, b) {
  70705. return this.r === r && this.g === g && this.b === b;
  70706. };
  70707. /**
  70708. * Multiplies in place each rgb value by scale
  70709. * @param scale defines the scaling factor
  70710. * @returns the updated Color3
  70711. */
  70712. Color3.prototype.scale = function (scale) {
  70713. return new Color3(this.r * scale, this.g * scale, this.b * scale);
  70714. };
  70715. /**
  70716. * Multiplies the rgb values by scale and stores the result into "result"
  70717. * @param scale defines the scaling factor
  70718. * @param result defines the Color3 object where to store the result
  70719. * @returns the unmodified current Color3
  70720. */
  70721. Color3.prototype.scaleToRef = function (scale, result) {
  70722. result.r = this.r * scale;
  70723. result.g = this.g * scale;
  70724. result.b = this.b * scale;
  70725. return this;
  70726. };
  70727. /**
  70728. * Scale the current Color3 values by a factor and add the result to a given Color3
  70729. * @param scale defines the scale factor
  70730. * @param result defines color to store the result into
  70731. * @returns the unmodified current Color3
  70732. */
  70733. Color3.prototype.scaleAndAddToRef = function (scale, result) {
  70734. result.r += this.r * scale;
  70735. result.g += this.g * scale;
  70736. result.b += this.b * scale;
  70737. return this;
  70738. };
  70739. /**
  70740. * Clamps the rgb values by the min and max values and stores the result into "result"
  70741. * @param min defines minimum clamping value (default is 0)
  70742. * @param max defines maximum clamping value (default is 1)
  70743. * @param result defines color to store the result into
  70744. * @returns the original Color3
  70745. */
  70746. Color3.prototype.clampToRef = function (min, max, result) {
  70747. if (min === void 0) { min = 0; }
  70748. if (max === void 0) { max = 1; }
  70749. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  70750. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  70751. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  70752. return this;
  70753. };
  70754. /**
  70755. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  70756. * @param otherColor defines the second operand
  70757. * @returns the new Color3
  70758. */
  70759. Color3.prototype.add = function (otherColor) {
  70760. return new Color3(this.r + otherColor.r, this.g + otherColor.g, this.b + otherColor.b);
  70761. };
  70762. /**
  70763. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  70764. * @param otherColor defines the second operand
  70765. * @param result defines Color3 object to store the result into
  70766. * @returns the unmodified current Color3
  70767. */
  70768. Color3.prototype.addToRef = function (otherColor, result) {
  70769. result.r = this.r + otherColor.r;
  70770. result.g = this.g + otherColor.g;
  70771. result.b = this.b + otherColor.b;
  70772. return this;
  70773. };
  70774. /**
  70775. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  70776. * @param otherColor defines the second operand
  70777. * @returns the new Color3
  70778. */
  70779. Color3.prototype.subtract = function (otherColor) {
  70780. return new Color3(this.r - otherColor.r, this.g - otherColor.g, this.b - otherColor.b);
  70781. };
  70782. /**
  70783. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  70784. * @param otherColor defines the second operand
  70785. * @param result defines Color3 object to store the result into
  70786. * @returns the unmodified current Color3
  70787. */
  70788. Color3.prototype.subtractToRef = function (otherColor, result) {
  70789. result.r = this.r - otherColor.r;
  70790. result.g = this.g - otherColor.g;
  70791. result.b = this.b - otherColor.b;
  70792. return this;
  70793. };
  70794. /**
  70795. * Copy the current object
  70796. * @returns a new Color3 copied the current one
  70797. */
  70798. Color3.prototype.clone = function () {
  70799. return new Color3(this.r, this.g, this.b);
  70800. };
  70801. /**
  70802. * Copies the rgb values from the source in the current Color3
  70803. * @param source defines the source Color3 object
  70804. * @returns the updated Color3 object
  70805. */
  70806. Color3.prototype.copyFrom = function (source) {
  70807. this.r = source.r;
  70808. this.g = source.g;
  70809. this.b = source.b;
  70810. return this;
  70811. };
  70812. /**
  70813. * Updates the Color3 rgb values from the given floats
  70814. * @param r defines the red component to read from
  70815. * @param g defines the green component to read from
  70816. * @param b defines the blue component to read from
  70817. * @returns the current Color3 object
  70818. */
  70819. Color3.prototype.copyFromFloats = function (r, g, b) {
  70820. this.r = r;
  70821. this.g = g;
  70822. this.b = b;
  70823. return this;
  70824. };
  70825. /**
  70826. * Updates the Color3 rgb values from the given floats
  70827. * @param r defines the red component to read from
  70828. * @param g defines the green component to read from
  70829. * @param b defines the blue component to read from
  70830. * @returns the current Color3 object
  70831. */
  70832. Color3.prototype.set = function (r, g, b) {
  70833. return this.copyFromFloats(r, g, b);
  70834. };
  70835. /**
  70836. * Compute the Color3 hexadecimal code as a string
  70837. * @returns a string containing the hexadecimal representation of the Color3 object
  70838. */
  70839. Color3.prototype.toHexString = function () {
  70840. var intR = (this.r * 255) | 0;
  70841. var intG = (this.g * 255) | 0;
  70842. var intB = (this.b * 255) | 0;
  70843. 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);
  70844. };
  70845. /**
  70846. * Computes a new Color3 converted from the current one to linear space
  70847. * @returns a new Color3 object
  70848. */
  70849. Color3.prototype.toLinearSpace = function () {
  70850. var convertedColor = new Color3();
  70851. this.toLinearSpaceToRef(convertedColor);
  70852. return convertedColor;
  70853. };
  70854. /**
  70855. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  70856. * @param convertedColor defines the Color3 object where to store the linear space version
  70857. * @returns the unmodified Color3
  70858. */
  70859. Color3.prototype.toLinearSpaceToRef = function (convertedColor) {
  70860. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  70861. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  70862. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  70863. return this;
  70864. };
  70865. /**
  70866. * Computes a new Color3 converted from the current one to gamma space
  70867. * @returns a new Color3 object
  70868. */
  70869. Color3.prototype.toGammaSpace = function () {
  70870. var convertedColor = new Color3();
  70871. this.toGammaSpaceToRef(convertedColor);
  70872. return convertedColor;
  70873. };
  70874. /**
  70875. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  70876. * @param convertedColor defines the Color3 object where to store the gamma space version
  70877. * @returns the unmodified Color3
  70878. */
  70879. Color3.prototype.toGammaSpaceToRef = function (convertedColor) {
  70880. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  70881. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  70882. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  70883. return this;
  70884. };
  70885. /**
  70886. * Creates a new Color3 from the string containing valid hexadecimal values
  70887. * @param hex defines a string containing valid hexadecimal values
  70888. * @returns a new Color3 object
  70889. */
  70890. Color3.FromHexString = function (hex) {
  70891. if (hex.substring(0, 1) !== "#" || hex.length !== 7) {
  70892. return new Color3(0, 0, 0);
  70893. }
  70894. var r = parseInt(hex.substring(1, 3), 16);
  70895. var g = parseInt(hex.substring(3, 5), 16);
  70896. var b = parseInt(hex.substring(5, 7), 16);
  70897. return Color3.FromInts(r, g, b);
  70898. };
  70899. /**
  70900. * Creates a new Vector3 from the starting index of the given array
  70901. * @param array defines the source array
  70902. * @param offset defines an offset in the source array
  70903. * @returns a new Color3 object
  70904. */
  70905. Color3.FromArray = function (array, offset) {
  70906. if (offset === void 0) { offset = 0; }
  70907. return new Color3(array[offset], array[offset + 1], array[offset + 2]);
  70908. };
  70909. /**
  70910. * Creates a new Color3 from integer values (< 256)
  70911. * @param r defines the red component to read from (value between 0 and 255)
  70912. * @param g defines the green component to read from (value between 0 and 255)
  70913. * @param b defines the blue component to read from (value between 0 and 255)
  70914. * @returns a new Color3 object
  70915. */
  70916. Color3.FromInts = function (r, g, b) {
  70917. return new Color3(r / 255.0, g / 255.0, b / 255.0);
  70918. };
  70919. /**
  70920. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70921. * @param start defines the start Color3 value
  70922. * @param end defines the end Color3 value
  70923. * @param amount defines the gradient value between start and end
  70924. * @returns a new Color3 object
  70925. */
  70926. Color3.Lerp = function (start, end, amount) {
  70927. var result = new Color3(0.0, 0.0, 0.0);
  70928. Color3.LerpToRef(start, end, amount, result);
  70929. return result;
  70930. };
  70931. /**
  70932. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70933. * @param left defines the start value
  70934. * @param right defines the end value
  70935. * @param amount defines the gradient factor
  70936. * @param result defines the Color3 object where to store the result
  70937. */
  70938. Color3.LerpToRef = function (left, right, amount, result) {
  70939. result.r = left.r + ((right.r - left.r) * amount);
  70940. result.g = left.g + ((right.g - left.g) * amount);
  70941. result.b = left.b + ((right.b - left.b) * amount);
  70942. };
  70943. /**
  70944. * Returns a Color3 value containing a red color
  70945. * @returns a new Color3 object
  70946. */
  70947. Color3.Red = function () { return new Color3(1, 0, 0); };
  70948. /**
  70949. * Returns a Color3 value containing a green color
  70950. * @returns a new Color3 object
  70951. */
  70952. Color3.Green = function () { return new Color3(0, 1, 0); };
  70953. /**
  70954. * Returns a Color3 value containing a blue color
  70955. * @returns a new Color3 object
  70956. */
  70957. Color3.Blue = function () { return new Color3(0, 0, 1); };
  70958. /**
  70959. * Returns a Color3 value containing a black color
  70960. * @returns a new Color3 object
  70961. */
  70962. Color3.Black = function () { return new Color3(0, 0, 0); };
  70963. Object.defineProperty(Color3, "BlackReadOnly", {
  70964. /**
  70965. * Gets a Color3 value containing a black color that must not be updated
  70966. */
  70967. get: function () {
  70968. return Color3._BlackReadOnly;
  70969. },
  70970. enumerable: true,
  70971. configurable: true
  70972. });
  70973. /**
  70974. * Returns a Color3 value containing a white color
  70975. * @returns a new Color3 object
  70976. */
  70977. Color3.White = function () { return new Color3(1, 1, 1); };
  70978. /**
  70979. * Returns a Color3 value containing a purple color
  70980. * @returns a new Color3 object
  70981. */
  70982. Color3.Purple = function () { return new Color3(0.5, 0, 0.5); };
  70983. /**
  70984. * Returns a Color3 value containing a magenta color
  70985. * @returns a new Color3 object
  70986. */
  70987. Color3.Magenta = function () { return new Color3(1, 0, 1); };
  70988. /**
  70989. * Returns a Color3 value containing a yellow color
  70990. * @returns a new Color3 object
  70991. */
  70992. Color3.Yellow = function () { return new Color3(1, 1, 0); };
  70993. /**
  70994. * Returns a Color3 value containing a gray color
  70995. * @returns a new Color3 object
  70996. */
  70997. Color3.Gray = function () { return new Color3(0.5, 0.5, 0.5); };
  70998. /**
  70999. * Returns a Color3 value containing a teal color
  71000. * @returns a new Color3 object
  71001. */
  71002. Color3.Teal = function () { return new Color3(0, 1.0, 1.0); };
  71003. /**
  71004. * Returns a Color3 value containing a random color
  71005. * @returns a new Color3 object
  71006. */
  71007. Color3.Random = function () { return new Color3(Math.random(), Math.random(), Math.random()); };
  71008. // Statics
  71009. Color3._BlackReadOnly = Color3.Black();
  71010. return Color3;
  71011. }());
  71012. /**
  71013. * Class used to hold a RBGA color
  71014. */
  71015. var Color4 = /** @class */ (function () {
  71016. /**
  71017. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  71018. * @param r defines the red component (between 0 and 1, default is 0)
  71019. * @param g defines the green component (between 0 and 1, default is 0)
  71020. * @param b defines the blue component (between 0 and 1, default is 0)
  71021. * @param a defines the alpha component (between 0 and 1, default is 1)
  71022. */
  71023. function Color4(
  71024. /**
  71025. * Defines the red component (between 0 and 1, default is 0)
  71026. */
  71027. r,
  71028. /**
  71029. * Defines the green component (between 0 and 1, default is 0)
  71030. */
  71031. g,
  71032. /**
  71033. * Defines the blue component (between 0 and 1, default is 0)
  71034. */
  71035. b,
  71036. /**
  71037. * Defines the alpha component (between 0 and 1, default is 1)
  71038. */
  71039. a) {
  71040. if (r === void 0) { r = 0; }
  71041. if (g === void 0) { g = 0; }
  71042. if (b === void 0) { b = 0; }
  71043. if (a === void 0) { a = 1; }
  71044. this.r = r;
  71045. this.g = g;
  71046. this.b = b;
  71047. this.a = a;
  71048. }
  71049. // Operators
  71050. /**
  71051. * Adds in place the given Color4 values to the current Color4 object
  71052. * @param right defines the second operand
  71053. * @returns the current updated Color4 object
  71054. */
  71055. Color4.prototype.addInPlace = function (right) {
  71056. this.r += right.r;
  71057. this.g += right.g;
  71058. this.b += right.b;
  71059. this.a += right.a;
  71060. return this;
  71061. };
  71062. /**
  71063. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  71064. * @returns the new array
  71065. */
  71066. Color4.prototype.asArray = function () {
  71067. var result = new Array();
  71068. this.toArray(result, 0);
  71069. return result;
  71070. };
  71071. /**
  71072. * Stores from the starting index in the given array the Color4 successive values
  71073. * @param array defines the array where to store the r,g,b components
  71074. * @param index defines an optional index in the target array to define where to start storing values
  71075. * @returns the current Color4 object
  71076. */
  71077. Color4.prototype.toArray = function (array, index) {
  71078. if (index === void 0) { index = 0; }
  71079. array[index] = this.r;
  71080. array[index + 1] = this.g;
  71081. array[index + 2] = this.b;
  71082. array[index + 3] = this.a;
  71083. return this;
  71084. };
  71085. /**
  71086. * Determines equality between Color4 objects
  71087. * @param otherColor defines the second operand
  71088. * @returns true if the rgba values are equal to the given ones
  71089. */
  71090. Color4.prototype.equals = function (otherColor) {
  71091. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b && this.a === otherColor.a;
  71092. };
  71093. /**
  71094. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  71095. * @param right defines the second operand
  71096. * @returns a new Color4 object
  71097. */
  71098. Color4.prototype.add = function (right) {
  71099. return new Color4(this.r + right.r, this.g + right.g, this.b + right.b, this.a + right.a);
  71100. };
  71101. /**
  71102. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  71103. * @param right defines the second operand
  71104. * @returns a new Color4 object
  71105. */
  71106. Color4.prototype.subtract = function (right) {
  71107. return new Color4(this.r - right.r, this.g - right.g, this.b - right.b, this.a - right.a);
  71108. };
  71109. /**
  71110. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  71111. * @param right defines the second operand
  71112. * @param result defines the Color4 object where to store the result
  71113. * @returns the current Color4 object
  71114. */
  71115. Color4.prototype.subtractToRef = function (right, result) {
  71116. result.r = this.r - right.r;
  71117. result.g = this.g - right.g;
  71118. result.b = this.b - right.b;
  71119. result.a = this.a - right.a;
  71120. return this;
  71121. };
  71122. /**
  71123. * Creates a new Color4 with the current Color4 values multiplied by scale
  71124. * @param scale defines the scaling factor to apply
  71125. * @returns a new Color4 object
  71126. */
  71127. Color4.prototype.scale = function (scale) {
  71128. return new Color4(this.r * scale, this.g * scale, this.b * scale, this.a * scale);
  71129. };
  71130. /**
  71131. * Multiplies the current Color4 values by scale and stores the result in "result"
  71132. * @param scale defines the scaling factor to apply
  71133. * @param result defines the Color4 object where to store the result
  71134. * @returns the current unmodified Color4
  71135. */
  71136. Color4.prototype.scaleToRef = function (scale, result) {
  71137. result.r = this.r * scale;
  71138. result.g = this.g * scale;
  71139. result.b = this.b * scale;
  71140. result.a = this.a * scale;
  71141. return this;
  71142. };
  71143. /**
  71144. * Scale the current Color4 values by a factor and add the result to a given Color4
  71145. * @param scale defines the scale factor
  71146. * @param result defines the Color4 object where to store the result
  71147. * @returns the unmodified current Color4
  71148. */
  71149. Color4.prototype.scaleAndAddToRef = function (scale, result) {
  71150. result.r += this.r * scale;
  71151. result.g += this.g * scale;
  71152. result.b += this.b * scale;
  71153. result.a += this.a * scale;
  71154. return this;
  71155. };
  71156. /**
  71157. * Clamps the rgb values by the min and max values and stores the result into "result"
  71158. * @param min defines minimum clamping value (default is 0)
  71159. * @param max defines maximum clamping value (default is 1)
  71160. * @param result defines color to store the result into.
  71161. * @returns the cuurent Color4
  71162. */
  71163. Color4.prototype.clampToRef = function (min, max, result) {
  71164. if (min === void 0) { min = 0; }
  71165. if (max === void 0) { max = 1; }
  71166. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  71167. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  71168. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  71169. result.a = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.a, min, max);
  71170. return this;
  71171. };
  71172. /**
  71173. * Multipy an Color4 value by another and return a new Color4 object
  71174. * @param color defines the Color4 value to multiply by
  71175. * @returns a new Color4 object
  71176. */
  71177. Color4.prototype.multiply = function (color) {
  71178. return new Color4(this.r * color.r, this.g * color.g, this.b * color.b, this.a * color.a);
  71179. };
  71180. /**
  71181. * Multipy a Color4 value by another and push the result in a reference value
  71182. * @param color defines the Color4 value to multiply by
  71183. * @param result defines the Color4 to fill the result in
  71184. * @returns the result Color4
  71185. */
  71186. Color4.prototype.multiplyToRef = function (color, result) {
  71187. result.r = this.r * color.r;
  71188. result.g = this.g * color.g;
  71189. result.b = this.b * color.b;
  71190. result.a = this.a * color.a;
  71191. return result;
  71192. };
  71193. /**
  71194. * Creates a string with the Color4 current values
  71195. * @returns the string representation of the Color4 object
  71196. */
  71197. Color4.prototype.toString = function () {
  71198. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}";
  71199. };
  71200. /**
  71201. * Returns the string "Color4"
  71202. * @returns "Color4"
  71203. */
  71204. Color4.prototype.getClassName = function () {
  71205. return "Color4";
  71206. };
  71207. /**
  71208. * Compute the Color4 hash code
  71209. * @returns an unique number that can be used to hash Color4 objects
  71210. */
  71211. Color4.prototype.getHashCode = function () {
  71212. var hash = this.r || 0;
  71213. hash = (hash * 397) ^ (this.g || 0);
  71214. hash = (hash * 397) ^ (this.b || 0);
  71215. hash = (hash * 397) ^ (this.a || 0);
  71216. return hash;
  71217. };
  71218. /**
  71219. * Creates a new Color4 copied from the current one
  71220. * @returns a new Color4 object
  71221. */
  71222. Color4.prototype.clone = function () {
  71223. return new Color4(this.r, this.g, this.b, this.a);
  71224. };
  71225. /**
  71226. * Copies the given Color4 values into the current one
  71227. * @param source defines the source Color4 object
  71228. * @returns the current updated Color4 object
  71229. */
  71230. Color4.prototype.copyFrom = function (source) {
  71231. this.r = source.r;
  71232. this.g = source.g;
  71233. this.b = source.b;
  71234. this.a = source.a;
  71235. return this;
  71236. };
  71237. /**
  71238. * Copies the given float values into the current one
  71239. * @param r defines the red component to read from
  71240. * @param g defines the green component to read from
  71241. * @param b defines the blue component to read from
  71242. * @param a defines the alpha component to read from
  71243. * @returns the current updated Color4 object
  71244. */
  71245. Color4.prototype.copyFromFloats = function (r, g, b, a) {
  71246. this.r = r;
  71247. this.g = g;
  71248. this.b = b;
  71249. this.a = a;
  71250. return this;
  71251. };
  71252. /**
  71253. * Copies the given float values into the current one
  71254. * @param r defines the red component to read from
  71255. * @param g defines the green component to read from
  71256. * @param b defines the blue component to read from
  71257. * @param a defines the alpha component to read from
  71258. * @returns the current updated Color4 object
  71259. */
  71260. Color4.prototype.set = function (r, g, b, a) {
  71261. return this.copyFromFloats(r, g, b, a);
  71262. };
  71263. /**
  71264. * Compute the Color4 hexadecimal code as a string
  71265. * @returns a string containing the hexadecimal representation of the Color4 object
  71266. */
  71267. Color4.prototype.toHexString = function () {
  71268. var intR = (this.r * 255) | 0;
  71269. var intG = (this.g * 255) | 0;
  71270. var intB = (this.b * 255) | 0;
  71271. var intA = (this.a * 255) | 0;
  71272. 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);
  71273. };
  71274. /**
  71275. * Computes a new Color4 converted from the current one to linear space
  71276. * @returns a new Color4 object
  71277. */
  71278. Color4.prototype.toLinearSpace = function () {
  71279. var convertedColor = new Color4();
  71280. this.toLinearSpaceToRef(convertedColor);
  71281. return convertedColor;
  71282. };
  71283. /**
  71284. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  71285. * @param convertedColor defines the Color4 object where to store the linear space version
  71286. * @returns the unmodified Color4
  71287. */
  71288. Color4.prototype.toLinearSpaceToRef = function (convertedColor) {
  71289. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  71290. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  71291. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  71292. convertedColor.a = this.a;
  71293. return this;
  71294. };
  71295. /**
  71296. * Computes a new Color4 converted from the current one to gamma space
  71297. * @returns a new Color4 object
  71298. */
  71299. Color4.prototype.toGammaSpace = function () {
  71300. var convertedColor = new Color4();
  71301. this.toGammaSpaceToRef(convertedColor);
  71302. return convertedColor;
  71303. };
  71304. /**
  71305. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  71306. * @param convertedColor defines the Color4 object where to store the gamma space version
  71307. * @returns the unmodified Color4
  71308. */
  71309. Color4.prototype.toGammaSpaceToRef = function (convertedColor) {
  71310. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  71311. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  71312. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  71313. convertedColor.a = this.a;
  71314. return this;
  71315. };
  71316. // Statics
  71317. /**
  71318. * Creates a new Color4 from the string containing valid hexadecimal values
  71319. * @param hex defines a string containing valid hexadecimal values
  71320. * @returns a new Color4 object
  71321. */
  71322. Color4.FromHexString = function (hex) {
  71323. if (hex.substring(0, 1) !== "#" || hex.length !== 9) {
  71324. return new Color4(0.0, 0.0, 0.0, 0.0);
  71325. }
  71326. var r = parseInt(hex.substring(1, 3), 16);
  71327. var g = parseInt(hex.substring(3, 5), 16);
  71328. var b = parseInt(hex.substring(5, 7), 16);
  71329. var a = parseInt(hex.substring(7, 9), 16);
  71330. return Color4.FromInts(r, g, b, a);
  71331. };
  71332. /**
  71333. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  71334. * @param left defines the start value
  71335. * @param right defines the end value
  71336. * @param amount defines the gradient factor
  71337. * @returns a new Color4 object
  71338. */
  71339. Color4.Lerp = function (left, right, amount) {
  71340. var result = new Color4(0.0, 0.0, 0.0, 0.0);
  71341. Color4.LerpToRef(left, right, amount, result);
  71342. return result;
  71343. };
  71344. /**
  71345. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  71346. * @param left defines the start value
  71347. * @param right defines the end value
  71348. * @param amount defines the gradient factor
  71349. * @param result defines the Color4 object where to store data
  71350. */
  71351. Color4.LerpToRef = function (left, right, amount, result) {
  71352. result.r = left.r + (right.r - left.r) * amount;
  71353. result.g = left.g + (right.g - left.g) * amount;
  71354. result.b = left.b + (right.b - left.b) * amount;
  71355. result.a = left.a + (right.a - left.a) * amount;
  71356. };
  71357. /**
  71358. * Creates a new Color4 from a Color3 and an alpha value
  71359. * @param color3 defines the source Color3 to read from
  71360. * @param alpha defines the alpha component (1.0 by default)
  71361. * @returns a new Color4 object
  71362. */
  71363. Color4.FromColor3 = function (color3, alpha) {
  71364. if (alpha === void 0) { alpha = 1.0; }
  71365. return new Color4(color3.r, color3.g, color3.b, alpha);
  71366. };
  71367. /**
  71368. * Creates a new Color4 from the starting index element of the given array
  71369. * @param array defines the source array to read from
  71370. * @param offset defines the offset in the source array
  71371. * @returns a new Color4 object
  71372. */
  71373. Color4.FromArray = function (array, offset) {
  71374. if (offset === void 0) { offset = 0; }
  71375. return new Color4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  71376. };
  71377. /**
  71378. * Creates a new Color3 from integer values (< 256)
  71379. * @param r defines the red component to read from (value between 0 and 255)
  71380. * @param g defines the green component to read from (value between 0 and 255)
  71381. * @param b defines the blue component to read from (value between 0 and 255)
  71382. * @param a defines the alpha component to read from (value between 0 and 255)
  71383. * @returns a new Color3 object
  71384. */
  71385. Color4.FromInts = function (r, g, b, a) {
  71386. return new Color4(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
  71387. };
  71388. /**
  71389. * Check the content of a given array and convert it to an array containing RGBA data
  71390. * If the original array was already containing count * 4 values then it is returned directly
  71391. * @param colors defines the array to check
  71392. * @param count defines the number of RGBA data to expect
  71393. * @returns an array containing count * 4 values (RGBA)
  71394. */
  71395. Color4.CheckColors4 = function (colors, count) {
  71396. // Check if color3 was used
  71397. if (colors.length === count * 3) {
  71398. var colors4 = [];
  71399. for (var index = 0; index < colors.length; index += 3) {
  71400. var newIndex = (index / 3) * 4;
  71401. colors4[newIndex] = colors[index];
  71402. colors4[newIndex + 1] = colors[index + 1];
  71403. colors4[newIndex + 2] = colors[index + 2];
  71404. colors4[newIndex + 3] = 1.0;
  71405. }
  71406. return colors4;
  71407. }
  71408. return colors;
  71409. };
  71410. return Color4;
  71411. }());
  71412. /**
  71413. * Class representing a vector containing 2 coordinates
  71414. */
  71415. var Vector2 = /** @class */ (function () {
  71416. /**
  71417. * Creates a new Vector2 from the given x and y coordinates
  71418. * @param x defines the first coordinate
  71419. * @param y defines the second coordinate
  71420. */
  71421. function Vector2(
  71422. /** defines the first coordinate */
  71423. x,
  71424. /** defines the second coordinate */
  71425. y) {
  71426. if (x === void 0) { x = 0; }
  71427. if (y === void 0) { y = 0; }
  71428. this.x = x;
  71429. this.y = y;
  71430. }
  71431. /**
  71432. * Gets a string with the Vector2 coordinates
  71433. * @returns a string with the Vector2 coordinates
  71434. */
  71435. Vector2.prototype.toString = function () {
  71436. return "{X: " + this.x + " Y:" + this.y + "}";
  71437. };
  71438. /**
  71439. * Gets class name
  71440. * @returns the string "Vector2"
  71441. */
  71442. Vector2.prototype.getClassName = function () {
  71443. return "Vector2";
  71444. };
  71445. /**
  71446. * Gets current vector hash code
  71447. * @returns the Vector2 hash code as a number
  71448. */
  71449. Vector2.prototype.getHashCode = function () {
  71450. var hash = this.x || 0;
  71451. hash = (hash * 397) ^ (this.y || 0);
  71452. return hash;
  71453. };
  71454. // Operators
  71455. /**
  71456. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  71457. * @param array defines the source array
  71458. * @param index defines the offset in source array
  71459. * @returns the current Vector2
  71460. */
  71461. Vector2.prototype.toArray = function (array, index) {
  71462. if (index === void 0) { index = 0; }
  71463. array[index] = this.x;
  71464. array[index + 1] = this.y;
  71465. return this;
  71466. };
  71467. /**
  71468. * Copy the current vector to an array
  71469. * @returns a new array with 2 elements: the Vector2 coordinates.
  71470. */
  71471. Vector2.prototype.asArray = function () {
  71472. var result = new Array();
  71473. this.toArray(result, 0);
  71474. return result;
  71475. };
  71476. /**
  71477. * Sets the Vector2 coordinates with the given Vector2 coordinates
  71478. * @param source defines the source Vector2
  71479. * @returns the current updated Vector2
  71480. */
  71481. Vector2.prototype.copyFrom = function (source) {
  71482. this.x = source.x;
  71483. this.y = source.y;
  71484. return this;
  71485. };
  71486. /**
  71487. * Sets the Vector2 coordinates with the given floats
  71488. * @param x defines the first coordinate
  71489. * @param y defines the second coordinate
  71490. * @returns the current updated Vector2
  71491. */
  71492. Vector2.prototype.copyFromFloats = function (x, y) {
  71493. this.x = x;
  71494. this.y = y;
  71495. return this;
  71496. };
  71497. /**
  71498. * Sets the Vector2 coordinates with the given floats
  71499. * @param x defines the first coordinate
  71500. * @param y defines the second coordinate
  71501. * @returns the current updated Vector2
  71502. */
  71503. Vector2.prototype.set = function (x, y) {
  71504. return this.copyFromFloats(x, y);
  71505. };
  71506. /**
  71507. * Add another vector with the current one
  71508. * @param otherVector defines the other vector
  71509. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  71510. */
  71511. Vector2.prototype.add = function (otherVector) {
  71512. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  71513. };
  71514. /**
  71515. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  71516. * @param otherVector defines the other vector
  71517. * @param result defines the target vector
  71518. * @returns the unmodified current Vector2
  71519. */
  71520. Vector2.prototype.addToRef = function (otherVector, result) {
  71521. result.x = this.x + otherVector.x;
  71522. result.y = this.y + otherVector.y;
  71523. return this;
  71524. };
  71525. /**
  71526. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  71527. * @param otherVector defines the other vector
  71528. * @returns the current updated Vector2
  71529. */
  71530. Vector2.prototype.addInPlace = function (otherVector) {
  71531. this.x += otherVector.x;
  71532. this.y += otherVector.y;
  71533. return this;
  71534. };
  71535. /**
  71536. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  71537. * @param otherVector defines the other vector
  71538. * @returns a new Vector2
  71539. */
  71540. Vector2.prototype.addVector3 = function (otherVector) {
  71541. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  71542. };
  71543. /**
  71544. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  71545. * @param otherVector defines the other vector
  71546. * @returns a new Vector2
  71547. */
  71548. Vector2.prototype.subtract = function (otherVector) {
  71549. return new Vector2(this.x - otherVector.x, this.y - otherVector.y);
  71550. };
  71551. /**
  71552. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  71553. * @param otherVector defines the other vector
  71554. * @param result defines the target vector
  71555. * @returns the unmodified current Vector2
  71556. */
  71557. Vector2.prototype.subtractToRef = function (otherVector, result) {
  71558. result.x = this.x - otherVector.x;
  71559. result.y = this.y - otherVector.y;
  71560. return this;
  71561. };
  71562. /**
  71563. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  71564. * @param otherVector defines the other vector
  71565. * @returns the current updated Vector2
  71566. */
  71567. Vector2.prototype.subtractInPlace = function (otherVector) {
  71568. this.x -= otherVector.x;
  71569. this.y -= otherVector.y;
  71570. return this;
  71571. };
  71572. /**
  71573. * Multiplies in place the current Vector2 coordinates by the given ones
  71574. * @param otherVector defines the other vector
  71575. * @returns the current updated Vector2
  71576. */
  71577. Vector2.prototype.multiplyInPlace = function (otherVector) {
  71578. this.x *= otherVector.x;
  71579. this.y *= otherVector.y;
  71580. return this;
  71581. };
  71582. /**
  71583. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  71584. * @param otherVector defines the other vector
  71585. * @returns a new Vector2
  71586. */
  71587. Vector2.prototype.multiply = function (otherVector) {
  71588. return new Vector2(this.x * otherVector.x, this.y * otherVector.y);
  71589. };
  71590. /**
  71591. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  71592. * @param otherVector defines the other vector
  71593. * @param result defines the target vector
  71594. * @returns the unmodified current Vector2
  71595. */
  71596. Vector2.prototype.multiplyToRef = function (otherVector, result) {
  71597. result.x = this.x * otherVector.x;
  71598. result.y = this.y * otherVector.y;
  71599. return this;
  71600. };
  71601. /**
  71602. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  71603. * @param x defines the first coordinate
  71604. * @param y defines the second coordinate
  71605. * @returns a new Vector2
  71606. */
  71607. Vector2.prototype.multiplyByFloats = function (x, y) {
  71608. return new Vector2(this.x * x, this.y * y);
  71609. };
  71610. /**
  71611. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  71612. * @param otherVector defines the other vector
  71613. * @returns a new Vector2
  71614. */
  71615. Vector2.prototype.divide = function (otherVector) {
  71616. return new Vector2(this.x / otherVector.x, this.y / otherVector.y);
  71617. };
  71618. /**
  71619. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  71620. * @param otherVector defines the other vector
  71621. * @param result defines the target vector
  71622. * @returns the unmodified current Vector2
  71623. */
  71624. Vector2.prototype.divideToRef = function (otherVector, result) {
  71625. result.x = this.x / otherVector.x;
  71626. result.y = this.y / otherVector.y;
  71627. return this;
  71628. };
  71629. /**
  71630. * Divides the current Vector2 coordinates by the given ones
  71631. * @param otherVector defines the other vector
  71632. * @returns the current updated Vector2
  71633. */
  71634. Vector2.prototype.divideInPlace = function (otherVector) {
  71635. return this.divideToRef(otherVector, this);
  71636. };
  71637. /**
  71638. * Gets a new Vector2 with current Vector2 negated coordinates
  71639. * @returns a new Vector2
  71640. */
  71641. Vector2.prototype.negate = function () {
  71642. return new Vector2(-this.x, -this.y);
  71643. };
  71644. /**
  71645. * Multiply the Vector2 coordinates by scale
  71646. * @param scale defines the scaling factor
  71647. * @returns the current updated Vector2
  71648. */
  71649. Vector2.prototype.scaleInPlace = function (scale) {
  71650. this.x *= scale;
  71651. this.y *= scale;
  71652. return this;
  71653. };
  71654. /**
  71655. * Returns a new Vector2 scaled by "scale" from the current Vector2
  71656. * @param scale defines the scaling factor
  71657. * @returns a new Vector2
  71658. */
  71659. Vector2.prototype.scale = function (scale) {
  71660. var result = new Vector2(0, 0);
  71661. this.scaleToRef(scale, result);
  71662. return result;
  71663. };
  71664. /**
  71665. * Scale the current Vector2 values by a factor to a given Vector2
  71666. * @param scale defines the scale factor
  71667. * @param result defines the Vector2 object where to store the result
  71668. * @returns the unmodified current Vector2
  71669. */
  71670. Vector2.prototype.scaleToRef = function (scale, result) {
  71671. result.x = this.x * scale;
  71672. result.y = this.y * scale;
  71673. return this;
  71674. };
  71675. /**
  71676. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  71677. * @param scale defines the scale factor
  71678. * @param result defines the Vector2 object where to store the result
  71679. * @returns the unmodified current Vector2
  71680. */
  71681. Vector2.prototype.scaleAndAddToRef = function (scale, result) {
  71682. result.x += this.x * scale;
  71683. result.y += this.y * scale;
  71684. return this;
  71685. };
  71686. /**
  71687. * Gets a boolean if two vectors are equals
  71688. * @param otherVector defines the other vector
  71689. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  71690. */
  71691. Vector2.prototype.equals = function (otherVector) {
  71692. return otherVector && this.x === otherVector.x && this.y === otherVector.y;
  71693. };
  71694. /**
  71695. * Gets a boolean if two vectors are equals (using an epsilon value)
  71696. * @param otherVector defines the other vector
  71697. * @param epsilon defines the minimal distance to consider equality
  71698. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  71699. */
  71700. Vector2.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  71701. if (epsilon === void 0) { epsilon = Epsilon; }
  71702. 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);
  71703. };
  71704. /**
  71705. * Gets a new Vector2 from current Vector2 floored values
  71706. * @returns a new Vector2
  71707. */
  71708. Vector2.prototype.floor = function () {
  71709. return new Vector2(Math.floor(this.x), Math.floor(this.y));
  71710. };
  71711. /**
  71712. * Gets a new Vector2 from current Vector2 floored values
  71713. * @returns a new Vector2
  71714. */
  71715. Vector2.prototype.fract = function () {
  71716. return new Vector2(this.x - Math.floor(this.x), this.y - Math.floor(this.y));
  71717. };
  71718. // Properties
  71719. /**
  71720. * Gets the length of the vector
  71721. * @returns the vector length (float)
  71722. */
  71723. Vector2.prototype.length = function () {
  71724. return Math.sqrt(this.x * this.x + this.y * this.y);
  71725. };
  71726. /**
  71727. * Gets the vector squared length
  71728. * @returns the vector squared length (float)
  71729. */
  71730. Vector2.prototype.lengthSquared = function () {
  71731. return (this.x * this.x + this.y * this.y);
  71732. };
  71733. // Methods
  71734. /**
  71735. * Normalize the vector
  71736. * @returns the current updated Vector2
  71737. */
  71738. Vector2.prototype.normalize = function () {
  71739. var len = this.length();
  71740. if (len === 0) {
  71741. return this;
  71742. }
  71743. var num = 1.0 / len;
  71744. this.x *= num;
  71745. this.y *= num;
  71746. return this;
  71747. };
  71748. /**
  71749. * Gets a new Vector2 copied from the Vector2
  71750. * @returns a new Vector2
  71751. */
  71752. Vector2.prototype.clone = function () {
  71753. return new Vector2(this.x, this.y);
  71754. };
  71755. // Statics
  71756. /**
  71757. * Gets a new Vector2(0, 0)
  71758. * @returns a new Vector2
  71759. */
  71760. Vector2.Zero = function () {
  71761. return new Vector2(0, 0);
  71762. };
  71763. /**
  71764. * Gets a new Vector2(1, 1)
  71765. * @returns a new Vector2
  71766. */
  71767. Vector2.One = function () {
  71768. return new Vector2(1, 1);
  71769. };
  71770. /**
  71771. * Gets a new Vector2 set from the given index element of the given array
  71772. * @param array defines the data source
  71773. * @param offset defines the offset in the data source
  71774. * @returns a new Vector2
  71775. */
  71776. Vector2.FromArray = function (array, offset) {
  71777. if (offset === void 0) { offset = 0; }
  71778. return new Vector2(array[offset], array[offset + 1]);
  71779. };
  71780. /**
  71781. * Sets "result" from the given index element of the given array
  71782. * @param array defines the data source
  71783. * @param offset defines the offset in the data source
  71784. * @param result defines the target vector
  71785. */
  71786. Vector2.FromArrayToRef = function (array, offset, result) {
  71787. result.x = array[offset];
  71788. result.y = array[offset + 1];
  71789. };
  71790. /**
  71791. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  71792. * @param value1 defines 1st point of control
  71793. * @param value2 defines 2nd point of control
  71794. * @param value3 defines 3rd point of control
  71795. * @param value4 defines 4th point of control
  71796. * @param amount defines the interpolation factor
  71797. * @returns a new Vector2
  71798. */
  71799. Vector2.CatmullRom = function (value1, value2, value3, value4, amount) {
  71800. var squared = amount * amount;
  71801. var cubed = amount * squared;
  71802. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  71803. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  71804. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  71805. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  71806. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  71807. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  71808. return new Vector2(x, y);
  71809. };
  71810. /**
  71811. * 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".
  71812. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  71813. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  71814. * @param value defines the value to clamp
  71815. * @param min defines the lower limit
  71816. * @param max defines the upper limit
  71817. * @returns a new Vector2
  71818. */
  71819. Vector2.Clamp = function (value, min, max) {
  71820. var x = value.x;
  71821. x = (x > max.x) ? max.x : x;
  71822. x = (x < min.x) ? min.x : x;
  71823. var y = value.y;
  71824. y = (y > max.y) ? max.y : y;
  71825. y = (y < min.y) ? min.y : y;
  71826. return new Vector2(x, y);
  71827. };
  71828. /**
  71829. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  71830. * @param value1 defines the 1st control point
  71831. * @param tangent1 defines the outgoing tangent
  71832. * @param value2 defines the 2nd control point
  71833. * @param tangent2 defines the incoming tangent
  71834. * @param amount defines the interpolation factor
  71835. * @returns a new Vector2
  71836. */
  71837. Vector2.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  71838. var squared = amount * amount;
  71839. var cubed = amount * squared;
  71840. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  71841. var part2 = (-2.0 * cubed) + (3.0 * squared);
  71842. var part3 = (cubed - (2.0 * squared)) + amount;
  71843. var part4 = cubed - squared;
  71844. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  71845. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  71846. return new Vector2(x, y);
  71847. };
  71848. /**
  71849. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  71850. * @param start defines the start vector
  71851. * @param end defines the end vector
  71852. * @param amount defines the interpolation factor
  71853. * @returns a new Vector2
  71854. */
  71855. Vector2.Lerp = function (start, end, amount) {
  71856. var x = start.x + ((end.x - start.x) * amount);
  71857. var y = start.y + ((end.y - start.y) * amount);
  71858. return new Vector2(x, y);
  71859. };
  71860. /**
  71861. * Gets the dot product of the vector "left" and the vector "right"
  71862. * @param left defines first vector
  71863. * @param right defines second vector
  71864. * @returns the dot product (float)
  71865. */
  71866. Vector2.Dot = function (left, right) {
  71867. return left.x * right.x + left.y * right.y;
  71868. };
  71869. /**
  71870. * Returns a new Vector2 equal to the normalized given vector
  71871. * @param vector defines the vector to normalize
  71872. * @returns a new Vector2
  71873. */
  71874. Vector2.Normalize = function (vector) {
  71875. var newVector = vector.clone();
  71876. newVector.normalize();
  71877. return newVector;
  71878. };
  71879. /**
  71880. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  71881. * @param left defines 1st vector
  71882. * @param right defines 2nd vector
  71883. * @returns a new Vector2
  71884. */
  71885. Vector2.Minimize = function (left, right) {
  71886. var x = (left.x < right.x) ? left.x : right.x;
  71887. var y = (left.y < right.y) ? left.y : right.y;
  71888. return new Vector2(x, y);
  71889. };
  71890. /**
  71891. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  71892. * @param left defines 1st vector
  71893. * @param right defines 2nd vector
  71894. * @returns a new Vector2
  71895. */
  71896. Vector2.Maximize = function (left, right) {
  71897. var x = (left.x > right.x) ? left.x : right.x;
  71898. var y = (left.y > right.y) ? left.y : right.y;
  71899. return new Vector2(x, y);
  71900. };
  71901. /**
  71902. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  71903. * @param vector defines the vector to transform
  71904. * @param transformation defines the matrix to apply
  71905. * @returns a new Vector2
  71906. */
  71907. Vector2.Transform = function (vector, transformation) {
  71908. var r = Vector2.Zero();
  71909. Vector2.TransformToRef(vector, transformation, r);
  71910. return r;
  71911. };
  71912. /**
  71913. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  71914. * @param vector defines the vector to transform
  71915. * @param transformation defines the matrix to apply
  71916. * @param result defines the target vector
  71917. */
  71918. Vector2.TransformToRef = function (vector, transformation, result) {
  71919. var m = transformation.m;
  71920. var x = (vector.x * m[0]) + (vector.y * m[4]) + m[12];
  71921. var y = (vector.x * m[1]) + (vector.y * m[5]) + m[13];
  71922. result.x = x;
  71923. result.y = y;
  71924. };
  71925. /**
  71926. * Determines if a given vector is included in a triangle
  71927. * @param p defines the vector to test
  71928. * @param p0 defines 1st triangle point
  71929. * @param p1 defines 2nd triangle point
  71930. * @param p2 defines 3rd triangle point
  71931. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  71932. */
  71933. Vector2.PointInTriangle = function (p, p0, p1, p2) {
  71934. var a = 1 / 2 * (-p1.y * p2.x + p0.y * (-p1.x + p2.x) + p0.x * (p1.y - p2.y) + p1.x * p2.y);
  71935. var sign = a < 0 ? -1 : 1;
  71936. var s = (p0.y * p2.x - p0.x * p2.y + (p2.y - p0.y) * p.x + (p0.x - p2.x) * p.y) * sign;
  71937. var t = (p0.x * p1.y - p0.y * p1.x + (p0.y - p1.y) * p.x + (p1.x - p0.x) * p.y) * sign;
  71938. return s > 0 && t > 0 && (s + t) < 2 * a * sign;
  71939. };
  71940. /**
  71941. * Gets the distance between the vectors "value1" and "value2"
  71942. * @param value1 defines first vector
  71943. * @param value2 defines second vector
  71944. * @returns the distance between vectors
  71945. */
  71946. Vector2.Distance = function (value1, value2) {
  71947. return Math.sqrt(Vector2.DistanceSquared(value1, value2));
  71948. };
  71949. /**
  71950. * Returns the squared distance between the vectors "value1" and "value2"
  71951. * @param value1 defines first vector
  71952. * @param value2 defines second vector
  71953. * @returns the squared distance between vectors
  71954. */
  71955. Vector2.DistanceSquared = function (value1, value2) {
  71956. var x = value1.x - value2.x;
  71957. var y = value1.y - value2.y;
  71958. return (x * x) + (y * y);
  71959. };
  71960. /**
  71961. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  71962. * @param value1 defines first vector
  71963. * @param value2 defines second vector
  71964. * @returns a new Vector2
  71965. */
  71966. Vector2.Center = function (value1, value2) {
  71967. var center = value1.add(value2);
  71968. center.scaleInPlace(0.5);
  71969. return center;
  71970. };
  71971. /**
  71972. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  71973. * @param p defines the middle point
  71974. * @param segA defines one point of the segment
  71975. * @param segB defines the other point of the segment
  71976. * @returns the shortest distance
  71977. */
  71978. Vector2.DistanceOfPointFromSegment = function (p, segA, segB) {
  71979. var l2 = Vector2.DistanceSquared(segA, segB);
  71980. if (l2 === 0.0) {
  71981. return Vector2.Distance(p, segA);
  71982. }
  71983. var v = segB.subtract(segA);
  71984. var t = Math.max(0, Math.min(1, Vector2.Dot(p.subtract(segA), v) / l2));
  71985. var proj = segA.add(v.multiplyByFloats(t, t));
  71986. return Vector2.Distance(p, proj);
  71987. };
  71988. return Vector2;
  71989. }());
  71990. /**
  71991. * Classed used to store (x,y,z) vector representation
  71992. * A Vector3 is the main object used in 3D geometry
  71993. * It can represent etiher the coordinates of a point the space, either a direction
  71994. * Reminder: js uses a left handed forward facing system
  71995. */
  71996. var Vector3 = /** @class */ (function () {
  71997. /**
  71998. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  71999. * @param x defines the first coordinates (on X axis)
  72000. * @param y defines the second coordinates (on Y axis)
  72001. * @param z defines the third coordinates (on Z axis)
  72002. */
  72003. function Vector3(
  72004. /**
  72005. * Defines the first coordinates (on X axis)
  72006. */
  72007. x,
  72008. /**
  72009. * Defines the second coordinates (on Y axis)
  72010. */
  72011. y,
  72012. /**
  72013. * Defines the third coordinates (on Z axis)
  72014. */
  72015. z) {
  72016. if (x === void 0) { x = 0; }
  72017. if (y === void 0) { y = 0; }
  72018. if (z === void 0) { z = 0; }
  72019. this.x = x;
  72020. this.y = y;
  72021. this.z = z;
  72022. }
  72023. /**
  72024. * Creates a string representation of the Vector3
  72025. * @returns a string with the Vector3 coordinates.
  72026. */
  72027. Vector3.prototype.toString = function () {
  72028. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + "}";
  72029. };
  72030. /**
  72031. * Gets the class name
  72032. * @returns the string "Vector3"
  72033. */
  72034. Vector3.prototype.getClassName = function () {
  72035. return "Vector3";
  72036. };
  72037. /**
  72038. * Creates the Vector3 hash code
  72039. * @returns a number which tends to be unique between Vector3 instances
  72040. */
  72041. Vector3.prototype.getHashCode = function () {
  72042. var hash = this.x || 0;
  72043. hash = (hash * 397) ^ (this.y || 0);
  72044. hash = (hash * 397) ^ (this.z || 0);
  72045. return hash;
  72046. };
  72047. // Operators
  72048. /**
  72049. * Creates an array containing three elements : the coordinates of the Vector3
  72050. * @returns a new array of numbers
  72051. */
  72052. Vector3.prototype.asArray = function () {
  72053. var result = [];
  72054. this.toArray(result, 0);
  72055. return result;
  72056. };
  72057. /**
  72058. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  72059. * @param array defines the destination array
  72060. * @param index defines the offset in the destination array
  72061. * @returns the current Vector3
  72062. */
  72063. Vector3.prototype.toArray = function (array, index) {
  72064. if (index === void 0) { index = 0; }
  72065. array[index] = this.x;
  72066. array[index + 1] = this.y;
  72067. array[index + 2] = this.z;
  72068. return this;
  72069. };
  72070. /**
  72071. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  72072. * @returns a new Quaternion object, computed from the Vector3 coordinates
  72073. */
  72074. Vector3.prototype.toQuaternion = function () {
  72075. return Quaternion.RotationYawPitchRoll(this.y, this.x, this.z);
  72076. };
  72077. /**
  72078. * Adds the given vector to the current Vector3
  72079. * @param otherVector defines the second operand
  72080. * @returns the current updated Vector3
  72081. */
  72082. Vector3.prototype.addInPlace = function (otherVector) {
  72083. return this.addInPlaceFromFloats(otherVector.x, otherVector.y, otherVector.z);
  72084. };
  72085. /**
  72086. * Adds the given coordinates to the current Vector3
  72087. * @param x defines the x coordinate of the operand
  72088. * @param y defines the y coordinate of the operand
  72089. * @param z defines the z coordinate of the operand
  72090. * @returns the current updated Vector3
  72091. */
  72092. Vector3.prototype.addInPlaceFromFloats = function (x, y, z) {
  72093. this.x += x;
  72094. this.y += y;
  72095. this.z += z;
  72096. return this;
  72097. };
  72098. /**
  72099. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  72100. * @param otherVector defines the second operand
  72101. * @returns the resulting Vector3
  72102. */
  72103. Vector3.prototype.add = function (otherVector) {
  72104. return new Vector3(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  72105. };
  72106. /**
  72107. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  72108. * @param otherVector defines the second operand
  72109. * @param result defines the Vector3 object where to store the result
  72110. * @returns the current Vector3
  72111. */
  72112. Vector3.prototype.addToRef = function (otherVector, result) {
  72113. return result.copyFromFloats(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  72114. };
  72115. /**
  72116. * Subtract the given vector from the current Vector3
  72117. * @param otherVector defines the second operand
  72118. * @returns the current updated Vector3
  72119. */
  72120. Vector3.prototype.subtractInPlace = function (otherVector) {
  72121. this.x -= otherVector.x;
  72122. this.y -= otherVector.y;
  72123. this.z -= otherVector.z;
  72124. return this;
  72125. };
  72126. /**
  72127. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  72128. * @param otherVector defines the second operand
  72129. * @returns the resulting Vector3
  72130. */
  72131. Vector3.prototype.subtract = function (otherVector) {
  72132. return new Vector3(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z);
  72133. };
  72134. /**
  72135. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  72136. * @param otherVector defines the second operand
  72137. * @param result defines the Vector3 object where to store the result
  72138. * @returns the current Vector3
  72139. */
  72140. Vector3.prototype.subtractToRef = function (otherVector, result) {
  72141. return this.subtractFromFloatsToRef(otherVector.x, otherVector.y, otherVector.z, result);
  72142. };
  72143. /**
  72144. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  72145. * @param x defines the x coordinate of the operand
  72146. * @param y defines the y coordinate of the operand
  72147. * @param z defines the z coordinate of the operand
  72148. * @returns the resulting Vector3
  72149. */
  72150. Vector3.prototype.subtractFromFloats = function (x, y, z) {
  72151. return new Vector3(this.x - x, this.y - y, this.z - z);
  72152. };
  72153. /**
  72154. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  72155. * @param x defines the x coordinate of the operand
  72156. * @param y defines the y coordinate of the operand
  72157. * @param z defines the z coordinate of the operand
  72158. * @param result defines the Vector3 object where to store the result
  72159. * @returns the current Vector3
  72160. */
  72161. Vector3.prototype.subtractFromFloatsToRef = function (x, y, z, result) {
  72162. return result.copyFromFloats(this.x - x, this.y - y, this.z - z);
  72163. };
  72164. /**
  72165. * Gets a new Vector3 set with the current Vector3 negated coordinates
  72166. * @returns a new Vector3
  72167. */
  72168. Vector3.prototype.negate = function () {
  72169. return new Vector3(-this.x, -this.y, -this.z);
  72170. };
  72171. /**
  72172. * Multiplies the Vector3 coordinates by the float "scale"
  72173. * @param scale defines the multiplier factor
  72174. * @returns the current updated Vector3
  72175. */
  72176. Vector3.prototype.scaleInPlace = function (scale) {
  72177. this.x *= scale;
  72178. this.y *= scale;
  72179. this.z *= scale;
  72180. return this;
  72181. };
  72182. /**
  72183. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  72184. * @param scale defines the multiplier factor
  72185. * @returns a new Vector3
  72186. */
  72187. Vector3.prototype.scale = function (scale) {
  72188. return new Vector3(this.x * scale, this.y * scale, this.z * scale);
  72189. };
  72190. /**
  72191. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  72192. * @param scale defines the multiplier factor
  72193. * @param result defines the Vector3 object where to store the result
  72194. * @returns the current Vector3
  72195. */
  72196. Vector3.prototype.scaleToRef = function (scale, result) {
  72197. return result.copyFromFloats(this.x * scale, this.y * scale, this.z * scale);
  72198. };
  72199. /**
  72200. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  72201. * @param scale defines the scale factor
  72202. * @param result defines the Vector3 object where to store the result
  72203. * @returns the unmodified current Vector3
  72204. */
  72205. Vector3.prototype.scaleAndAddToRef = function (scale, result) {
  72206. return result.addInPlaceFromFloats(this.x * scale, this.y * scale, this.z * scale);
  72207. };
  72208. /**
  72209. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  72210. * @param otherVector defines the second operand
  72211. * @returns true if both vectors are equals
  72212. */
  72213. Vector3.prototype.equals = function (otherVector) {
  72214. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z;
  72215. };
  72216. /**
  72217. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  72218. * @param otherVector defines the second operand
  72219. * @param epsilon defines the minimal distance to define values as equals
  72220. * @returns true if both vectors are distant less than epsilon
  72221. */
  72222. Vector3.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  72223. if (epsilon === void 0) { epsilon = Epsilon; }
  72224. 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);
  72225. };
  72226. /**
  72227. * Returns true if the current Vector3 coordinates equals the given floats
  72228. * @param x defines the x coordinate of the operand
  72229. * @param y defines the y coordinate of the operand
  72230. * @param z defines the z coordinate of the operand
  72231. * @returns true if both vectors are equals
  72232. */
  72233. Vector3.prototype.equalsToFloats = function (x, y, z) {
  72234. return this.x === x && this.y === y && this.z === z;
  72235. };
  72236. /**
  72237. * Multiplies the current Vector3 coordinates by the given ones
  72238. * @param otherVector defines the second operand
  72239. * @returns the current updated Vector3
  72240. */
  72241. Vector3.prototype.multiplyInPlace = function (otherVector) {
  72242. this.x *= otherVector.x;
  72243. this.y *= otherVector.y;
  72244. this.z *= otherVector.z;
  72245. return this;
  72246. };
  72247. /**
  72248. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  72249. * @param otherVector defines the second operand
  72250. * @returns the new Vector3
  72251. */
  72252. Vector3.prototype.multiply = function (otherVector) {
  72253. return this.multiplyByFloats(otherVector.x, otherVector.y, otherVector.z);
  72254. };
  72255. /**
  72256. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  72257. * @param otherVector defines the second operand
  72258. * @param result defines the Vector3 object where to store the result
  72259. * @returns the current Vector3
  72260. */
  72261. Vector3.prototype.multiplyToRef = function (otherVector, result) {
  72262. return result.copyFromFloats(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z);
  72263. };
  72264. /**
  72265. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  72266. * @param x defines the x coordinate of the operand
  72267. * @param y defines the y coordinate of the operand
  72268. * @param z defines the z coordinate of the operand
  72269. * @returns the new Vector3
  72270. */
  72271. Vector3.prototype.multiplyByFloats = function (x, y, z) {
  72272. return new Vector3(this.x * x, this.y * y, this.z * z);
  72273. };
  72274. /**
  72275. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  72276. * @param otherVector defines the second operand
  72277. * @returns the new Vector3
  72278. */
  72279. Vector3.prototype.divide = function (otherVector) {
  72280. return new Vector3(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  72281. };
  72282. /**
  72283. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  72284. * @param otherVector defines the second operand
  72285. * @param result defines the Vector3 object where to store the result
  72286. * @returns the current Vector3
  72287. */
  72288. Vector3.prototype.divideToRef = function (otherVector, result) {
  72289. return result.copyFromFloats(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  72290. };
  72291. /**
  72292. * Divides the current Vector3 coordinates by the given ones.
  72293. * @param otherVector defines the second operand
  72294. * @returns the current updated Vector3
  72295. */
  72296. Vector3.prototype.divideInPlace = function (otherVector) {
  72297. return this.divideToRef(otherVector, this);
  72298. };
  72299. /**
  72300. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  72301. * @param other defines the second operand
  72302. * @returns the current updated Vector3
  72303. */
  72304. Vector3.prototype.minimizeInPlace = function (other) {
  72305. return this.minimizeInPlaceFromFloats(other.x, other.y, other.z);
  72306. };
  72307. /**
  72308. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  72309. * @param other defines the second operand
  72310. * @returns the current updated Vector3
  72311. */
  72312. Vector3.prototype.maximizeInPlace = function (other) {
  72313. return this.maximizeInPlaceFromFloats(other.x, other.y, other.z);
  72314. };
  72315. /**
  72316. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  72317. * @param x defines the x coordinate of the operand
  72318. * @param y defines the y coordinate of the operand
  72319. * @param z defines the z coordinate of the operand
  72320. * @returns the current updated Vector3
  72321. */
  72322. Vector3.prototype.minimizeInPlaceFromFloats = function (x, y, z) {
  72323. if (x < this.x) {
  72324. this.x = x;
  72325. }
  72326. if (y < this.y) {
  72327. this.y = y;
  72328. }
  72329. if (z < this.z) {
  72330. this.z = z;
  72331. }
  72332. return this;
  72333. };
  72334. /**
  72335. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  72336. * @param x defines the x coordinate of the operand
  72337. * @param y defines the y coordinate of the operand
  72338. * @param z defines the z coordinate of the operand
  72339. * @returns the current updated Vector3
  72340. */
  72341. Vector3.prototype.maximizeInPlaceFromFloats = function (x, y, z) {
  72342. if (x > this.x) {
  72343. this.x = x;
  72344. }
  72345. if (y > this.y) {
  72346. this.y = y;
  72347. }
  72348. if (z > this.z) {
  72349. this.z = z;
  72350. }
  72351. return this;
  72352. };
  72353. /**
  72354. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  72355. * Check if is non uniform within a certain amount of decimal places to account for this
  72356. * @param epsilon the amount the values can differ
  72357. * @returns if the the vector is non uniform to a certain number of decimal places
  72358. */
  72359. Vector3.prototype.isNonUniformWithinEpsilon = function (epsilon) {
  72360. var absX = Math.abs(this.x);
  72361. var absY = Math.abs(this.y);
  72362. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absY, epsilon)) {
  72363. return true;
  72364. }
  72365. var absZ = Math.abs(this.z);
  72366. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absZ, epsilon)) {
  72367. return true;
  72368. }
  72369. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absY, absZ, epsilon)) {
  72370. return true;
  72371. }
  72372. return false;
  72373. };
  72374. Object.defineProperty(Vector3.prototype, "isNonUniform", {
  72375. /**
  72376. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  72377. */
  72378. get: function () {
  72379. var absX = Math.abs(this.x);
  72380. var absY = Math.abs(this.y);
  72381. if (absX !== absY) {
  72382. return true;
  72383. }
  72384. var absZ = Math.abs(this.z);
  72385. if (absX !== absZ) {
  72386. return true;
  72387. }
  72388. if (absY !== absZ) {
  72389. return true;
  72390. }
  72391. return false;
  72392. },
  72393. enumerable: true,
  72394. configurable: true
  72395. });
  72396. /**
  72397. * Gets a new Vector3 from current Vector3 floored values
  72398. * @returns a new Vector3
  72399. */
  72400. Vector3.prototype.floor = function () {
  72401. return new Vector3(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
  72402. };
  72403. /**
  72404. * Gets a new Vector3 from current Vector3 floored values
  72405. * @returns a new Vector3
  72406. */
  72407. Vector3.prototype.fract = function () {
  72408. return new Vector3(this.x - Math.floor(this.x), this.y - Math.floor(this.y), this.z - Math.floor(this.z));
  72409. };
  72410. // Properties
  72411. /**
  72412. * Gets the length of the Vector3
  72413. * @returns the length of the Vecto3
  72414. */
  72415. Vector3.prototype.length = function () {
  72416. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  72417. };
  72418. /**
  72419. * Gets the squared length of the Vector3
  72420. * @returns squared length of the Vector3
  72421. */
  72422. Vector3.prototype.lengthSquared = function () {
  72423. return (this.x * this.x + this.y * this.y + this.z * this.z);
  72424. };
  72425. /**
  72426. * Normalize the current Vector3.
  72427. * Please note that this is an in place operation.
  72428. * @returns the current updated Vector3
  72429. */
  72430. Vector3.prototype.normalize = function () {
  72431. return this.normalizeFromLength(this.length());
  72432. };
  72433. /**
  72434. * Reorders the x y z properties of the vector in place
  72435. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  72436. * @returns the current updated vector
  72437. */
  72438. Vector3.prototype.reorderInPlace = function (order) {
  72439. var _this = this;
  72440. order = order.toLowerCase();
  72441. if (order === "xyz") {
  72442. return this;
  72443. }
  72444. MathTmp.Vector3[0].copyFrom(this);
  72445. ["x", "y", "z"].forEach(function (val, i) {
  72446. _this[val] = MathTmp.Vector3[0][order[i]];
  72447. });
  72448. return this;
  72449. };
  72450. /**
  72451. * Rotates the vector around 0,0,0 by a quaternion
  72452. * @param quaternion the rotation quaternion
  72453. * @param result vector to store the result
  72454. * @returns the resulting vector
  72455. */
  72456. Vector3.prototype.rotateByQuaternionToRef = function (quaternion, result) {
  72457. quaternion.toRotationMatrix(MathTmp.Matrix[0]);
  72458. Vector3.TransformCoordinatesToRef(this, MathTmp.Matrix[0], result);
  72459. return result;
  72460. };
  72461. /**
  72462. * Rotates a vector around a given point
  72463. * @param quaternion the rotation quaternion
  72464. * @param point the point to rotate around
  72465. * @param result vector to store the result
  72466. * @returns the resulting vector
  72467. */
  72468. Vector3.prototype.rotateByQuaternionAroundPointToRef = function (quaternion, point, result) {
  72469. this.subtractToRef(point, MathTmp.Vector3[0]);
  72470. MathTmp.Vector3[0].rotateByQuaternionToRef(quaternion, MathTmp.Vector3[0]);
  72471. point.addToRef(MathTmp.Vector3[0], result);
  72472. return result;
  72473. };
  72474. /**
  72475. * Normalize the current Vector3 with the given input length.
  72476. * Please note that this is an in place operation.
  72477. * @param len the length of the vector
  72478. * @returns the current updated Vector3
  72479. */
  72480. Vector3.prototype.normalizeFromLength = function (len) {
  72481. if (len === 0 || len === 1.0) {
  72482. return this;
  72483. }
  72484. return this.scaleInPlace(1.0 / len);
  72485. };
  72486. /**
  72487. * Normalize the current Vector3 to a new vector
  72488. * @returns the new Vector3
  72489. */
  72490. Vector3.prototype.normalizeToNew = function () {
  72491. var normalized = new Vector3(0, 0, 0);
  72492. this.normalizeToRef(normalized);
  72493. return normalized;
  72494. };
  72495. /**
  72496. * Normalize the current Vector3 to the reference
  72497. * @param reference define the Vector3 to update
  72498. * @returns the updated Vector3
  72499. */
  72500. Vector3.prototype.normalizeToRef = function (reference) {
  72501. var len = this.length();
  72502. if (len === 0 || len === 1.0) {
  72503. return reference.copyFromFloats(this.x, this.y, this.z);
  72504. }
  72505. return this.scaleToRef(1.0 / len, reference);
  72506. };
  72507. /**
  72508. * Creates a new Vector3 copied from the current Vector3
  72509. * @returns the new Vector3
  72510. */
  72511. Vector3.prototype.clone = function () {
  72512. return new Vector3(this.x, this.y, this.z);
  72513. };
  72514. /**
  72515. * Copies the given vector coordinates to the current Vector3 ones
  72516. * @param source defines the source Vector3
  72517. * @returns the current updated Vector3
  72518. */
  72519. Vector3.prototype.copyFrom = function (source) {
  72520. return this.copyFromFloats(source.x, source.y, source.z);
  72521. };
  72522. /**
  72523. * Copies the given floats to the current Vector3 coordinates
  72524. * @param x defines the x coordinate of the operand
  72525. * @param y defines the y coordinate of the operand
  72526. * @param z defines the z coordinate of the operand
  72527. * @returns the current updated Vector3
  72528. */
  72529. Vector3.prototype.copyFromFloats = function (x, y, z) {
  72530. this.x = x;
  72531. this.y = y;
  72532. this.z = z;
  72533. return this;
  72534. };
  72535. /**
  72536. * Copies the given floats to the current Vector3 coordinates
  72537. * @param x defines the x coordinate of the operand
  72538. * @param y defines the y coordinate of the operand
  72539. * @param z defines the z coordinate of the operand
  72540. * @returns the current updated Vector3
  72541. */
  72542. Vector3.prototype.set = function (x, y, z) {
  72543. return this.copyFromFloats(x, y, z);
  72544. };
  72545. /**
  72546. * Copies the given float to the current Vector3 coordinates
  72547. * @param v defines the x, y and z coordinates of the operand
  72548. * @returns the current updated Vector3
  72549. */
  72550. Vector3.prototype.setAll = function (v) {
  72551. this.x = this.y = this.z = v;
  72552. return this;
  72553. };
  72554. // Statics
  72555. /**
  72556. * Get the clip factor between two vectors
  72557. * @param vector0 defines the first operand
  72558. * @param vector1 defines the second operand
  72559. * @param axis defines the axis to use
  72560. * @param size defines the size along the axis
  72561. * @returns the clip factor
  72562. */
  72563. Vector3.GetClipFactor = function (vector0, vector1, axis, size) {
  72564. var d0 = Vector3.Dot(vector0, axis) - size;
  72565. var d1 = Vector3.Dot(vector1, axis) - size;
  72566. var s = d0 / (d0 - d1);
  72567. return s;
  72568. };
  72569. /**
  72570. * Get angle between two vectors
  72571. * @param vector0 angle between vector0 and vector1
  72572. * @param vector1 angle between vector0 and vector1
  72573. * @param normal direction of the normal
  72574. * @return the angle between vector0 and vector1
  72575. */
  72576. Vector3.GetAngleBetweenVectors = function (vector0, vector1, normal) {
  72577. var v0 = vector0.normalizeToRef(MathTmp.Vector3[1]);
  72578. var v1 = vector1.normalizeToRef(MathTmp.Vector3[2]);
  72579. var dot = Vector3.Dot(v0, v1);
  72580. var n = MathTmp.Vector3[3];
  72581. Vector3.CrossToRef(v0, v1, n);
  72582. if (Vector3.Dot(n, normal) > 0) {
  72583. return Math.acos(dot);
  72584. }
  72585. return -Math.acos(dot);
  72586. };
  72587. /**
  72588. * Returns a new Vector3 set from the index "offset" of the given array
  72589. * @param array defines the source array
  72590. * @param offset defines the offset in the source array
  72591. * @returns the new Vector3
  72592. */
  72593. Vector3.FromArray = function (array, offset) {
  72594. if (offset === void 0) { offset = 0; }
  72595. return new Vector3(array[offset], array[offset + 1], array[offset + 2]);
  72596. };
  72597. /**
  72598. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  72599. * This function is deprecated. Use FromArray instead
  72600. * @param array defines the source array
  72601. * @param offset defines the offset in the source array
  72602. * @returns the new Vector3
  72603. */
  72604. Vector3.FromFloatArray = function (array, offset) {
  72605. return Vector3.FromArray(array, offset);
  72606. };
  72607. /**
  72608. * Sets the given vector "result" with the element values from the index "offset" of the given array
  72609. * @param array defines the source array
  72610. * @param offset defines the offset in the source array
  72611. * @param result defines the Vector3 where to store the result
  72612. */
  72613. Vector3.FromArrayToRef = function (array, offset, result) {
  72614. result.x = array[offset];
  72615. result.y = array[offset + 1];
  72616. result.z = array[offset + 2];
  72617. };
  72618. /**
  72619. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  72620. * This function is deprecated. Use FromArrayToRef instead.
  72621. * @param array defines the source array
  72622. * @param offset defines the offset in the source array
  72623. * @param result defines the Vector3 where to store the result
  72624. */
  72625. Vector3.FromFloatArrayToRef = function (array, offset, result) {
  72626. return Vector3.FromArrayToRef(array, offset, result);
  72627. };
  72628. /**
  72629. * Sets the given vector "result" with the given floats.
  72630. * @param x defines the x coordinate of the source
  72631. * @param y defines the y coordinate of the source
  72632. * @param z defines the z coordinate of the source
  72633. * @param result defines the Vector3 where to store the result
  72634. */
  72635. Vector3.FromFloatsToRef = function (x, y, z, result) {
  72636. result.copyFromFloats(x, y, z);
  72637. };
  72638. /**
  72639. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  72640. * @returns a new empty Vector3
  72641. */
  72642. Vector3.Zero = function () {
  72643. return new Vector3(0.0, 0.0, 0.0);
  72644. };
  72645. /**
  72646. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  72647. * @returns a new unit Vector3
  72648. */
  72649. Vector3.One = function () {
  72650. return new Vector3(1.0, 1.0, 1.0);
  72651. };
  72652. /**
  72653. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  72654. * @returns a new up Vector3
  72655. */
  72656. Vector3.Up = function () {
  72657. return new Vector3(0.0, 1.0, 0.0);
  72658. };
  72659. Object.defineProperty(Vector3, "UpReadOnly", {
  72660. /**
  72661. * Gets a up Vector3 that must not be updated
  72662. */
  72663. get: function () {
  72664. return Vector3._UpReadOnly;
  72665. },
  72666. enumerable: true,
  72667. configurable: true
  72668. });
  72669. /**
  72670. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  72671. * @returns a new down Vector3
  72672. */
  72673. Vector3.Down = function () {
  72674. return new Vector3(0.0, -1.0, 0.0);
  72675. };
  72676. /**
  72677. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  72678. * @returns a new forward Vector3
  72679. */
  72680. Vector3.Forward = function () {
  72681. return new Vector3(0.0, 0.0, 1.0);
  72682. };
  72683. /**
  72684. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  72685. * @returns a new forward Vector3
  72686. */
  72687. Vector3.Backward = function () {
  72688. return new Vector3(0.0, 0.0, -1.0);
  72689. };
  72690. /**
  72691. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  72692. * @returns a new right Vector3
  72693. */
  72694. Vector3.Right = function () {
  72695. return new Vector3(1.0, 0.0, 0.0);
  72696. };
  72697. /**
  72698. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  72699. * @returns a new left Vector3
  72700. */
  72701. Vector3.Left = function () {
  72702. return new Vector3(-1.0, 0.0, 0.0);
  72703. };
  72704. /**
  72705. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  72706. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  72707. * @param vector defines the Vector3 to transform
  72708. * @param transformation defines the transformation matrix
  72709. * @returns the transformed Vector3
  72710. */
  72711. Vector3.TransformCoordinates = function (vector, transformation) {
  72712. var result = Vector3.Zero();
  72713. Vector3.TransformCoordinatesToRef(vector, transformation, result);
  72714. return result;
  72715. };
  72716. /**
  72717. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  72718. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  72719. * @param vector defines the Vector3 to transform
  72720. * @param transformation defines the transformation matrix
  72721. * @param result defines the Vector3 where to store the result
  72722. */
  72723. Vector3.TransformCoordinatesToRef = function (vector, transformation, result) {
  72724. Vector3.TransformCoordinatesFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  72725. };
  72726. /**
  72727. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  72728. * This method computes tranformed coordinates only, not transformed direction vectors
  72729. * @param x define the x coordinate of the source vector
  72730. * @param y define the y coordinate of the source vector
  72731. * @param z define the z coordinate of the source vector
  72732. * @param transformation defines the transformation matrix
  72733. * @param result defines the Vector3 where to store the result
  72734. */
  72735. Vector3.TransformCoordinatesFromFloatsToRef = function (x, y, z, transformation, result) {
  72736. var m = transformation.m;
  72737. var rx = x * m[0] + y * m[4] + z * m[8] + m[12];
  72738. var ry = x * m[1] + y * m[5] + z * m[9] + m[13];
  72739. var rz = x * m[2] + y * m[6] + z * m[10] + m[14];
  72740. var rw = 1 / (x * m[3] + y * m[7] + z * m[11] + m[15]);
  72741. result.x = rx * rw;
  72742. result.y = ry * rw;
  72743. result.z = rz * rw;
  72744. };
  72745. /**
  72746. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  72747. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  72748. * @param vector defines the Vector3 to transform
  72749. * @param transformation defines the transformation matrix
  72750. * @returns the new Vector3
  72751. */
  72752. Vector3.TransformNormal = function (vector, transformation) {
  72753. var result = Vector3.Zero();
  72754. Vector3.TransformNormalToRef(vector, transformation, result);
  72755. return result;
  72756. };
  72757. /**
  72758. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  72759. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  72760. * @param vector defines the Vector3 to transform
  72761. * @param transformation defines the transformation matrix
  72762. * @param result defines the Vector3 where to store the result
  72763. */
  72764. Vector3.TransformNormalToRef = function (vector, transformation, result) {
  72765. this.TransformNormalFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  72766. };
  72767. /**
  72768. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  72769. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  72770. * @param x define the x coordinate of the source vector
  72771. * @param y define the y coordinate of the source vector
  72772. * @param z define the z coordinate of the source vector
  72773. * @param transformation defines the transformation matrix
  72774. * @param result defines the Vector3 where to store the result
  72775. */
  72776. Vector3.TransformNormalFromFloatsToRef = function (x, y, z, transformation, result) {
  72777. var m = transformation.m;
  72778. result.x = x * m[0] + y * m[4] + z * m[8];
  72779. result.y = x * m[1] + y * m[5] + z * m[9];
  72780. result.z = x * m[2] + y * m[6] + z * m[10];
  72781. };
  72782. /**
  72783. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  72784. * @param value1 defines the first control point
  72785. * @param value2 defines the second control point
  72786. * @param value3 defines the third control point
  72787. * @param value4 defines the fourth control point
  72788. * @param amount defines the amount on the spline to use
  72789. * @returns the new Vector3
  72790. */
  72791. Vector3.CatmullRom = function (value1, value2, value3, value4, amount) {
  72792. var squared = amount * amount;
  72793. var cubed = amount * squared;
  72794. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  72795. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  72796. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  72797. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  72798. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  72799. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  72800. var z = 0.5 * ((((2.0 * value2.z) + ((-value1.z + value3.z) * amount)) +
  72801. (((((2.0 * value1.z) - (5.0 * value2.z)) + (4.0 * value3.z)) - value4.z) * squared)) +
  72802. ((((-value1.z + (3.0 * value2.z)) - (3.0 * value3.z)) + value4.z) * cubed));
  72803. return new Vector3(x, y, z);
  72804. };
  72805. /**
  72806. * 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"
  72807. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  72808. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  72809. * @param value defines the current value
  72810. * @param min defines the lower range value
  72811. * @param max defines the upper range value
  72812. * @returns the new Vector3
  72813. */
  72814. Vector3.Clamp = function (value, min, max) {
  72815. var v = new Vector3();
  72816. Vector3.ClampToRef(value, min, max, v);
  72817. return v;
  72818. };
  72819. /**
  72820. * 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"
  72821. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  72822. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  72823. * @param value defines the current value
  72824. * @param min defines the lower range value
  72825. * @param max defines the upper range value
  72826. * @param result defines the Vector3 where to store the result
  72827. */
  72828. Vector3.ClampToRef = function (value, min, max, result) {
  72829. var x = value.x;
  72830. x = (x > max.x) ? max.x : x;
  72831. x = (x < min.x) ? min.x : x;
  72832. var y = value.y;
  72833. y = (y > max.y) ? max.y : y;
  72834. y = (y < min.y) ? min.y : y;
  72835. var z = value.z;
  72836. z = (z > max.z) ? max.z : z;
  72837. z = (z < min.z) ? min.z : z;
  72838. result.copyFromFloats(x, y, z);
  72839. };
  72840. /**
  72841. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  72842. * @param value1 defines the first control point
  72843. * @param tangent1 defines the first tangent vector
  72844. * @param value2 defines the second control point
  72845. * @param tangent2 defines the second tangent vector
  72846. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  72847. * @returns the new Vector3
  72848. */
  72849. Vector3.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  72850. var squared = amount * amount;
  72851. var cubed = amount * squared;
  72852. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  72853. var part2 = (-2.0 * cubed) + (3.0 * squared);
  72854. var part3 = (cubed - (2.0 * squared)) + amount;
  72855. var part4 = cubed - squared;
  72856. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  72857. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  72858. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  72859. return new Vector3(x, y, z);
  72860. };
  72861. /**
  72862. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  72863. * @param start defines the start value
  72864. * @param end defines the end value
  72865. * @param amount max defines amount between both (between 0 and 1)
  72866. * @returns the new Vector3
  72867. */
  72868. Vector3.Lerp = function (start, end, amount) {
  72869. var result = new Vector3(0, 0, 0);
  72870. Vector3.LerpToRef(start, end, amount, result);
  72871. return result;
  72872. };
  72873. /**
  72874. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  72875. * @param start defines the start value
  72876. * @param end defines the end value
  72877. * @param amount max defines amount between both (between 0 and 1)
  72878. * @param result defines the Vector3 where to store the result
  72879. */
  72880. Vector3.LerpToRef = function (start, end, amount, result) {
  72881. result.x = start.x + ((end.x - start.x) * amount);
  72882. result.y = start.y + ((end.y - start.y) * amount);
  72883. result.z = start.z + ((end.z - start.z) * amount);
  72884. };
  72885. /**
  72886. * Returns the dot product (float) between the vectors "left" and "right"
  72887. * @param left defines the left operand
  72888. * @param right defines the right operand
  72889. * @returns the dot product
  72890. */
  72891. Vector3.Dot = function (left, right) {
  72892. return (left.x * right.x + left.y * right.y + left.z * right.z);
  72893. };
  72894. /**
  72895. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  72896. * The cross product is then orthogonal to both "left" and "right"
  72897. * @param left defines the left operand
  72898. * @param right defines the right operand
  72899. * @returns the cross product
  72900. */
  72901. Vector3.Cross = function (left, right) {
  72902. var result = Vector3.Zero();
  72903. Vector3.CrossToRef(left, right, result);
  72904. return result;
  72905. };
  72906. /**
  72907. * Sets the given vector "result" with the cross product of "left" and "right"
  72908. * The cross product is then orthogonal to both "left" and "right"
  72909. * @param left defines the left operand
  72910. * @param right defines the right operand
  72911. * @param result defines the Vector3 where to store the result
  72912. */
  72913. Vector3.CrossToRef = function (left, right, result) {
  72914. var x = left.y * right.z - left.z * right.y;
  72915. var y = left.z * right.x - left.x * right.z;
  72916. var z = left.x * right.y - left.y * right.x;
  72917. result.copyFromFloats(x, y, z);
  72918. };
  72919. /**
  72920. * Returns a new Vector3 as the normalization of the given vector
  72921. * @param vector defines the Vector3 to normalize
  72922. * @returns the new Vector3
  72923. */
  72924. Vector3.Normalize = function (vector) {
  72925. var result = Vector3.Zero();
  72926. Vector3.NormalizeToRef(vector, result);
  72927. return result;
  72928. };
  72929. /**
  72930. * Sets the given vector "result" with the normalization of the given first vector
  72931. * @param vector defines the Vector3 to normalize
  72932. * @param result defines the Vector3 where to store the result
  72933. */
  72934. Vector3.NormalizeToRef = function (vector, result) {
  72935. vector.normalizeToRef(result);
  72936. };
  72937. /**
  72938. * Project a Vector3 onto screen space
  72939. * @param vector defines the Vector3 to project
  72940. * @param world defines the world matrix to use
  72941. * @param transform defines the transform (view x projection) matrix to use
  72942. * @param viewport defines the screen viewport to use
  72943. * @returns the new Vector3
  72944. */
  72945. Vector3.Project = function (vector, world, transform, viewport) {
  72946. var cw = viewport.width;
  72947. var ch = viewport.height;
  72948. var cx = viewport.x;
  72949. var cy = viewport.y;
  72950. var viewportMatrix = MathTmp.Matrix[1];
  72951. 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);
  72952. var matrix = MathTmp.Matrix[0];
  72953. world.multiplyToRef(transform, matrix);
  72954. matrix.multiplyToRef(viewportMatrix, matrix);
  72955. return Vector3.TransformCoordinates(vector, matrix);
  72956. };
  72957. /** @hidden */
  72958. Vector3._UnprojectFromInvertedMatrixToRef = function (source, matrix, result) {
  72959. Vector3.TransformCoordinatesToRef(source, matrix, result);
  72960. var m = matrix.m;
  72961. var num = source.x * m[3] + source.y * m[7] + source.z * m[11] + m[15];
  72962. if (_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(num, 1.0)) {
  72963. result.scaleInPlace(1.0 / num);
  72964. }
  72965. };
  72966. /**
  72967. * Unproject from screen space to object space
  72968. * @param source defines the screen space Vector3 to use
  72969. * @param viewportWidth defines the current width of the viewport
  72970. * @param viewportHeight defines the current height of the viewport
  72971. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72972. * @param transform defines the transform (view x projection) matrix to use
  72973. * @returns the new Vector3
  72974. */
  72975. Vector3.UnprojectFromTransform = function (source, viewportWidth, viewportHeight, world, transform) {
  72976. var matrix = MathTmp.Matrix[0];
  72977. world.multiplyToRef(transform, matrix);
  72978. matrix.invert();
  72979. source.x = source.x / viewportWidth * 2 - 1;
  72980. source.y = -(source.y / viewportHeight * 2 - 1);
  72981. var vector = new Vector3();
  72982. Vector3._UnprojectFromInvertedMatrixToRef(source, matrix, vector);
  72983. return vector;
  72984. };
  72985. /**
  72986. * Unproject from screen space to object space
  72987. * @param source defines the screen space Vector3 to use
  72988. * @param viewportWidth defines the current width of the viewport
  72989. * @param viewportHeight defines the current height of the viewport
  72990. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72991. * @param view defines the view matrix to use
  72992. * @param projection defines the projection matrix to use
  72993. * @returns the new Vector3
  72994. */
  72995. Vector3.Unproject = function (source, viewportWidth, viewportHeight, world, view, projection) {
  72996. var result = Vector3.Zero();
  72997. Vector3.UnprojectToRef(source, viewportWidth, viewportHeight, world, view, projection, result);
  72998. return result;
  72999. };
  73000. /**
  73001. * Unproject from screen space to object space
  73002. * @param source defines the screen space Vector3 to use
  73003. * @param viewportWidth defines the current width of the viewport
  73004. * @param viewportHeight defines the current height of the viewport
  73005. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73006. * @param view defines the view matrix to use
  73007. * @param projection defines the projection matrix to use
  73008. * @param result defines the Vector3 where to store the result
  73009. */
  73010. Vector3.UnprojectToRef = function (source, viewportWidth, viewportHeight, world, view, projection, result) {
  73011. Vector3.UnprojectFloatsToRef(source.x, source.y, source.z, viewportWidth, viewportHeight, world, view, projection, result);
  73012. };
  73013. /**
  73014. * Unproject from screen space to object space
  73015. * @param sourceX defines the screen space x coordinate to use
  73016. * @param sourceY defines the screen space y coordinate to use
  73017. * @param sourceZ defines the screen space z coordinate to use
  73018. * @param viewportWidth defines the current width of the viewport
  73019. * @param viewportHeight defines the current height of the viewport
  73020. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73021. * @param view defines the view matrix to use
  73022. * @param projection defines the projection matrix to use
  73023. * @param result defines the Vector3 where to store the result
  73024. */
  73025. Vector3.UnprojectFloatsToRef = function (sourceX, sourceY, sourceZ, viewportWidth, viewportHeight, world, view, projection, result) {
  73026. var matrix = MathTmp.Matrix[0];
  73027. world.multiplyToRef(view, matrix);
  73028. matrix.multiplyToRef(projection, matrix);
  73029. matrix.invert();
  73030. var screenSource = MathTmp.Vector3[0];
  73031. screenSource.x = sourceX / viewportWidth * 2 - 1;
  73032. screenSource.y = -(sourceY / viewportHeight * 2 - 1);
  73033. screenSource.z = 2 * sourceZ - 1.0;
  73034. Vector3._UnprojectFromInvertedMatrixToRef(screenSource, matrix, result);
  73035. };
  73036. /**
  73037. * Gets the minimal coordinate values between two Vector3
  73038. * @param left defines the first operand
  73039. * @param right defines the second operand
  73040. * @returns the new Vector3
  73041. */
  73042. Vector3.Minimize = function (left, right) {
  73043. var min = left.clone();
  73044. min.minimizeInPlace(right);
  73045. return min;
  73046. };
  73047. /**
  73048. * Gets the maximal coordinate values between two Vector3
  73049. * @param left defines the first operand
  73050. * @param right defines the second operand
  73051. * @returns the new Vector3
  73052. */
  73053. Vector3.Maximize = function (left, right) {
  73054. var max = left.clone();
  73055. max.maximizeInPlace(right);
  73056. return max;
  73057. };
  73058. /**
  73059. * Returns the distance between the vectors "value1" and "value2"
  73060. * @param value1 defines the first operand
  73061. * @param value2 defines the second operand
  73062. * @returns the distance
  73063. */
  73064. Vector3.Distance = function (value1, value2) {
  73065. return Math.sqrt(Vector3.DistanceSquared(value1, value2));
  73066. };
  73067. /**
  73068. * Returns the squared distance between the vectors "value1" and "value2"
  73069. * @param value1 defines the first operand
  73070. * @param value2 defines the second operand
  73071. * @returns the squared distance
  73072. */
  73073. Vector3.DistanceSquared = function (value1, value2) {
  73074. var x = value1.x - value2.x;
  73075. var y = value1.y - value2.y;
  73076. var z = value1.z - value2.z;
  73077. return (x * x) + (y * y) + (z * z);
  73078. };
  73079. /**
  73080. * Returns a new Vector3 located at the center between "value1" and "value2"
  73081. * @param value1 defines the first operand
  73082. * @param value2 defines the second operand
  73083. * @returns the new Vector3
  73084. */
  73085. Vector3.Center = function (value1, value2) {
  73086. var center = value1.add(value2);
  73087. center.scaleInPlace(0.5);
  73088. return center;
  73089. };
  73090. /**
  73091. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  73092. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  73093. * to something in order to rotate it from its local system to the given target system
  73094. * Note: axis1, axis2 and axis3 are normalized during this operation
  73095. * @param axis1 defines the first axis
  73096. * @param axis2 defines the second axis
  73097. * @param axis3 defines the third axis
  73098. * @returns a new Vector3
  73099. */
  73100. Vector3.RotationFromAxis = function (axis1, axis2, axis3) {
  73101. var rotation = Vector3.Zero();
  73102. Vector3.RotationFromAxisToRef(axis1, axis2, axis3, rotation);
  73103. return rotation;
  73104. };
  73105. /**
  73106. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  73107. * @param axis1 defines the first axis
  73108. * @param axis2 defines the second axis
  73109. * @param axis3 defines the third axis
  73110. * @param ref defines the Vector3 where to store the result
  73111. */
  73112. Vector3.RotationFromAxisToRef = function (axis1, axis2, axis3, ref) {
  73113. var quat = MathTmp.Quaternion[0];
  73114. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  73115. quat.toEulerAnglesToRef(ref);
  73116. };
  73117. Vector3._UpReadOnly = Vector3.Up();
  73118. return Vector3;
  73119. }());
  73120. /**
  73121. * Vector4 class created for EulerAngle class conversion to Quaternion
  73122. */
  73123. var Vector4 = /** @class */ (function () {
  73124. /**
  73125. * Creates a Vector4 object from the given floats.
  73126. * @param x x value of the vector
  73127. * @param y y value of the vector
  73128. * @param z z value of the vector
  73129. * @param w w value of the vector
  73130. */
  73131. function Vector4(
  73132. /** x value of the vector */
  73133. x,
  73134. /** y value of the vector */
  73135. y,
  73136. /** z value of the vector */
  73137. z,
  73138. /** w value of the vector */
  73139. w) {
  73140. this.x = x;
  73141. this.y = y;
  73142. this.z = z;
  73143. this.w = w;
  73144. }
  73145. /**
  73146. * Returns the string with the Vector4 coordinates.
  73147. * @returns a string containing all the vector values
  73148. */
  73149. Vector4.prototype.toString = function () {
  73150. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  73151. };
  73152. /**
  73153. * Returns the string "Vector4".
  73154. * @returns "Vector4"
  73155. */
  73156. Vector4.prototype.getClassName = function () {
  73157. return "Vector4";
  73158. };
  73159. /**
  73160. * Returns the Vector4 hash code.
  73161. * @returns a unique hash code
  73162. */
  73163. Vector4.prototype.getHashCode = function () {
  73164. var hash = this.x || 0;
  73165. hash = (hash * 397) ^ (this.y || 0);
  73166. hash = (hash * 397) ^ (this.z || 0);
  73167. hash = (hash * 397) ^ (this.w || 0);
  73168. return hash;
  73169. };
  73170. // Operators
  73171. /**
  73172. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  73173. * @returns the resulting array
  73174. */
  73175. Vector4.prototype.asArray = function () {
  73176. var result = new Array();
  73177. this.toArray(result, 0);
  73178. return result;
  73179. };
  73180. /**
  73181. * Populates the given array from the given index with the Vector4 coordinates.
  73182. * @param array array to populate
  73183. * @param index index of the array to start at (default: 0)
  73184. * @returns the Vector4.
  73185. */
  73186. Vector4.prototype.toArray = function (array, index) {
  73187. if (index === undefined) {
  73188. index = 0;
  73189. }
  73190. array[index] = this.x;
  73191. array[index + 1] = this.y;
  73192. array[index + 2] = this.z;
  73193. array[index + 3] = this.w;
  73194. return this;
  73195. };
  73196. /**
  73197. * Adds the given vector to the current Vector4.
  73198. * @param otherVector the vector to add
  73199. * @returns the updated Vector4.
  73200. */
  73201. Vector4.prototype.addInPlace = function (otherVector) {
  73202. this.x += otherVector.x;
  73203. this.y += otherVector.y;
  73204. this.z += otherVector.z;
  73205. this.w += otherVector.w;
  73206. return this;
  73207. };
  73208. /**
  73209. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  73210. * @param otherVector the vector to add
  73211. * @returns the resulting vector
  73212. */
  73213. Vector4.prototype.add = function (otherVector) {
  73214. return new Vector4(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z, this.w + otherVector.w);
  73215. };
  73216. /**
  73217. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  73218. * @param otherVector the vector to add
  73219. * @param result the vector to store the result
  73220. * @returns the current Vector4.
  73221. */
  73222. Vector4.prototype.addToRef = function (otherVector, result) {
  73223. result.x = this.x + otherVector.x;
  73224. result.y = this.y + otherVector.y;
  73225. result.z = this.z + otherVector.z;
  73226. result.w = this.w + otherVector.w;
  73227. return this;
  73228. };
  73229. /**
  73230. * Subtract in place the given vector from the current Vector4.
  73231. * @param otherVector the vector to subtract
  73232. * @returns the updated Vector4.
  73233. */
  73234. Vector4.prototype.subtractInPlace = function (otherVector) {
  73235. this.x -= otherVector.x;
  73236. this.y -= otherVector.y;
  73237. this.z -= otherVector.z;
  73238. this.w -= otherVector.w;
  73239. return this;
  73240. };
  73241. /**
  73242. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  73243. * @param otherVector the vector to add
  73244. * @returns the new vector with the result
  73245. */
  73246. Vector4.prototype.subtract = function (otherVector) {
  73247. return new Vector4(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z, this.w - otherVector.w);
  73248. };
  73249. /**
  73250. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  73251. * @param otherVector the vector to subtract
  73252. * @param result the vector to store the result
  73253. * @returns the current Vector4.
  73254. */
  73255. Vector4.prototype.subtractToRef = function (otherVector, result) {
  73256. result.x = this.x - otherVector.x;
  73257. result.y = this.y - otherVector.y;
  73258. result.z = this.z - otherVector.z;
  73259. result.w = this.w - otherVector.w;
  73260. return this;
  73261. };
  73262. /**
  73263. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73264. */
  73265. /**
  73266. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73267. * @param x value to subtract
  73268. * @param y value to subtract
  73269. * @param z value to subtract
  73270. * @param w value to subtract
  73271. * @returns new vector containing the result
  73272. */
  73273. Vector4.prototype.subtractFromFloats = function (x, y, z, w) {
  73274. return new Vector4(this.x - x, this.y - y, this.z - z, this.w - w);
  73275. };
  73276. /**
  73277. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73278. * @param x value to subtract
  73279. * @param y value to subtract
  73280. * @param z value to subtract
  73281. * @param w value to subtract
  73282. * @param result the vector to store the result in
  73283. * @returns the current Vector4.
  73284. */
  73285. Vector4.prototype.subtractFromFloatsToRef = function (x, y, z, w, result) {
  73286. result.x = this.x - x;
  73287. result.y = this.y - y;
  73288. result.z = this.z - z;
  73289. result.w = this.w - w;
  73290. return this;
  73291. };
  73292. /**
  73293. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  73294. * @returns a new vector with the negated values
  73295. */
  73296. Vector4.prototype.negate = function () {
  73297. return new Vector4(-this.x, -this.y, -this.z, -this.w);
  73298. };
  73299. /**
  73300. * Multiplies the current Vector4 coordinates by scale (float).
  73301. * @param scale the number to scale with
  73302. * @returns the updated Vector4.
  73303. */
  73304. Vector4.prototype.scaleInPlace = function (scale) {
  73305. this.x *= scale;
  73306. this.y *= scale;
  73307. this.z *= scale;
  73308. this.w *= scale;
  73309. return this;
  73310. };
  73311. /**
  73312. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  73313. * @param scale the number to scale with
  73314. * @returns a new vector with the result
  73315. */
  73316. Vector4.prototype.scale = function (scale) {
  73317. return new Vector4(this.x * scale, this.y * scale, this.z * scale, this.w * scale);
  73318. };
  73319. /**
  73320. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  73321. * @param scale the number to scale with
  73322. * @param result a vector to store the result in
  73323. * @returns the current Vector4.
  73324. */
  73325. Vector4.prototype.scaleToRef = function (scale, result) {
  73326. result.x = this.x * scale;
  73327. result.y = this.y * scale;
  73328. result.z = this.z * scale;
  73329. result.w = this.w * scale;
  73330. return this;
  73331. };
  73332. /**
  73333. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  73334. * @param scale defines the scale factor
  73335. * @param result defines the Vector4 object where to store the result
  73336. * @returns the unmodified current Vector4
  73337. */
  73338. Vector4.prototype.scaleAndAddToRef = function (scale, result) {
  73339. result.x += this.x * scale;
  73340. result.y += this.y * scale;
  73341. result.z += this.z * scale;
  73342. result.w += this.w * scale;
  73343. return this;
  73344. };
  73345. /**
  73346. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  73347. * @param otherVector the vector to compare against
  73348. * @returns true if they are equal
  73349. */
  73350. Vector4.prototype.equals = function (otherVector) {
  73351. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z && this.w === otherVector.w;
  73352. };
  73353. /**
  73354. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  73355. * @param otherVector vector to compare against
  73356. * @param epsilon (Default: very small number)
  73357. * @returns true if they are equal
  73358. */
  73359. Vector4.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  73360. if (epsilon === void 0) { epsilon = Epsilon; }
  73361. return otherVector
  73362. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.x, otherVector.x, epsilon)
  73363. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.y, otherVector.y, epsilon)
  73364. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.z, otherVector.z, epsilon)
  73365. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.w, otherVector.w, epsilon);
  73366. };
  73367. /**
  73368. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  73369. * @param x x value to compare against
  73370. * @param y y value to compare against
  73371. * @param z z value to compare against
  73372. * @param w w value to compare against
  73373. * @returns true if equal
  73374. */
  73375. Vector4.prototype.equalsToFloats = function (x, y, z, w) {
  73376. return this.x === x && this.y === y && this.z === z && this.w === w;
  73377. };
  73378. /**
  73379. * Multiplies in place the current Vector4 by the given one.
  73380. * @param otherVector vector to multiple with
  73381. * @returns the updated Vector4.
  73382. */
  73383. Vector4.prototype.multiplyInPlace = function (otherVector) {
  73384. this.x *= otherVector.x;
  73385. this.y *= otherVector.y;
  73386. this.z *= otherVector.z;
  73387. this.w *= otherVector.w;
  73388. return this;
  73389. };
  73390. /**
  73391. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  73392. * @param otherVector vector to multiple with
  73393. * @returns resulting new vector
  73394. */
  73395. Vector4.prototype.multiply = function (otherVector) {
  73396. return new Vector4(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z, this.w * otherVector.w);
  73397. };
  73398. /**
  73399. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  73400. * @param otherVector vector to multiple with
  73401. * @param result vector to store the result
  73402. * @returns the current Vector4.
  73403. */
  73404. Vector4.prototype.multiplyToRef = function (otherVector, result) {
  73405. result.x = this.x * otherVector.x;
  73406. result.y = this.y * otherVector.y;
  73407. result.z = this.z * otherVector.z;
  73408. result.w = this.w * otherVector.w;
  73409. return this;
  73410. };
  73411. /**
  73412. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  73413. * @param x x value multiply with
  73414. * @param y y value multiply with
  73415. * @param z z value multiply with
  73416. * @param w w value multiply with
  73417. * @returns resulting new vector
  73418. */
  73419. Vector4.prototype.multiplyByFloats = function (x, y, z, w) {
  73420. return new Vector4(this.x * x, this.y * y, this.z * z, this.w * w);
  73421. };
  73422. /**
  73423. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  73424. * @param otherVector vector to devide with
  73425. * @returns resulting new vector
  73426. */
  73427. Vector4.prototype.divide = function (otherVector) {
  73428. return new Vector4(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z, this.w / otherVector.w);
  73429. };
  73430. /**
  73431. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  73432. * @param otherVector vector to devide with
  73433. * @param result vector to store the result
  73434. * @returns the current Vector4.
  73435. */
  73436. Vector4.prototype.divideToRef = function (otherVector, result) {
  73437. result.x = this.x / otherVector.x;
  73438. result.y = this.y / otherVector.y;
  73439. result.z = this.z / otherVector.z;
  73440. result.w = this.w / otherVector.w;
  73441. return this;
  73442. };
  73443. /**
  73444. * Divides the current Vector3 coordinates by the given ones.
  73445. * @param otherVector vector to devide with
  73446. * @returns the updated Vector3.
  73447. */
  73448. Vector4.prototype.divideInPlace = function (otherVector) {
  73449. return this.divideToRef(otherVector, this);
  73450. };
  73451. /**
  73452. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  73453. * @param other defines the second operand
  73454. * @returns the current updated Vector4
  73455. */
  73456. Vector4.prototype.minimizeInPlace = function (other) {
  73457. if (other.x < this.x) {
  73458. this.x = other.x;
  73459. }
  73460. if (other.y < this.y) {
  73461. this.y = other.y;
  73462. }
  73463. if (other.z < this.z) {
  73464. this.z = other.z;
  73465. }
  73466. if (other.w < this.w) {
  73467. this.w = other.w;
  73468. }
  73469. return this;
  73470. };
  73471. /**
  73472. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  73473. * @param other defines the second operand
  73474. * @returns the current updated Vector4
  73475. */
  73476. Vector4.prototype.maximizeInPlace = function (other) {
  73477. if (other.x > this.x) {
  73478. this.x = other.x;
  73479. }
  73480. if (other.y > this.y) {
  73481. this.y = other.y;
  73482. }
  73483. if (other.z > this.z) {
  73484. this.z = other.z;
  73485. }
  73486. if (other.w > this.w) {
  73487. this.w = other.w;
  73488. }
  73489. return this;
  73490. };
  73491. /**
  73492. * Gets a new Vector4 from current Vector4 floored values
  73493. * @returns a new Vector4
  73494. */
  73495. Vector4.prototype.floor = function () {
  73496. return new Vector4(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z), Math.floor(this.w));
  73497. };
  73498. /**
  73499. * Gets a new Vector4 from current Vector3 floored values
  73500. * @returns a new Vector4
  73501. */
  73502. Vector4.prototype.fract = function () {
  73503. 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));
  73504. };
  73505. // Properties
  73506. /**
  73507. * Returns the Vector4 length (float).
  73508. * @returns the length
  73509. */
  73510. Vector4.prototype.length = function () {
  73511. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  73512. };
  73513. /**
  73514. * Returns the Vector4 squared length (float).
  73515. * @returns the length squared
  73516. */
  73517. Vector4.prototype.lengthSquared = function () {
  73518. return (this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  73519. };
  73520. // Methods
  73521. /**
  73522. * Normalizes in place the Vector4.
  73523. * @returns the updated Vector4.
  73524. */
  73525. Vector4.prototype.normalize = function () {
  73526. var len = this.length();
  73527. if (len === 0) {
  73528. return this;
  73529. }
  73530. return this.scaleInPlace(1.0 / len);
  73531. };
  73532. /**
  73533. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  73534. * @returns this converted to a new vector3
  73535. */
  73536. Vector4.prototype.toVector3 = function () {
  73537. return new Vector3(this.x, this.y, this.z);
  73538. };
  73539. /**
  73540. * Returns a new Vector4 copied from the current one.
  73541. * @returns the new cloned vector
  73542. */
  73543. Vector4.prototype.clone = function () {
  73544. return new Vector4(this.x, this.y, this.z, this.w);
  73545. };
  73546. /**
  73547. * Updates the current Vector4 with the given one coordinates.
  73548. * @param source the source vector to copy from
  73549. * @returns the updated Vector4.
  73550. */
  73551. Vector4.prototype.copyFrom = function (source) {
  73552. this.x = source.x;
  73553. this.y = source.y;
  73554. this.z = source.z;
  73555. this.w = source.w;
  73556. return this;
  73557. };
  73558. /**
  73559. * Updates the current Vector4 coordinates with the given floats.
  73560. * @param x float to copy from
  73561. * @param y float to copy from
  73562. * @param z float to copy from
  73563. * @param w float to copy from
  73564. * @returns the updated Vector4.
  73565. */
  73566. Vector4.prototype.copyFromFloats = function (x, y, z, w) {
  73567. this.x = x;
  73568. this.y = y;
  73569. this.z = z;
  73570. this.w = w;
  73571. return this;
  73572. };
  73573. /**
  73574. * Updates the current Vector4 coordinates with the given floats.
  73575. * @param x float to set from
  73576. * @param y float to set from
  73577. * @param z float to set from
  73578. * @param w float to set from
  73579. * @returns the updated Vector4.
  73580. */
  73581. Vector4.prototype.set = function (x, y, z, w) {
  73582. return this.copyFromFloats(x, y, z, w);
  73583. };
  73584. /**
  73585. * Copies the given float to the current Vector3 coordinates
  73586. * @param v defines the x, y, z and w coordinates of the operand
  73587. * @returns the current updated Vector3
  73588. */
  73589. Vector4.prototype.setAll = function (v) {
  73590. this.x = this.y = this.z = this.w = v;
  73591. return this;
  73592. };
  73593. // Statics
  73594. /**
  73595. * Returns a new Vector4 set from the starting index of the given array.
  73596. * @param array the array to pull values from
  73597. * @param offset the offset into the array to start at
  73598. * @returns the new vector
  73599. */
  73600. Vector4.FromArray = function (array, offset) {
  73601. if (!offset) {
  73602. offset = 0;
  73603. }
  73604. return new Vector4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  73605. };
  73606. /**
  73607. * Updates the given vector "result" from the starting index of the given array.
  73608. * @param array the array to pull values from
  73609. * @param offset the offset into the array to start at
  73610. * @param result the vector to store the result in
  73611. */
  73612. Vector4.FromArrayToRef = function (array, offset, result) {
  73613. result.x = array[offset];
  73614. result.y = array[offset + 1];
  73615. result.z = array[offset + 2];
  73616. result.w = array[offset + 3];
  73617. };
  73618. /**
  73619. * Updates the given vector "result" from the starting index of the given Float32Array.
  73620. * @param array the array to pull values from
  73621. * @param offset the offset into the array to start at
  73622. * @param result the vector to store the result in
  73623. */
  73624. Vector4.FromFloatArrayToRef = function (array, offset, result) {
  73625. Vector4.FromArrayToRef(array, offset, result);
  73626. };
  73627. /**
  73628. * Updates the given vector "result" coordinates from the given floats.
  73629. * @param x float to set from
  73630. * @param y float to set from
  73631. * @param z float to set from
  73632. * @param w float to set from
  73633. * @param result the vector to the floats in
  73634. */
  73635. Vector4.FromFloatsToRef = function (x, y, z, w, result) {
  73636. result.x = x;
  73637. result.y = y;
  73638. result.z = z;
  73639. result.w = w;
  73640. };
  73641. /**
  73642. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  73643. * @returns the new vector
  73644. */
  73645. Vector4.Zero = function () {
  73646. return new Vector4(0.0, 0.0, 0.0, 0.0);
  73647. };
  73648. /**
  73649. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  73650. * @returns the new vector
  73651. */
  73652. Vector4.One = function () {
  73653. return new Vector4(1.0, 1.0, 1.0, 1.0);
  73654. };
  73655. /**
  73656. * Returns a new normalized Vector4 from the given one.
  73657. * @param vector the vector to normalize
  73658. * @returns the vector
  73659. */
  73660. Vector4.Normalize = function (vector) {
  73661. var result = Vector4.Zero();
  73662. Vector4.NormalizeToRef(vector, result);
  73663. return result;
  73664. };
  73665. /**
  73666. * Updates the given vector "result" from the normalization of the given one.
  73667. * @param vector the vector to normalize
  73668. * @param result the vector to store the result in
  73669. */
  73670. Vector4.NormalizeToRef = function (vector, result) {
  73671. result.copyFrom(vector);
  73672. result.normalize();
  73673. };
  73674. /**
  73675. * Returns a vector with the minimum values from the left and right vectors
  73676. * @param left left vector to minimize
  73677. * @param right right vector to minimize
  73678. * @returns a new vector with the minimum of the left and right vector values
  73679. */
  73680. Vector4.Minimize = function (left, right) {
  73681. var min = left.clone();
  73682. min.minimizeInPlace(right);
  73683. return min;
  73684. };
  73685. /**
  73686. * Returns a vector with the maximum values from the left and right vectors
  73687. * @param left left vector to maximize
  73688. * @param right right vector to maximize
  73689. * @returns a new vector with the maximum of the left and right vector values
  73690. */
  73691. Vector4.Maximize = function (left, right) {
  73692. var max = left.clone();
  73693. max.maximizeInPlace(right);
  73694. return max;
  73695. };
  73696. /**
  73697. * Returns the distance (float) between the vectors "value1" and "value2".
  73698. * @param value1 value to calulate the distance between
  73699. * @param value2 value to calulate the distance between
  73700. * @return the distance between the two vectors
  73701. */
  73702. Vector4.Distance = function (value1, value2) {
  73703. return Math.sqrt(Vector4.DistanceSquared(value1, value2));
  73704. };
  73705. /**
  73706. * Returns the squared distance (float) between the vectors "value1" and "value2".
  73707. * @param value1 value to calulate the distance between
  73708. * @param value2 value to calulate the distance between
  73709. * @return the distance between the two vectors squared
  73710. */
  73711. Vector4.DistanceSquared = function (value1, value2) {
  73712. var x = value1.x - value2.x;
  73713. var y = value1.y - value2.y;
  73714. var z = value1.z - value2.z;
  73715. var w = value1.w - value2.w;
  73716. return (x * x) + (y * y) + (z * z) + (w * w);
  73717. };
  73718. /**
  73719. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  73720. * @param value1 value to calulate the center between
  73721. * @param value2 value to calulate the center between
  73722. * @return the center between the two vectors
  73723. */
  73724. Vector4.Center = function (value1, value2) {
  73725. var center = value1.add(value2);
  73726. center.scaleInPlace(0.5);
  73727. return center;
  73728. };
  73729. /**
  73730. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  73731. * This methods computes transformed normalized direction vectors only.
  73732. * @param vector the vector to transform
  73733. * @param transformation the transformation matrix to apply
  73734. * @returns the new vector
  73735. */
  73736. Vector4.TransformNormal = function (vector, transformation) {
  73737. var result = Vector4.Zero();
  73738. Vector4.TransformNormalToRef(vector, transformation, result);
  73739. return result;
  73740. };
  73741. /**
  73742. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  73743. * This methods computes transformed normalized direction vectors only.
  73744. * @param vector the vector to transform
  73745. * @param transformation the transformation matrix to apply
  73746. * @param result the vector to store the result in
  73747. */
  73748. Vector4.TransformNormalToRef = function (vector, transformation, result) {
  73749. var m = transformation.m;
  73750. var x = (vector.x * m[0]) + (vector.y * m[4]) + (vector.z * m[8]);
  73751. var y = (vector.x * m[1]) + (vector.y * m[5]) + (vector.z * m[9]);
  73752. var z = (vector.x * m[2]) + (vector.y * m[6]) + (vector.z * m[10]);
  73753. result.x = x;
  73754. result.y = y;
  73755. result.z = z;
  73756. result.w = vector.w;
  73757. };
  73758. /**
  73759. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  73760. * This methods computes transformed normalized direction vectors only.
  73761. * @param x value to transform
  73762. * @param y value to transform
  73763. * @param z value to transform
  73764. * @param w value to transform
  73765. * @param transformation the transformation matrix to apply
  73766. * @param result the vector to store the results in
  73767. */
  73768. Vector4.TransformNormalFromFloatsToRef = function (x, y, z, w, transformation, result) {
  73769. var m = transformation.m;
  73770. result.x = (x * m[0]) + (y * m[4]) + (z * m[8]);
  73771. result.y = (x * m[1]) + (y * m[5]) + (z * m[9]);
  73772. result.z = (x * m[2]) + (y * m[6]) + (z * m[10]);
  73773. result.w = w;
  73774. };
  73775. /**
  73776. * Creates a new Vector4 from a Vector3
  73777. * @param source defines the source data
  73778. * @param w defines the 4th component (default is 0)
  73779. * @returns a new Vector4
  73780. */
  73781. Vector4.FromVector3 = function (source, w) {
  73782. if (w === void 0) { w = 0; }
  73783. return new Vector4(source.x, source.y, source.z, w);
  73784. };
  73785. return Vector4;
  73786. }());
  73787. /**
  73788. * Size containing widht and height
  73789. */
  73790. var Size = /** @class */ (function () {
  73791. /**
  73792. * Creates a Size object from the given width and height (floats).
  73793. * @param width width of the new size
  73794. * @param height height of the new size
  73795. */
  73796. function Size(width, height) {
  73797. this.width = width;
  73798. this.height = height;
  73799. }
  73800. /**
  73801. * Returns a string with the Size width and height
  73802. * @returns a string with the Size width and height
  73803. */
  73804. Size.prototype.toString = function () {
  73805. return "{W: " + this.width + ", H: " + this.height + "}";
  73806. };
  73807. /**
  73808. * "Size"
  73809. * @returns the string "Size"
  73810. */
  73811. Size.prototype.getClassName = function () {
  73812. return "Size";
  73813. };
  73814. /**
  73815. * Returns the Size hash code.
  73816. * @returns a hash code for a unique width and height
  73817. */
  73818. Size.prototype.getHashCode = function () {
  73819. var hash = this.width || 0;
  73820. hash = (hash * 397) ^ (this.height || 0);
  73821. return hash;
  73822. };
  73823. /**
  73824. * Updates the current size from the given one.
  73825. * @param src the given size
  73826. */
  73827. Size.prototype.copyFrom = function (src) {
  73828. this.width = src.width;
  73829. this.height = src.height;
  73830. };
  73831. /**
  73832. * Updates in place the current Size from the given floats.
  73833. * @param width width of the new size
  73834. * @param height height of the new size
  73835. * @returns the updated Size.
  73836. */
  73837. Size.prototype.copyFromFloats = function (width, height) {
  73838. this.width = width;
  73839. this.height = height;
  73840. return this;
  73841. };
  73842. /**
  73843. * Updates in place the current Size from the given floats.
  73844. * @param width width to set
  73845. * @param height height to set
  73846. * @returns the updated Size.
  73847. */
  73848. Size.prototype.set = function (width, height) {
  73849. return this.copyFromFloats(width, height);
  73850. };
  73851. /**
  73852. * Multiplies the width and height by numbers
  73853. * @param w factor to multiple the width by
  73854. * @param h factor to multiple the height by
  73855. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  73856. */
  73857. Size.prototype.multiplyByFloats = function (w, h) {
  73858. return new Size(this.width * w, this.height * h);
  73859. };
  73860. /**
  73861. * Clones the size
  73862. * @returns a new Size copied from the given one.
  73863. */
  73864. Size.prototype.clone = function () {
  73865. return new Size(this.width, this.height);
  73866. };
  73867. /**
  73868. * True if the current Size and the given one width and height are strictly equal.
  73869. * @param other the other size to compare against
  73870. * @returns True if the current Size and the given one width and height are strictly equal.
  73871. */
  73872. Size.prototype.equals = function (other) {
  73873. if (!other) {
  73874. return false;
  73875. }
  73876. return (this.width === other.width) && (this.height === other.height);
  73877. };
  73878. Object.defineProperty(Size.prototype, "surface", {
  73879. /**
  73880. * The surface of the Size : width * height (float).
  73881. */
  73882. get: function () {
  73883. return this.width * this.height;
  73884. },
  73885. enumerable: true,
  73886. configurable: true
  73887. });
  73888. /**
  73889. * Create a new size of zero
  73890. * @returns a new Size set to (0.0, 0.0)
  73891. */
  73892. Size.Zero = function () {
  73893. return new Size(0.0, 0.0);
  73894. };
  73895. /**
  73896. * Sums the width and height of two sizes
  73897. * @param otherSize size to add to this size
  73898. * @returns a new Size set as the addition result of the current Size and the given one.
  73899. */
  73900. Size.prototype.add = function (otherSize) {
  73901. var r = new Size(this.width + otherSize.width, this.height + otherSize.height);
  73902. return r;
  73903. };
  73904. /**
  73905. * Subtracts the width and height of two
  73906. * @param otherSize size to subtract to this size
  73907. * @returns a new Size set as the subtraction result of the given one from the current Size.
  73908. */
  73909. Size.prototype.subtract = function (otherSize) {
  73910. var r = new Size(this.width - otherSize.width, this.height - otherSize.height);
  73911. return r;
  73912. };
  73913. /**
  73914. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  73915. * @param start starting size to lerp between
  73916. * @param end end size to lerp between
  73917. * @param amount amount to lerp between the start and end values
  73918. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  73919. */
  73920. Size.Lerp = function (start, end, amount) {
  73921. var w = start.width + ((end.width - start.width) * amount);
  73922. var h = start.height + ((end.height - start.height) * amount);
  73923. return new Size(w, h);
  73924. };
  73925. return Size;
  73926. }());
  73927. /**
  73928. * Class used to store quaternion data
  73929. * @see https://en.wikipedia.org/wiki/Quaternion
  73930. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  73931. */
  73932. var Quaternion = /** @class */ (function () {
  73933. /**
  73934. * Creates a new Quaternion from the given floats
  73935. * @param x defines the first component (0 by default)
  73936. * @param y defines the second component (0 by default)
  73937. * @param z defines the third component (0 by default)
  73938. * @param w defines the fourth component (1.0 by default)
  73939. */
  73940. function Quaternion(
  73941. /** defines the first component (0 by default) */
  73942. x,
  73943. /** defines the second component (0 by default) */
  73944. y,
  73945. /** defines the third component (0 by default) */
  73946. z,
  73947. /** defines the fourth component (1.0 by default) */
  73948. w) {
  73949. if (x === void 0) { x = 0.0; }
  73950. if (y === void 0) { y = 0.0; }
  73951. if (z === void 0) { z = 0.0; }
  73952. if (w === void 0) { w = 1.0; }
  73953. this.x = x;
  73954. this.y = y;
  73955. this.z = z;
  73956. this.w = w;
  73957. }
  73958. /**
  73959. * Gets a string representation for the current quaternion
  73960. * @returns a string with the Quaternion coordinates
  73961. */
  73962. Quaternion.prototype.toString = function () {
  73963. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  73964. };
  73965. /**
  73966. * Gets the class name of the quaternion
  73967. * @returns the string "Quaternion"
  73968. */
  73969. Quaternion.prototype.getClassName = function () {
  73970. return "Quaternion";
  73971. };
  73972. /**
  73973. * Gets a hash code for this quaternion
  73974. * @returns the quaternion hash code
  73975. */
  73976. Quaternion.prototype.getHashCode = function () {
  73977. var hash = this.x || 0;
  73978. hash = (hash * 397) ^ (this.y || 0);
  73979. hash = (hash * 397) ^ (this.z || 0);
  73980. hash = (hash * 397) ^ (this.w || 0);
  73981. return hash;
  73982. };
  73983. /**
  73984. * Copy the quaternion to an array
  73985. * @returns a new array populated with 4 elements from the quaternion coordinates
  73986. */
  73987. Quaternion.prototype.asArray = function () {
  73988. return [this.x, this.y, this.z, this.w];
  73989. };
  73990. /**
  73991. * Check if two quaternions are equals
  73992. * @param otherQuaternion defines the second operand
  73993. * @return true if the current quaternion and the given one coordinates are strictly equals
  73994. */
  73995. Quaternion.prototype.equals = function (otherQuaternion) {
  73996. return otherQuaternion && this.x === otherQuaternion.x && this.y === otherQuaternion.y && this.z === otherQuaternion.z && this.w === otherQuaternion.w;
  73997. };
  73998. /**
  73999. * Clone the current quaternion
  74000. * @returns a new quaternion copied from the current one
  74001. */
  74002. Quaternion.prototype.clone = function () {
  74003. return new Quaternion(this.x, this.y, this.z, this.w);
  74004. };
  74005. /**
  74006. * Copy a quaternion to the current one
  74007. * @param other defines the other quaternion
  74008. * @returns the updated current quaternion
  74009. */
  74010. Quaternion.prototype.copyFrom = function (other) {
  74011. this.x = other.x;
  74012. this.y = other.y;
  74013. this.z = other.z;
  74014. this.w = other.w;
  74015. return this;
  74016. };
  74017. /**
  74018. * Updates the current quaternion with the given float coordinates
  74019. * @param x defines the x coordinate
  74020. * @param y defines the y coordinate
  74021. * @param z defines the z coordinate
  74022. * @param w defines the w coordinate
  74023. * @returns the updated current quaternion
  74024. */
  74025. Quaternion.prototype.copyFromFloats = function (x, y, z, w) {
  74026. this.x = x;
  74027. this.y = y;
  74028. this.z = z;
  74029. this.w = w;
  74030. return this;
  74031. };
  74032. /**
  74033. * Updates the current quaternion from the given float coordinates
  74034. * @param x defines the x coordinate
  74035. * @param y defines the y coordinate
  74036. * @param z defines the z coordinate
  74037. * @param w defines the w coordinate
  74038. * @returns the updated current quaternion
  74039. */
  74040. Quaternion.prototype.set = function (x, y, z, w) {
  74041. return this.copyFromFloats(x, y, z, w);
  74042. };
  74043. /**
  74044. * Adds two quaternions
  74045. * @param other defines the second operand
  74046. * @returns a new quaternion as the addition result of the given one and the current quaternion
  74047. */
  74048. Quaternion.prototype.add = function (other) {
  74049. return new Quaternion(this.x + other.x, this.y + other.y, this.z + other.z, this.w + other.w);
  74050. };
  74051. /**
  74052. * Add a quaternion to the current one
  74053. * @param other defines the quaternion to add
  74054. * @returns the current quaternion
  74055. */
  74056. Quaternion.prototype.addInPlace = function (other) {
  74057. this.x += other.x;
  74058. this.y += other.y;
  74059. this.z += other.z;
  74060. this.w += other.w;
  74061. return this;
  74062. };
  74063. /**
  74064. * Subtract two quaternions
  74065. * @param other defines the second operand
  74066. * @returns a new quaternion as the subtraction result of the given one from the current one
  74067. */
  74068. Quaternion.prototype.subtract = function (other) {
  74069. return new Quaternion(this.x - other.x, this.y - other.y, this.z - other.z, this.w - other.w);
  74070. };
  74071. /**
  74072. * Multiplies the current quaternion by a scale factor
  74073. * @param value defines the scale factor
  74074. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  74075. */
  74076. Quaternion.prototype.scale = function (value) {
  74077. return new Quaternion(this.x * value, this.y * value, this.z * value, this.w * value);
  74078. };
  74079. /**
  74080. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  74081. * @param scale defines the scale factor
  74082. * @param result defines the Quaternion object where to store the result
  74083. * @returns the unmodified current quaternion
  74084. */
  74085. Quaternion.prototype.scaleToRef = function (scale, result) {
  74086. result.x = this.x * scale;
  74087. result.y = this.y * scale;
  74088. result.z = this.z * scale;
  74089. result.w = this.w * scale;
  74090. return this;
  74091. };
  74092. /**
  74093. * Multiplies in place the current quaternion by a scale factor
  74094. * @param value defines the scale factor
  74095. * @returns the current modified quaternion
  74096. */
  74097. Quaternion.prototype.scaleInPlace = function (value) {
  74098. this.x *= value;
  74099. this.y *= value;
  74100. this.z *= value;
  74101. this.w *= value;
  74102. return this;
  74103. };
  74104. /**
  74105. * Scale the current quaternion values by a factor and add the result to a given quaternion
  74106. * @param scale defines the scale factor
  74107. * @param result defines the Quaternion object where to store the result
  74108. * @returns the unmodified current quaternion
  74109. */
  74110. Quaternion.prototype.scaleAndAddToRef = function (scale, result) {
  74111. result.x += this.x * scale;
  74112. result.y += this.y * scale;
  74113. result.z += this.z * scale;
  74114. result.w += this.w * scale;
  74115. return this;
  74116. };
  74117. /**
  74118. * Multiplies two quaternions
  74119. * @param q1 defines the second operand
  74120. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  74121. */
  74122. Quaternion.prototype.multiply = function (q1) {
  74123. var result = new Quaternion(0, 0, 0, 1.0);
  74124. this.multiplyToRef(q1, result);
  74125. return result;
  74126. };
  74127. /**
  74128. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  74129. * @param q1 defines the second operand
  74130. * @param result defines the target quaternion
  74131. * @returns the current quaternion
  74132. */
  74133. Quaternion.prototype.multiplyToRef = function (q1, result) {
  74134. var x = this.x * q1.w + this.y * q1.z - this.z * q1.y + this.w * q1.x;
  74135. var y = -this.x * q1.z + this.y * q1.w + this.z * q1.x + this.w * q1.y;
  74136. var z = this.x * q1.y - this.y * q1.x + this.z * q1.w + this.w * q1.z;
  74137. var w = -this.x * q1.x - this.y * q1.y - this.z * q1.z + this.w * q1.w;
  74138. result.copyFromFloats(x, y, z, w);
  74139. return this;
  74140. };
  74141. /**
  74142. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  74143. * @param q1 defines the second operand
  74144. * @returns the currentupdated quaternion
  74145. */
  74146. Quaternion.prototype.multiplyInPlace = function (q1) {
  74147. this.multiplyToRef(q1, this);
  74148. return this;
  74149. };
  74150. /**
  74151. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  74152. * @param ref defines the target quaternion
  74153. * @returns the current quaternion
  74154. */
  74155. Quaternion.prototype.conjugateToRef = function (ref) {
  74156. ref.copyFromFloats(-this.x, -this.y, -this.z, this.w);
  74157. return this;
  74158. };
  74159. /**
  74160. * Conjugates in place (1-q) the current quaternion
  74161. * @returns the current updated quaternion
  74162. */
  74163. Quaternion.prototype.conjugateInPlace = function () {
  74164. this.x *= -1;
  74165. this.y *= -1;
  74166. this.z *= -1;
  74167. return this;
  74168. };
  74169. /**
  74170. * Conjugates in place (1-q) the current quaternion
  74171. * @returns a new quaternion
  74172. */
  74173. Quaternion.prototype.conjugate = function () {
  74174. var result = new Quaternion(-this.x, -this.y, -this.z, this.w);
  74175. return result;
  74176. };
  74177. /**
  74178. * Gets length of current quaternion
  74179. * @returns the quaternion length (float)
  74180. */
  74181. Quaternion.prototype.length = function () {
  74182. return Math.sqrt((this.x * this.x) + (this.y * this.y) + (this.z * this.z) + (this.w * this.w));
  74183. };
  74184. /**
  74185. * Normalize in place the current quaternion
  74186. * @returns the current updated quaternion
  74187. */
  74188. Quaternion.prototype.normalize = function () {
  74189. var len = this.length();
  74190. if (len === 0) {
  74191. return this;
  74192. }
  74193. var inv = 1.0 / len;
  74194. this.x *= inv;
  74195. this.y *= inv;
  74196. this.z *= inv;
  74197. this.w *= inv;
  74198. return this;
  74199. };
  74200. /**
  74201. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  74202. * @param order is a reserved parameter and is ignore for now
  74203. * @returns a new Vector3 containing the Euler angles
  74204. */
  74205. Quaternion.prototype.toEulerAngles = function (order) {
  74206. if (order === void 0) { order = "YZX"; }
  74207. var result = Vector3.Zero();
  74208. this.toEulerAnglesToRef(result);
  74209. return result;
  74210. };
  74211. /**
  74212. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  74213. * @param result defines the vector which will be filled with the Euler angles
  74214. * @param order is a reserved parameter and is ignore for now
  74215. * @returns the current unchanged quaternion
  74216. */
  74217. Quaternion.prototype.toEulerAnglesToRef = function (result) {
  74218. var qz = this.z;
  74219. var qx = this.x;
  74220. var qy = this.y;
  74221. var qw = this.w;
  74222. var sqw = qw * qw;
  74223. var sqz = qz * qz;
  74224. var sqx = qx * qx;
  74225. var sqy = qy * qy;
  74226. var zAxisY = qy * qz - qx * qw;
  74227. var limit = .4999999;
  74228. if (zAxisY < -limit) {
  74229. result.y = 2 * Math.atan2(qy, qw);
  74230. result.x = Math.PI / 2;
  74231. result.z = 0;
  74232. }
  74233. else if (zAxisY > limit) {
  74234. result.y = 2 * Math.atan2(qy, qw);
  74235. result.x = -Math.PI / 2;
  74236. result.z = 0;
  74237. }
  74238. else {
  74239. result.z = Math.atan2(2.0 * (qx * qy + qz * qw), (-sqz - sqx + sqy + sqw));
  74240. result.x = Math.asin(-2.0 * (qz * qy - qx * qw));
  74241. result.y = Math.atan2(2.0 * (qz * qx + qy * qw), (sqz - sqx - sqy + sqw));
  74242. }
  74243. return this;
  74244. };
  74245. /**
  74246. * Updates the given rotation matrix with the current quaternion values
  74247. * @param result defines the target matrix
  74248. * @returns the current unchanged quaternion
  74249. */
  74250. Quaternion.prototype.toRotationMatrix = function (result) {
  74251. Matrix.FromQuaternionToRef(this, result);
  74252. return this;
  74253. };
  74254. /**
  74255. * Updates the current quaternion from the given rotation matrix values
  74256. * @param matrix defines the source matrix
  74257. * @returns the current updated quaternion
  74258. */
  74259. Quaternion.prototype.fromRotationMatrix = function (matrix) {
  74260. Quaternion.FromRotationMatrixToRef(matrix, this);
  74261. return this;
  74262. };
  74263. // Statics
  74264. /**
  74265. * Creates a new quaternion from a rotation matrix
  74266. * @param matrix defines the source matrix
  74267. * @returns a new quaternion created from the given rotation matrix values
  74268. */
  74269. Quaternion.FromRotationMatrix = function (matrix) {
  74270. var result = new Quaternion();
  74271. Quaternion.FromRotationMatrixToRef(matrix, result);
  74272. return result;
  74273. };
  74274. /**
  74275. * Updates the given quaternion with the given rotation matrix values
  74276. * @param matrix defines the source matrix
  74277. * @param result defines the target quaternion
  74278. */
  74279. Quaternion.FromRotationMatrixToRef = function (matrix, result) {
  74280. var data = matrix.m;
  74281. var m11 = data[0], m12 = data[4], m13 = data[8];
  74282. var m21 = data[1], m22 = data[5], m23 = data[9];
  74283. var m31 = data[2], m32 = data[6], m33 = data[10];
  74284. var trace = m11 + m22 + m33;
  74285. var s;
  74286. if (trace > 0) {
  74287. s = 0.5 / Math.sqrt(trace + 1.0);
  74288. result.w = 0.25 / s;
  74289. result.x = (m32 - m23) * s;
  74290. result.y = (m13 - m31) * s;
  74291. result.z = (m21 - m12) * s;
  74292. }
  74293. else if (m11 > m22 && m11 > m33) {
  74294. s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
  74295. result.w = (m32 - m23) / s;
  74296. result.x = 0.25 * s;
  74297. result.y = (m12 + m21) / s;
  74298. result.z = (m13 + m31) / s;
  74299. }
  74300. else if (m22 > m33) {
  74301. s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
  74302. result.w = (m13 - m31) / s;
  74303. result.x = (m12 + m21) / s;
  74304. result.y = 0.25 * s;
  74305. result.z = (m23 + m32) / s;
  74306. }
  74307. else {
  74308. s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
  74309. result.w = (m21 - m12) / s;
  74310. result.x = (m13 + m31) / s;
  74311. result.y = (m23 + m32) / s;
  74312. result.z = 0.25 * s;
  74313. }
  74314. };
  74315. /**
  74316. * Returns the dot product (float) between the quaternions "left" and "right"
  74317. * @param left defines the left operand
  74318. * @param right defines the right operand
  74319. * @returns the dot product
  74320. */
  74321. Quaternion.Dot = function (left, right) {
  74322. return (left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w);
  74323. };
  74324. /**
  74325. * Checks if the two quaternions are close to each other
  74326. * @param quat0 defines the first quaternion to check
  74327. * @param quat1 defines the second quaternion to check
  74328. * @returns true if the two quaternions are close to each other
  74329. */
  74330. Quaternion.AreClose = function (quat0, quat1) {
  74331. var dot = Quaternion.Dot(quat0, quat1);
  74332. return dot >= 0;
  74333. };
  74334. /**
  74335. * Creates an empty quaternion
  74336. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  74337. */
  74338. Quaternion.Zero = function () {
  74339. return new Quaternion(0.0, 0.0, 0.0, 0.0);
  74340. };
  74341. /**
  74342. * Inverse a given quaternion
  74343. * @param q defines the source quaternion
  74344. * @returns a new quaternion as the inverted current quaternion
  74345. */
  74346. Quaternion.Inverse = function (q) {
  74347. return new Quaternion(-q.x, -q.y, -q.z, q.w);
  74348. };
  74349. /**
  74350. * Inverse a given quaternion
  74351. * @param q defines the source quaternion
  74352. * @param result the quaternion the result will be stored in
  74353. * @returns the result quaternion
  74354. */
  74355. Quaternion.InverseToRef = function (q, result) {
  74356. result.set(-q.x, -q.y, -q.z, q.w);
  74357. return result;
  74358. };
  74359. /**
  74360. * Creates an identity quaternion
  74361. * @returns the identity quaternion
  74362. */
  74363. Quaternion.Identity = function () {
  74364. return new Quaternion(0.0, 0.0, 0.0, 1.0);
  74365. };
  74366. /**
  74367. * Gets a boolean indicating if the given quaternion is identity
  74368. * @param quaternion defines the quaternion to check
  74369. * @returns true if the quaternion is identity
  74370. */
  74371. Quaternion.IsIdentity = function (quaternion) {
  74372. return quaternion && quaternion.x === 0 && quaternion.y === 0 && quaternion.z === 0 && quaternion.w === 1;
  74373. };
  74374. /**
  74375. * Creates a quaternion from a rotation around an axis
  74376. * @param axis defines the axis to use
  74377. * @param angle defines the angle to use
  74378. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  74379. */
  74380. Quaternion.RotationAxis = function (axis, angle) {
  74381. return Quaternion.RotationAxisToRef(axis, angle, new Quaternion());
  74382. };
  74383. /**
  74384. * Creates a rotation around an axis and stores it into the given quaternion
  74385. * @param axis defines the axis to use
  74386. * @param angle defines the angle to use
  74387. * @param result defines the target quaternion
  74388. * @returns the target quaternion
  74389. */
  74390. Quaternion.RotationAxisToRef = function (axis, angle, result) {
  74391. var sin = Math.sin(angle / 2);
  74392. axis.normalize();
  74393. result.w = Math.cos(angle / 2);
  74394. result.x = axis.x * sin;
  74395. result.y = axis.y * sin;
  74396. result.z = axis.z * sin;
  74397. return result;
  74398. };
  74399. /**
  74400. * Creates a new quaternion from data stored into an array
  74401. * @param array defines the data source
  74402. * @param offset defines the offset in the source array where the data starts
  74403. * @returns a new quaternion
  74404. */
  74405. Quaternion.FromArray = function (array, offset) {
  74406. if (!offset) {
  74407. offset = 0;
  74408. }
  74409. return new Quaternion(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  74410. };
  74411. /**
  74412. * Create a quaternion from Euler rotation angles
  74413. * @param x Pitch
  74414. * @param y Yaw
  74415. * @param z Roll
  74416. * @returns the new Quaternion
  74417. */
  74418. Quaternion.FromEulerAngles = function (x, y, z) {
  74419. var q = new Quaternion();
  74420. Quaternion.RotationYawPitchRollToRef(y, x, z, q);
  74421. return q;
  74422. };
  74423. /**
  74424. * Updates a quaternion from Euler rotation angles
  74425. * @param x Pitch
  74426. * @param y Yaw
  74427. * @param z Roll
  74428. * @param result the quaternion to store the result
  74429. * @returns the updated quaternion
  74430. */
  74431. Quaternion.FromEulerAnglesToRef = function (x, y, z, result) {
  74432. Quaternion.RotationYawPitchRollToRef(y, x, z, result);
  74433. return result;
  74434. };
  74435. /**
  74436. * Create a quaternion from Euler rotation vector
  74437. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  74438. * @returns the new Quaternion
  74439. */
  74440. Quaternion.FromEulerVector = function (vec) {
  74441. var q = new Quaternion();
  74442. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, q);
  74443. return q;
  74444. };
  74445. /**
  74446. * Updates a quaternion from Euler rotation vector
  74447. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  74448. * @param result the quaternion to store the result
  74449. * @returns the updated quaternion
  74450. */
  74451. Quaternion.FromEulerVectorToRef = function (vec, result) {
  74452. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, result);
  74453. return result;
  74454. };
  74455. /**
  74456. * Creates a new quaternion from the given Euler float angles (y, x, z)
  74457. * @param yaw defines the rotation around Y axis
  74458. * @param pitch defines the rotation around X axis
  74459. * @param roll defines the rotation around Z axis
  74460. * @returns the new quaternion
  74461. */
  74462. Quaternion.RotationYawPitchRoll = function (yaw, pitch, roll) {
  74463. var q = new Quaternion();
  74464. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, q);
  74465. return q;
  74466. };
  74467. /**
  74468. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  74469. * @param yaw defines the rotation around Y axis
  74470. * @param pitch defines the rotation around X axis
  74471. * @param roll defines the rotation around Z axis
  74472. * @param result defines the target quaternion
  74473. */
  74474. Quaternion.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  74475. // Produces a quaternion from Euler angles in the z-y-x orientation (Tait-Bryan angles)
  74476. var halfRoll = roll * 0.5;
  74477. var halfPitch = pitch * 0.5;
  74478. var halfYaw = yaw * 0.5;
  74479. var sinRoll = Math.sin(halfRoll);
  74480. var cosRoll = Math.cos(halfRoll);
  74481. var sinPitch = Math.sin(halfPitch);
  74482. var cosPitch = Math.cos(halfPitch);
  74483. var sinYaw = Math.sin(halfYaw);
  74484. var cosYaw = Math.cos(halfYaw);
  74485. result.x = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);
  74486. result.y = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);
  74487. result.z = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch * cosRoll);
  74488. result.w = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch * sinRoll);
  74489. };
  74490. /**
  74491. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  74492. * @param alpha defines the rotation around first axis
  74493. * @param beta defines the rotation around second axis
  74494. * @param gamma defines the rotation around third axis
  74495. * @returns the new quaternion
  74496. */
  74497. Quaternion.RotationAlphaBetaGamma = function (alpha, beta, gamma) {
  74498. var result = new Quaternion();
  74499. Quaternion.RotationAlphaBetaGammaToRef(alpha, beta, gamma, result);
  74500. return result;
  74501. };
  74502. /**
  74503. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  74504. * @param alpha defines the rotation around first axis
  74505. * @param beta defines the rotation around second axis
  74506. * @param gamma defines the rotation around third axis
  74507. * @param result defines the target quaternion
  74508. */
  74509. Quaternion.RotationAlphaBetaGammaToRef = function (alpha, beta, gamma, result) {
  74510. // Produces a quaternion from Euler angles in the z-x-z orientation
  74511. var halfGammaPlusAlpha = (gamma + alpha) * 0.5;
  74512. var halfGammaMinusAlpha = (gamma - alpha) * 0.5;
  74513. var halfBeta = beta * 0.5;
  74514. result.x = Math.cos(halfGammaMinusAlpha) * Math.sin(halfBeta);
  74515. result.y = Math.sin(halfGammaMinusAlpha) * Math.sin(halfBeta);
  74516. result.z = Math.sin(halfGammaPlusAlpha) * Math.cos(halfBeta);
  74517. result.w = Math.cos(halfGammaPlusAlpha) * Math.cos(halfBeta);
  74518. };
  74519. /**
  74520. * 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)
  74521. * @param axis1 defines the first axis
  74522. * @param axis2 defines the second axis
  74523. * @param axis3 defines the third axis
  74524. * @returns the new quaternion
  74525. */
  74526. Quaternion.RotationQuaternionFromAxis = function (axis1, axis2, axis3) {
  74527. var quat = new Quaternion(0.0, 0.0, 0.0, 0.0);
  74528. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  74529. return quat;
  74530. };
  74531. /**
  74532. * 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
  74533. * @param axis1 defines the first axis
  74534. * @param axis2 defines the second axis
  74535. * @param axis3 defines the third axis
  74536. * @param ref defines the target quaternion
  74537. */
  74538. Quaternion.RotationQuaternionFromAxisToRef = function (axis1, axis2, axis3, ref) {
  74539. var rotMat = MathTmp.Matrix[0];
  74540. Matrix.FromXYZAxesToRef(axis1.normalize(), axis2.normalize(), axis3.normalize(), rotMat);
  74541. Quaternion.FromRotationMatrixToRef(rotMat, ref);
  74542. };
  74543. /**
  74544. * Interpolates between two quaternions
  74545. * @param left defines first quaternion
  74546. * @param right defines second quaternion
  74547. * @param amount defines the gradient to use
  74548. * @returns the new interpolated quaternion
  74549. */
  74550. Quaternion.Slerp = function (left, right, amount) {
  74551. var result = Quaternion.Identity();
  74552. Quaternion.SlerpToRef(left, right, amount, result);
  74553. return result;
  74554. };
  74555. /**
  74556. * Interpolates between two quaternions and stores it into a target quaternion
  74557. * @param left defines first quaternion
  74558. * @param right defines second quaternion
  74559. * @param amount defines the gradient to use
  74560. * @param result defines the target quaternion
  74561. */
  74562. Quaternion.SlerpToRef = function (left, right, amount, result) {
  74563. var num2;
  74564. var num3;
  74565. var num4 = (((left.x * right.x) + (left.y * right.y)) + (left.z * right.z)) + (left.w * right.w);
  74566. var flag = false;
  74567. if (num4 < 0) {
  74568. flag = true;
  74569. num4 = -num4;
  74570. }
  74571. if (num4 > 0.999999) {
  74572. num3 = 1 - amount;
  74573. num2 = flag ? -amount : amount;
  74574. }
  74575. else {
  74576. var num5 = Math.acos(num4);
  74577. var num6 = (1.0 / Math.sin(num5));
  74578. num3 = (Math.sin((1.0 - amount) * num5)) * num6;
  74579. num2 = flag ? ((-Math.sin(amount * num5)) * num6) : ((Math.sin(amount * num5)) * num6);
  74580. }
  74581. result.x = (num3 * left.x) + (num2 * right.x);
  74582. result.y = (num3 * left.y) + (num2 * right.y);
  74583. result.z = (num3 * left.z) + (num2 * right.z);
  74584. result.w = (num3 * left.w) + (num2 * right.w);
  74585. };
  74586. /**
  74587. * Interpolate between two quaternions using Hermite interpolation
  74588. * @param value1 defines first quaternion
  74589. * @param tangent1 defines the incoming tangent
  74590. * @param value2 defines second quaternion
  74591. * @param tangent2 defines the outgoing tangent
  74592. * @param amount defines the target quaternion
  74593. * @returns the new interpolated quaternion
  74594. */
  74595. Quaternion.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  74596. var squared = amount * amount;
  74597. var cubed = amount * squared;
  74598. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  74599. var part2 = (-2.0 * cubed) + (3.0 * squared);
  74600. var part3 = (cubed - (2.0 * squared)) + amount;
  74601. var part4 = cubed - squared;
  74602. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  74603. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  74604. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  74605. var w = (((value1.w * part1) + (value2.w * part2)) + (tangent1.w * part3)) + (tangent2.w * part4);
  74606. return new Quaternion(x, y, z, w);
  74607. };
  74608. return Quaternion;
  74609. }());
  74610. /**
  74611. * Class used to store matrix data (4x4)
  74612. */
  74613. var Matrix = /** @class */ (function () {
  74614. /**
  74615. * Creates an empty matrix (filled with zeros)
  74616. */
  74617. function Matrix() {
  74618. this._isIdentity = false;
  74619. this._isIdentityDirty = true;
  74620. this._isIdentity3x2 = true;
  74621. this._isIdentity3x2Dirty = true;
  74622. this._m = new Float32Array(16);
  74623. this._updateIdentityStatus(false);
  74624. }
  74625. Object.defineProperty(Matrix.prototype, "m", {
  74626. /**
  74627. * Gets the internal data of the matrix
  74628. */
  74629. get: function () { return this._m; },
  74630. enumerable: true,
  74631. configurable: true
  74632. });
  74633. /** @hidden */
  74634. Matrix.prototype._markAsUpdated = function () {
  74635. this.updateFlag = Matrix._updateFlagSeed++;
  74636. this._isIdentity = false;
  74637. this._isIdentity3x2 = false;
  74638. this._isIdentityDirty = true;
  74639. this._isIdentity3x2Dirty = true;
  74640. };
  74641. /** @hidden */
  74642. Matrix.prototype._updateIdentityStatus = function (isIdentity, isIdentityDirty, isIdentity3x2, isIdentity3x2Dirty) {
  74643. if (isIdentityDirty === void 0) { isIdentityDirty = false; }
  74644. if (isIdentity3x2 === void 0) { isIdentity3x2 = false; }
  74645. if (isIdentity3x2Dirty === void 0) { isIdentity3x2Dirty = true; }
  74646. this.updateFlag = Matrix._updateFlagSeed++;
  74647. this._isIdentity = isIdentity;
  74648. this._isIdentity3x2 = isIdentity || isIdentity3x2;
  74649. this._isIdentityDirty = this._isIdentity ? false : isIdentityDirty;
  74650. this._isIdentity3x2Dirty = this._isIdentity3x2 ? false : isIdentity3x2Dirty;
  74651. };
  74652. // Properties
  74653. /**
  74654. * Check if the current matrix is identity
  74655. * @returns true is the matrix is the identity matrix
  74656. */
  74657. Matrix.prototype.isIdentity = function () {
  74658. if (this._isIdentityDirty) {
  74659. this._isIdentityDirty = false;
  74660. var m = this._m;
  74661. this._isIdentity = (m[0] === 1.0 && m[1] === 0.0 && m[2] === 0.0 && m[3] === 0.0 &&
  74662. m[4] === 0.0 && m[5] === 1.0 && m[6] === 0.0 && m[7] === 0.0 &&
  74663. m[8] === 0.0 && m[9] === 0.0 && m[10] === 1.0 && m[11] === 0.0 &&
  74664. m[12] === 0.0 && m[13] === 0.0 && m[14] === 0.0 && m[15] === 1.0);
  74665. }
  74666. return this._isIdentity;
  74667. };
  74668. /**
  74669. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  74670. * @returns true is the matrix is the identity matrix
  74671. */
  74672. Matrix.prototype.isIdentityAs3x2 = function () {
  74673. if (this._isIdentity3x2Dirty) {
  74674. this._isIdentity3x2Dirty = false;
  74675. if (this._m[0] !== 1.0 || this._m[5] !== 1.0 || this._m[15] !== 1.0) {
  74676. this._isIdentity3x2 = false;
  74677. }
  74678. else if (this._m[1] !== 0.0 || this._m[2] !== 0.0 || this._m[3] !== 0.0 ||
  74679. this._m[4] !== 0.0 || this._m[6] !== 0.0 || this._m[7] !== 0.0 ||
  74680. this._m[8] !== 0.0 || this._m[9] !== 0.0 || this._m[10] !== 0.0 || this._m[11] !== 0.0 ||
  74681. this._m[12] !== 0.0 || this._m[13] !== 0.0 || this._m[14] !== 0.0) {
  74682. this._isIdentity3x2 = false;
  74683. }
  74684. else {
  74685. this._isIdentity3x2 = true;
  74686. }
  74687. }
  74688. return this._isIdentity3x2;
  74689. };
  74690. /**
  74691. * Gets the determinant of the matrix
  74692. * @returns the matrix determinant
  74693. */
  74694. Matrix.prototype.determinant = function () {
  74695. if (this._isIdentity === true) {
  74696. return 1;
  74697. }
  74698. var m = this._m;
  74699. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  74700. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  74701. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  74702. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  74703. // https://en.wikipedia.org/wiki/Laplace_expansion
  74704. // to compute the deterrminant of a 4x4 Matrix we compute the cofactors of any row or column,
  74705. // then we multiply each Cofactor by its corresponding matrix value and sum them all to get the determinant
  74706. // Cofactor(i, j) = sign(i,j) * det(Minor(i, j))
  74707. // where
  74708. // - sign(i,j) = (i+j) % 2 === 0 ? 1 : -1
  74709. // - Minor(i, j) is the 3x3 matrix we get by removing row i and column j from current Matrix
  74710. //
  74711. // Here we do that for the 1st row.
  74712. var det_22_33 = m22 * m33 - m32 * m23;
  74713. var det_21_33 = m21 * m33 - m31 * m23;
  74714. var det_21_32 = m21 * m32 - m31 * m22;
  74715. var det_20_33 = m20 * m33 - m30 * m23;
  74716. var det_20_32 = m20 * m32 - m22 * m30;
  74717. var det_20_31 = m20 * m31 - m30 * m21;
  74718. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  74719. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  74720. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  74721. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  74722. return m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  74723. };
  74724. // Methods
  74725. /**
  74726. * Returns the matrix as a Float32Array
  74727. * @returns the matrix underlying array
  74728. */
  74729. Matrix.prototype.toArray = function () {
  74730. return this._m;
  74731. };
  74732. /**
  74733. * Returns the matrix as a Float32Array
  74734. * @returns the matrix underlying array.
  74735. */
  74736. Matrix.prototype.asArray = function () {
  74737. return this._m;
  74738. };
  74739. /**
  74740. * Inverts the current matrix in place
  74741. * @returns the current inverted matrix
  74742. */
  74743. Matrix.prototype.invert = function () {
  74744. this.invertToRef(this);
  74745. return this;
  74746. };
  74747. /**
  74748. * Sets all the matrix elements to zero
  74749. * @returns the current matrix
  74750. */
  74751. Matrix.prototype.reset = function () {
  74752. 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);
  74753. this._updateIdentityStatus(false);
  74754. return this;
  74755. };
  74756. /**
  74757. * Adds the current matrix with a second one
  74758. * @param other defines the matrix to add
  74759. * @returns a new matrix as the addition of the current matrix and the given one
  74760. */
  74761. Matrix.prototype.add = function (other) {
  74762. var result = new Matrix();
  74763. this.addToRef(other, result);
  74764. return result;
  74765. };
  74766. /**
  74767. * Sets the given matrix "result" to the addition of the current matrix and the given one
  74768. * @param other defines the matrix to add
  74769. * @param result defines the target matrix
  74770. * @returns the current matrix
  74771. */
  74772. Matrix.prototype.addToRef = function (other, result) {
  74773. var m = this._m;
  74774. var resultM = result._m;
  74775. var otherM = other.m;
  74776. for (var index = 0; index < 16; index++) {
  74777. resultM[index] = m[index] + otherM[index];
  74778. }
  74779. result._markAsUpdated();
  74780. return this;
  74781. };
  74782. /**
  74783. * Adds in place the given matrix to the current matrix
  74784. * @param other defines the second operand
  74785. * @returns the current updated matrix
  74786. */
  74787. Matrix.prototype.addToSelf = function (other) {
  74788. var m = this._m;
  74789. var otherM = other.m;
  74790. for (var index = 0; index < 16; index++) {
  74791. m[index] += otherM[index];
  74792. }
  74793. this._markAsUpdated();
  74794. return this;
  74795. };
  74796. /**
  74797. * Sets the given matrix to the current inverted Matrix
  74798. * @param other defines the target matrix
  74799. * @returns the unmodified current matrix
  74800. */
  74801. Matrix.prototype.invertToRef = function (other) {
  74802. if (this._isIdentity === true) {
  74803. Matrix.IdentityToRef(other);
  74804. return this;
  74805. }
  74806. // the inverse of a Matrix is the transpose of cofactor matrix divided by the determinant
  74807. var m = this._m;
  74808. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  74809. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  74810. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  74811. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  74812. var det_22_33 = m22 * m33 - m32 * m23;
  74813. var det_21_33 = m21 * m33 - m31 * m23;
  74814. var det_21_32 = m21 * m32 - m31 * m22;
  74815. var det_20_33 = m20 * m33 - m30 * m23;
  74816. var det_20_32 = m20 * m32 - m22 * m30;
  74817. var det_20_31 = m20 * m31 - m30 * m21;
  74818. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  74819. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  74820. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  74821. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  74822. var det = m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  74823. if (det === 0) {
  74824. // not invertible
  74825. other.copyFrom(this);
  74826. return this;
  74827. }
  74828. var detInv = 1 / det;
  74829. var det_12_33 = m12 * m33 - m32 * m13;
  74830. var det_11_33 = m11 * m33 - m31 * m13;
  74831. var det_11_32 = m11 * m32 - m31 * m12;
  74832. var det_10_33 = m10 * m33 - m30 * m13;
  74833. var det_10_32 = m10 * m32 - m30 * m12;
  74834. var det_10_31 = m10 * m31 - m30 * m11;
  74835. var det_12_23 = m12 * m23 - m22 * m13;
  74836. var det_11_23 = m11 * m23 - m21 * m13;
  74837. var det_11_22 = m11 * m22 - m21 * m12;
  74838. var det_10_23 = m10 * m23 - m20 * m13;
  74839. var det_10_22 = m10 * m22 - m20 * m12;
  74840. var det_10_21 = m10 * m21 - m20 * m11;
  74841. var cofact_10 = -(m01 * det_22_33 - m02 * det_21_33 + m03 * det_21_32);
  74842. var cofact_11 = +(m00 * det_22_33 - m02 * det_20_33 + m03 * det_20_32);
  74843. var cofact_12 = -(m00 * det_21_33 - m01 * det_20_33 + m03 * det_20_31);
  74844. var cofact_13 = +(m00 * det_21_32 - m01 * det_20_32 + m02 * det_20_31);
  74845. var cofact_20 = +(m01 * det_12_33 - m02 * det_11_33 + m03 * det_11_32);
  74846. var cofact_21 = -(m00 * det_12_33 - m02 * det_10_33 + m03 * det_10_32);
  74847. var cofact_22 = +(m00 * det_11_33 - m01 * det_10_33 + m03 * det_10_31);
  74848. var cofact_23 = -(m00 * det_11_32 - m01 * det_10_32 + m02 * det_10_31);
  74849. var cofact_30 = -(m01 * det_12_23 - m02 * det_11_23 + m03 * det_11_22);
  74850. var cofact_31 = +(m00 * det_12_23 - m02 * det_10_23 + m03 * det_10_22);
  74851. var cofact_32 = -(m00 * det_11_23 - m01 * det_10_23 + m03 * det_10_21);
  74852. var cofact_33 = +(m00 * det_11_22 - m01 * det_10_22 + m02 * det_10_21);
  74853. 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);
  74854. return this;
  74855. };
  74856. /**
  74857. * add a value at the specified position in the current Matrix
  74858. * @param index the index of the value within the matrix. between 0 and 15.
  74859. * @param value the value to be added
  74860. * @returns the current updated matrix
  74861. */
  74862. Matrix.prototype.addAtIndex = function (index, value) {
  74863. this._m[index] += value;
  74864. this._markAsUpdated();
  74865. return this;
  74866. };
  74867. /**
  74868. * mutiply the specified position in the current Matrix by a value
  74869. * @param index the index of the value within the matrix. between 0 and 15.
  74870. * @param value the value to be added
  74871. * @returns the current updated matrix
  74872. */
  74873. Matrix.prototype.multiplyAtIndex = function (index, value) {
  74874. this._m[index] *= value;
  74875. this._markAsUpdated();
  74876. return this;
  74877. };
  74878. /**
  74879. * Inserts the translation vector (using 3 floats) in the current matrix
  74880. * @param x defines the 1st component of the translation
  74881. * @param y defines the 2nd component of the translation
  74882. * @param z defines the 3rd component of the translation
  74883. * @returns the current updated matrix
  74884. */
  74885. Matrix.prototype.setTranslationFromFloats = function (x, y, z) {
  74886. this._m[12] = x;
  74887. this._m[13] = y;
  74888. this._m[14] = z;
  74889. this._markAsUpdated();
  74890. return this;
  74891. };
  74892. /**
  74893. * Inserts the translation vector in the current matrix
  74894. * @param vector3 defines the translation to insert
  74895. * @returns the current updated matrix
  74896. */
  74897. Matrix.prototype.setTranslation = function (vector3) {
  74898. return this.setTranslationFromFloats(vector3.x, vector3.y, vector3.z);
  74899. };
  74900. /**
  74901. * Gets the translation value of the current matrix
  74902. * @returns a new Vector3 as the extracted translation from the matrix
  74903. */
  74904. Matrix.prototype.getTranslation = function () {
  74905. return new Vector3(this._m[12], this._m[13], this._m[14]);
  74906. };
  74907. /**
  74908. * Fill a Vector3 with the extracted translation from the matrix
  74909. * @param result defines the Vector3 where to store the translation
  74910. * @returns the current matrix
  74911. */
  74912. Matrix.prototype.getTranslationToRef = function (result) {
  74913. result.x = this._m[12];
  74914. result.y = this._m[13];
  74915. result.z = this._m[14];
  74916. return this;
  74917. };
  74918. /**
  74919. * Remove rotation and scaling part from the matrix
  74920. * @returns the updated matrix
  74921. */
  74922. Matrix.prototype.removeRotationAndScaling = function () {
  74923. var m = this.m;
  74924. 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);
  74925. this._updateIdentityStatus(m[12] === 0 && m[13] === 0 && m[14] === 0 && m[15] === 1);
  74926. return this;
  74927. };
  74928. /**
  74929. * Multiply two matrices
  74930. * @param other defines the second operand
  74931. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  74932. */
  74933. Matrix.prototype.multiply = function (other) {
  74934. var result = new Matrix();
  74935. this.multiplyToRef(other, result);
  74936. return result;
  74937. };
  74938. /**
  74939. * Copy the current matrix from the given one
  74940. * @param other defines the source matrix
  74941. * @returns the current updated matrix
  74942. */
  74943. Matrix.prototype.copyFrom = function (other) {
  74944. other.copyToArray(this._m);
  74945. var o = other;
  74946. this._updateIdentityStatus(o._isIdentity, o._isIdentityDirty, o._isIdentity3x2, o._isIdentity3x2Dirty);
  74947. return this;
  74948. };
  74949. /**
  74950. * Populates the given array from the starting index with the current matrix values
  74951. * @param array defines the target array
  74952. * @param offset defines the offset in the target array where to start storing values
  74953. * @returns the current matrix
  74954. */
  74955. Matrix.prototype.copyToArray = function (array, offset) {
  74956. if (offset === void 0) { offset = 0; }
  74957. for (var index = 0; index < 16; index++) {
  74958. array[offset + index] = this._m[index];
  74959. }
  74960. return this;
  74961. };
  74962. /**
  74963. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  74964. * @param other defines the second operand
  74965. * @param result defines the matrix where to store the multiplication
  74966. * @returns the current matrix
  74967. */
  74968. Matrix.prototype.multiplyToRef = function (other, result) {
  74969. if (this._isIdentity) {
  74970. result.copyFrom(other);
  74971. return this;
  74972. }
  74973. if (other._isIdentity) {
  74974. result.copyFrom(this);
  74975. return this;
  74976. }
  74977. this.multiplyToArray(other, result._m, 0);
  74978. result._markAsUpdated();
  74979. return this;
  74980. };
  74981. /**
  74982. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  74983. * @param other defines the second operand
  74984. * @param result defines the array where to store the multiplication
  74985. * @param offset defines the offset in the target array where to start storing values
  74986. * @returns the current matrix
  74987. */
  74988. Matrix.prototype.multiplyToArray = function (other, result, offset) {
  74989. var m = this._m;
  74990. var otherM = other.m;
  74991. var tm0 = m[0], tm1 = m[1], tm2 = m[2], tm3 = m[3];
  74992. var tm4 = m[4], tm5 = m[5], tm6 = m[6], tm7 = m[7];
  74993. var tm8 = m[8], tm9 = m[9], tm10 = m[10], tm11 = m[11];
  74994. var tm12 = m[12], tm13 = m[13], tm14 = m[14], tm15 = m[15];
  74995. var om0 = otherM[0], om1 = otherM[1], om2 = otherM[2], om3 = otherM[3];
  74996. var om4 = otherM[4], om5 = otherM[5], om6 = otherM[6], om7 = otherM[7];
  74997. var om8 = otherM[8], om9 = otherM[9], om10 = otherM[10], om11 = otherM[11];
  74998. var om12 = otherM[12], om13 = otherM[13], om14 = otherM[14], om15 = otherM[15];
  74999. result[offset] = tm0 * om0 + tm1 * om4 + tm2 * om8 + tm3 * om12;
  75000. result[offset + 1] = tm0 * om1 + tm1 * om5 + tm2 * om9 + tm3 * om13;
  75001. result[offset + 2] = tm0 * om2 + tm1 * om6 + tm2 * om10 + tm3 * om14;
  75002. result[offset + 3] = tm0 * om3 + tm1 * om7 + tm2 * om11 + tm3 * om15;
  75003. result[offset + 4] = tm4 * om0 + tm5 * om4 + tm6 * om8 + tm7 * om12;
  75004. result[offset + 5] = tm4 * om1 + tm5 * om5 + tm6 * om9 + tm7 * om13;
  75005. result[offset + 6] = tm4 * om2 + tm5 * om6 + tm6 * om10 + tm7 * om14;
  75006. result[offset + 7] = tm4 * om3 + tm5 * om7 + tm6 * om11 + tm7 * om15;
  75007. result[offset + 8] = tm8 * om0 + tm9 * om4 + tm10 * om8 + tm11 * om12;
  75008. result[offset + 9] = tm8 * om1 + tm9 * om5 + tm10 * om9 + tm11 * om13;
  75009. result[offset + 10] = tm8 * om2 + tm9 * om6 + tm10 * om10 + tm11 * om14;
  75010. result[offset + 11] = tm8 * om3 + tm9 * om7 + tm10 * om11 + tm11 * om15;
  75011. result[offset + 12] = tm12 * om0 + tm13 * om4 + tm14 * om8 + tm15 * om12;
  75012. result[offset + 13] = tm12 * om1 + tm13 * om5 + tm14 * om9 + tm15 * om13;
  75013. result[offset + 14] = tm12 * om2 + tm13 * om6 + tm14 * om10 + tm15 * om14;
  75014. result[offset + 15] = tm12 * om3 + tm13 * om7 + tm14 * om11 + tm15 * om15;
  75015. return this;
  75016. };
  75017. /**
  75018. * Check equality between this matrix and a second one
  75019. * @param value defines the second matrix to compare
  75020. * @returns true is the current matrix and the given one values are strictly equal
  75021. */
  75022. Matrix.prototype.equals = function (value) {
  75023. var other = value;
  75024. if (!other) {
  75025. return false;
  75026. }
  75027. if (this._isIdentity || other._isIdentity) {
  75028. if (!this._isIdentityDirty && !other._isIdentityDirty) {
  75029. return this._isIdentity && other._isIdentity;
  75030. }
  75031. }
  75032. var m = this.m;
  75033. var om = other.m;
  75034. return (m[0] === om[0] && m[1] === om[1] && m[2] === om[2] && m[3] === om[3] &&
  75035. m[4] === om[4] && m[5] === om[5] && m[6] === om[6] && m[7] === om[7] &&
  75036. m[8] === om[8] && m[9] === om[9] && m[10] === om[10] && m[11] === om[11] &&
  75037. m[12] === om[12] && m[13] === om[13] && m[14] === om[14] && m[15] === om[15]);
  75038. };
  75039. /**
  75040. * Clone the current matrix
  75041. * @returns a new matrix from the current matrix
  75042. */
  75043. Matrix.prototype.clone = function () {
  75044. var matrix = new Matrix();
  75045. matrix.copyFrom(this);
  75046. return matrix;
  75047. };
  75048. /**
  75049. * Returns the name of the current matrix class
  75050. * @returns the string "Matrix"
  75051. */
  75052. Matrix.prototype.getClassName = function () {
  75053. return "Matrix";
  75054. };
  75055. /**
  75056. * Gets the hash code of the current matrix
  75057. * @returns the hash code
  75058. */
  75059. Matrix.prototype.getHashCode = function () {
  75060. var hash = this._m[0] || 0;
  75061. for (var i = 1; i < 16; i++) {
  75062. hash = (hash * 397) ^ (this._m[i] || 0);
  75063. }
  75064. return hash;
  75065. };
  75066. /**
  75067. * Decomposes the current Matrix into a translation, rotation and scaling components
  75068. * @param scale defines the scale vector3 given as a reference to update
  75069. * @param rotation defines the rotation quaternion given as a reference to update
  75070. * @param translation defines the translation vector3 given as a reference to update
  75071. * @returns true if operation was successful
  75072. */
  75073. Matrix.prototype.decompose = function (scale, rotation, translation) {
  75074. if (this._isIdentity) {
  75075. if (translation) {
  75076. translation.setAll(0);
  75077. }
  75078. if (scale) {
  75079. scale.setAll(1);
  75080. }
  75081. if (rotation) {
  75082. rotation.copyFromFloats(0, 0, 0, 1);
  75083. }
  75084. return true;
  75085. }
  75086. var m = this._m;
  75087. if (translation) {
  75088. translation.copyFromFloats(m[12], m[13], m[14]);
  75089. }
  75090. scale = scale || MathTmp.Vector3[0];
  75091. scale.x = Math.sqrt(m[0] * m[0] + m[1] * m[1] + m[2] * m[2]);
  75092. scale.y = Math.sqrt(m[4] * m[4] + m[5] * m[5] + m[6] * m[6]);
  75093. scale.z = Math.sqrt(m[8] * m[8] + m[9] * m[9] + m[10] * m[10]);
  75094. if (this.determinant() <= 0) {
  75095. scale.y *= -1;
  75096. }
  75097. if (scale.x === 0 || scale.y === 0 || scale.z === 0) {
  75098. if (rotation) {
  75099. rotation.copyFromFloats(0.0, 0.0, 0.0, 1.0);
  75100. }
  75101. return false;
  75102. }
  75103. if (rotation) {
  75104. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  75105. 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]);
  75106. Quaternion.FromRotationMatrixToRef(MathTmp.Matrix[0], rotation);
  75107. }
  75108. return true;
  75109. };
  75110. /**
  75111. * Gets specific row of the matrix
  75112. * @param index defines the number of the row to get
  75113. * @returns the index-th row of the current matrix as a new Vector4
  75114. */
  75115. Matrix.prototype.getRow = function (index) {
  75116. if (index < 0 || index > 3) {
  75117. return null;
  75118. }
  75119. var i = index * 4;
  75120. return new Vector4(this._m[i + 0], this._m[i + 1], this._m[i + 2], this._m[i + 3]);
  75121. };
  75122. /**
  75123. * Sets the index-th row of the current matrix to the vector4 values
  75124. * @param index defines the number of the row to set
  75125. * @param row defines the target vector4
  75126. * @returns the updated current matrix
  75127. */
  75128. Matrix.prototype.setRow = function (index, row) {
  75129. return this.setRowFromFloats(index, row.x, row.y, row.z, row.w);
  75130. };
  75131. /**
  75132. * Compute the transpose of the matrix
  75133. * @returns the new transposed matrix
  75134. */
  75135. Matrix.prototype.transpose = function () {
  75136. return Matrix.Transpose(this);
  75137. };
  75138. /**
  75139. * Compute the transpose of the matrix and store it in a given matrix
  75140. * @param result defines the target matrix
  75141. * @returns the current matrix
  75142. */
  75143. Matrix.prototype.transposeToRef = function (result) {
  75144. Matrix.TransposeToRef(this, result);
  75145. return this;
  75146. };
  75147. /**
  75148. * Sets the index-th row of the current matrix with the given 4 x float values
  75149. * @param index defines the row index
  75150. * @param x defines the x component to set
  75151. * @param y defines the y component to set
  75152. * @param z defines the z component to set
  75153. * @param w defines the w component to set
  75154. * @returns the updated current matrix
  75155. */
  75156. Matrix.prototype.setRowFromFloats = function (index, x, y, z, w) {
  75157. if (index < 0 || index > 3) {
  75158. return this;
  75159. }
  75160. var i = index * 4;
  75161. this._m[i + 0] = x;
  75162. this._m[i + 1] = y;
  75163. this._m[i + 2] = z;
  75164. this._m[i + 3] = w;
  75165. this._markAsUpdated();
  75166. return this;
  75167. };
  75168. /**
  75169. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  75170. * @param scale defines the scale factor
  75171. * @returns a new matrix
  75172. */
  75173. Matrix.prototype.scale = function (scale) {
  75174. var result = new Matrix();
  75175. this.scaleToRef(scale, result);
  75176. return result;
  75177. };
  75178. /**
  75179. * Scale the current matrix values by a factor to a given result matrix
  75180. * @param scale defines the scale factor
  75181. * @param result defines the matrix to store the result
  75182. * @returns the current matrix
  75183. */
  75184. Matrix.prototype.scaleToRef = function (scale, result) {
  75185. for (var index = 0; index < 16; index++) {
  75186. result._m[index] = this._m[index] * scale;
  75187. }
  75188. result._markAsUpdated();
  75189. return this;
  75190. };
  75191. /**
  75192. * Scale the current matrix values by a factor and add the result to a given matrix
  75193. * @param scale defines the scale factor
  75194. * @param result defines the Matrix to store the result
  75195. * @returns the current matrix
  75196. */
  75197. Matrix.prototype.scaleAndAddToRef = function (scale, result) {
  75198. for (var index = 0; index < 16; index++) {
  75199. result._m[index] += this._m[index] * scale;
  75200. }
  75201. result._markAsUpdated();
  75202. return this;
  75203. };
  75204. /**
  75205. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  75206. * @param ref matrix to store the result
  75207. */
  75208. Matrix.prototype.toNormalMatrix = function (ref) {
  75209. var tmp = MathTmp.Matrix[0];
  75210. this.invertToRef(tmp);
  75211. tmp.transposeToRef(ref);
  75212. var m = ref._m;
  75213. 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);
  75214. };
  75215. /**
  75216. * Gets only rotation part of the current matrix
  75217. * @returns a new matrix sets to the extracted rotation matrix from the current one
  75218. */
  75219. Matrix.prototype.getRotationMatrix = function () {
  75220. var result = new Matrix();
  75221. this.getRotationMatrixToRef(result);
  75222. return result;
  75223. };
  75224. /**
  75225. * Extracts the rotation matrix from the current one and sets it as the given "result"
  75226. * @param result defines the target matrix to store data to
  75227. * @returns the current matrix
  75228. */
  75229. Matrix.prototype.getRotationMatrixToRef = function (result) {
  75230. var scale = MathTmp.Vector3[0];
  75231. if (!this.decompose(scale)) {
  75232. Matrix.IdentityToRef(result);
  75233. return this;
  75234. }
  75235. var m = this._m;
  75236. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  75237. 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);
  75238. return this;
  75239. };
  75240. /**
  75241. * Toggles model matrix from being right handed to left handed in place and vice versa
  75242. */
  75243. Matrix.prototype.toggleModelMatrixHandInPlace = function () {
  75244. var m = this._m;
  75245. m[2] *= -1;
  75246. m[6] *= -1;
  75247. m[8] *= -1;
  75248. m[9] *= -1;
  75249. m[14] *= -1;
  75250. this._markAsUpdated();
  75251. };
  75252. /**
  75253. * Toggles projection matrix from being right handed to left handed in place and vice versa
  75254. */
  75255. Matrix.prototype.toggleProjectionMatrixHandInPlace = function () {
  75256. var m = this._m;
  75257. m[8] *= -1;
  75258. m[9] *= -1;
  75259. m[10] *= -1;
  75260. m[11] *= -1;
  75261. this._markAsUpdated();
  75262. };
  75263. // Statics
  75264. /**
  75265. * Creates a matrix from an array
  75266. * @param array defines the source array
  75267. * @param offset defines an offset in the source array
  75268. * @returns a new Matrix set from the starting index of the given array
  75269. */
  75270. Matrix.FromArray = function (array, offset) {
  75271. if (offset === void 0) { offset = 0; }
  75272. var result = new Matrix();
  75273. Matrix.FromArrayToRef(array, offset, result);
  75274. return result;
  75275. };
  75276. /**
  75277. * Copy the content of an array into a given matrix
  75278. * @param array defines the source array
  75279. * @param offset defines an offset in the source array
  75280. * @param result defines the target matrix
  75281. */
  75282. Matrix.FromArrayToRef = function (array, offset, result) {
  75283. for (var index = 0; index < 16; index++) {
  75284. result._m[index] = array[index + offset];
  75285. }
  75286. result._markAsUpdated();
  75287. };
  75288. /**
  75289. * Stores an array into a matrix after having multiplied each component by a given factor
  75290. * @param array defines the source array
  75291. * @param offset defines the offset in the source array
  75292. * @param scale defines the scaling factor
  75293. * @param result defines the target matrix
  75294. */
  75295. Matrix.FromFloat32ArrayToRefScaled = function (array, offset, scale, result) {
  75296. for (var index = 0; index < 16; index++) {
  75297. result._m[index] = array[index + offset] * scale;
  75298. }
  75299. result._markAsUpdated();
  75300. };
  75301. Object.defineProperty(Matrix, "IdentityReadOnly", {
  75302. /**
  75303. * Gets an identity matrix that must not be updated
  75304. */
  75305. get: function () {
  75306. return Matrix._identityReadOnly;
  75307. },
  75308. enumerable: true,
  75309. configurable: true
  75310. });
  75311. /**
  75312. * Stores a list of values (16) inside a given matrix
  75313. * @param initialM11 defines 1st value of 1st row
  75314. * @param initialM12 defines 2nd value of 1st row
  75315. * @param initialM13 defines 3rd value of 1st row
  75316. * @param initialM14 defines 4th value of 1st row
  75317. * @param initialM21 defines 1st value of 2nd row
  75318. * @param initialM22 defines 2nd value of 2nd row
  75319. * @param initialM23 defines 3rd value of 2nd row
  75320. * @param initialM24 defines 4th value of 2nd row
  75321. * @param initialM31 defines 1st value of 3rd row
  75322. * @param initialM32 defines 2nd value of 3rd row
  75323. * @param initialM33 defines 3rd value of 3rd row
  75324. * @param initialM34 defines 4th value of 3rd row
  75325. * @param initialM41 defines 1st value of 4th row
  75326. * @param initialM42 defines 2nd value of 4th row
  75327. * @param initialM43 defines 3rd value of 4th row
  75328. * @param initialM44 defines 4th value of 4th row
  75329. * @param result defines the target matrix
  75330. */
  75331. Matrix.FromValuesToRef = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44, result) {
  75332. var m = result._m;
  75333. m[0] = initialM11;
  75334. m[1] = initialM12;
  75335. m[2] = initialM13;
  75336. m[3] = initialM14;
  75337. m[4] = initialM21;
  75338. m[5] = initialM22;
  75339. m[6] = initialM23;
  75340. m[7] = initialM24;
  75341. m[8] = initialM31;
  75342. m[9] = initialM32;
  75343. m[10] = initialM33;
  75344. m[11] = initialM34;
  75345. m[12] = initialM41;
  75346. m[13] = initialM42;
  75347. m[14] = initialM43;
  75348. m[15] = initialM44;
  75349. result._markAsUpdated();
  75350. };
  75351. /**
  75352. * Creates new matrix from a list of values (16)
  75353. * @param initialM11 defines 1st value of 1st row
  75354. * @param initialM12 defines 2nd value of 1st row
  75355. * @param initialM13 defines 3rd value of 1st row
  75356. * @param initialM14 defines 4th value of 1st row
  75357. * @param initialM21 defines 1st value of 2nd row
  75358. * @param initialM22 defines 2nd value of 2nd row
  75359. * @param initialM23 defines 3rd value of 2nd row
  75360. * @param initialM24 defines 4th value of 2nd row
  75361. * @param initialM31 defines 1st value of 3rd row
  75362. * @param initialM32 defines 2nd value of 3rd row
  75363. * @param initialM33 defines 3rd value of 3rd row
  75364. * @param initialM34 defines 4th value of 3rd row
  75365. * @param initialM41 defines 1st value of 4th row
  75366. * @param initialM42 defines 2nd value of 4th row
  75367. * @param initialM43 defines 3rd value of 4th row
  75368. * @param initialM44 defines 4th value of 4th row
  75369. * @returns the new matrix
  75370. */
  75371. Matrix.FromValues = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44) {
  75372. var result = new Matrix();
  75373. var m = result._m;
  75374. m[0] = initialM11;
  75375. m[1] = initialM12;
  75376. m[2] = initialM13;
  75377. m[3] = initialM14;
  75378. m[4] = initialM21;
  75379. m[5] = initialM22;
  75380. m[6] = initialM23;
  75381. m[7] = initialM24;
  75382. m[8] = initialM31;
  75383. m[9] = initialM32;
  75384. m[10] = initialM33;
  75385. m[11] = initialM34;
  75386. m[12] = initialM41;
  75387. m[13] = initialM42;
  75388. m[14] = initialM43;
  75389. m[15] = initialM44;
  75390. result._markAsUpdated();
  75391. return result;
  75392. };
  75393. /**
  75394. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  75395. * @param scale defines the scale vector3
  75396. * @param rotation defines the rotation quaternion
  75397. * @param translation defines the translation vector3
  75398. * @returns a new matrix
  75399. */
  75400. Matrix.Compose = function (scale, rotation, translation) {
  75401. var result = new Matrix();
  75402. Matrix.ComposeToRef(scale, rotation, translation, result);
  75403. return result;
  75404. };
  75405. /**
  75406. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  75407. * @param scale defines the scale vector3
  75408. * @param rotation defines the rotation quaternion
  75409. * @param translation defines the translation vector3
  75410. * @param result defines the target matrix
  75411. */
  75412. Matrix.ComposeToRef = function (scale, rotation, translation, result) {
  75413. Matrix.ScalingToRef(scale.x, scale.y, scale.z, MathTmp.Matrix[1]);
  75414. rotation.toRotationMatrix(MathTmp.Matrix[0]);
  75415. MathTmp.Matrix[1].multiplyToRef(MathTmp.Matrix[0], result);
  75416. result.setTranslation(translation);
  75417. };
  75418. /**
  75419. * Creates a new identity matrix
  75420. * @returns a new identity matrix
  75421. */
  75422. Matrix.Identity = function () {
  75423. 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);
  75424. identity._updateIdentityStatus(true);
  75425. return identity;
  75426. };
  75427. /**
  75428. * Creates a new identity matrix and stores the result in a given matrix
  75429. * @param result defines the target matrix
  75430. */
  75431. Matrix.IdentityToRef = function (result) {
  75432. 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);
  75433. result._updateIdentityStatus(true);
  75434. };
  75435. /**
  75436. * Creates a new zero matrix
  75437. * @returns a new zero matrix
  75438. */
  75439. Matrix.Zero = function () {
  75440. 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);
  75441. zero._updateIdentityStatus(false);
  75442. return zero;
  75443. };
  75444. /**
  75445. * Creates a new rotation matrix for "angle" radians around the X axis
  75446. * @param angle defines the angle (in radians) to use
  75447. * @return the new matrix
  75448. */
  75449. Matrix.RotationX = function (angle) {
  75450. var result = new Matrix();
  75451. Matrix.RotationXToRef(angle, result);
  75452. return result;
  75453. };
  75454. /**
  75455. * Creates a new matrix as the invert of a given matrix
  75456. * @param source defines the source matrix
  75457. * @returns the new matrix
  75458. */
  75459. Matrix.Invert = function (source) {
  75460. var result = new Matrix();
  75461. source.invertToRef(result);
  75462. return result;
  75463. };
  75464. /**
  75465. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  75466. * @param angle defines the angle (in radians) to use
  75467. * @param result defines the target matrix
  75468. */
  75469. Matrix.RotationXToRef = function (angle, result) {
  75470. var s = Math.sin(angle);
  75471. var c = Math.cos(angle);
  75472. 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);
  75473. result._updateIdentityStatus(c === 1 && s === 0);
  75474. };
  75475. /**
  75476. * Creates a new rotation matrix for "angle" radians around the Y axis
  75477. * @param angle defines the angle (in radians) to use
  75478. * @return the new matrix
  75479. */
  75480. Matrix.RotationY = function (angle) {
  75481. var result = new Matrix();
  75482. Matrix.RotationYToRef(angle, result);
  75483. return result;
  75484. };
  75485. /**
  75486. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  75487. * @param angle defines the angle (in radians) to use
  75488. * @param result defines the target matrix
  75489. */
  75490. Matrix.RotationYToRef = function (angle, result) {
  75491. var s = Math.sin(angle);
  75492. var c = Math.cos(angle);
  75493. 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);
  75494. result._updateIdentityStatus(c === 1 && s === 0);
  75495. };
  75496. /**
  75497. * Creates a new rotation matrix for "angle" radians around the Z axis
  75498. * @param angle defines the angle (in radians) to use
  75499. * @return the new matrix
  75500. */
  75501. Matrix.RotationZ = function (angle) {
  75502. var result = new Matrix();
  75503. Matrix.RotationZToRef(angle, result);
  75504. return result;
  75505. };
  75506. /**
  75507. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  75508. * @param angle defines the angle (in radians) to use
  75509. * @param result defines the target matrix
  75510. */
  75511. Matrix.RotationZToRef = function (angle, result) {
  75512. var s = Math.sin(angle);
  75513. var c = Math.cos(angle);
  75514. 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);
  75515. result._updateIdentityStatus(c === 1 && s === 0);
  75516. };
  75517. /**
  75518. * Creates a new rotation matrix for "angle" radians around the given axis
  75519. * @param axis defines the axis to use
  75520. * @param angle defines the angle (in radians) to use
  75521. * @return the new matrix
  75522. */
  75523. Matrix.RotationAxis = function (axis, angle) {
  75524. var result = new Matrix();
  75525. Matrix.RotationAxisToRef(axis, angle, result);
  75526. return result;
  75527. };
  75528. /**
  75529. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  75530. * @param axis defines the axis to use
  75531. * @param angle defines the angle (in radians) to use
  75532. * @param result defines the target matrix
  75533. */
  75534. Matrix.RotationAxisToRef = function (axis, angle, result) {
  75535. var s = Math.sin(-angle);
  75536. var c = Math.cos(-angle);
  75537. var c1 = 1 - c;
  75538. axis.normalize();
  75539. var m = result._m;
  75540. m[0] = (axis.x * axis.x) * c1 + c;
  75541. m[1] = (axis.x * axis.y) * c1 - (axis.z * s);
  75542. m[2] = (axis.x * axis.z) * c1 + (axis.y * s);
  75543. m[3] = 0.0;
  75544. m[4] = (axis.y * axis.x) * c1 + (axis.z * s);
  75545. m[5] = (axis.y * axis.y) * c1 + c;
  75546. m[6] = (axis.y * axis.z) * c1 - (axis.x * s);
  75547. m[7] = 0.0;
  75548. m[8] = (axis.z * axis.x) * c1 - (axis.y * s);
  75549. m[9] = (axis.z * axis.y) * c1 + (axis.x * s);
  75550. m[10] = (axis.z * axis.z) * c1 + c;
  75551. m[11] = 0.0;
  75552. m[12] = 0.0;
  75553. m[13] = 0.0;
  75554. m[14] = 0.0;
  75555. m[15] = 1.0;
  75556. result._markAsUpdated();
  75557. };
  75558. /**
  75559. * Creates a rotation matrix
  75560. * @param yaw defines the yaw angle in radians (Y axis)
  75561. * @param pitch defines the pitch angle in radians (X axis)
  75562. * @param roll defines the roll angle in radians (X axis)
  75563. * @returns the new rotation matrix
  75564. */
  75565. Matrix.RotationYawPitchRoll = function (yaw, pitch, roll) {
  75566. var result = new Matrix();
  75567. Matrix.RotationYawPitchRollToRef(yaw, pitch, roll, result);
  75568. return result;
  75569. };
  75570. /**
  75571. * Creates a rotation matrix and stores it in a given matrix
  75572. * @param yaw defines the yaw angle in radians (Y axis)
  75573. * @param pitch defines the pitch angle in radians (X axis)
  75574. * @param roll defines the roll angle in radians (X axis)
  75575. * @param result defines the target matrix
  75576. */
  75577. Matrix.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  75578. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, MathTmp.Quaternion[0]);
  75579. MathTmp.Quaternion[0].toRotationMatrix(result);
  75580. };
  75581. /**
  75582. * Creates a scaling matrix
  75583. * @param x defines the scale factor on X axis
  75584. * @param y defines the scale factor on Y axis
  75585. * @param z defines the scale factor on Z axis
  75586. * @returns the new matrix
  75587. */
  75588. Matrix.Scaling = function (x, y, z) {
  75589. var result = new Matrix();
  75590. Matrix.ScalingToRef(x, y, z, result);
  75591. return result;
  75592. };
  75593. /**
  75594. * Creates a scaling matrix and stores it in a given matrix
  75595. * @param x defines the scale factor on X axis
  75596. * @param y defines the scale factor on Y axis
  75597. * @param z defines the scale factor on Z axis
  75598. * @param result defines the target matrix
  75599. */
  75600. Matrix.ScalingToRef = function (x, y, z, result) {
  75601. 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);
  75602. result._updateIdentityStatus(x === 1 && y === 1 && z === 1);
  75603. };
  75604. /**
  75605. * Creates a translation matrix
  75606. * @param x defines the translation on X axis
  75607. * @param y defines the translation on Y axis
  75608. * @param z defines the translationon Z axis
  75609. * @returns the new matrix
  75610. */
  75611. Matrix.Translation = function (x, y, z) {
  75612. var result = new Matrix();
  75613. Matrix.TranslationToRef(x, y, z, result);
  75614. return result;
  75615. };
  75616. /**
  75617. * Creates a translation matrix and stores it in a given matrix
  75618. * @param x defines the translation on X axis
  75619. * @param y defines the translation on Y axis
  75620. * @param z defines the translationon Z axis
  75621. * @param result defines the target matrix
  75622. */
  75623. Matrix.TranslationToRef = function (x, y, z, result) {
  75624. 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);
  75625. result._updateIdentityStatus(x === 0 && y === 0 && z === 0);
  75626. };
  75627. /**
  75628. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  75629. * @param startValue defines the start value
  75630. * @param endValue defines the end value
  75631. * @param gradient defines the gradient factor
  75632. * @returns the new matrix
  75633. */
  75634. Matrix.Lerp = function (startValue, endValue, gradient) {
  75635. var result = new Matrix();
  75636. Matrix.LerpToRef(startValue, endValue, gradient, result);
  75637. return result;
  75638. };
  75639. /**
  75640. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  75641. * @param startValue defines the start value
  75642. * @param endValue defines the end value
  75643. * @param gradient defines the gradient factor
  75644. * @param result defines the Matrix object where to store data
  75645. */
  75646. Matrix.LerpToRef = function (startValue, endValue, gradient, result) {
  75647. var resultM = result._m;
  75648. var startM = startValue.m;
  75649. var endM = endValue.m;
  75650. for (var index = 0; index < 16; index++) {
  75651. resultM[index] = startM[index] * (1.0 - gradient) + endM[index] * gradient;
  75652. }
  75653. result._markAsUpdated();
  75654. };
  75655. /**
  75656. * Builds a new matrix whose values are computed by:
  75657. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  75658. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  75659. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  75660. * @param startValue defines the first matrix
  75661. * @param endValue defines the second matrix
  75662. * @param gradient defines the gradient between the two matrices
  75663. * @returns the new matrix
  75664. */
  75665. Matrix.DecomposeLerp = function (startValue, endValue, gradient) {
  75666. var result = new Matrix();
  75667. Matrix.DecomposeLerpToRef(startValue, endValue, gradient, result);
  75668. return result;
  75669. };
  75670. /**
  75671. * Update a matrix to values which are computed by:
  75672. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  75673. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  75674. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  75675. * @param startValue defines the first matrix
  75676. * @param endValue defines the second matrix
  75677. * @param gradient defines the gradient between the two matrices
  75678. * @param result defines the target matrix
  75679. */
  75680. Matrix.DecomposeLerpToRef = function (startValue, endValue, gradient, result) {
  75681. var startScale = MathTmp.Vector3[0];
  75682. var startRotation = MathTmp.Quaternion[0];
  75683. var startTranslation = MathTmp.Vector3[1];
  75684. startValue.decompose(startScale, startRotation, startTranslation);
  75685. var endScale = MathTmp.Vector3[2];
  75686. var endRotation = MathTmp.Quaternion[1];
  75687. var endTranslation = MathTmp.Vector3[3];
  75688. endValue.decompose(endScale, endRotation, endTranslation);
  75689. var resultScale = MathTmp.Vector3[4];
  75690. Vector3.LerpToRef(startScale, endScale, gradient, resultScale);
  75691. var resultRotation = MathTmp.Quaternion[2];
  75692. Quaternion.SlerpToRef(startRotation, endRotation, gradient, resultRotation);
  75693. var resultTranslation = MathTmp.Vector3[5];
  75694. Vector3.LerpToRef(startTranslation, endTranslation, gradient, resultTranslation);
  75695. Matrix.ComposeToRef(resultScale, resultRotation, resultTranslation, result);
  75696. };
  75697. /**
  75698. * 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"
  75699. * This function works in left handed mode
  75700. * @param eye defines the final position of the entity
  75701. * @param target defines where the entity should look at
  75702. * @param up defines the up vector for the entity
  75703. * @returns the new matrix
  75704. */
  75705. Matrix.LookAtLH = function (eye, target, up) {
  75706. var result = new Matrix();
  75707. Matrix.LookAtLHToRef(eye, target, up, result);
  75708. return result;
  75709. };
  75710. /**
  75711. * 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".
  75712. * This function works in left handed mode
  75713. * @param eye defines the final position of the entity
  75714. * @param target defines where the entity should look at
  75715. * @param up defines the up vector for the entity
  75716. * @param result defines the target matrix
  75717. */
  75718. Matrix.LookAtLHToRef = function (eye, target, up, result) {
  75719. var xAxis = MathTmp.Vector3[0];
  75720. var yAxis = MathTmp.Vector3[1];
  75721. var zAxis = MathTmp.Vector3[2];
  75722. // Z axis
  75723. target.subtractToRef(eye, zAxis);
  75724. zAxis.normalize();
  75725. // X axis
  75726. Vector3.CrossToRef(up, zAxis, xAxis);
  75727. var xSquareLength = xAxis.lengthSquared();
  75728. if (xSquareLength === 0) {
  75729. xAxis.x = 1.0;
  75730. }
  75731. else {
  75732. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  75733. }
  75734. // Y axis
  75735. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  75736. yAxis.normalize();
  75737. // Eye angles
  75738. var ex = -Vector3.Dot(xAxis, eye);
  75739. var ey = -Vector3.Dot(yAxis, eye);
  75740. var ez = -Vector3.Dot(zAxis, eye);
  75741. 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);
  75742. };
  75743. /**
  75744. * 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"
  75745. * This function works in right handed mode
  75746. * @param eye defines the final position of the entity
  75747. * @param target defines where the entity should look at
  75748. * @param up defines the up vector for the entity
  75749. * @returns the new matrix
  75750. */
  75751. Matrix.LookAtRH = function (eye, target, up) {
  75752. var result = new Matrix();
  75753. Matrix.LookAtRHToRef(eye, target, up, result);
  75754. return result;
  75755. };
  75756. /**
  75757. * 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".
  75758. * This function works in right handed mode
  75759. * @param eye defines the final position of the entity
  75760. * @param target defines where the entity should look at
  75761. * @param up defines the up vector for the entity
  75762. * @param result defines the target matrix
  75763. */
  75764. Matrix.LookAtRHToRef = function (eye, target, up, result) {
  75765. var xAxis = MathTmp.Vector3[0];
  75766. var yAxis = MathTmp.Vector3[1];
  75767. var zAxis = MathTmp.Vector3[2];
  75768. // Z axis
  75769. eye.subtractToRef(target, zAxis);
  75770. zAxis.normalize();
  75771. // X axis
  75772. Vector3.CrossToRef(up, zAxis, xAxis);
  75773. var xSquareLength = xAxis.lengthSquared();
  75774. if (xSquareLength === 0) {
  75775. xAxis.x = 1.0;
  75776. }
  75777. else {
  75778. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  75779. }
  75780. // Y axis
  75781. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  75782. yAxis.normalize();
  75783. // Eye angles
  75784. var ex = -Vector3.Dot(xAxis, eye);
  75785. var ey = -Vector3.Dot(yAxis, eye);
  75786. var ez = -Vector3.Dot(zAxis, eye);
  75787. 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);
  75788. };
  75789. /**
  75790. * Create a left-handed orthographic projection matrix
  75791. * @param width defines the viewport width
  75792. * @param height defines the viewport height
  75793. * @param znear defines the near clip plane
  75794. * @param zfar defines the far clip plane
  75795. * @returns a new matrix as a left-handed orthographic projection matrix
  75796. */
  75797. Matrix.OrthoLH = function (width, height, znear, zfar) {
  75798. var matrix = new Matrix();
  75799. Matrix.OrthoLHToRef(width, height, znear, zfar, matrix);
  75800. return matrix;
  75801. };
  75802. /**
  75803. * Store a left-handed orthographic projection to a given matrix
  75804. * @param width defines the viewport width
  75805. * @param height defines the viewport height
  75806. * @param znear defines the near clip plane
  75807. * @param zfar defines the far clip plane
  75808. * @param result defines the target matrix
  75809. */
  75810. Matrix.OrthoLHToRef = function (width, height, znear, zfar, result) {
  75811. var n = znear;
  75812. var f = zfar;
  75813. var a = 2.0 / width;
  75814. var b = 2.0 / height;
  75815. var c = 2.0 / (f - n);
  75816. var d = -(f + n) / (f - n);
  75817. 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);
  75818. result._updateIdentityStatus(a === 1 && b === 1 && c === 1 && d === 0);
  75819. };
  75820. /**
  75821. * Create a left-handed orthographic projection matrix
  75822. * @param left defines the viewport left coordinate
  75823. * @param right defines the viewport right coordinate
  75824. * @param bottom defines the viewport bottom coordinate
  75825. * @param top defines the viewport top coordinate
  75826. * @param znear defines the near clip plane
  75827. * @param zfar defines the far clip plane
  75828. * @returns a new matrix as a left-handed orthographic projection matrix
  75829. */
  75830. Matrix.OrthoOffCenterLH = function (left, right, bottom, top, znear, zfar) {
  75831. var matrix = new Matrix();
  75832. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, matrix);
  75833. return matrix;
  75834. };
  75835. /**
  75836. * Stores a left-handed orthographic projection into a given matrix
  75837. * @param left defines the viewport left coordinate
  75838. * @param right defines the viewport right coordinate
  75839. * @param bottom defines the viewport bottom coordinate
  75840. * @param top defines the viewport top coordinate
  75841. * @param znear defines the near clip plane
  75842. * @param zfar defines the far clip plane
  75843. * @param result defines the target matrix
  75844. */
  75845. Matrix.OrthoOffCenterLHToRef = function (left, right, bottom, top, znear, zfar, result) {
  75846. var n = znear;
  75847. var f = zfar;
  75848. var a = 2.0 / (right - left);
  75849. var b = 2.0 / (top - bottom);
  75850. var c = 2.0 / (f - n);
  75851. var d = -(f + n) / (f - n);
  75852. var i0 = (left + right) / (left - right);
  75853. var i1 = (top + bottom) / (bottom - top);
  75854. 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);
  75855. result._markAsUpdated();
  75856. };
  75857. /**
  75858. * Creates a right-handed orthographic projection matrix
  75859. * @param left defines the viewport left coordinate
  75860. * @param right defines the viewport right coordinate
  75861. * @param bottom defines the viewport bottom coordinate
  75862. * @param top defines the viewport top coordinate
  75863. * @param znear defines the near clip plane
  75864. * @param zfar defines the far clip plane
  75865. * @returns a new matrix as a right-handed orthographic projection matrix
  75866. */
  75867. Matrix.OrthoOffCenterRH = function (left, right, bottom, top, znear, zfar) {
  75868. var matrix = new Matrix();
  75869. Matrix.OrthoOffCenterRHToRef(left, right, bottom, top, znear, zfar, matrix);
  75870. return matrix;
  75871. };
  75872. /**
  75873. * Stores a right-handed orthographic projection into a given matrix
  75874. * @param left defines the viewport left coordinate
  75875. * @param right defines the viewport right coordinate
  75876. * @param bottom defines the viewport bottom coordinate
  75877. * @param top defines the viewport top coordinate
  75878. * @param znear defines the near clip plane
  75879. * @param zfar defines the far clip plane
  75880. * @param result defines the target matrix
  75881. */
  75882. Matrix.OrthoOffCenterRHToRef = function (left, right, bottom, top, znear, zfar, result) {
  75883. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, result);
  75884. result._m[10] *= -1; // No need to call _markAsUpdated as previous function already called it and let _isIdentityDirty to true
  75885. };
  75886. /**
  75887. * Creates a left-handed perspective projection matrix
  75888. * @param width defines the viewport width
  75889. * @param height defines the viewport height
  75890. * @param znear defines the near clip plane
  75891. * @param zfar defines the far clip plane
  75892. * @returns a new matrix as a left-handed perspective projection matrix
  75893. */
  75894. Matrix.PerspectiveLH = function (width, height, znear, zfar) {
  75895. var matrix = new Matrix();
  75896. var n = znear;
  75897. var f = zfar;
  75898. var a = 2.0 * n / width;
  75899. var b = 2.0 * n / height;
  75900. var c = (f + n) / (f - n);
  75901. var d = -2.0 * f * n / (f - n);
  75902. 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);
  75903. matrix._updateIdentityStatus(false);
  75904. return matrix;
  75905. };
  75906. /**
  75907. * Creates a left-handed perspective projection matrix
  75908. * @param fov defines the horizontal field of view
  75909. * @param aspect defines the aspect ratio
  75910. * @param znear defines the near clip plane
  75911. * @param zfar defines the far clip plane
  75912. * @returns a new matrix as a left-handed perspective projection matrix
  75913. */
  75914. Matrix.PerspectiveFovLH = function (fov, aspect, znear, zfar) {
  75915. var matrix = new Matrix();
  75916. Matrix.PerspectiveFovLHToRef(fov, aspect, znear, zfar, matrix);
  75917. return matrix;
  75918. };
  75919. /**
  75920. * Stores a left-handed perspective projection into a given matrix
  75921. * @param fov defines the horizontal field of view
  75922. * @param aspect defines the aspect ratio
  75923. * @param znear defines the near clip plane
  75924. * @param zfar defines the far clip plane
  75925. * @param result defines the target matrix
  75926. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75927. */
  75928. Matrix.PerspectiveFovLHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  75929. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  75930. var n = znear;
  75931. var f = zfar;
  75932. var t = 1.0 / (Math.tan(fov * 0.5));
  75933. var a = isVerticalFovFixed ? (t / aspect) : t;
  75934. var b = isVerticalFovFixed ? t : (t * aspect);
  75935. var c = (f + n) / (f - n);
  75936. var d = -2.0 * f * n / (f - n);
  75937. 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);
  75938. result._updateIdentityStatus(false);
  75939. };
  75940. /**
  75941. * Creates a right-handed perspective projection matrix
  75942. * @param fov defines the horizontal field of view
  75943. * @param aspect defines the aspect ratio
  75944. * @param znear defines the near clip plane
  75945. * @param zfar defines the far clip plane
  75946. * @returns a new matrix as a right-handed perspective projection matrix
  75947. */
  75948. Matrix.PerspectiveFovRH = function (fov, aspect, znear, zfar) {
  75949. var matrix = new Matrix();
  75950. Matrix.PerspectiveFovRHToRef(fov, aspect, znear, zfar, matrix);
  75951. return matrix;
  75952. };
  75953. /**
  75954. * Stores a right-handed perspective projection into a given matrix
  75955. * @param fov defines the horizontal field of view
  75956. * @param aspect defines the aspect ratio
  75957. * @param znear defines the near clip plane
  75958. * @param zfar defines the far clip plane
  75959. * @param result defines the target matrix
  75960. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75961. */
  75962. Matrix.PerspectiveFovRHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  75963. //alternatively this could be expressed as:
  75964. // m = PerspectiveFovLHToRef
  75965. // m[10] *= -1.0;
  75966. // m[11] *= -1.0;
  75967. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  75968. var n = znear;
  75969. var f = zfar;
  75970. var t = 1.0 / (Math.tan(fov * 0.5));
  75971. var a = isVerticalFovFixed ? (t / aspect) : t;
  75972. var b = isVerticalFovFixed ? t : (t * aspect);
  75973. var c = -(f + n) / (f - n);
  75974. var d = -2 * f * n / (f - n);
  75975. 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);
  75976. result._updateIdentityStatus(false);
  75977. };
  75978. /**
  75979. * Stores a perspective projection for WebVR info a given matrix
  75980. * @param fov defines the field of view
  75981. * @param znear defines the near clip plane
  75982. * @param zfar defines the far clip plane
  75983. * @param result defines the target matrix
  75984. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  75985. */
  75986. Matrix.PerspectiveFovWebVRToRef = function (fov, znear, zfar, result, rightHanded) {
  75987. if (rightHanded === void 0) { rightHanded = false; }
  75988. var rightHandedFactor = rightHanded ? -1 : 1;
  75989. var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);
  75990. var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0);
  75991. var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0);
  75992. var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);
  75993. var xScale = 2.0 / (leftTan + rightTan);
  75994. var yScale = 2.0 / (upTan + downTan);
  75995. var m = result._m;
  75996. m[0] = xScale;
  75997. m[1] = m[2] = m[3] = m[4] = 0.0;
  75998. m[5] = yScale;
  75999. m[6] = m[7] = 0.0;
  76000. m[8] = ((leftTan - rightTan) * xScale * 0.5);
  76001. m[9] = -((upTan - downTan) * yScale * 0.5);
  76002. m[10] = -zfar / (znear - zfar);
  76003. m[11] = 1.0 * rightHandedFactor;
  76004. m[12] = m[13] = m[15] = 0.0;
  76005. m[14] = -(2.0 * zfar * znear) / (zfar - znear);
  76006. result._markAsUpdated();
  76007. };
  76008. /**
  76009. * Computes a complete transformation matrix
  76010. * @param viewport defines the viewport to use
  76011. * @param world defines the world matrix
  76012. * @param view defines the view matrix
  76013. * @param projection defines the projection matrix
  76014. * @param zmin defines the near clip plane
  76015. * @param zmax defines the far clip plane
  76016. * @returns the transformation matrix
  76017. */
  76018. Matrix.GetFinalMatrix = function (viewport, world, view, projection, zmin, zmax) {
  76019. var cw = viewport.width;
  76020. var ch = viewport.height;
  76021. var cx = viewport.x;
  76022. var cy = viewport.y;
  76023. 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);
  76024. var matrix = MathTmp.Matrix[0];
  76025. world.multiplyToRef(view, matrix);
  76026. matrix.multiplyToRef(projection, matrix);
  76027. return matrix.multiply(viewportMatrix);
  76028. };
  76029. /**
  76030. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  76031. * @param matrix defines the matrix to use
  76032. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  76033. */
  76034. Matrix.GetAsMatrix2x2 = function (matrix) {
  76035. var m = matrix.m;
  76036. return new Float32Array([m[0], m[1], m[4], m[5]]);
  76037. };
  76038. /**
  76039. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  76040. * @param matrix defines the matrix to use
  76041. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  76042. */
  76043. Matrix.GetAsMatrix3x3 = function (matrix) {
  76044. var m = matrix.m;
  76045. return new Float32Array([
  76046. m[0], m[1], m[2],
  76047. m[4], m[5], m[6],
  76048. m[8], m[9], m[10]
  76049. ]);
  76050. };
  76051. /**
  76052. * Compute the transpose of a given matrix
  76053. * @param matrix defines the matrix to transpose
  76054. * @returns the new matrix
  76055. */
  76056. Matrix.Transpose = function (matrix) {
  76057. var result = new Matrix();
  76058. Matrix.TransposeToRef(matrix, result);
  76059. return result;
  76060. };
  76061. /**
  76062. * Compute the transpose of a matrix and store it in a target matrix
  76063. * @param matrix defines the matrix to transpose
  76064. * @param result defines the target matrix
  76065. */
  76066. Matrix.TransposeToRef = function (matrix, result) {
  76067. var rm = result._m;
  76068. var mm = matrix.m;
  76069. rm[0] = mm[0];
  76070. rm[1] = mm[4];
  76071. rm[2] = mm[8];
  76072. rm[3] = mm[12];
  76073. rm[4] = mm[1];
  76074. rm[5] = mm[5];
  76075. rm[6] = mm[9];
  76076. rm[7] = mm[13];
  76077. rm[8] = mm[2];
  76078. rm[9] = mm[6];
  76079. rm[10] = mm[10];
  76080. rm[11] = mm[14];
  76081. rm[12] = mm[3];
  76082. rm[13] = mm[7];
  76083. rm[14] = mm[11];
  76084. rm[15] = mm[15];
  76085. // identity-ness does not change when transposing
  76086. result._updateIdentityStatus(matrix._isIdentity, matrix._isIdentityDirty);
  76087. };
  76088. /**
  76089. * Computes a reflection matrix from a plane
  76090. * @param plane defines the reflection plane
  76091. * @returns a new matrix
  76092. */
  76093. Matrix.Reflection = function (plane) {
  76094. var matrix = new Matrix();
  76095. Matrix.ReflectionToRef(plane, matrix);
  76096. return matrix;
  76097. };
  76098. /**
  76099. * Computes a reflection matrix from a plane
  76100. * @param plane defines the reflection plane
  76101. * @param result defines the target matrix
  76102. */
  76103. Matrix.ReflectionToRef = function (plane, result) {
  76104. plane.normalize();
  76105. var x = plane.normal.x;
  76106. var y = plane.normal.y;
  76107. var z = plane.normal.z;
  76108. var temp = -2 * x;
  76109. var temp2 = -2 * y;
  76110. var temp3 = -2 * z;
  76111. 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);
  76112. };
  76113. /**
  76114. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  76115. * @param xaxis defines the value of the 1st axis
  76116. * @param yaxis defines the value of the 2nd axis
  76117. * @param zaxis defines the value of the 3rd axis
  76118. * @param result defines the target matrix
  76119. */
  76120. Matrix.FromXYZAxesToRef = function (xaxis, yaxis, zaxis, result) {
  76121. 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);
  76122. };
  76123. /**
  76124. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  76125. * @param quat defines the quaternion to use
  76126. * @param result defines the target matrix
  76127. */
  76128. Matrix.FromQuaternionToRef = function (quat, result) {
  76129. var xx = quat.x * quat.x;
  76130. var yy = quat.y * quat.y;
  76131. var zz = quat.z * quat.z;
  76132. var xy = quat.x * quat.y;
  76133. var zw = quat.z * quat.w;
  76134. var zx = quat.z * quat.x;
  76135. var yw = quat.y * quat.w;
  76136. var yz = quat.y * quat.z;
  76137. var xw = quat.x * quat.w;
  76138. result._m[0] = 1.0 - (2.0 * (yy + zz));
  76139. result._m[1] = 2.0 * (xy + zw);
  76140. result._m[2] = 2.0 * (zx - yw);
  76141. result._m[3] = 0.0;
  76142. result._m[4] = 2.0 * (xy - zw);
  76143. result._m[5] = 1.0 - (2.0 * (zz + xx));
  76144. result._m[6] = 2.0 * (yz + xw);
  76145. result._m[7] = 0.0;
  76146. result._m[8] = 2.0 * (zx + yw);
  76147. result._m[9] = 2.0 * (yz - xw);
  76148. result._m[10] = 1.0 - (2.0 * (yy + xx));
  76149. result._m[11] = 0.0;
  76150. result._m[12] = 0.0;
  76151. result._m[13] = 0.0;
  76152. result._m[14] = 0.0;
  76153. result._m[15] = 1.0;
  76154. result._markAsUpdated();
  76155. };
  76156. Matrix._updateFlagSeed = 0;
  76157. Matrix._identityReadOnly = Matrix.Identity();
  76158. return Matrix;
  76159. }());
  76160. /**
  76161. * Represens a plane by the equation ax + by + cz + d = 0
  76162. */
  76163. var Plane = /** @class */ (function () {
  76164. /**
  76165. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  76166. * @param a a component of the plane
  76167. * @param b b component of the plane
  76168. * @param c c component of the plane
  76169. * @param d d component of the plane
  76170. */
  76171. function Plane(a, b, c, d) {
  76172. this.normal = new Vector3(a, b, c);
  76173. this.d = d;
  76174. }
  76175. /**
  76176. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  76177. */
  76178. Plane.prototype.asArray = function () {
  76179. return [this.normal.x, this.normal.y, this.normal.z, this.d];
  76180. };
  76181. // Methods
  76182. /**
  76183. * @returns a new plane copied from the current Plane.
  76184. */
  76185. Plane.prototype.clone = function () {
  76186. return new Plane(this.normal.x, this.normal.y, this.normal.z, this.d);
  76187. };
  76188. /**
  76189. * @returns the string "Plane".
  76190. */
  76191. Plane.prototype.getClassName = function () {
  76192. return "Plane";
  76193. };
  76194. /**
  76195. * @returns the Plane hash code.
  76196. */
  76197. Plane.prototype.getHashCode = function () {
  76198. var hash = this.normal.getHashCode();
  76199. hash = (hash * 397) ^ (this.d || 0);
  76200. return hash;
  76201. };
  76202. /**
  76203. * Normalize the current Plane in place.
  76204. * @returns the updated Plane.
  76205. */
  76206. Plane.prototype.normalize = function () {
  76207. var norm = (Math.sqrt((this.normal.x * this.normal.x) + (this.normal.y * this.normal.y) + (this.normal.z * this.normal.z)));
  76208. var magnitude = 0.0;
  76209. if (norm !== 0) {
  76210. magnitude = 1.0 / norm;
  76211. }
  76212. this.normal.x *= magnitude;
  76213. this.normal.y *= magnitude;
  76214. this.normal.z *= magnitude;
  76215. this.d *= magnitude;
  76216. return this;
  76217. };
  76218. /**
  76219. * Applies a transformation the plane and returns the result
  76220. * @param transformation the transformation matrix to be applied to the plane
  76221. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  76222. */
  76223. Plane.prototype.transform = function (transformation) {
  76224. var transposedMatrix = MathTmp.Matrix[0];
  76225. Matrix.TransposeToRef(transformation, transposedMatrix);
  76226. var m = transposedMatrix.m;
  76227. var x = this.normal.x;
  76228. var y = this.normal.y;
  76229. var z = this.normal.z;
  76230. var d = this.d;
  76231. var normalX = x * m[0] + y * m[1] + z * m[2] + d * m[3];
  76232. var normalY = x * m[4] + y * m[5] + z * m[6] + d * m[7];
  76233. var normalZ = x * m[8] + y * m[9] + z * m[10] + d * m[11];
  76234. var finalD = x * m[12] + y * m[13] + z * m[14] + d * m[15];
  76235. return new Plane(normalX, normalY, normalZ, finalD);
  76236. };
  76237. /**
  76238. * Calcualtte the dot product between the point and the plane normal
  76239. * @param point point to calculate the dot product with
  76240. * @returns the dot product (float) of the point coordinates and the plane normal.
  76241. */
  76242. Plane.prototype.dotCoordinate = function (point) {
  76243. return ((((this.normal.x * point.x) + (this.normal.y * point.y)) + (this.normal.z * point.z)) + this.d);
  76244. };
  76245. /**
  76246. * Updates the current Plane from the plane defined by the three given points.
  76247. * @param point1 one of the points used to contruct the plane
  76248. * @param point2 one of the points used to contruct the plane
  76249. * @param point3 one of the points used to contruct the plane
  76250. * @returns the updated Plane.
  76251. */
  76252. Plane.prototype.copyFromPoints = function (point1, point2, point3) {
  76253. var x1 = point2.x - point1.x;
  76254. var y1 = point2.y - point1.y;
  76255. var z1 = point2.z - point1.z;
  76256. var x2 = point3.x - point1.x;
  76257. var y2 = point3.y - point1.y;
  76258. var z2 = point3.z - point1.z;
  76259. var yz = (y1 * z2) - (z1 * y2);
  76260. var xz = (z1 * x2) - (x1 * z2);
  76261. var xy = (x1 * y2) - (y1 * x2);
  76262. var pyth = (Math.sqrt((yz * yz) + (xz * xz) + (xy * xy)));
  76263. var invPyth;
  76264. if (pyth !== 0) {
  76265. invPyth = 1.0 / pyth;
  76266. }
  76267. else {
  76268. invPyth = 0.0;
  76269. }
  76270. this.normal.x = yz * invPyth;
  76271. this.normal.y = xz * invPyth;
  76272. this.normal.z = xy * invPyth;
  76273. this.d = -((this.normal.x * point1.x) + (this.normal.y * point1.y) + (this.normal.z * point1.z));
  76274. return this;
  76275. };
  76276. /**
  76277. * Checks if the plane is facing a given direction
  76278. * @param direction the direction to check if the plane is facing
  76279. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  76280. * @returns True is the vector "direction" is the same side than the plane normal.
  76281. */
  76282. Plane.prototype.isFrontFacingTo = function (direction, epsilon) {
  76283. var dot = Vector3.Dot(this.normal, direction);
  76284. return (dot <= epsilon);
  76285. };
  76286. /**
  76287. * Calculates the distance to a point
  76288. * @param point point to calculate distance to
  76289. * @returns the signed distance (float) from the given point to the Plane.
  76290. */
  76291. Plane.prototype.signedDistanceTo = function (point) {
  76292. return Vector3.Dot(point, this.normal) + this.d;
  76293. };
  76294. // Statics
  76295. /**
  76296. * Creates a plane from an array
  76297. * @param array the array to create a plane from
  76298. * @returns a new Plane from the given array.
  76299. */
  76300. Plane.FromArray = function (array) {
  76301. return new Plane(array[0], array[1], array[2], array[3]);
  76302. };
  76303. /**
  76304. * Creates a plane from three points
  76305. * @param point1 point used to create the plane
  76306. * @param point2 point used to create the plane
  76307. * @param point3 point used to create the plane
  76308. * @returns a new Plane defined by the three given points.
  76309. */
  76310. Plane.FromPoints = function (point1, point2, point3) {
  76311. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  76312. result.copyFromPoints(point1, point2, point3);
  76313. return result;
  76314. };
  76315. /**
  76316. * Creates a plane from an origin point and a normal
  76317. * @param origin origin of the plane to be constructed
  76318. * @param normal normal of the plane to be constructed
  76319. * @returns a new Plane the normal vector to this plane at the given origin point.
  76320. * Note : the vector "normal" is updated because normalized.
  76321. */
  76322. Plane.FromPositionAndNormal = function (origin, normal) {
  76323. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  76324. normal.normalize();
  76325. result.normal = normal;
  76326. result.d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  76327. return result;
  76328. };
  76329. /**
  76330. * Calculates the distance from a plane and a point
  76331. * @param origin origin of the plane to be constructed
  76332. * @param normal normal of the plane to be constructed
  76333. * @param point point to calculate distance to
  76334. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  76335. */
  76336. Plane.SignedDistanceToPlaneFromPositionAndNormal = function (origin, normal, point) {
  76337. var d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  76338. return Vector3.Dot(point, normal) + d;
  76339. };
  76340. return Plane;
  76341. }());
  76342. /**
  76343. * Class used to represent a viewport on screen
  76344. */
  76345. var Viewport = /** @class */ (function () {
  76346. /**
  76347. * Creates a Viewport object located at (x, y) and sized (width, height)
  76348. * @param x defines viewport left coordinate
  76349. * @param y defines viewport top coordinate
  76350. * @param width defines the viewport width
  76351. * @param height defines the viewport height
  76352. */
  76353. function Viewport(
  76354. /** viewport left coordinate */
  76355. x,
  76356. /** viewport top coordinate */
  76357. y,
  76358. /**viewport width */
  76359. width,
  76360. /** viewport height */
  76361. height) {
  76362. this.x = x;
  76363. this.y = y;
  76364. this.width = width;
  76365. this.height = height;
  76366. }
  76367. /**
  76368. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  76369. * @param renderWidth defines the rendering width
  76370. * @param renderHeight defines the rendering height
  76371. * @returns a new Viewport
  76372. */
  76373. Viewport.prototype.toGlobal = function (renderWidth, renderHeight) {
  76374. return new Viewport(this.x * renderWidth, this.y * renderHeight, this.width * renderWidth, this.height * renderHeight);
  76375. };
  76376. /**
  76377. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  76378. * @param renderWidth defines the rendering width
  76379. * @param renderHeight defines the rendering height
  76380. * @param ref defines the target viewport
  76381. * @returns the current viewport
  76382. */
  76383. Viewport.prototype.toGlobalToRef = function (renderWidth, renderHeight, ref) {
  76384. ref.x = this.x * renderWidth;
  76385. ref.y = this.y * renderHeight;
  76386. ref.width = this.width * renderWidth;
  76387. ref.height = this.height * renderHeight;
  76388. return this;
  76389. };
  76390. /**
  76391. * Returns a new Viewport copied from the current one
  76392. * @returns a new Viewport
  76393. */
  76394. Viewport.prototype.clone = function () {
  76395. return new Viewport(this.x, this.y, this.width, this.height);
  76396. };
  76397. return Viewport;
  76398. }());
  76399. /**
  76400. * Reprasents a camera frustum
  76401. */
  76402. var Frustum = /** @class */ (function () {
  76403. function Frustum() {
  76404. }
  76405. /**
  76406. * Gets the planes representing the frustum
  76407. * @param transform matrix to be applied to the returned planes
  76408. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  76409. */
  76410. Frustum.GetPlanes = function (transform) {
  76411. var frustumPlanes = [];
  76412. for (var index = 0; index < 6; index++) {
  76413. frustumPlanes.push(new Plane(0.0, 0.0, 0.0, 0.0));
  76414. }
  76415. Frustum.GetPlanesToRef(transform, frustumPlanes);
  76416. return frustumPlanes;
  76417. };
  76418. /**
  76419. * Gets the near frustum plane transformed by the transform matrix
  76420. * @param transform transformation matrix to be applied to the resulting frustum plane
  76421. * @param frustumPlane the resuling frustum plane
  76422. */
  76423. Frustum.GetNearPlaneToRef = function (transform, frustumPlane) {
  76424. var m = transform.m;
  76425. frustumPlane.normal.x = m[3] + m[2];
  76426. frustumPlane.normal.y = m[7] + m[6];
  76427. frustumPlane.normal.z = m[11] + m[10];
  76428. frustumPlane.d = m[15] + m[14];
  76429. frustumPlane.normalize();
  76430. };
  76431. /**
  76432. * Gets the far frustum plane transformed by the transform matrix
  76433. * @param transform transformation matrix to be applied to the resulting frustum plane
  76434. * @param frustumPlane the resuling frustum plane
  76435. */
  76436. Frustum.GetFarPlaneToRef = function (transform, frustumPlane) {
  76437. var m = transform.m;
  76438. frustumPlane.normal.x = m[3] - m[2];
  76439. frustumPlane.normal.y = m[7] - m[6];
  76440. frustumPlane.normal.z = m[11] - m[10];
  76441. frustumPlane.d = m[15] - m[14];
  76442. frustumPlane.normalize();
  76443. };
  76444. /**
  76445. * Gets the left frustum plane transformed by the transform matrix
  76446. * @param transform transformation matrix to be applied to the resulting frustum plane
  76447. * @param frustumPlane the resuling frustum plane
  76448. */
  76449. Frustum.GetLeftPlaneToRef = function (transform, frustumPlane) {
  76450. var m = transform.m;
  76451. frustumPlane.normal.x = m[3] + m[0];
  76452. frustumPlane.normal.y = m[7] + m[4];
  76453. frustumPlane.normal.z = m[11] + m[8];
  76454. frustumPlane.d = m[15] + m[12];
  76455. frustumPlane.normalize();
  76456. };
  76457. /**
  76458. * Gets the right frustum plane transformed by the transform matrix
  76459. * @param transform transformation matrix to be applied to the resulting frustum plane
  76460. * @param frustumPlane the resuling frustum plane
  76461. */
  76462. Frustum.GetRightPlaneToRef = function (transform, frustumPlane) {
  76463. var m = transform.m;
  76464. frustumPlane.normal.x = m[3] - m[0];
  76465. frustumPlane.normal.y = m[7] - m[4];
  76466. frustumPlane.normal.z = m[11] - m[8];
  76467. frustumPlane.d = m[15] - m[12];
  76468. frustumPlane.normalize();
  76469. };
  76470. /**
  76471. * Gets the top frustum plane transformed by the transform matrix
  76472. * @param transform transformation matrix to be applied to the resulting frustum plane
  76473. * @param frustumPlane the resuling frustum plane
  76474. */
  76475. Frustum.GetTopPlaneToRef = function (transform, frustumPlane) {
  76476. var m = transform.m;
  76477. frustumPlane.normal.x = m[3] - m[1];
  76478. frustumPlane.normal.y = m[7] - m[5];
  76479. frustumPlane.normal.z = m[11] - m[9];
  76480. frustumPlane.d = m[15] - m[13];
  76481. frustumPlane.normalize();
  76482. };
  76483. /**
  76484. * Gets the bottom frustum plane transformed by the transform matrix
  76485. * @param transform transformation matrix to be applied to the resulting frustum plane
  76486. * @param frustumPlane the resuling frustum plane
  76487. */
  76488. Frustum.GetBottomPlaneToRef = function (transform, frustumPlane) {
  76489. var m = transform.m;
  76490. frustumPlane.normal.x = m[3] + m[1];
  76491. frustumPlane.normal.y = m[7] + m[5];
  76492. frustumPlane.normal.z = m[11] + m[9];
  76493. frustumPlane.d = m[15] + m[13];
  76494. frustumPlane.normalize();
  76495. };
  76496. /**
  76497. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  76498. * @param transform transformation matrix to be applied to the resulting frustum planes
  76499. * @param frustumPlanes the resuling frustum planes
  76500. */
  76501. Frustum.GetPlanesToRef = function (transform, frustumPlanes) {
  76502. // Near
  76503. Frustum.GetNearPlaneToRef(transform, frustumPlanes[0]);
  76504. // Far
  76505. Frustum.GetFarPlaneToRef(transform, frustumPlanes[1]);
  76506. // Left
  76507. Frustum.GetLeftPlaneToRef(transform, frustumPlanes[2]);
  76508. // Right
  76509. Frustum.GetRightPlaneToRef(transform, frustumPlanes[3]);
  76510. // Top
  76511. Frustum.GetTopPlaneToRef(transform, frustumPlanes[4]);
  76512. // Bottom
  76513. Frustum.GetBottomPlaneToRef(transform, frustumPlanes[5]);
  76514. };
  76515. return Frustum;
  76516. }());
  76517. /** Defines supported spaces */
  76518. var Space;
  76519. (function (Space) {
  76520. /** Local (object) space */
  76521. Space[Space["LOCAL"] = 0] = "LOCAL";
  76522. /** World space */
  76523. Space[Space["WORLD"] = 1] = "WORLD";
  76524. /** Bone space */
  76525. Space[Space["BONE"] = 2] = "BONE";
  76526. })(Space || (Space = {}));
  76527. /** Defines the 3 main axes */
  76528. var Axis = /** @class */ (function () {
  76529. function Axis() {
  76530. }
  76531. /** X axis */
  76532. Axis.X = new Vector3(1.0, 0.0, 0.0);
  76533. /** Y axis */
  76534. Axis.Y = new Vector3(0.0, 1.0, 0.0);
  76535. /** Z axis */
  76536. Axis.Z = new Vector3(0.0, 0.0, 1.0);
  76537. return Axis;
  76538. }());
  76539. /** Class used to represent a Bezier curve */
  76540. var BezierCurve = /** @class */ (function () {
  76541. function BezierCurve() {
  76542. }
  76543. /**
  76544. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  76545. * @param t defines the time
  76546. * @param x1 defines the left coordinate on X axis
  76547. * @param y1 defines the left coordinate on Y axis
  76548. * @param x2 defines the right coordinate on X axis
  76549. * @param y2 defines the right coordinate on Y axis
  76550. * @returns the interpolated value
  76551. */
  76552. BezierCurve.Interpolate = function (t, x1, y1, x2, y2) {
  76553. // Extract X (which is equal to time here)
  76554. var f0 = 1 - 3 * x2 + 3 * x1;
  76555. var f1 = 3 * x2 - 6 * x1;
  76556. var f2 = 3 * x1;
  76557. var refinedT = t;
  76558. for (var i = 0; i < 5; i++) {
  76559. var refinedT2 = refinedT * refinedT;
  76560. var refinedT3 = refinedT2 * refinedT;
  76561. var x = f0 * refinedT3 + f1 * refinedT2 + f2 * refinedT;
  76562. var slope = 1.0 / (3.0 * f0 * refinedT2 + 2.0 * f1 * refinedT + f2);
  76563. refinedT -= (x - t) * slope;
  76564. refinedT = Math.min(1, Math.max(0, refinedT));
  76565. }
  76566. // Resolve cubic bezier for the given x
  76567. return 3 * Math.pow(1 - refinedT, 2) * refinedT * y1 +
  76568. 3 * (1 - refinedT) * Math.pow(refinedT, 2) * y2 +
  76569. Math.pow(refinedT, 3);
  76570. };
  76571. return BezierCurve;
  76572. }());
  76573. /**
  76574. * Defines potential orientation for back face culling
  76575. */
  76576. var Orientation;
  76577. (function (Orientation) {
  76578. /**
  76579. * Clockwise
  76580. */
  76581. Orientation[Orientation["CW"] = 0] = "CW";
  76582. /** Counter clockwise */
  76583. Orientation[Orientation["CCW"] = 1] = "CCW";
  76584. })(Orientation || (Orientation = {}));
  76585. /**
  76586. * Defines angle representation
  76587. */
  76588. var Angle = /** @class */ (function () {
  76589. /**
  76590. * Creates an Angle object of "radians" radians (float).
  76591. * @param radians the angle in radians
  76592. */
  76593. function Angle(radians) {
  76594. this._radians = radians;
  76595. if (this._radians < 0.0) {
  76596. this._radians += (2.0 * Math.PI);
  76597. }
  76598. }
  76599. /**
  76600. * Get value in degrees
  76601. * @returns the Angle value in degrees (float)
  76602. */
  76603. Angle.prototype.degrees = function () {
  76604. return this._radians * 180.0 / Math.PI;
  76605. };
  76606. /**
  76607. * Get value in radians
  76608. * @returns the Angle value in radians (float)
  76609. */
  76610. Angle.prototype.radians = function () {
  76611. return this._radians;
  76612. };
  76613. /**
  76614. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  76615. * @param a defines first vector
  76616. * @param b defines second vector
  76617. * @returns a new Angle
  76618. */
  76619. Angle.BetweenTwoPoints = function (a, b) {
  76620. var delta = b.subtract(a);
  76621. var theta = Math.atan2(delta.y, delta.x);
  76622. return new Angle(theta);
  76623. };
  76624. /**
  76625. * Gets a new Angle object from the given float in radians
  76626. * @param radians defines the angle value in radians
  76627. * @returns a new Angle
  76628. */
  76629. Angle.FromRadians = function (radians) {
  76630. return new Angle(radians);
  76631. };
  76632. /**
  76633. * Gets a new Angle object from the given float in degrees
  76634. * @param degrees defines the angle value in degrees
  76635. * @returns a new Angle
  76636. */
  76637. Angle.FromDegrees = function (degrees) {
  76638. return new Angle(degrees * Math.PI / 180.0);
  76639. };
  76640. return Angle;
  76641. }());
  76642. /**
  76643. * This represents an arc in a 2d space.
  76644. */
  76645. var Arc2 = /** @class */ (function () {
  76646. /**
  76647. * Creates an Arc object from the three given points : start, middle and end.
  76648. * @param startPoint Defines the start point of the arc
  76649. * @param midPoint Defines the midlle point of the arc
  76650. * @param endPoint Defines the end point of the arc
  76651. */
  76652. function Arc2(
  76653. /** Defines the start point of the arc */
  76654. startPoint,
  76655. /** Defines the mid point of the arc */
  76656. midPoint,
  76657. /** Defines the end point of the arc */
  76658. endPoint) {
  76659. this.startPoint = startPoint;
  76660. this.midPoint = midPoint;
  76661. this.endPoint = endPoint;
  76662. var temp = Math.pow(midPoint.x, 2) + Math.pow(midPoint.y, 2);
  76663. var startToMid = (Math.pow(startPoint.x, 2) + Math.pow(startPoint.y, 2) - temp) / 2.;
  76664. var midToEnd = (temp - Math.pow(endPoint.x, 2) - Math.pow(endPoint.y, 2)) / 2.;
  76665. var det = (startPoint.x - midPoint.x) * (midPoint.y - endPoint.y) - (midPoint.x - endPoint.x) * (startPoint.y - midPoint.y);
  76666. 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);
  76667. this.radius = this.centerPoint.subtract(this.startPoint).length();
  76668. this.startAngle = Angle.BetweenTwoPoints(this.centerPoint, this.startPoint);
  76669. var a1 = this.startAngle.degrees();
  76670. var a2 = Angle.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees();
  76671. var a3 = Angle.BetweenTwoPoints(this.centerPoint, this.endPoint).degrees();
  76672. // angles correction
  76673. if (a2 - a1 > +180.0) {
  76674. a2 -= 360.0;
  76675. }
  76676. if (a2 - a1 < -180.0) {
  76677. a2 += 360.0;
  76678. }
  76679. if (a3 - a2 > +180.0) {
  76680. a3 -= 360.0;
  76681. }
  76682. if (a3 - a2 < -180.0) {
  76683. a3 += 360.0;
  76684. }
  76685. this.orientation = (a2 - a1) < 0 ? Orientation.CW : Orientation.CCW;
  76686. this.angle = Angle.FromDegrees(this.orientation === Orientation.CW ? a1 - a3 : a3 - a1);
  76687. }
  76688. return Arc2;
  76689. }());
  76690. /**
  76691. * Represents a 2D path made up of multiple 2D points
  76692. */
  76693. var Path2 = /** @class */ (function () {
  76694. /**
  76695. * Creates a Path2 object from the starting 2D coordinates x and y.
  76696. * @param x the starting points x value
  76697. * @param y the starting points y value
  76698. */
  76699. function Path2(x, y) {
  76700. this._points = new Array();
  76701. this._length = 0.0;
  76702. /**
  76703. * If the path start and end point are the same
  76704. */
  76705. this.closed = false;
  76706. this._points.push(new Vector2(x, y));
  76707. }
  76708. /**
  76709. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  76710. * @param x the added points x value
  76711. * @param y the added points y value
  76712. * @returns the updated Path2.
  76713. */
  76714. Path2.prototype.addLineTo = function (x, y) {
  76715. if (this.closed) {
  76716. return this;
  76717. }
  76718. var newPoint = new Vector2(x, y);
  76719. var previousPoint = this._points[this._points.length - 1];
  76720. this._points.push(newPoint);
  76721. this._length += newPoint.subtract(previousPoint).length();
  76722. return this;
  76723. };
  76724. /**
  76725. * 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.
  76726. * @param midX middle point x value
  76727. * @param midY middle point y value
  76728. * @param endX end point x value
  76729. * @param endY end point y value
  76730. * @param numberOfSegments (default: 36)
  76731. * @returns the updated Path2.
  76732. */
  76733. Path2.prototype.addArcTo = function (midX, midY, endX, endY, numberOfSegments) {
  76734. if (numberOfSegments === void 0) { numberOfSegments = 36; }
  76735. if (this.closed) {
  76736. return this;
  76737. }
  76738. var startPoint = this._points[this._points.length - 1];
  76739. var midPoint = new Vector2(midX, midY);
  76740. var endPoint = new Vector2(endX, endY);
  76741. var arc = new Arc2(startPoint, midPoint, endPoint);
  76742. var increment = arc.angle.radians() / numberOfSegments;
  76743. if (arc.orientation === Orientation.CW) {
  76744. increment *= -1;
  76745. }
  76746. var currentAngle = arc.startAngle.radians() + increment;
  76747. for (var i = 0; i < numberOfSegments; i++) {
  76748. var x = Math.cos(currentAngle) * arc.radius + arc.centerPoint.x;
  76749. var y = Math.sin(currentAngle) * arc.radius + arc.centerPoint.y;
  76750. this.addLineTo(x, y);
  76751. currentAngle += increment;
  76752. }
  76753. return this;
  76754. };
  76755. /**
  76756. * Closes the Path2.
  76757. * @returns the Path2.
  76758. */
  76759. Path2.prototype.close = function () {
  76760. this.closed = true;
  76761. return this;
  76762. };
  76763. /**
  76764. * Gets the sum of the distance between each sequential point in the path
  76765. * @returns the Path2 total length (float).
  76766. */
  76767. Path2.prototype.length = function () {
  76768. var result = this._length;
  76769. if (!this.closed) {
  76770. var lastPoint = this._points[this._points.length - 1];
  76771. var firstPoint = this._points[0];
  76772. result += (firstPoint.subtract(lastPoint).length());
  76773. }
  76774. return result;
  76775. };
  76776. /**
  76777. * Gets the points which construct the path
  76778. * @returns the Path2 internal array of points.
  76779. */
  76780. Path2.prototype.getPoints = function () {
  76781. return this._points;
  76782. };
  76783. /**
  76784. * Retreives the point at the distance aways from the starting point
  76785. * @param normalizedLengthPosition the length along the path to retreive the point from
  76786. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  76787. */
  76788. Path2.prototype.getPointAtLengthPosition = function (normalizedLengthPosition) {
  76789. if (normalizedLengthPosition < 0 || normalizedLengthPosition > 1) {
  76790. return Vector2.Zero();
  76791. }
  76792. var lengthPosition = normalizedLengthPosition * this.length();
  76793. var previousOffset = 0;
  76794. for (var i = 0; i < this._points.length; i++) {
  76795. var j = (i + 1) % this._points.length;
  76796. var a = this._points[i];
  76797. var b = this._points[j];
  76798. var bToA = b.subtract(a);
  76799. var nextOffset = (bToA.length() + previousOffset);
  76800. if (lengthPosition >= previousOffset && lengthPosition <= nextOffset) {
  76801. var dir = bToA.normalize();
  76802. var localOffset = lengthPosition - previousOffset;
  76803. return new Vector2(a.x + (dir.x * localOffset), a.y + (dir.y * localOffset));
  76804. }
  76805. previousOffset = nextOffset;
  76806. }
  76807. return Vector2.Zero();
  76808. };
  76809. /**
  76810. * Creates a new path starting from an x and y position
  76811. * @param x starting x value
  76812. * @param y starting y value
  76813. * @returns a new Path2 starting at the coordinates (x, y).
  76814. */
  76815. Path2.StartingAt = function (x, y) {
  76816. return new Path2(x, y);
  76817. };
  76818. return Path2;
  76819. }());
  76820. /**
  76821. * Represents a 3D path made up of multiple 3D points
  76822. */
  76823. var Path3D = /** @class */ (function () {
  76824. /**
  76825. * new Path3D(path, normal, raw)
  76826. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  76827. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  76828. * @param path an array of Vector3, the curve axis of the Path3D
  76829. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  76830. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  76831. */
  76832. function Path3D(
  76833. /**
  76834. * an array of Vector3, the curve axis of the Path3D
  76835. */
  76836. path, firstNormal, raw) {
  76837. if (firstNormal === void 0) { firstNormal = null; }
  76838. this.path = path;
  76839. this._curve = new Array();
  76840. this._distances = new Array();
  76841. this._tangents = new Array();
  76842. this._normals = new Array();
  76843. this._binormals = new Array();
  76844. for (var p = 0; p < path.length; p++) {
  76845. this._curve[p] = path[p].clone(); // hard copy
  76846. }
  76847. this._raw = raw || false;
  76848. this._compute(firstNormal);
  76849. }
  76850. /**
  76851. * Returns the Path3D array of successive Vector3 designing its curve.
  76852. * @returns the Path3D array of successive Vector3 designing its curve.
  76853. */
  76854. Path3D.prototype.getCurve = function () {
  76855. return this._curve;
  76856. };
  76857. /**
  76858. * Returns an array populated with tangent vectors on each Path3D curve point.
  76859. * @returns an array populated with tangent vectors on each Path3D curve point.
  76860. */
  76861. Path3D.prototype.getTangents = function () {
  76862. return this._tangents;
  76863. };
  76864. /**
  76865. * Returns an array populated with normal vectors on each Path3D curve point.
  76866. * @returns an array populated with normal vectors on each Path3D curve point.
  76867. */
  76868. Path3D.prototype.getNormals = function () {
  76869. return this._normals;
  76870. };
  76871. /**
  76872. * Returns an array populated with binormal vectors on each Path3D curve point.
  76873. * @returns an array populated with binormal vectors on each Path3D curve point.
  76874. */
  76875. Path3D.prototype.getBinormals = function () {
  76876. return this._binormals;
  76877. };
  76878. /**
  76879. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  76880. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  76881. */
  76882. Path3D.prototype.getDistances = function () {
  76883. return this._distances;
  76884. };
  76885. /**
  76886. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  76887. * @param path path which all values are copied into the curves points
  76888. * @param firstNormal which should be projected onto the curve
  76889. * @returns the same object updated.
  76890. */
  76891. Path3D.prototype.update = function (path, firstNormal) {
  76892. if (firstNormal === void 0) { firstNormal = null; }
  76893. for (var p = 0; p < path.length; p++) {
  76894. this._curve[p].x = path[p].x;
  76895. this._curve[p].y = path[p].y;
  76896. this._curve[p].z = path[p].z;
  76897. }
  76898. this._compute(firstNormal);
  76899. return this;
  76900. };
  76901. // private function compute() : computes tangents, normals and binormals
  76902. Path3D.prototype._compute = function (firstNormal) {
  76903. var l = this._curve.length;
  76904. // first and last tangents
  76905. this._tangents[0] = this._getFirstNonNullVector(0);
  76906. if (!this._raw) {
  76907. this._tangents[0].normalize();
  76908. }
  76909. this._tangents[l - 1] = this._curve[l - 1].subtract(this._curve[l - 2]);
  76910. if (!this._raw) {
  76911. this._tangents[l - 1].normalize();
  76912. }
  76913. // normals and binormals at first point : arbitrary vector with _normalVector()
  76914. var tg0 = this._tangents[0];
  76915. var pp0 = this._normalVector(tg0, firstNormal);
  76916. this._normals[0] = pp0;
  76917. if (!this._raw) {
  76918. this._normals[0].normalize();
  76919. }
  76920. this._binormals[0] = Vector3.Cross(tg0, this._normals[0]);
  76921. if (!this._raw) {
  76922. this._binormals[0].normalize();
  76923. }
  76924. this._distances[0] = 0.0;
  76925. // normals and binormals : next points
  76926. var prev; // previous vector (segment)
  76927. var cur; // current vector (segment)
  76928. var curTang; // current tangent
  76929. // previous normal
  76930. var prevBinor; // previous binormal
  76931. for (var i = 1; i < l; i++) {
  76932. // tangents
  76933. prev = this._getLastNonNullVector(i);
  76934. if (i < l - 1) {
  76935. cur = this._getFirstNonNullVector(i);
  76936. this._tangents[i] = prev.add(cur);
  76937. this._tangents[i].normalize();
  76938. }
  76939. this._distances[i] = this._distances[i - 1] + prev.length();
  76940. // normals and binormals
  76941. // http://www.cs.cmu.edu/afs/andrew/scs/cs/15-462/web/old/asst2camera.html
  76942. curTang = this._tangents[i];
  76943. prevBinor = this._binormals[i - 1];
  76944. this._normals[i] = Vector3.Cross(prevBinor, curTang);
  76945. if (!this._raw) {
  76946. this._normals[i].normalize();
  76947. }
  76948. this._binormals[i] = Vector3.Cross(curTang, this._normals[i]);
  76949. if (!this._raw) {
  76950. this._binormals[i].normalize();
  76951. }
  76952. }
  76953. };
  76954. // private function getFirstNonNullVector(index)
  76955. // returns the first non null vector from index : curve[index + N].subtract(curve[index])
  76956. Path3D.prototype._getFirstNonNullVector = function (index) {
  76957. var i = 1;
  76958. var nNVector = this._curve[index + i].subtract(this._curve[index]);
  76959. while (nNVector.length() === 0 && index + i + 1 < this._curve.length) {
  76960. i++;
  76961. nNVector = this._curve[index + i].subtract(this._curve[index]);
  76962. }
  76963. return nNVector;
  76964. };
  76965. // private function getLastNonNullVector(index)
  76966. // returns the last non null vector from index : curve[index].subtract(curve[index - N])
  76967. Path3D.prototype._getLastNonNullVector = function (index) {
  76968. var i = 1;
  76969. var nLVector = this._curve[index].subtract(this._curve[index - i]);
  76970. while (nLVector.length() === 0 && index > i + 1) {
  76971. i++;
  76972. nLVector = this._curve[index].subtract(this._curve[index - i]);
  76973. }
  76974. return nLVector;
  76975. };
  76976. // private function normalVector(v0, vt, va) :
  76977. // returns an arbitrary point in the plane defined by the point v0 and the vector vt orthogonal to this plane
  76978. // if va is passed, it returns the va projection on the plane orthogonal to vt at the point v0
  76979. Path3D.prototype._normalVector = function (vt, va) {
  76980. var normal0;
  76981. var tgl = vt.length();
  76982. if (tgl === 0.0) {
  76983. tgl = 1.0;
  76984. }
  76985. if (va === undefined || va === null) {
  76986. var point;
  76987. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.y) / tgl, 1.0, Epsilon)) { // search for a point in the plane
  76988. point = new Vector3(0.0, -1.0, 0.0);
  76989. }
  76990. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.x) / tgl, 1.0, Epsilon)) {
  76991. point = new Vector3(1.0, 0.0, 0.0);
  76992. }
  76993. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.z) / tgl, 1.0, Epsilon)) {
  76994. point = new Vector3(0.0, 0.0, 1.0);
  76995. }
  76996. else {
  76997. point = Vector3.Zero();
  76998. }
  76999. normal0 = Vector3.Cross(vt, point);
  77000. }
  77001. else {
  77002. normal0 = Vector3.Cross(vt, va);
  77003. Vector3.CrossToRef(normal0, vt, normal0);
  77004. }
  77005. normal0.normalize();
  77006. return normal0;
  77007. };
  77008. return Path3D;
  77009. }());
  77010. /**
  77011. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  77012. * A Curve3 is designed from a series of successive Vector3.
  77013. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  77014. */
  77015. var Curve3 = /** @class */ (function () {
  77016. /**
  77017. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  77018. * A Curve3 is designed from a series of successive Vector3.
  77019. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  77020. * @param points points which make up the curve
  77021. */
  77022. function Curve3(points) {
  77023. this._length = 0.0;
  77024. this._points = points;
  77025. this._length = this._computeLength(points);
  77026. }
  77027. /**
  77028. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  77029. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  77030. * @param v1 (Vector3) the control point
  77031. * @param v2 (Vector3) the end point of the Quadratic Bezier
  77032. * @param nbPoints (integer) the wanted number of points in the curve
  77033. * @returns the created Curve3
  77034. */
  77035. Curve3.CreateQuadraticBezier = function (v0, v1, v2, nbPoints) {
  77036. nbPoints = nbPoints > 2 ? nbPoints : 3;
  77037. var bez = new Array();
  77038. var equation = function (t, val0, val1, val2) {
  77039. var res = (1.0 - t) * (1.0 - t) * val0 + 2.0 * t * (1.0 - t) * val1 + t * t * val2;
  77040. return res;
  77041. };
  77042. for (var i = 0; i <= nbPoints; i++) {
  77043. 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)));
  77044. }
  77045. return new Curve3(bez);
  77046. };
  77047. /**
  77048. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  77049. * @param v0 (Vector3) the origin point of the Cubic Bezier
  77050. * @param v1 (Vector3) the first control point
  77051. * @param v2 (Vector3) the second control point
  77052. * @param v3 (Vector3) the end point of the Cubic Bezier
  77053. * @param nbPoints (integer) the wanted number of points in the curve
  77054. * @returns the created Curve3
  77055. */
  77056. Curve3.CreateCubicBezier = function (v0, v1, v2, v3, nbPoints) {
  77057. nbPoints = nbPoints > 3 ? nbPoints : 4;
  77058. var bez = new Array();
  77059. var equation = function (t, val0, val1, val2, val3) {
  77060. 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;
  77061. return res;
  77062. };
  77063. for (var i = 0; i <= nbPoints; i++) {
  77064. 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)));
  77065. }
  77066. return new Curve3(bez);
  77067. };
  77068. /**
  77069. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  77070. * @param p1 (Vector3) the origin point of the Hermite Spline
  77071. * @param t1 (Vector3) the tangent vector at the origin point
  77072. * @param p2 (Vector3) the end point of the Hermite Spline
  77073. * @param t2 (Vector3) the tangent vector at the end point
  77074. * @param nbPoints (integer) the wanted number of points in the curve
  77075. * @returns the created Curve3
  77076. */
  77077. Curve3.CreateHermiteSpline = function (p1, t1, p2, t2, nbPoints) {
  77078. var hermite = new Array();
  77079. var step = 1.0 / nbPoints;
  77080. for (var i = 0; i <= nbPoints; i++) {
  77081. hermite.push(Vector3.Hermite(p1, t1, p2, t2, i * step));
  77082. }
  77083. return new Curve3(hermite);
  77084. };
  77085. /**
  77086. * Returns a Curve3 object along a CatmullRom Spline curve :
  77087. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  77088. * @param nbPoints (integer) the wanted number of points between each curve control points
  77089. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  77090. * @returns the created Curve3
  77091. */
  77092. Curve3.CreateCatmullRomSpline = function (points, nbPoints, closed) {
  77093. var catmullRom = new Array();
  77094. var step = 1.0 / nbPoints;
  77095. var amount = 0.0;
  77096. if (closed) {
  77097. var pointsCount = points.length;
  77098. for (var i = 0; i < pointsCount; i++) {
  77099. amount = 0;
  77100. for (var c = 0; c < nbPoints; c++) {
  77101. catmullRom.push(Vector3.CatmullRom(points[i % pointsCount], points[(i + 1) % pointsCount], points[(i + 2) % pointsCount], points[(i + 3) % pointsCount], amount));
  77102. amount += step;
  77103. }
  77104. }
  77105. catmullRom.push(catmullRom[0]);
  77106. }
  77107. else {
  77108. var totalPoints = new Array();
  77109. totalPoints.push(points[0].clone());
  77110. Array.prototype.push.apply(totalPoints, points);
  77111. totalPoints.push(points[points.length - 1].clone());
  77112. for (var i = 0; i < totalPoints.length - 3; i++) {
  77113. amount = 0;
  77114. for (var c = 0; c < nbPoints; c++) {
  77115. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  77116. amount += step;
  77117. }
  77118. }
  77119. i--;
  77120. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  77121. }
  77122. return new Curve3(catmullRom);
  77123. };
  77124. /**
  77125. * @returns the Curve3 stored array of successive Vector3
  77126. */
  77127. Curve3.prototype.getPoints = function () {
  77128. return this._points;
  77129. };
  77130. /**
  77131. * @returns the computed length (float) of the curve.
  77132. */
  77133. Curve3.prototype.length = function () {
  77134. return this._length;
  77135. };
  77136. /**
  77137. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  77138. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  77139. * curveA and curveB keep unchanged.
  77140. * @param curve the curve to continue from this curve
  77141. * @returns the newly constructed curve
  77142. */
  77143. Curve3.prototype.continue = function (curve) {
  77144. var lastPoint = this._points[this._points.length - 1];
  77145. var continuedPoints = this._points.slice();
  77146. var curvePoints = curve.getPoints();
  77147. for (var i = 1; i < curvePoints.length; i++) {
  77148. continuedPoints.push(curvePoints[i].subtract(curvePoints[0]).add(lastPoint));
  77149. }
  77150. var continuedCurve = new Curve3(continuedPoints);
  77151. return continuedCurve;
  77152. };
  77153. Curve3.prototype._computeLength = function (path) {
  77154. var l = 0;
  77155. for (var i = 1; i < path.length; i++) {
  77156. l += (path[i].subtract(path[i - 1])).length();
  77157. }
  77158. return l;
  77159. };
  77160. return Curve3;
  77161. }());
  77162. // Vertex formats
  77163. /**
  77164. * Contains position and normal vectors for a vertex
  77165. */
  77166. var PositionNormalVertex = /** @class */ (function () {
  77167. /**
  77168. * Creates a PositionNormalVertex
  77169. * @param position the position of the vertex (defaut: 0,0,0)
  77170. * @param normal the normal of the vertex (defaut: 0,1,0)
  77171. */
  77172. function PositionNormalVertex(
  77173. /** the position of the vertex (defaut: 0,0,0) */
  77174. position,
  77175. /** the normal of the vertex (defaut: 0,1,0) */
  77176. normal) {
  77177. if (position === void 0) { position = Vector3.Zero(); }
  77178. if (normal === void 0) { normal = Vector3.Up(); }
  77179. this.position = position;
  77180. this.normal = normal;
  77181. }
  77182. /**
  77183. * Clones the PositionNormalVertex
  77184. * @returns the cloned PositionNormalVertex
  77185. */
  77186. PositionNormalVertex.prototype.clone = function () {
  77187. return new PositionNormalVertex(this.position.clone(), this.normal.clone());
  77188. };
  77189. return PositionNormalVertex;
  77190. }());
  77191. /**
  77192. * Contains position, normal and uv vectors for a vertex
  77193. */
  77194. var PositionNormalTextureVertex = /** @class */ (function () {
  77195. /**
  77196. * Creates a PositionNormalTextureVertex
  77197. * @param position the position of the vertex (defaut: 0,0,0)
  77198. * @param normal the normal of the vertex (defaut: 0,1,0)
  77199. * @param uv the uv of the vertex (default: 0,0)
  77200. */
  77201. function PositionNormalTextureVertex(
  77202. /** the position of the vertex (defaut: 0,0,0) */
  77203. position,
  77204. /** the normal of the vertex (defaut: 0,1,0) */
  77205. normal,
  77206. /** the uv of the vertex (default: 0,0) */
  77207. uv) {
  77208. if (position === void 0) { position = Vector3.Zero(); }
  77209. if (normal === void 0) { normal = Vector3.Up(); }
  77210. if (uv === void 0) { uv = Vector2.Zero(); }
  77211. this.position = position;
  77212. this.normal = normal;
  77213. this.uv = uv;
  77214. }
  77215. /**
  77216. * Clones the PositionNormalTextureVertex
  77217. * @returns the cloned PositionNormalTextureVertex
  77218. */
  77219. PositionNormalTextureVertex.prototype.clone = function () {
  77220. return new PositionNormalTextureVertex(this.position.clone(), this.normal.clone(), this.uv.clone());
  77221. };
  77222. return PositionNormalTextureVertex;
  77223. }());
  77224. // Temporary pre-allocated objects for engine internal use
  77225. // usage in any internal function :
  77226. // var tmp = Tmp.Vector3[0]; <= gets access to the first pre-created Vector3
  77227. // There's a Tmp array per object type : int, float, Vector2, Vector3, Vector4, Quaternion, Matrix
  77228. /**
  77229. * @hidden
  77230. */
  77231. var Tmp = /** @class */ (function () {
  77232. function Tmp() {
  77233. }
  77234. Tmp.Color3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Color3.Black);
  77235. Tmp.Color4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, function () { return new Color4(0, 0, 0, 0); });
  77236. Tmp.Vector2 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector2.Zero); // 3 temp Vector2 at once should be enough
  77237. Tmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(13, Vector3.Zero); // 13 temp Vector3 at once should be enough
  77238. Tmp.Vector4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector4.Zero); // 3 temp Vector4 at once should be enough
  77239. Tmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Quaternion.Zero); // 2 temp Quaternion at once should be enough
  77240. Tmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, Matrix.Identity); // 8 temp Matrices at once should be enough
  77241. return Tmp;
  77242. }());
  77243. /**
  77244. * @hidden
  77245. * Same as Tmp but not exported to keep it only for math functions to avoid conflicts
  77246. */
  77247. var MathTmp = /** @class */ (function () {
  77248. function MathTmp() {
  77249. }
  77250. MathTmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, Vector3.Zero);
  77251. MathTmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Matrix.Identity);
  77252. MathTmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Quaternion.Zero);
  77253. return MathTmp;
  77254. }());
  77255. /***/ }),
  77256. /***/ "./Maths/sphericalPolynomial.ts":
  77257. /*!**************************************!*\
  77258. !*** ./Maths/sphericalPolynomial.ts ***!
  77259. \**************************************/
  77260. /*! exports provided: SphericalPolynomial, SphericalHarmonics */
  77261. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77262. "use strict";
  77263. __webpack_require__.r(__webpack_exports__);
  77264. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return SphericalPolynomial; });
  77265. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return SphericalHarmonics; });
  77266. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  77267. /**
  77268. * Class representing spherical polynomial coefficients to the 3rd degree
  77269. */
  77270. var SphericalPolynomial = /** @class */ (function () {
  77271. function SphericalPolynomial() {
  77272. /**
  77273. * The x coefficients of the spherical polynomial
  77274. */
  77275. this.x = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77276. /**
  77277. * The y coefficients of the spherical polynomial
  77278. */
  77279. this.y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77280. /**
  77281. * The z coefficients of the spherical polynomial
  77282. */
  77283. this.z = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77284. /**
  77285. * The xx coefficients of the spherical polynomial
  77286. */
  77287. this.xx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77288. /**
  77289. * The yy coefficients of the spherical polynomial
  77290. */
  77291. this.yy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77292. /**
  77293. * The zz coefficients of the spherical polynomial
  77294. */
  77295. this.zz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77296. /**
  77297. * The xy coefficients of the spherical polynomial
  77298. */
  77299. this.xy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77300. /**
  77301. * The yz coefficients of the spherical polynomial
  77302. */
  77303. this.yz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77304. /**
  77305. * The zx coefficients of the spherical polynomial
  77306. */
  77307. this.zx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77308. }
  77309. /**
  77310. * Adds an ambient color to the spherical polynomial
  77311. * @param color the color to add
  77312. */
  77313. SphericalPolynomial.prototype.addAmbient = function (color) {
  77314. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  77315. this.xx = this.xx.add(colorVector);
  77316. this.yy = this.yy.add(colorVector);
  77317. this.zz = this.zz.add(colorVector);
  77318. };
  77319. /**
  77320. * Scales the spherical polynomial by the given amount
  77321. * @param scale the amount to scale
  77322. */
  77323. SphericalPolynomial.prototype.scale = function (scale) {
  77324. this.x = this.x.scale(scale);
  77325. this.y = this.y.scale(scale);
  77326. this.z = this.z.scale(scale);
  77327. this.xx = this.xx.scale(scale);
  77328. this.yy = this.yy.scale(scale);
  77329. this.zz = this.zz.scale(scale);
  77330. this.yz = this.yz.scale(scale);
  77331. this.zx = this.zx.scale(scale);
  77332. this.xy = this.xy.scale(scale);
  77333. };
  77334. /**
  77335. * Gets the spherical polynomial from harmonics
  77336. * @param harmonics the spherical harmonics
  77337. * @returns the spherical polynomial
  77338. */
  77339. SphericalPolynomial.FromHarmonics = function (harmonics) {
  77340. var result = new SphericalPolynomial();
  77341. result.x = harmonics.l11.scale(1.02333);
  77342. result.y = harmonics.l1_1.scale(1.02333);
  77343. result.z = harmonics.l10.scale(1.02333);
  77344. result.xx = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).add(harmonics.lL22.scale(0.429043));
  77345. result.yy = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).subtract(harmonics.lL22.scale(0.429043));
  77346. result.zz = harmonics.l00.scale(0.886277).add(harmonics.l20.scale(0.495417));
  77347. result.yz = harmonics.l2_1.scale(0.858086);
  77348. result.zx = harmonics.l21.scale(0.858086);
  77349. result.xy = harmonics.l2_2.scale(0.858086);
  77350. result.scale(1.0 / Math.PI);
  77351. return result;
  77352. };
  77353. /**
  77354. * Constructs a spherical polynomial from an array.
  77355. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  77356. * @returns the spherical polynomial
  77357. */
  77358. SphericalPolynomial.FromArray = function (data) {
  77359. var sp = new SphericalPolynomial();
  77360. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sp.x);
  77361. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sp.y);
  77362. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sp.z);
  77363. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sp.xx);
  77364. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sp.yy);
  77365. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sp.zz);
  77366. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sp.yz);
  77367. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sp.zx);
  77368. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sp.xy);
  77369. return sp;
  77370. };
  77371. return SphericalPolynomial;
  77372. }());
  77373. /**
  77374. * Class representing spherical harmonics coefficients to the 3rd degree
  77375. */
  77376. var SphericalHarmonics = /** @class */ (function () {
  77377. function SphericalHarmonics() {
  77378. /**
  77379. * The l0,0 coefficients of the spherical harmonics
  77380. */
  77381. this.l00 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77382. /**
  77383. * The l1,-1 coefficients of the spherical harmonics
  77384. */
  77385. this.l1_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77386. /**
  77387. * The l1,0 coefficients of the spherical harmonics
  77388. */
  77389. this.l10 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77390. /**
  77391. * The l1,1 coefficients of the spherical harmonics
  77392. */
  77393. this.l11 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77394. /**
  77395. * The l2,-2 coefficients of the spherical harmonics
  77396. */
  77397. this.l2_2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77398. /**
  77399. * The l2,-1 coefficients of the spherical harmonics
  77400. */
  77401. this.l2_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77402. /**
  77403. * The l2,0 coefficients of the spherical harmonics
  77404. */
  77405. this.l20 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77406. /**
  77407. * The l2,1 coefficients of the spherical harmonics
  77408. */
  77409. this.l21 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77410. /**
  77411. * The l2,2 coefficients of the spherical harmonics
  77412. */
  77413. this.lL22 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77414. }
  77415. /**
  77416. * Adds a light to the spherical harmonics
  77417. * @param direction the direction of the light
  77418. * @param color the color of the light
  77419. * @param deltaSolidAngle the delta solid angle of the light
  77420. */
  77421. SphericalHarmonics.prototype.addLight = function (direction, color, deltaSolidAngle) {
  77422. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  77423. var c = colorVector.scale(deltaSolidAngle);
  77424. this.l00 = this.l00.add(c.scale(0.282095));
  77425. this.l1_1 = this.l1_1.add(c.scale(0.488603 * direction.y));
  77426. this.l10 = this.l10.add(c.scale(0.488603 * direction.z));
  77427. this.l11 = this.l11.add(c.scale(0.488603 * direction.x));
  77428. this.l2_2 = this.l2_2.add(c.scale(1.092548 * direction.x * direction.y));
  77429. this.l2_1 = this.l2_1.add(c.scale(1.092548 * direction.y * direction.z));
  77430. this.l21 = this.l21.add(c.scale(1.092548 * direction.x * direction.z));
  77431. this.l20 = this.l20.add(c.scale(0.315392 * (3.0 * direction.z * direction.z - 1.0)));
  77432. this.lL22 = this.lL22.add(c.scale(0.546274 * (direction.x * direction.x - direction.y * direction.y)));
  77433. };
  77434. /**
  77435. * Scales the spherical harmonics by the given amount
  77436. * @param scale the amount to scale
  77437. */
  77438. SphericalHarmonics.prototype.scale = function (scale) {
  77439. this.l00 = this.l00.scale(scale);
  77440. this.l1_1 = this.l1_1.scale(scale);
  77441. this.l10 = this.l10.scale(scale);
  77442. this.l11 = this.l11.scale(scale);
  77443. this.l2_2 = this.l2_2.scale(scale);
  77444. this.l2_1 = this.l2_1.scale(scale);
  77445. this.l20 = this.l20.scale(scale);
  77446. this.l21 = this.l21.scale(scale);
  77447. this.lL22 = this.lL22.scale(scale);
  77448. };
  77449. /**
  77450. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  77451. *
  77452. * ```
  77453. * E_lm = A_l * L_lm
  77454. * ```
  77455. *
  77456. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  77457. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  77458. * the scaling factors are given in equation 9.
  77459. */
  77460. SphericalHarmonics.prototype.convertIncidentRadianceToIrradiance = function () {
  77461. // Constant (Band 0)
  77462. this.l00 = this.l00.scale(3.141593);
  77463. // Linear (Band 1)
  77464. this.l1_1 = this.l1_1.scale(2.094395);
  77465. this.l10 = this.l10.scale(2.094395);
  77466. this.l11 = this.l11.scale(2.094395);
  77467. // Quadratic (Band 2)
  77468. this.l2_2 = this.l2_2.scale(0.785398);
  77469. this.l2_1 = this.l2_1.scale(0.785398);
  77470. this.l20 = this.l20.scale(0.785398);
  77471. this.l21 = this.l21.scale(0.785398);
  77472. this.lL22 = this.lL22.scale(0.785398);
  77473. };
  77474. /**
  77475. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  77476. *
  77477. * ```
  77478. * L = (1/pi) * E * rho
  77479. * ```
  77480. *
  77481. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  77482. */
  77483. SphericalHarmonics.prototype.convertIrradianceToLambertianRadiance = function () {
  77484. this.scale(1.0 / Math.PI);
  77485. // The resultant SH now represents outgoing radiance, so includes the Lambert 1/pi normalisation factor but without albedo (rho) applied
  77486. // (The pixel shader must apply albedo after texture fetches, etc).
  77487. };
  77488. /**
  77489. * Gets the spherical harmonics from polynomial
  77490. * @param polynomial the spherical polynomial
  77491. * @returns the spherical harmonics
  77492. */
  77493. SphericalHarmonics.FromPolynomial = function (polynomial) {
  77494. var result = new SphericalHarmonics();
  77495. result.l00 = polynomial.xx.scale(0.376127).add(polynomial.yy.scale(0.376127)).add(polynomial.zz.scale(0.376126));
  77496. result.l1_1 = polynomial.y.scale(0.977204);
  77497. result.l10 = polynomial.z.scale(0.977204);
  77498. result.l11 = polynomial.x.scale(0.977204);
  77499. result.l2_2 = polynomial.xy.scale(1.16538);
  77500. result.l2_1 = polynomial.yz.scale(1.16538);
  77501. result.l20 = polynomial.zz.scale(1.34567).subtract(polynomial.xx.scale(0.672834)).subtract(polynomial.yy.scale(0.672834));
  77502. result.l21 = polynomial.zx.scale(1.16538);
  77503. result.lL22 = polynomial.xx.scale(1.16538).subtract(polynomial.yy.scale(1.16538));
  77504. result.scale(Math.PI);
  77505. return result;
  77506. };
  77507. /**
  77508. * Constructs a spherical harmonics from an array.
  77509. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  77510. * @returns the spherical harmonics
  77511. */
  77512. SphericalHarmonics.FromArray = function (data) {
  77513. var sh = new SphericalHarmonics();
  77514. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sh.l00);
  77515. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sh.l1_1);
  77516. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sh.l10);
  77517. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sh.l11);
  77518. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sh.l2_2);
  77519. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sh.l2_1);
  77520. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sh.l20);
  77521. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sh.l21);
  77522. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sh.lL22);
  77523. return sh;
  77524. };
  77525. return SphericalHarmonics;
  77526. }());
  77527. /***/ }),
  77528. /***/ "./Meshes/Builders/boxBuilder.ts":
  77529. /*!***************************************!*\
  77530. !*** ./Meshes/Builders/boxBuilder.ts ***!
  77531. \***************************************/
  77532. /*! exports provided: BoxBuilder */
  77533. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77534. "use strict";
  77535. __webpack_require__.r(__webpack_exports__);
  77536. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return BoxBuilder; });
  77537. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77538. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77539. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77540. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox = function (options) {
  77541. var normalsSource = [
  77542. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1),
  77543. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1),
  77544. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0),
  77545. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0),
  77546. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0),
  77547. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0)
  77548. ];
  77549. var indices = [];
  77550. var positions = [];
  77551. var normals = [];
  77552. var uvs = [];
  77553. var width = options.width || options.size || 1;
  77554. var height = options.height || options.size || 1;
  77555. var depth = options.depth || options.size || 1;
  77556. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  77557. var faceUV = options.faceUV || new Array(6);
  77558. var faceColors = options.faceColors;
  77559. var colors = [];
  77560. // default face colors and UV if undefined
  77561. for (var f = 0; f < 6; f++) {
  77562. if (faceUV[f] === undefined) {
  77563. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  77564. }
  77565. if (faceColors && faceColors[f] === undefined) {
  77566. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  77567. }
  77568. }
  77569. var scaleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](width / 2, height / 2, depth / 2);
  77570. // Create each face in turn.
  77571. for (var index = 0; index < normalsSource.length; index++) {
  77572. var normal = normalsSource[index];
  77573. // Get two vectors perpendicular to the face normal and to each other.
  77574. var side1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normal.y, normal.z, normal.x);
  77575. var side2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(normal, side1);
  77576. // Six indices (two triangles) per face.
  77577. var verticesLength = positions.length / 3;
  77578. indices.push(verticesLength);
  77579. indices.push(verticesLength + 1);
  77580. indices.push(verticesLength + 2);
  77581. indices.push(verticesLength);
  77582. indices.push(verticesLength + 2);
  77583. indices.push(verticesLength + 3);
  77584. // Four vertices per face.
  77585. var vertex = normal.subtract(side1).subtract(side2).multiply(scaleVector);
  77586. positions.push(vertex.x, vertex.y, vertex.z);
  77587. normals.push(normal.x, normal.y, normal.z);
  77588. uvs.push(faceUV[index].z, faceUV[index].w);
  77589. if (faceColors) {
  77590. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  77591. }
  77592. vertex = normal.subtract(side1).add(side2).multiply(scaleVector);
  77593. positions.push(vertex.x, vertex.y, vertex.z);
  77594. normals.push(normal.x, normal.y, normal.z);
  77595. uvs.push(faceUV[index].x, faceUV[index].w);
  77596. if (faceColors) {
  77597. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  77598. }
  77599. vertex = normal.add(side1).add(side2).multiply(scaleVector);
  77600. positions.push(vertex.x, vertex.y, vertex.z);
  77601. normals.push(normal.x, normal.y, normal.z);
  77602. uvs.push(faceUV[index].x, faceUV[index].y);
  77603. if (faceColors) {
  77604. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  77605. }
  77606. vertex = normal.add(side1).subtract(side2).multiply(scaleVector);
  77607. positions.push(vertex.x, vertex.y, vertex.z);
  77608. normals.push(normal.x, normal.y, normal.z);
  77609. uvs.push(faceUV[index].z, faceUV[index].y);
  77610. if (faceColors) {
  77611. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  77612. }
  77613. }
  77614. // sides
  77615. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77616. // Result
  77617. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77618. vertexData.indices = indices;
  77619. vertexData.positions = positions;
  77620. vertexData.normals = normals;
  77621. vertexData.uvs = uvs;
  77622. if (faceColors) {
  77623. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  77624. vertexData.colors = totalColors;
  77625. }
  77626. return vertexData;
  77627. };
  77628. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateBox = function (name, size, scene, updatable, sideOrientation) {
  77629. if (scene === void 0) { scene = null; }
  77630. var options = {
  77631. size: size,
  77632. sideOrientation: sideOrientation,
  77633. updatable: updatable
  77634. };
  77635. return BoxBuilder.CreateBox(name, options, scene);
  77636. };
  77637. /**
  77638. * Class containing static functions to help procedurally build meshes
  77639. */
  77640. var BoxBuilder = /** @class */ (function () {
  77641. function BoxBuilder() {
  77642. }
  77643. /**
  77644. * Creates a box mesh
  77645. * * The parameter `size` sets the size (float) of each box side (default 1)
  77646. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  77647. * * 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)
  77648. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  77649. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77650. * * 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
  77651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77652. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  77653. * @param name defines the name of the mesh
  77654. * @param options defines the options used to create the mesh
  77655. * @param scene defines the hosting scene
  77656. * @returns the box mesh
  77657. */
  77658. BoxBuilder.CreateBox = function (name, options, scene) {
  77659. if (scene === void 0) { scene = null; }
  77660. var box = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77661. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77662. box._originalBuilderSideOrientation = options.sideOrientation;
  77663. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox(options);
  77664. vertexData.applyToMesh(box, options.updatable);
  77665. return box;
  77666. };
  77667. return BoxBuilder;
  77668. }());
  77669. /***/ }),
  77670. /***/ "./Meshes/Builders/cylinderBuilder.ts":
  77671. /*!********************************************!*\
  77672. !*** ./Meshes/Builders/cylinderBuilder.ts ***!
  77673. \********************************************/
  77674. /*! exports provided: CylinderBuilder */
  77675. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77676. "use strict";
  77677. __webpack_require__.r(__webpack_exports__);
  77678. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return CylinderBuilder; });
  77679. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77680. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77681. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77682. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  77683. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder = function (options) {
  77684. var height = options.height || 2;
  77685. var diameterTop = (options.diameterTop === 0) ? 0 : options.diameterTop || options.diameter || 1;
  77686. var diameterBottom = (options.diameterBottom === 0) ? 0 : options.diameterBottom || options.diameter || 1;
  77687. var tessellation = options.tessellation || 24;
  77688. var subdivisions = options.subdivisions || 1;
  77689. var hasRings = options.hasRings ? true : false;
  77690. var enclose = options.enclose ? true : false;
  77691. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  77692. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  77693. var faceUV = options.faceUV || new Array(3);
  77694. var faceColors = options.faceColors;
  77695. // default face colors and UV if undefined
  77696. var quadNb = (arc !== 1 && enclose) ? 2 : 0;
  77697. var ringNb = (hasRings) ? subdivisions : 1;
  77698. var surfaceNb = 2 + (1 + quadNb) * ringNb;
  77699. var f;
  77700. for (f = 0; f < surfaceNb; f++) {
  77701. if (faceColors && faceColors[f] === undefined) {
  77702. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  77703. }
  77704. }
  77705. for (f = 0; f < surfaceNb; f++) {
  77706. if (faceUV && faceUV[f] === undefined) {
  77707. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  77708. }
  77709. }
  77710. var indices = new Array();
  77711. var positions = new Array();
  77712. var normals = new Array();
  77713. var uvs = new Array();
  77714. var colors = new Array();
  77715. var angle_step = Math.PI * 2 * arc / tessellation;
  77716. var angle;
  77717. var h;
  77718. var radius;
  77719. var tan = (diameterBottom - diameterTop) / 2 / height;
  77720. var ringVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77721. var ringNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77722. var ringFirstVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77723. var ringFirstNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77724. var quadNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77725. var Y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Y;
  77726. // positions, normals, uvs
  77727. var i;
  77728. var j;
  77729. var r;
  77730. var ringIdx = 1;
  77731. var s = 1; // surface index
  77732. var cs = 0;
  77733. var v = 0;
  77734. for (i = 0; i <= subdivisions; i++) {
  77735. h = i / subdivisions;
  77736. radius = (h * (diameterTop - diameterBottom) + diameterBottom) / 2;
  77737. ringIdx = (hasRings && i !== 0 && i !== subdivisions) ? 2 : 1;
  77738. for (r = 0; r < ringIdx; r++) {
  77739. if (hasRings) {
  77740. s += r;
  77741. }
  77742. if (enclose) {
  77743. s += 2 * r;
  77744. }
  77745. for (j = 0; j <= tessellation; j++) {
  77746. angle = j * angle_step;
  77747. // position
  77748. ringVertex.x = Math.cos(-angle) * radius;
  77749. ringVertex.y = -height / 2 + h * height;
  77750. ringVertex.z = Math.sin(-angle) * radius;
  77751. // normal
  77752. if (diameterTop === 0 && i === subdivisions) {
  77753. // if no top cap, reuse former normals
  77754. ringNormal.x = normals[normals.length - (tessellation + 1) * 3];
  77755. ringNormal.y = normals[normals.length - (tessellation + 1) * 3 + 1];
  77756. ringNormal.z = normals[normals.length - (tessellation + 1) * 3 + 2];
  77757. }
  77758. else {
  77759. ringNormal.x = ringVertex.x;
  77760. ringNormal.z = ringVertex.z;
  77761. ringNormal.y = Math.sqrt(ringNormal.x * ringNormal.x + ringNormal.z * ringNormal.z) * tan;
  77762. ringNormal.normalize();
  77763. }
  77764. // keep first ring vertex values for enclose
  77765. if (j === 0) {
  77766. ringFirstVertex.copyFrom(ringVertex);
  77767. ringFirstNormal.copyFrom(ringNormal);
  77768. }
  77769. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  77770. normals.push(ringNormal.x, ringNormal.y, ringNormal.z);
  77771. if (hasRings) {
  77772. v = (cs !== s) ? faceUV[s].y : faceUV[s].w;
  77773. }
  77774. else {
  77775. v = faceUV[s].y + (faceUV[s].w - faceUV[s].y) * h;
  77776. }
  77777. uvs.push(faceUV[s].x + (faceUV[s].z - faceUV[s].x) * j / tessellation, v);
  77778. if (faceColors) {
  77779. colors.push(faceColors[s].r, faceColors[s].g, faceColors[s].b, faceColors[s].a);
  77780. }
  77781. }
  77782. // if enclose, add four vertices and their dedicated normals
  77783. if (arc !== 1 && enclose) {
  77784. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  77785. positions.push(0, ringVertex.y, 0);
  77786. positions.push(0, ringVertex.y, 0);
  77787. positions.push(ringFirstVertex.x, ringFirstVertex.y, ringFirstVertex.z);
  77788. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(Y, ringNormal, quadNormal);
  77789. quadNormal.normalize();
  77790. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  77791. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(ringFirstNormal, Y, quadNormal);
  77792. quadNormal.normalize();
  77793. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  77794. if (hasRings) {
  77795. v = (cs !== s) ? faceUV[s + 1].y : faceUV[s + 1].w;
  77796. }
  77797. else {
  77798. v = faceUV[s + 1].y + (faceUV[s + 1].w - faceUV[s + 1].y) * h;
  77799. }
  77800. uvs.push(faceUV[s + 1].x, v);
  77801. uvs.push(faceUV[s + 1].z, v);
  77802. if (hasRings) {
  77803. v = (cs !== s) ? faceUV[s + 2].y : faceUV[s + 2].w;
  77804. }
  77805. else {
  77806. v = faceUV[s + 2].y + (faceUV[s + 2].w - faceUV[s + 2].y) * h;
  77807. }
  77808. uvs.push(faceUV[s + 2].x, v);
  77809. uvs.push(faceUV[s + 2].z, v);
  77810. if (faceColors) {
  77811. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  77812. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  77813. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  77814. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  77815. }
  77816. }
  77817. if (cs !== s) {
  77818. cs = s;
  77819. }
  77820. }
  77821. }
  77822. // indices
  77823. var e = (arc !== 1 && enclose) ? tessellation + 4 : tessellation; // correction of number of iteration if enclose
  77824. var s;
  77825. i = 0;
  77826. for (s = 0; s < subdivisions; s++) {
  77827. var i0 = 0;
  77828. var i1 = 0;
  77829. var i2 = 0;
  77830. var i3 = 0;
  77831. for (j = 0; j < tessellation; j++) {
  77832. i0 = i * (e + 1) + j;
  77833. i1 = (i + 1) * (e + 1) + j;
  77834. i2 = i * (e + 1) + (j + 1);
  77835. i3 = (i + 1) * (e + 1) + (j + 1);
  77836. indices.push(i0, i1, i2);
  77837. indices.push(i3, i2, i1);
  77838. }
  77839. if (arc !== 1 && enclose) { // if enclose, add two quads
  77840. indices.push(i0 + 2, i1 + 2, i2 + 2);
  77841. indices.push(i3 + 2, i2 + 2, i1 + 2);
  77842. indices.push(i0 + 4, i1 + 4, i2 + 4);
  77843. indices.push(i3 + 4, i2 + 4, i1 + 4);
  77844. }
  77845. i = (hasRings) ? (i + 2) : (i + 1);
  77846. }
  77847. // Caps
  77848. var createCylinderCap = function (isTop) {
  77849. var radius = isTop ? diameterTop / 2 : diameterBottom / 2;
  77850. if (radius === 0) {
  77851. return;
  77852. }
  77853. // Cap positions, normals & uvs
  77854. var angle;
  77855. var circleVector;
  77856. var i;
  77857. var u = (isTop) ? faceUV[surfaceNb - 1] : faceUV[0];
  77858. var c = null;
  77859. if (faceColors) {
  77860. c = (isTop) ? faceColors[surfaceNb - 1] : faceColors[0];
  77861. }
  77862. // cap center
  77863. var vbase = positions.length / 3;
  77864. var offset = isTop ? height / 2 : -height / 2;
  77865. var center = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, offset, 0);
  77866. positions.push(center.x, center.y, center.z);
  77867. normals.push(0, isTop ? 1 : -1, 0);
  77868. uvs.push(u.x + (u.z - u.x) * 0.5, u.y + (u.w - u.y) * 0.5);
  77869. if (c) {
  77870. colors.push(c.r, c.g, c.b, c.a);
  77871. }
  77872. var textureScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0.5, 0.5);
  77873. for (i = 0; i <= tessellation; i++) {
  77874. angle = Math.PI * 2 * i * arc / tessellation;
  77875. var cos = Math.cos(-angle);
  77876. var sin = Math.sin(-angle);
  77877. circleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](cos * radius, offset, sin * radius);
  77878. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](cos * textureScale.x + 0.5, sin * textureScale.y + 0.5);
  77879. positions.push(circleVector.x, circleVector.y, circleVector.z);
  77880. normals.push(0, isTop ? 1 : -1, 0);
  77881. uvs.push(u.x + (u.z - u.x) * textureCoordinate.x, u.y + (u.w - u.y) * textureCoordinate.y);
  77882. if (c) {
  77883. colors.push(c.r, c.g, c.b, c.a);
  77884. }
  77885. }
  77886. // Cap indices
  77887. for (i = 0; i < tessellation; i++) {
  77888. if (!isTop) {
  77889. indices.push(vbase);
  77890. indices.push(vbase + (i + 1));
  77891. indices.push(vbase + (i + 2));
  77892. }
  77893. else {
  77894. indices.push(vbase);
  77895. indices.push(vbase + (i + 2));
  77896. indices.push(vbase + (i + 1));
  77897. }
  77898. }
  77899. };
  77900. // add caps to geometry
  77901. createCylinderCap(false);
  77902. createCylinderCap(true);
  77903. // Sides
  77904. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77905. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77906. vertexData.indices = indices;
  77907. vertexData.positions = positions;
  77908. vertexData.normals = normals;
  77909. vertexData.uvs = uvs;
  77910. if (faceColors) {
  77911. vertexData.colors = colors;
  77912. }
  77913. return vertexData;
  77914. };
  77915. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  77916. if (scene === undefined || !(scene instanceof _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"])) {
  77917. if (scene !== undefined) {
  77918. sideOrientation = updatable || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DEFAULTSIDE;
  77919. updatable = scene;
  77920. }
  77921. scene = subdivisions;
  77922. subdivisions = 1;
  77923. }
  77924. var options = {
  77925. height: height,
  77926. diameterTop: diameterTop,
  77927. diameterBottom: diameterBottom,
  77928. tessellation: tessellation,
  77929. subdivisions: subdivisions,
  77930. sideOrientation: sideOrientation,
  77931. updatable: updatable
  77932. };
  77933. return CylinderBuilder.CreateCylinder(name, options, scene);
  77934. };
  77935. /**
  77936. * Class containing static functions to help procedurally build meshes
  77937. */
  77938. var CylinderBuilder = /** @class */ (function () {
  77939. function CylinderBuilder() {
  77940. }
  77941. /**
  77942. * Creates a cylinder or a cone mesh
  77943. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  77944. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  77945. * * 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.
  77946. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  77947. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  77948. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  77949. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  77950. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  77951. * * 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).
  77952. * * 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
  77953. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  77954. * * 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
  77955. * * 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.
  77956. * * If `enclose` is false, a ring surface is one element.
  77957. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  77958. * * 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
  77959. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77960. * * 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
  77961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77962. * @param name defines the name of the mesh
  77963. * @param options defines the options used to create the mesh
  77964. * @param scene defines the hosting scene
  77965. * @returns the cylinder mesh
  77966. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  77967. */
  77968. CylinderBuilder.CreateCylinder = function (name, options, scene) {
  77969. var cylinder = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77970. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77971. cylinder._originalBuilderSideOrientation = options.sideOrientation;
  77972. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder(options);
  77973. vertexData.applyToMesh(cylinder, options.updatable);
  77974. return cylinder;
  77975. };
  77976. return CylinderBuilder;
  77977. }());
  77978. /***/ }),
  77979. /***/ "./Meshes/Builders/decalBuilder.ts":
  77980. /*!*****************************************!*\
  77981. !*** ./Meshes/Builders/decalBuilder.ts ***!
  77982. \*****************************************/
  77983. /*! exports provided: DecalBuilder */
  77984. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77985. "use strict";
  77986. __webpack_require__.r(__webpack_exports__);
  77987. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return DecalBuilder; });
  77988. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77989. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77990. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  77991. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77992. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  77993. var options = {
  77994. position: position,
  77995. normal: normal,
  77996. size: size,
  77997. angle: angle
  77998. };
  77999. return DecalBuilder.CreateDecal(name, sourceMesh, options);
  78000. };
  78001. /**
  78002. * Class containing static functions to help procedurally build meshes
  78003. */
  78004. var DecalBuilder = /** @class */ (function () {
  78005. function DecalBuilder() {
  78006. }
  78007. /**
  78008. * Creates a decal mesh.
  78009. * 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
  78010. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  78011. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  78012. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  78013. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  78014. * @param name defines the name of the mesh
  78015. * @param sourceMesh defines the mesh where the decal must be applied
  78016. * @param options defines the options used to create the mesh
  78017. * @param scene defines the hosting scene
  78018. * @returns the decal mesh
  78019. * @see https://doc.babylonjs.com/how_to/decals
  78020. */
  78021. DecalBuilder.CreateDecal = function (name, sourceMesh, options) {
  78022. var indices = sourceMesh.getIndices();
  78023. var positions = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  78024. var normals = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  78025. var position = options.position || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78026. var normal = options.normal || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up();
  78027. var size = options.size || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  78028. var angle = options.angle || 0;
  78029. // Getting correct rotation
  78030. if (!normal) {
  78031. var target = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1);
  78032. var camera = sourceMesh.getScene().activeCamera;
  78033. var cameraWorldTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(target, camera.getWorldMatrix());
  78034. normal = camera.globalPosition.subtract(cameraWorldTarget);
  78035. }
  78036. var yaw = -Math.atan2(normal.z, normal.x) - Math.PI / 2;
  78037. var len = Math.sqrt(normal.x * normal.x + normal.z * normal.z);
  78038. var pitch = Math.atan2(normal.y, len);
  78039. // Matrix
  78040. 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));
  78041. var inverseDecalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Invert(decalWorldMatrix);
  78042. var meshWorldMatrix = sourceMesh.getWorldMatrix();
  78043. var transformMatrix = meshWorldMatrix.multiply(inverseDecalWorldMatrix);
  78044. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  78045. vertexData.indices = [];
  78046. vertexData.positions = [];
  78047. vertexData.normals = [];
  78048. vertexData.uvs = [];
  78049. var currentVertexDataIndex = 0;
  78050. var extractDecalVector3 = function (indexId) {
  78051. var result = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]();
  78052. if (!indices || !positions || !normals) {
  78053. return result;
  78054. }
  78055. var vertexId = indices[indexId];
  78056. result.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](positions[vertexId * 3], positions[vertexId * 3 + 1], positions[vertexId * 3 + 2]);
  78057. // Send vector to decal local world
  78058. result.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(result.position, transformMatrix);
  78059. // Get normal
  78060. result.normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normals[vertexId * 3], normals[vertexId * 3 + 1], normals[vertexId * 3 + 2]);
  78061. result.normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result.normal, transformMatrix);
  78062. return result;
  78063. }; // Inspired by https://github.com/mrdoob/three.js/blob/eee231960882f6f3b6113405f524956145148146/examples/js/geometries/DecalGeometry.js
  78064. var clip = function (vertices, axis) {
  78065. if (vertices.length === 0) {
  78066. return vertices;
  78067. }
  78068. var clipSize = 0.5 * Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(size, axis));
  78069. var clipVertices = function (v0, v1) {
  78070. var clipFactor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetClipFactor(v0.position, v1.position, axis, clipSize);
  78071. 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));
  78072. };
  78073. var result = new Array();
  78074. for (var index = 0; index < vertices.length; index += 3) {
  78075. var v1Out;
  78076. var v2Out;
  78077. var v3Out;
  78078. var total = 0;
  78079. var nV1 = null;
  78080. var nV2 = null;
  78081. var nV3 = null;
  78082. var nV4 = null;
  78083. var d1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index].position, axis) - clipSize;
  78084. var d2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 1].position, axis) - clipSize;
  78085. var d3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 2].position, axis) - clipSize;
  78086. v1Out = d1 > 0;
  78087. v2Out = d2 > 0;
  78088. v3Out = d3 > 0;
  78089. total = (v1Out ? 1 : 0) + (v2Out ? 1 : 0) + (v3Out ? 1 : 0);
  78090. switch (total) {
  78091. case 0:
  78092. result.push(vertices[index]);
  78093. result.push(vertices[index + 1]);
  78094. result.push(vertices[index + 2]);
  78095. break;
  78096. case 1:
  78097. if (v1Out) {
  78098. nV1 = vertices[index + 1];
  78099. nV2 = vertices[index + 2];
  78100. nV3 = clipVertices(vertices[index], nV1);
  78101. nV4 = clipVertices(vertices[index], nV2);
  78102. }
  78103. if (v2Out) {
  78104. nV1 = vertices[index];
  78105. nV2 = vertices[index + 2];
  78106. nV3 = clipVertices(vertices[index + 1], nV1);
  78107. nV4 = clipVertices(vertices[index + 1], nV2);
  78108. result.push(nV3);
  78109. result.push(nV2.clone());
  78110. result.push(nV1.clone());
  78111. result.push(nV2.clone());
  78112. result.push(nV3.clone());
  78113. result.push(nV4);
  78114. break;
  78115. }
  78116. if (v3Out) {
  78117. nV1 = vertices[index];
  78118. nV2 = vertices[index + 1];
  78119. nV3 = clipVertices(vertices[index + 2], nV1);
  78120. nV4 = clipVertices(vertices[index + 2], nV2);
  78121. }
  78122. if (nV1 && nV2 && nV3 && nV4) {
  78123. result.push(nV1.clone());
  78124. result.push(nV2.clone());
  78125. result.push(nV3);
  78126. result.push(nV4);
  78127. result.push(nV3.clone());
  78128. result.push(nV2.clone());
  78129. }
  78130. break;
  78131. case 2:
  78132. if (!v1Out) {
  78133. nV1 = vertices[index].clone();
  78134. nV2 = clipVertices(nV1, vertices[index + 1]);
  78135. nV3 = clipVertices(nV1, vertices[index + 2]);
  78136. result.push(nV1);
  78137. result.push(nV2);
  78138. result.push(nV3);
  78139. }
  78140. if (!v2Out) {
  78141. nV1 = vertices[index + 1].clone();
  78142. nV2 = clipVertices(nV1, vertices[index + 2]);
  78143. nV3 = clipVertices(nV1, vertices[index]);
  78144. result.push(nV1);
  78145. result.push(nV2);
  78146. result.push(nV3);
  78147. }
  78148. if (!v3Out) {
  78149. nV1 = vertices[index + 2].clone();
  78150. nV2 = clipVertices(nV1, vertices[index]);
  78151. nV3 = clipVertices(nV1, vertices[index + 1]);
  78152. result.push(nV1);
  78153. result.push(nV2);
  78154. result.push(nV3);
  78155. }
  78156. break;
  78157. case 3:
  78158. break;
  78159. }
  78160. }
  78161. return result;
  78162. };
  78163. for (var index = 0; index < indices.length; index += 3) {
  78164. var faceVertices = new Array();
  78165. faceVertices.push(extractDecalVector3(index));
  78166. faceVertices.push(extractDecalVector3(index + 1));
  78167. faceVertices.push(extractDecalVector3(index + 2));
  78168. // Clip
  78169. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0));
  78170. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0));
  78171. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0));
  78172. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0));
  78173. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1));
  78174. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1));
  78175. if (faceVertices.length === 0) {
  78176. continue;
  78177. }
  78178. // Add UVs and get back to world
  78179. for (var vIndex = 0; vIndex < faceVertices.length; vIndex++) {
  78180. var vertex = faceVertices[vIndex];
  78181. //TODO check for Int32Array | Uint32Array | Uint16Array
  78182. vertexData.indices.push(currentVertexDataIndex);
  78183. vertex.position.toArray(vertexData.positions, currentVertexDataIndex * 3);
  78184. vertex.normal.toArray(vertexData.normals, currentVertexDataIndex * 3);
  78185. vertexData.uvs.push(0.5 + vertex.position.x / size.x);
  78186. vertexData.uvs.push(0.5 + vertex.position.y / size.y);
  78187. currentVertexDataIndex++;
  78188. }
  78189. }
  78190. // Return mesh
  78191. var decal = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, sourceMesh.getScene());
  78192. vertexData.applyToMesh(decal);
  78193. decal.position = position.clone();
  78194. decal.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pitch, yaw, angle);
  78195. return decal;
  78196. };
  78197. return DecalBuilder;
  78198. }());
  78199. /***/ }),
  78200. /***/ "./Meshes/Builders/discBuilder.ts":
  78201. /*!****************************************!*\
  78202. !*** ./Meshes/Builders/discBuilder.ts ***!
  78203. \****************************************/
  78204. /*! exports provided: DiscBuilder */
  78205. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78206. "use strict";
  78207. __webpack_require__.r(__webpack_exports__);
  78208. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return DiscBuilder; });
  78209. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78210. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78211. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc = function (options) {
  78212. var positions = new Array();
  78213. var indices = new Array();
  78214. var normals = new Array();
  78215. var uvs = new Array();
  78216. var radius = options.radius || 0.5;
  78217. var tessellation = options.tessellation || 64;
  78218. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  78219. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  78220. // positions and uvs
  78221. positions.push(0, 0, 0); // disc center first
  78222. uvs.push(0.5, 0.5);
  78223. var theta = Math.PI * 2 * arc;
  78224. var step = theta / tessellation;
  78225. for (var a = 0; a < theta; a += step) {
  78226. var x = Math.cos(a);
  78227. var y = Math.sin(a);
  78228. var u = (x + 1) / 2;
  78229. var v = (1 - y) / 2;
  78230. positions.push(radius * x, radius * y, 0);
  78231. uvs.push(u, v);
  78232. }
  78233. if (arc === 1) {
  78234. positions.push(positions[3], positions[4], positions[5]); // close the circle
  78235. uvs.push(uvs[2], uvs[3]);
  78236. }
  78237. //indices
  78238. var vertexNb = positions.length / 3;
  78239. for (var i = 1; i < vertexNb - 1; i++) {
  78240. indices.push(i + 1, 0, i);
  78241. }
  78242. // result
  78243. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ComputeNormals(positions, indices, normals);
  78244. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  78245. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  78246. vertexData.indices = indices;
  78247. vertexData.positions = positions;
  78248. vertexData.normals = normals;
  78249. vertexData.uvs = uvs;
  78250. return vertexData;
  78251. };
  78252. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  78253. if (scene === void 0) { scene = null; }
  78254. var options = {
  78255. radius: radius,
  78256. tessellation: tessellation,
  78257. sideOrientation: sideOrientation,
  78258. updatable: updatable
  78259. };
  78260. return DiscBuilder.CreateDisc(name, options, scene);
  78261. };
  78262. /**
  78263. * Class containing static functions to help procedurally build meshes
  78264. */
  78265. var DiscBuilder = /** @class */ (function () {
  78266. function DiscBuilder() {
  78267. }
  78268. /**
  78269. * Creates a plane polygonal mesh. By default, this is a disc
  78270. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  78271. * * 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
  78272. * * 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
  78273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78274. * * 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
  78275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78276. * @param name defines the name of the mesh
  78277. * @param options defines the options used to create the mesh
  78278. * @param scene defines the hosting scene
  78279. * @returns the plane polygonal mesh
  78280. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  78281. */
  78282. DiscBuilder.CreateDisc = function (name, options, scene) {
  78283. if (scene === void 0) { scene = null; }
  78284. var disc = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  78285. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78286. disc._originalBuilderSideOrientation = options.sideOrientation;
  78287. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc(options);
  78288. vertexData.applyToMesh(disc, options.updatable);
  78289. return disc;
  78290. };
  78291. return DiscBuilder;
  78292. }());
  78293. /***/ }),
  78294. /***/ "./Meshes/Builders/groundBuilder.ts":
  78295. /*!******************************************!*\
  78296. !*** ./Meshes/Builders/groundBuilder.ts ***!
  78297. \******************************************/
  78298. /*! exports provided: GroundBuilder */
  78299. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78300. "use strict";
  78301. __webpack_require__.r(__webpack_exports__);
  78302. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return GroundBuilder; });
  78303. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78304. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78305. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78306. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../groundMesh */ "./Meshes/groundMesh.ts");
  78307. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  78308. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround = function (options) {
  78309. var indices = [];
  78310. var positions = [];
  78311. var normals = [];
  78312. var uvs = [];
  78313. var row, col;
  78314. var width = options.width || 1;
  78315. var height = options.height || 1;
  78316. var subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  78317. var subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  78318. for (row = 0; row <= subdivisionsY; row++) {
  78319. for (col = 0; col <= subdivisionsX; col++) {
  78320. var position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]((col * width) / subdivisionsX - (width / 2.0), 0, ((subdivisionsY - row) * height) / subdivisionsY - (height / 2.0));
  78321. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  78322. positions.push(position.x, position.y, position.z);
  78323. normals.push(normal.x, normal.y, normal.z);
  78324. uvs.push(col / subdivisionsX, 1.0 - row / subdivisionsY);
  78325. }
  78326. }
  78327. for (row = 0; row < subdivisionsY; row++) {
  78328. for (col = 0; col < subdivisionsX; col++) {
  78329. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  78330. indices.push(col + 1 + row * (subdivisionsX + 1));
  78331. indices.push(col + row * (subdivisionsX + 1));
  78332. indices.push(col + (row + 1) * (subdivisionsX + 1));
  78333. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  78334. indices.push(col + row * (subdivisionsX + 1));
  78335. }
  78336. }
  78337. // Result
  78338. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78339. vertexData.indices = indices;
  78340. vertexData.positions = positions;
  78341. vertexData.normals = normals;
  78342. vertexData.uvs = uvs;
  78343. return vertexData;
  78344. };
  78345. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround = function (options) {
  78346. var xmin = (options.xmin !== undefined && options.xmin !== null) ? options.xmin : -1.0;
  78347. var zmin = (options.zmin !== undefined && options.zmin !== null) ? options.zmin : -1.0;
  78348. var xmax = (options.xmax !== undefined && options.xmax !== null) ? options.xmax : 1.0;
  78349. var zmax = (options.zmax !== undefined && options.zmax !== null) ? options.zmax : 1.0;
  78350. var subdivisions = options.subdivisions || { w: 1, h: 1 };
  78351. var precision = options.precision || { w: 1, h: 1 };
  78352. var indices = new Array();
  78353. var positions = new Array();
  78354. var normals = new Array();
  78355. var uvs = new Array();
  78356. var row, col, tileRow, tileCol;
  78357. subdivisions.h = (subdivisions.h < 1) ? 1 : subdivisions.h;
  78358. subdivisions.w = (subdivisions.w < 1) ? 1 : subdivisions.w;
  78359. precision.w = (precision.w < 1) ? 1 : precision.w;
  78360. precision.h = (precision.h < 1) ? 1 : precision.h;
  78361. var tileSize = {
  78362. 'w': (xmax - xmin) / subdivisions.w,
  78363. 'h': (zmax - zmin) / subdivisions.h
  78364. };
  78365. function applyTile(xTileMin, zTileMin, xTileMax, zTileMax) {
  78366. // Indices
  78367. var base = positions.length / 3;
  78368. var rowLength = precision.w + 1;
  78369. for (row = 0; row < precision.h; row++) {
  78370. for (col = 0; col < precision.w; col++) {
  78371. var square = [
  78372. base + col + row * rowLength,
  78373. base + (col + 1) + row * rowLength,
  78374. base + (col + 1) + (row + 1) * rowLength,
  78375. base + col + (row + 1) * rowLength
  78376. ];
  78377. indices.push(square[1]);
  78378. indices.push(square[2]);
  78379. indices.push(square[3]);
  78380. indices.push(square[0]);
  78381. indices.push(square[1]);
  78382. indices.push(square[3]);
  78383. }
  78384. }
  78385. // Position, normals and uvs
  78386. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78387. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  78388. for (row = 0; row <= precision.h; row++) {
  78389. position.z = (row * (zTileMax - zTileMin)) / precision.h + zTileMin;
  78390. for (col = 0; col <= precision.w; col++) {
  78391. position.x = (col * (xTileMax - xTileMin)) / precision.w + xTileMin;
  78392. position.y = 0;
  78393. positions.push(position.x, position.y, position.z);
  78394. normals.push(normal.x, normal.y, normal.z);
  78395. uvs.push(col / precision.w, row / precision.h);
  78396. }
  78397. }
  78398. }
  78399. for (tileRow = 0; tileRow < subdivisions.h; tileRow++) {
  78400. for (tileCol = 0; tileCol < subdivisions.w; tileCol++) {
  78401. applyTile(xmin + tileCol * tileSize.w, zmin + tileRow * tileSize.h, xmin + (tileCol + 1) * tileSize.w, zmin + (tileRow + 1) * tileSize.h);
  78402. }
  78403. }
  78404. // Result
  78405. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78406. vertexData.indices = indices;
  78407. vertexData.positions = positions;
  78408. vertexData.normals = normals;
  78409. vertexData.uvs = uvs;
  78410. return vertexData;
  78411. };
  78412. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap = function (options) {
  78413. var indices = [];
  78414. var positions = [];
  78415. var normals = [];
  78416. var uvs = [];
  78417. var row, col;
  78418. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  78419. var alphaFilter = options.alphaFilter || 0.0;
  78420. var invert = false;
  78421. if (options.minHeight > options.maxHeight) {
  78422. invert = true;
  78423. var temp = options.maxHeight;
  78424. options.maxHeight = options.minHeight;
  78425. options.minHeight = temp;
  78426. }
  78427. // Vertices
  78428. for (row = 0; row <= options.subdivisions; row++) {
  78429. for (col = 0; col <= options.subdivisions; col++) {
  78430. 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));
  78431. // Compute height
  78432. var heightMapX = (((position.x + options.width / 2) / options.width) * (options.bufferWidth - 1)) | 0;
  78433. var heightMapY = ((1.0 - (position.z + options.height / 2) / options.height) * (options.bufferHeight - 1)) | 0;
  78434. var pos = (heightMapX + heightMapY * options.bufferWidth) * 4;
  78435. var r = options.buffer[pos] / 255.0;
  78436. var g = options.buffer[pos + 1] / 255.0;
  78437. var b = options.buffer[pos + 2] / 255.0;
  78438. var a = options.buffer[pos + 3] / 255.0;
  78439. if (invert) {
  78440. r = 1.0 - r;
  78441. g = 1.0 - g;
  78442. b = 1.0 - b;
  78443. }
  78444. var gradient = r * filter.r + g * filter.g + b * filter.b;
  78445. // If our alpha channel is not within our filter then we will assign a 'special' height
  78446. // Then when building the indices, we will ignore any vertex that is using the special height
  78447. if (a >= alphaFilter) {
  78448. position.y = options.minHeight + (options.maxHeight - options.minHeight) * gradient;
  78449. }
  78450. else {
  78451. position.y = options.minHeight - _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; // We can't have a height below minHeight, normally.
  78452. }
  78453. // Add vertex
  78454. positions.push(position.x, position.y, position.z);
  78455. normals.push(0, 0, 0);
  78456. uvs.push(col / options.subdivisions, 1.0 - row / options.subdivisions);
  78457. }
  78458. }
  78459. // Indices
  78460. for (row = 0; row < options.subdivisions; row++) {
  78461. for (col = 0; col < options.subdivisions; col++) {
  78462. // Calculate Indices
  78463. var idx1 = (col + 1 + (row + 1) * (options.subdivisions + 1));
  78464. var idx2 = (col + 1 + row * (options.subdivisions + 1));
  78465. var idx3 = (col + row * (options.subdivisions + 1));
  78466. var idx4 = (col + (row + 1) * (options.subdivisions + 1));
  78467. // Check that all indices are visible (based on our special height)
  78468. // Only display the vertex if all Indices are visible
  78469. // Positions are stored x,y,z for each vertex, hence the * 3 and + 1 for height
  78470. var isVisibleIdx1 = positions[idx1 * 3 + 1] >= options.minHeight;
  78471. var isVisibleIdx2 = positions[idx2 * 3 + 1] >= options.minHeight;
  78472. var isVisibleIdx3 = positions[idx3 * 3 + 1] >= options.minHeight;
  78473. if (isVisibleIdx1 && isVisibleIdx2 && isVisibleIdx3) {
  78474. indices.push(idx1);
  78475. indices.push(idx2);
  78476. indices.push(idx3);
  78477. }
  78478. var isVisibleIdx4 = positions[idx4 * 3 + 1] >= options.minHeight;
  78479. if (isVisibleIdx4 && isVisibleIdx1 && isVisibleIdx3) {
  78480. indices.push(idx4);
  78481. indices.push(idx1);
  78482. indices.push(idx3);
  78483. }
  78484. }
  78485. }
  78486. // Normals
  78487. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  78488. // Result
  78489. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78490. vertexData.indices = indices;
  78491. vertexData.positions = positions;
  78492. vertexData.normals = normals;
  78493. vertexData.uvs = uvs;
  78494. return vertexData;
  78495. };
  78496. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  78497. var options = {
  78498. width: width,
  78499. height: height,
  78500. subdivisions: subdivisions,
  78501. updatable: updatable
  78502. };
  78503. return GroundBuilder.CreateGround(name, options, scene);
  78504. };
  78505. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  78506. var options = {
  78507. xmin: xmin,
  78508. zmin: zmin,
  78509. xmax: xmax,
  78510. zmax: zmax,
  78511. subdivisions: subdivisions,
  78512. precision: precision,
  78513. updatable: updatable
  78514. };
  78515. return GroundBuilder.CreateTiledGround(name, options, scene);
  78516. };
  78517. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  78518. var options = {
  78519. width: width,
  78520. height: height,
  78521. subdivisions: subdivisions,
  78522. minHeight: minHeight,
  78523. maxHeight: maxHeight,
  78524. updatable: updatable,
  78525. onReady: onReady,
  78526. alphaFilter: alphaFilter
  78527. };
  78528. return GroundBuilder.CreateGroundFromHeightMap(name, url, options, scene);
  78529. };
  78530. /**
  78531. * Class containing static functions to help procedurally build meshes
  78532. */
  78533. var GroundBuilder = /** @class */ (function () {
  78534. function GroundBuilder() {
  78535. }
  78536. /**
  78537. * Creates a ground mesh
  78538. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  78539. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  78540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78541. * @param name defines the name of the mesh
  78542. * @param options defines the options used to create the mesh
  78543. * @param scene defines the hosting scene
  78544. * @returns the ground mesh
  78545. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  78546. */
  78547. GroundBuilder.CreateGround = function (name, options, scene) {
  78548. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  78549. ground._setReady(false);
  78550. ground._subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  78551. ground._subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  78552. ground._width = options.width || 1;
  78553. ground._height = options.height || 1;
  78554. ground._maxX = ground._width / 2;
  78555. ground._maxZ = ground._height / 2;
  78556. ground._minX = -ground._maxX;
  78557. ground._minZ = -ground._maxZ;
  78558. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround(options);
  78559. vertexData.applyToMesh(ground, options.updatable);
  78560. ground._setReady(true);
  78561. return ground;
  78562. };
  78563. /**
  78564. * Creates a tiled ground mesh
  78565. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  78566. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  78567. * * 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
  78568. * * 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
  78569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  78570. * @param name defines the name of the mesh
  78571. * @param options defines the options used to create the mesh
  78572. * @param scene defines the hosting scene
  78573. * @returns the tiled ground mesh
  78574. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  78575. */
  78576. GroundBuilder.CreateTiledGround = function (name, options, scene) {
  78577. var tiledGround = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  78578. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround(options);
  78579. vertexData.applyToMesh(tiledGround, options.updatable);
  78580. return tiledGround;
  78581. };
  78582. /**
  78583. * Creates a ground mesh from a height map
  78584. * * The parameter `url` sets the URL of the height map image resource.
  78585. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  78586. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  78587. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  78588. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  78589. * * 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.
  78590. * * 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).
  78591. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  78592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  78593. * @param name defines the name of the mesh
  78594. * @param url defines the url to the height map
  78595. * @param options defines the options used to create the mesh
  78596. * @param scene defines the hosting scene
  78597. * @returns the ground mesh
  78598. * @see https://doc.babylonjs.com/babylon101/height_map
  78599. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  78600. */
  78601. GroundBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  78602. var width = options.width || 10.0;
  78603. var height = options.height || 10.0;
  78604. var subdivisions = options.subdivisions || 1 | 0;
  78605. var minHeight = options.minHeight || 0.0;
  78606. var maxHeight = options.maxHeight || 1.0;
  78607. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  78608. var alphaFilter = options.alphaFilter || 0.0;
  78609. var updatable = options.updatable;
  78610. var onReady = options.onReady;
  78611. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  78612. ground._subdivisionsX = subdivisions;
  78613. ground._subdivisionsY = subdivisions;
  78614. ground._width = width;
  78615. ground._height = height;
  78616. ground._maxX = ground._width / 2.0;
  78617. ground._maxZ = ground._height / 2.0;
  78618. ground._minX = -ground._maxX;
  78619. ground._minZ = -ground._maxZ;
  78620. ground._setReady(false);
  78621. var onload = function (img) {
  78622. // Getting height map data
  78623. var canvas = document.createElement("canvas");
  78624. var context = canvas.getContext("2d");
  78625. if (!context) {
  78626. throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");
  78627. }
  78628. if (scene.isDisposed) {
  78629. return;
  78630. }
  78631. var bufferWidth = img.width;
  78632. var bufferHeight = img.height;
  78633. canvas.width = bufferWidth;
  78634. canvas.height = bufferHeight;
  78635. context.drawImage(img, 0, 0);
  78636. // Create VertexData from map data
  78637. // Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  78638. var buffer = context.getImageData(0, 0, bufferWidth, bufferHeight).data;
  78639. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap({
  78640. width: width, height: height,
  78641. subdivisions: subdivisions,
  78642. minHeight: minHeight, maxHeight: maxHeight, colorFilter: filter,
  78643. buffer: buffer, bufferWidth: bufferWidth, bufferHeight: bufferHeight,
  78644. alphaFilter: alphaFilter
  78645. });
  78646. vertexData.applyToMesh(ground, updatable);
  78647. //execute ready callback, if set
  78648. if (onReady) {
  78649. onReady(ground);
  78650. }
  78651. ground._setReady(true);
  78652. };
  78653. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  78654. return ground;
  78655. };
  78656. return GroundBuilder;
  78657. }());
  78658. /***/ }),
  78659. /***/ "./Meshes/Builders/hemisphereBuilder.ts":
  78660. /*!**********************************************!*\
  78661. !*** ./Meshes/Builders/hemisphereBuilder.ts ***!
  78662. \**********************************************/
  78663. /*! exports provided: HemisphereBuilder */
  78664. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78665. "use strict";
  78666. __webpack_require__.r(__webpack_exports__);
  78667. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return HemisphereBuilder; });
  78668. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78669. /* harmony import */ var _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  78670. /**
  78671. * Creates a hemispheric light
  78672. */
  78673. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateHemisphere = function (name, segments, diameter, scene) {
  78674. var options = {
  78675. segments: segments,
  78676. diameter: diameter
  78677. };
  78678. return HemisphereBuilder.CreateHemisphere(name, options, scene);
  78679. };
  78680. /**
  78681. * Class containing static functions to help procedurally build meshes
  78682. */
  78683. var HemisphereBuilder = /** @class */ (function () {
  78684. function HemisphereBuilder() {
  78685. }
  78686. /**
  78687. * Creates a hemisphere mesh
  78688. * @param name defines the name of the mesh
  78689. * @param options defines the options used to create the mesh
  78690. * @param scene defines the hosting scene
  78691. * @returns the hemisphere mesh
  78692. */
  78693. HemisphereBuilder.CreateHemisphere = function (name, options, scene) {
  78694. if (!options.diameter) {
  78695. options.diameter = 1;
  78696. }
  78697. if (!options.segments) {
  78698. options.segments = 16;
  78699. }
  78700. var halfSphere = _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere("", { slice: 0.5, diameter: options.diameter, segments: options.segments }, scene);
  78701. var disc = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateDisc("", options.diameter / 2, (options.segments * 3) + (4 - options.segments), scene);
  78702. disc.rotation.x = -Math.PI / 2;
  78703. disc.parent = halfSphere;
  78704. var merged = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].MergeMeshes([disc, halfSphere], true);
  78705. merged.name = name;
  78706. return merged;
  78707. };
  78708. return HemisphereBuilder;
  78709. }());
  78710. /***/ }),
  78711. /***/ "./Meshes/Builders/icoSphereBuilder.ts":
  78712. /*!*********************************************!*\
  78713. !*** ./Meshes/Builders/icoSphereBuilder.ts ***!
  78714. \*********************************************/
  78715. /*! exports provided: IcoSphereBuilder */
  78716. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78717. "use strict";
  78718. __webpack_require__.r(__webpack_exports__);
  78719. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return IcoSphereBuilder; });
  78720. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78721. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78722. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78723. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere = function (options) {
  78724. var sideOrientation = options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  78725. var radius = options.radius || 1;
  78726. var flat = (options.flat === undefined) ? true : options.flat;
  78727. var subdivisions = options.subdivisions || 4;
  78728. var radiusX = options.radiusX || radius;
  78729. var radiusY = options.radiusY || radius;
  78730. var radiusZ = options.radiusZ || radius;
  78731. var t = (1 + Math.sqrt(5)) / 2;
  78732. // 12 vertex x,y,z
  78733. var ico_vertices = [
  78734. -1, t, -0, 1, t, 0, -1, -t, 0, 1, -t, 0,
  78735. 0, -1, -t, 0, 1, -t, 0, -1, t, 0, 1, t,
  78736. t, 0, 1, t, 0, -1, -t, 0, 1, -t, 0, -1 // v8-11
  78737. ];
  78738. // index of 3 vertex makes a face of icopshere
  78739. var ico_indices = [
  78740. 0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 12, 22, 23,
  78741. 1, 5, 20, 5, 11, 4, 23, 22, 13, 22, 18, 6, 7, 1, 8,
  78742. 14, 21, 4, 14, 4, 2, 16, 13, 6, 15, 6, 19, 3, 8, 9,
  78743. 4, 21, 5, 13, 17, 23, 6, 13, 22, 19, 6, 18, 9, 8, 1
  78744. ];
  78745. // vertex for uv have aliased position, not for UV
  78746. var vertices_unalias_id = [
  78747. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
  78748. // vertex alias
  78749. 0,
  78750. 2,
  78751. 3,
  78752. 3,
  78753. 3,
  78754. 4,
  78755. 7,
  78756. 8,
  78757. 9,
  78758. 9,
  78759. 10,
  78760. 11 // 23: B + 12
  78761. ];
  78762. // uv as integer step (not pixels !)
  78763. var ico_vertexuv = [
  78764. 5, 1, 3, 1, 6, 4, 0, 0,
  78765. 5, 3, 4, 2, 2, 2, 4, 0,
  78766. 2, 0, 1, 1, 6, 0, 6, 2,
  78767. // vertex alias (for same vertex on different faces)
  78768. 0, 4,
  78769. 3, 3,
  78770. 4, 4,
  78771. 3, 1,
  78772. 4, 2,
  78773. 4, 4,
  78774. 0, 2,
  78775. 1, 1,
  78776. 2, 2,
  78777. 3, 3,
  78778. 1, 3,
  78779. 2, 4 // 23: B + 12
  78780. ];
  78781. // Vertices[0, 1, ...9, A, B] : position on UV plane
  78782. // '+' indicate duplicate position to be fixed (3,9:0,2,3,4,7,8,A,B)
  78783. // First island of uv mapping
  78784. // v = 4h 3+ 2
  78785. // v = 3h 9+ 4
  78786. // v = 2h 9+ 5 B
  78787. // v = 1h 9 1 0
  78788. // v = 0h 3 8 7 A
  78789. // u = 0 1 2 3 4 5 6 *a
  78790. // Second island of uv mapping
  78791. // v = 4h 0+ B+ 4+
  78792. // v = 3h A+ 2+
  78793. // v = 2h 7+ 6 3+
  78794. // v = 1h 8+ 3+
  78795. // v = 0h
  78796. // u = 0 1 2 3 4 5 6 *a
  78797. // Face layout on texture UV mapping
  78798. // ============
  78799. // \ 4 /\ 16 / ======
  78800. // \ / \ / /\ 11 /
  78801. // \/ 7 \/ / \ /
  78802. // ======= / 10 \/
  78803. // /\ 17 /\ =======
  78804. // / \ / \ \ 15 /\
  78805. // / 8 \/ 12 \ \ / \
  78806. // ============ \/ 6 \
  78807. // \ 18 /\ ============
  78808. // \ / \ \ 5 /\ 0 /
  78809. // \/ 13 \ \ / \ /
  78810. // ======= \/ 1 \/
  78811. // =============
  78812. // /\ 19 /\ 2 /\
  78813. // / \ / \ / \
  78814. // / 14 \/ 9 \/ 3 \
  78815. // ===================
  78816. // uv step is u:1 or 0.5, v:cos(30)=sqrt(3)/2, ratio approx is 84/97
  78817. var ustep = 138 / 1024;
  78818. var vstep = 239 / 1024;
  78819. var uoffset = 60 / 1024;
  78820. var voffset = 26 / 1024;
  78821. // Second island should have margin, not to touch the first island
  78822. // avoid any borderline artefact in pixel rounding
  78823. var island_u_offset = -40 / 1024;
  78824. var island_v_offset = +20 / 1024;
  78825. // face is either island 0 or 1 :
  78826. // second island is for faces : [4, 7, 8, 12, 13, 16, 17, 18]
  78827. var island = [
  78828. 0, 0, 0, 0, 1,
  78829. 0, 0, 1, 1, 0,
  78830. 0, 0, 1, 1, 0,
  78831. 0, 1, 1, 1, 0 // 15 - 19
  78832. ];
  78833. var indices = new Array();
  78834. var positions = new Array();
  78835. var normals = new Array();
  78836. var uvs = new Array();
  78837. var current_indice = 0;
  78838. // prepare array of 3 vector (empty) (to be worked in place, shared for each face)
  78839. var face_vertex_pos = new Array(3);
  78840. var face_vertex_uv = new Array(3);
  78841. var v012;
  78842. for (v012 = 0; v012 < 3; v012++) {
  78843. face_vertex_pos[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78844. face_vertex_uv[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  78845. }
  78846. // create all with normals
  78847. for (var face = 0; face < 20; face++) {
  78848. // 3 vertex per face
  78849. for (v012 = 0; v012 < 3; v012++) {
  78850. // look up vertex 0,1,2 to its index in 0 to 11 (or 23 including alias)
  78851. var v_id = ico_indices[3 * face + v012];
  78852. // vertex have 3D position (x,y,z)
  78853. 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]);
  78854. // Normalize to get normal, then scale to radius
  78855. face_vertex_pos[v012].normalize().scaleInPlace(radius);
  78856. // uv Coordinates from vertex ID
  78857. 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);
  78858. }
  78859. // Subdivide the face (interpolate pos, norm, uv)
  78860. // - pos is linear interpolation, then projected to sphere (converge polyhedron to sphere)
  78861. // - norm is linear interpolation of vertex corner normal
  78862. // (to be checked if better to re-calc from face vertex, or if approximation is OK ??? )
  78863. // - uv is linear interpolation
  78864. //
  78865. // Topology is as below for sub-divide by 2
  78866. // vertex shown as v0,v1,v2
  78867. // interp index is i1 to progress in range [v0,v1[
  78868. // interp index is i2 to progress in range [v0,v2[
  78869. // face index as (i1,i2) for /\ : (i1,i2),(i1+1,i2),(i1,i2+1)
  78870. // and (i1,i2)' for \/ : (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  78871. //
  78872. //
  78873. // i2 v2
  78874. // ^ ^
  78875. // / / \
  78876. // / / \
  78877. // / / \
  78878. // / / (0,1) \
  78879. // / #---------\
  78880. // / / \ (0,0)'/ \
  78881. // / / \ / \
  78882. // / / \ / \
  78883. // / / (0,0) \ / (1,0) \
  78884. // / #---------#---------\
  78885. // v0 v1
  78886. //
  78887. // --------------------> i1
  78888. //
  78889. // interp of (i1,i2):
  78890. // along i2 : x0=lerp(v0,v2, i2/S) <---> x1=lerp(v1,v2, i2/S)
  78891. // along i1 : lerp(x0,x1, i1/(S-i2))
  78892. //
  78893. // centroid of triangle is needed to get help normal computation
  78894. // (c1,c2) are used for centroid location
  78895. var interp_vertex = function (i1, i2, c1, c2) {
  78896. // vertex is interpolated from
  78897. // - face_vertex_pos[0..2]
  78898. // - face_vertex_uv[0..2]
  78899. var pos_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], i2 / subdivisions);
  78900. var pos_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], i2 / subdivisions);
  78901. var pos_interp = (subdivisions === i2) ? face_vertex_pos[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(pos_x0, pos_x1, i1 / (subdivisions - i2));
  78902. pos_interp.normalize();
  78903. var vertex_normal;
  78904. if (flat) {
  78905. // in flat mode, recalculate normal as face centroid normal
  78906. var centroid_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], c2 / subdivisions);
  78907. var centroid_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], c2 / subdivisions);
  78908. vertex_normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(centroid_x0, centroid_x1, c1 / (subdivisions - c2));
  78909. }
  78910. else {
  78911. // in smooth mode, recalculate normal from each single vertex position
  78912. vertex_normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pos_interp.x, pos_interp.y, pos_interp.z);
  78913. }
  78914. // Vertex normal need correction due to X,Y,Z radius scaling
  78915. vertex_normal.x /= radiusX;
  78916. vertex_normal.y /= radiusY;
  78917. vertex_normal.z /= radiusZ;
  78918. vertex_normal.normalize();
  78919. var uv_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[0], face_vertex_uv[2], i2 / subdivisions);
  78920. var uv_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[1], face_vertex_uv[2], i2 / subdivisions);
  78921. var uv_interp = (subdivisions === i2) ? face_vertex_uv[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(uv_x0, uv_x1, i1 / (subdivisions - i2));
  78922. positions.push(pos_interp.x * radiusX, pos_interp.y * radiusY, pos_interp.z * radiusZ);
  78923. normals.push(vertex_normal.x, vertex_normal.y, vertex_normal.z);
  78924. uvs.push(uv_interp.x, uv_interp.y);
  78925. // push each vertex has member of a face
  78926. // Same vertex can bleong to multiple face, it is pushed multiple time (duplicate vertex are present)
  78927. indices.push(current_indice);
  78928. current_indice++;
  78929. };
  78930. for (var i2 = 0; i2 < subdivisions; i2++) {
  78931. for (var i1 = 0; i1 + i2 < subdivisions; i1++) {
  78932. // face : (i1,i2) for /\ :
  78933. // interp for : (i1,i2),(i1+1,i2),(i1,i2+1)
  78934. interp_vertex(i1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  78935. interp_vertex(i1 + 1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  78936. interp_vertex(i1, i2 + 1, i1 + 1.0 / 3, i2 + 1.0 / 3);
  78937. if (i1 + i2 + 1 < subdivisions) {
  78938. // face : (i1,i2)' for \/ :
  78939. // interp for (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  78940. interp_vertex(i1 + 1, i2, i1 + 2.0 / 3, i2 + 2.0 / 3);
  78941. interp_vertex(i1 + 1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  78942. interp_vertex(i1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  78943. }
  78944. }
  78945. }
  78946. }
  78947. // Sides
  78948. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  78949. // Result
  78950. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78951. vertexData.indices = indices;
  78952. vertexData.positions = positions;
  78953. vertexData.normals = normals;
  78954. vertexData.uvs = uvs;
  78955. return vertexData;
  78956. };
  78957. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateIcoSphere = function (name, options, scene) {
  78958. return IcoSphereBuilder.CreateIcoSphere(name, options, scene);
  78959. };
  78960. /**
  78961. * Class containing static functions to help procedurally build meshes
  78962. */
  78963. var IcoSphereBuilder = /** @class */ (function () {
  78964. function IcoSphereBuilder() {
  78965. }
  78966. /**
  78967. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  78968. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  78969. * * 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`)
  78970. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  78971. * * 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
  78972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78973. * * 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
  78974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78975. * @param name defines the name of the mesh
  78976. * @param options defines the options used to create the mesh
  78977. * @param scene defines the hosting scene
  78978. * @returns the icosahedron mesh
  78979. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  78980. */
  78981. IcoSphereBuilder.CreateIcoSphere = function (name, options, scene) {
  78982. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  78983. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78984. sphere._originalBuilderSideOrientation = options.sideOrientation;
  78985. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere(options);
  78986. vertexData.applyToMesh(sphere, options.updatable);
  78987. return sphere;
  78988. };
  78989. return IcoSphereBuilder;
  78990. }());
  78991. /***/ }),
  78992. /***/ "./Meshes/Builders/index.ts":
  78993. /*!**********************************!*\
  78994. !*** ./Meshes/Builders/index.ts ***!
  78995. \**********************************/
  78996. /*! exports provided: BoxBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, DiscBuilder, RibbonBuilder, HemisphereBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  78997. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78998. "use strict";
  78999. __webpack_require__.r(__webpack_exports__);
  79000. /* harmony import */ var _boxBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  79001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _boxBuilder__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  79002. /* harmony import */ var _discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./discBuilder */ "./Meshes/Builders/discBuilder.ts");
  79003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"]; });
  79004. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  79005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"]; });
  79006. /* harmony import */ var _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  79007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"]; });
  79008. /* harmony import */ var _hemisphereBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hemisphereBuilder */ "./Meshes/Builders/hemisphereBuilder.ts");
  79009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return _hemisphereBuilder__WEBPACK_IMPORTED_MODULE_4__["HemisphereBuilder"]; });
  79010. /* harmony import */ var _cylinderBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  79011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _cylinderBuilder__WEBPACK_IMPORTED_MODULE_5__["CylinderBuilder"]; });
  79012. /* harmony import */ var _torusBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  79013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _torusBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusBuilder"]; });
  79014. /* harmony import */ var _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  79015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_7__["TorusKnotBuilder"]; });
  79016. /* harmony import */ var _linesBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  79017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"]; });
  79018. /* harmony import */ var _polygonBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  79019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _polygonBuilder__WEBPACK_IMPORTED_MODULE_9__["PolygonBuilder"]; });
  79020. /* harmony import */ var _shapeBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  79021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _shapeBuilder__WEBPACK_IMPORTED_MODULE_10__["ShapeBuilder"]; });
  79022. /* harmony import */ var _latheBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  79023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _latheBuilder__WEBPACK_IMPORTED_MODULE_11__["LatheBuilder"]; });
  79024. /* harmony import */ var _planeBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  79025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _planeBuilder__WEBPACK_IMPORTED_MODULE_12__["PlaneBuilder"]; });
  79026. /* harmony import */ var _groundBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  79027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _groundBuilder__WEBPACK_IMPORTED_MODULE_13__["GroundBuilder"]; });
  79028. /* harmony import */ var _tubeBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  79029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _tubeBuilder__WEBPACK_IMPORTED_MODULE_14__["TubeBuilder"]; });
  79030. /* harmony import */ var _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  79031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_15__["PolyhedronBuilder"]; });
  79032. /* harmony import */ var _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  79033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_16__["IcoSphereBuilder"]; });
  79034. /* harmony import */ var _decalBuilder__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  79035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _decalBuilder__WEBPACK_IMPORTED_MODULE_17__["DecalBuilder"]; });
  79036. /***/ }),
  79037. /***/ "./Meshes/Builders/latheBuilder.ts":
  79038. /*!*****************************************!*\
  79039. !*** ./Meshes/Builders/latheBuilder.ts ***!
  79040. \*****************************************/
  79041. /*! exports provided: LatheBuilder */
  79042. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79043. "use strict";
  79044. __webpack_require__.r(__webpack_exports__);
  79045. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return LatheBuilder; });
  79046. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79047. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79048. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  79049. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  79050. var options = {
  79051. shape: shape,
  79052. radius: radius,
  79053. tessellation: tessellation,
  79054. sideOrientation: sideOrientation,
  79055. updatable: updatable
  79056. };
  79057. return LatheBuilder.CreateLathe(name, options, scene);
  79058. };
  79059. /**
  79060. * Class containing static functions to help procedurally build meshes
  79061. */
  79062. var LatheBuilder = /** @class */ (function () {
  79063. function LatheBuilder() {
  79064. }
  79065. /**
  79066. * Creates lathe mesh.
  79067. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  79068. * * 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
  79069. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  79070. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  79071. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  79072. * * 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
  79073. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  79074. * * 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
  79075. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79076. * * 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
  79077. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  79078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79079. * @param name defines the name of the mesh
  79080. * @param options defines the options used to create the mesh
  79081. * @param scene defines the hosting scene
  79082. * @returns the lathe mesh
  79083. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  79084. */
  79085. LatheBuilder.CreateLathe = function (name, options, scene) {
  79086. var arc = options.arc ? ((options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc) : 1.0;
  79087. var closed = (options.closed === undefined) ? true : options.closed;
  79088. var shape = options.shape;
  79089. var radius = options.radius || 1;
  79090. var tessellation = options.tessellation || 64;
  79091. var clip = options.clip || 0;
  79092. var updatable = options.updatable;
  79093. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79094. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  79095. var pi2 = Math.PI * 2;
  79096. var paths = new Array();
  79097. var invertUV = options.invertUV || false;
  79098. var i = 0;
  79099. var p = 0;
  79100. var step = pi2 / tessellation * arc;
  79101. var rotated;
  79102. var path = new Array();
  79103. for (i = 0; i <= tessellation - clip; i++) {
  79104. var path = [];
  79105. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  79106. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[0].y, 0));
  79107. 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));
  79108. }
  79109. for (p = 0; p < shape.length; p++) {
  79110. 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);
  79111. path.push(rotated);
  79112. }
  79113. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  79114. 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));
  79115. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[shape.length - 1].y, 0));
  79116. }
  79117. paths.push(path);
  79118. }
  79119. // lathe ribbon
  79120. 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);
  79121. return lathe;
  79122. };
  79123. return LatheBuilder;
  79124. }());
  79125. /***/ }),
  79126. /***/ "./Meshes/Builders/linesBuilder.ts":
  79127. /*!*****************************************!*\
  79128. !*** ./Meshes/Builders/linesBuilder.ts ***!
  79129. \*****************************************/
  79130. /*! exports provided: LinesBuilder */
  79131. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79132. "use strict";
  79133. __webpack_require__.r(__webpack_exports__);
  79134. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return LinesBuilder; });
  79135. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79136. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79137. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79138. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  79139. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  79140. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem = function (options) {
  79141. var indices = [];
  79142. var positions = [];
  79143. var lines = options.lines;
  79144. var colors = options.colors;
  79145. var vertexColors = [];
  79146. var idx = 0;
  79147. for (var l = 0; l < lines.length; l++) {
  79148. var points = lines[l];
  79149. for (var index = 0; index < points.length; index++) {
  79150. positions.push(points[index].x, points[index].y, points[index].z);
  79151. if (colors) {
  79152. var color = colors[l];
  79153. vertexColors.push(color[index].r, color[index].g, color[index].b, color[index].a);
  79154. }
  79155. if (index > 0) {
  79156. indices.push(idx - 1);
  79157. indices.push(idx);
  79158. }
  79159. idx++;
  79160. }
  79161. }
  79162. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79163. vertexData.indices = indices;
  79164. vertexData.positions = positions;
  79165. if (colors) {
  79166. vertexData.colors = vertexColors;
  79167. }
  79168. return vertexData;
  79169. };
  79170. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines = function (options) {
  79171. var dashSize = options.dashSize || 3;
  79172. var gapSize = options.gapSize || 1;
  79173. var dashNb = options.dashNb || 200;
  79174. var points = options.points;
  79175. var positions = new Array();
  79176. var indices = new Array();
  79177. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79178. var lg = 0;
  79179. var nb = 0;
  79180. var shft = 0;
  79181. var dashshft = 0;
  79182. var curshft = 0;
  79183. var idx = 0;
  79184. var i = 0;
  79185. for (i = 0; i < points.length - 1; i++) {
  79186. points[i + 1].subtractToRef(points[i], curvect);
  79187. lg += curvect.length();
  79188. }
  79189. shft = lg / dashNb;
  79190. dashshft = dashSize * shft / (dashSize + gapSize);
  79191. for (i = 0; i < points.length - 1; i++) {
  79192. points[i + 1].subtractToRef(points[i], curvect);
  79193. nb = Math.floor(curvect.length() / shft);
  79194. curvect.normalize();
  79195. for (var j = 0; j < nb; j++) {
  79196. curshft = shft * j;
  79197. positions.push(points[i].x + curshft * curvect.x, points[i].y + curshft * curvect.y, points[i].z + curshft * curvect.z);
  79198. positions.push(points[i].x + (curshft + dashshft) * curvect.x, points[i].y + (curshft + dashshft) * curvect.y, points[i].z + (curshft + dashshft) * curvect.z);
  79199. indices.push(idx, idx + 1);
  79200. idx += 2;
  79201. }
  79202. }
  79203. // Result
  79204. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79205. vertexData.positions = positions;
  79206. vertexData.indices = indices;
  79207. return vertexData;
  79208. };
  79209. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines = function (name, points, scene, updatable, instance) {
  79210. if (scene === void 0) { scene = null; }
  79211. if (updatable === void 0) { updatable = false; }
  79212. if (instance === void 0) { instance = null; }
  79213. var options = {
  79214. points: points,
  79215. updatable: updatable,
  79216. instance: instance
  79217. };
  79218. return LinesBuilder.CreateLines(name, options, scene);
  79219. };
  79220. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  79221. if (scene === void 0) { scene = null; }
  79222. var options = {
  79223. points: points,
  79224. dashSize: dashSize,
  79225. gapSize: gapSize,
  79226. dashNb: dashNb,
  79227. updatable: updatable,
  79228. instance: instance
  79229. };
  79230. return LinesBuilder.CreateDashedLines(name, options, scene);
  79231. };
  79232. /**
  79233. * Class containing static functions to help procedurally build meshes
  79234. */
  79235. var LinesBuilder = /** @class */ (function () {
  79236. function LinesBuilder() {
  79237. }
  79238. /**
  79239. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  79240. * * 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
  79241. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  79242. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  79243. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  79244. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  79245. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  79246. * * 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
  79247. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  79248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79249. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  79250. * @param name defines the name of the new line system
  79251. * @param options defines the options used to create the line system
  79252. * @param scene defines the hosting scene
  79253. * @returns a new line system mesh
  79254. */
  79255. LinesBuilder.CreateLineSystem = function (name, options, scene) {
  79256. var instance = options.instance;
  79257. var lines = options.lines;
  79258. var colors = options.colors;
  79259. if (instance) { // lines update
  79260. var positions = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  79261. var vertexColor;
  79262. var lineColors;
  79263. if (colors) {
  79264. vertexColor = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  79265. }
  79266. var i = 0;
  79267. var c = 0;
  79268. for (var l = 0; l < lines.length; l++) {
  79269. var points = lines[l];
  79270. for (var p = 0; p < points.length; p++) {
  79271. positions[i] = points[p].x;
  79272. positions[i + 1] = points[p].y;
  79273. positions[i + 2] = points[p].z;
  79274. if (colors && vertexColor) {
  79275. lineColors = colors[l];
  79276. vertexColor[c] = lineColors[p].r;
  79277. vertexColor[c + 1] = lineColors[p].g;
  79278. vertexColor[c + 2] = lineColors[p].b;
  79279. vertexColor[c + 3] = lineColors[p].a;
  79280. c += 4;
  79281. }
  79282. i += 3;
  79283. }
  79284. }
  79285. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind, positions, false, false);
  79286. if (colors && vertexColor) {
  79287. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind, vertexColor, false, false);
  79288. }
  79289. return instance;
  79290. }
  79291. // line system creation
  79292. var useVertexColor = (colors) ? true : false;
  79293. var lineSystem = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene, null, undefined, undefined, useVertexColor, options.useVertexAlpha);
  79294. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem(options);
  79295. vertexData.applyToMesh(lineSystem, options.updatable);
  79296. return lineSystem;
  79297. };
  79298. /**
  79299. * Creates a line mesh
  79300. * 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
  79301. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  79302. * * The parameter `points` is an array successive Vector3
  79303. * * 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
  79304. * * The optional parameter `colors` is an array of successive Color4, one per line point
  79305. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  79306. * * When updating an instance, remember that only point positions can change, not the number of points
  79307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79308. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  79309. * @param name defines the name of the new line system
  79310. * @param options defines the options used to create the line system
  79311. * @param scene defines the hosting scene
  79312. * @returns a new line mesh
  79313. */
  79314. LinesBuilder.CreateLines = function (name, options, scene) {
  79315. if (scene === void 0) { scene = null; }
  79316. var colors = (options.colors) ? [options.colors] : null;
  79317. var lines = LinesBuilder.CreateLineSystem(name, { lines: [options.points], updatable: options.updatable, instance: options.instance, colors: colors, useVertexAlpha: options.useVertexAlpha }, scene);
  79318. return lines;
  79319. };
  79320. /**
  79321. * Creates a dashed line mesh
  79322. * * 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
  79323. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  79324. * * The parameter `points` is an array successive Vector3
  79325. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  79326. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  79327. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  79328. * * 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
  79329. * * When updating an instance, remember that only point positions can change, not the number of points
  79330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79331. * @param name defines the name of the mesh
  79332. * @param options defines the options used to create the mesh
  79333. * @param scene defines the hosting scene
  79334. * @returns the dashed line mesh
  79335. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  79336. */
  79337. LinesBuilder.CreateDashedLines = function (name, options, scene) {
  79338. if (scene === void 0) { scene = null; }
  79339. var points = options.points;
  79340. var instance = options.instance;
  79341. var gapSize = options.gapSize || 1;
  79342. var dashSize = options.dashSize || 3;
  79343. if (instance) { // dashed lines update
  79344. var positionFunction = function (positions) {
  79345. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79346. var nbSeg = positions.length / 6;
  79347. var lg = 0;
  79348. var nb = 0;
  79349. var shft = 0;
  79350. var dashshft = 0;
  79351. var curshft = 0;
  79352. var p = 0;
  79353. var i = 0;
  79354. var j = 0;
  79355. for (i = 0; i < points.length - 1; i++) {
  79356. points[i + 1].subtractToRef(points[i], curvect);
  79357. lg += curvect.length();
  79358. }
  79359. shft = lg / nbSeg;
  79360. var dashSize = instance._creationDataStorage.dashSize;
  79361. var gapSize = instance._creationDataStorage.gapSize;
  79362. dashshft = dashSize * shft / (dashSize + gapSize);
  79363. for (i = 0; i < points.length - 1; i++) {
  79364. points[i + 1].subtractToRef(points[i], curvect);
  79365. nb = Math.floor(curvect.length() / shft);
  79366. curvect.normalize();
  79367. j = 0;
  79368. while (j < nb && p < positions.length) {
  79369. curshft = shft * j;
  79370. positions[p] = points[i].x + curshft * curvect.x;
  79371. positions[p + 1] = points[i].y + curshft * curvect.y;
  79372. positions[p + 2] = points[i].z + curshft * curvect.z;
  79373. positions[p + 3] = points[i].x + (curshft + dashshft) * curvect.x;
  79374. positions[p + 4] = points[i].y + (curshft + dashshft) * curvect.y;
  79375. positions[p + 5] = points[i].z + (curshft + dashshft) * curvect.z;
  79376. p += 6;
  79377. j++;
  79378. }
  79379. }
  79380. while (p < positions.length) {
  79381. positions[p] = points[i].x;
  79382. positions[p + 1] = points[i].y;
  79383. positions[p + 2] = points[i].z;
  79384. p += 3;
  79385. }
  79386. };
  79387. instance.updateMeshPositions(positionFunction, false);
  79388. return instance;
  79389. }
  79390. // dashed lines creation
  79391. var dashedLines = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene);
  79392. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines(options);
  79393. vertexData.applyToMesh(dashedLines, options.updatable);
  79394. dashedLines._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  79395. dashedLines._creationDataStorage.dashSize = dashSize;
  79396. dashedLines._creationDataStorage.gapSize = gapSize;
  79397. return dashedLines;
  79398. };
  79399. return LinesBuilder;
  79400. }());
  79401. /***/ }),
  79402. /***/ "./Meshes/Builders/planeBuilder.ts":
  79403. /*!*****************************************!*\
  79404. !*** ./Meshes/Builders/planeBuilder.ts ***!
  79405. \*****************************************/
  79406. /*! exports provided: PlaneBuilder */
  79407. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79408. "use strict";
  79409. __webpack_require__.r(__webpack_exports__);
  79410. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return PlaneBuilder; });
  79411. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79412. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79413. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane = function (options) {
  79414. var indices = [];
  79415. var positions = [];
  79416. var normals = [];
  79417. var uvs = [];
  79418. var width = options.width || options.size || 1;
  79419. var height = options.height || options.size || 1;
  79420. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  79421. // Vertices
  79422. var halfWidth = width / 2.0;
  79423. var halfHeight = height / 2.0;
  79424. positions.push(-halfWidth, -halfHeight, 0);
  79425. normals.push(0, 0, -1.0);
  79426. uvs.push(0.0, 0.0);
  79427. positions.push(halfWidth, -halfHeight, 0);
  79428. normals.push(0, 0, -1.0);
  79429. uvs.push(1.0, 0.0);
  79430. positions.push(halfWidth, halfHeight, 0);
  79431. normals.push(0, 0, -1.0);
  79432. uvs.push(1.0, 1.0);
  79433. positions.push(-halfWidth, halfHeight, 0);
  79434. normals.push(0, 0, -1.0);
  79435. uvs.push(0.0, 1.0);
  79436. // Indices
  79437. indices.push(0);
  79438. indices.push(1);
  79439. indices.push(2);
  79440. indices.push(0);
  79441. indices.push(2);
  79442. indices.push(3);
  79443. // Sides
  79444. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  79445. // Result
  79446. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  79447. vertexData.indices = indices;
  79448. vertexData.positions = positions;
  79449. vertexData.normals = normals;
  79450. vertexData.uvs = uvs;
  79451. return vertexData;
  79452. };
  79453. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  79454. var options = {
  79455. size: size,
  79456. width: size,
  79457. height: size,
  79458. sideOrientation: sideOrientation,
  79459. updatable: updatable
  79460. };
  79461. return PlaneBuilder.CreatePlane(name, options, scene);
  79462. };
  79463. /**
  79464. * Class containing static functions to help procedurally build meshes
  79465. */
  79466. var PlaneBuilder = /** @class */ (function () {
  79467. function PlaneBuilder() {
  79468. }
  79469. /**
  79470. * Creates a plane mesh
  79471. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  79472. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  79473. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  79474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79475. * * 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
  79476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79477. * @param name defines the name of the mesh
  79478. * @param options defines the options used to create the mesh
  79479. * @param scene defines the hosting scene
  79480. * @returns the plane mesh
  79481. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  79482. */
  79483. PlaneBuilder.CreatePlane = function (name, options, scene) {
  79484. var plane = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  79485. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79486. plane._originalBuilderSideOrientation = options.sideOrientation;
  79487. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane(options);
  79488. vertexData.applyToMesh(plane, options.updatable);
  79489. if (options.sourcePlane) {
  79490. plane.translate(options.sourcePlane.normal, -options.sourcePlane.d);
  79491. plane.setDirection(options.sourcePlane.normal.scale(-1));
  79492. }
  79493. return plane;
  79494. };
  79495. return PlaneBuilder;
  79496. }());
  79497. /***/ }),
  79498. /***/ "./Meshes/Builders/polygonBuilder.ts":
  79499. /*!*******************************************!*\
  79500. !*** ./Meshes/Builders/polygonBuilder.ts ***!
  79501. \*******************************************/
  79502. /*! exports provided: PolygonBuilder */
  79503. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79504. "use strict";
  79505. __webpack_require__.r(__webpack_exports__);
  79506. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return PolygonBuilder; });
  79507. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79508. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79509. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79510. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../polygonMesh */ "./Meshes/polygonMesh.ts");
  79511. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  79512. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  79513. var faceUV = fUV || new Array(3);
  79514. var faceColors = fColors;
  79515. var colors = [];
  79516. // default face colors and UV if undefined
  79517. for (var f = 0; f < 3; f++) {
  79518. if (faceUV[f] === undefined) {
  79519. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  79520. }
  79521. if (faceColors && faceColors[f] === undefined) {
  79522. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  79523. }
  79524. }
  79525. var positions = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  79526. var normals = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  79527. var uvs = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  79528. var indices = polygon.getIndices();
  79529. // set face colours and textures
  79530. var idx = 0;
  79531. var face = 0;
  79532. for (var index = 0; index < normals.length; index += 3) {
  79533. //Edge Face no. 1
  79534. if (Math.abs(normals[index + 1]) < 0.001) {
  79535. face = 1;
  79536. }
  79537. //Top Face no. 0
  79538. if (Math.abs(normals[index + 1] - 1) < 0.001) {
  79539. face = 0;
  79540. }
  79541. //Bottom Face no. 2
  79542. if (Math.abs(normals[index + 1] + 1) < 0.001) {
  79543. face = 2;
  79544. }
  79545. idx = index / 3;
  79546. uvs[2 * idx] = (1 - uvs[2 * idx]) * faceUV[face].x + uvs[2 * idx] * faceUV[face].z;
  79547. uvs[2 * idx + 1] = (1 - uvs[2 * idx + 1]) * faceUV[face].y + uvs[2 * idx + 1] * faceUV[face].w;
  79548. if (faceColors) {
  79549. colors.push(faceColors[face].r, faceColors[face].g, faceColors[face].b, faceColors[face].a);
  79550. }
  79551. }
  79552. // sides
  79553. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs);
  79554. // Result
  79555. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79556. vertexData.indices = indices;
  79557. vertexData.positions = positions;
  79558. vertexData.normals = normals;
  79559. vertexData.uvs = uvs;
  79560. if (faceColors) {
  79561. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  79562. vertexData.colors = totalColors;
  79563. }
  79564. return vertexData;
  79565. };
  79566. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  79567. if (earcutInjection === void 0) { earcutInjection = earcut; }
  79568. var options = {
  79569. shape: shape,
  79570. holes: holes,
  79571. updatable: updatable,
  79572. sideOrientation: sideOrientation
  79573. };
  79574. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  79575. };
  79576. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  79577. if (earcutInjection === void 0) { earcutInjection = earcut; }
  79578. var options = {
  79579. shape: shape,
  79580. holes: holes,
  79581. depth: depth,
  79582. updatable: updatable,
  79583. sideOrientation: sideOrientation
  79584. };
  79585. return PolygonBuilder.ExtrudePolygon(name, options, scene, earcutInjection);
  79586. };
  79587. /**
  79588. * Class containing static functions to help procedurally build meshes
  79589. */
  79590. var PolygonBuilder = /** @class */ (function () {
  79591. function PolygonBuilder() {
  79592. }
  79593. /**
  79594. * Creates a polygon mesh
  79595. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  79596. * * 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
  79597. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79599. * * 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)
  79600. * * Remember you can only change the shape positions, not their number when updating a polygon
  79601. * @param name defines the name of the mesh
  79602. * @param options defines the options used to create the mesh
  79603. * @param scene defines the hosting scene
  79604. * @param earcutInjection can be used to inject your own earcut reference
  79605. * @returns the polygon mesh
  79606. */
  79607. PolygonBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  79608. if (earcutInjection === void 0) { earcutInjection = earcut; }
  79609. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79610. var shape = options.shape;
  79611. var holes = options.holes || [];
  79612. var depth = options.depth || 0;
  79613. var contours = [];
  79614. var hole = [];
  79615. for (var i = 0; i < shape.length; i++) {
  79616. contours[i] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](shape[i].x, shape[i].z);
  79617. }
  79618. var epsilon = 0.00000001;
  79619. if (contours[0].equalsWithEpsilon(contours[contours.length - 1], epsilon)) {
  79620. contours.pop();
  79621. }
  79622. var polygonTriangulation = new _polygonMesh__WEBPACK_IMPORTED_MODULE_3__["PolygonMeshBuilder"](name, contours, scene, earcutInjection);
  79623. for (var hNb = 0; hNb < holes.length; hNb++) {
  79624. hole = [];
  79625. for (var hPoint = 0; hPoint < holes[hNb].length; hPoint++) {
  79626. hole.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](holes[hNb][hPoint].x, holes[hNb][hPoint].z));
  79627. }
  79628. polygonTriangulation.addHole(hole);
  79629. }
  79630. var polygon = polygonTriangulation.build(options.updatable, depth);
  79631. polygon._originalBuilderSideOrientation = options.sideOrientation;
  79632. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon(polygon, options.sideOrientation, options.faceUV, options.faceColors, options.frontUVs, options.backUVs);
  79633. vertexData.applyToMesh(polygon, options.updatable);
  79634. return polygon;
  79635. };
  79636. /**
  79637. * Creates an extruded polygon mesh, with depth in the Y direction.
  79638. * * 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)
  79639. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  79640. * @param name defines the name of the mesh
  79641. * @param options defines the options used to create the mesh
  79642. * @param scene defines the hosting scene
  79643. * @param earcutInjection can be used to inject your own earcut reference
  79644. * @returns the polygon mesh
  79645. */
  79646. PolygonBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  79647. if (earcutInjection === void 0) { earcutInjection = earcut; }
  79648. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  79649. };
  79650. return PolygonBuilder;
  79651. }());
  79652. /***/ }),
  79653. /***/ "./Meshes/Builders/polyhedronBuilder.ts":
  79654. /*!**********************************************!*\
  79655. !*** ./Meshes/Builders/polyhedronBuilder.ts ***!
  79656. \**********************************************/
  79657. /*! exports provided: PolyhedronBuilder */
  79658. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79659. "use strict";
  79660. __webpack_require__.r(__webpack_exports__);
  79661. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return PolyhedronBuilder; });
  79662. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79663. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79664. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79665. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron = function (options) {
  79666. // provided polyhedron types :
  79667. // 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  79668. // 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)
  79669. var polyhedra = [];
  79670. 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]] };
  79671. 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]] };
  79672. polyhedra[2] = {
  79673. 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]],
  79674. 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]]
  79675. };
  79676. polyhedra[3] = {
  79677. 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]],
  79678. 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]]
  79679. };
  79680. polyhedra[4] = {
  79681. 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]],
  79682. 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]]
  79683. };
  79684. 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]] };
  79685. 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]] };
  79686. 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]] };
  79687. 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]] };
  79688. 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]] };
  79689. 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]] };
  79690. 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]] };
  79691. 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]] };
  79692. 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]] };
  79693. polyhedra[14] = {
  79694. 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]],
  79695. 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]]
  79696. };
  79697. var type = options.type && (options.type < 0 || options.type >= polyhedra.length) ? 0 : options.type || 0;
  79698. var size = options.size;
  79699. var sizeX = options.sizeX || size || 1;
  79700. var sizeY = options.sizeY || size || 1;
  79701. var sizeZ = options.sizeZ || size || 1;
  79702. var data = options.custom || polyhedra[type];
  79703. var nbfaces = data.face.length;
  79704. var faceUV = options.faceUV || new Array(nbfaces);
  79705. var faceColors = options.faceColors;
  79706. var flat = (options.flat === undefined) ? true : options.flat;
  79707. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  79708. var positions = new Array();
  79709. var indices = new Array();
  79710. var normals = new Array();
  79711. var uvs = new Array();
  79712. var colors = new Array();
  79713. var index = 0;
  79714. var faceIdx = 0; // face cursor in the array "indexes"
  79715. var indexes = new Array();
  79716. var i = 0;
  79717. var f = 0;
  79718. var u, v, ang, x, y, tmp;
  79719. // default face colors and UV if undefined
  79720. if (flat) {
  79721. for (f = 0; f < nbfaces; f++) {
  79722. if (faceColors && faceColors[f] === undefined) {
  79723. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  79724. }
  79725. if (faceUV && faceUV[f] === undefined) {
  79726. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  79727. }
  79728. }
  79729. }
  79730. if (!flat) {
  79731. for (i = 0; i < data.vertex.length; i++) {
  79732. positions.push(data.vertex[i][0] * sizeX, data.vertex[i][1] * sizeY, data.vertex[i][2] * sizeZ);
  79733. uvs.push(0, 0);
  79734. }
  79735. for (f = 0; f < nbfaces; f++) {
  79736. for (i = 0; i < data.face[f].length - 2; i++) {
  79737. indices.push(data.face[f][0], data.face[f][i + 2], data.face[f][i + 1]);
  79738. }
  79739. }
  79740. }
  79741. else {
  79742. for (f = 0; f < nbfaces; f++) {
  79743. var fl = data.face[f].length; // number of vertices of the current face
  79744. ang = 2 * Math.PI / fl;
  79745. x = 0.5 * Math.tan(ang / 2);
  79746. y = 0.5;
  79747. // positions, uvs, colors
  79748. for (i = 0; i < fl; i++) {
  79749. // positions
  79750. 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);
  79751. indexes.push(index);
  79752. index++;
  79753. // uvs
  79754. u = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * (0.5 + x);
  79755. v = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * (y - 0.5);
  79756. uvs.push(u, v);
  79757. tmp = x * Math.cos(ang) - y * Math.sin(ang);
  79758. y = x * Math.sin(ang) + y * Math.cos(ang);
  79759. x = tmp;
  79760. // colors
  79761. if (faceColors) {
  79762. colors.push(faceColors[f].r, faceColors[f].g, faceColors[f].b, faceColors[f].a);
  79763. }
  79764. }
  79765. // indices from indexes
  79766. for (i = 0; i < fl - 2; i++) {
  79767. indices.push(indexes[0 + faceIdx], indexes[i + 2 + faceIdx], indexes[i + 1 + faceIdx]);
  79768. }
  79769. faceIdx += fl;
  79770. }
  79771. }
  79772. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  79773. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  79774. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79775. vertexData.positions = positions;
  79776. vertexData.indices = indices;
  79777. vertexData.normals = normals;
  79778. vertexData.uvs = uvs;
  79779. if (faceColors && flat) {
  79780. vertexData.colors = colors;
  79781. }
  79782. return vertexData;
  79783. };
  79784. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolyhedron = function (name, options, scene) {
  79785. return PolyhedronBuilder.CreatePolyhedron(name, options, scene);
  79786. };
  79787. /**
  79788. * Class containing static functions to help procedurally build meshes
  79789. */
  79790. var PolyhedronBuilder = /** @class */ (function () {
  79791. function PolyhedronBuilder() {
  79792. }
  79793. /**
  79794. * Creates a polyhedron mesh
  79795. * * 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
  79796. * * The parameter `size` (positive float, default 1) sets the polygon size
  79797. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  79798. * * 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`
  79799. * * 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
  79800. * * 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)`)
  79801. * * 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
  79802. * * 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
  79803. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79804. * * 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
  79805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79806. * @param name defines the name of the mesh
  79807. * @param options defines the options used to create the mesh
  79808. * @param scene defines the hosting scene
  79809. * @returns the polyhedron mesh
  79810. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  79811. */
  79812. PolyhedronBuilder.CreatePolyhedron = function (name, options, scene) {
  79813. var polyhedron = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  79814. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79815. polyhedron._originalBuilderSideOrientation = options.sideOrientation;
  79816. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron(options);
  79817. vertexData.applyToMesh(polyhedron, options.updatable);
  79818. return polyhedron;
  79819. };
  79820. return PolyhedronBuilder;
  79821. }());
  79822. /***/ }),
  79823. /***/ "./Meshes/Builders/ribbonBuilder.ts":
  79824. /*!******************************************!*\
  79825. !*** ./Meshes/Builders/ribbonBuilder.ts ***!
  79826. \******************************************/
  79827. /*! exports provided: RibbonBuilder */
  79828. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79829. "use strict";
  79830. __webpack_require__.r(__webpack_exports__);
  79831. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return RibbonBuilder; });
  79832. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79833. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79834. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  79835. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79836. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  79837. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon = function (options) {
  79838. var pathArray = options.pathArray;
  79839. var closeArray = options.closeArray || false;
  79840. var closePath = options.closePath || false;
  79841. var invertUV = options.invertUV || false;
  79842. var defaultOffset = Math.floor(pathArray[0].length / 2);
  79843. var offset = options.offset || defaultOffset;
  79844. offset = offset > defaultOffset ? defaultOffset : Math.floor(offset); // offset max allowed : defaultOffset
  79845. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].DEFAULTSIDE;
  79846. var customUV = options.uvs;
  79847. var customColors = options.colors;
  79848. var positions = [];
  79849. var indices = [];
  79850. var normals = [];
  79851. var uvs = [];
  79852. var us = []; // us[path_id] = [uDist1, uDist2, uDist3 ... ] distances between points on path path_id
  79853. var vs = []; // vs[i] = [vDist1, vDist2, vDist3, ... ] distances between points i of consecutives paths from pathArray
  79854. var uTotalDistance = []; // uTotalDistance[p] : total distance of path p
  79855. var vTotalDistance = []; // vTotalDistance[i] : total distance between points i of first and last path from pathArray
  79856. var minlg; // minimal length among all paths from pathArray
  79857. var lg = []; // array of path lengths : nb of vertex per path
  79858. var idx = []; // array of path indexes : index of each path (first vertex) in the total vertex number
  79859. var p; // path iterator
  79860. var i; // point iterator
  79861. var j; // point iterator
  79862. // if single path in pathArray
  79863. if (pathArray.length < 2) {
  79864. var ar1 = [];
  79865. var ar2 = [];
  79866. for (i = 0; i < pathArray[0].length - offset; i++) {
  79867. ar1.push(pathArray[0][i]);
  79868. ar2.push(pathArray[0][i + offset]);
  79869. }
  79870. pathArray = [ar1, ar2];
  79871. }
  79872. // positions and horizontal distances (u)
  79873. var idc = 0;
  79874. var closePathCorr = (closePath) ? 1 : 0; // the final index will be +1 if closePath
  79875. var path;
  79876. var l;
  79877. minlg = pathArray[0].length;
  79878. var vectlg;
  79879. var dist;
  79880. for (p = 0; p < pathArray.length; p++) {
  79881. uTotalDistance[p] = 0;
  79882. us[p] = [0];
  79883. path = pathArray[p];
  79884. l = path.length;
  79885. minlg = (minlg < l) ? minlg : l;
  79886. j = 0;
  79887. while (j < l) {
  79888. positions.push(path[j].x, path[j].y, path[j].z);
  79889. if (j > 0) {
  79890. vectlg = path[j].subtract(path[j - 1]).length();
  79891. dist = vectlg + uTotalDistance[p];
  79892. us[p].push(dist);
  79893. uTotalDistance[p] = dist;
  79894. }
  79895. j++;
  79896. }
  79897. if (closePath) { // an extra hidden vertex is added in the "positions" array
  79898. j--;
  79899. positions.push(path[0].x, path[0].y, path[0].z);
  79900. vectlg = path[j].subtract(path[0]).length();
  79901. dist = vectlg + uTotalDistance[p];
  79902. us[p].push(dist);
  79903. uTotalDistance[p] = dist;
  79904. }
  79905. lg[p] = l + closePathCorr;
  79906. idx[p] = idc;
  79907. idc += (l + closePathCorr);
  79908. }
  79909. // vertical distances (v)
  79910. var path1;
  79911. var path2;
  79912. var vertex1 = null;
  79913. var vertex2 = null;
  79914. for (i = 0; i < minlg + closePathCorr; i++) {
  79915. vTotalDistance[i] = 0;
  79916. vs[i] = [0];
  79917. for (p = 0; p < pathArray.length - 1; p++) {
  79918. path1 = pathArray[p];
  79919. path2 = pathArray[p + 1];
  79920. if (i === minlg) { // closePath
  79921. vertex1 = path1[0];
  79922. vertex2 = path2[0];
  79923. }
  79924. else {
  79925. vertex1 = path1[i];
  79926. vertex2 = path2[i];
  79927. }
  79928. vectlg = vertex2.subtract(vertex1).length();
  79929. dist = vectlg + vTotalDistance[i];
  79930. vs[i].push(dist);
  79931. vTotalDistance[i] = dist;
  79932. }
  79933. if (closeArray && vertex2 && vertex1) {
  79934. path1 = pathArray[p];
  79935. path2 = pathArray[0];
  79936. if (i === minlg) { // closePath
  79937. vertex2 = path2[0];
  79938. }
  79939. vectlg = vertex2.subtract(vertex1).length();
  79940. dist = vectlg + vTotalDistance[i];
  79941. vTotalDistance[i] = dist;
  79942. }
  79943. }
  79944. // uvs
  79945. var u;
  79946. var v;
  79947. if (customUV) {
  79948. for (p = 0; p < customUV.length; p++) {
  79949. uvs.push(customUV[p].x, customUV[p].y);
  79950. }
  79951. }
  79952. else {
  79953. for (p = 0; p < pathArray.length; p++) {
  79954. for (i = 0; i < minlg + closePathCorr; i++) {
  79955. u = (uTotalDistance[p] != 0.0) ? us[p][i] / uTotalDistance[p] : 0.0;
  79956. v = (vTotalDistance[i] != 0.0) ? vs[i][p] / vTotalDistance[i] : 0.0;
  79957. if (invertUV) {
  79958. uvs.push(v, u);
  79959. }
  79960. else {
  79961. uvs.push(u, v);
  79962. }
  79963. }
  79964. }
  79965. }
  79966. // indices
  79967. p = 0; // path index
  79968. var pi = 0; // positions array index
  79969. var l1 = lg[p] - 1; // path1 length
  79970. var l2 = lg[p + 1] - 1; // path2 length
  79971. var min = (l1 < l2) ? l1 : l2; // current path stop index
  79972. var shft = idx[1] - idx[0]; // shift
  79973. var path1nb = closeArray ? lg.length : lg.length - 1; // number of path1 to iterate on
  79974. while (pi <= min && p < path1nb) { // stay under min and don't go over next to last path
  79975. // 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
  79976. indices.push(pi, pi + shft, pi + 1);
  79977. indices.push(pi + shft + 1, pi + 1, pi + shft);
  79978. pi += 1;
  79979. if (pi === min) { // if end of one of two consecutive paths reached, go to next existing path
  79980. p++;
  79981. if (p === lg.length - 1) { // last path of pathArray reached <=> closeArray == true
  79982. shft = idx[0] - idx[p];
  79983. l1 = lg[p] - 1;
  79984. l2 = lg[0] - 1;
  79985. }
  79986. else {
  79987. shft = idx[p + 1] - idx[p];
  79988. l1 = lg[p] - 1;
  79989. l2 = lg[p + 1] - 1;
  79990. }
  79991. pi = idx[p];
  79992. min = (l1 < l2) ? l1 + pi : l2 + pi;
  79993. }
  79994. }
  79995. // normals
  79996. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals);
  79997. if (closePath) { // update both the first and last vertex normals to their average value
  79998. var indexFirst = 0;
  79999. var indexLast = 0;
  80000. for (p = 0; p < pathArray.length; p++) {
  80001. indexFirst = idx[p] * 3;
  80002. if (p + 1 < pathArray.length) {
  80003. indexLast = (idx[p + 1] - 1) * 3;
  80004. }
  80005. else {
  80006. indexLast = normals.length - 3;
  80007. }
  80008. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  80009. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  80010. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  80011. normals[indexLast] = normals[indexFirst];
  80012. normals[indexLast + 1] = normals[indexFirst + 1];
  80013. normals[indexLast + 2] = normals[indexFirst + 2];
  80014. }
  80015. }
  80016. // sides
  80017. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  80018. // Colors
  80019. var colors = null;
  80020. if (customColors) {
  80021. colors = new Float32Array(customColors.length * 4);
  80022. for (var c = 0; c < customColors.length; c++) {
  80023. colors[c * 4] = customColors[c].r;
  80024. colors[c * 4 + 1] = customColors[c].g;
  80025. colors[c * 4 + 2] = customColors[c].b;
  80026. colors[c * 4 + 3] = customColors[c].a;
  80027. }
  80028. }
  80029. // Result
  80030. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  80031. var positions32 = new Float32Array(positions);
  80032. var normals32 = new Float32Array(normals);
  80033. var uvs32 = new Float32Array(uvs);
  80034. vertexData.indices = indices;
  80035. vertexData.positions = positions32;
  80036. vertexData.normals = normals32;
  80037. vertexData.uvs = uvs32;
  80038. if (colors) {
  80039. vertexData.set(colors, _buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  80040. }
  80041. if (closePath) {
  80042. vertexData._idx = idx;
  80043. }
  80044. return vertexData;
  80045. };
  80046. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  80047. if (closeArray === void 0) { closeArray = false; }
  80048. if (updatable === void 0) { updatable = false; }
  80049. return RibbonBuilder.CreateRibbon(name, {
  80050. pathArray: pathArray,
  80051. closeArray: closeArray,
  80052. closePath: closePath,
  80053. offset: offset,
  80054. updatable: updatable,
  80055. sideOrientation: sideOrientation,
  80056. instance: instance
  80057. }, scene);
  80058. };
  80059. /**
  80060. * Class containing static functions to help procedurally build meshes
  80061. */
  80062. var RibbonBuilder = /** @class */ (function () {
  80063. function RibbonBuilder() {
  80064. }
  80065. /**
  80066. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  80067. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  80068. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  80069. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  80070. * * 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
  80071. * * 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
  80072. * * 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
  80073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80074. * * 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
  80075. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  80076. * * 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
  80077. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  80078. * * 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
  80079. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  80080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80081. * @param name defines the name of the mesh
  80082. * @param options defines the options used to create the mesh
  80083. * @param scene defines the hosting scene
  80084. * @returns the ribbon mesh
  80085. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  80086. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  80087. */
  80088. RibbonBuilder.CreateRibbon = function (name, options, scene) {
  80089. if (scene === void 0) { scene = null; }
  80090. var pathArray = options.pathArray;
  80091. var closeArray = options.closeArray;
  80092. var closePath = options.closePath;
  80093. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80094. var instance = options.instance;
  80095. var updatable = options.updatable;
  80096. if (instance) { // existing ribbon instance update
  80097. // positionFunction : ribbon case
  80098. // only pathArray and sideOrientation parameters are taken into account for positions update
  80099. var minimum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0].setAll(Number.MAX_VALUE);
  80100. var maximum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1].setAll(-Number.MAX_VALUE);
  80101. var positionFunction = function (positions) {
  80102. var minlg = pathArray[0].length;
  80103. var mesh = instance;
  80104. var i = 0;
  80105. var ns = (mesh._originalBuilderSideOrientation === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DOUBLESIDE) ? 2 : 1;
  80106. for (var si = 1; si <= ns; ++si) {
  80107. for (var p = 0; p < pathArray.length; ++p) {
  80108. var path = pathArray[p];
  80109. var l = path.length;
  80110. minlg = (minlg < l) ? minlg : l;
  80111. for (var j = 0; j < minlg; ++j) {
  80112. var pathPoint = path[j];
  80113. positions[i] = pathPoint.x;
  80114. positions[i + 1] = pathPoint.y;
  80115. positions[i + 2] = pathPoint.z;
  80116. minimum_1.minimizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  80117. maximum_1.maximizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  80118. i += 3;
  80119. }
  80120. if (mesh._creationDataStorage && mesh._creationDataStorage.closePath) {
  80121. var pathPoint = path[0];
  80122. positions[i] = pathPoint.x;
  80123. positions[i + 1] = pathPoint.y;
  80124. positions[i + 2] = pathPoint.z;
  80125. i += 3;
  80126. }
  80127. }
  80128. }
  80129. };
  80130. var positions = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  80131. positionFunction(positions);
  80132. if (instance._boundingInfo) {
  80133. instance._boundingInfo.reConstruct(minimum_1, maximum_1, instance._worldMatrix);
  80134. }
  80135. else {
  80136. instance._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](minimum_1, maximum_1, instance._worldMatrix);
  80137. }
  80138. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positions, false, false);
  80139. if (options.colors) {
  80140. var colors = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  80141. for (var c = 0, colorIndex = 0; c < options.colors.length; c++, colorIndex += 4) {
  80142. var color = options.colors[c];
  80143. colors[colorIndex] = color.r;
  80144. colors[colorIndex + 1] = color.g;
  80145. colors[colorIndex + 2] = color.b;
  80146. colors[colorIndex + 3] = color.a;
  80147. }
  80148. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colors, false, false);
  80149. }
  80150. if (options.uvs) {
  80151. var uvs = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  80152. for (var i = 0; i < options.uvs.length; i++) {
  80153. uvs[i * 2] = options.uvs[i].x;
  80154. uvs[i * 2 + 1] = options.uvs[i].y;
  80155. }
  80156. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvs, false, false);
  80157. }
  80158. if (!instance.areNormalsFrozen || instance.isFacetDataEnabled) {
  80159. var indices = instance.getIndices();
  80160. var normals = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  80161. var params = instance.isFacetDataEnabled ? instance.getFacetDataParameters() : null;
  80162. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals, params);
  80163. if (instance._creationDataStorage && instance._creationDataStorage.closePath) {
  80164. var indexFirst = 0;
  80165. var indexLast = 0;
  80166. for (var p = 0; p < pathArray.length; p++) {
  80167. indexFirst = instance._creationDataStorage.idx[p] * 3;
  80168. if (p + 1 < pathArray.length) {
  80169. indexLast = (instance._creationDataStorage.idx[p + 1] - 1) * 3;
  80170. }
  80171. else {
  80172. indexLast = normals.length - 3;
  80173. }
  80174. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  80175. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  80176. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  80177. normals[indexLast] = normals[indexFirst];
  80178. normals[indexLast + 1] = normals[indexFirst + 1];
  80179. normals[indexLast + 2] = normals[indexFirst + 2];
  80180. }
  80181. }
  80182. if (!(instance.areNormalsFrozen)) {
  80183. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normals, false, false);
  80184. }
  80185. }
  80186. return instance;
  80187. }
  80188. else { // new ribbon creation
  80189. var ribbon = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  80190. ribbon._originalBuilderSideOrientation = sideOrientation;
  80191. ribbon._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  80192. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon(options);
  80193. if (closePath) {
  80194. ribbon._creationDataStorage.idx = vertexData._idx;
  80195. }
  80196. ribbon._creationDataStorage.closePath = closePath;
  80197. ribbon._creationDataStorage.closeArray = closeArray;
  80198. vertexData.applyToMesh(ribbon, updatable);
  80199. return ribbon;
  80200. }
  80201. };
  80202. return RibbonBuilder;
  80203. }());
  80204. /***/ }),
  80205. /***/ "./Meshes/Builders/shapeBuilder.ts":
  80206. /*!*****************************************!*\
  80207. !*** ./Meshes/Builders/shapeBuilder.ts ***!
  80208. \*****************************************/
  80209. /*! exports provided: ShapeBuilder */
  80210. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80211. "use strict";
  80212. __webpack_require__.r(__webpack_exports__);
  80213. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return ShapeBuilder; });
  80214. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  80215. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80216. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  80217. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  80218. if (scene === void 0) { scene = null; }
  80219. var options = {
  80220. shape: shape,
  80221. path: path,
  80222. scale: scale,
  80223. rotation: rotation,
  80224. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  80225. sideOrientation: sideOrientation,
  80226. instance: instance,
  80227. updatable: updatable
  80228. };
  80229. return ShapeBuilder.ExtrudeShape(name, options, scene);
  80230. };
  80231. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  80232. var options = {
  80233. shape: shape,
  80234. path: path,
  80235. scaleFunction: scaleFunction,
  80236. rotationFunction: rotationFunction,
  80237. ribbonCloseArray: ribbonCloseArray,
  80238. ribbonClosePath: ribbonClosePath,
  80239. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  80240. sideOrientation: sideOrientation,
  80241. instance: instance,
  80242. updatable: updatable
  80243. };
  80244. return ShapeBuilder.ExtrudeShapeCustom(name, options, scene);
  80245. };
  80246. /**
  80247. * Class containing static functions to help procedurally build meshes
  80248. */
  80249. var ShapeBuilder = /** @class */ (function () {
  80250. function ShapeBuilder() {
  80251. }
  80252. /**
  80253. * 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.
  80254. * * 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.
  80255. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  80256. * * 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.
  80257. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  80258. * * 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
  80259. * * 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
  80260. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  80261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80262. * * 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
  80263. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  80264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  80265. * @param name defines the name of the mesh
  80266. * @param options defines the options used to create the mesh
  80267. * @param scene defines the hosting scene
  80268. * @returns the extruded shape mesh
  80269. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  80270. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  80271. */
  80272. ShapeBuilder.ExtrudeShape = function (name, options, scene) {
  80273. if (scene === void 0) { scene = null; }
  80274. var path = options.path;
  80275. var shape = options.shape;
  80276. var scale = options.scale || 1;
  80277. var rotation = options.rotation || 0;
  80278. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  80279. var updatable = options.updatable;
  80280. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80281. var instance = options.instance || null;
  80282. var invertUV = options.invertUV || false;
  80283. 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);
  80284. };
  80285. /**
  80286. * Creates an custom extruded shape mesh.
  80287. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  80288. * * 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.
  80289. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  80290. * * 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
  80291. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  80292. * * 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
  80293. * * It must returns a float value that will be the scale value applied to the shape on each path point
  80294. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  80295. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  80296. * * 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
  80297. * * 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
  80298. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  80299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80300. * * 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
  80301. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  80302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80303. * @param name defines the name of the mesh
  80304. * @param options defines the options used to create the mesh
  80305. * @param scene defines the hosting scene
  80306. * @returns the custom extruded shape mesh
  80307. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  80308. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  80309. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  80310. */
  80311. ShapeBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  80312. var path = options.path;
  80313. var shape = options.shape;
  80314. var scaleFunction = options.scaleFunction || (function () { return 1; });
  80315. var rotationFunction = options.rotationFunction || (function () { return 0; });
  80316. var ribbonCloseArray = options.ribbonCloseArray || false;
  80317. var ribbonClosePath = options.ribbonClosePath || false;
  80318. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  80319. var updatable = options.updatable;
  80320. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80321. var instance = options.instance;
  80322. var invertUV = options.invertUV || false;
  80323. 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);
  80324. };
  80325. ShapeBuilder._ExtrudeShapeGeneric = function (name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs) {
  80326. // extrusion geometry
  80327. var extrusionPathArray = function (shape, curve, path3D, shapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom) {
  80328. var tangents = path3D.getTangents();
  80329. var normals = path3D.getNormals();
  80330. var binormals = path3D.getBinormals();
  80331. var distances = path3D.getDistances();
  80332. var angle = 0;
  80333. var returnScale = function () { return scale !== null ? scale : 1; };
  80334. var returnRotation = function () { return rotation !== null ? rotation : 0; };
  80335. var rotate = custom && rotateFunction ? rotateFunction : returnRotation;
  80336. var scl = custom && scaleFunction ? scaleFunction : returnScale;
  80337. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  80338. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  80339. for (var i = 0; i < curve.length; i++) {
  80340. var shapePath = new Array();
  80341. var angleStep = rotate(i, distances[i]);
  80342. var scaleRatio = scl(i, distances[i]);
  80343. for (var p = 0; p < shape.length; p++) {
  80344. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], angle, rotationMatrix);
  80345. var planed = ((tangents[i].scale(shape[p].z)).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y)));
  80346. var rotated = shapePath[p] ? shapePath[p] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  80347. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(planed, rotationMatrix, rotated);
  80348. rotated.scaleInPlace(scaleRatio).addInPlace(curve[i]);
  80349. shapePath[p] = rotated;
  80350. }
  80351. shapePaths[index] = shapePath;
  80352. angle += angleStep;
  80353. index++;
  80354. }
  80355. // cap
  80356. var capPath = function (shapePath) {
  80357. var pointCap = Array();
  80358. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  80359. var i;
  80360. for (i = 0; i < shapePath.length; i++) {
  80361. barycenter.addInPlace(shapePath[i]);
  80362. }
  80363. barycenter.scaleInPlace(1.0 / shapePath.length);
  80364. for (i = 0; i < shapePath.length; i++) {
  80365. pointCap.push(barycenter);
  80366. }
  80367. return pointCap;
  80368. };
  80369. switch (cap) {
  80370. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  80371. break;
  80372. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  80373. shapePaths[0] = capPath(shapePaths[2]);
  80374. shapePaths[1] = shapePaths[2];
  80375. break;
  80376. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  80377. shapePaths[index] = shapePaths[index - 1];
  80378. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  80379. break;
  80380. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  80381. shapePaths[0] = capPath(shapePaths[2]);
  80382. shapePaths[1] = shapePaths[2];
  80383. shapePaths[index] = shapePaths[index - 1];
  80384. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  80385. break;
  80386. default:
  80387. break;
  80388. }
  80389. return shapePaths;
  80390. };
  80391. var path3D;
  80392. var pathArray;
  80393. if (instance) { // instance update
  80394. var storage = instance._creationDataStorage;
  80395. path3D = storage.path3D.update(curve);
  80396. pathArray = extrusionPathArray(shape, curve, storage.path3D, storage.pathArray, scale, rotation, scaleFunction, rotateFunction, storage.cap, custom);
  80397. instance = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon("", pathArray, false, false, 0, scene || undefined, false, 0, instance);
  80398. return instance;
  80399. }
  80400. // extruded shape creation
  80401. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](curve);
  80402. var newShapePaths = new Array();
  80403. cap = (cap < 0 || cap > 3) ? 0 : cap;
  80404. pathArray = extrusionPathArray(shape, curve, path3D, newShapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom);
  80405. 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);
  80406. extrudedGeneric._creationDataStorage.pathArray = pathArray;
  80407. extrudedGeneric._creationDataStorage.path3D = path3D;
  80408. extrudedGeneric._creationDataStorage.cap = cap;
  80409. return extrudedGeneric;
  80410. };
  80411. return ShapeBuilder;
  80412. }());
  80413. /***/ }),
  80414. /***/ "./Meshes/Builders/sphereBuilder.ts":
  80415. /*!******************************************!*\
  80416. !*** ./Meshes/Builders/sphereBuilder.ts ***!
  80417. \******************************************/
  80418. /*! exports provided: SphereBuilder */
  80419. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80420. "use strict";
  80421. __webpack_require__.r(__webpack_exports__);
  80422. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return SphereBuilder; });
  80423. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  80424. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80425. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80426. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere = function (options) {
  80427. var segments = options.segments || 32;
  80428. var diameterX = options.diameterX || options.diameter || 1;
  80429. var diameterY = options.diameterY || options.diameter || 1;
  80430. var diameterZ = options.diameterZ || options.diameter || 1;
  80431. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  80432. var slice = options.slice && (options.slice <= 0) ? 1.0 : options.slice || 1.0;
  80433. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  80434. var radius = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](diameterX / 2, diameterY / 2, diameterZ / 2);
  80435. var totalZRotationSteps = 2 + segments;
  80436. var totalYRotationSteps = 2 * totalZRotationSteps;
  80437. var indices = [];
  80438. var positions = [];
  80439. var normals = [];
  80440. var uvs = [];
  80441. for (var zRotationStep = 0; zRotationStep <= totalZRotationSteps; zRotationStep++) {
  80442. var normalizedZ = zRotationStep / totalZRotationSteps;
  80443. var angleZ = normalizedZ * Math.PI * slice;
  80444. for (var yRotationStep = 0; yRotationStep <= totalYRotationSteps; yRotationStep++) {
  80445. var normalizedY = yRotationStep / totalYRotationSteps;
  80446. var angleY = normalizedY * Math.PI * 2 * arc;
  80447. var rotationZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationZ(-angleZ);
  80448. var rotationY = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationY(angleY);
  80449. var afterRotZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), rotationZ);
  80450. var complete = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(afterRotZ, rotationY);
  80451. var vertex = complete.multiply(radius);
  80452. var normal = complete.divide(radius).normalize();
  80453. positions.push(vertex.x, vertex.y, vertex.z);
  80454. normals.push(normal.x, normal.y, normal.z);
  80455. uvs.push(normalizedY, normalizedZ);
  80456. }
  80457. if (zRotationStep > 0) {
  80458. var verticesCount = positions.length / 3;
  80459. for (var firstIndex = verticesCount - 2 * (totalYRotationSteps + 1); (firstIndex + totalYRotationSteps + 2) < verticesCount; firstIndex++) {
  80460. indices.push((firstIndex));
  80461. indices.push((firstIndex + 1));
  80462. indices.push(firstIndex + totalYRotationSteps + 1);
  80463. indices.push((firstIndex + totalYRotationSteps + 1));
  80464. indices.push((firstIndex + 1));
  80465. indices.push((firstIndex + totalYRotationSteps + 2));
  80466. }
  80467. }
  80468. }
  80469. // Sides
  80470. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  80471. // Result
  80472. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  80473. vertexData.indices = indices;
  80474. vertexData.positions = positions;
  80475. vertexData.normals = normals;
  80476. vertexData.uvs = uvs;
  80477. return vertexData;
  80478. };
  80479. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  80480. var options = {
  80481. segments: segments,
  80482. diameterX: diameter,
  80483. diameterY: diameter,
  80484. diameterZ: diameter,
  80485. sideOrientation: sideOrientation,
  80486. updatable: updatable
  80487. };
  80488. return SphereBuilder.CreateSphere(name, options, scene);
  80489. };
  80490. /**
  80491. * Class containing static functions to help procedurally build meshes
  80492. */
  80493. var SphereBuilder = /** @class */ (function () {
  80494. function SphereBuilder() {
  80495. }
  80496. /**
  80497. * Creates a sphere mesh
  80498. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  80499. * * 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`)
  80500. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  80501. * * 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
  80502. * * 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)
  80503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80504. * * 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
  80505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80506. * @param name defines the name of the mesh
  80507. * @param options defines the options used to create the mesh
  80508. * @param scene defines the hosting scene
  80509. * @returns the sphere mesh
  80510. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  80511. */
  80512. SphereBuilder.CreateSphere = function (name, options, scene) {
  80513. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  80514. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80515. sphere._originalBuilderSideOrientation = options.sideOrientation;
  80516. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere(options);
  80517. vertexData.applyToMesh(sphere, options.updatable);
  80518. return sphere;
  80519. };
  80520. return SphereBuilder;
  80521. }());
  80522. /***/ }),
  80523. /***/ "./Meshes/Builders/torusBuilder.ts":
  80524. /*!*****************************************!*\
  80525. !*** ./Meshes/Builders/torusBuilder.ts ***!
  80526. \*****************************************/
  80527. /*! exports provided: TorusBuilder */
  80528. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80529. "use strict";
  80530. __webpack_require__.r(__webpack_exports__);
  80531. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return TorusBuilder; });
  80532. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  80533. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80534. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80535. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus = function (options) {
  80536. var indices = [];
  80537. var positions = [];
  80538. var normals = [];
  80539. var uvs = [];
  80540. var diameter = options.diameter || 1;
  80541. var thickness = options.thickness || 0.5;
  80542. var tessellation = options.tessellation || 16;
  80543. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  80544. var stride = tessellation + 1;
  80545. for (var i = 0; i <= tessellation; i++) {
  80546. var u = i / tessellation;
  80547. var outerAngle = i * Math.PI * 2.0 / tessellation - Math.PI / 2.0;
  80548. 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));
  80549. for (var j = 0; j <= tessellation; j++) {
  80550. var v = 1 - j / tessellation;
  80551. var innerAngle = j * Math.PI * 2.0 / tessellation + Math.PI;
  80552. var dx = Math.cos(innerAngle);
  80553. var dy = Math.sin(innerAngle);
  80554. // Create a vertex.
  80555. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](dx, dy, 0);
  80556. var position = normal.scale(thickness / 2);
  80557. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](u, v);
  80558. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(position, transform);
  80559. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, transform);
  80560. positions.push(position.x, position.y, position.z);
  80561. normals.push(normal.x, normal.y, normal.z);
  80562. uvs.push(textureCoordinate.x, textureCoordinate.y);
  80563. // And create indices for two triangles.
  80564. var nextI = (i + 1) % stride;
  80565. var nextJ = (j + 1) % stride;
  80566. indices.push(i * stride + j);
  80567. indices.push(i * stride + nextJ);
  80568. indices.push(nextI * stride + j);
  80569. indices.push(i * stride + nextJ);
  80570. indices.push(nextI * stride + nextJ);
  80571. indices.push(nextI * stride + j);
  80572. }
  80573. }
  80574. // Sides
  80575. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  80576. // Result
  80577. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  80578. vertexData.indices = indices;
  80579. vertexData.positions = positions;
  80580. vertexData.normals = normals;
  80581. vertexData.uvs = uvs;
  80582. return vertexData;
  80583. };
  80584. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  80585. var options = {
  80586. diameter: diameter,
  80587. thickness: thickness,
  80588. tessellation: tessellation,
  80589. sideOrientation: sideOrientation,
  80590. updatable: updatable
  80591. };
  80592. return TorusBuilder.CreateTorus(name, options, scene);
  80593. };
  80594. /**
  80595. * Class containing static functions to help procedurally build meshes
  80596. */
  80597. var TorusBuilder = /** @class */ (function () {
  80598. function TorusBuilder() {
  80599. }
  80600. /**
  80601. * Creates a torus mesh
  80602. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  80603. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  80604. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  80605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80606. * * 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
  80607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  80608. * @param name defines the name of the mesh
  80609. * @param options defines the options used to create the mesh
  80610. * @param scene defines the hosting scene
  80611. * @returns the torus mesh
  80612. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  80613. */
  80614. TorusBuilder.CreateTorus = function (name, options, scene) {
  80615. var torus = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  80616. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80617. torus._originalBuilderSideOrientation = options.sideOrientation;
  80618. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus(options);
  80619. vertexData.applyToMesh(torus, options.updatable);
  80620. return torus;
  80621. };
  80622. return TorusBuilder;
  80623. }());
  80624. /***/ }),
  80625. /***/ "./Meshes/Builders/torusKnotBuilder.ts":
  80626. /*!*********************************************!*\
  80627. !*** ./Meshes/Builders/torusKnotBuilder.ts ***!
  80628. \*********************************************/
  80629. /*! exports provided: TorusKnotBuilder */
  80630. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80631. "use strict";
  80632. __webpack_require__.r(__webpack_exports__);
  80633. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return TorusKnotBuilder; });
  80634. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  80635. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80636. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80637. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot = function (options) {
  80638. var indices = new Array();
  80639. var positions = new Array();
  80640. var normals = new Array();
  80641. var uvs = new Array();
  80642. var radius = options.radius || 2;
  80643. var tube = options.tube || 0.5;
  80644. var radialSegments = options.radialSegments || 32;
  80645. var tubularSegments = options.tubularSegments || 32;
  80646. var p = options.p || 2;
  80647. var q = options.q || 3;
  80648. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  80649. // Helper
  80650. var getPos = function (angle) {
  80651. var cu = Math.cos(angle);
  80652. var su = Math.sin(angle);
  80653. var quOverP = q / p * angle;
  80654. var cs = Math.cos(quOverP);
  80655. var tx = radius * (2 + cs) * 0.5 * cu;
  80656. var ty = radius * (2 + cs) * su * 0.5;
  80657. var tz = radius * Math.sin(quOverP) * 0.5;
  80658. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](tx, ty, tz);
  80659. };
  80660. // Vertices
  80661. var i;
  80662. var j;
  80663. for (i = 0; i <= radialSegments; i++) {
  80664. var modI = i % radialSegments;
  80665. var u = modI / radialSegments * 2 * p * Math.PI;
  80666. var p1 = getPos(u);
  80667. var p2 = getPos(u + 0.01);
  80668. var tang = p2.subtract(p1);
  80669. var n = p2.add(p1);
  80670. var bitan = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(tang, n);
  80671. n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(bitan, tang);
  80672. bitan.normalize();
  80673. n.normalize();
  80674. for (j = 0; j < tubularSegments; j++) {
  80675. var modJ = j % tubularSegments;
  80676. var v = modJ / tubularSegments * 2 * Math.PI;
  80677. var cx = -tube * Math.cos(v);
  80678. var cy = tube * Math.sin(v);
  80679. positions.push(p1.x + cx * n.x + cy * bitan.x);
  80680. positions.push(p1.y + cx * n.y + cy * bitan.y);
  80681. positions.push(p1.z + cx * n.z + cy * bitan.z);
  80682. uvs.push(i / radialSegments);
  80683. uvs.push(j / tubularSegments);
  80684. }
  80685. }
  80686. for (i = 0; i < radialSegments; i++) {
  80687. for (j = 0; j < tubularSegments; j++) {
  80688. var jNext = (j + 1) % tubularSegments;
  80689. var a = i * tubularSegments + j;
  80690. var b = (i + 1) * tubularSegments + j;
  80691. var c = (i + 1) * tubularSegments + jNext;
  80692. var d = i * tubularSegments + jNext;
  80693. indices.push(d);
  80694. indices.push(b);
  80695. indices.push(a);
  80696. indices.push(d);
  80697. indices.push(c);
  80698. indices.push(b);
  80699. }
  80700. }
  80701. // Normals
  80702. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  80703. // Sides
  80704. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  80705. // Result
  80706. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  80707. vertexData.indices = indices;
  80708. vertexData.positions = positions;
  80709. vertexData.normals = normals;
  80710. vertexData.uvs = uvs;
  80711. return vertexData;
  80712. };
  80713. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  80714. var options = {
  80715. radius: radius,
  80716. tube: tube,
  80717. radialSegments: radialSegments,
  80718. tubularSegments: tubularSegments,
  80719. p: p,
  80720. q: q,
  80721. sideOrientation: sideOrientation,
  80722. updatable: updatable
  80723. };
  80724. return TorusKnotBuilder.CreateTorusKnot(name, options, scene);
  80725. };
  80726. /**
  80727. * Class containing static functions to help procedurally build meshes
  80728. */
  80729. var TorusKnotBuilder = /** @class */ (function () {
  80730. function TorusKnotBuilder() {
  80731. }
  80732. /**
  80733. * Creates a torus knot mesh
  80734. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  80735. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  80736. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  80737. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  80738. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80739. * * 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
  80740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  80741. * @param name defines the name of the mesh
  80742. * @param options defines the options used to create the mesh
  80743. * @param scene defines the hosting scene
  80744. * @returns the torus knot mesh
  80745. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  80746. */
  80747. TorusKnotBuilder.CreateTorusKnot = function (name, options, scene) {
  80748. var torusKnot = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  80749. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80750. torusKnot._originalBuilderSideOrientation = options.sideOrientation;
  80751. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot(options);
  80752. vertexData.applyToMesh(torusKnot, options.updatable);
  80753. return torusKnot;
  80754. };
  80755. return TorusKnotBuilder;
  80756. }());
  80757. /***/ }),
  80758. /***/ "./Meshes/Builders/tubeBuilder.ts":
  80759. /*!****************************************!*\
  80760. !*** ./Meshes/Builders/tubeBuilder.ts ***!
  80761. \****************************************/
  80762. /*! exports provided: TubeBuilder */
  80763. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80764. "use strict";
  80765. __webpack_require__.r(__webpack_exports__);
  80766. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return TubeBuilder; });
  80767. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  80768. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80769. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  80770. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  80771. var options = {
  80772. path: path,
  80773. radius: radius,
  80774. tessellation: tessellation,
  80775. radiusFunction: radiusFunction,
  80776. arc: 1,
  80777. cap: cap,
  80778. updatable: updatable,
  80779. sideOrientation: sideOrientation,
  80780. instance: instance
  80781. };
  80782. return TubeBuilder.CreateTube(name, options, scene);
  80783. };
  80784. /**
  80785. * Class containing static functions to help procedurally build meshes
  80786. */
  80787. var TubeBuilder = /** @class */ (function () {
  80788. function TubeBuilder() {
  80789. }
  80790. /**
  80791. * Creates a tube mesh.
  80792. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  80793. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  80794. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  80795. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  80796. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  80797. * * 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)
  80798. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  80799. * * 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
  80800. * * 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
  80801. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80802. * * 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
  80803. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  80804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80805. * @param name defines the name of the mesh
  80806. * @param options defines the options used to create the mesh
  80807. * @param scene defines the hosting scene
  80808. * @returns the tube mesh
  80809. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  80810. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  80811. */
  80812. TubeBuilder.CreateTube = function (name, options, scene) {
  80813. var path = options.path;
  80814. var instance = options.instance;
  80815. var radius = 1.0;
  80816. if (options.radius !== undefined) {
  80817. radius = options.radius;
  80818. }
  80819. else if (instance) {
  80820. radius = instance._creationDataStorage.radius;
  80821. }
  80822. var tessellation = options.tessellation || 64 | 0;
  80823. var radiusFunction = options.radiusFunction || null;
  80824. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  80825. var invertUV = options.invertUV || false;
  80826. var updatable = options.updatable;
  80827. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80828. options.arc = options.arc && (options.arc <= 0.0 || options.arc > 1.0) ? 1.0 : options.arc || 1.0;
  80829. // tube geometry
  80830. var tubePathArray = function (path, path3D, circlePaths, radius, tessellation, radiusFunction, cap, arc) {
  80831. var tangents = path3D.getTangents();
  80832. var normals = path3D.getNormals();
  80833. var distances = path3D.getDistances();
  80834. var pi2 = Math.PI * 2;
  80835. var step = pi2 / tessellation * arc;
  80836. var returnRadius = function () { return radius; };
  80837. var radiusFunctionFinal = radiusFunction || returnRadius;
  80838. var circlePath;
  80839. var rad;
  80840. var normal;
  80841. var rotated;
  80842. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  80843. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  80844. for (var i = 0; i < path.length; i++) {
  80845. rad = radiusFunctionFinal(i, distances[i]); // current radius
  80846. circlePath = Array(); // current circle array
  80847. normal = normals[i]; // current normal
  80848. for (var t = 0; t < tessellation; t++) {
  80849. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], step * t, rotationMatrix);
  80850. rotated = circlePath[t] ? circlePath[t] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  80851. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(normal, rotationMatrix, rotated);
  80852. rotated.scaleInPlace(rad).addInPlace(path[i]);
  80853. circlePath[t] = rotated;
  80854. }
  80855. circlePaths[index] = circlePath;
  80856. index++;
  80857. }
  80858. // cap
  80859. var capPath = function (nbPoints, pathIndex) {
  80860. var pointCap = Array();
  80861. for (var i = 0; i < nbPoints; i++) {
  80862. pointCap.push(path[pathIndex]);
  80863. }
  80864. return pointCap;
  80865. };
  80866. switch (cap) {
  80867. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  80868. break;
  80869. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  80870. circlePaths[0] = capPath(tessellation, 0);
  80871. circlePaths[1] = circlePaths[2].slice(0);
  80872. break;
  80873. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  80874. circlePaths[index] = circlePaths[index - 1].slice(0);
  80875. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  80876. break;
  80877. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  80878. circlePaths[0] = capPath(tessellation, 0);
  80879. circlePaths[1] = circlePaths[2].slice(0);
  80880. circlePaths[index] = circlePaths[index - 1].slice(0);
  80881. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  80882. break;
  80883. default:
  80884. break;
  80885. }
  80886. return circlePaths;
  80887. };
  80888. var path3D;
  80889. var pathArray;
  80890. if (instance) { // tube update
  80891. var storage = instance._creationDataStorage;
  80892. var arc = options.arc || storage.arc;
  80893. path3D = storage.path3D.update(path);
  80894. pathArray = tubePathArray(path, path3D, storage.pathArray, radius, storage.tessellation, radiusFunction, storage.cap, arc);
  80895. instance = _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"].CreateRibbon("", { pathArray: pathArray, instance: instance });
  80896. // Update mode, no need to recreate the storage.
  80897. storage.path3D = path3D;
  80898. storage.pathArray = pathArray;
  80899. storage.arc = arc;
  80900. storage.radius = radius;
  80901. return instance;
  80902. }
  80903. // tube creation
  80904. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](path);
  80905. var newPathArray = new Array();
  80906. cap = (cap < 0 || cap > 3) ? 0 : cap;
  80907. pathArray = tubePathArray(path, path3D, newPathArray, radius, tessellation, radiusFunction, cap, options.arc);
  80908. 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);
  80909. tube._creationDataStorage.pathArray = pathArray;
  80910. tube._creationDataStorage.path3D = path3D;
  80911. tube._creationDataStorage.tessellation = tessellation;
  80912. tube._creationDataStorage.cap = cap;
  80913. tube._creationDataStorage.arc = options.arc;
  80914. tube._creationDataStorage.radius = radius;
  80915. return tube;
  80916. };
  80917. return TubeBuilder;
  80918. }());
  80919. /***/ }),
  80920. /***/ "./Meshes/Compression/dracoCompression.ts":
  80921. /*!************************************************!*\
  80922. !*** ./Meshes/Compression/dracoCompression.ts ***!
  80923. \************************************************/
  80924. /*! exports provided: DracoCompression */
  80925. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80926. "use strict";
  80927. __webpack_require__.r(__webpack_exports__);
  80928. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return DracoCompression; });
  80929. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  80930. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80931. /**
  80932. * Draco compression (https://google.github.io/draco/)
  80933. *
  80934. * This class wraps the Draco module.
  80935. *
  80936. * **Encoder**
  80937. *
  80938. * The encoder is not currently implemented.
  80939. *
  80940. * **Decoder**
  80941. *
  80942. * 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.
  80943. *
  80944. * To update the configuration, use the following code:
  80945. * ```javascript
  80946. * DracoCompression.Configuration = {
  80947. * decoder: {
  80948. * wasmUrl: "<url to the WebAssembly library>",
  80949. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  80950. * fallbackUrl: "<url to the fallback JavaScript library>",
  80951. * }
  80952. * };
  80953. * ```
  80954. *
  80955. * 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.
  80956. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  80957. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  80958. *
  80959. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  80960. * ```javascript
  80961. * var dracoCompression = new DracoCompression();
  80962. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  80963. * [VertexBuffer.PositionKind]: 0
  80964. * });
  80965. * ```
  80966. *
  80967. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  80968. */
  80969. var DracoCompression = /** @class */ (function () {
  80970. /**
  80971. * Constructor
  80972. */
  80973. function DracoCompression() {
  80974. }
  80975. Object.defineProperty(DracoCompression, "DecoderAvailable", {
  80976. /**
  80977. * Returns true if the decoder is available.
  80978. */
  80979. get: function () {
  80980. if (typeof DracoDecoderModule !== "undefined") {
  80981. return true;
  80982. }
  80983. var decoder = DracoCompression.Configuration.decoder;
  80984. if (decoder) {
  80985. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  80986. return true;
  80987. }
  80988. if (decoder.fallbackUrl) {
  80989. return true;
  80990. }
  80991. }
  80992. return false;
  80993. },
  80994. enumerable: true,
  80995. configurable: true
  80996. });
  80997. /**
  80998. * Stop all async operations and release resources.
  80999. */
  81000. DracoCompression.prototype.dispose = function () {
  81001. };
  81002. /**
  81003. * Decode Draco compressed mesh data to vertex data.
  81004. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  81005. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  81006. * @returns A promise that resolves with the decoded vertex data
  81007. */
  81008. DracoCompression.prototype.decodeMeshAsync = function (data, attributes) {
  81009. var dataView = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
  81010. return DracoCompression._GetDecoderModule().then(function (wrappedModule) {
  81011. var module = wrappedModule.module;
  81012. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  81013. var buffer = new module.DecoderBuffer();
  81014. buffer.Init(dataView, dataView.byteLength);
  81015. var decoder = new module.Decoder();
  81016. var geometry;
  81017. var status;
  81018. try {
  81019. var type = decoder.GetEncodedGeometryType(buffer);
  81020. switch (type) {
  81021. case module.TRIANGULAR_MESH:
  81022. geometry = new module.Mesh();
  81023. status = decoder.DecodeBufferToMesh(buffer, geometry);
  81024. break;
  81025. case module.POINT_CLOUD:
  81026. geometry = new module.PointCloud();
  81027. status = decoder.DecodeBufferToPointCloud(buffer, geometry);
  81028. break;
  81029. default:
  81030. throw new Error("Invalid geometry type " + type);
  81031. }
  81032. if (!status.ok() || !geometry.ptr) {
  81033. throw new Error(status.error_msg());
  81034. }
  81035. var numPoints = geometry.num_points();
  81036. if (type === module.TRIANGULAR_MESH) {
  81037. var numFaces = geometry.num_faces();
  81038. var faceIndices = new module.DracoInt32Array();
  81039. try {
  81040. var indices = new Uint32Array(numFaces * 3);
  81041. for (var i = 0; i < numFaces; i++) {
  81042. decoder.GetFaceFromMesh(geometry, i, faceIndices);
  81043. var offset = i * 3;
  81044. indices[offset + 0] = faceIndices.GetValue(0);
  81045. indices[offset + 1] = faceIndices.GetValue(1);
  81046. indices[offset + 2] = faceIndices.GetValue(2);
  81047. }
  81048. vertexData.indices = indices;
  81049. }
  81050. finally {
  81051. module.destroy(faceIndices);
  81052. }
  81053. }
  81054. for (var kind in attributes) {
  81055. var uniqueId = attributes[kind];
  81056. var attribute = decoder.GetAttributeByUniqueId(geometry, uniqueId);
  81057. var dracoData = new module.DracoFloat32Array();
  81058. try {
  81059. decoder.GetAttributeFloatForAllPoints(geometry, attribute, dracoData);
  81060. var babylonData = new Float32Array(numPoints * attribute.num_components());
  81061. for (var i = 0; i < babylonData.length; i++) {
  81062. babylonData[i] = dracoData.GetValue(i);
  81063. }
  81064. vertexData.set(babylonData, kind);
  81065. }
  81066. finally {
  81067. module.destroy(dracoData);
  81068. }
  81069. }
  81070. }
  81071. finally {
  81072. if (geometry) {
  81073. module.destroy(geometry);
  81074. }
  81075. module.destroy(decoder);
  81076. module.destroy(buffer);
  81077. }
  81078. return vertexData;
  81079. });
  81080. };
  81081. DracoCompression._GetDecoderModule = function () {
  81082. if (!DracoCompression._DecoderModulePromise) {
  81083. var promise = null;
  81084. var config_1 = {};
  81085. if (typeof DracoDecoderModule !== "undefined") {
  81086. promise = Promise.resolve();
  81087. }
  81088. else {
  81089. var decoder = DracoCompression.Configuration.decoder;
  81090. if (decoder) {
  81091. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  81092. promise = Promise.all([
  81093. DracoCompression._LoadScriptAsync(decoder.wasmUrl),
  81094. DracoCompression._LoadFileAsync(decoder.wasmBinaryUrl).then(function (data) {
  81095. config_1.wasmBinary = data;
  81096. })
  81097. ]);
  81098. }
  81099. else if (decoder.fallbackUrl) {
  81100. promise = DracoCompression._LoadScriptAsync(decoder.fallbackUrl);
  81101. }
  81102. }
  81103. }
  81104. if (!promise) {
  81105. throw new Error("Draco decoder module is not available");
  81106. }
  81107. DracoCompression._DecoderModulePromise = promise.then(function () {
  81108. return new Promise(function (resolve) {
  81109. config_1.onModuleLoaded = function (decoderModule) {
  81110. // decoderModule is Promise-like. Wrap before resolving to avoid loop.
  81111. resolve({ module: decoderModule });
  81112. };
  81113. DracoDecoderModule(config_1);
  81114. });
  81115. });
  81116. }
  81117. return DracoCompression._DecoderModulePromise;
  81118. };
  81119. DracoCompression._LoadScriptAsync = function (url) {
  81120. return new Promise(function (resolve, reject) {
  81121. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadScript(url, function () {
  81122. resolve();
  81123. }, function (message) {
  81124. reject(new Error(message));
  81125. });
  81126. });
  81127. };
  81128. DracoCompression._LoadFileAsync = function (url) {
  81129. return new Promise(function (resolve, reject) {
  81130. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(url, function (data) {
  81131. resolve(data);
  81132. }, undefined, undefined, true, function (request, exception) {
  81133. reject(exception);
  81134. });
  81135. });
  81136. };
  81137. /**
  81138. * The configuration. Defaults to the following urls:
  81139. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  81140. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  81141. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  81142. */
  81143. DracoCompression.Configuration = {
  81144. decoder: {
  81145. wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js",
  81146. wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm",
  81147. fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  81148. }
  81149. };
  81150. return DracoCompression;
  81151. }());
  81152. /***/ }),
  81153. /***/ "./Meshes/Compression/index.ts":
  81154. /*!*************************************!*\
  81155. !*** ./Meshes/Compression/index.ts ***!
  81156. \*************************************/
  81157. /*! exports provided: DracoCompression */
  81158. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81159. "use strict";
  81160. __webpack_require__.r(__webpack_exports__);
  81161. /* harmony import */ var _dracoCompression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dracoCompression */ "./Meshes/Compression/dracoCompression.ts");
  81162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _dracoCompression__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  81163. /***/ }),
  81164. /***/ "./Meshes/abstractMesh.ts":
  81165. /*!********************************!*\
  81166. !*** ./Meshes/abstractMesh.ts ***!
  81167. \********************************/
  81168. /*! exports provided: AbstractMesh */
  81169. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81170. "use strict";
  81171. __webpack_require__.r(__webpack_exports__);
  81172. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return AbstractMesh; });
  81173. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  81174. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  81175. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  81176. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  81177. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  81178. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  81179. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  81180. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  81181. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  81182. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  81183. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  81184. /** @hidden */
  81185. var _FacetDataStorage = /** @class */ (function () {
  81186. function _FacetDataStorage() {
  81187. this.facetNb = 0; // facet number
  81188. this.partitioningSubdivisions = 10; // number of subdivisions per axis in the partioning space
  81189. this.partitioningBBoxRatio = 1.01; // the partioning array space is by default 1% bigger than the bounding box
  81190. this.facetDataEnabled = false; // is the facet data feature enabled on this mesh ?
  81191. this.facetParameters = {}; // keep a reference to the object parameters to avoid memory re-allocation
  81192. this.bbSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(); // bbox size approximated for facet data
  81193. this.subDiv = {
  81194. max: 1,
  81195. X: 1,
  81196. Y: 1,
  81197. Z: 1
  81198. };
  81199. this.facetDepthSort = false; // is the facet depth sort to be computed
  81200. this.facetDepthSortEnabled = false; // is the facet depth sort initialized
  81201. }
  81202. return _FacetDataStorage;
  81203. }());
  81204. /**
  81205. * Class used to store all common mesh properties
  81206. */
  81207. var AbstractMesh = /** @class */ (function (_super) {
  81208. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractMesh, _super);
  81209. // Constructor
  81210. /**
  81211. * Creates a new AbstractMesh
  81212. * @param name defines the name of the mesh
  81213. * @param scene defines the hosting scene
  81214. */
  81215. function AbstractMesh(name, scene) {
  81216. if (scene === void 0) { scene = null; }
  81217. var _this = _super.call(this, name, scene, false) || this;
  81218. _this._facetData = new _FacetDataStorage();
  81219. /**
  81220. * The culling strategy to use to check whether the mesh must be rendered or not.
  81221. * This value can be changed at any time and will be used on the next render mesh selection.
  81222. * The possible values are :
  81223. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  81224. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  81225. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  81226. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  81227. * Please read each static variable documentation to get details about the culling process.
  81228. * */
  81229. _this.cullingStrategy = AbstractMesh.CULLINGSTRATEGY_STANDARD;
  81230. // Events
  81231. /**
  81232. * An event triggered when this mesh collides with another one
  81233. */
  81234. _this.onCollideObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  81235. /**
  81236. * An event triggered when the collision's position changes
  81237. */
  81238. _this.onCollisionPositionChangeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  81239. /**
  81240. * An event triggered when material is changed
  81241. */
  81242. _this.onMaterialChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  81243. // Properties
  81244. /**
  81245. * Gets or sets the orientation for POV movement & rotation
  81246. */
  81247. _this.definedFacingForward = true;
  81248. _this._visibility = 1.0;
  81249. /** Gets or sets the alpha index used to sort transparent meshes
  81250. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  81251. */
  81252. _this.alphaIndex = Number.MAX_VALUE;
  81253. /**
  81254. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  81255. */
  81256. _this.isVisible = true;
  81257. /**
  81258. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  81259. */
  81260. _this.isPickable = true;
  81261. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  81262. _this.showSubMeshesBoundingBox = false;
  81263. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  81264. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  81265. */
  81266. _this.isBlocker = false;
  81267. /**
  81268. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  81269. */
  81270. _this.enablePointerMoveEvents = false;
  81271. /**
  81272. * Specifies the rendering group id for this mesh (0 by default)
  81273. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  81274. */
  81275. _this.renderingGroupId = 0;
  81276. _this._receiveShadows = false;
  81277. /** Defines color to use when rendering outline */
  81278. _this.outlineColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  81279. /** Define width to use when rendering outline */
  81280. _this.outlineWidth = 0.02;
  81281. /** Defines color to use when rendering overlay */
  81282. _this.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  81283. /** Defines alpha to use when rendering overlay */
  81284. _this.overlayAlpha = 0.5;
  81285. _this._hasVertexAlpha = false;
  81286. _this._useVertexColors = true;
  81287. _this._computeBonesUsingShaders = true;
  81288. _this._numBoneInfluencers = 4;
  81289. _this._applyFog = true;
  81290. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  81291. _this.useOctreeForRenderingSelection = true;
  81292. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  81293. _this.useOctreeForPicking = true;
  81294. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  81295. _this.useOctreeForCollisions = true;
  81296. _this._layerMask = 0x0FFFFFFF;
  81297. /**
  81298. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  81299. */
  81300. _this.alwaysSelectAsActiveMesh = false;
  81301. /**
  81302. * Gets or sets the current action manager
  81303. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81304. */
  81305. _this.actionManager = null;
  81306. // Collisions
  81307. _this._checkCollisions = false;
  81308. _this._collisionMask = -1;
  81309. _this._collisionGroup = -1;
  81310. /**
  81311. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  81312. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81313. */
  81314. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 1, 0.5);
  81315. /**
  81316. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  81317. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81318. */
  81319. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  81320. _this._oldPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  81321. _this._diffPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  81322. // Edges
  81323. /**
  81324. * Defines edge width used when edgesRenderer is enabled
  81325. * @see https://www.babylonjs-playground.com/#10OJSG#13
  81326. */
  81327. _this.edgesWidth = 1;
  81328. /**
  81329. * Defines edge color used when edgesRenderer is enabled
  81330. * @see https://www.babylonjs-playground.com/#10OJSG#13
  81331. */
  81332. _this.edgesColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](1, 0, 0, 1);
  81333. /** @hidden */
  81334. _this._renderId = 0;
  81335. /** @hidden */
  81336. _this._intersectionsInProgress = new Array();
  81337. /** @hidden */
  81338. _this._unIndexed = false;
  81339. /** @hidden */
  81340. _this._lightSources = new Array();
  81341. /**
  81342. * An event triggered when the mesh is rebuilt.
  81343. */
  81344. _this.onRebuildObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  81345. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  81346. if (collidedMesh === void 0) { collidedMesh = null; }
  81347. newPosition.subtractToRef(_this._oldPositionForCollisions, _this._diffPositionForCollisions);
  81348. if (_this._diffPositionForCollisions.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].CollisionsEpsilon) {
  81349. _this.position.addInPlace(_this._diffPositionForCollisions);
  81350. }
  81351. if (collidedMesh) {
  81352. _this.onCollideObservable.notifyObservers(collidedMesh);
  81353. }
  81354. _this.onCollisionPositionChangeObservable.notifyObservers(_this.position);
  81355. };
  81356. _this.getScene().addMesh(_this);
  81357. _this._resyncLightSources();
  81358. return _this;
  81359. }
  81360. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_NONE", {
  81361. /**
  81362. * No billboard
  81363. */
  81364. get: function () {
  81365. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE;
  81366. },
  81367. enumerable: true,
  81368. configurable: true
  81369. });
  81370. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_X", {
  81371. /** Billboard on X axis */
  81372. get: function () {
  81373. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_X;
  81374. },
  81375. enumerable: true,
  81376. configurable: true
  81377. });
  81378. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Y", {
  81379. /** Billboard on Y axis */
  81380. get: function () {
  81381. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Y;
  81382. },
  81383. enumerable: true,
  81384. configurable: true
  81385. });
  81386. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Z", {
  81387. /** Billboard on Z axis */
  81388. get: function () {
  81389. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Z;
  81390. },
  81391. enumerable: true,
  81392. configurable: true
  81393. });
  81394. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_ALL", {
  81395. /** Billboard on all axes */
  81396. get: function () {
  81397. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_ALL;
  81398. },
  81399. enumerable: true,
  81400. configurable: true
  81401. });
  81402. Object.defineProperty(AbstractMesh.prototype, "facetNb", {
  81403. /**
  81404. * Gets the number of facets in the mesh
  81405. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  81406. */
  81407. get: function () {
  81408. return this._facetData.facetNb;
  81409. },
  81410. enumerable: true,
  81411. configurable: true
  81412. });
  81413. Object.defineProperty(AbstractMesh.prototype, "partitioningSubdivisions", {
  81414. /**
  81415. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  81416. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  81417. */
  81418. get: function () {
  81419. return this._facetData.partitioningSubdivisions;
  81420. },
  81421. set: function (nb) {
  81422. this._facetData.partitioningSubdivisions = nb;
  81423. },
  81424. enumerable: true,
  81425. configurable: true
  81426. });
  81427. Object.defineProperty(AbstractMesh.prototype, "partitioningBBoxRatio", {
  81428. /**
  81429. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  81430. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  81431. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  81432. */
  81433. get: function () {
  81434. return this._facetData.partitioningBBoxRatio;
  81435. },
  81436. set: function (ratio) {
  81437. this._facetData.partitioningBBoxRatio = ratio;
  81438. },
  81439. enumerable: true,
  81440. configurable: true
  81441. });
  81442. Object.defineProperty(AbstractMesh.prototype, "mustDepthSortFacets", {
  81443. /**
  81444. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  81445. * Works only for updatable meshes.
  81446. * Doesn't work with multi-materials
  81447. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  81448. */
  81449. get: function () {
  81450. return this._facetData.facetDepthSort;
  81451. },
  81452. set: function (sort) {
  81453. this._facetData.facetDepthSort = sort;
  81454. },
  81455. enumerable: true,
  81456. configurable: true
  81457. });
  81458. Object.defineProperty(AbstractMesh.prototype, "facetDepthSortFrom", {
  81459. /**
  81460. * The location (Vector3) where the facet depth sort must be computed from.
  81461. * By default, the active camera position.
  81462. * Used only when facet depth sort is enabled
  81463. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  81464. */
  81465. get: function () {
  81466. return this._facetData.facetDepthSortFrom;
  81467. },
  81468. set: function (location) {
  81469. this._facetData.facetDepthSortFrom = location;
  81470. },
  81471. enumerable: true,
  81472. configurable: true
  81473. });
  81474. Object.defineProperty(AbstractMesh.prototype, "isFacetDataEnabled", {
  81475. /**
  81476. * gets a boolean indicating if facetData is enabled
  81477. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  81478. */
  81479. get: function () {
  81480. return this._facetData.facetDataEnabled;
  81481. },
  81482. enumerable: true,
  81483. configurable: true
  81484. });
  81485. /** @hidden */
  81486. AbstractMesh.prototype._updateNonUniformScalingState = function (value) {
  81487. if (!_super.prototype._updateNonUniformScalingState.call(this, value)) {
  81488. return false;
  81489. }
  81490. this._markSubMeshesAsMiscDirty();
  81491. return true;
  81492. };
  81493. Object.defineProperty(AbstractMesh.prototype, "onCollide", {
  81494. /** Set a function to call when this mesh collides with another one */
  81495. set: function (callback) {
  81496. if (this._onCollideObserver) {
  81497. this.onCollideObservable.remove(this._onCollideObserver);
  81498. }
  81499. this._onCollideObserver = this.onCollideObservable.add(callback);
  81500. },
  81501. enumerable: true,
  81502. configurable: true
  81503. });
  81504. Object.defineProperty(AbstractMesh.prototype, "onCollisionPositionChange", {
  81505. /** Set a function to call when the collision's position changes */
  81506. set: function (callback) {
  81507. if (this._onCollisionPositionChangeObserver) {
  81508. this.onCollisionPositionChangeObservable.remove(this._onCollisionPositionChangeObserver);
  81509. }
  81510. this._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(callback);
  81511. },
  81512. enumerable: true,
  81513. configurable: true
  81514. });
  81515. Object.defineProperty(AbstractMesh.prototype, "visibility", {
  81516. /**
  81517. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  81518. */
  81519. get: function () {
  81520. return this._visibility;
  81521. },
  81522. /**
  81523. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  81524. */
  81525. set: function (value) {
  81526. if (this._visibility === value) {
  81527. return;
  81528. }
  81529. this._visibility = value;
  81530. this._markSubMeshesAsMiscDirty();
  81531. },
  81532. enumerable: true,
  81533. configurable: true
  81534. });
  81535. Object.defineProperty(AbstractMesh.prototype, "material", {
  81536. /** Gets or sets current material */
  81537. get: function () {
  81538. return this._material;
  81539. },
  81540. set: function (value) {
  81541. if (this._material === value) {
  81542. return;
  81543. }
  81544. // remove from material mesh map id needed
  81545. if (this._material && this._material.meshMap) {
  81546. this._material.meshMap[this.uniqueId] = undefined;
  81547. }
  81548. this._material = value;
  81549. if (value && value.meshMap) {
  81550. value.meshMap[this.uniqueId] = this;
  81551. }
  81552. if (this.onMaterialChangedObservable.hasObservers) {
  81553. this.onMaterialChangedObservable.notifyObservers(this);
  81554. }
  81555. if (!this.subMeshes) {
  81556. return;
  81557. }
  81558. this._unBindEffect();
  81559. },
  81560. enumerable: true,
  81561. configurable: true
  81562. });
  81563. Object.defineProperty(AbstractMesh.prototype, "receiveShadows", {
  81564. /**
  81565. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  81566. * @see http://doc.babylonjs.com/babylon101/shadows
  81567. */
  81568. get: function () {
  81569. return this._receiveShadows;
  81570. },
  81571. set: function (value) {
  81572. if (this._receiveShadows === value) {
  81573. return;
  81574. }
  81575. this._receiveShadows = value;
  81576. this._markSubMeshesAsLightDirty();
  81577. },
  81578. enumerable: true,
  81579. configurable: true
  81580. });
  81581. Object.defineProperty(AbstractMesh.prototype, "hasVertexAlpha", {
  81582. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  81583. get: function () {
  81584. return this._hasVertexAlpha;
  81585. },
  81586. set: function (value) {
  81587. if (this._hasVertexAlpha === value) {
  81588. return;
  81589. }
  81590. this._hasVertexAlpha = value;
  81591. this._markSubMeshesAsAttributesDirty();
  81592. this._markSubMeshesAsMiscDirty();
  81593. },
  81594. enumerable: true,
  81595. configurable: true
  81596. });
  81597. Object.defineProperty(AbstractMesh.prototype, "useVertexColors", {
  81598. /** 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) */
  81599. get: function () {
  81600. return this._useVertexColors;
  81601. },
  81602. set: function (value) {
  81603. if (this._useVertexColors === value) {
  81604. return;
  81605. }
  81606. this._useVertexColors = value;
  81607. this._markSubMeshesAsAttributesDirty();
  81608. },
  81609. enumerable: true,
  81610. configurable: true
  81611. });
  81612. Object.defineProperty(AbstractMesh.prototype, "computeBonesUsingShaders", {
  81613. /**
  81614. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  81615. */
  81616. get: function () {
  81617. return this._computeBonesUsingShaders;
  81618. },
  81619. set: function (value) {
  81620. if (this._computeBonesUsingShaders === value) {
  81621. return;
  81622. }
  81623. this._computeBonesUsingShaders = value;
  81624. this._markSubMeshesAsAttributesDirty();
  81625. },
  81626. enumerable: true,
  81627. configurable: true
  81628. });
  81629. Object.defineProperty(AbstractMesh.prototype, "numBoneInfluencers", {
  81630. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  81631. get: function () {
  81632. return this._numBoneInfluencers;
  81633. },
  81634. set: function (value) {
  81635. if (this._numBoneInfluencers === value) {
  81636. return;
  81637. }
  81638. this._numBoneInfluencers = value;
  81639. this._markSubMeshesAsAttributesDirty();
  81640. },
  81641. enumerable: true,
  81642. configurable: true
  81643. });
  81644. Object.defineProperty(AbstractMesh.prototype, "applyFog", {
  81645. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  81646. get: function () {
  81647. return this._applyFog;
  81648. },
  81649. set: function (value) {
  81650. if (this._applyFog === value) {
  81651. return;
  81652. }
  81653. this._applyFog = value;
  81654. this._markSubMeshesAsMiscDirty();
  81655. },
  81656. enumerable: true,
  81657. configurable: true
  81658. });
  81659. Object.defineProperty(AbstractMesh.prototype, "layerMask", {
  81660. /**
  81661. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  81662. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  81663. */
  81664. get: function () {
  81665. return this._layerMask;
  81666. },
  81667. set: function (value) {
  81668. if (value === this._layerMask) {
  81669. return;
  81670. }
  81671. this._layerMask = value;
  81672. this._resyncLightSources();
  81673. },
  81674. enumerable: true,
  81675. configurable: true
  81676. });
  81677. Object.defineProperty(AbstractMesh.prototype, "collisionMask", {
  81678. /**
  81679. * Gets or sets a collision mask used to mask collisions (default is -1).
  81680. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  81681. */
  81682. get: function () {
  81683. return this._collisionMask;
  81684. },
  81685. set: function (mask) {
  81686. this._collisionMask = !isNaN(mask) ? mask : -1;
  81687. },
  81688. enumerable: true,
  81689. configurable: true
  81690. });
  81691. Object.defineProperty(AbstractMesh.prototype, "collisionGroup", {
  81692. /**
  81693. * Gets or sets the current collision group mask (-1 by default).
  81694. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  81695. */
  81696. get: function () {
  81697. return this._collisionGroup;
  81698. },
  81699. set: function (mask) {
  81700. this._collisionGroup = !isNaN(mask) ? mask : -1;
  81701. },
  81702. enumerable: true,
  81703. configurable: true
  81704. });
  81705. Object.defineProperty(AbstractMesh.prototype, "_positions", {
  81706. /** @hidden */
  81707. get: function () {
  81708. return null;
  81709. },
  81710. enumerable: true,
  81711. configurable: true
  81712. });
  81713. Object.defineProperty(AbstractMesh.prototype, "skeleton", {
  81714. get: function () {
  81715. return this._skeleton;
  81716. },
  81717. /**
  81718. * Gets or sets a skeleton to apply skining transformations
  81719. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81720. */
  81721. set: function (value) {
  81722. if (this._skeleton && this._skeleton.needInitialSkinMatrix) {
  81723. this._skeleton._unregisterMeshWithPoseMatrix(this);
  81724. }
  81725. if (value && value.needInitialSkinMatrix) {
  81726. value._registerMeshWithPoseMatrix(this);
  81727. }
  81728. this._skeleton = value;
  81729. if (!this._skeleton) {
  81730. this._bonesTransformMatrices = null;
  81731. }
  81732. this._markSubMeshesAsAttributesDirty();
  81733. },
  81734. enumerable: true,
  81735. configurable: true
  81736. });
  81737. /**
  81738. * Returns the string "AbstractMesh"
  81739. * @returns "AbstractMesh"
  81740. */
  81741. AbstractMesh.prototype.getClassName = function () {
  81742. return "AbstractMesh";
  81743. };
  81744. /**
  81745. * Gets a string representation of the current mesh
  81746. * @param fullDetails defines a boolean indicating if full details must be included
  81747. * @returns a string representation of the current mesh
  81748. */
  81749. AbstractMesh.prototype.toString = function (fullDetails) {
  81750. var ret = "Name: " + this.name + ", isInstance: " + (this.getClassName() !== "InstancedMesh" ? "YES" : "NO");
  81751. ret += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
  81752. if (this._skeleton) {
  81753. ret += ", skeleton: " + this._skeleton.name;
  81754. }
  81755. if (fullDetails) {
  81756. ret += ", billboard mode: " + (["NONE", "X", "Y", null, "Z", null, null, "ALL"])[this.billboardMode];
  81757. ret += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingFreezeWorldMatrix ? "YES" : "NO");
  81758. }
  81759. return ret;
  81760. };
  81761. /** @hidden */
  81762. AbstractMesh.prototype._getActionManagerForTrigger = function (trigger, initialCall) {
  81763. if (initialCall === void 0) { initialCall = true; }
  81764. if (this.actionManager && (initialCall || this.actionManager.isRecursive)) {
  81765. if (trigger) {
  81766. if (this.actionManager.hasSpecificTrigger(trigger)) {
  81767. return this.actionManager;
  81768. }
  81769. }
  81770. else {
  81771. return this.actionManager;
  81772. }
  81773. }
  81774. if (!this.parent) {
  81775. return null;
  81776. }
  81777. return this.parent._getActionManagerForTrigger(trigger, false);
  81778. };
  81779. /** @hidden */
  81780. AbstractMesh.prototype._rebuild = function () {
  81781. this.onRebuildObservable.notifyObservers(this);
  81782. if (this._occlusionQuery) {
  81783. this._occlusionQuery = null;
  81784. }
  81785. if (!this.subMeshes) {
  81786. return;
  81787. }
  81788. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  81789. var subMesh = _a[_i];
  81790. subMesh._rebuild();
  81791. }
  81792. };
  81793. /** @hidden */
  81794. AbstractMesh.prototype._resyncLightSources = function () {
  81795. this._lightSources.length = 0;
  81796. for (var _i = 0, _a = this.getScene().lights; _i < _a.length; _i++) {
  81797. var light = _a[_i];
  81798. if (!light.isEnabled()) {
  81799. continue;
  81800. }
  81801. if (light.canAffectMesh(this)) {
  81802. this._lightSources.push(light);
  81803. }
  81804. }
  81805. this._markSubMeshesAsLightDirty();
  81806. };
  81807. /** @hidden */
  81808. AbstractMesh.prototype._resyncLighSource = function (light) {
  81809. var isIn = light.isEnabled() && light.canAffectMesh(this);
  81810. var index = this._lightSources.indexOf(light);
  81811. if (index === -1) {
  81812. if (!isIn) {
  81813. return;
  81814. }
  81815. this._lightSources.push(light);
  81816. }
  81817. else {
  81818. if (isIn) {
  81819. return;
  81820. }
  81821. this._lightSources.splice(index, 1);
  81822. }
  81823. this._markSubMeshesAsLightDirty();
  81824. };
  81825. /** @hidden */
  81826. AbstractMesh.prototype._unBindEffect = function () {
  81827. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  81828. var subMesh = _a[_i];
  81829. subMesh.setEffect(null);
  81830. }
  81831. };
  81832. /** @hidden */
  81833. AbstractMesh.prototype._removeLightSource = function (light) {
  81834. var index = this._lightSources.indexOf(light);
  81835. if (index === -1) {
  81836. return;
  81837. }
  81838. this._lightSources.splice(index, 1);
  81839. this._markSubMeshesAsLightDirty();
  81840. };
  81841. AbstractMesh.prototype._markSubMeshesAsDirty = function (func) {
  81842. if (!this.subMeshes) {
  81843. return;
  81844. }
  81845. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  81846. var subMesh = _a[_i];
  81847. if (subMesh._materialDefines) {
  81848. func(subMesh._materialDefines);
  81849. }
  81850. }
  81851. };
  81852. /** @hidden */
  81853. AbstractMesh.prototype._markSubMeshesAsLightDirty = function () {
  81854. this._markSubMeshesAsDirty(function (defines) { return defines.markAsLightDirty(); });
  81855. };
  81856. /** @hidden */
  81857. AbstractMesh.prototype._markSubMeshesAsAttributesDirty = function () {
  81858. this._markSubMeshesAsDirty(function (defines) { return defines.markAsAttributesDirty(); });
  81859. };
  81860. /** @hidden */
  81861. AbstractMesh.prototype._markSubMeshesAsMiscDirty = function () {
  81862. if (!this.subMeshes) {
  81863. return;
  81864. }
  81865. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  81866. var subMesh = _a[_i];
  81867. var material = subMesh.getMaterial();
  81868. if (material) {
  81869. material.markAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MATERIAL_MiscDirtyFlag);
  81870. }
  81871. }
  81872. };
  81873. Object.defineProperty(AbstractMesh.prototype, "scaling", {
  81874. /**
  81875. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  81876. */
  81877. get: function () {
  81878. return this._scaling;
  81879. },
  81880. set: function (newScaling) {
  81881. this._scaling = newScaling;
  81882. if (this.physicsImpostor) {
  81883. this.physicsImpostor.forceUpdate();
  81884. }
  81885. },
  81886. enumerable: true,
  81887. configurable: true
  81888. });
  81889. Object.defineProperty(AbstractMesh.prototype, "isBlocked", {
  81890. // Methods
  81891. /**
  81892. * Returns true if the mesh is blocked. Implemented by child classes
  81893. */
  81894. get: function () {
  81895. return false;
  81896. },
  81897. enumerable: true,
  81898. configurable: true
  81899. });
  81900. /**
  81901. * Returns the mesh itself by default. Implemented by child classes
  81902. * @param camera defines the camera to use to pick the right LOD level
  81903. * @returns the currentAbstractMesh
  81904. */
  81905. AbstractMesh.prototype.getLOD = function (camera) {
  81906. return this;
  81907. };
  81908. /**
  81909. * Returns 0 by default. Implemented by child classes
  81910. * @returns an integer
  81911. */
  81912. AbstractMesh.prototype.getTotalVertices = function () {
  81913. return 0;
  81914. };
  81915. /**
  81916. * Returns a positive integer : the total number of indices in this mesh geometry.
  81917. * @returns the numner of indices or zero if the mesh has no geometry.
  81918. */
  81919. AbstractMesh.prototype.getTotalIndices = function () {
  81920. return 0;
  81921. };
  81922. /**
  81923. * Returns null by default. Implemented by child classes
  81924. * @returns null
  81925. */
  81926. AbstractMesh.prototype.getIndices = function () {
  81927. return null;
  81928. };
  81929. /**
  81930. * Returns the array of the requested vertex data kind. Implemented by child classes
  81931. * @param kind defines the vertex data kind to use
  81932. * @returns null
  81933. */
  81934. AbstractMesh.prototype.getVerticesData = function (kind) {
  81935. return null;
  81936. };
  81937. /**
  81938. * Sets the vertex data of the mesh geometry for the requested `kind`.
  81939. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  81940. * Note that a new underlying VertexBuffer object is created each call.
  81941. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  81942. * @param kind defines vertex data kind:
  81943. * * VertexBuffer.PositionKind
  81944. * * VertexBuffer.UVKind
  81945. * * VertexBuffer.UV2Kind
  81946. * * VertexBuffer.UV3Kind
  81947. * * VertexBuffer.UV4Kind
  81948. * * VertexBuffer.UV5Kind
  81949. * * VertexBuffer.UV6Kind
  81950. * * VertexBuffer.ColorKind
  81951. * * VertexBuffer.MatricesIndicesKind
  81952. * * VertexBuffer.MatricesIndicesExtraKind
  81953. * * VertexBuffer.MatricesWeightsKind
  81954. * * VertexBuffer.MatricesWeightsExtraKind
  81955. * @param data defines the data source
  81956. * @param updatable defines if the data must be flagged as updatable (or static)
  81957. * @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
  81958. * @returns the current mesh
  81959. */
  81960. AbstractMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  81961. return this;
  81962. };
  81963. /**
  81964. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  81965. * If the mesh has no geometry, it is simply returned as it is.
  81966. * @param kind defines vertex data kind:
  81967. * * VertexBuffer.PositionKind
  81968. * * VertexBuffer.UVKind
  81969. * * VertexBuffer.UV2Kind
  81970. * * VertexBuffer.UV3Kind
  81971. * * VertexBuffer.UV4Kind
  81972. * * VertexBuffer.UV5Kind
  81973. * * VertexBuffer.UV6Kind
  81974. * * VertexBuffer.ColorKind
  81975. * * VertexBuffer.MatricesIndicesKind
  81976. * * VertexBuffer.MatricesIndicesExtraKind
  81977. * * VertexBuffer.MatricesWeightsKind
  81978. * * VertexBuffer.MatricesWeightsExtraKind
  81979. * @param data defines the data source
  81980. * @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
  81981. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  81982. * @returns the current mesh
  81983. */
  81984. AbstractMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  81985. return this;
  81986. };
  81987. /**
  81988. * Sets the mesh indices,
  81989. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  81990. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  81991. * @param totalVertices Defines the total number of vertices
  81992. * @returns the current mesh
  81993. */
  81994. AbstractMesh.prototype.setIndices = function (indices, totalVertices) {
  81995. return this;
  81996. };
  81997. /**
  81998. * Gets a boolean indicating if specific vertex data is present
  81999. * @param kind defines the vertex data kind to use
  82000. * @returns true is data kind is present
  82001. */
  82002. AbstractMesh.prototype.isVerticesDataPresent = function (kind) {
  82003. return false;
  82004. };
  82005. /**
  82006. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  82007. * @returns a BoundingInfo
  82008. */
  82009. AbstractMesh.prototype.getBoundingInfo = function () {
  82010. if (this._masterMesh) {
  82011. return this._masterMesh.getBoundingInfo();
  82012. }
  82013. if (!this._boundingInfo) {
  82014. // this._boundingInfo is being created here
  82015. this._updateBoundingInfo();
  82016. }
  82017. // cannot be null.
  82018. return this._boundingInfo;
  82019. };
  82020. /**
  82021. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  82022. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  82023. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  82024. * @returns the current mesh
  82025. */
  82026. AbstractMesh.prototype.normalizeToUnitCube = function (includeDescendants, ignoreRotation) {
  82027. if (includeDescendants === void 0) { includeDescendants = true; }
  82028. if (ignoreRotation === void 0) { ignoreRotation = false; }
  82029. var storedRotation = null;
  82030. var storedRotationQuaternion = null;
  82031. if (ignoreRotation) {
  82032. if (this.rotationQuaternion) {
  82033. storedRotationQuaternion = this.rotationQuaternion.clone();
  82034. this.rotationQuaternion.copyFromFloats(0, 0, 0, 1);
  82035. }
  82036. else if (this.rotation) {
  82037. storedRotation = this.rotation.clone();
  82038. this.rotation.copyFromFloats(0, 0, 0);
  82039. }
  82040. }
  82041. var boundingVectors = this.getHierarchyBoundingVectors(includeDescendants);
  82042. var sizeVec = boundingVectors.max.subtract(boundingVectors.min);
  82043. var maxDimension = Math.max(sizeVec.x, sizeVec.y, sizeVec.z);
  82044. if (maxDimension === 0) {
  82045. return this;
  82046. }
  82047. var scale = 1 / maxDimension;
  82048. this.scaling.scaleInPlace(scale);
  82049. if (ignoreRotation) {
  82050. if (this.rotationQuaternion && storedRotationQuaternion) {
  82051. this.rotationQuaternion.copyFrom(storedRotationQuaternion);
  82052. }
  82053. else if (this.rotation && storedRotation) {
  82054. this.rotation.copyFrom(storedRotation);
  82055. }
  82056. }
  82057. return this;
  82058. };
  82059. /**
  82060. * Overwrite the current bounding info
  82061. * @param boundingInfo defines the new bounding info
  82062. * @returns the current mesh
  82063. */
  82064. AbstractMesh.prototype.setBoundingInfo = function (boundingInfo) {
  82065. this._boundingInfo = boundingInfo;
  82066. return this;
  82067. };
  82068. Object.defineProperty(AbstractMesh.prototype, "useBones", {
  82069. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  82070. get: function () {
  82071. 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));
  82072. },
  82073. enumerable: true,
  82074. configurable: true
  82075. });
  82076. /** @hidden */
  82077. AbstractMesh.prototype._preActivate = function () {
  82078. };
  82079. /** @hidden */
  82080. AbstractMesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  82081. };
  82082. /** @hidden */
  82083. AbstractMesh.prototype._activate = function (renderId) {
  82084. this._renderId = renderId;
  82085. };
  82086. /**
  82087. * Gets the current world matrix
  82088. * @returns a Matrix
  82089. */
  82090. AbstractMesh.prototype.getWorldMatrix = function () {
  82091. if (this._masterMesh) {
  82092. return this._masterMesh.getWorldMatrix();
  82093. }
  82094. return _super.prototype.getWorldMatrix.call(this);
  82095. };
  82096. /** @hidden */
  82097. AbstractMesh.prototype._getWorldMatrixDeterminant = function () {
  82098. if (this._masterMesh) {
  82099. return this._masterMesh._getWorldMatrixDeterminant();
  82100. }
  82101. return _super.prototype._getWorldMatrixDeterminant.call(this);
  82102. };
  82103. // ================================== Point of View Movement =================================
  82104. /**
  82105. * Perform relative position change from the point of view of behind the front of the mesh.
  82106. * This is performed taking into account the meshes current rotation, so you do not have to care.
  82107. * Supports definition of mesh facing forward or backward
  82108. * @param amountRight defines the distance on the right axis
  82109. * @param amountUp defines the distance on the up axis
  82110. * @param amountForward defines the distance on the forward axis
  82111. * @returns the current mesh
  82112. */
  82113. AbstractMesh.prototype.movePOV = function (amountRight, amountUp, amountForward) {
  82114. this.position.addInPlace(this.calcMovePOV(amountRight, amountUp, amountForward));
  82115. return this;
  82116. };
  82117. /**
  82118. * Calculate relative position change from the point of view of behind the front of the mesh.
  82119. * This is performed taking into account the meshes current rotation, so you do not have to care.
  82120. * Supports definition of mesh facing forward or backward
  82121. * @param amountRight defines the distance on the right axis
  82122. * @param amountUp defines the distance on the up axis
  82123. * @param amountForward defines the distance on the forward axis
  82124. * @returns the new displacement vector
  82125. */
  82126. AbstractMesh.prototype.calcMovePOV = function (amountRight, amountUp, amountForward) {
  82127. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  82128. var rotQuaternion = (this.rotationQuaternion) ? this.rotationQuaternion : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  82129. rotQuaternion.toRotationMatrix(rotMatrix);
  82130. var translationDelta = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  82131. var defForwardMult = this.definedFacingForward ? -1 : 1;
  82132. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(amountRight * defForwardMult, amountUp, amountForward * defForwardMult, rotMatrix, translationDelta);
  82133. return translationDelta;
  82134. };
  82135. // ================================== Point of View Rotation =================================
  82136. /**
  82137. * Perform relative rotation change from the point of view of behind the front of the mesh.
  82138. * Supports definition of mesh facing forward or backward
  82139. * @param flipBack defines the flip
  82140. * @param twirlClockwise defines the twirl
  82141. * @param tiltRight defines the tilt
  82142. * @returns the current mesh
  82143. */
  82144. AbstractMesh.prototype.rotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  82145. this.rotation.addInPlace(this.calcRotatePOV(flipBack, twirlClockwise, tiltRight));
  82146. return this;
  82147. };
  82148. /**
  82149. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  82150. * Supports definition of mesh facing forward or backward.
  82151. * @param flipBack defines the flip
  82152. * @param twirlClockwise defines the twirl
  82153. * @param tiltRight defines the tilt
  82154. * @returns the new rotation vector
  82155. */
  82156. AbstractMesh.prototype.calcRotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  82157. var defForwardMult = this.definedFacingForward ? 1 : -1;
  82158. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](flipBack * defForwardMult, twirlClockwise, tiltRight * defForwardMult);
  82159. };
  82160. /**
  82161. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  82162. * @param includeDescendants Include bounding info from descendants as well (true by default)
  82163. * @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
  82164. * @returns the new bounding vectors
  82165. */
  82166. AbstractMesh.prototype.getHierarchyBoundingVectors = function (includeDescendants, predicate) {
  82167. if (includeDescendants === void 0) { includeDescendants = true; }
  82168. if (predicate === void 0) { predicate = null; }
  82169. // Ensures that all world matrix will be recomputed.
  82170. this.getScene().incrementRenderId();
  82171. this.computeWorldMatrix(true);
  82172. var min;
  82173. var max;
  82174. var boundingInfo = this.getBoundingInfo();
  82175. if (!this.subMeshes) {
  82176. min = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  82177. max = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  82178. }
  82179. else {
  82180. min = boundingInfo.boundingBox.minimumWorld;
  82181. max = boundingInfo.boundingBox.maximumWorld;
  82182. }
  82183. if (includeDescendants) {
  82184. var descendants = this.getDescendants(false);
  82185. for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
  82186. var descendant = descendants_1[_i];
  82187. var childMesh = descendant;
  82188. childMesh.computeWorldMatrix(true);
  82189. // Filters meshes based on custom predicate function.
  82190. if (predicate && !predicate(childMesh)) {
  82191. continue;
  82192. }
  82193. //make sure we have the needed params to get mix and max
  82194. if (!childMesh.getBoundingInfo || childMesh.getTotalVertices() === 0) {
  82195. continue;
  82196. }
  82197. var childBoundingInfo = childMesh.getBoundingInfo();
  82198. var boundingBox = childBoundingInfo.boundingBox;
  82199. var minBox = boundingBox.minimumWorld;
  82200. var maxBox = boundingBox.maximumWorld;
  82201. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  82202. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  82203. }
  82204. }
  82205. return {
  82206. min: min,
  82207. max: max
  82208. };
  82209. };
  82210. /**
  82211. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  82212. * This means the mesh underlying bounding box and sphere are recomputed.
  82213. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  82214. * @returns the current mesh
  82215. */
  82216. AbstractMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  82217. if (applySkeleton === void 0) { applySkeleton = false; }
  82218. if (this._boundingInfo && this._boundingInfo.isLocked) {
  82219. return this;
  82220. }
  82221. this._refreshBoundingInfo(this._getPositionData(applySkeleton), null);
  82222. return this;
  82223. };
  82224. /** @hidden */
  82225. AbstractMesh.prototype._refreshBoundingInfo = function (data, bias) {
  82226. if (data) {
  82227. var extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMax(data, 0, this.getTotalVertices(), bias);
  82228. if (this._boundingInfo) {
  82229. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  82230. }
  82231. else {
  82232. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](extend.minimum, extend.maximum);
  82233. }
  82234. }
  82235. if (this.subMeshes) {
  82236. for (var index = 0; index < this.subMeshes.length; index++) {
  82237. this.subMeshes[index].refreshBoundingInfo();
  82238. }
  82239. }
  82240. this._updateBoundingInfo();
  82241. };
  82242. /** @hidden */
  82243. AbstractMesh.prototype._getPositionData = function (applySkeleton) {
  82244. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  82245. if (data && applySkeleton && this.skeleton) {
  82246. data = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Slice(data);
  82247. var matricesIndicesData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesKind);
  82248. var matricesWeightsData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsKind);
  82249. if (matricesWeightsData && matricesIndicesData) {
  82250. var needExtras = this.numBoneInfluencers > 4;
  82251. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  82252. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  82253. this.skeleton.prepare();
  82254. var skeletonMatrices = this.skeleton.getTransformMatrices(this);
  82255. var tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  82256. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  82257. var tempMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  82258. var matWeightIdx = 0;
  82259. for (var index = 0; index < data.length; index += 3, matWeightIdx += 4) {
  82260. finalMatrix.reset();
  82261. var inf;
  82262. var weight;
  82263. for (inf = 0; inf < 4; inf++) {
  82264. weight = matricesWeightsData[matWeightIdx + inf];
  82265. if (weight > 0) {
  82266. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  82267. finalMatrix.addToSelf(tempMatrix);
  82268. }
  82269. }
  82270. if (needExtras) {
  82271. for (inf = 0; inf < 4; inf++) {
  82272. weight = matricesWeightsExtraData[matWeightIdx + inf];
  82273. if (weight > 0) {
  82274. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  82275. finalMatrix.addToSelf(tempMatrix);
  82276. }
  82277. }
  82278. }
  82279. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(data[index], data[index + 1], data[index + 2], finalMatrix, tempVector);
  82280. tempVector.toArray(data, index);
  82281. }
  82282. }
  82283. }
  82284. return data;
  82285. };
  82286. /** @hidden */
  82287. AbstractMesh.prototype._updateBoundingInfo = function () {
  82288. var effectiveMesh = this._effectiveMesh;
  82289. if (this._boundingInfo) {
  82290. this._boundingInfo.update(effectiveMesh.worldMatrixFromCache);
  82291. }
  82292. else {
  82293. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](this.absolutePosition, this.absolutePosition, effectiveMesh.worldMatrixFromCache);
  82294. }
  82295. this._updateSubMeshesBoundingInfo(effectiveMesh.worldMatrixFromCache);
  82296. return this;
  82297. };
  82298. /** @hidden */
  82299. AbstractMesh.prototype._updateSubMeshesBoundingInfo = function (matrix) {
  82300. if (!this.subMeshes) {
  82301. return this;
  82302. }
  82303. var count = this.subMeshes.length;
  82304. for (var subIndex = 0; subIndex < count; subIndex++) {
  82305. var subMesh = this.subMeshes[subIndex];
  82306. if (count > 1 || !subMesh.IsGlobal) {
  82307. subMesh.updateBoundingInfo(matrix);
  82308. }
  82309. }
  82310. return this;
  82311. };
  82312. /** @hidden */
  82313. AbstractMesh.prototype._afterComputeWorldMatrix = function () {
  82314. // Bounding info
  82315. this._updateBoundingInfo();
  82316. };
  82317. Object.defineProperty(AbstractMesh.prototype, "_effectiveMesh", {
  82318. /** @hidden */
  82319. get: function () {
  82320. return (this.skeleton && this.skeleton.overrideMesh) || this;
  82321. },
  82322. enumerable: true,
  82323. configurable: true
  82324. });
  82325. /**
  82326. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  82327. * A mesh is in the frustum if its bounding box intersects the frustum
  82328. * @param frustumPlanes defines the frustum to test
  82329. * @returns true if the mesh is in the frustum planes
  82330. */
  82331. AbstractMesh.prototype.isInFrustum = function (frustumPlanes) {
  82332. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  82333. };
  82334. /**
  82335. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  82336. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  82337. * @param frustumPlanes defines the frustum to test
  82338. * @returns true if the mesh is completely in the frustum planes
  82339. */
  82340. AbstractMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  82341. return this._boundingInfo !== null && this._boundingInfo.isCompletelyInFrustum(frustumPlanes);
  82342. };
  82343. /**
  82344. * True if the mesh intersects another mesh or a SolidParticle object
  82345. * @param mesh defines a target mesh or SolidParticle to test
  82346. * @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)
  82347. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  82348. * @returns true if there is an intersection
  82349. */
  82350. AbstractMesh.prototype.intersectsMesh = function (mesh, precise, includeDescendants) {
  82351. if (precise === void 0) { precise = false; }
  82352. if (!this._boundingInfo || !mesh._boundingInfo) {
  82353. return false;
  82354. }
  82355. if (this._boundingInfo.intersects(mesh._boundingInfo, precise)) {
  82356. return true;
  82357. }
  82358. if (includeDescendants) {
  82359. for (var _i = 0, _a = this.getChildMeshes(); _i < _a.length; _i++) {
  82360. var child = _a[_i];
  82361. if (child.intersectsMesh(mesh, precise, true)) {
  82362. return true;
  82363. }
  82364. }
  82365. }
  82366. return false;
  82367. };
  82368. /**
  82369. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  82370. * @param point defines the point to test
  82371. * @returns true if there is an intersection
  82372. */
  82373. AbstractMesh.prototype.intersectsPoint = function (point) {
  82374. if (!this._boundingInfo) {
  82375. return false;
  82376. }
  82377. return this._boundingInfo.intersectsPoint(point);
  82378. };
  82379. Object.defineProperty(AbstractMesh.prototype, "checkCollisions", {
  82380. // Collisions
  82381. /**
  82382. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  82383. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82384. */
  82385. get: function () {
  82386. return this._checkCollisions;
  82387. },
  82388. set: function (collisionEnabled) {
  82389. this._checkCollisions = collisionEnabled;
  82390. },
  82391. enumerable: true,
  82392. configurable: true
  82393. });
  82394. Object.defineProperty(AbstractMesh.prototype, "collider", {
  82395. /**
  82396. * Gets Collider object used to compute collisions (not physics)
  82397. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82398. */
  82399. get: function () {
  82400. return this._collider;
  82401. },
  82402. enumerable: true,
  82403. configurable: true
  82404. });
  82405. /**
  82406. * Move the mesh using collision engine
  82407. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82408. * @param displacement defines the requested displacement vector
  82409. * @returns the current mesh
  82410. */
  82411. AbstractMesh.prototype.moveWithCollisions = function (displacement) {
  82412. var globalPosition = this.getAbsolutePosition();
  82413. globalPosition.addToRef(this.ellipsoidOffset, this._oldPositionForCollisions);
  82414. var coordinator = this.getScene().collisionCoordinator;
  82415. if (!this._collider) {
  82416. this._collider = coordinator.createCollider();
  82417. }
  82418. this._collider._radius = this.ellipsoid;
  82419. coordinator.getNewPosition(this._oldPositionForCollisions, displacement, this._collider, 3, this, this._onCollisionPositionChange, this.uniqueId);
  82420. return this;
  82421. };
  82422. // Collisions
  82423. /** @hidden */
  82424. AbstractMesh.prototype._collideForSubMesh = function (subMesh, transformMatrix, collider) {
  82425. this._generatePointsArray();
  82426. if (!this._positions) {
  82427. return this;
  82428. }
  82429. // Transformation
  82430. if (!subMesh._lastColliderWorldVertices || !subMesh._lastColliderTransformMatrix.equals(transformMatrix)) {
  82431. subMesh._lastColliderTransformMatrix = transformMatrix.clone();
  82432. subMesh._lastColliderWorldVertices = [];
  82433. subMesh._trianglePlanes = [];
  82434. var start = subMesh.verticesStart;
  82435. var end = (subMesh.verticesStart + subMesh.verticesCount);
  82436. for (var i = start; i < end; i++) {
  82437. subMesh._lastColliderWorldVertices.push(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this._positions[i], transformMatrix));
  82438. }
  82439. }
  82440. // Collide
  82441. collider._collide(subMesh._trianglePlanes, subMesh._lastColliderWorldVertices, this.getIndices(), subMesh.indexStart, subMesh.indexStart + subMesh.indexCount, subMesh.verticesStart, !!subMesh.getMaterial());
  82442. if (collider.collisionFound) {
  82443. collider.collidedMesh = this;
  82444. }
  82445. return this;
  82446. };
  82447. /** @hidden */
  82448. AbstractMesh.prototype._processCollisionsForSubMeshes = function (collider, transformMatrix) {
  82449. var subMeshes = this._scene.getCollidingSubMeshCandidates(this, collider);
  82450. var len = subMeshes.length;
  82451. for (var index = 0; index < len; index++) {
  82452. var subMesh = subMeshes.data[index];
  82453. // Bounding test
  82454. if (len > 1 && !subMesh._checkCollision(collider)) {
  82455. continue;
  82456. }
  82457. this._collideForSubMesh(subMesh, transformMatrix, collider);
  82458. }
  82459. return this;
  82460. };
  82461. /** @hidden */
  82462. AbstractMesh.prototype._checkCollision = function (collider) {
  82463. // Bounding box test
  82464. if (!this._boundingInfo || !this._boundingInfo._checkCollision(collider)) {
  82465. return this;
  82466. }
  82467. // Transformation matrix
  82468. var collisionsScalingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  82469. var collisionsTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  82470. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(1.0 / collider._radius.x, 1.0 / collider._radius.y, 1.0 / collider._radius.z, collisionsScalingMatrix);
  82471. this.worldMatrixFromCache.multiplyToRef(collisionsScalingMatrix, collisionsTransformMatrix);
  82472. this._processCollisionsForSubMeshes(collider, collisionsTransformMatrix);
  82473. return this;
  82474. };
  82475. // Picking
  82476. /** @hidden */
  82477. AbstractMesh.prototype._generatePointsArray = function () {
  82478. return false;
  82479. };
  82480. /**
  82481. * Checks if the passed Ray intersects with the mesh
  82482. * @param ray defines the ray to use
  82483. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  82484. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  82485. * @returns the picking info
  82486. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  82487. */
  82488. AbstractMesh.prototype.intersects = function (ray, fastCheck, trianglePredicate) {
  82489. var pickingInfo = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]();
  82490. var intersectionThreshold = this.getClassName() === "InstancedLinesMesh" || this.getClassName() === "LinesMesh" ? this.intersectionThreshold : 0;
  82491. var boundingInfo = this._boundingInfo;
  82492. if (!this.subMeshes || !boundingInfo || !ray.intersectsSphere(boundingInfo.boundingSphere, intersectionThreshold) || !ray.intersectsBox(boundingInfo.boundingBox, intersectionThreshold)) {
  82493. return pickingInfo;
  82494. }
  82495. if (!this._generatePointsArray()) {
  82496. return pickingInfo;
  82497. }
  82498. var intersectInfo = null;
  82499. var subMeshes = this._scene.getIntersectingSubMeshCandidates(this, ray);
  82500. var len = subMeshes.length;
  82501. for (var index = 0; index < len; index++) {
  82502. var subMesh = subMeshes.data[index];
  82503. // Bounding test
  82504. if (len > 1 && !subMesh.canIntersects(ray)) {
  82505. continue;
  82506. }
  82507. var currentIntersectInfo = subMesh.intersects(ray, this._positions, this.getIndices(), fastCheck, trianglePredicate);
  82508. if (currentIntersectInfo) {
  82509. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  82510. intersectInfo = currentIntersectInfo;
  82511. intersectInfo.subMeshId = index;
  82512. if (fastCheck) {
  82513. break;
  82514. }
  82515. }
  82516. }
  82517. }
  82518. if (intersectInfo) {
  82519. // Get picked point
  82520. var world = this.getWorldMatrix();
  82521. var worldOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  82522. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  82523. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(ray.origin, world, worldOrigin);
  82524. ray.direction.scaleToRef(intersectInfo.distance, direction);
  82525. var worldDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(direction, world);
  82526. var pickedPoint = worldDirection.addInPlace(worldOrigin);
  82527. // Return result
  82528. pickingInfo.hit = true;
  82529. pickingInfo.distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(worldOrigin, pickedPoint);
  82530. pickingInfo.pickedPoint = pickedPoint;
  82531. pickingInfo.pickedMesh = this;
  82532. pickingInfo.bu = intersectInfo.bu || 0;
  82533. pickingInfo.bv = intersectInfo.bv || 0;
  82534. pickingInfo.faceId = intersectInfo.faceId;
  82535. pickingInfo.subMeshId = intersectInfo.subMeshId;
  82536. return pickingInfo;
  82537. }
  82538. return pickingInfo;
  82539. };
  82540. /**
  82541. * Clones the current mesh
  82542. * @param name defines the mesh name
  82543. * @param newParent defines the new mesh parent
  82544. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  82545. * @returns the new mesh
  82546. */
  82547. AbstractMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  82548. return null;
  82549. };
  82550. /**
  82551. * Disposes all the submeshes of the current meshnp
  82552. * @returns the current mesh
  82553. */
  82554. AbstractMesh.prototype.releaseSubMeshes = function () {
  82555. if (this.subMeshes) {
  82556. while (this.subMeshes.length) {
  82557. this.subMeshes[0].dispose();
  82558. }
  82559. }
  82560. else {
  82561. this.subMeshes = new Array();
  82562. }
  82563. return this;
  82564. };
  82565. /**
  82566. * Releases resources associated with this abstract mesh.
  82567. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82568. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82569. */
  82570. AbstractMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  82571. var _this = this;
  82572. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  82573. var index;
  82574. // Smart Array Retainers.
  82575. this.getScene().freeActiveMeshes();
  82576. this.getScene().freeRenderingGroups();
  82577. // Action manager
  82578. if (this.actionManager !== undefined && this.actionManager !== null) {
  82579. this.actionManager.dispose();
  82580. this.actionManager = null;
  82581. }
  82582. // Skeleton
  82583. this._skeleton = null;
  82584. // Intersections in progress
  82585. for (index = 0; index < this._intersectionsInProgress.length; index++) {
  82586. var other = this._intersectionsInProgress[index];
  82587. var pos = other._intersectionsInProgress.indexOf(this);
  82588. other._intersectionsInProgress.splice(pos, 1);
  82589. }
  82590. this._intersectionsInProgress = [];
  82591. // Lights
  82592. var lights = this.getScene().lights;
  82593. lights.forEach(function (light) {
  82594. var meshIndex = light.includedOnlyMeshes.indexOf(_this);
  82595. if (meshIndex !== -1) {
  82596. light.includedOnlyMeshes.splice(meshIndex, 1);
  82597. }
  82598. meshIndex = light.excludedMeshes.indexOf(_this);
  82599. if (meshIndex !== -1) {
  82600. light.excludedMeshes.splice(meshIndex, 1);
  82601. }
  82602. // Shadow generators
  82603. var generator = light.getShadowGenerator();
  82604. if (generator) {
  82605. var shadowMap = generator.getShadowMap();
  82606. if (shadowMap && shadowMap.renderList) {
  82607. meshIndex = shadowMap.renderList.indexOf(_this);
  82608. if (meshIndex !== -1) {
  82609. shadowMap.renderList.splice(meshIndex, 1);
  82610. }
  82611. }
  82612. }
  82613. });
  82614. // SubMeshes
  82615. if (this.getClassName() !== "InstancedMesh" || this.getClassName() !== "InstancedLinesMesh") {
  82616. this.releaseSubMeshes();
  82617. }
  82618. // Query
  82619. var engine = this.getScene().getEngine();
  82620. if (this._occlusionQuery) {
  82621. this.isOcclusionQueryInProgress = false;
  82622. engine.deleteQuery(this._occlusionQuery);
  82623. this._occlusionQuery = null;
  82624. }
  82625. // Engine
  82626. engine.wipeCaches();
  82627. // Remove from scene
  82628. this.getScene().removeMesh(this);
  82629. if (disposeMaterialAndTextures) {
  82630. if (this.material) {
  82631. if (this.material.getClassName() === "MultiMaterial") {
  82632. this.material.dispose(false, true, true);
  82633. }
  82634. else {
  82635. this.material.dispose(false, true);
  82636. }
  82637. }
  82638. }
  82639. if (!doNotRecurse) {
  82640. // Particles
  82641. for (index = 0; index < this.getScene().particleSystems.length; index++) {
  82642. if (this.getScene().particleSystems[index].emitter === this) {
  82643. this.getScene().particleSystems[index].dispose();
  82644. index--;
  82645. }
  82646. }
  82647. }
  82648. // facet data
  82649. if (this._facetData.facetDataEnabled) {
  82650. this.disableFacetData();
  82651. }
  82652. this.onAfterWorldMatrixUpdateObservable.clear();
  82653. this.onCollideObservable.clear();
  82654. this.onCollisionPositionChangeObservable.clear();
  82655. this.onRebuildObservable.clear();
  82656. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  82657. };
  82658. /**
  82659. * Adds the passed mesh as a child to the current mesh
  82660. * @param mesh defines the child mesh
  82661. * @returns the current mesh
  82662. */
  82663. AbstractMesh.prototype.addChild = function (mesh) {
  82664. mesh.setParent(this);
  82665. return this;
  82666. };
  82667. /**
  82668. * Removes the passed mesh from the current mesh children list
  82669. * @param mesh defines the child mesh
  82670. * @returns the current mesh
  82671. */
  82672. AbstractMesh.prototype.removeChild = function (mesh) {
  82673. mesh.setParent(null);
  82674. return this;
  82675. };
  82676. // Facet data
  82677. /** @hidden */
  82678. AbstractMesh.prototype._initFacetData = function () {
  82679. var data = this._facetData;
  82680. if (!data.facetNormals) {
  82681. data.facetNormals = new Array();
  82682. }
  82683. if (!data.facetPositions) {
  82684. data.facetPositions = new Array();
  82685. }
  82686. if (!data.facetPartitioning) {
  82687. data.facetPartitioning = new Array();
  82688. }
  82689. data.facetNb = (this.getIndices().length / 3) | 0;
  82690. data.partitioningSubdivisions = (data.partitioningSubdivisions) ? data.partitioningSubdivisions : 10; // default nb of partitioning subdivisions = 10
  82691. data.partitioningBBoxRatio = (data.partitioningBBoxRatio) ? data.partitioningBBoxRatio : 1.01; // default ratio 1.01 = the partitioning is 1% bigger than the bounding box
  82692. for (var f = 0; f < data.facetNb; f++) {
  82693. data.facetNormals[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  82694. data.facetPositions[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  82695. }
  82696. data.facetDataEnabled = true;
  82697. return this;
  82698. };
  82699. /**
  82700. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  82701. * This method can be called within the render loop.
  82702. * 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
  82703. * @returns the current mesh
  82704. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82705. */
  82706. AbstractMesh.prototype.updateFacetData = function () {
  82707. var data = this._facetData;
  82708. if (!data.facetDataEnabled) {
  82709. this._initFacetData();
  82710. }
  82711. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  82712. var indices = this.getIndices();
  82713. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  82714. var bInfo = this.getBoundingInfo();
  82715. if (data.facetDepthSort && !data.facetDepthSortEnabled) {
  82716. // init arrays, matrix and sort function on first call
  82717. data.facetDepthSortEnabled = true;
  82718. if (indices instanceof Uint16Array) {
  82719. data.depthSortedIndices = new Uint16Array(indices);
  82720. }
  82721. else if (indices instanceof Uint32Array) {
  82722. data.depthSortedIndices = new Uint32Array(indices);
  82723. }
  82724. else {
  82725. var needs32bits = false;
  82726. for (var i = 0; i < indices.length; i++) {
  82727. if (indices[i] > 65535) {
  82728. needs32bits = true;
  82729. break;
  82730. }
  82731. }
  82732. if (needs32bits) {
  82733. data.depthSortedIndices = new Uint32Array(indices);
  82734. }
  82735. else {
  82736. data.depthSortedIndices = new Uint16Array(indices);
  82737. }
  82738. }
  82739. data.facetDepthSortFunction = function (f1, f2) {
  82740. return (f2.sqDistance - f1.sqDistance);
  82741. };
  82742. if (!data.facetDepthSortFrom) {
  82743. var camera = this.getScene().activeCamera;
  82744. data.facetDepthSortFrom = (camera) ? camera.position : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  82745. }
  82746. data.depthSortedFacets = [];
  82747. for (var f = 0; f < data.facetNb; f++) {
  82748. var depthSortedFacet = { ind: f * 3, sqDistance: 0.0 };
  82749. data.depthSortedFacets.push(depthSortedFacet);
  82750. }
  82751. data.invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  82752. data.facetDepthSortOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  82753. }
  82754. 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"];
  82755. 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"];
  82756. 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"];
  82757. var bbSizeMax = (data.bbSize.x > data.bbSize.y) ? data.bbSize.x : data.bbSize.y;
  82758. bbSizeMax = (bbSizeMax > data.bbSize.z) ? bbSizeMax : data.bbSize.z;
  82759. data.subDiv.max = data.partitioningSubdivisions;
  82760. data.subDiv.X = Math.floor(data.subDiv.max * data.bbSize.x / bbSizeMax); // adjust the number of subdivisions per axis
  82761. data.subDiv.Y = Math.floor(data.subDiv.max * data.bbSize.y / bbSizeMax); // according to each bbox size per axis
  82762. data.subDiv.Z = Math.floor(data.subDiv.max * data.bbSize.z / bbSizeMax);
  82763. data.subDiv.X = data.subDiv.X < 1 ? 1 : data.subDiv.X; // at least one subdivision
  82764. data.subDiv.Y = data.subDiv.Y < 1 ? 1 : data.subDiv.Y;
  82765. data.subDiv.Z = data.subDiv.Z < 1 ? 1 : data.subDiv.Z;
  82766. // set the parameters for ComputeNormals()
  82767. data.facetParameters.facetNormals = this.getFacetLocalNormals();
  82768. data.facetParameters.facetPositions = this.getFacetLocalPositions();
  82769. data.facetParameters.facetPartitioning = this.getFacetLocalPartitioning();
  82770. data.facetParameters.bInfo = bInfo;
  82771. data.facetParameters.bbSize = data.bbSize;
  82772. data.facetParameters.subDiv = data.subDiv;
  82773. data.facetParameters.ratio = this.partitioningBBoxRatio;
  82774. data.facetParameters.depthSort = data.facetDepthSort;
  82775. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  82776. this.computeWorldMatrix(true);
  82777. this._worldMatrix.invertToRef(data.invertedMatrix);
  82778. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(data.facetDepthSortFrom, data.invertedMatrix, data.facetDepthSortOrigin);
  82779. data.facetParameters.distanceTo = data.facetDepthSortOrigin;
  82780. }
  82781. data.facetParameters.depthSortedFacets = data.depthSortedFacets;
  82782. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, data.facetParameters);
  82783. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  82784. data.depthSortedFacets.sort(data.facetDepthSortFunction);
  82785. var l = (data.depthSortedIndices.length / 3) | 0;
  82786. for (var f = 0; f < l; f++) {
  82787. var sind = data.depthSortedFacets[f].ind;
  82788. data.depthSortedIndices[f * 3] = indices[sind];
  82789. data.depthSortedIndices[f * 3 + 1] = indices[sind + 1];
  82790. data.depthSortedIndices[f * 3 + 2] = indices[sind + 2];
  82791. }
  82792. this.updateIndices(data.depthSortedIndices, undefined, true);
  82793. }
  82794. return this;
  82795. };
  82796. /**
  82797. * Returns the facetLocalNormals array.
  82798. * The normals are expressed in the mesh local spac
  82799. * @returns an array of Vector3
  82800. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82801. */
  82802. AbstractMesh.prototype.getFacetLocalNormals = function () {
  82803. if (!this._facetData.facetNormals) {
  82804. this.updateFacetData();
  82805. }
  82806. return this._facetData.facetNormals;
  82807. };
  82808. /**
  82809. * Returns the facetLocalPositions array.
  82810. * The facet positions are expressed in the mesh local space
  82811. * @returns an array of Vector3
  82812. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82813. */
  82814. AbstractMesh.prototype.getFacetLocalPositions = function () {
  82815. if (!this._facetData.facetPositions) {
  82816. this.updateFacetData();
  82817. }
  82818. return this._facetData.facetPositions;
  82819. };
  82820. /**
  82821. * Returns the facetLocalPartioning array
  82822. * @returns an array of array of numbers
  82823. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82824. */
  82825. AbstractMesh.prototype.getFacetLocalPartitioning = function () {
  82826. if (!this._facetData.facetPartitioning) {
  82827. this.updateFacetData();
  82828. }
  82829. return this._facetData.facetPartitioning;
  82830. };
  82831. /**
  82832. * Returns the i-th facet position in the world system.
  82833. * This method allocates a new Vector3 per call
  82834. * @param i defines the facet index
  82835. * @returns a new Vector3
  82836. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82837. */
  82838. AbstractMesh.prototype.getFacetPosition = function (i) {
  82839. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  82840. this.getFacetPositionToRef(i, pos);
  82841. return pos;
  82842. };
  82843. /**
  82844. * Sets the reference Vector3 with the i-th facet position in the world system
  82845. * @param i defines the facet index
  82846. * @param ref defines the target vector
  82847. * @returns the current mesh
  82848. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82849. */
  82850. AbstractMesh.prototype.getFacetPositionToRef = function (i, ref) {
  82851. var localPos = (this.getFacetLocalPositions())[i];
  82852. var world = this.getWorldMatrix();
  82853. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(localPos, world, ref);
  82854. return this;
  82855. };
  82856. /**
  82857. * Returns the i-th facet normal in the world system.
  82858. * This method allocates a new Vector3 per call
  82859. * @param i defines the facet index
  82860. * @returns a new Vector3
  82861. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82862. */
  82863. AbstractMesh.prototype.getFacetNormal = function (i) {
  82864. var norm = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  82865. this.getFacetNormalToRef(i, norm);
  82866. return norm;
  82867. };
  82868. /**
  82869. * Sets the reference Vector3 with the i-th facet normal in the world system
  82870. * @param i defines the facet index
  82871. * @param ref defines the target vector
  82872. * @returns the current mesh
  82873. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82874. */
  82875. AbstractMesh.prototype.getFacetNormalToRef = function (i, ref) {
  82876. var localNorm = (this.getFacetLocalNormals())[i];
  82877. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localNorm, this.getWorldMatrix(), ref);
  82878. return this;
  82879. };
  82880. /**
  82881. * 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)
  82882. * @param x defines x coordinate
  82883. * @param y defines y coordinate
  82884. * @param z defines z coordinate
  82885. * @returns the array of facet indexes
  82886. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82887. */
  82888. AbstractMesh.prototype.getFacetsAtLocalCoordinates = function (x, y, z) {
  82889. var bInfo = this.getBoundingInfo();
  82890. var data = this._facetData;
  82891. var ox = Math.floor((x - bInfo.minimum.x * data.partitioningBBoxRatio) * data.subDiv.X * data.partitioningBBoxRatio / data.bbSize.x);
  82892. var oy = Math.floor((y - bInfo.minimum.y * data.partitioningBBoxRatio) * data.subDiv.Y * data.partitioningBBoxRatio / data.bbSize.y);
  82893. var oz = Math.floor((z - bInfo.minimum.z * data.partitioningBBoxRatio) * data.subDiv.Z * data.partitioningBBoxRatio / data.bbSize.z);
  82894. if (ox < 0 || ox > data.subDiv.max || oy < 0 || oy > data.subDiv.max || oz < 0 || oz > data.subDiv.max) {
  82895. return null;
  82896. }
  82897. return data.facetPartitioning[ox + data.subDiv.max * oy + data.subDiv.max * data.subDiv.max * oz];
  82898. };
  82899. /**
  82900. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  82901. * @param projected sets as the (x,y,z) world projection on the facet
  82902. * @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
  82903. * @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
  82904. * @param x defines x coordinate
  82905. * @param y defines y coordinate
  82906. * @param z defines z coordinate
  82907. * @returns the face index if found (or null instead)
  82908. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82909. */
  82910. AbstractMesh.prototype.getClosestFacetAtCoordinates = function (x, y, z, projected, checkFace, facing) {
  82911. if (checkFace === void 0) { checkFace = false; }
  82912. if (facing === void 0) { facing = true; }
  82913. var world = this.getWorldMatrix();
  82914. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5];
  82915. world.invertToRef(invMat);
  82916. var invVect = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[8];
  82917. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, invMat, invVect); // transform (x,y,z) to coordinates in the mesh local space
  82918. var closest = this.getClosestFacetAtLocalCoordinates(invVect.x, invVect.y, invVect.z, projected, checkFace, facing);
  82919. if (projected) {
  82920. // tranform the local computed projected vector to world coordinates
  82921. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(projected.x, projected.y, projected.z, world, projected);
  82922. }
  82923. return closest;
  82924. };
  82925. /**
  82926. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  82927. * @param projected sets as the (x,y,z) local projection on the facet
  82928. * @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
  82929. * @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
  82930. * @param x defines x coordinate
  82931. * @param y defines y coordinate
  82932. * @param z defines z coordinate
  82933. * @returns the face index if found (or null instead)
  82934. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82935. */
  82936. AbstractMesh.prototype.getClosestFacetAtLocalCoordinates = function (x, y, z, projected, checkFace, facing) {
  82937. if (checkFace === void 0) { checkFace = false; }
  82938. if (facing === void 0) { facing = true; }
  82939. var closest = null;
  82940. var tmpx = 0.0;
  82941. var tmpy = 0.0;
  82942. var tmpz = 0.0;
  82943. var d = 0.0; // tmp dot facet normal * facet position
  82944. var t0 = 0.0;
  82945. var projx = 0.0;
  82946. var projy = 0.0;
  82947. var projz = 0.0;
  82948. // Get all the facets in the same partitioning block than (x, y, z)
  82949. var facetPositions = this.getFacetLocalPositions();
  82950. var facetNormals = this.getFacetLocalNormals();
  82951. var facetsInBlock = this.getFacetsAtLocalCoordinates(x, y, z);
  82952. if (!facetsInBlock) {
  82953. return null;
  82954. }
  82955. // Get the closest facet to (x, y, z)
  82956. var shortest = Number.MAX_VALUE; // init distance vars
  82957. var tmpDistance = shortest;
  82958. var fib; // current facet in the block
  82959. var norm; // current facet normal
  82960. var p0; // current facet barycenter position
  82961. // loop on all the facets in the current partitioning block
  82962. for (var idx = 0; idx < facetsInBlock.length; idx++) {
  82963. fib = facetsInBlock[idx];
  82964. norm = facetNormals[fib];
  82965. p0 = facetPositions[fib];
  82966. d = (x - p0.x) * norm.x + (y - p0.y) * norm.y + (z - p0.z) * norm.z;
  82967. if (!checkFace || (checkFace && facing && d >= 0.0) || (checkFace && !facing && d <= 0.0)) {
  82968. // compute (x,y,z) projection on the facet = (projx, projy, projz)
  82969. d = norm.x * p0.x + norm.y * p0.y + norm.z * p0.z;
  82970. t0 = -(norm.x * x + norm.y * y + norm.z * z - d) / (norm.x * norm.x + norm.y * norm.y + norm.z * norm.z);
  82971. projx = x + norm.x * t0;
  82972. projy = y + norm.y * t0;
  82973. projz = z + norm.z * t0;
  82974. tmpx = projx - x;
  82975. tmpy = projy - y;
  82976. tmpz = projz - z;
  82977. tmpDistance = tmpx * tmpx + tmpy * tmpy + tmpz * tmpz; // compute length between (x, y, z) and its projection on the facet
  82978. if (tmpDistance < shortest) { // just keep the closest facet to (x, y, z)
  82979. shortest = tmpDistance;
  82980. closest = fib;
  82981. if (projected) {
  82982. projected.x = projx;
  82983. projected.y = projy;
  82984. projected.z = projz;
  82985. }
  82986. }
  82987. }
  82988. }
  82989. return closest;
  82990. };
  82991. /**
  82992. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  82993. * @returns the parameters
  82994. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82995. */
  82996. AbstractMesh.prototype.getFacetDataParameters = function () {
  82997. return this._facetData.facetParameters;
  82998. };
  82999. /**
  83000. * Disables the feature FacetData and frees the related memory
  83001. * @returns the current mesh
  83002. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83003. */
  83004. AbstractMesh.prototype.disableFacetData = function () {
  83005. if (this._facetData.facetDataEnabled) {
  83006. this._facetData.facetDataEnabled = false;
  83007. this._facetData.facetPositions = new Array();
  83008. this._facetData.facetNormals = new Array();
  83009. this._facetData.facetPartitioning = new Array();
  83010. this._facetData.facetParameters = null;
  83011. this._facetData.depthSortedIndices = new Uint32Array(0);
  83012. }
  83013. return this;
  83014. };
  83015. /**
  83016. * Updates the AbstractMesh indices array
  83017. * @param indices defines the data source
  83018. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  83019. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  83020. * @returns the current mesh
  83021. */
  83022. AbstractMesh.prototype.updateIndices = function (indices, offset, gpuMemoryOnly) {
  83023. if (gpuMemoryOnly === void 0) { gpuMemoryOnly = false; }
  83024. return this;
  83025. };
  83026. /**
  83027. * Creates new normals data for the mesh
  83028. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  83029. * @returns the current mesh
  83030. */
  83031. AbstractMesh.prototype.createNormals = function (updatable) {
  83032. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  83033. var indices = this.getIndices();
  83034. var normals;
  83035. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  83036. normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  83037. }
  83038. else {
  83039. normals = [];
  83040. }
  83041. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, { useRightHandedSystem: this.getScene().useRightHandedSystem });
  83042. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind, normals, updatable);
  83043. return this;
  83044. };
  83045. /**
  83046. * Align the mesh with a normal
  83047. * @param normal defines the normal to use
  83048. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  83049. * @returns the current mesh
  83050. */
  83051. AbstractMesh.prototype.alignWithNormal = function (normal, upDirection) {
  83052. if (!upDirection) {
  83053. upDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y;
  83054. }
  83055. var axisX = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  83056. var axisZ = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  83057. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(upDirection, normal, axisZ);
  83058. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(normal, axisZ, axisX);
  83059. if (this.rotationQuaternion) {
  83060. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationQuaternionFromAxisToRef(axisX, normal, axisZ, this.rotationQuaternion);
  83061. }
  83062. else {
  83063. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].RotationFromAxisToRef(axisX, normal, axisZ, this.rotation);
  83064. }
  83065. return this;
  83066. };
  83067. /** @hidden */
  83068. AbstractMesh.prototype._checkOcclusionQuery = function () {
  83069. return false;
  83070. };
  83071. /** No occlusion */
  83072. AbstractMesh.OCCLUSION_TYPE_NONE = 0;
  83073. /** Occlusion set to optimisitic */
  83074. AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC = 1;
  83075. /** Occlusion set to strict */
  83076. AbstractMesh.OCCLUSION_TYPE_STRICT = 2;
  83077. /** Use an accurante occlusion algorithm */
  83078. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0;
  83079. /** Use a conservative occlusion algorithm */
  83080. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1;
  83081. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  83082. * Test order :
  83083. * Is the bounding sphere outside the frustum ?
  83084. * If not, are the bounding box vertices outside the frustum ?
  83085. * It not, then the cullable object is in the frustum.
  83086. */
  83087. AbstractMesh.CULLINGSTRATEGY_STANDARD = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD;
  83088. /** Culling strategy : Bounding Sphere Only.
  83089. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  83090. * It's also less accurate than the standard because some not visible objects can still be selected.
  83091. * Test : is the bounding sphere outside the frustum ?
  83092. * If not, then the cullable object is in the frustum.
  83093. */
  83094. AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  83095. /** Culling strategy : Optimistic Inclusion.
  83096. * This in an inclusion test first, then the standard exclusion test.
  83097. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  83098. * 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.
  83099. * Anyway, it's as accurate as the standard strategy.
  83100. * Test :
  83101. * Is the cullable object bounding sphere center in the frustum ?
  83102. * If not, apply the default culling strategy.
  83103. */
  83104. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION;
  83105. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  83106. * This in an inclusion test first, then the bounding sphere only exclusion test.
  83107. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  83108. * 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.
  83109. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  83110. * Test :
  83111. * Is the cullable object bounding sphere center in the frustum ?
  83112. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  83113. */
  83114. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY;
  83115. return AbstractMesh;
  83116. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"]));
  83117. /***/ }),
  83118. /***/ "./Meshes/buffer.ts":
  83119. /*!**************************!*\
  83120. !*** ./Meshes/buffer.ts ***!
  83121. \**************************/
  83122. /*! exports provided: Buffer, VertexBuffer */
  83123. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83124. "use strict";
  83125. __webpack_require__.r(__webpack_exports__);
  83126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return Buffer; });
  83127. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return VertexBuffer; });
  83128. /**
  83129. * Class used to store data that will be store in GPU memory
  83130. */
  83131. var Buffer = /** @class */ (function () {
  83132. /**
  83133. * Constructor
  83134. * @param engine the engine
  83135. * @param data the data to use for this buffer
  83136. * @param updatable whether the data is updatable
  83137. * @param stride the stride (optional)
  83138. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  83139. * @param instanced whether the buffer is instanced (optional)
  83140. * @param useBytes set to true if the stride in in bytes (optional)
  83141. */
  83142. function Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes) {
  83143. if (stride === void 0) { stride = 0; }
  83144. if (postponeInternalCreation === void 0) { postponeInternalCreation = false; }
  83145. if (instanced === void 0) { instanced = false; }
  83146. if (useBytes === void 0) { useBytes = false; }
  83147. if (engine.getScene) { // old versions of VertexBuffer accepted 'mesh' instead of 'engine'
  83148. this._engine = engine.getScene().getEngine();
  83149. }
  83150. else {
  83151. this._engine = engine;
  83152. }
  83153. this._updatable = updatable;
  83154. this._instanced = instanced;
  83155. this._data = data;
  83156. this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;
  83157. if (!postponeInternalCreation) { // by default
  83158. this.create();
  83159. }
  83160. }
  83161. /**
  83162. * Create a new VertexBuffer based on the current buffer
  83163. * @param kind defines the vertex buffer kind (position, normal, etc.)
  83164. * @param offset defines offset in the buffer (0 by default)
  83165. * @param size defines the size in floats of attributes (position is 3 for instance)
  83166. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  83167. * @param instanced defines if the vertex buffer contains indexed data
  83168. * @param useBytes defines if the offset and stride are in bytes
  83169. * @returns the new vertex buffer
  83170. */
  83171. Buffer.prototype.createVertexBuffer = function (kind, offset, size, stride, instanced, useBytes) {
  83172. if (useBytes === void 0) { useBytes = false; }
  83173. var byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;
  83174. var byteStride = stride ? (useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT) : this.byteStride;
  83175. // a lot of these parameters are ignored as they are overriden by the buffer
  83176. return new VertexBuffer(this._engine, this, kind, this._updatable, true, byteStride, instanced === undefined ? this._instanced : instanced, byteOffset, size, undefined, undefined, true);
  83177. };
  83178. // Properties
  83179. /**
  83180. * Gets a boolean indicating if the Buffer is updatable?
  83181. * @returns true if the buffer is updatable
  83182. */
  83183. Buffer.prototype.isUpdatable = function () {
  83184. return this._updatable;
  83185. };
  83186. /**
  83187. * Gets current buffer's data
  83188. * @returns a DataArray or null
  83189. */
  83190. Buffer.prototype.getData = function () {
  83191. return this._data;
  83192. };
  83193. /**
  83194. * Gets underlying native buffer
  83195. * @returns underlying native buffer
  83196. */
  83197. Buffer.prototype.getBuffer = function () {
  83198. return this._buffer;
  83199. };
  83200. /**
  83201. * Gets the stride in float32 units (i.e. byte stride / 4).
  83202. * May not be an integer if the byte stride is not divisible by 4.
  83203. * DEPRECATED. Use byteStride instead.
  83204. * @returns the stride in float32 units
  83205. */
  83206. Buffer.prototype.getStrideSize = function () {
  83207. return this.byteStride / Float32Array.BYTES_PER_ELEMENT;
  83208. };
  83209. // Methods
  83210. /**
  83211. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  83212. * @param data defines the data to store
  83213. */
  83214. Buffer.prototype.create = function (data) {
  83215. if (data === void 0) { data = null; }
  83216. if (!data && this._buffer) {
  83217. return; // nothing to do
  83218. }
  83219. data = data || this._data;
  83220. if (!data) {
  83221. return;
  83222. }
  83223. if (!this._buffer) { // create buffer
  83224. if (this._updatable) {
  83225. this._buffer = this._engine.createDynamicVertexBuffer(data);
  83226. this._data = data;
  83227. }
  83228. else {
  83229. this._buffer = this._engine.createVertexBuffer(data);
  83230. }
  83231. }
  83232. else if (this._updatable) { // update buffer
  83233. this._engine.updateDynamicVertexBuffer(this._buffer, data);
  83234. this._data = data;
  83235. }
  83236. };
  83237. /** @hidden */
  83238. Buffer.prototype._rebuild = function () {
  83239. this._buffer = null;
  83240. this.create(this._data);
  83241. };
  83242. /**
  83243. * Update current buffer data
  83244. * @param data defines the data to store
  83245. */
  83246. Buffer.prototype.update = function (data) {
  83247. this.create(data);
  83248. };
  83249. /**
  83250. * Updates the data directly.
  83251. * @param data the new data
  83252. * @param offset the new offset
  83253. * @param vertexCount the vertex count (optional)
  83254. * @param useBytes set to true if the offset is in bytes
  83255. */
  83256. Buffer.prototype.updateDirectly = function (data, offset, vertexCount, useBytes) {
  83257. if (useBytes === void 0) { useBytes = false; }
  83258. if (!this._buffer) {
  83259. return;
  83260. }
  83261. if (this._updatable) { // update buffer
  83262. this._engine.updateDynamicVertexBuffer(this._buffer, data, useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT, (vertexCount ? vertexCount * this.byteStride : undefined));
  83263. this._data = null;
  83264. }
  83265. };
  83266. /**
  83267. * Release all resources
  83268. */
  83269. Buffer.prototype.dispose = function () {
  83270. if (!this._buffer) {
  83271. return;
  83272. }
  83273. if (this._engine._releaseBuffer(this._buffer)) {
  83274. this._buffer = null;
  83275. }
  83276. };
  83277. return Buffer;
  83278. }());
  83279. /**
  83280. * Specialized buffer used to store vertex data
  83281. */
  83282. var VertexBuffer = /** @class */ (function () {
  83283. /**
  83284. * Constructor
  83285. * @param engine the engine
  83286. * @param data the data to use for this vertex buffer
  83287. * @param kind the vertex buffer kind
  83288. * @param updatable whether the data is updatable
  83289. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  83290. * @param stride the stride (optional)
  83291. * @param instanced whether the buffer is instanced (optional)
  83292. * @param offset the offset of the data (optional)
  83293. * @param size the number of components (optional)
  83294. * @param type the type of the component (optional)
  83295. * @param normalized whether the data contains normalized data (optional)
  83296. * @param useBytes set to true if stride and offset are in bytes (optional)
  83297. */
  83298. function VertexBuffer(engine, data, kind, updatable, postponeInternalCreation, stride, instanced, offset, size, type, normalized, useBytes) {
  83299. if (normalized === void 0) { normalized = false; }
  83300. if (useBytes === void 0) { useBytes = false; }
  83301. if (data instanceof Buffer) {
  83302. this._buffer = data;
  83303. this._ownsBuffer = false;
  83304. }
  83305. else {
  83306. this._buffer = new Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes);
  83307. this._ownsBuffer = true;
  83308. }
  83309. this._kind = kind;
  83310. if (type == undefined) {
  83311. var data_1 = this.getData();
  83312. this.type = VertexBuffer.FLOAT;
  83313. if (data_1 instanceof Int8Array) {
  83314. this.type = VertexBuffer.BYTE;
  83315. }
  83316. else if (data_1 instanceof Uint8Array) {
  83317. this.type = VertexBuffer.UNSIGNED_BYTE;
  83318. }
  83319. else if (data_1 instanceof Int16Array) {
  83320. this.type = VertexBuffer.SHORT;
  83321. }
  83322. else if (data_1 instanceof Uint16Array) {
  83323. this.type = VertexBuffer.UNSIGNED_SHORT;
  83324. }
  83325. else if (data_1 instanceof Int32Array) {
  83326. this.type = VertexBuffer.INT;
  83327. }
  83328. else if (data_1 instanceof Uint32Array) {
  83329. this.type = VertexBuffer.UNSIGNED_INT;
  83330. }
  83331. }
  83332. else {
  83333. this.type = type;
  83334. }
  83335. var typeByteLength = VertexBuffer.GetTypeByteLength(this.type);
  83336. if (useBytes) {
  83337. this._size = size || (stride ? (stride / typeByteLength) : VertexBuffer.DeduceStride(kind));
  83338. this.byteStride = stride || this._buffer.byteStride || (this._size * typeByteLength);
  83339. this.byteOffset = offset || 0;
  83340. }
  83341. else {
  83342. this._size = size || stride || VertexBuffer.DeduceStride(kind);
  83343. this.byteStride = stride ? (stride * typeByteLength) : (this._buffer.byteStride || (this._size * typeByteLength));
  83344. this.byteOffset = (offset || 0) * typeByteLength;
  83345. }
  83346. this.normalized = normalized;
  83347. this._instanced = instanced !== undefined ? instanced : false;
  83348. this._instanceDivisor = instanced ? 1 : 0;
  83349. }
  83350. Object.defineProperty(VertexBuffer.prototype, "instanceDivisor", {
  83351. /**
  83352. * Gets or sets the instance divisor when in instanced mode
  83353. */
  83354. get: function () {
  83355. return this._instanceDivisor;
  83356. },
  83357. set: function (value) {
  83358. this._instanceDivisor = value;
  83359. if (value == 0) {
  83360. this._instanced = false;
  83361. }
  83362. else {
  83363. this._instanced = true;
  83364. }
  83365. },
  83366. enumerable: true,
  83367. configurable: true
  83368. });
  83369. /** @hidden */
  83370. VertexBuffer.prototype._rebuild = function () {
  83371. if (!this._buffer) {
  83372. return;
  83373. }
  83374. this._buffer._rebuild();
  83375. };
  83376. /**
  83377. * Returns the kind of the VertexBuffer (string)
  83378. * @returns a string
  83379. */
  83380. VertexBuffer.prototype.getKind = function () {
  83381. return this._kind;
  83382. };
  83383. // Properties
  83384. /**
  83385. * Gets a boolean indicating if the VertexBuffer is updatable?
  83386. * @returns true if the buffer is updatable
  83387. */
  83388. VertexBuffer.prototype.isUpdatable = function () {
  83389. return this._buffer.isUpdatable();
  83390. };
  83391. /**
  83392. * Gets current buffer's data
  83393. * @returns a DataArray or null
  83394. */
  83395. VertexBuffer.prototype.getData = function () {
  83396. return this._buffer.getData();
  83397. };
  83398. /**
  83399. * Gets underlying native buffer
  83400. * @returns underlying native buffer
  83401. */
  83402. VertexBuffer.prototype.getBuffer = function () {
  83403. return this._buffer.getBuffer();
  83404. };
  83405. /**
  83406. * Gets the stride in float32 units (i.e. byte stride / 4).
  83407. * May not be an integer if the byte stride is not divisible by 4.
  83408. * DEPRECATED. Use byteStride instead.
  83409. * @returns the stride in float32 units
  83410. */
  83411. VertexBuffer.prototype.getStrideSize = function () {
  83412. return this.byteStride / VertexBuffer.GetTypeByteLength(this.type);
  83413. };
  83414. /**
  83415. * Returns the offset as a multiple of the type byte length.
  83416. * DEPRECATED. Use byteOffset instead.
  83417. * @returns the offset in bytes
  83418. */
  83419. VertexBuffer.prototype.getOffset = function () {
  83420. return this.byteOffset / VertexBuffer.GetTypeByteLength(this.type);
  83421. };
  83422. /**
  83423. * Returns the number of components per vertex attribute (integer)
  83424. * @returns the size in float
  83425. */
  83426. VertexBuffer.prototype.getSize = function () {
  83427. return this._size;
  83428. };
  83429. /**
  83430. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  83431. * @returns true if this buffer is instanced
  83432. */
  83433. VertexBuffer.prototype.getIsInstanced = function () {
  83434. return this._instanced;
  83435. };
  83436. /**
  83437. * Returns the instancing divisor, zero for non-instanced (integer).
  83438. * @returns a number
  83439. */
  83440. VertexBuffer.prototype.getInstanceDivisor = function () {
  83441. return this._instanceDivisor;
  83442. };
  83443. // Methods
  83444. /**
  83445. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  83446. * @param data defines the data to store
  83447. */
  83448. VertexBuffer.prototype.create = function (data) {
  83449. this._buffer.create(data);
  83450. };
  83451. /**
  83452. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  83453. * This function will create a new buffer if the current one is not updatable
  83454. * @param data defines the data to store
  83455. */
  83456. VertexBuffer.prototype.update = function (data) {
  83457. this._buffer.update(data);
  83458. };
  83459. /**
  83460. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  83461. * Returns the directly updated WebGLBuffer.
  83462. * @param data the new data
  83463. * @param offset the new offset
  83464. * @param useBytes set to true if the offset is in bytes
  83465. */
  83466. VertexBuffer.prototype.updateDirectly = function (data, offset, useBytes) {
  83467. if (useBytes === void 0) { useBytes = false; }
  83468. this._buffer.updateDirectly(data, offset, undefined, useBytes);
  83469. };
  83470. /**
  83471. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  83472. */
  83473. VertexBuffer.prototype.dispose = function () {
  83474. if (this._ownsBuffer) {
  83475. this._buffer.dispose();
  83476. }
  83477. };
  83478. /**
  83479. * Enumerates each value of this vertex buffer as numbers.
  83480. * @param count the number of values to enumerate
  83481. * @param callback the callback function called for each value
  83482. */
  83483. VertexBuffer.prototype.forEach = function (count, callback) {
  83484. VertexBuffer.ForEach(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, count, this.normalized, callback);
  83485. };
  83486. /**
  83487. * Deduces the stride given a kind.
  83488. * @param kind The kind string to deduce
  83489. * @returns The deduced stride
  83490. */
  83491. VertexBuffer.DeduceStride = function (kind) {
  83492. switch (kind) {
  83493. case VertexBuffer.UVKind:
  83494. case VertexBuffer.UV2Kind:
  83495. case VertexBuffer.UV3Kind:
  83496. case VertexBuffer.UV4Kind:
  83497. case VertexBuffer.UV5Kind:
  83498. case VertexBuffer.UV6Kind:
  83499. return 2;
  83500. case VertexBuffer.NormalKind:
  83501. case VertexBuffer.PositionKind:
  83502. return 3;
  83503. case VertexBuffer.ColorKind:
  83504. case VertexBuffer.MatricesIndicesKind:
  83505. case VertexBuffer.MatricesIndicesExtraKind:
  83506. case VertexBuffer.MatricesWeightsKind:
  83507. case VertexBuffer.MatricesWeightsExtraKind:
  83508. case VertexBuffer.TangentKind:
  83509. return 4;
  83510. default:
  83511. throw new Error("Invalid kind '" + kind + "'");
  83512. }
  83513. };
  83514. /**
  83515. * Gets the byte length of the given type.
  83516. * @param type the type
  83517. * @returns the number of bytes
  83518. */
  83519. VertexBuffer.GetTypeByteLength = function (type) {
  83520. switch (type) {
  83521. case VertexBuffer.BYTE:
  83522. case VertexBuffer.UNSIGNED_BYTE:
  83523. return 1;
  83524. case VertexBuffer.SHORT:
  83525. case VertexBuffer.UNSIGNED_SHORT:
  83526. return 2;
  83527. case VertexBuffer.INT:
  83528. case VertexBuffer.FLOAT:
  83529. return 4;
  83530. default:
  83531. throw new Error("Invalid type '" + type + "'");
  83532. }
  83533. };
  83534. /**
  83535. * Enumerates each value of the given parameters as numbers.
  83536. * @param data the data to enumerate
  83537. * @param byteOffset the byte offset of the data
  83538. * @param byteStride the byte stride of the data
  83539. * @param componentCount the number of components per element
  83540. * @param componentType the type of the component
  83541. * @param count the total number of components
  83542. * @param normalized whether the data is normalized
  83543. * @param callback the callback function called for each value
  83544. */
  83545. VertexBuffer.ForEach = function (data, byteOffset, byteStride, componentCount, componentType, count, normalized, callback) {
  83546. if (data instanceof Array) {
  83547. var offset = byteOffset / 4;
  83548. var stride = byteStride / 4;
  83549. for (var index = 0; index < count; index += componentCount) {
  83550. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  83551. callback(data[offset + componentIndex], index + componentIndex);
  83552. }
  83553. offset += stride;
  83554. }
  83555. }
  83556. else {
  83557. var dataView = data instanceof ArrayBuffer ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);
  83558. var componentByteLength = VertexBuffer.GetTypeByteLength(componentType);
  83559. for (var index = 0; index < count; index += componentCount) {
  83560. var componentByteOffset = byteOffset;
  83561. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  83562. var value = VertexBuffer._GetFloatValue(dataView, componentType, componentByteOffset, normalized);
  83563. callback(value, index + componentIndex);
  83564. componentByteOffset += componentByteLength;
  83565. }
  83566. byteOffset += byteStride;
  83567. }
  83568. }
  83569. };
  83570. VertexBuffer._GetFloatValue = function (dataView, type, byteOffset, normalized) {
  83571. switch (type) {
  83572. case VertexBuffer.BYTE: {
  83573. var value = dataView.getInt8(byteOffset);
  83574. if (normalized) {
  83575. value = Math.max(value / 127, -1);
  83576. }
  83577. return value;
  83578. }
  83579. case VertexBuffer.UNSIGNED_BYTE: {
  83580. var value = dataView.getUint8(byteOffset);
  83581. if (normalized) {
  83582. value = value / 255;
  83583. }
  83584. return value;
  83585. }
  83586. case VertexBuffer.SHORT: {
  83587. var value = dataView.getInt16(byteOffset, true);
  83588. if (normalized) {
  83589. value = Math.max(value / 16383, -1);
  83590. }
  83591. return value;
  83592. }
  83593. case VertexBuffer.UNSIGNED_SHORT: {
  83594. var value = dataView.getUint16(byteOffset, true);
  83595. if (normalized) {
  83596. value = value / 65535;
  83597. }
  83598. return value;
  83599. }
  83600. case VertexBuffer.FLOAT: {
  83601. return dataView.getFloat32(byteOffset, true);
  83602. }
  83603. default: {
  83604. throw new Error("Invalid component type " + type);
  83605. }
  83606. }
  83607. };
  83608. /**
  83609. * The byte type.
  83610. */
  83611. VertexBuffer.BYTE = 5120;
  83612. /**
  83613. * The unsigned byte type.
  83614. */
  83615. VertexBuffer.UNSIGNED_BYTE = 5121;
  83616. /**
  83617. * The short type.
  83618. */
  83619. VertexBuffer.SHORT = 5122;
  83620. /**
  83621. * The unsigned short type.
  83622. */
  83623. VertexBuffer.UNSIGNED_SHORT = 5123;
  83624. /**
  83625. * The integer type.
  83626. */
  83627. VertexBuffer.INT = 5124;
  83628. /**
  83629. * The unsigned integer type.
  83630. */
  83631. VertexBuffer.UNSIGNED_INT = 5125;
  83632. /**
  83633. * The float type.
  83634. */
  83635. VertexBuffer.FLOAT = 5126;
  83636. // Enums
  83637. /**
  83638. * Positions
  83639. */
  83640. VertexBuffer.PositionKind = "position";
  83641. /**
  83642. * Normals
  83643. */
  83644. VertexBuffer.NormalKind = "normal";
  83645. /**
  83646. * Tangents
  83647. */
  83648. VertexBuffer.TangentKind = "tangent";
  83649. /**
  83650. * Texture coordinates
  83651. */
  83652. VertexBuffer.UVKind = "uv";
  83653. /**
  83654. * Texture coordinates 2
  83655. */
  83656. VertexBuffer.UV2Kind = "uv2";
  83657. /**
  83658. * Texture coordinates 3
  83659. */
  83660. VertexBuffer.UV3Kind = "uv3";
  83661. /**
  83662. * Texture coordinates 4
  83663. */
  83664. VertexBuffer.UV4Kind = "uv4";
  83665. /**
  83666. * Texture coordinates 5
  83667. */
  83668. VertexBuffer.UV5Kind = "uv5";
  83669. /**
  83670. * Texture coordinates 6
  83671. */
  83672. VertexBuffer.UV6Kind = "uv6";
  83673. /**
  83674. * Colors
  83675. */
  83676. VertexBuffer.ColorKind = "color";
  83677. /**
  83678. * Matrix indices (for bones)
  83679. */
  83680. VertexBuffer.MatricesIndicesKind = "matricesIndices";
  83681. /**
  83682. * Matrix weights (for bones)
  83683. */
  83684. VertexBuffer.MatricesWeightsKind = "matricesWeights";
  83685. /**
  83686. * Additional matrix indices (for bones)
  83687. */
  83688. VertexBuffer.MatricesIndicesExtraKind = "matricesIndicesExtra";
  83689. /**
  83690. * Additional matrix weights (for bones)
  83691. */
  83692. VertexBuffer.MatricesWeightsExtraKind = "matricesWeightsExtra";
  83693. return VertexBuffer;
  83694. }());
  83695. /***/ }),
  83696. /***/ "./Meshes/csg.ts":
  83697. /*!***********************!*\
  83698. !*** ./Meshes/csg.ts ***!
  83699. \***********************/
  83700. /*! exports provided: CSG */
  83701. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83702. "use strict";
  83703. __webpack_require__.r(__webpack_exports__);
  83704. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return CSG; });
  83705. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  83706. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  83707. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  83708. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  83709. /**
  83710. * Unique ID when we import meshes from Babylon to CSG
  83711. */
  83712. var currentCSGMeshId = 0;
  83713. /**
  83714. * Represents a vertex of a polygon. Use your own vertex class instead of this
  83715. * one to provide additional features like texture coordinates and vertex
  83716. * colors. Custom vertex classes need to provide a `pos` property and `clone()`,
  83717. * `flip()`, and `interpolate()` methods that behave analogous to the ones
  83718. * defined by `BABYLON.CSG.Vertex`. This class provides `normal` so convenience
  83719. * functions like `BABYLON.CSG.sphere()` can return a smooth vertex normal, but `normal`
  83720. * is not used anywhere else.
  83721. * Same goes for uv, it allows to keep the original vertex uv coordinates of the 2 meshes
  83722. */
  83723. var Vertex = /** @class */ (function () {
  83724. /**
  83725. * Initializes the vertex
  83726. * @param pos The position of the vertex
  83727. * @param normal The normal of the vertex
  83728. * @param uv The texture coordinate of the vertex
  83729. */
  83730. function Vertex(
  83731. /**
  83732. * The position of the vertex
  83733. */
  83734. pos,
  83735. /**
  83736. * The normal of the vertex
  83737. */
  83738. normal,
  83739. /**
  83740. * The texture coordinate of the vertex
  83741. */
  83742. uv) {
  83743. this.pos = pos;
  83744. this.normal = normal;
  83745. this.uv = uv;
  83746. }
  83747. /**
  83748. * Make a clone, or deep copy, of the vertex
  83749. * @returns A new Vertex
  83750. */
  83751. Vertex.prototype.clone = function () {
  83752. return new Vertex(this.pos.clone(), this.normal.clone(), this.uv.clone());
  83753. };
  83754. /**
  83755. * Invert all orientation-specific data (e.g. vertex normal). Called when the
  83756. * orientation of a polygon is flipped.
  83757. */
  83758. Vertex.prototype.flip = function () {
  83759. this.normal = this.normal.scale(-1);
  83760. };
  83761. /**
  83762. * Create a new vertex between this vertex and `other` by linearly
  83763. * interpolating all properties using a parameter of `t`. Subclasses should
  83764. * override this to interpolate additional properties.
  83765. * @param other the vertex to interpolate against
  83766. * @param t The factor used to linearly interpolate between the vertices
  83767. */
  83768. Vertex.prototype.interpolate = function (other, t) {
  83769. 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));
  83770. };
  83771. return Vertex;
  83772. }());
  83773. /**
  83774. * Represents a plane in 3D space.
  83775. */
  83776. var Plane = /** @class */ (function () {
  83777. /**
  83778. * Initializes the plane
  83779. * @param normal The normal for the plane
  83780. * @param w
  83781. */
  83782. function Plane(normal, w) {
  83783. this.normal = normal;
  83784. this.w = w;
  83785. }
  83786. /**
  83787. * Construct a plane from three points
  83788. * @param a Point a
  83789. * @param b Point b
  83790. * @param c Point c
  83791. */
  83792. Plane.FromPoints = function (a, b, c) {
  83793. var v0 = c.subtract(a);
  83794. var v1 = b.subtract(a);
  83795. if (v0.lengthSquared() === 0 || v1.lengthSquared() === 0) {
  83796. return null;
  83797. }
  83798. var n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v0, v1));
  83799. return new Plane(n, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(n, a));
  83800. };
  83801. /**
  83802. * Clone, or make a deep copy of the plane
  83803. * @returns a new Plane
  83804. */
  83805. Plane.prototype.clone = function () {
  83806. return new Plane(this.normal.clone(), this.w);
  83807. };
  83808. /**
  83809. * Flip the face of the plane
  83810. */
  83811. Plane.prototype.flip = function () {
  83812. this.normal.scaleInPlace(-1);
  83813. this.w = -this.w;
  83814. };
  83815. /**
  83816. * Split `polygon` by this plane if needed, then put the polygon or polygon
  83817. * fragments in the appropriate lists. Coplanar polygons go into either
  83818. `* coplanarFront` or `coplanarBack` depending on their orientation with
  83819. * respect to this plane. Polygons in front or in back of this plane go into
  83820. * either `front` or `back`
  83821. * @param polygon The polygon to be split
  83822. * @param coplanarFront Will contain polygons coplanar with the plane that are oriented to the front of the plane
  83823. * @param coplanarBack Will contain polygons coplanar with the plane that are oriented to the back of the plane
  83824. * @param front Will contain the polygons in front of the plane
  83825. * @param back Will contain the polygons begind the plane
  83826. */
  83827. Plane.prototype.splitPolygon = function (polygon, coplanarFront, coplanarBack, front, back) {
  83828. var COPLANAR = 0;
  83829. var FRONT = 1;
  83830. var BACK = 2;
  83831. var SPANNING = 3;
  83832. // Classify each point as well as the entire polygon into one of the above
  83833. // four classes.
  83834. var polygonType = 0;
  83835. var types = [];
  83836. var i;
  83837. var t;
  83838. for (i = 0; i < polygon.vertices.length; i++) {
  83839. t = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.vertices[i].pos) - this.w;
  83840. var type = (t < -Plane.EPSILON) ? BACK : (t > Plane.EPSILON) ? FRONT : COPLANAR;
  83841. polygonType |= type;
  83842. types.push(type);
  83843. }
  83844. // Put the polygon in the correct list, splitting it when necessary
  83845. switch (polygonType) {
  83846. case COPLANAR:
  83847. (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.plane.normal) > 0 ? coplanarFront : coplanarBack).push(polygon);
  83848. break;
  83849. case FRONT:
  83850. front.push(polygon);
  83851. break;
  83852. case BACK:
  83853. back.push(polygon);
  83854. break;
  83855. case SPANNING:
  83856. var f = [], b = [];
  83857. for (i = 0; i < polygon.vertices.length; i++) {
  83858. var j = (i + 1) % polygon.vertices.length;
  83859. var ti = types[i], tj = types[j];
  83860. var vi = polygon.vertices[i], vj = polygon.vertices[j];
  83861. if (ti !== BACK) {
  83862. f.push(vi);
  83863. }
  83864. if (ti !== FRONT) {
  83865. b.push(ti !== BACK ? vi.clone() : vi);
  83866. }
  83867. if ((ti | tj) === SPANNING) {
  83868. 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));
  83869. var v = vi.interpolate(vj, t);
  83870. f.push(v);
  83871. b.push(v.clone());
  83872. }
  83873. }
  83874. var poly;
  83875. if (f.length >= 3) {
  83876. poly = new Polygon(f, polygon.shared);
  83877. if (poly.plane) {
  83878. front.push(poly);
  83879. }
  83880. }
  83881. if (b.length >= 3) {
  83882. poly = new Polygon(b, polygon.shared);
  83883. if (poly.plane) {
  83884. back.push(poly);
  83885. }
  83886. }
  83887. break;
  83888. }
  83889. };
  83890. /**
  83891. * `CSG.Plane.EPSILON` is the tolerance used by `splitPolygon()` to decide if a
  83892. * point is on the plane
  83893. */
  83894. Plane.EPSILON = 1e-5;
  83895. return Plane;
  83896. }());
  83897. /**
  83898. * Represents a convex polygon. The vertices used to initialize a polygon must
  83899. * be coplanar and form a convex loop.
  83900. *
  83901. * Each convex polygon has a `shared` property, which is shared between all
  83902. * polygons that are clones of each other or were split from the same polygon.
  83903. * This can be used to define per-polygon properties (such as surface color)
  83904. */
  83905. var Polygon = /** @class */ (function () {
  83906. /**
  83907. * Initializes the polygon
  83908. * @param vertices The vertices of the polygon
  83909. * @param shared The properties shared across all polygons
  83910. */
  83911. function Polygon(vertices, shared) {
  83912. this.vertices = vertices;
  83913. this.shared = shared;
  83914. this.plane = Plane.FromPoints(vertices[0].pos, vertices[1].pos, vertices[2].pos);
  83915. }
  83916. /**
  83917. * Clones, or makes a deep copy, or the polygon
  83918. */
  83919. Polygon.prototype.clone = function () {
  83920. var vertices = this.vertices.map(function (v) { return v.clone(); });
  83921. return new Polygon(vertices, this.shared);
  83922. };
  83923. /**
  83924. * Flips the faces of the polygon
  83925. */
  83926. Polygon.prototype.flip = function () {
  83927. this.vertices.reverse().map(function (v) { v.flip(); });
  83928. this.plane.flip();
  83929. };
  83930. return Polygon;
  83931. }());
  83932. /**
  83933. * Holds a node in a BSP tree. A BSP tree is built from a collection of polygons
  83934. * by picking a polygon to split along. That polygon (and all other coplanar
  83935. * polygons) are added directly to that node and the other polygons are added to
  83936. * the front and/or back subtrees. This is not a leafy BSP tree since there is
  83937. * no distinction between internal and leaf nodes
  83938. */
  83939. var Node = /** @class */ (function () {
  83940. /**
  83941. * Initializes the node
  83942. * @param polygons A collection of polygons held in the node
  83943. */
  83944. function Node(polygons) {
  83945. this.plane = null;
  83946. this.front = null;
  83947. this.back = null;
  83948. this.polygons = new Array();
  83949. if (polygons) {
  83950. this.build(polygons);
  83951. }
  83952. }
  83953. /**
  83954. * Clones, or makes a deep copy, of the node
  83955. * @returns The cloned node
  83956. */
  83957. Node.prototype.clone = function () {
  83958. var node = new Node();
  83959. node.plane = this.plane && this.plane.clone();
  83960. node.front = this.front && this.front.clone();
  83961. node.back = this.back && this.back.clone();
  83962. node.polygons = this.polygons.map(function (p) { return p.clone(); });
  83963. return node;
  83964. };
  83965. /**
  83966. * Convert solid space to empty space and empty space to solid space
  83967. */
  83968. Node.prototype.invert = function () {
  83969. for (var i = 0; i < this.polygons.length; i++) {
  83970. this.polygons[i].flip();
  83971. }
  83972. if (this.plane) {
  83973. this.plane.flip();
  83974. }
  83975. if (this.front) {
  83976. this.front.invert();
  83977. }
  83978. if (this.back) {
  83979. this.back.invert();
  83980. }
  83981. var temp = this.front;
  83982. this.front = this.back;
  83983. this.back = temp;
  83984. };
  83985. /**
  83986. * Recursively remove all polygons in `polygons` that are inside this BSP
  83987. * tree.
  83988. * @param polygons Polygons to remove from the BSP
  83989. * @returns Polygons clipped from the BSP
  83990. */
  83991. Node.prototype.clipPolygons = function (polygons) {
  83992. if (!this.plane) {
  83993. return polygons.slice();
  83994. }
  83995. var front = new Array(), back = new Array();
  83996. for (var i = 0; i < polygons.length; i++) {
  83997. this.plane.splitPolygon(polygons[i], front, back, front, back);
  83998. }
  83999. if (this.front) {
  84000. front = this.front.clipPolygons(front);
  84001. }
  84002. if (this.back) {
  84003. back = this.back.clipPolygons(back);
  84004. }
  84005. else {
  84006. back = [];
  84007. }
  84008. return front.concat(back);
  84009. };
  84010. /**
  84011. * Remove all polygons in this BSP tree that are inside the other BSP tree
  84012. * `bsp`.
  84013. * @param bsp BSP containing polygons to remove from this BSP
  84014. */
  84015. Node.prototype.clipTo = function (bsp) {
  84016. this.polygons = bsp.clipPolygons(this.polygons);
  84017. if (this.front) {
  84018. this.front.clipTo(bsp);
  84019. }
  84020. if (this.back) {
  84021. this.back.clipTo(bsp);
  84022. }
  84023. };
  84024. /**
  84025. * Return a list of all polygons in this BSP tree
  84026. * @returns List of all polygons in this BSP tree
  84027. */
  84028. Node.prototype.allPolygons = function () {
  84029. var polygons = this.polygons.slice();
  84030. if (this.front) {
  84031. polygons = polygons.concat(this.front.allPolygons());
  84032. }
  84033. if (this.back) {
  84034. polygons = polygons.concat(this.back.allPolygons());
  84035. }
  84036. return polygons;
  84037. };
  84038. /**
  84039. * Build a BSP tree out of `polygons`. When called on an existing tree, the
  84040. * new polygons are filtered down to the bottom of the tree and become new
  84041. * nodes there. Each set of polygons is partitioned using the first polygon
  84042. * (no heuristic is used to pick a good split)
  84043. * @param polygons Polygons used to construct the BSP tree
  84044. */
  84045. Node.prototype.build = function (polygons) {
  84046. if (!polygons.length) {
  84047. return;
  84048. }
  84049. if (!this.plane) {
  84050. this.plane = polygons[0].plane.clone();
  84051. }
  84052. var front = new Array(), back = new Array();
  84053. for (var i = 0; i < polygons.length; i++) {
  84054. this.plane.splitPolygon(polygons[i], this.polygons, this.polygons, front, back);
  84055. }
  84056. if (front.length) {
  84057. if (!this.front) {
  84058. this.front = new Node();
  84059. }
  84060. this.front.build(front);
  84061. }
  84062. if (back.length) {
  84063. if (!this.back) {
  84064. this.back = new Node();
  84065. }
  84066. this.back.build(back);
  84067. }
  84068. };
  84069. return Node;
  84070. }());
  84071. /**
  84072. * Class for building Constructive Solid Geometry
  84073. */
  84074. var CSG = /** @class */ (function () {
  84075. function CSG() {
  84076. this.polygons = new Array();
  84077. }
  84078. /**
  84079. * Convert the Mesh to CSG
  84080. * @param mesh The Mesh to convert to CSG
  84081. * @returns A new CSG from the Mesh
  84082. */
  84083. CSG.FromMesh = function (mesh) {
  84084. var vertex, normal, uv, position, polygon, polygons = new Array(), vertices;
  84085. var matrix, meshPosition, meshRotation, meshRotationQuaternion = null, meshScaling;
  84086. if (mesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]) {
  84087. mesh.computeWorldMatrix(true);
  84088. matrix = mesh.getWorldMatrix();
  84089. meshPosition = mesh.position.clone();
  84090. meshRotation = mesh.rotation.clone();
  84091. if (mesh.rotationQuaternion) {
  84092. meshRotationQuaternion = mesh.rotationQuaternion.clone();
  84093. }
  84094. meshScaling = mesh.scaling.clone();
  84095. }
  84096. else {
  84097. throw 'BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh';
  84098. }
  84099. 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);
  84100. var subMeshes = mesh.subMeshes;
  84101. for (var sm = 0, sml = subMeshes.length; sm < sml; sm++) {
  84102. for (var i = subMeshes[sm].indexStart, il = subMeshes[sm].indexCount + subMeshes[sm].indexStart; i < il; i += 3) {
  84103. vertices = [];
  84104. for (var j = 0; j < 3; j++) {
  84105. 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]);
  84106. uv = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uvs[indices[i + j] * 2], uvs[indices[i + j] * 2 + 1]);
  84107. 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]);
  84108. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(sourcePosition, matrix);
  84109. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(sourceNormal, matrix);
  84110. vertex = new Vertex(position, normal, uv);
  84111. vertices.push(vertex);
  84112. }
  84113. polygon = new Polygon(vertices, { subMeshId: sm, meshId: currentCSGMeshId, materialIndex: subMeshes[sm].materialIndex });
  84114. // To handle the case of degenerated triangle
  84115. // polygon.plane == null <=> the polygon does not represent 1 single plane <=> the triangle is degenerated
  84116. if (polygon.plane) {
  84117. polygons.push(polygon);
  84118. }
  84119. }
  84120. }
  84121. var csg = CSG.FromPolygons(polygons);
  84122. csg.matrix = matrix;
  84123. csg.position = meshPosition;
  84124. csg.rotation = meshRotation;
  84125. csg.scaling = meshScaling;
  84126. csg.rotationQuaternion = meshRotationQuaternion;
  84127. currentCSGMeshId++;
  84128. return csg;
  84129. };
  84130. /**
  84131. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  84132. * @param polygons Polygons used to construct a CSG solid
  84133. */
  84134. CSG.FromPolygons = function (polygons) {
  84135. var csg = new CSG();
  84136. csg.polygons = polygons;
  84137. return csg;
  84138. };
  84139. /**
  84140. * Clones, or makes a deep copy, of the CSG
  84141. * @returns A new CSG
  84142. */
  84143. CSG.prototype.clone = function () {
  84144. var csg = new CSG();
  84145. csg.polygons = this.polygons.map(function (p) { return p.clone(); });
  84146. csg.copyTransformAttributes(this);
  84147. return csg;
  84148. };
  84149. /**
  84150. * Unions this CSG with another CSG
  84151. * @param csg The CSG to union against this CSG
  84152. * @returns The unioned CSG
  84153. */
  84154. CSG.prototype.union = function (csg) {
  84155. var a = new Node(this.clone().polygons);
  84156. var b = new Node(csg.clone().polygons);
  84157. a.clipTo(b);
  84158. b.clipTo(a);
  84159. b.invert();
  84160. b.clipTo(a);
  84161. b.invert();
  84162. a.build(b.allPolygons());
  84163. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  84164. };
  84165. /**
  84166. * Unions this CSG with another CSG in place
  84167. * @param csg The CSG to union against this CSG
  84168. */
  84169. CSG.prototype.unionInPlace = function (csg) {
  84170. var a = new Node(this.polygons);
  84171. var b = new Node(csg.polygons);
  84172. a.clipTo(b);
  84173. b.clipTo(a);
  84174. b.invert();
  84175. b.clipTo(a);
  84176. b.invert();
  84177. a.build(b.allPolygons());
  84178. this.polygons = a.allPolygons();
  84179. };
  84180. /**
  84181. * Subtracts this CSG with another CSG
  84182. * @param csg The CSG to subtract against this CSG
  84183. * @returns A new CSG
  84184. */
  84185. CSG.prototype.subtract = function (csg) {
  84186. var a = new Node(this.clone().polygons);
  84187. var b = new Node(csg.clone().polygons);
  84188. a.invert();
  84189. a.clipTo(b);
  84190. b.clipTo(a);
  84191. b.invert();
  84192. b.clipTo(a);
  84193. b.invert();
  84194. a.build(b.allPolygons());
  84195. a.invert();
  84196. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  84197. };
  84198. /**
  84199. * Subtracts this CSG with another CSG in place
  84200. * @param csg The CSG to subtact against this CSG
  84201. */
  84202. CSG.prototype.subtractInPlace = function (csg) {
  84203. var a = new Node(this.polygons);
  84204. var b = new Node(csg.polygons);
  84205. a.invert();
  84206. a.clipTo(b);
  84207. b.clipTo(a);
  84208. b.invert();
  84209. b.clipTo(a);
  84210. b.invert();
  84211. a.build(b.allPolygons());
  84212. a.invert();
  84213. this.polygons = a.allPolygons();
  84214. };
  84215. /**
  84216. * Intersect this CSG with another CSG
  84217. * @param csg The CSG to intersect against this CSG
  84218. * @returns A new CSG
  84219. */
  84220. CSG.prototype.intersect = function (csg) {
  84221. var a = new Node(this.clone().polygons);
  84222. var b = new Node(csg.clone().polygons);
  84223. a.invert();
  84224. b.clipTo(a);
  84225. b.invert();
  84226. a.clipTo(b);
  84227. b.clipTo(a);
  84228. a.build(b.allPolygons());
  84229. a.invert();
  84230. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  84231. };
  84232. /**
  84233. * Intersects this CSG with another CSG in place
  84234. * @param csg The CSG to intersect against this CSG
  84235. */
  84236. CSG.prototype.intersectInPlace = function (csg) {
  84237. var a = new Node(this.polygons);
  84238. var b = new Node(csg.polygons);
  84239. a.invert();
  84240. b.clipTo(a);
  84241. b.invert();
  84242. a.clipTo(b);
  84243. b.clipTo(a);
  84244. a.build(b.allPolygons());
  84245. a.invert();
  84246. this.polygons = a.allPolygons();
  84247. };
  84248. /**
  84249. * Return a new CSG solid with solid and empty space switched. This solid is
  84250. * not modified.
  84251. * @returns A new CSG solid with solid and empty space switched
  84252. */
  84253. CSG.prototype.inverse = function () {
  84254. var csg = this.clone();
  84255. csg.inverseInPlace();
  84256. return csg;
  84257. };
  84258. /**
  84259. * Inverses the CSG in place
  84260. */
  84261. CSG.prototype.inverseInPlace = function () {
  84262. this.polygons.map(function (p) { p.flip(); });
  84263. };
  84264. /**
  84265. * This is used to keep meshes transformations so they can be restored
  84266. * when we build back a Babylon Mesh
  84267. * NB : All CSG operations are performed in world coordinates
  84268. * @param csg The CSG to copy the transform attributes from
  84269. * @returns This CSG
  84270. */
  84271. CSG.prototype.copyTransformAttributes = function (csg) {
  84272. this.matrix = csg.matrix;
  84273. this.position = csg.position;
  84274. this.rotation = csg.rotation;
  84275. this.scaling = csg.scaling;
  84276. this.rotationQuaternion = csg.rotationQuaternion;
  84277. return this;
  84278. };
  84279. /**
  84280. * Build Raw mesh from CSG
  84281. * Coordinates here are in world space
  84282. * @param name The name of the mesh geometry
  84283. * @param scene The Scene
  84284. * @param keepSubMeshes Specifies if the submeshes should be kept
  84285. * @returns A new Mesh
  84286. */
  84287. CSG.prototype.buildMeshGeometry = function (name, scene, keepSubMeshes) {
  84288. var matrix = this.matrix.clone();
  84289. matrix.invert();
  84290. 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;
  84291. if (keepSubMeshes) {
  84292. // Sort Polygons, since subMeshes are indices range
  84293. polygons.sort(function (a, b) {
  84294. if (a.shared.meshId === b.shared.meshId) {
  84295. return a.shared.subMeshId - b.shared.subMeshId;
  84296. }
  84297. else {
  84298. return a.shared.meshId - b.shared.meshId;
  84299. }
  84300. });
  84301. }
  84302. for (var i = 0, il = polygons.length; i < il; i++) {
  84303. polygon = polygons[i];
  84304. // Building SubMeshes
  84305. if (!subMesh_dict[polygon.shared.meshId]) {
  84306. subMesh_dict[polygon.shared.meshId] = {};
  84307. }
  84308. if (!subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId]) {
  84309. subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId] = {
  84310. indexStart: +Infinity,
  84311. indexEnd: -Infinity,
  84312. materialIndex: polygon.shared.materialIndex
  84313. };
  84314. }
  84315. subMesh_obj = subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId];
  84316. for (var j = 2, jl = polygon.vertices.length; j < jl; j++) {
  84317. polygonIndices[0] = 0;
  84318. polygonIndices[1] = j - 1;
  84319. polygonIndices[2] = j;
  84320. for (var k = 0; k < 3; k++) {
  84321. vertex.copyFrom(polygon.vertices[polygonIndices[k]].pos);
  84322. normal.copyFrom(polygon.vertices[polygonIndices[k]].normal);
  84323. uv.copyFrom(polygon.vertices[polygonIndices[k]].uv);
  84324. var localVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(vertex, matrix);
  84325. var localNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, matrix);
  84326. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z];
  84327. // Check if 2 points can be merged
  84328. if (!(typeof vertex_idx !== 'undefined' &&
  84329. normals[vertex_idx * 3] === localNormal.x &&
  84330. normals[vertex_idx * 3 + 1] === localNormal.y &&
  84331. normals[vertex_idx * 3 + 2] === localNormal.z &&
  84332. uvs[vertex_idx * 2] === uv.x &&
  84333. uvs[vertex_idx * 2 + 1] === uv.y)) {
  84334. vertices.push(localVertex.x, localVertex.y, localVertex.z);
  84335. uvs.push(uv.x, uv.y);
  84336. normals.push(normal.x, normal.y, normal.z);
  84337. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z] = (vertices.length / 3) - 1;
  84338. }
  84339. indices.push(vertex_idx);
  84340. subMesh_obj.indexStart = Math.min(currentIndex, subMesh_obj.indexStart);
  84341. subMesh_obj.indexEnd = Math.max(currentIndex, subMesh_obj.indexEnd);
  84342. currentIndex++;
  84343. }
  84344. }
  84345. }
  84346. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, vertices);
  84347. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals);
  84348. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs);
  84349. mesh.setIndices(indices, null);
  84350. if (keepSubMeshes) {
  84351. // We offset the materialIndex by the previous number of materials in the CSG mixed meshes
  84352. var materialIndexOffset = 0, materialMaxIndex;
  84353. mesh.subMeshes = new Array();
  84354. for (var m in subMesh_dict) {
  84355. materialMaxIndex = -1;
  84356. for (var sm in subMesh_dict[m]) {
  84357. subMesh_obj = subMesh_dict[m][sm];
  84358. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].CreateFromIndices(subMesh_obj.materialIndex + materialIndexOffset, subMesh_obj.indexStart, subMesh_obj.indexEnd - subMesh_obj.indexStart + 1, mesh);
  84359. materialMaxIndex = Math.max(subMesh_obj.materialIndex, materialMaxIndex);
  84360. }
  84361. materialIndexOffset += ++materialMaxIndex;
  84362. }
  84363. }
  84364. return mesh;
  84365. };
  84366. /**
  84367. * Build Mesh from CSG taking material and transforms into account
  84368. * @param name The name of the Mesh
  84369. * @param material The material of the Mesh
  84370. * @param scene The Scene
  84371. * @param keepSubMeshes Specifies if submeshes should be kept
  84372. * @returns The new Mesh
  84373. */
  84374. CSG.prototype.toMesh = function (name, material, scene, keepSubMeshes) {
  84375. var mesh = this.buildMeshGeometry(name, scene, keepSubMeshes);
  84376. mesh.material = material;
  84377. mesh.position.copyFrom(this.position);
  84378. mesh.rotation.copyFrom(this.rotation);
  84379. if (this.rotationQuaternion) {
  84380. mesh.rotationQuaternion = this.rotationQuaternion.clone();
  84381. }
  84382. mesh.scaling.copyFrom(this.scaling);
  84383. mesh.computeWorldMatrix(true);
  84384. return mesh;
  84385. };
  84386. return CSG;
  84387. }());
  84388. /***/ }),
  84389. /***/ "./Meshes/geometry.ts":
  84390. /*!****************************!*\
  84391. !*** ./Meshes/geometry.ts ***!
  84392. \****************************/
  84393. /*! exports provided: Geometry */
  84394. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  84395. "use strict";
  84396. __webpack_require__.r(__webpack_exports__);
  84397. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return Geometry; });
  84398. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  84399. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  84400. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  84401. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  84402. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  84403. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  84404. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  84405. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  84406. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  84407. /**
  84408. * Class used to store geometry data (vertex buffers + index buffer)
  84409. */
  84410. var Geometry = /** @class */ (function () {
  84411. /**
  84412. * Creates a new geometry
  84413. * @param id defines the unique ID
  84414. * @param scene defines the hosting scene
  84415. * @param vertexData defines the VertexData used to get geometry data
  84416. * @param updatable defines if geometry must be updatable (false by default)
  84417. * @param mesh defines the mesh that will be associated with the geometry
  84418. */
  84419. function Geometry(id, scene, vertexData, updatable, mesh) {
  84420. if (updatable === void 0) { updatable = false; }
  84421. if (mesh === void 0) { mesh = null; }
  84422. /**
  84423. * Gets the delay loading state of the geometry (none by default which means not delayed)
  84424. */
  84425. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  84426. this._totalVertices = 0;
  84427. this._isDisposed = false;
  84428. this._indexBufferIsUpdatable = false;
  84429. this.id = id;
  84430. this.uniqueId = scene.getUniqueId();
  84431. this._engine = scene.getEngine();
  84432. this._meshes = [];
  84433. this._scene = scene;
  84434. //Init vertex buffer cache
  84435. this._vertexBuffers = {};
  84436. this._indices = [];
  84437. this._updatable = updatable;
  84438. // vertexData
  84439. if (vertexData) {
  84440. this.setAllVerticesData(vertexData, updatable);
  84441. }
  84442. else {
  84443. this._totalVertices = 0;
  84444. this._indices = [];
  84445. }
  84446. if (this._engine.getCaps().vertexArrayObject) {
  84447. this._vertexArrayObjects = {};
  84448. }
  84449. // applyToMesh
  84450. if (mesh) {
  84451. this.applyToMesh(mesh);
  84452. mesh.computeWorldMatrix(true);
  84453. }
  84454. }
  84455. Object.defineProperty(Geometry.prototype, "boundingBias", {
  84456. /**
  84457. * 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
  84458. */
  84459. get: function () {
  84460. return this._boundingBias;
  84461. },
  84462. /**
  84463. * 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
  84464. */
  84465. set: function (value) {
  84466. if (this._boundingBias) {
  84467. this._boundingBias.copyFrom(value);
  84468. }
  84469. else {
  84470. this._boundingBias = value.clone();
  84471. }
  84472. this._updateBoundingInfo(true, null);
  84473. },
  84474. enumerable: true,
  84475. configurable: true
  84476. });
  84477. /**
  84478. * Static function used to attach a new empty geometry to a mesh
  84479. * @param mesh defines the mesh to attach the geometry to
  84480. * @returns the new Geometry
  84481. */
  84482. Geometry.CreateGeometryForMesh = function (mesh) {
  84483. var geometry = new Geometry(Geometry.RandomId(), mesh.getScene());
  84484. geometry.applyToMesh(mesh);
  84485. return geometry;
  84486. };
  84487. Object.defineProperty(Geometry.prototype, "extend", {
  84488. /**
  84489. * Gets the current extend of the geometry
  84490. */
  84491. get: function () {
  84492. return this._extend;
  84493. },
  84494. enumerable: true,
  84495. configurable: true
  84496. });
  84497. /**
  84498. * Gets the hosting scene
  84499. * @returns the hosting Scene
  84500. */
  84501. Geometry.prototype.getScene = function () {
  84502. return this._scene;
  84503. };
  84504. /**
  84505. * Gets the hosting engine
  84506. * @returns the hosting Engine
  84507. */
  84508. Geometry.prototype.getEngine = function () {
  84509. return this._engine;
  84510. };
  84511. /**
  84512. * Defines if the geometry is ready to use
  84513. * @returns true if the geometry is ready to be used
  84514. */
  84515. Geometry.prototype.isReady = function () {
  84516. return this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED || this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  84517. };
  84518. Object.defineProperty(Geometry.prototype, "doNotSerialize", {
  84519. /**
  84520. * Gets a value indicating that the geometry should not be serialized
  84521. */
  84522. get: function () {
  84523. for (var index = 0; index < this._meshes.length; index++) {
  84524. if (!this._meshes[index].doNotSerialize) {
  84525. return false;
  84526. }
  84527. }
  84528. return true;
  84529. },
  84530. enumerable: true,
  84531. configurable: true
  84532. });
  84533. /** @hidden */
  84534. Geometry.prototype._rebuild = function () {
  84535. if (this._vertexArrayObjects) {
  84536. this._vertexArrayObjects = {};
  84537. }
  84538. // Index buffer
  84539. if (this._meshes.length !== 0 && this._indices) {
  84540. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  84541. }
  84542. // Vertex buffers
  84543. for (var key in this._vertexBuffers) {
  84544. var vertexBuffer = this._vertexBuffers[key];
  84545. vertexBuffer._rebuild();
  84546. }
  84547. };
  84548. /**
  84549. * Affects all geometry data in one call
  84550. * @param vertexData defines the geometry data
  84551. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  84552. */
  84553. Geometry.prototype.setAllVerticesData = function (vertexData, updatable) {
  84554. vertexData.applyToGeometry(this, updatable);
  84555. this.notifyUpdate();
  84556. };
  84557. /**
  84558. * Set specific vertex data
  84559. * @param kind defines the data kind (Position, normal, etc...)
  84560. * @param data defines the vertex data to use
  84561. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  84562. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  84563. */
  84564. Geometry.prototype.setVerticesData = function (kind, data, updatable, stride) {
  84565. if (updatable === void 0) { updatable = false; }
  84566. var buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"](this._engine, data, kind, updatable, this._meshes.length === 0, stride);
  84567. this.setVerticesBuffer(buffer);
  84568. };
  84569. /**
  84570. * Removes a specific vertex data
  84571. * @param kind defines the data kind (Position, normal, etc...)
  84572. */
  84573. Geometry.prototype.removeVerticesData = function (kind) {
  84574. if (this._vertexBuffers[kind]) {
  84575. this._vertexBuffers[kind].dispose();
  84576. delete this._vertexBuffers[kind];
  84577. }
  84578. };
  84579. /**
  84580. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  84581. * @param buffer defines the vertex buffer to use
  84582. * @param totalVertices defines the total number of vertices for position kind (could be null)
  84583. */
  84584. Geometry.prototype.setVerticesBuffer = function (buffer, totalVertices) {
  84585. if (totalVertices === void 0) { totalVertices = null; }
  84586. var kind = buffer.getKind();
  84587. if (this._vertexBuffers[kind]) {
  84588. this._vertexBuffers[kind].dispose();
  84589. }
  84590. this._vertexBuffers[kind] = buffer;
  84591. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  84592. var data = buffer.getData();
  84593. if (totalVertices != null) {
  84594. this._totalVertices = totalVertices;
  84595. }
  84596. else {
  84597. if (data != null) {
  84598. this._totalVertices = data.length / (buffer.byteStride / 4);
  84599. }
  84600. }
  84601. this._updateExtend(data);
  84602. this._resetPointsArrayCache();
  84603. var meshes = this._meshes;
  84604. var numOfMeshes = meshes.length;
  84605. for (var index = 0; index < numOfMeshes; index++) {
  84606. var mesh = meshes[index];
  84607. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  84608. mesh._createGlobalSubMesh(false);
  84609. mesh.computeWorldMatrix(true);
  84610. }
  84611. }
  84612. this.notifyUpdate(kind);
  84613. if (this._vertexArrayObjects) {
  84614. this._disposeVertexArrayObjects();
  84615. this._vertexArrayObjects = {}; // Will trigger a rebuild of the VAO if supported
  84616. }
  84617. };
  84618. /**
  84619. * Update a specific vertex buffer
  84620. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  84621. * It will do nothing if the buffer is not updatable
  84622. * @param kind defines the data kind (Position, normal, etc...)
  84623. * @param data defines the data to use
  84624. * @param offset defines the offset in the target buffer where to store the data
  84625. * @param useBytes set to true if the offset is in bytes
  84626. */
  84627. Geometry.prototype.updateVerticesDataDirectly = function (kind, data, offset, useBytes) {
  84628. if (useBytes === void 0) { useBytes = false; }
  84629. var vertexBuffer = this.getVertexBuffer(kind);
  84630. if (!vertexBuffer) {
  84631. return;
  84632. }
  84633. vertexBuffer.updateDirectly(data, offset, useBytes);
  84634. this.notifyUpdate(kind);
  84635. };
  84636. /**
  84637. * Update a specific vertex buffer
  84638. * This function will create a new buffer if the current one is not updatable
  84639. * @param kind defines the data kind (Position, normal, etc...)
  84640. * @param data defines the data to use
  84641. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  84642. */
  84643. Geometry.prototype.updateVerticesData = function (kind, data, updateExtends) {
  84644. if (updateExtends === void 0) { updateExtends = false; }
  84645. var vertexBuffer = this.getVertexBuffer(kind);
  84646. if (!vertexBuffer) {
  84647. return;
  84648. }
  84649. vertexBuffer.update(data);
  84650. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  84651. this._updateBoundingInfo(updateExtends, data);
  84652. }
  84653. this.notifyUpdate(kind);
  84654. };
  84655. Geometry.prototype._updateBoundingInfo = function (updateExtends, data) {
  84656. if (updateExtends) {
  84657. this._updateExtend(data);
  84658. }
  84659. this._resetPointsArrayCache();
  84660. if (updateExtends) {
  84661. var meshes = this._meshes;
  84662. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  84663. var mesh = meshes_1[_i];
  84664. if (mesh._boundingInfo) {
  84665. mesh._boundingInfo.reConstruct(this._extend.minimum, this._extend.maximum);
  84666. }
  84667. else {
  84668. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  84669. }
  84670. var subMeshes = mesh.subMeshes;
  84671. for (var _a = 0, subMeshes_1 = subMeshes; _a < subMeshes_1.length; _a++) {
  84672. var subMesh = subMeshes_1[_a];
  84673. subMesh.refreshBoundingInfo();
  84674. }
  84675. }
  84676. }
  84677. };
  84678. /** @hidden */
  84679. Geometry.prototype._bind = function (effect, indexToBind) {
  84680. if (!effect) {
  84681. return;
  84682. }
  84683. if (indexToBind === undefined) {
  84684. indexToBind = this._indexBuffer;
  84685. }
  84686. var vbs = this.getVertexBuffers();
  84687. if (!vbs) {
  84688. return;
  84689. }
  84690. if (indexToBind != this._indexBuffer || !this._vertexArrayObjects) {
  84691. this._engine.bindBuffers(vbs, indexToBind, effect);
  84692. return;
  84693. }
  84694. // Using VAO
  84695. if (!this._vertexArrayObjects[effect.key]) {
  84696. this._vertexArrayObjects[effect.key] = this._engine.recordVertexArrayObject(vbs, indexToBind, effect);
  84697. }
  84698. this._engine.bindVertexArrayObject(this._vertexArrayObjects[effect.key], indexToBind);
  84699. };
  84700. /**
  84701. * Gets total number of vertices
  84702. * @returns the total number of vertices
  84703. */
  84704. Geometry.prototype.getTotalVertices = function () {
  84705. if (!this.isReady()) {
  84706. return 0;
  84707. }
  84708. return this._totalVertices;
  84709. };
  84710. /**
  84711. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  84712. * @param kind defines the data kind (Position, normal, etc...)
  84713. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84714. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84715. * @returns a float array containing vertex data
  84716. */
  84717. Geometry.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  84718. var vertexBuffer = this.getVertexBuffer(kind);
  84719. if (!vertexBuffer) {
  84720. return null;
  84721. }
  84722. var data = vertexBuffer.getData();
  84723. if (!data) {
  84724. return null;
  84725. }
  84726. var tightlyPackedByteStride = vertexBuffer.getSize() * _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].GetTypeByteLength(vertexBuffer.type);
  84727. var count = this._totalVertices * vertexBuffer.getSize();
  84728. if (vertexBuffer.type !== _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].FLOAT || vertexBuffer.byteStride !== tightlyPackedByteStride) {
  84729. var copy_1 = [];
  84730. vertexBuffer.forEach(count, function (value) { return copy_1.push(value); });
  84731. return copy_1;
  84732. }
  84733. if (!((data instanceof Array) || (data instanceof Float32Array)) || vertexBuffer.byteOffset !== 0 || data.length !== count) {
  84734. if (data instanceof Array) {
  84735. var offset = vertexBuffer.byteOffset / 4;
  84736. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data, offset, offset + count);
  84737. }
  84738. else if (data instanceof ArrayBuffer) {
  84739. return new Float32Array(data, vertexBuffer.byteOffset, count);
  84740. }
  84741. else {
  84742. var offset = data.byteOffset + vertexBuffer.byteOffset;
  84743. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  84744. var result = new Float32Array(count);
  84745. var source = new Float32Array(data.buffer, offset, count);
  84746. result.set(source);
  84747. return result;
  84748. }
  84749. return new Float32Array(data.buffer, offset, count);
  84750. }
  84751. }
  84752. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  84753. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data);
  84754. }
  84755. return data;
  84756. };
  84757. /**
  84758. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  84759. * @param kind defines the data kind (Position, normal, etc...)
  84760. * @returns true if the vertex buffer with the specified kind is updatable
  84761. */
  84762. Geometry.prototype.isVertexBufferUpdatable = function (kind) {
  84763. var vb = this._vertexBuffers[kind];
  84764. if (!vb) {
  84765. return false;
  84766. }
  84767. return vb.isUpdatable();
  84768. };
  84769. /**
  84770. * Gets a specific vertex buffer
  84771. * @param kind defines the data kind (Position, normal, etc...)
  84772. * @returns a VertexBuffer
  84773. */
  84774. Geometry.prototype.getVertexBuffer = function (kind) {
  84775. if (!this.isReady()) {
  84776. return null;
  84777. }
  84778. return this._vertexBuffers[kind];
  84779. };
  84780. /**
  84781. * Returns all vertex buffers
  84782. * @return an object holding all vertex buffers indexed by kind
  84783. */
  84784. Geometry.prototype.getVertexBuffers = function () {
  84785. if (!this.isReady()) {
  84786. return null;
  84787. }
  84788. return this._vertexBuffers;
  84789. };
  84790. /**
  84791. * Gets a boolean indicating if specific vertex buffer is present
  84792. * @param kind defines the data kind (Position, normal, etc...)
  84793. * @returns true if data is present
  84794. */
  84795. Geometry.prototype.isVerticesDataPresent = function (kind) {
  84796. if (!this._vertexBuffers) {
  84797. if (this._delayInfo) {
  84798. return this._delayInfo.indexOf(kind) !== -1;
  84799. }
  84800. return false;
  84801. }
  84802. return this._vertexBuffers[kind] !== undefined;
  84803. };
  84804. /**
  84805. * Gets a list of all attached data kinds (Position, normal, etc...)
  84806. * @returns a list of string containing all kinds
  84807. */
  84808. Geometry.prototype.getVerticesDataKinds = function () {
  84809. var result = [];
  84810. var kind;
  84811. if (!this._vertexBuffers && this._delayInfo) {
  84812. for (kind in this._delayInfo) {
  84813. result.push(kind);
  84814. }
  84815. }
  84816. else {
  84817. for (kind in this._vertexBuffers) {
  84818. result.push(kind);
  84819. }
  84820. }
  84821. return result;
  84822. };
  84823. /**
  84824. * Update index buffer
  84825. * @param indices defines the indices to store in the index buffer
  84826. * @param offset defines the offset in the target buffer where to store the data
  84827. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  84828. */
  84829. Geometry.prototype.updateIndices = function (indices, offset, gpuMemoryOnly) {
  84830. if (gpuMemoryOnly === void 0) { gpuMemoryOnly = false; }
  84831. if (!this._indexBuffer) {
  84832. return;
  84833. }
  84834. if (!this._indexBufferIsUpdatable) {
  84835. this.setIndices(indices, null, true);
  84836. }
  84837. else {
  84838. var needToUpdateSubMeshes = indices.length !== this._indices.length;
  84839. if (!gpuMemoryOnly) {
  84840. this._indices = indices.slice();
  84841. }
  84842. this._engine.updateDynamicIndexBuffer(this._indexBuffer, indices, offset);
  84843. if (needToUpdateSubMeshes) {
  84844. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  84845. var mesh = _a[_i];
  84846. mesh._createGlobalSubMesh(true);
  84847. }
  84848. }
  84849. }
  84850. };
  84851. /**
  84852. * Creates a new index buffer
  84853. * @param indices defines the indices to store in the index buffer
  84854. * @param totalVertices defines the total number of vertices (could be null)
  84855. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  84856. */
  84857. Geometry.prototype.setIndices = function (indices, totalVertices, updatable) {
  84858. if (totalVertices === void 0) { totalVertices = null; }
  84859. if (updatable === void 0) { updatable = false; }
  84860. if (this._indexBuffer) {
  84861. this._engine._releaseBuffer(this._indexBuffer);
  84862. }
  84863. this._disposeVertexArrayObjects();
  84864. this._indices = indices;
  84865. this._indexBufferIsUpdatable = updatable;
  84866. if (this._meshes.length !== 0 && this._indices) {
  84867. this._indexBuffer = this._engine.createIndexBuffer(this._indices, updatable);
  84868. }
  84869. if (totalVertices != undefined) { // including null and undefined
  84870. this._totalVertices = totalVertices;
  84871. }
  84872. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  84873. var mesh = _a[_i];
  84874. mesh._createGlobalSubMesh(true);
  84875. }
  84876. this.notifyUpdate();
  84877. };
  84878. /**
  84879. * Return the total number of indices
  84880. * @returns the total number of indices
  84881. */
  84882. Geometry.prototype.getTotalIndices = function () {
  84883. if (!this.isReady()) {
  84884. return 0;
  84885. }
  84886. return this._indices.length;
  84887. };
  84888. /**
  84889. * Gets the index buffer array
  84890. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84891. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84892. * @returns the index buffer array
  84893. */
  84894. Geometry.prototype.getIndices = function (copyWhenShared, forceCopy) {
  84895. if (!this.isReady()) {
  84896. return null;
  84897. }
  84898. var orig = this._indices;
  84899. if (!forceCopy && (!copyWhenShared || this._meshes.length === 1)) {
  84900. return orig;
  84901. }
  84902. else {
  84903. var len = orig.length;
  84904. var copy = [];
  84905. for (var i = 0; i < len; i++) {
  84906. copy.push(orig[i]);
  84907. }
  84908. return copy;
  84909. }
  84910. };
  84911. /**
  84912. * Gets the index buffer
  84913. * @return the index buffer
  84914. */
  84915. Geometry.prototype.getIndexBuffer = function () {
  84916. if (!this.isReady()) {
  84917. return null;
  84918. }
  84919. return this._indexBuffer;
  84920. };
  84921. /** @hidden */
  84922. Geometry.prototype._releaseVertexArrayObject = function (effect) {
  84923. if (effect === void 0) { effect = null; }
  84924. if (!effect || !this._vertexArrayObjects) {
  84925. return;
  84926. }
  84927. if (this._vertexArrayObjects[effect.key]) {
  84928. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[effect.key]);
  84929. delete this._vertexArrayObjects[effect.key];
  84930. }
  84931. };
  84932. /**
  84933. * Release the associated resources for a specific mesh
  84934. * @param mesh defines the source mesh
  84935. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  84936. */
  84937. Geometry.prototype.releaseForMesh = function (mesh, shouldDispose) {
  84938. var meshes = this._meshes;
  84939. var index = meshes.indexOf(mesh);
  84940. if (index === -1) {
  84941. return;
  84942. }
  84943. meshes.splice(index, 1);
  84944. mesh._geometry = null;
  84945. if (meshes.length === 0 && shouldDispose) {
  84946. this.dispose();
  84947. }
  84948. };
  84949. /**
  84950. * Apply current geometry to a given mesh
  84951. * @param mesh defines the mesh to apply geometry to
  84952. */
  84953. Geometry.prototype.applyToMesh = function (mesh) {
  84954. if (mesh._geometry === this) {
  84955. return;
  84956. }
  84957. var previousGeometry = mesh._geometry;
  84958. if (previousGeometry) {
  84959. previousGeometry.releaseForMesh(mesh);
  84960. }
  84961. var meshes = this._meshes;
  84962. // must be done before setting vertexBuffers because of mesh._createGlobalSubMesh()
  84963. mesh._geometry = this;
  84964. this._scene.pushGeometry(this);
  84965. meshes.push(mesh);
  84966. if (this.isReady()) {
  84967. this._applyToMesh(mesh);
  84968. }
  84969. else {
  84970. mesh._boundingInfo = this._boundingInfo;
  84971. }
  84972. };
  84973. Geometry.prototype._updateExtend = function (data) {
  84974. if (data === void 0) { data = null; }
  84975. if (!data) {
  84976. data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  84977. }
  84978. this._extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].ExtractMinAndMax(data, 0, this._totalVertices, this.boundingBias, 3);
  84979. };
  84980. Geometry.prototype._applyToMesh = function (mesh) {
  84981. var numOfMeshes = this._meshes.length;
  84982. // vertexBuffers
  84983. for (var kind in this._vertexBuffers) {
  84984. if (numOfMeshes === 1) {
  84985. this._vertexBuffers[kind].create();
  84986. }
  84987. var buffer = this._vertexBuffers[kind].getBuffer();
  84988. if (buffer) {
  84989. buffer.references = numOfMeshes;
  84990. }
  84991. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  84992. if (!this._extend) {
  84993. this._updateExtend();
  84994. }
  84995. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  84996. mesh._createGlobalSubMesh(false);
  84997. //bounding info was just created again, world matrix should be applied again.
  84998. mesh._updateBoundingInfo();
  84999. }
  85000. }
  85001. // indexBuffer
  85002. if (numOfMeshes === 1 && this._indices && this._indices.length > 0) {
  85003. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  85004. }
  85005. if (this._indexBuffer) {
  85006. this._indexBuffer.references = numOfMeshes;
  85007. }
  85008. // morphTargets
  85009. mesh._syncGeometryWithMorphTargetManager();
  85010. // instances
  85011. mesh.synchronizeInstances();
  85012. };
  85013. Geometry.prototype.notifyUpdate = function (kind) {
  85014. if (this.onGeometryUpdated) {
  85015. this.onGeometryUpdated(this, kind);
  85016. }
  85017. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  85018. var mesh = _a[_i];
  85019. mesh._markSubMeshesAsAttributesDirty();
  85020. }
  85021. };
  85022. /**
  85023. * Load the geometry if it was flagged as delay loaded
  85024. * @param scene defines the hosting scene
  85025. * @param onLoaded defines a callback called when the geometry is loaded
  85026. */
  85027. Geometry.prototype.load = function (scene, onLoaded) {
  85028. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING) {
  85029. return;
  85030. }
  85031. if (this.isReady()) {
  85032. if (onLoaded) {
  85033. onLoaded();
  85034. }
  85035. return;
  85036. }
  85037. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING;
  85038. this._queueLoad(scene, onLoaded);
  85039. };
  85040. Geometry.prototype._queueLoad = function (scene, onLoaded) {
  85041. var _this = this;
  85042. if (!this.delayLoadingFile) {
  85043. return;
  85044. }
  85045. scene._addPendingData(this);
  85046. scene._loadFile(this.delayLoadingFile, function (data) {
  85047. if (!_this._delayLoadingFunction) {
  85048. return;
  85049. }
  85050. _this._delayLoadingFunction(JSON.parse(data), _this);
  85051. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  85052. _this._delayInfo = [];
  85053. scene._removePendingData(_this);
  85054. var meshes = _this._meshes;
  85055. var numOfMeshes = meshes.length;
  85056. for (var index = 0; index < numOfMeshes; index++) {
  85057. _this._applyToMesh(meshes[index]);
  85058. }
  85059. if (onLoaded) {
  85060. onLoaded();
  85061. }
  85062. }, undefined, true);
  85063. };
  85064. /**
  85065. * Invert the geometry to move from a right handed system to a left handed one.
  85066. */
  85067. Geometry.prototype.toLeftHanded = function () {
  85068. // Flip faces
  85069. var tIndices = this.getIndices(false);
  85070. if (tIndices != null && tIndices.length > 0) {
  85071. for (var i = 0; i < tIndices.length; i += 3) {
  85072. var tTemp = tIndices[i + 0];
  85073. tIndices[i + 0] = tIndices[i + 2];
  85074. tIndices[i + 2] = tTemp;
  85075. }
  85076. this.setIndices(tIndices);
  85077. }
  85078. // Negate position.z
  85079. var tPositions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, false);
  85080. if (tPositions != null && tPositions.length > 0) {
  85081. for (var i = 0; i < tPositions.length; i += 3) {
  85082. tPositions[i + 2] = -tPositions[i + 2];
  85083. }
  85084. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, tPositions, false);
  85085. }
  85086. // Negate normal.z
  85087. var tNormals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, false);
  85088. if (tNormals != null && tNormals.length > 0) {
  85089. for (var i = 0; i < tNormals.length; i += 3) {
  85090. tNormals[i + 2] = -tNormals[i + 2];
  85091. }
  85092. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, tNormals, false);
  85093. }
  85094. };
  85095. // Cache
  85096. /** @hidden */
  85097. Geometry.prototype._resetPointsArrayCache = function () {
  85098. this._positions = null;
  85099. };
  85100. /** @hidden */
  85101. Geometry.prototype._generatePointsArray = function () {
  85102. if (this._positions) {
  85103. return true;
  85104. }
  85105. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  85106. if (!data || data.length === 0) {
  85107. return false;
  85108. }
  85109. this._positions = [];
  85110. for (var index = 0; index < data.length; index += 3) {
  85111. this._positions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(data, index));
  85112. }
  85113. return true;
  85114. };
  85115. /**
  85116. * Gets a value indicating if the geometry is disposed
  85117. * @returns true if the geometry was disposed
  85118. */
  85119. Geometry.prototype.isDisposed = function () {
  85120. return this._isDisposed;
  85121. };
  85122. Geometry.prototype._disposeVertexArrayObjects = function () {
  85123. if (this._vertexArrayObjects) {
  85124. for (var kind in this._vertexArrayObjects) {
  85125. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[kind]);
  85126. }
  85127. this._vertexArrayObjects = {};
  85128. }
  85129. };
  85130. /**
  85131. * Free all associated resources
  85132. */
  85133. Geometry.prototype.dispose = function () {
  85134. var meshes = this._meshes;
  85135. var numOfMeshes = meshes.length;
  85136. var index;
  85137. for (index = 0; index < numOfMeshes; index++) {
  85138. this.releaseForMesh(meshes[index]);
  85139. }
  85140. this._meshes = [];
  85141. this._disposeVertexArrayObjects();
  85142. for (var kind in this._vertexBuffers) {
  85143. this._vertexBuffers[kind].dispose();
  85144. }
  85145. this._vertexBuffers = {};
  85146. this._totalVertices = 0;
  85147. if (this._indexBuffer) {
  85148. this._engine._releaseBuffer(this._indexBuffer);
  85149. }
  85150. this._indexBuffer = null;
  85151. this._indices = [];
  85152. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  85153. this.delayLoadingFile = null;
  85154. this._delayLoadingFunction = null;
  85155. this._delayInfo = [];
  85156. this._boundingInfo = null;
  85157. this._scene.removeGeometry(this);
  85158. this._isDisposed = true;
  85159. };
  85160. /**
  85161. * Clone the current geometry into a new geometry
  85162. * @param id defines the unique ID of the new geometry
  85163. * @returns a new geometry object
  85164. */
  85165. Geometry.prototype.copy = function (id) {
  85166. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  85167. vertexData.indices = [];
  85168. var indices = this.getIndices();
  85169. if (indices) {
  85170. for (var index = 0; index < indices.length; index++) {
  85171. vertexData.indices.push(indices[index]);
  85172. }
  85173. }
  85174. var updatable = false;
  85175. var stopChecking = false;
  85176. var kind;
  85177. for (kind in this._vertexBuffers) {
  85178. // using slice() to make a copy of the array and not just reference it
  85179. var data = this.getVerticesData(kind);
  85180. if (data) {
  85181. if (data instanceof Float32Array) {
  85182. vertexData.set(new Float32Array(data), kind);
  85183. }
  85184. else {
  85185. vertexData.set(data.slice(0), kind);
  85186. }
  85187. if (!stopChecking) {
  85188. var vb = this.getVertexBuffer(kind);
  85189. if (vb) {
  85190. updatable = vb.isUpdatable();
  85191. stopChecking = !updatable;
  85192. }
  85193. }
  85194. }
  85195. }
  85196. var geometry = new Geometry(id, this._scene, vertexData, updatable);
  85197. geometry.delayLoadState = this.delayLoadState;
  85198. geometry.delayLoadingFile = this.delayLoadingFile;
  85199. geometry._delayLoadingFunction = this._delayLoadingFunction;
  85200. for (kind in this._delayInfo) {
  85201. geometry._delayInfo = geometry._delayInfo || [];
  85202. geometry._delayInfo.push(kind);
  85203. }
  85204. // Bounding info
  85205. geometry._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  85206. return geometry;
  85207. };
  85208. /**
  85209. * Serialize the current geometry info (and not the vertices data) into a JSON object
  85210. * @return a JSON representation of the current geometry data (without the vertices data)
  85211. */
  85212. Geometry.prototype.serialize = function () {
  85213. var serializationObject = {};
  85214. serializationObject.id = this.id;
  85215. serializationObject.updatable = this._updatable;
  85216. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].HasTags(this)) {
  85217. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].GetTags(this);
  85218. }
  85219. return serializationObject;
  85220. };
  85221. Geometry.prototype.toNumberArray = function (origin) {
  85222. if (Array.isArray(origin)) {
  85223. return origin;
  85224. }
  85225. else {
  85226. return Array.prototype.slice.call(origin);
  85227. }
  85228. };
  85229. /**
  85230. * Serialize all vertices data into a JSON oject
  85231. * @returns a JSON representation of the current geometry data
  85232. */
  85233. Geometry.prototype.serializeVerticeData = function () {
  85234. var serializationObject = this.serialize();
  85235. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  85236. serializationObject.positions = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  85237. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  85238. serializationObject.positions._updatable = true;
  85239. }
  85240. }
  85241. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  85242. serializationObject.normals = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind));
  85243. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  85244. serializationObject.normals._updatable = true;
  85245. }
  85246. }
  85247. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  85248. serializationObject.tangets = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind));
  85249. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  85250. serializationObject.tangets._updatable = true;
  85251. }
  85252. }
  85253. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  85254. serializationObject.uvs = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind));
  85255. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  85256. serializationObject.uvs._updatable = true;
  85257. }
  85258. }
  85259. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  85260. serializationObject.uv2s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind));
  85261. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  85262. serializationObject.uv2s._updatable = true;
  85263. }
  85264. }
  85265. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  85266. serializationObject.uv3s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind));
  85267. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  85268. serializationObject.uv3s._updatable = true;
  85269. }
  85270. }
  85271. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  85272. serializationObject.uv4s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind));
  85273. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  85274. serializationObject.uv4s._updatable = true;
  85275. }
  85276. }
  85277. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  85278. serializationObject.uv5s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind));
  85279. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  85280. serializationObject.uv5s._updatable = true;
  85281. }
  85282. }
  85283. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  85284. serializationObject.uv6s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind));
  85285. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  85286. serializationObject.uv6s._updatable = true;
  85287. }
  85288. }
  85289. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  85290. serializationObject.colors = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind));
  85291. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  85292. serializationObject.colors._updatable = true;
  85293. }
  85294. }
  85295. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  85296. serializationObject.matricesIndices = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind));
  85297. serializationObject.matricesIndices._isExpanded = true;
  85298. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  85299. serializationObject.matricesIndices._updatable = true;
  85300. }
  85301. }
  85302. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  85303. serializationObject.matricesWeights = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind));
  85304. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  85305. serializationObject.matricesWeights._updatable = true;
  85306. }
  85307. }
  85308. serializationObject.indices = this.toNumberArray(this.getIndices());
  85309. return serializationObject;
  85310. };
  85311. // Statics
  85312. /**
  85313. * Extracts a clone of a mesh geometry
  85314. * @param mesh defines the source mesh
  85315. * @param id defines the unique ID of the new geometry object
  85316. * @returns the new geometry object
  85317. */
  85318. Geometry.ExtractFromMesh = function (mesh, id) {
  85319. var geometry = mesh._geometry;
  85320. if (!geometry) {
  85321. return null;
  85322. }
  85323. return geometry.copy(id);
  85324. };
  85325. /**
  85326. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  85327. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  85328. * Be aware Math.random() could cause collisions, but:
  85329. * "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"
  85330. * @returns a string containing a new GUID
  85331. */
  85332. Geometry.RandomId = function () {
  85333. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].RandomId();
  85334. };
  85335. /** @hidden */
  85336. Geometry._ImportGeometry = function (parsedGeometry, mesh) {
  85337. var scene = mesh.getScene();
  85338. // Geometry
  85339. var geometryId = parsedGeometry.geometryId;
  85340. if (geometryId) {
  85341. var geometry = scene.getGeometryByID(geometryId);
  85342. if (geometry) {
  85343. geometry.applyToMesh(mesh);
  85344. }
  85345. }
  85346. else if (parsedGeometry instanceof ArrayBuffer) {
  85347. var binaryInfo = mesh._binaryInfo;
  85348. if (binaryInfo.positionsAttrDesc && binaryInfo.positionsAttrDesc.count > 0) {
  85349. var positionsData = new Float32Array(parsedGeometry, binaryInfo.positionsAttrDesc.offset, binaryInfo.positionsAttrDesc.count);
  85350. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positionsData, false);
  85351. }
  85352. if (binaryInfo.normalsAttrDesc && binaryInfo.normalsAttrDesc.count > 0) {
  85353. var normalsData = new Float32Array(parsedGeometry, binaryInfo.normalsAttrDesc.offset, binaryInfo.normalsAttrDesc.count);
  85354. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normalsData, false);
  85355. }
  85356. if (binaryInfo.tangetsAttrDesc && binaryInfo.tangetsAttrDesc.count > 0) {
  85357. var tangentsData = new Float32Array(parsedGeometry, binaryInfo.tangetsAttrDesc.offset, binaryInfo.tangetsAttrDesc.count);
  85358. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, tangentsData, false);
  85359. }
  85360. if (binaryInfo.uvsAttrDesc && binaryInfo.uvsAttrDesc.count > 0) {
  85361. var uvsData = new Float32Array(parsedGeometry, binaryInfo.uvsAttrDesc.offset, binaryInfo.uvsAttrDesc.count);
  85362. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvsData, false);
  85363. }
  85364. if (binaryInfo.uvs2AttrDesc && binaryInfo.uvs2AttrDesc.count > 0) {
  85365. var uvs2Data = new Float32Array(parsedGeometry, binaryInfo.uvs2AttrDesc.offset, binaryInfo.uvs2AttrDesc.count);
  85366. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, uvs2Data, false);
  85367. }
  85368. if (binaryInfo.uvs3AttrDesc && binaryInfo.uvs3AttrDesc.count > 0) {
  85369. var uvs3Data = new Float32Array(parsedGeometry, binaryInfo.uvs3AttrDesc.offset, binaryInfo.uvs3AttrDesc.count);
  85370. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, uvs3Data, false);
  85371. }
  85372. if (binaryInfo.uvs4AttrDesc && binaryInfo.uvs4AttrDesc.count > 0) {
  85373. var uvs4Data = new Float32Array(parsedGeometry, binaryInfo.uvs4AttrDesc.offset, binaryInfo.uvs4AttrDesc.count);
  85374. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, uvs4Data, false);
  85375. }
  85376. if (binaryInfo.uvs5AttrDesc && binaryInfo.uvs5AttrDesc.count > 0) {
  85377. var uvs5Data = new Float32Array(parsedGeometry, binaryInfo.uvs5AttrDesc.offset, binaryInfo.uvs5AttrDesc.count);
  85378. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, uvs5Data, false);
  85379. }
  85380. if (binaryInfo.uvs6AttrDesc && binaryInfo.uvs6AttrDesc.count > 0) {
  85381. var uvs6Data = new Float32Array(parsedGeometry, binaryInfo.uvs6AttrDesc.offset, binaryInfo.uvs6AttrDesc.count);
  85382. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, uvs6Data, false);
  85383. }
  85384. if (binaryInfo.colorsAttrDesc && binaryInfo.colorsAttrDesc.count > 0) {
  85385. var colorsData = new Float32Array(parsedGeometry, binaryInfo.colorsAttrDesc.offset, binaryInfo.colorsAttrDesc.count);
  85386. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colorsData, false, binaryInfo.colorsAttrDesc.stride);
  85387. }
  85388. if (binaryInfo.matricesIndicesAttrDesc && binaryInfo.matricesIndicesAttrDesc.count > 0) {
  85389. var matricesIndicesData = new Int32Array(parsedGeometry, binaryInfo.matricesIndicesAttrDesc.offset, binaryInfo.matricesIndicesAttrDesc.count);
  85390. var floatIndices = [];
  85391. for (var i = 0; i < matricesIndicesData.length; i++) {
  85392. var index = matricesIndicesData[i];
  85393. floatIndices.push(index & 0x000000FF);
  85394. floatIndices.push((index & 0x0000FF00) >> 8);
  85395. floatIndices.push((index & 0x00FF0000) >> 16);
  85396. floatIndices.push(index >> 24);
  85397. }
  85398. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, false);
  85399. }
  85400. if (binaryInfo.matricesWeightsAttrDesc && binaryInfo.matricesWeightsAttrDesc.count > 0) {
  85401. var matricesWeightsData = new Float32Array(parsedGeometry, binaryInfo.matricesWeightsAttrDesc.offset, binaryInfo.matricesWeightsAttrDesc.count);
  85402. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, matricesWeightsData, false);
  85403. }
  85404. if (binaryInfo.indicesAttrDesc && binaryInfo.indicesAttrDesc.count > 0) {
  85405. var indicesData = new Int32Array(parsedGeometry, binaryInfo.indicesAttrDesc.offset, binaryInfo.indicesAttrDesc.count);
  85406. mesh.setIndices(indicesData, null);
  85407. }
  85408. if (binaryInfo.subMeshesAttrDesc && binaryInfo.subMeshesAttrDesc.count > 0) {
  85409. var subMeshesData = new Int32Array(parsedGeometry, binaryInfo.subMeshesAttrDesc.offset, binaryInfo.subMeshesAttrDesc.count * 5);
  85410. mesh.subMeshes = [];
  85411. for (var i = 0; i < binaryInfo.subMeshesAttrDesc.count; i++) {
  85412. var materialIndex = subMeshesData[(i * 5) + 0];
  85413. var verticesStart = subMeshesData[(i * 5) + 1];
  85414. var verticesCount = subMeshesData[(i * 5) + 2];
  85415. var indexStart = subMeshesData[(i * 5) + 3];
  85416. var indexCount = subMeshesData[(i * 5) + 4];
  85417. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh);
  85418. }
  85419. }
  85420. }
  85421. else if (parsedGeometry.positions && parsedGeometry.normals && parsedGeometry.indices) {
  85422. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, parsedGeometry.positions, parsedGeometry.positions._updatable);
  85423. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, parsedGeometry.normals, parsedGeometry.normals._updatable);
  85424. if (parsedGeometry.tangents) {
  85425. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, parsedGeometry.tangents, parsedGeometry.tangents._updatable);
  85426. }
  85427. if (parsedGeometry.uvs) {
  85428. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, parsedGeometry.uvs, parsedGeometry.uvs._updatable);
  85429. }
  85430. if (parsedGeometry.uvs2) {
  85431. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, parsedGeometry.uvs2, parsedGeometry.uvs2._updatable);
  85432. }
  85433. if (parsedGeometry.uvs3) {
  85434. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, parsedGeometry.uvs3, parsedGeometry.uvs3._updatable);
  85435. }
  85436. if (parsedGeometry.uvs4) {
  85437. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, parsedGeometry.uvs4, parsedGeometry.uvs4._updatable);
  85438. }
  85439. if (parsedGeometry.uvs5) {
  85440. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, parsedGeometry.uvs5, parsedGeometry.uvs5._updatable);
  85441. }
  85442. if (parsedGeometry.uvs6) {
  85443. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, parsedGeometry.uvs6, parsedGeometry.uvs6._updatable);
  85444. }
  85445. if (parsedGeometry.colors) {
  85446. 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);
  85447. }
  85448. if (parsedGeometry.matricesIndices) {
  85449. if (!parsedGeometry.matricesIndices._isExpanded) {
  85450. var floatIndices = [];
  85451. for (var i = 0; i < parsedGeometry.matricesIndices.length; i++) {
  85452. var matricesIndex = parsedGeometry.matricesIndices[i];
  85453. floatIndices.push(matricesIndex & 0x000000FF);
  85454. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  85455. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  85456. floatIndices.push(matricesIndex >> 24);
  85457. }
  85458. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, parsedGeometry.matricesIndices._updatable);
  85459. }
  85460. else {
  85461. delete parsedGeometry.matricesIndices._isExpanded;
  85462. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, parsedGeometry.matricesIndices, parsedGeometry.matricesIndices._updatable);
  85463. }
  85464. }
  85465. if (parsedGeometry.matricesIndicesExtra) {
  85466. if (!parsedGeometry.matricesIndicesExtra._isExpanded) {
  85467. var floatIndices = [];
  85468. for (var i = 0; i < parsedGeometry.matricesIndicesExtra.length; i++) {
  85469. var matricesIndex = parsedGeometry.matricesIndicesExtra[i];
  85470. floatIndices.push(matricesIndex & 0x000000FF);
  85471. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  85472. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  85473. floatIndices.push(matricesIndex >> 24);
  85474. }
  85475. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, floatIndices, parsedGeometry.matricesIndicesExtra._updatable);
  85476. }
  85477. else {
  85478. delete parsedGeometry.matricesIndices._isExpanded;
  85479. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, parsedGeometry.matricesIndicesExtra, parsedGeometry.matricesIndicesExtra._updatable);
  85480. }
  85481. }
  85482. if (parsedGeometry.matricesWeights) {
  85483. Geometry._CleanMatricesWeights(parsedGeometry, mesh);
  85484. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, parsedGeometry.matricesWeights, parsedGeometry.matricesWeights._updatable);
  85485. }
  85486. if (parsedGeometry.matricesWeightsExtra) {
  85487. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind, parsedGeometry.matricesWeightsExtra, parsedGeometry.matricesWeights._updatable);
  85488. }
  85489. mesh.setIndices(parsedGeometry.indices, null);
  85490. }
  85491. // SubMeshes
  85492. if (parsedGeometry.subMeshes) {
  85493. mesh.subMeshes = [];
  85494. for (var subIndex = 0; subIndex < parsedGeometry.subMeshes.length; subIndex++) {
  85495. var parsedSubMesh = parsedGeometry.subMeshes[subIndex];
  85496. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(parsedSubMesh.materialIndex, parsedSubMesh.verticesStart, parsedSubMesh.verticesCount, parsedSubMesh.indexStart, parsedSubMesh.indexCount, mesh);
  85497. }
  85498. }
  85499. // Flat shading
  85500. if (mesh._shouldGenerateFlatShading) {
  85501. mesh.convertToFlatShadedMesh();
  85502. delete mesh._shouldGenerateFlatShading;
  85503. }
  85504. // Update
  85505. mesh.computeWorldMatrix(true);
  85506. scene.onMeshImportedObservable.notifyObservers(mesh);
  85507. };
  85508. Geometry._CleanMatricesWeights = function (parsedGeometry, mesh) {
  85509. var epsilon = 1e-3;
  85510. if (!_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__["SceneLoaderFlags"].CleanBoneMatrixWeights) {
  85511. return;
  85512. }
  85513. var noInfluenceBoneIndex = 0.0;
  85514. if (parsedGeometry.skeletonId > -1) {
  85515. var skeleton = mesh.getScene().getLastSkeletonByID(parsedGeometry.skeletonId);
  85516. if (!skeleton) {
  85517. return;
  85518. }
  85519. noInfluenceBoneIndex = skeleton.bones.length;
  85520. }
  85521. else {
  85522. return;
  85523. }
  85524. var matricesIndices = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  85525. var matricesIndicesExtra = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  85526. var matricesWeights = parsedGeometry.matricesWeights;
  85527. var matricesWeightsExtra = parsedGeometry.matricesWeightsExtra;
  85528. var influencers = parsedGeometry.numBoneInfluencer;
  85529. var size = matricesWeights.length;
  85530. for (var i = 0; i < size; i += 4) {
  85531. var weight = 0.0;
  85532. var firstZeroWeight = -1;
  85533. for (var j = 0; j < 4; j++) {
  85534. var w = matricesWeights[i + j];
  85535. weight += w;
  85536. if (w < epsilon && firstZeroWeight < 0) {
  85537. firstZeroWeight = j;
  85538. }
  85539. }
  85540. if (matricesWeightsExtra) {
  85541. for (var j = 0; j < 4; j++) {
  85542. var w = matricesWeightsExtra[i + j];
  85543. weight += w;
  85544. if (w < epsilon && firstZeroWeight < 0) {
  85545. firstZeroWeight = j + 4;
  85546. }
  85547. }
  85548. }
  85549. if (firstZeroWeight < 0 || firstZeroWeight > (influencers - 1)) {
  85550. firstZeroWeight = influencers - 1;
  85551. }
  85552. if (weight > epsilon) {
  85553. var mweight = 1.0 / weight;
  85554. for (var j = 0; j < 4; j++) {
  85555. matricesWeights[i + j] *= mweight;
  85556. }
  85557. if (matricesWeightsExtra) {
  85558. for (var j = 0; j < 4; j++) {
  85559. matricesWeightsExtra[i + j] *= mweight;
  85560. }
  85561. }
  85562. }
  85563. else {
  85564. if (firstZeroWeight >= 4) {
  85565. matricesWeightsExtra[i + firstZeroWeight - 4] = 1.0 - weight;
  85566. matricesIndicesExtra[i + firstZeroWeight - 4] = noInfluenceBoneIndex;
  85567. }
  85568. else {
  85569. matricesWeights[i + firstZeroWeight] = 1.0 - weight;
  85570. matricesIndices[i + firstZeroWeight] = noInfluenceBoneIndex;
  85571. }
  85572. }
  85573. }
  85574. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, matricesIndices);
  85575. if (parsedGeometry.matricesWeightsExtra) {
  85576. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, matricesIndicesExtra);
  85577. }
  85578. };
  85579. /**
  85580. * Create a new geometry from persisted data (Using .babylon file format)
  85581. * @param parsedVertexData defines the persisted data
  85582. * @param scene defines the hosting scene
  85583. * @param rootUrl defines the root url to use to load assets (like delayed data)
  85584. * @returns the new geometry object
  85585. */
  85586. Geometry.Parse = function (parsedVertexData, scene, rootUrl) {
  85587. if (scene.getGeometryByID(parsedVertexData.id)) {
  85588. return null; // null since geometry could be something else than a box...
  85589. }
  85590. var geometry = new Geometry(parsedVertexData.id, scene, undefined, parsedVertexData.updatable);
  85591. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"]) {
  85592. _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].AddTagsTo(geometry, parsedVertexData.tags);
  85593. }
  85594. if (parsedVertexData.delayLoadingFile) {
  85595. geometry.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  85596. geometry.delayLoadingFile = rootUrl + parsedVertexData.delayLoadingFile;
  85597. 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));
  85598. geometry._delayInfo = [];
  85599. if (parsedVertexData.hasUVs) {
  85600. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  85601. }
  85602. if (parsedVertexData.hasUVs2) {
  85603. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  85604. }
  85605. if (parsedVertexData.hasUVs3) {
  85606. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind);
  85607. }
  85608. if (parsedVertexData.hasUVs4) {
  85609. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind);
  85610. }
  85611. if (parsedVertexData.hasUVs5) {
  85612. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind);
  85613. }
  85614. if (parsedVertexData.hasUVs6) {
  85615. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind);
  85616. }
  85617. if (parsedVertexData.hasColors) {
  85618. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  85619. }
  85620. if (parsedVertexData.hasMatricesIndices) {
  85621. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  85622. }
  85623. if (parsedVertexData.hasMatricesWeights) {
  85624. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  85625. }
  85626. geometry._delayLoadingFunction = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData;
  85627. }
  85628. else {
  85629. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData(parsedVertexData, geometry);
  85630. }
  85631. scene.pushGeometry(geometry, true);
  85632. return geometry;
  85633. };
  85634. return Geometry;
  85635. }());
  85636. /***/ }),
  85637. /***/ "./Meshes/groundMesh.ts":
  85638. /*!******************************!*\
  85639. !*** ./Meshes/groundMesh.ts ***!
  85640. \******************************/
  85641. /*! exports provided: GroundMesh */
  85642. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  85643. "use strict";
  85644. __webpack_require__.r(__webpack_exports__);
  85645. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return GroundMesh; });
  85646. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  85647. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  85648. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  85649. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  85650. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._GroundMeshParser = function (parsedMesh, scene) {
  85651. return GroundMesh.Parse(parsedMesh, scene);
  85652. };
  85653. /**
  85654. * Mesh representing the gorund
  85655. */
  85656. var GroundMesh = /** @class */ (function (_super) {
  85657. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GroundMesh, _super);
  85658. function GroundMesh(name, scene) {
  85659. var _this = _super.call(this, name, scene) || this;
  85660. /** If octree should be generated */
  85661. _this.generateOctree = false;
  85662. return _this;
  85663. }
  85664. /**
  85665. * "GroundMesh"
  85666. * @returns "GroundMesh"
  85667. */
  85668. GroundMesh.prototype.getClassName = function () {
  85669. return "GroundMesh";
  85670. };
  85671. Object.defineProperty(GroundMesh.prototype, "subdivisions", {
  85672. /**
  85673. * The minimum of x and y subdivisions
  85674. */
  85675. get: function () {
  85676. return Math.min(this._subdivisionsX, this._subdivisionsY);
  85677. },
  85678. enumerable: true,
  85679. configurable: true
  85680. });
  85681. Object.defineProperty(GroundMesh.prototype, "subdivisionsX", {
  85682. /**
  85683. * X subdivisions
  85684. */
  85685. get: function () {
  85686. return this._subdivisionsX;
  85687. },
  85688. enumerable: true,
  85689. configurable: true
  85690. });
  85691. Object.defineProperty(GroundMesh.prototype, "subdivisionsY", {
  85692. /**
  85693. * Y subdivisions
  85694. */
  85695. get: function () {
  85696. return this._subdivisionsY;
  85697. },
  85698. enumerable: true,
  85699. configurable: true
  85700. });
  85701. /**
  85702. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  85703. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  85704. * @param chunksCount the number of subdivisions for x and y
  85705. * @param octreeBlocksSize (Default: 32)
  85706. */
  85707. GroundMesh.prototype.optimize = function (chunksCount, octreeBlocksSize) {
  85708. if (octreeBlocksSize === void 0) { octreeBlocksSize = 32; }
  85709. this._subdivisionsX = chunksCount;
  85710. this._subdivisionsY = chunksCount;
  85711. this.subdivide(chunksCount);
  85712. // Call the octree system optimization if it is defined.
  85713. var thisAsAny = this;
  85714. if (thisAsAny.createOrUpdateSubmeshesOctree) {
  85715. thisAsAny.createOrUpdateSubmeshesOctree(octreeBlocksSize);
  85716. }
  85717. };
  85718. /**
  85719. * Returns a height (y) value in the Worl system :
  85720. * the ground altitude at the coordinates (x, z) expressed in the World system.
  85721. * @param x x coordinate
  85722. * @param z z coordinate
  85723. * @returns the ground y position if (x, z) are outside the ground surface.
  85724. */
  85725. GroundMesh.prototype.getHeightAtCoordinates = function (x, z) {
  85726. var world = this.getWorldMatrix();
  85727. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  85728. world.invertToRef(invMat);
  85729. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  85730. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, invMat, tmpVect); // transform x,z in the mesh local space
  85731. x = tmpVect.x;
  85732. z = tmpVect.z;
  85733. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  85734. return this.position.y;
  85735. }
  85736. if (!this._heightQuads || this._heightQuads.length == 0) {
  85737. this._initHeightQuads();
  85738. this._computeHeightQuads();
  85739. }
  85740. var facet = this._getFacetAt(x, z);
  85741. var y = -(facet.x * x + facet.z * z + facet.w) / facet.y;
  85742. // return y in the World system
  85743. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0.0, y, 0.0, world, tmpVect);
  85744. return tmpVect.y;
  85745. };
  85746. /**
  85747. * Returns a normalized vector (Vector3) orthogonal to the ground
  85748. * at the ground coordinates (x, z) expressed in the World system.
  85749. * @param x x coordinate
  85750. * @param z z coordinate
  85751. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  85752. */
  85753. GroundMesh.prototype.getNormalAtCoordinates = function (x, z) {
  85754. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.0, 1.0, 0.0);
  85755. this.getNormalAtCoordinatesToRef(x, z, normal);
  85756. return normal;
  85757. };
  85758. /**
  85759. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  85760. * at the ground coordinates (x, z) expressed in the World system.
  85761. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  85762. * @param x x coordinate
  85763. * @param z z coordinate
  85764. * @param ref vector to store the result
  85765. * @returns the GroundMesh.
  85766. */
  85767. GroundMesh.prototype.getNormalAtCoordinatesToRef = function (x, z, ref) {
  85768. var world = this.getWorldMatrix();
  85769. var tmpMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  85770. world.invertToRef(tmpMat);
  85771. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  85772. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, tmpMat, tmpVect); // transform x,z in the mesh local space
  85773. x = tmpVect.x;
  85774. z = tmpVect.z;
  85775. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  85776. return this;
  85777. }
  85778. if (!this._heightQuads || this._heightQuads.length == 0) {
  85779. this._initHeightQuads();
  85780. this._computeHeightQuads();
  85781. }
  85782. var facet = this._getFacetAt(x, z);
  85783. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(facet.x, facet.y, facet.z, world, ref);
  85784. return this;
  85785. };
  85786. /**
  85787. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  85788. * if the ground has been updated.
  85789. * This can be used in the render loop.
  85790. * @returns the GroundMesh.
  85791. */
  85792. GroundMesh.prototype.updateCoordinateHeights = function () {
  85793. if (!this._heightQuads || this._heightQuads.length == 0) {
  85794. this._initHeightQuads();
  85795. }
  85796. this._computeHeightQuads();
  85797. return this;
  85798. };
  85799. // Returns the element "facet" from the heightQuads array relative to (x, z) local coordinates
  85800. GroundMesh.prototype._getFacetAt = function (x, z) {
  85801. // retrieve col and row from x, z coordinates in the ground local system
  85802. var col = Math.floor((x + this._maxX) * this._subdivisionsX / this._width);
  85803. var row = Math.floor(-(z + this._maxZ) * this._subdivisionsY / this._height + this._subdivisionsY);
  85804. var quad = this._heightQuads[row * this._subdivisionsX + col];
  85805. var facet;
  85806. if (z < quad.slope.x * x + quad.slope.y) {
  85807. facet = quad.facet1;
  85808. }
  85809. else {
  85810. facet = quad.facet2;
  85811. }
  85812. return facet;
  85813. };
  85814. // Creates and populates the heightMap array with "facet" elements :
  85815. // a quad is two triangular facets separated by a slope, so a "facet" element is 1 slope + 2 facets
  85816. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  85817. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  85818. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  85819. // Returns the GroundMesh.
  85820. GroundMesh.prototype._initHeightQuads = function () {
  85821. var subdivisionsX = this._subdivisionsX;
  85822. var subdivisionsY = this._subdivisionsY;
  85823. this._heightQuads = new Array();
  85824. for (var row = 0; row < subdivisionsY; row++) {
  85825. for (var col = 0; col < subdivisionsX; col++) {
  85826. 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) };
  85827. this._heightQuads[row * subdivisionsX + col] = quad;
  85828. }
  85829. }
  85830. return this;
  85831. };
  85832. // Compute each quad element values and update the the heightMap array :
  85833. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  85834. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  85835. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  85836. // Returns the GroundMesh.
  85837. GroundMesh.prototype._computeHeightQuads = function () {
  85838. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  85839. if (!positions) {
  85840. return this;
  85841. }
  85842. var v1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  85843. var v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  85844. var v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  85845. var v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  85846. var v1v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  85847. var v1v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  85848. var v1v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  85849. var norm1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[7];
  85850. var norm2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  85851. var i = 0;
  85852. var j = 0;
  85853. var k = 0;
  85854. var cd = 0; // 2D slope coefficient : z = cd * x + h
  85855. var h = 0;
  85856. var d1 = 0; // facet plane equation : ax + by + cz + d = 0
  85857. var d2 = 0;
  85858. var subdivisionsX = this._subdivisionsX;
  85859. var subdivisionsY = this._subdivisionsY;
  85860. for (var row = 0; row < subdivisionsY; row++) {
  85861. for (var col = 0; col < subdivisionsX; col++) {
  85862. i = col * 3;
  85863. j = row * (subdivisionsX + 1) * 3;
  85864. k = (row + 1) * (subdivisionsX + 1) * 3;
  85865. v1.x = positions[j + i];
  85866. v1.y = positions[j + i + 1];
  85867. v1.z = positions[j + i + 2];
  85868. v2.x = positions[j + i + 3];
  85869. v2.y = positions[j + i + 4];
  85870. v2.z = positions[j + i + 5];
  85871. v3.x = positions[k + i];
  85872. v3.y = positions[k + i + 1];
  85873. v3.z = positions[k + i + 2];
  85874. v4.x = positions[k + i + 3];
  85875. v4.y = positions[k + i + 4];
  85876. v4.z = positions[k + i + 5];
  85877. // 2D slope V1V4
  85878. cd = (v4.z - v1.z) / (v4.x - v1.x);
  85879. h = v1.z - cd * v1.x; // v1 belongs to the slope
  85880. // facet equations :
  85881. // we compute each facet normal vector
  85882. // the equation of the facet plane is : norm.x * x + norm.y * y + norm.z * z + d = 0
  85883. // we compute the value d by applying the equation to v1 which belongs to the plane
  85884. // then we store the facet equation in a Vector4
  85885. v2.subtractToRef(v1, v1v2);
  85886. v3.subtractToRef(v1, v1v3);
  85887. v4.subtractToRef(v1, v1v4);
  85888. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v4, v1v3, norm1); // caution : CrossToRef uses the Tmp class
  85889. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v2, v1v4, norm2);
  85890. norm1.normalize();
  85891. norm2.normalize();
  85892. d1 = -(norm1.x * v1.x + norm1.y * v1.y + norm1.z * v1.z);
  85893. d2 = -(norm2.x * v2.x + norm2.y * v2.y + norm2.z * v2.z);
  85894. var quad = this._heightQuads[row * subdivisionsX + col];
  85895. quad.slope.copyFromFloats(cd, h);
  85896. quad.facet1.copyFromFloats(norm1.x, norm1.y, norm1.z, d1);
  85897. quad.facet2.copyFromFloats(norm2.x, norm2.y, norm2.z, d2);
  85898. }
  85899. }
  85900. return this;
  85901. };
  85902. /**
  85903. * Serializes this ground mesh
  85904. * @param serializationObject object to write serialization to
  85905. */
  85906. GroundMesh.prototype.serialize = function (serializationObject) {
  85907. _super.prototype.serialize.call(this, serializationObject);
  85908. serializationObject.subdivisionsX = this._subdivisionsX;
  85909. serializationObject.subdivisionsY = this._subdivisionsY;
  85910. serializationObject.minX = this._minX;
  85911. serializationObject.maxX = this._maxX;
  85912. serializationObject.minZ = this._minZ;
  85913. serializationObject.maxZ = this._maxZ;
  85914. serializationObject.width = this._width;
  85915. serializationObject.height = this._height;
  85916. };
  85917. /**
  85918. * Parses a serialized ground mesh
  85919. * @param parsedMesh the serialized mesh
  85920. * @param scene the scene to create the ground mesh in
  85921. * @returns the created ground mesh
  85922. */
  85923. GroundMesh.Parse = function (parsedMesh, scene) {
  85924. var result = new GroundMesh(parsedMesh.name, scene);
  85925. result._subdivisionsX = parsedMesh.subdivisionsX || 1;
  85926. result._subdivisionsY = parsedMesh.subdivisionsY || 1;
  85927. result._minX = parsedMesh.minX;
  85928. result._maxX = parsedMesh.maxX;
  85929. result._minZ = parsedMesh.minZ;
  85930. result._maxZ = parsedMesh.maxZ;
  85931. result._width = parsedMesh.width;
  85932. result._height = parsedMesh.height;
  85933. return result;
  85934. };
  85935. return GroundMesh;
  85936. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  85937. /***/ }),
  85938. /***/ "./Meshes/index.ts":
  85939. /*!*************************!*\
  85940. !*** ./Meshes/index.ts ***!
  85941. \*************************/
  85942. /*! exports provided: AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, TrailMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, BoxBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, DracoCompression, DiscBuilder, RibbonBuilder, HemisphereBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  85943. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  85944. "use strict";
  85945. __webpack_require__.r(__webpack_exports__);
  85946. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  85947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  85948. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  85949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["Buffer"]; });
  85950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"]; });
  85951. /* harmony import */ var _Compression_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Compression/index */ "./Meshes/Compression/index.ts");
  85952. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Compression_index__WEBPACK_IMPORTED_MODULE_2__["DracoCompression"]; });
  85953. /* harmony import */ var _csg__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./csg */ "./Meshes/csg.ts");
  85954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _csg__WEBPACK_IMPORTED_MODULE_3__["CSG"]; });
  85955. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  85956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"]; });
  85957. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./groundMesh */ "./Meshes/groundMesh.ts");
  85958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _groundMesh__WEBPACK_IMPORTED_MODULE_5__["GroundMesh"]; });
  85959. /* harmony import */ var _trailMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./trailMesh */ "./Meshes/trailMesh.ts");
  85960. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _trailMesh__WEBPACK_IMPORTED_MODULE_6__["TrailMesh"]; });
  85961. /* harmony import */ var _instancedMesh__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./instancedMesh */ "./Meshes/instancedMesh.ts");
  85962. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _instancedMesh__WEBPACK_IMPORTED_MODULE_7__["InstancedMesh"]; });
  85963. /* harmony import */ var _linesMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./linesMesh */ "./Meshes/linesMesh.ts");
  85964. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_8__["LinesMesh"]; });
  85965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_8__["InstancedLinesMesh"]; });
  85966. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  85967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["MeshLODLevel"]; });
  85968. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["_CreationDataStorage"]; });
  85969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["_InstancesBatch"]; });
  85970. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["Mesh"]; });
  85971. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  85972. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _mesh_vertexData__WEBPACK_IMPORTED_MODULE_10__["VertexData"]; });
  85973. /* harmony import */ var _meshBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./meshBuilder */ "./Meshes/meshBuilder.ts");
  85974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _meshBuilder__WEBPACK_IMPORTED_MODULE_11__["MeshBuilder"]; });
  85975. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  85976. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationSettings"]; });
  85977. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationQueue"]; });
  85978. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationType"]; });
  85979. /* harmony import */ var _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./meshSimplificationSceneComponent */ "./Meshes/meshSimplificationSceneComponent.ts");
  85980. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_13__["SimplicationQueueSceneComponent"]; });
  85981. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./polygonMesh */ "./Meshes/polygonMesh.ts");
  85982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_14__["Polygon"]; });
  85983. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_14__["PolygonMeshBuilder"]; });
  85984. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  85985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_15__["BaseSubMesh"]; });
  85986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_15__["SubMesh"]; });
  85987. /* harmony import */ var _transformNode__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./transformNode */ "./Meshes/transformNode.ts");
  85988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _transformNode__WEBPACK_IMPORTED_MODULE_16__["TransformNode"]; });
  85989. /* harmony import */ var _Builders_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Builders/index */ "./Meshes/Builders/index.ts");
  85990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["BoxBuilder"]; });
  85991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["SphereBuilder"]; });
  85992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["CylinderBuilder"]; });
  85993. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["LinesBuilder"]; });
  85994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["PlaneBuilder"]; });
  85995. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["DiscBuilder"]; });
  85996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["RibbonBuilder"]; });
  85997. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["HemisphereBuilder"]; });
  85998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["TorusBuilder"]; });
  85999. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["TorusKnotBuilder"]; });
  86000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["PolygonBuilder"]; });
  86001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["ShapeBuilder"]; });
  86002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["LatheBuilder"]; });
  86003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["GroundBuilder"]; });
  86004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["TubeBuilder"]; });
  86005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["PolyhedronBuilder"]; });
  86006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["IcoSphereBuilder"]; });
  86007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["DecalBuilder"]; });
  86008. /***/ }),
  86009. /***/ "./Meshes/instancedMesh.ts":
  86010. /*!*********************************!*\
  86011. !*** ./Meshes/instancedMesh.ts ***!
  86012. \*********************************/
  86013. /*! exports provided: InstancedMesh */
  86014. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  86015. "use strict";
  86016. __webpack_require__.r(__webpack_exports__);
  86017. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return InstancedMesh; });
  86018. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  86019. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  86020. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  86021. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  86022. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  86023. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._instancedMeshFactory = function (name, mesh) {
  86024. return new InstancedMesh(name, mesh);
  86025. };
  86026. /**
  86027. * Creates an instance based on a source mesh.
  86028. */
  86029. var InstancedMesh = /** @class */ (function (_super) {
  86030. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedMesh, _super);
  86031. function InstancedMesh(name, source) {
  86032. var _this = _super.call(this, name, source.getScene()) || this;
  86033. /** @hidden */
  86034. _this._indexInSourceMeshInstanceArray = -1;
  86035. source.addInstance(_this);
  86036. _this._sourceMesh = source;
  86037. _this.position.copyFrom(source.position);
  86038. _this.rotation.copyFrom(source.rotation);
  86039. _this.scaling.copyFrom(source.scaling);
  86040. if (source.rotationQuaternion) {
  86041. _this.rotationQuaternion = source.rotationQuaternion.clone();
  86042. }
  86043. _this.infiniteDistance = source.infiniteDistance;
  86044. _this.setPivotMatrix(source.getPivotMatrix());
  86045. _this.refreshBoundingInfo();
  86046. _this._syncSubMeshes();
  86047. return _this;
  86048. }
  86049. /**
  86050. * Returns the string "InstancedMesh".
  86051. */
  86052. InstancedMesh.prototype.getClassName = function () {
  86053. return "InstancedMesh";
  86054. };
  86055. Object.defineProperty(InstancedMesh.prototype, "receiveShadows", {
  86056. // Methods
  86057. /**
  86058. * If the source mesh receives shadows
  86059. */
  86060. get: function () {
  86061. return this._sourceMesh.receiveShadows;
  86062. },
  86063. enumerable: true,
  86064. configurable: true
  86065. });
  86066. Object.defineProperty(InstancedMesh.prototype, "material", {
  86067. /**
  86068. * The material of the source mesh
  86069. */
  86070. get: function () {
  86071. return this._sourceMesh.material;
  86072. },
  86073. enumerable: true,
  86074. configurable: true
  86075. });
  86076. Object.defineProperty(InstancedMesh.prototype, "visibility", {
  86077. /**
  86078. * Visibility of the source mesh
  86079. */
  86080. get: function () {
  86081. return this._sourceMesh.visibility;
  86082. },
  86083. enumerable: true,
  86084. configurable: true
  86085. });
  86086. Object.defineProperty(InstancedMesh.prototype, "skeleton", {
  86087. /**
  86088. * Skeleton of the source mesh
  86089. */
  86090. get: function () {
  86091. return this._sourceMesh.skeleton;
  86092. },
  86093. enumerable: true,
  86094. configurable: true
  86095. });
  86096. Object.defineProperty(InstancedMesh.prototype, "renderingGroupId", {
  86097. /**
  86098. * Rendering ground id of the source mesh
  86099. */
  86100. get: function () {
  86101. return this._sourceMesh.renderingGroupId;
  86102. },
  86103. set: function (value) {
  86104. if (!this._sourceMesh || value === this._sourceMesh.renderingGroupId) {
  86105. return;
  86106. }
  86107. //no-op with warning
  86108. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene");
  86109. },
  86110. enumerable: true,
  86111. configurable: true
  86112. });
  86113. /**
  86114. * Returns the total number of vertices (integer).
  86115. */
  86116. InstancedMesh.prototype.getTotalVertices = function () {
  86117. return this._sourceMesh.getTotalVertices();
  86118. };
  86119. /**
  86120. * Returns a positive integer : the total number of indices in this mesh geometry.
  86121. * @returns the numner of indices or zero if the mesh has no geometry.
  86122. */
  86123. InstancedMesh.prototype.getTotalIndices = function () {
  86124. return this._sourceMesh.getTotalIndices();
  86125. };
  86126. Object.defineProperty(InstancedMesh.prototype, "sourceMesh", {
  86127. /**
  86128. * The source mesh of the instance
  86129. */
  86130. get: function () {
  86131. return this._sourceMesh;
  86132. },
  86133. enumerable: true,
  86134. configurable: true
  86135. });
  86136. /**
  86137. * Is this node ready to be used/rendered
  86138. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  86139. * @return {boolean} is it ready
  86140. */
  86141. InstancedMesh.prototype.isReady = function (completeCheck) {
  86142. if (completeCheck === void 0) { completeCheck = false; }
  86143. return this._sourceMesh.isReady(completeCheck, true);
  86144. };
  86145. /**
  86146. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86147. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  86148. * @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.
  86149. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  86150. */
  86151. InstancedMesh.prototype.getVerticesData = function (kind, copyWhenShared) {
  86152. return this._sourceMesh.getVerticesData(kind, copyWhenShared);
  86153. };
  86154. /**
  86155. * Sets the vertex data of the mesh geometry for the requested `kind`.
  86156. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  86157. * The `data` are either a numeric array either a Float32Array.
  86158. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  86159. * 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).
  86160. * Note that a new underlying VertexBuffer object is created each call.
  86161. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  86162. *
  86163. * Possible `kind` values :
  86164. * - VertexBuffer.PositionKind
  86165. * - VertexBuffer.UVKind
  86166. * - VertexBuffer.UV2Kind
  86167. * - VertexBuffer.UV3Kind
  86168. * - VertexBuffer.UV4Kind
  86169. * - VertexBuffer.UV5Kind
  86170. * - VertexBuffer.UV6Kind
  86171. * - VertexBuffer.ColorKind
  86172. * - VertexBuffer.MatricesIndicesKind
  86173. * - VertexBuffer.MatricesIndicesExtraKind
  86174. * - VertexBuffer.MatricesWeightsKind
  86175. * - VertexBuffer.MatricesWeightsExtraKind
  86176. *
  86177. * Returns the Mesh.
  86178. */
  86179. InstancedMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  86180. if (this.sourceMesh) {
  86181. this.sourceMesh.setVerticesData(kind, data, updatable, stride);
  86182. }
  86183. return this.sourceMesh;
  86184. };
  86185. /**
  86186. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  86187. * If the mesh has no geometry, it is simply returned as it is.
  86188. * The `data` are either a numeric array either a Float32Array.
  86189. * No new underlying VertexBuffer object is created.
  86190. * 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.
  86191. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  86192. *
  86193. * Possible `kind` values :
  86194. * - VertexBuffer.PositionKind
  86195. * - VertexBuffer.UVKind
  86196. * - VertexBuffer.UV2Kind
  86197. * - VertexBuffer.UV3Kind
  86198. * - VertexBuffer.UV4Kind
  86199. * - VertexBuffer.UV5Kind
  86200. * - VertexBuffer.UV6Kind
  86201. * - VertexBuffer.ColorKind
  86202. * - VertexBuffer.MatricesIndicesKind
  86203. * - VertexBuffer.MatricesIndicesExtraKind
  86204. * - VertexBuffer.MatricesWeightsKind
  86205. * - VertexBuffer.MatricesWeightsExtraKind
  86206. *
  86207. * Returns the Mesh.
  86208. */
  86209. InstancedMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  86210. if (this.sourceMesh) {
  86211. this.sourceMesh.updateVerticesData(kind, data, updateExtends, makeItUnique);
  86212. }
  86213. return this.sourceMesh;
  86214. };
  86215. /**
  86216. * Sets the mesh indices.
  86217. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  86218. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  86219. * This method creates a new index buffer each call.
  86220. * Returns the Mesh.
  86221. */
  86222. InstancedMesh.prototype.setIndices = function (indices, totalVertices) {
  86223. if (totalVertices === void 0) { totalVertices = null; }
  86224. if (this.sourceMesh) {
  86225. this.sourceMesh.setIndices(indices, totalVertices);
  86226. }
  86227. return this.sourceMesh;
  86228. };
  86229. /**
  86230. * Boolean : True if the mesh owns the requested kind of data.
  86231. */
  86232. InstancedMesh.prototype.isVerticesDataPresent = function (kind) {
  86233. return this._sourceMesh.isVerticesDataPresent(kind);
  86234. };
  86235. /**
  86236. * Returns an array of indices (IndicesArray).
  86237. */
  86238. InstancedMesh.prototype.getIndices = function () {
  86239. return this._sourceMesh.getIndices();
  86240. };
  86241. Object.defineProperty(InstancedMesh.prototype, "_positions", {
  86242. get: function () {
  86243. return this._sourceMesh._positions;
  86244. },
  86245. enumerable: true,
  86246. configurable: true
  86247. });
  86248. /**
  86249. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  86250. * This means the mesh underlying bounding box and sphere are recomputed.
  86251. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  86252. * @returns the current mesh
  86253. */
  86254. InstancedMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  86255. if (applySkeleton === void 0) { applySkeleton = false; }
  86256. if (this._boundingInfo && this._boundingInfo.isLocked) {
  86257. return this;
  86258. }
  86259. var bias = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;
  86260. this._refreshBoundingInfo(this._sourceMesh._getPositionData(applySkeleton), bias);
  86261. return this;
  86262. };
  86263. /** @hidden */
  86264. InstancedMesh.prototype._preActivate = function () {
  86265. if (this._currentLOD) {
  86266. this._currentLOD._preActivate();
  86267. }
  86268. return this;
  86269. };
  86270. /** @hidden */
  86271. InstancedMesh.prototype._activate = function (renderId) {
  86272. if (this._currentLOD) {
  86273. this._currentLOD._registerInstanceForRenderId(this, renderId);
  86274. }
  86275. return this;
  86276. };
  86277. /**
  86278. * Returns the current associated LOD AbstractMesh.
  86279. */
  86280. InstancedMesh.prototype.getLOD = function (camera) {
  86281. if (!camera) {
  86282. return this;
  86283. }
  86284. var boundingInfo = this.getBoundingInfo();
  86285. this._currentLOD = this.sourceMesh.getLOD(camera, boundingInfo.boundingSphere);
  86286. if (this._currentLOD === this.sourceMesh) {
  86287. return this;
  86288. }
  86289. return this._currentLOD;
  86290. };
  86291. /** @hidden */
  86292. InstancedMesh.prototype._syncSubMeshes = function () {
  86293. this.releaseSubMeshes();
  86294. if (this._sourceMesh.subMeshes) {
  86295. for (var index = 0; index < this._sourceMesh.subMeshes.length; index++) {
  86296. this._sourceMesh.subMeshes[index].clone(this, this._sourceMesh);
  86297. }
  86298. }
  86299. return this;
  86300. };
  86301. /** @hidden */
  86302. InstancedMesh.prototype._generatePointsArray = function () {
  86303. return this._sourceMesh._generatePointsArray();
  86304. };
  86305. /**
  86306. * Creates a new InstancedMesh from the current mesh.
  86307. * - name (string) : the cloned mesh name
  86308. * - newParent (optional Node) : the optional Node to parent the clone to.
  86309. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  86310. *
  86311. * Returns the clone.
  86312. */
  86313. InstancedMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  86314. var result = this._sourceMesh.createInstance(name);
  86315. // Deep copy
  86316. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__["DeepCopier"].DeepCopy(this, result, ["name", "subMeshes", "uniqueId"], []);
  86317. // Bounding info
  86318. this.refreshBoundingInfo();
  86319. // Parent
  86320. if (newParent) {
  86321. result.parent = newParent;
  86322. }
  86323. if (!doNotCloneChildren) {
  86324. // Children
  86325. for (var index = 0; index < this.getScene().meshes.length; index++) {
  86326. var mesh = this.getScene().meshes[index];
  86327. if (mesh.parent === this) {
  86328. mesh.clone(mesh.name, result);
  86329. }
  86330. }
  86331. }
  86332. result.computeWorldMatrix(true);
  86333. return result;
  86334. };
  86335. /**
  86336. * Disposes the InstancedMesh.
  86337. * Returns nothing.
  86338. */
  86339. InstancedMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  86340. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  86341. // Remove from mesh
  86342. this._sourceMesh.removeInstance(this);
  86343. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  86344. };
  86345. return InstancedMesh;
  86346. }(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]));
  86347. /***/ }),
  86348. /***/ "./Meshes/linesMesh.ts":
  86349. /*!*****************************!*\
  86350. !*** ./Meshes/linesMesh.ts ***!
  86351. \*****************************/
  86352. /*! exports provided: LinesMesh, InstancedLinesMesh */
  86353. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  86354. "use strict";
  86355. __webpack_require__.r(__webpack_exports__);
  86356. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return LinesMesh; });
  86357. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return InstancedLinesMesh; });
  86358. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  86359. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  86360. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  86361. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  86362. /* harmony import */ var _Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/instancedMesh */ "./Meshes/instancedMesh.ts");
  86363. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  86364. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  86365. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  86366. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  86367. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  86368. /**
  86369. * Line mesh
  86370. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  86371. */
  86372. var LinesMesh = /** @class */ (function (_super) {
  86373. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LinesMesh, _super);
  86374. /**
  86375. * Creates a new LinesMesh
  86376. * @param name defines the name
  86377. * @param scene defines the hosting scene
  86378. * @param parent defines the parent mesh if any
  86379. * @param source defines the optional source LinesMesh used to clone data from
  86380. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  86381. * When false, achieved by calling a clone(), also passing False.
  86382. * This will make creation of children, recursive.
  86383. * @param useVertexColor defines if this LinesMesh supports vertex color
  86384. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  86385. */
  86386. function LinesMesh(name, scene, parent, source, doNotCloneChildren,
  86387. /**
  86388. * If vertex color should be applied to the mesh
  86389. */
  86390. useVertexColor,
  86391. /**
  86392. * If vertex alpha should be applied to the mesh
  86393. */
  86394. useVertexAlpha) {
  86395. if (scene === void 0) { scene = null; }
  86396. if (parent === void 0) { parent = null; }
  86397. var _this = _super.call(this, name, scene, parent, source, doNotCloneChildren) || this;
  86398. _this.useVertexColor = useVertexColor;
  86399. _this.useVertexAlpha = useVertexAlpha;
  86400. /**
  86401. * Color of the line (Default: White)
  86402. */
  86403. _this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
  86404. /**
  86405. * Alpha of the line (Default: 1)
  86406. */
  86407. _this.alpha = 1;
  86408. if (source) {
  86409. _this.color = source.color.clone();
  86410. _this.alpha = source.alpha;
  86411. _this.useVertexColor = source.useVertexColor;
  86412. _this.useVertexAlpha = source.useVertexAlpha;
  86413. }
  86414. _this.intersectionThreshold = 0.1;
  86415. var defines = [];
  86416. var options = {
  86417. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, "world0", "world1", "world2", "world3"],
  86418. uniforms: ["vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "world", "viewProjection"],
  86419. needAlphaBlending: true,
  86420. defines: defines
  86421. };
  86422. if (useVertexAlpha === false) {
  86423. options.needAlphaBlending = false;
  86424. }
  86425. if (!useVertexColor) {
  86426. options.uniforms.push("color");
  86427. }
  86428. else {
  86429. options.defines.push("#define VERTEXCOLOR");
  86430. options.attributes.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  86431. }
  86432. _this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("colorShader", _this.getScene(), "color", options);
  86433. return _this;
  86434. }
  86435. LinesMesh.prototype._addClipPlaneDefine = function (label) {
  86436. var define = "#define " + label;
  86437. var index = this._colorShader.options.defines.indexOf(define);
  86438. if (index !== -1) {
  86439. return;
  86440. }
  86441. this._colorShader.options.defines.push(define);
  86442. };
  86443. LinesMesh.prototype._removeClipPlaneDefine = function (label) {
  86444. var define = "#define " + label;
  86445. var index = this._colorShader.options.defines.indexOf(define);
  86446. if (index === -1) {
  86447. return;
  86448. }
  86449. this._colorShader.options.defines.splice(index, 1);
  86450. };
  86451. LinesMesh.prototype.isReady = function () {
  86452. var scene = this.getScene();
  86453. // Clip planes
  86454. scene.clipPlane ? this._addClipPlaneDefine("CLIPPLANE") : this._removeClipPlaneDefine("CLIPPLANE");
  86455. scene.clipPlane2 ? this._addClipPlaneDefine("CLIPPLANE2") : this._removeClipPlaneDefine("CLIPPLANE2");
  86456. scene.clipPlane3 ? this._addClipPlaneDefine("CLIPPLANE3") : this._removeClipPlaneDefine("CLIPPLANE3");
  86457. scene.clipPlane4 ? this._addClipPlaneDefine("CLIPPLANE4") : this._removeClipPlaneDefine("CLIPPLANE4");
  86458. if (!this._colorShader.isReady()) {
  86459. return false;
  86460. }
  86461. return _super.prototype.isReady.call(this);
  86462. };
  86463. /**
  86464. * Returns the string "LineMesh"
  86465. */
  86466. LinesMesh.prototype.getClassName = function () {
  86467. return "LinesMesh";
  86468. };
  86469. Object.defineProperty(LinesMesh.prototype, "material", {
  86470. /**
  86471. * @hidden
  86472. */
  86473. get: function () {
  86474. return this._colorShader;
  86475. },
  86476. /**
  86477. * @hidden
  86478. */
  86479. set: function (value) {
  86480. // Do nothing
  86481. },
  86482. enumerable: true,
  86483. configurable: true
  86484. });
  86485. Object.defineProperty(LinesMesh.prototype, "checkCollisions", {
  86486. /**
  86487. * @hidden
  86488. */
  86489. get: function () {
  86490. return false;
  86491. },
  86492. enumerable: true,
  86493. configurable: true
  86494. });
  86495. /** @hidden */
  86496. LinesMesh.prototype._bind = function (subMesh, effect, fillMode) {
  86497. if (!this._geometry) {
  86498. return this;
  86499. }
  86500. var colorEffect = this._colorShader.getEffect();
  86501. // VBOs
  86502. this._geometry._bind(colorEffect);
  86503. // Color
  86504. if (!this.useVertexColor) {
  86505. this._colorShader.setColor4("color", this.color.toColor4(this.alpha));
  86506. }
  86507. // Clip planes
  86508. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_9__["MaterialHelper"].BindClipPlane(colorEffect, this.getScene());
  86509. return this;
  86510. };
  86511. /** @hidden */
  86512. LinesMesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
  86513. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  86514. return this;
  86515. }
  86516. var engine = this.getScene().getEngine();
  86517. // Draw order
  86518. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].LineListDrawMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  86519. return this;
  86520. };
  86521. /**
  86522. * Disposes of the line mesh
  86523. * @param doNotRecurse If children should be disposed
  86524. */
  86525. LinesMesh.prototype.dispose = function (doNotRecurse) {
  86526. this._colorShader.dispose(false, false, true);
  86527. _super.prototype.dispose.call(this, doNotRecurse);
  86528. };
  86529. /**
  86530. * Returns a new LineMesh object cloned from the current one.
  86531. */
  86532. LinesMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  86533. return new LinesMesh(name, this.getScene(), newParent, this, doNotCloneChildren);
  86534. };
  86535. /**
  86536. * Creates a new InstancedLinesMesh object from the mesh model.
  86537. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  86538. * @param name defines the name of the new instance
  86539. * @returns a new InstancedLinesMesh
  86540. */
  86541. LinesMesh.prototype.createInstance = function (name) {
  86542. return new InstancedLinesMesh(name, this);
  86543. };
  86544. return LinesMesh;
  86545. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  86546. /**
  86547. * Creates an instance based on a source LinesMesh
  86548. */
  86549. var InstancedLinesMesh = /** @class */ (function (_super) {
  86550. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedLinesMesh, _super);
  86551. function InstancedLinesMesh(name, source) {
  86552. var _this = _super.call(this, name, source) || this;
  86553. _this.intersectionThreshold = source.intersectionThreshold;
  86554. return _this;
  86555. }
  86556. /**
  86557. * Returns the string "InstancedLinesMesh".
  86558. */
  86559. InstancedLinesMesh.prototype.getClassName = function () {
  86560. return "InstancedLinesMesh";
  86561. };
  86562. return InstancedLinesMesh;
  86563. }(_Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__["InstancedMesh"]));
  86564. /***/ }),
  86565. /***/ "./Meshes/mesh.ts":
  86566. /*!************************!*\
  86567. !*** ./Meshes/mesh.ts ***!
  86568. \************************/
  86569. /*! exports provided: MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh */
  86570. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  86571. "use strict";
  86572. __webpack_require__.r(__webpack_exports__);
  86573. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return MeshLODLevel; });
  86574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _CreationDataStorage; });
  86575. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _InstancesBatch; });
  86576. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return Mesh; });
  86577. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  86578. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  86579. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  86580. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  86581. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  86582. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  86583. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  86584. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  86585. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  86586. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  86587. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  86588. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  86589. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  86590. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  86591. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  86592. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  86593. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  86594. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  86595. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  86596. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  86597. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  86598. /**
  86599. * Class used to represent a specific level of detail of a mesh
  86600. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  86601. */
  86602. var MeshLODLevel = /** @class */ (function () {
  86603. /**
  86604. * Creates a new LOD level
  86605. * @param distance defines the distance where this level should star being displayed
  86606. * @param mesh defines the mesh to use to render this level
  86607. */
  86608. function MeshLODLevel(
  86609. /** Defines the distance where this level should star being displayed */
  86610. distance,
  86611. /** Defines the mesh to use to render this level */
  86612. mesh) {
  86613. this.distance = distance;
  86614. this.mesh = mesh;
  86615. }
  86616. return MeshLODLevel;
  86617. }());
  86618. /**
  86619. * @hidden
  86620. **/
  86621. var _CreationDataStorage = /** @class */ (function () {
  86622. function _CreationDataStorage() {
  86623. }
  86624. return _CreationDataStorage;
  86625. }());
  86626. /**
  86627. * @hidden
  86628. **/
  86629. var _InstanceDataStorage = /** @class */ (function () {
  86630. function _InstanceDataStorage() {
  86631. this.visibleInstances = {};
  86632. this.renderIdForInstances = new Array();
  86633. this.batchCache = new _InstancesBatch();
  86634. this.instancesBufferSize = 32 * 16 * 4; // let's start with a maximum of 32 instances
  86635. }
  86636. return _InstanceDataStorage;
  86637. }());
  86638. /**
  86639. * @hidden
  86640. **/
  86641. var _InstancesBatch = /** @class */ (function () {
  86642. function _InstancesBatch() {
  86643. this.mustReturn = false;
  86644. this.visibleInstances = new Array();
  86645. this.renderSelf = new Array();
  86646. }
  86647. return _InstancesBatch;
  86648. }());
  86649. /**
  86650. * Class used to represent renderable models
  86651. */
  86652. var Mesh = /** @class */ (function (_super) {
  86653. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Mesh, _super);
  86654. /**
  86655. * @constructor
  86656. * @param name The value used by scene.getMeshByName() to do a lookup.
  86657. * @param scene The scene to add this mesh to.
  86658. * @param parent The parent of this mesh, if it has one
  86659. * @param source An optional Mesh from which geometry is shared, cloned.
  86660. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  86661. * When false, achieved by calling a clone(), also passing False.
  86662. * This will make creation of children, recursive.
  86663. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  86664. */
  86665. function Mesh(name, scene, parent, source, doNotCloneChildren, clonePhysicsImpostor) {
  86666. if (scene === void 0) { scene = null; }
  86667. if (parent === void 0) { parent = null; }
  86668. if (source === void 0) { source = null; }
  86669. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  86670. var _this = _super.call(this, name, scene) || this;
  86671. // Members
  86672. /**
  86673. * Gets the delay loading state of the mesh (when delay loading is turned on)
  86674. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  86675. */
  86676. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NONE;
  86677. /**
  86678. * Gets the list of instances created from this mesh
  86679. * it is not supposed to be modified manually.
  86680. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  86681. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  86682. */
  86683. _this.instances = new Array();
  86684. _this._LODLevels = new Array();
  86685. /** @hidden */
  86686. _this._instanceDataStorage = new _InstanceDataStorage();
  86687. // Use by builder only to know what orientation were the mesh build in.
  86688. /** @hidden */
  86689. _this._originalBuilderSideOrientation = Mesh.DEFAULTSIDE;
  86690. /**
  86691. * Use this property to change the original side orientation defined at construction time
  86692. */
  86693. _this.overrideMaterialSideOrientation = null;
  86694. _this._areNormalsFrozen = false; // Will be used by ribbons mainly
  86695. // Will be used to save a source mesh reference, If any
  86696. _this._source = null;
  86697. /** @hidden */
  86698. _this._isMesh = true;
  86699. scene = _this.getScene();
  86700. if (source) {
  86701. // Geometry
  86702. if (source._geometry) {
  86703. source._geometry.applyToMesh(_this);
  86704. }
  86705. // Deep copy
  86706. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(source, _this, ["name", "material", "skeleton", "instances", "parent", "uniqueId",
  86707. "source", "metadata", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen",
  86708. "onBeforeDrawObservable", "onBeforeRenderObservable", "onAfterRenderObservable", "onBeforeDraw",
  86709. "onAfterWorldMatrixUpdateObservable", "onCollideObservable", "onCollisionPositionChangeObservable", "onRebuildObservable",
  86710. "onDisposeObservable"
  86711. ], ["_poseMatrix"]);
  86712. // Source mesh
  86713. _this._source = source;
  86714. if (scene.useClonedMeshhMap) {
  86715. if (!source.meshMap) {
  86716. source.meshMap = {};
  86717. }
  86718. source.meshMap[_this.uniqueId] = _this;
  86719. }
  86720. // Construction Params
  86721. // Clone parameters allowing mesh to be updated in case of parametric shapes.
  86722. _this._originalBuilderSideOrientation = source._originalBuilderSideOrientation;
  86723. _this._creationDataStorage = source._creationDataStorage;
  86724. // Animation ranges
  86725. if (_this._source._ranges) {
  86726. var ranges = _this._source._ranges;
  86727. for (var name in ranges) {
  86728. if (!ranges.hasOwnProperty(name)) {
  86729. continue;
  86730. }
  86731. if (!ranges[name]) {
  86732. continue;
  86733. }
  86734. _this.createAnimationRange(name, ranges[name].from, ranges[name].to);
  86735. }
  86736. }
  86737. // Metadata
  86738. if (source.metadata && source.metadata.clone) {
  86739. _this.metadata = source.metadata.clone();
  86740. }
  86741. else {
  86742. _this.metadata = source.metadata;
  86743. }
  86744. // Tags
  86745. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(source)) {
  86746. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(_this, _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(source, true));
  86747. }
  86748. // Parent
  86749. _this.parent = source.parent;
  86750. // Pivot
  86751. _this.setPivotMatrix(source.getPivotMatrix());
  86752. _this.id = name + "." + source.id;
  86753. // Material
  86754. _this.material = source.material;
  86755. var index;
  86756. if (!doNotCloneChildren) {
  86757. // Children
  86758. var directDescendants = source.getDescendants(true);
  86759. for (var index_1 = 0; index_1 < directDescendants.length; index_1++) {
  86760. var child = directDescendants[index_1];
  86761. if (child.clone) {
  86762. child.clone(name + "." + child.name, _this);
  86763. }
  86764. }
  86765. }
  86766. // Physics clone
  86767. var physicsEngine = _this.getScene().getPhysicsEngine();
  86768. if (clonePhysicsImpostor && physicsEngine) {
  86769. var impostor = physicsEngine.getImpostorForPhysicsObject(source);
  86770. if (impostor) {
  86771. _this.physicsImpostor = impostor.clone(_this);
  86772. }
  86773. }
  86774. // Particles
  86775. for (index = 0; index < scene.particleSystems.length; index++) {
  86776. var system = scene.particleSystems[index];
  86777. if (system.emitter === source) {
  86778. system.clone(system.name, _this);
  86779. }
  86780. }
  86781. _this.refreshBoundingInfo();
  86782. _this.computeWorldMatrix(true);
  86783. }
  86784. // Parent
  86785. if (parent !== null) {
  86786. _this.parent = parent;
  86787. }
  86788. return _this;
  86789. }
  86790. /**
  86791. * Gets the default side orientation.
  86792. * @param orientation the orientation to value to attempt to get
  86793. * @returns the default orientation
  86794. * @hidden
  86795. */
  86796. Mesh._GetDefaultSideOrientation = function (orientation) {
  86797. return orientation || Mesh.FRONTSIDE; // works as Mesh.FRONTSIDE is 0
  86798. };
  86799. Object.defineProperty(Mesh.prototype, "onBeforeRenderObservable", {
  86800. /**
  86801. * An event triggered before rendering the mesh
  86802. */
  86803. get: function () {
  86804. if (!this._onBeforeRenderObservable) {
  86805. this._onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  86806. }
  86807. return this._onBeforeRenderObservable;
  86808. },
  86809. enumerable: true,
  86810. configurable: true
  86811. });
  86812. Object.defineProperty(Mesh.prototype, "onBeforeBindObservable", {
  86813. /**
  86814. * An event triggered before binding the mesh
  86815. */
  86816. get: function () {
  86817. if (!this._onBeforeBindObservable) {
  86818. this._onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  86819. }
  86820. return this._onBeforeBindObservable;
  86821. },
  86822. enumerable: true,
  86823. configurable: true
  86824. });
  86825. Object.defineProperty(Mesh.prototype, "onAfterRenderObservable", {
  86826. /**
  86827. * An event triggered after rendering the mesh
  86828. */
  86829. get: function () {
  86830. if (!this._onAfterRenderObservable) {
  86831. this._onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  86832. }
  86833. return this._onAfterRenderObservable;
  86834. },
  86835. enumerable: true,
  86836. configurable: true
  86837. });
  86838. Object.defineProperty(Mesh.prototype, "onBeforeDrawObservable", {
  86839. /**
  86840. * An event triggered before drawing the mesh
  86841. */
  86842. get: function () {
  86843. if (!this._onBeforeDrawObservable) {
  86844. this._onBeforeDrawObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  86845. }
  86846. return this._onBeforeDrawObservable;
  86847. },
  86848. enumerable: true,
  86849. configurable: true
  86850. });
  86851. Object.defineProperty(Mesh.prototype, "onBeforeDraw", {
  86852. /**
  86853. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  86854. */
  86855. set: function (callback) {
  86856. if (this._onBeforeDrawObserver) {
  86857. this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver);
  86858. }
  86859. this._onBeforeDrawObserver = this.onBeforeDrawObservable.add(callback);
  86860. },
  86861. enumerable: true,
  86862. configurable: true
  86863. });
  86864. Object.defineProperty(Mesh.prototype, "morphTargetManager", {
  86865. /**
  86866. * Gets or sets the morph target manager
  86867. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  86868. */
  86869. get: function () {
  86870. return this._morphTargetManager;
  86871. },
  86872. set: function (value) {
  86873. if (this._morphTargetManager === value) {
  86874. return;
  86875. }
  86876. this._morphTargetManager = value;
  86877. this._syncGeometryWithMorphTargetManager();
  86878. },
  86879. enumerable: true,
  86880. configurable: true
  86881. });
  86882. Object.defineProperty(Mesh.prototype, "source", {
  86883. /**
  86884. * Gets the source mesh (the one used to clone this one from)
  86885. */
  86886. get: function () {
  86887. return this._source;
  86888. },
  86889. enumerable: true,
  86890. configurable: true
  86891. });
  86892. Object.defineProperty(Mesh.prototype, "isUnIndexed", {
  86893. /**
  86894. * Gets or sets a boolean indicating that this mesh does not use index buffer
  86895. */
  86896. get: function () {
  86897. return this._unIndexed;
  86898. },
  86899. set: function (value) {
  86900. if (this._unIndexed !== value) {
  86901. this._unIndexed = value;
  86902. this._markSubMeshesAsAttributesDirty();
  86903. }
  86904. },
  86905. enumerable: true,
  86906. configurable: true
  86907. });
  86908. // Methods
  86909. /**
  86910. * Gets the class name
  86911. * @returns the string "Mesh".
  86912. */
  86913. Mesh.prototype.getClassName = function () {
  86914. return "Mesh";
  86915. };
  86916. /**
  86917. * Returns a description of this mesh
  86918. * @param fullDetails define if full details about this mesh must be used
  86919. * @returns a descriptive string representing this mesh
  86920. */
  86921. Mesh.prototype.toString = function (fullDetails) {
  86922. var ret = _super.prototype.toString.call(this, fullDetails);
  86923. ret += ", n vertices: " + this.getTotalVertices();
  86924. ret += ", parent: " + (this._waitingParentId ? this._waitingParentId : (this.parent ? this.parent.name : "NONE"));
  86925. if (this.animations) {
  86926. for (var i = 0; i < this.animations.length; i++) {
  86927. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  86928. }
  86929. }
  86930. if (fullDetails) {
  86931. if (this._geometry) {
  86932. var ib = this.getIndices();
  86933. var vb = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  86934. if (vb && ib) {
  86935. ret += ", flat shading: " + (vb.length / 3 === ib.length ? "YES" : "NO");
  86936. }
  86937. }
  86938. else {
  86939. ret += ", flat shading: UNKNOWN";
  86940. }
  86941. }
  86942. return ret;
  86943. };
  86944. /** @hidden */
  86945. Mesh.prototype._unBindEffect = function () {
  86946. _super.prototype._unBindEffect.call(this);
  86947. for (var _i = 0, _a = this.instances; _i < _a.length; _i++) {
  86948. var instance = _a[_i];
  86949. instance._unBindEffect();
  86950. }
  86951. };
  86952. Object.defineProperty(Mesh.prototype, "hasLODLevels", {
  86953. /**
  86954. * Gets a boolean indicating if this mesh has LOD
  86955. */
  86956. get: function () {
  86957. return this._LODLevels.length > 0;
  86958. },
  86959. enumerable: true,
  86960. configurable: true
  86961. });
  86962. /**
  86963. * Gets the list of MeshLODLevel associated with the current mesh
  86964. * @returns an array of MeshLODLevel
  86965. */
  86966. Mesh.prototype.getLODLevels = function () {
  86967. return this._LODLevels;
  86968. };
  86969. Mesh.prototype._sortLODLevels = function () {
  86970. this._LODLevels.sort(function (a, b) {
  86971. if (a.distance < b.distance) {
  86972. return 1;
  86973. }
  86974. if (a.distance > b.distance) {
  86975. return -1;
  86976. }
  86977. return 0;
  86978. });
  86979. };
  86980. /**
  86981. * Add a mesh as LOD level triggered at the given distance.
  86982. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  86983. * @param distance The distance from the center of the object to show this level
  86984. * @param mesh The mesh to be added as LOD level (can be null)
  86985. * @return This mesh (for chaining)
  86986. */
  86987. Mesh.prototype.addLODLevel = function (distance, mesh) {
  86988. if (mesh && mesh._masterMesh) {
  86989. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("You cannot use a mesh as LOD level twice");
  86990. return this;
  86991. }
  86992. var level = new MeshLODLevel(distance, mesh);
  86993. this._LODLevels.push(level);
  86994. if (mesh) {
  86995. mesh._masterMesh = this;
  86996. }
  86997. this._sortLODLevels();
  86998. return this;
  86999. };
  87000. /**
  87001. * Returns the LOD level mesh at the passed distance or null if not found.
  87002. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87003. * @param distance The distance from the center of the object to show this level
  87004. * @returns a Mesh or `null`
  87005. */
  87006. Mesh.prototype.getLODLevelAtDistance = function (distance) {
  87007. for (var index = 0; index < this._LODLevels.length; index++) {
  87008. var level = this._LODLevels[index];
  87009. if (level.distance === distance) {
  87010. return level.mesh;
  87011. }
  87012. }
  87013. return null;
  87014. };
  87015. /**
  87016. * Remove a mesh from the LOD array
  87017. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87018. * @param mesh defines the mesh to be removed
  87019. * @return This mesh (for chaining)
  87020. */
  87021. Mesh.prototype.removeLODLevel = function (mesh) {
  87022. for (var index = 0; index < this._LODLevels.length; index++) {
  87023. if (this._LODLevels[index].mesh === mesh) {
  87024. this._LODLevels.splice(index, 1);
  87025. if (mesh) {
  87026. mesh._masterMesh = null;
  87027. }
  87028. }
  87029. }
  87030. this._sortLODLevels();
  87031. return this;
  87032. };
  87033. /**
  87034. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  87035. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87036. * @param camera defines the camera to use to compute distance
  87037. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  87038. * @return This mesh (for chaining)
  87039. */
  87040. Mesh.prototype.getLOD = function (camera, boundingSphere) {
  87041. if (!this._LODLevels || this._LODLevels.length === 0) {
  87042. return this;
  87043. }
  87044. var bSphere;
  87045. if (boundingSphere) {
  87046. bSphere = boundingSphere;
  87047. }
  87048. else {
  87049. var boundingInfo = this.getBoundingInfo();
  87050. bSphere = boundingInfo.boundingSphere;
  87051. }
  87052. var distanceToCamera = bSphere.centerWorld.subtract(camera.globalPosition).length();
  87053. if (this._LODLevels[this._LODLevels.length - 1].distance > distanceToCamera) {
  87054. if (this.onLODLevelSelection) {
  87055. this.onLODLevelSelection(distanceToCamera, this, this._LODLevels[this._LODLevels.length - 1].mesh);
  87056. }
  87057. return this;
  87058. }
  87059. for (var index = 0; index < this._LODLevels.length; index++) {
  87060. var level = this._LODLevels[index];
  87061. if (level.distance < distanceToCamera) {
  87062. if (level.mesh) {
  87063. level.mesh._preActivate();
  87064. level.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);
  87065. }
  87066. if (this.onLODLevelSelection) {
  87067. this.onLODLevelSelection(distanceToCamera, this, level.mesh);
  87068. }
  87069. return level.mesh;
  87070. }
  87071. }
  87072. if (this.onLODLevelSelection) {
  87073. this.onLODLevelSelection(distanceToCamera, this, this);
  87074. }
  87075. return this;
  87076. };
  87077. Object.defineProperty(Mesh.prototype, "geometry", {
  87078. /**
  87079. * Gets the mesh internal Geometry object
  87080. */
  87081. get: function () {
  87082. return this._geometry;
  87083. },
  87084. enumerable: true,
  87085. configurable: true
  87086. });
  87087. /**
  87088. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  87089. * @returns the total number of vertices
  87090. */
  87091. Mesh.prototype.getTotalVertices = function () {
  87092. if (this._geometry === null || this._geometry === undefined) {
  87093. return 0;
  87094. }
  87095. return this._geometry.getTotalVertices();
  87096. };
  87097. /**
  87098. * Returns the content of an associated vertex buffer
  87099. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87100. * - VertexBuffer.PositionKind
  87101. * - VertexBuffer.UVKind
  87102. * - VertexBuffer.UV2Kind
  87103. * - VertexBuffer.UV3Kind
  87104. * - VertexBuffer.UV4Kind
  87105. * - VertexBuffer.UV5Kind
  87106. * - VertexBuffer.UV6Kind
  87107. * - VertexBuffer.ColorKind
  87108. * - VertexBuffer.MatricesIndicesKind
  87109. * - VertexBuffer.MatricesIndicesExtraKind
  87110. * - VertexBuffer.MatricesWeightsKind
  87111. * - VertexBuffer.MatricesWeightsExtraKind
  87112. * @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
  87113. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  87114. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  87115. */
  87116. Mesh.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  87117. if (!this._geometry) {
  87118. return null;
  87119. }
  87120. return this._geometry.getVerticesData(kind, copyWhenShared, forceCopy);
  87121. };
  87122. /**
  87123. * Returns the mesh VertexBuffer object from the requested `kind`
  87124. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87125. * - VertexBuffer.PositionKind
  87126. * - VertexBuffer.UVKind
  87127. * - VertexBuffer.UV2Kind
  87128. * - VertexBuffer.UV3Kind
  87129. * - VertexBuffer.UV4Kind
  87130. * - VertexBuffer.UV5Kind
  87131. * - VertexBuffer.UV6Kind
  87132. * - VertexBuffer.ColorKind
  87133. * - VertexBuffer.MatricesIndicesKind
  87134. * - VertexBuffer.MatricesIndicesExtraKind
  87135. * - VertexBuffer.MatricesWeightsKind
  87136. * - VertexBuffer.MatricesWeightsExtraKind
  87137. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  87138. */
  87139. Mesh.prototype.getVertexBuffer = function (kind) {
  87140. if (!this._geometry) {
  87141. return null;
  87142. }
  87143. return this._geometry.getVertexBuffer(kind);
  87144. };
  87145. /**
  87146. * Tests if a specific vertex buffer is associated with this mesh
  87147. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  87148. * - VertexBuffer.PositionKind
  87149. * - VertexBuffer.UVKind
  87150. * - VertexBuffer.UV2Kind
  87151. * - VertexBuffer.UV3Kind
  87152. * - VertexBuffer.UV4Kind
  87153. * - VertexBuffer.UV5Kind
  87154. * - VertexBuffer.UV6Kind
  87155. * - VertexBuffer.ColorKind
  87156. * - VertexBuffer.MatricesIndicesKind
  87157. * - VertexBuffer.MatricesIndicesExtraKind
  87158. * - VertexBuffer.MatricesWeightsKind
  87159. * - VertexBuffer.MatricesWeightsExtraKind
  87160. * @returns a boolean
  87161. */
  87162. Mesh.prototype.isVerticesDataPresent = function (kind) {
  87163. if (!this._geometry) {
  87164. if (this._delayInfo) {
  87165. return this._delayInfo.indexOf(kind) !== -1;
  87166. }
  87167. return false;
  87168. }
  87169. return this._geometry.isVerticesDataPresent(kind);
  87170. };
  87171. /**
  87172. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  87173. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  87174. * - VertexBuffer.PositionKind
  87175. * - VertexBuffer.UVKind
  87176. * - VertexBuffer.UV2Kind
  87177. * - VertexBuffer.UV3Kind
  87178. * - VertexBuffer.UV4Kind
  87179. * - VertexBuffer.UV5Kind
  87180. * - VertexBuffer.UV6Kind
  87181. * - VertexBuffer.ColorKind
  87182. * - VertexBuffer.MatricesIndicesKind
  87183. * - VertexBuffer.MatricesIndicesExtraKind
  87184. * - VertexBuffer.MatricesWeightsKind
  87185. * - VertexBuffer.MatricesWeightsExtraKind
  87186. * @returns a boolean
  87187. */
  87188. Mesh.prototype.isVertexBufferUpdatable = function (kind) {
  87189. if (!this._geometry) {
  87190. if (this._delayInfo) {
  87191. return this._delayInfo.indexOf(kind) !== -1;
  87192. }
  87193. return false;
  87194. }
  87195. return this._geometry.isVertexBufferUpdatable(kind);
  87196. };
  87197. /**
  87198. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  87199. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87200. * - VertexBuffer.PositionKind
  87201. * - VertexBuffer.UVKind
  87202. * - VertexBuffer.UV2Kind
  87203. * - VertexBuffer.UV3Kind
  87204. * - VertexBuffer.UV4Kind
  87205. * - VertexBuffer.UV5Kind
  87206. * - VertexBuffer.UV6Kind
  87207. * - VertexBuffer.ColorKind
  87208. * - VertexBuffer.MatricesIndicesKind
  87209. * - VertexBuffer.MatricesIndicesExtraKind
  87210. * - VertexBuffer.MatricesWeightsKind
  87211. * - VertexBuffer.MatricesWeightsExtraKind
  87212. * @returns an array of strings
  87213. */
  87214. Mesh.prototype.getVerticesDataKinds = function () {
  87215. if (!this._geometry) {
  87216. var result = new Array();
  87217. if (this._delayInfo) {
  87218. this._delayInfo.forEach(function (kind) {
  87219. result.push(kind);
  87220. });
  87221. }
  87222. return result;
  87223. }
  87224. return this._geometry.getVerticesDataKinds();
  87225. };
  87226. /**
  87227. * Returns a positive integer : the total number of indices in this mesh geometry.
  87228. * @returns the numner of indices or zero if the mesh has no geometry.
  87229. */
  87230. Mesh.prototype.getTotalIndices = function () {
  87231. if (!this._geometry) {
  87232. return 0;
  87233. }
  87234. return this._geometry.getTotalIndices();
  87235. };
  87236. /**
  87237. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87238. * @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.
  87239. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87240. * @returns the indices array or an empty array if the mesh has no geometry
  87241. */
  87242. Mesh.prototype.getIndices = function (copyWhenShared, forceCopy) {
  87243. if (!this._geometry) {
  87244. return [];
  87245. }
  87246. return this._geometry.getIndices(copyWhenShared, forceCopy);
  87247. };
  87248. Object.defineProperty(Mesh.prototype, "isBlocked", {
  87249. get: function () {
  87250. return this._masterMesh !== null && this._masterMesh !== undefined;
  87251. },
  87252. enumerable: true,
  87253. configurable: true
  87254. });
  87255. /**
  87256. * Determine if the current mesh is ready to be rendered
  87257. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87258. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  87259. * @returns true if all associated assets are ready (material, textures, shaders)
  87260. */
  87261. Mesh.prototype.isReady = function (completeCheck, forceInstanceSupport) {
  87262. if (completeCheck === void 0) { completeCheck = false; }
  87263. if (forceInstanceSupport === void 0) { forceInstanceSupport = false; }
  87264. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  87265. return false;
  87266. }
  87267. if (!_super.prototype.isReady.call(this, completeCheck)) {
  87268. return false;
  87269. }
  87270. if (!this.subMeshes || this.subMeshes.length === 0) {
  87271. return true;
  87272. }
  87273. if (!completeCheck) {
  87274. return true;
  87275. }
  87276. var engine = this.getEngine();
  87277. var scene = this.getScene();
  87278. var hardwareInstancedRendering = forceInstanceSupport || engine.getCaps().instancedArrays && this.instances.length > 0;
  87279. this.computeWorldMatrix();
  87280. var mat = this.material || scene.defaultMaterial;
  87281. if (mat) {
  87282. if (mat._storeEffectOnSubMeshes) {
  87283. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  87284. var subMesh = _a[_i];
  87285. var effectiveMaterial = subMesh.getMaterial();
  87286. if (effectiveMaterial) {
  87287. if (effectiveMaterial._storeEffectOnSubMeshes) {
  87288. if (!effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  87289. return false;
  87290. }
  87291. }
  87292. else {
  87293. if (!effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  87294. return false;
  87295. }
  87296. }
  87297. }
  87298. }
  87299. }
  87300. else {
  87301. if (!mat.isReady(this, hardwareInstancedRendering)) {
  87302. return false;
  87303. }
  87304. }
  87305. }
  87306. // Shadows
  87307. for (var _b = 0, _c = this._lightSources; _b < _c.length; _b++) {
  87308. var light = _c[_b];
  87309. var generator = light.getShadowGenerator();
  87310. if (generator) {
  87311. for (var _d = 0, _e = this.subMeshes; _d < _e.length; _d++) {
  87312. var subMesh = _e[_d];
  87313. if (!generator.isReady(subMesh, hardwareInstancedRendering)) {
  87314. return false;
  87315. }
  87316. }
  87317. }
  87318. }
  87319. // LOD
  87320. for (var _f = 0, _g = this._LODLevels; _f < _g.length; _f++) {
  87321. var lod = _g[_f];
  87322. if (lod.mesh && !lod.mesh.isReady(hardwareInstancedRendering)) {
  87323. return false;
  87324. }
  87325. }
  87326. return true;
  87327. };
  87328. Object.defineProperty(Mesh.prototype, "areNormalsFrozen", {
  87329. /**
  87330. * 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.
  87331. */
  87332. get: function () {
  87333. return this._areNormalsFrozen;
  87334. },
  87335. enumerable: true,
  87336. configurable: true
  87337. });
  87338. /**
  87339. * 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.
  87340. * @returns the current mesh
  87341. */
  87342. Mesh.prototype.freezeNormals = function () {
  87343. this._areNormalsFrozen = true;
  87344. return this;
  87345. };
  87346. /**
  87347. * 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
  87348. * @returns the current mesh
  87349. */
  87350. Mesh.prototype.unfreezeNormals = function () {
  87351. this._areNormalsFrozen = false;
  87352. return this;
  87353. };
  87354. Object.defineProperty(Mesh.prototype, "overridenInstanceCount", {
  87355. /**
  87356. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  87357. */
  87358. set: function (count) {
  87359. this._instanceDataStorage.overridenInstanceCount = count;
  87360. },
  87361. enumerable: true,
  87362. configurable: true
  87363. });
  87364. // Methods
  87365. /** @hidden */
  87366. Mesh.prototype._preActivate = function () {
  87367. var sceneRenderId = this.getScene().getRenderId();
  87368. if (this._preActivateId === sceneRenderId) {
  87369. return this;
  87370. }
  87371. this._preActivateId = sceneRenderId;
  87372. this._instanceDataStorage.visibleInstances = null;
  87373. return this;
  87374. };
  87375. /** @hidden */
  87376. Mesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  87377. if (this._instanceDataStorage.visibleInstances) {
  87378. this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId = renderId;
  87379. }
  87380. return this;
  87381. };
  87382. /** @hidden */
  87383. Mesh.prototype._registerInstanceForRenderId = function (instance, renderId) {
  87384. if (!this._instanceDataStorage.visibleInstances) {
  87385. this._instanceDataStorage.visibleInstances = {
  87386. defaultRenderId: renderId,
  87387. selfDefaultRenderId: this._renderId
  87388. };
  87389. }
  87390. if (!this._instanceDataStorage.visibleInstances[renderId]) {
  87391. this._instanceDataStorage.visibleInstances[renderId] = new Array();
  87392. }
  87393. this._instanceDataStorage.visibleInstances[renderId].push(instance);
  87394. return this;
  87395. };
  87396. /**
  87397. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87398. * This means the mesh underlying bounding box and sphere are recomputed.
  87399. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87400. * @returns the current mesh
  87401. */
  87402. Mesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  87403. if (applySkeleton === void 0) { applySkeleton = false; }
  87404. if (this._boundingInfo && this._boundingInfo.isLocked) {
  87405. return this;
  87406. }
  87407. var bias = this.geometry ? this.geometry.boundingBias : null;
  87408. this._refreshBoundingInfo(this._getPositionData(applySkeleton), bias);
  87409. return this;
  87410. };
  87411. /** @hidden */
  87412. Mesh.prototype._createGlobalSubMesh = function (force) {
  87413. var totalVertices = this.getTotalVertices();
  87414. if (!totalVertices || !this.getIndices()) {
  87415. return null;
  87416. }
  87417. // Check if we need to recreate the submeshes
  87418. if (this.subMeshes && this.subMeshes.length > 0) {
  87419. var ib = this.getIndices();
  87420. if (!ib) {
  87421. return null;
  87422. }
  87423. var totalIndices = ib.length;
  87424. var needToRecreate = false;
  87425. if (force) {
  87426. needToRecreate = true;
  87427. }
  87428. else {
  87429. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  87430. var submesh = _a[_i];
  87431. if (submesh.indexStart + submesh.indexCount >= totalIndices) {
  87432. needToRecreate = true;
  87433. break;
  87434. }
  87435. if (submesh.verticesStart + submesh.verticesCount >= totalVertices) {
  87436. needToRecreate = true;
  87437. break;
  87438. }
  87439. }
  87440. }
  87441. if (!needToRecreate) {
  87442. return this.subMeshes[0];
  87443. }
  87444. }
  87445. this.releaseSubMeshes();
  87446. return new _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"](0, 0, totalVertices, 0, this.getTotalIndices(), this);
  87447. };
  87448. /**
  87449. * This function will subdivide the mesh into multiple submeshes
  87450. * @param count defines the expected number of submeshes
  87451. */
  87452. Mesh.prototype.subdivide = function (count) {
  87453. if (count < 1) {
  87454. return;
  87455. }
  87456. var totalIndices = this.getTotalIndices();
  87457. var subdivisionSize = (totalIndices / count) | 0;
  87458. var offset = 0;
  87459. // Ensure that subdivisionSize is a multiple of 3
  87460. while (subdivisionSize % 3 !== 0) {
  87461. subdivisionSize++;
  87462. }
  87463. this.releaseSubMeshes();
  87464. for (var index = 0; index < count; index++) {
  87465. if (offset >= totalIndices) {
  87466. break;
  87467. }
  87468. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, Math.min(subdivisionSize, totalIndices - offset), this);
  87469. offset += subdivisionSize;
  87470. }
  87471. this.synchronizeInstances();
  87472. };
  87473. /**
  87474. * Copy a FloatArray into a specific associated vertex buffer
  87475. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87476. * - VertexBuffer.PositionKind
  87477. * - VertexBuffer.UVKind
  87478. * - VertexBuffer.UV2Kind
  87479. * - VertexBuffer.UV3Kind
  87480. * - VertexBuffer.UV4Kind
  87481. * - VertexBuffer.UV5Kind
  87482. * - VertexBuffer.UV6Kind
  87483. * - VertexBuffer.ColorKind
  87484. * - VertexBuffer.MatricesIndicesKind
  87485. * - VertexBuffer.MatricesIndicesExtraKind
  87486. * - VertexBuffer.MatricesWeightsKind
  87487. * - VertexBuffer.MatricesWeightsExtraKind
  87488. * @param data defines the data source
  87489. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  87490. * @param stride defines the data stride size (can be null)
  87491. * @returns the current mesh
  87492. */
  87493. Mesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  87494. if (updatable === void 0) { updatable = false; }
  87495. if (!this._geometry) {
  87496. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  87497. vertexData.set(data, kind);
  87498. var scene = this.getScene();
  87499. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  87500. }
  87501. else {
  87502. this._geometry.setVerticesData(kind, data, updatable, stride);
  87503. }
  87504. return this;
  87505. };
  87506. /**
  87507. * Flags an associated vertex buffer as updatable
  87508. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  87509. * - VertexBuffer.PositionKind
  87510. * - VertexBuffer.UVKind
  87511. * - VertexBuffer.UV2Kind
  87512. * - VertexBuffer.UV3Kind
  87513. * - VertexBuffer.UV4Kind
  87514. * - VertexBuffer.UV5Kind
  87515. * - VertexBuffer.UV6Kind
  87516. * - VertexBuffer.ColorKind
  87517. * - VertexBuffer.MatricesIndicesKind
  87518. * - VertexBuffer.MatricesIndicesExtraKind
  87519. * - VertexBuffer.MatricesWeightsKind
  87520. * - VertexBuffer.MatricesWeightsExtraKind
  87521. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  87522. */
  87523. Mesh.prototype.markVerticesDataAsUpdatable = function (kind, updatable) {
  87524. if (updatable === void 0) { updatable = true; }
  87525. var vb = this.getVertexBuffer(kind);
  87526. if (!vb || vb.isUpdatable() === updatable) {
  87527. return;
  87528. }
  87529. this.setVerticesData(kind, this.getVerticesData(kind), updatable);
  87530. };
  87531. /**
  87532. * Sets the mesh global Vertex Buffer
  87533. * @param buffer defines the buffer to use
  87534. * @returns the current mesh
  87535. */
  87536. Mesh.prototype.setVerticesBuffer = function (buffer) {
  87537. if (!this._geometry) {
  87538. this._geometry = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].CreateGeometryForMesh(this);
  87539. }
  87540. this._geometry.setVerticesBuffer(buffer);
  87541. return this;
  87542. };
  87543. /**
  87544. * Update a specific associated vertex buffer
  87545. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87546. * - VertexBuffer.PositionKind
  87547. * - VertexBuffer.UVKind
  87548. * - VertexBuffer.UV2Kind
  87549. * - VertexBuffer.UV3Kind
  87550. * - VertexBuffer.UV4Kind
  87551. * - VertexBuffer.UV5Kind
  87552. * - VertexBuffer.UV6Kind
  87553. * - VertexBuffer.ColorKind
  87554. * - VertexBuffer.MatricesIndicesKind
  87555. * - VertexBuffer.MatricesIndicesExtraKind
  87556. * - VertexBuffer.MatricesWeightsKind
  87557. * - VertexBuffer.MatricesWeightsExtraKind
  87558. * @param data defines the data source
  87559. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  87560. * @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)
  87561. * @returns the current mesh
  87562. */
  87563. Mesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  87564. if (!this._geometry) {
  87565. return this;
  87566. }
  87567. if (!makeItUnique) {
  87568. this._geometry.updateVerticesData(kind, data, updateExtends);
  87569. }
  87570. else {
  87571. this.makeGeometryUnique();
  87572. this.updateVerticesData(kind, data, updateExtends, false);
  87573. }
  87574. return this;
  87575. };
  87576. /**
  87577. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  87578. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  87579. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  87580. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  87581. * @returns the current mesh
  87582. */
  87583. Mesh.prototype.updateMeshPositions = function (positionFunction, computeNormals) {
  87584. if (computeNormals === void 0) { computeNormals = true; }
  87585. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  87586. if (!positions) {
  87587. return this;
  87588. }
  87589. positionFunction(positions);
  87590. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions, false, false);
  87591. if (computeNormals) {
  87592. var indices = this.getIndices();
  87593. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  87594. if (!normals) {
  87595. return this;
  87596. }
  87597. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, indices, normals);
  87598. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, false, false);
  87599. }
  87600. return this;
  87601. };
  87602. /**
  87603. * Creates a un-shared specific occurence of the geometry for the mesh.
  87604. * @returns the current mesh
  87605. */
  87606. Mesh.prototype.makeGeometryUnique = function () {
  87607. if (!this._geometry) {
  87608. return this;
  87609. }
  87610. var oldGeometry = this._geometry;
  87611. var geometry = this._geometry.copy(_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId());
  87612. oldGeometry.releaseForMesh(this, true);
  87613. geometry.applyToMesh(this);
  87614. return this;
  87615. };
  87616. /**
  87617. * Set the index buffer of this mesh
  87618. * @param indices defines the source data
  87619. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  87620. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  87621. * @returns the current mesh
  87622. */
  87623. Mesh.prototype.setIndices = function (indices, totalVertices, updatable) {
  87624. if (totalVertices === void 0) { totalVertices = null; }
  87625. if (updatable === void 0) { updatable = false; }
  87626. if (!this._geometry) {
  87627. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  87628. vertexData.indices = indices;
  87629. var scene = this.getScene();
  87630. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  87631. }
  87632. else {
  87633. this._geometry.setIndices(indices, totalVertices, updatable);
  87634. }
  87635. return this;
  87636. };
  87637. /**
  87638. * Update the current index buffer
  87639. * @param indices defines the source data
  87640. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  87641. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  87642. * @returns the current mesh
  87643. */
  87644. Mesh.prototype.updateIndices = function (indices, offset, gpuMemoryOnly) {
  87645. if (gpuMemoryOnly === void 0) { gpuMemoryOnly = false; }
  87646. if (!this._geometry) {
  87647. return this;
  87648. }
  87649. this._geometry.updateIndices(indices, offset, gpuMemoryOnly);
  87650. return this;
  87651. };
  87652. /**
  87653. * Invert the geometry to move from a right handed system to a left handed one.
  87654. * @returns the current mesh
  87655. */
  87656. Mesh.prototype.toLeftHanded = function () {
  87657. if (!this._geometry) {
  87658. return this;
  87659. }
  87660. this._geometry.toLeftHanded();
  87661. return this;
  87662. };
  87663. /** @hidden */
  87664. Mesh.prototype._bind = function (subMesh, effect, fillMode) {
  87665. if (!this._geometry) {
  87666. return this;
  87667. }
  87668. var engine = this.getScene().getEngine();
  87669. // Wireframe
  87670. var indexToBind;
  87671. if (this._unIndexed) {
  87672. indexToBind = null;
  87673. }
  87674. else {
  87675. switch (fillMode) {
  87676. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode:
  87677. indexToBind = null;
  87678. break;
  87679. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode:
  87680. indexToBind = subMesh._getLinesIndexBuffer(this.getIndices(), engine);
  87681. break;
  87682. default:
  87683. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].TriangleFillMode:
  87684. indexToBind = this._unIndexed ? null : this._geometry.getIndexBuffer();
  87685. break;
  87686. }
  87687. }
  87688. // VBOs
  87689. this._geometry._bind(effect, indexToBind);
  87690. return this;
  87691. };
  87692. /** @hidden */
  87693. Mesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
  87694. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  87695. return this;
  87696. }
  87697. if (this._onBeforeDrawObservable) {
  87698. this._onBeforeDrawObservable.notifyObservers(this);
  87699. }
  87700. var scene = this.getScene();
  87701. var engine = scene.getEngine();
  87702. if (this._unIndexed || fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode) {
  87703. // or triangles as points
  87704. engine.drawArraysType(fillMode, subMesh.verticesStart, subMesh.verticesCount, instancesCount);
  87705. }
  87706. else if (fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode) {
  87707. // Triangles as wireframe
  87708. engine.drawElementsType(fillMode, 0, subMesh._linesIndexCount, instancesCount);
  87709. }
  87710. else {
  87711. engine.drawElementsType(fillMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  87712. }
  87713. return this;
  87714. };
  87715. /**
  87716. * Registers for this mesh a javascript function called just before the rendering process
  87717. * @param func defines the function to call before rendering this mesh
  87718. * @returns the current mesh
  87719. */
  87720. Mesh.prototype.registerBeforeRender = function (func) {
  87721. this.onBeforeRenderObservable.add(func);
  87722. return this;
  87723. };
  87724. /**
  87725. * Disposes a previously registered javascript function called before the rendering
  87726. * @param func defines the function to remove
  87727. * @returns the current mesh
  87728. */
  87729. Mesh.prototype.unregisterBeforeRender = function (func) {
  87730. this.onBeforeRenderObservable.removeCallback(func);
  87731. return this;
  87732. };
  87733. /**
  87734. * Registers for this mesh a javascript function called just after the rendering is complete
  87735. * @param func defines the function to call after rendering this mesh
  87736. * @returns the current mesh
  87737. */
  87738. Mesh.prototype.registerAfterRender = function (func) {
  87739. this.onAfterRenderObservable.add(func);
  87740. return this;
  87741. };
  87742. /**
  87743. * Disposes a previously registered javascript function called after the rendering.
  87744. * @param func defines the function to remove
  87745. * @returns the current mesh
  87746. */
  87747. Mesh.prototype.unregisterAfterRender = function (func) {
  87748. this.onAfterRenderObservable.removeCallback(func);
  87749. return this;
  87750. };
  87751. /** @hidden */
  87752. Mesh.prototype._getInstancesRenderList = function (subMeshId) {
  87753. var scene = this.getScene();
  87754. var batchCache = this._instanceDataStorage.batchCache;
  87755. batchCache.mustReturn = false;
  87756. batchCache.renderSelf[subMeshId] = this.isEnabled() && this.isVisible;
  87757. batchCache.visibleInstances[subMeshId] = null;
  87758. if (this._instanceDataStorage.visibleInstances) {
  87759. var visibleInstances = this._instanceDataStorage.visibleInstances;
  87760. var currentRenderId = scene.getRenderId();
  87761. var defaultRenderId = (scene._isInIntermediateRendering() ? visibleInstances.intermediateDefaultRenderId : visibleInstances.defaultRenderId);
  87762. batchCache.visibleInstances[subMeshId] = visibleInstances[currentRenderId];
  87763. var selfRenderId = this._renderId;
  87764. if (!batchCache.visibleInstances[subMeshId] && defaultRenderId) {
  87765. batchCache.visibleInstances[subMeshId] = visibleInstances[defaultRenderId];
  87766. currentRenderId = Math.max(defaultRenderId, currentRenderId);
  87767. selfRenderId = Math.max(visibleInstances.selfDefaultRenderId, currentRenderId);
  87768. }
  87769. var visibleInstancesForSubMesh = batchCache.visibleInstances[subMeshId];
  87770. if (visibleInstancesForSubMesh && visibleInstancesForSubMesh.length) {
  87771. if (this._instanceDataStorage.renderIdForInstances[subMeshId] === currentRenderId) {
  87772. batchCache.mustReturn = true;
  87773. return batchCache;
  87774. }
  87775. if (currentRenderId !== selfRenderId) {
  87776. batchCache.renderSelf[subMeshId] = false;
  87777. }
  87778. }
  87779. this._instanceDataStorage.renderIdForInstances[subMeshId] = currentRenderId;
  87780. }
  87781. return batchCache;
  87782. };
  87783. /** @hidden */
  87784. Mesh.prototype._renderWithInstances = function (subMesh, fillMode, batch, effect, engine) {
  87785. var visibleInstances = batch.visibleInstances[subMesh._id];
  87786. if (!visibleInstances) {
  87787. return this;
  87788. }
  87789. var matricesCount = visibleInstances.length + 1;
  87790. var bufferSize = matricesCount * 16 * 4;
  87791. var instanceStorage = this._instanceDataStorage;
  87792. var currentInstancesBufferSize = instanceStorage.instancesBufferSize;
  87793. var instancesBuffer = instanceStorage.instancesBuffer;
  87794. while (instanceStorage.instancesBufferSize < bufferSize) {
  87795. instanceStorage.instancesBufferSize *= 2;
  87796. }
  87797. if (!instanceStorage.instancesData || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  87798. instanceStorage.instancesData = new Float32Array(instanceStorage.instancesBufferSize / 4);
  87799. }
  87800. var offset = 0;
  87801. var instancesCount = 0;
  87802. var world = this._effectiveMesh.getWorldMatrix();
  87803. if (batch.renderSelf[subMesh._id]) {
  87804. world.copyToArray(instanceStorage.instancesData, offset);
  87805. offset += 16;
  87806. instancesCount++;
  87807. }
  87808. if (visibleInstances) {
  87809. for (var instanceIndex = 0; instanceIndex < visibleInstances.length; instanceIndex++) {
  87810. var instance = visibleInstances[instanceIndex];
  87811. instance.getWorldMatrix().copyToArray(instanceStorage.instancesData, offset);
  87812. offset += 16;
  87813. instancesCount++;
  87814. }
  87815. }
  87816. if (!instancesBuffer || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  87817. if (instancesBuffer) {
  87818. instancesBuffer.dispose();
  87819. }
  87820. instancesBuffer = new _buffer__WEBPACK_IMPORTED_MODULE_7__["Buffer"](engine, instanceStorage.instancesData, true, 16, false, true);
  87821. instanceStorage.instancesBuffer = instancesBuffer;
  87822. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world0", 0, 4));
  87823. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world1", 4, 4));
  87824. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world2", 8, 4));
  87825. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world3", 12, 4));
  87826. }
  87827. else {
  87828. instancesBuffer.updateDirectly(instanceStorage.instancesData, 0, instancesCount);
  87829. }
  87830. this._bind(subMesh, effect, fillMode);
  87831. this._draw(subMesh, fillMode, instancesCount);
  87832. engine.unbindInstanceAttributes();
  87833. return this;
  87834. };
  87835. /** @hidden */
  87836. Mesh.prototype._processRendering = function (subMesh, effect, fillMode, batch, hardwareInstancedRendering, onBeforeDraw, effectiveMaterial) {
  87837. var scene = this.getScene();
  87838. var engine = scene.getEngine();
  87839. if (hardwareInstancedRendering) {
  87840. this._renderWithInstances(subMesh, fillMode, batch, effect, engine);
  87841. }
  87842. else {
  87843. if (batch.renderSelf[subMesh._id]) {
  87844. // Draw
  87845. if (onBeforeDraw) {
  87846. onBeforeDraw(false, this._effectiveMesh.getWorldMatrix(), effectiveMaterial);
  87847. }
  87848. this._draw(subMesh, fillMode, this._instanceDataStorage.overridenInstanceCount);
  87849. }
  87850. var visibleInstancesForSubMesh = batch.visibleInstances[subMesh._id];
  87851. if (visibleInstancesForSubMesh) {
  87852. for (var instanceIndex = 0; instanceIndex < visibleInstancesForSubMesh.length; instanceIndex++) {
  87853. var instance = visibleInstancesForSubMesh[instanceIndex];
  87854. // World
  87855. var world = instance.getWorldMatrix();
  87856. if (onBeforeDraw) {
  87857. onBeforeDraw(true, world, effectiveMaterial);
  87858. }
  87859. // Draw
  87860. this._draw(subMesh, fillMode);
  87861. }
  87862. }
  87863. }
  87864. return this;
  87865. };
  87866. /**
  87867. * 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
  87868. * @param subMesh defines the subMesh to render
  87869. * @param enableAlphaMode defines if alpha mode can be changed
  87870. * @returns the current mesh
  87871. */
  87872. Mesh.prototype.render = function (subMesh, enableAlphaMode) {
  87873. if (this._checkOcclusionQuery()) {
  87874. return this;
  87875. }
  87876. var scene = this.getScene();
  87877. // Managing instances
  87878. var batch = this._getInstancesRenderList(subMesh._id);
  87879. if (batch.mustReturn) {
  87880. return this;
  87881. }
  87882. // Checking geometry state
  87883. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  87884. return this;
  87885. }
  87886. if (this._onBeforeRenderObservable) {
  87887. this._onBeforeRenderObservable.notifyObservers(this);
  87888. }
  87889. var engine = scene.getEngine();
  87890. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  87891. // Material
  87892. var material = subMesh.getMaterial();
  87893. if (!material) {
  87894. return this;
  87895. }
  87896. this._effectiveMaterial = material;
  87897. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  87898. if (!this._effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  87899. return this;
  87900. }
  87901. }
  87902. else if (!this._effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  87903. return this;
  87904. }
  87905. // Alpha mode
  87906. if (enableAlphaMode) {
  87907. engine.setAlphaMode(this._effectiveMaterial.alphaMode);
  87908. }
  87909. for (var _i = 0, _a = scene._beforeRenderingMeshStage; _i < _a.length; _i++) {
  87910. var step = _a[_i];
  87911. step.action(this, subMesh, batch);
  87912. }
  87913. var effect;
  87914. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  87915. effect = subMesh.effect;
  87916. }
  87917. else {
  87918. effect = this._effectiveMaterial.getEffect();
  87919. }
  87920. if (!effect) {
  87921. return this;
  87922. }
  87923. var effectiveMesh = this._effectiveMesh;
  87924. var sideOrientation = this.overrideMaterialSideOrientation;
  87925. if (sideOrientation == null) {
  87926. sideOrientation = this._effectiveMaterial.sideOrientation;
  87927. if (effectiveMesh._getWorldMatrixDeterminant() < 0) {
  87928. 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);
  87929. }
  87930. }
  87931. var reverse = this._effectiveMaterial._preBind(effect, sideOrientation);
  87932. if (this._effectiveMaterial.forceDepthWrite) {
  87933. engine.setDepthWrite(true);
  87934. }
  87935. // Bind
  87936. 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);
  87937. if (this._onBeforeBindObservable) {
  87938. this._onBeforeBindObservable.notifyObservers(this);
  87939. }
  87940. if (!hardwareInstancedRendering) { // Binding will be done later because we need to add more info to the VB
  87941. this._bind(subMesh, effect, fillMode);
  87942. }
  87943. var world = effectiveMesh.getWorldMatrix();
  87944. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  87945. this._effectiveMaterial.bindForSubMesh(world, this, subMesh);
  87946. }
  87947. else {
  87948. this._effectiveMaterial.bind(world, this);
  87949. }
  87950. if (!this._effectiveMaterial.backFaceCulling && this._effectiveMaterial.separateCullingPass) {
  87951. engine.setState(true, this._effectiveMaterial.zOffset, false, !reverse);
  87952. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  87953. engine.setState(true, this._effectiveMaterial.zOffset, false, reverse);
  87954. }
  87955. // Draw
  87956. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  87957. // Unbind
  87958. this._effectiveMaterial.unbind();
  87959. for (var _b = 0, _c = scene._afterRenderingMeshStage; _b < _c.length; _b++) {
  87960. var step = _c[_b];
  87961. step.action(this, subMesh, batch);
  87962. }
  87963. if (this._onAfterRenderObservable) {
  87964. this._onAfterRenderObservable.notifyObservers(this);
  87965. }
  87966. return this;
  87967. };
  87968. Mesh.prototype._onBeforeDraw = function (isInstance, world, effectiveMaterial) {
  87969. if (isInstance && effectiveMaterial) {
  87970. effectiveMaterial.bindOnlyWorldMatrix(world);
  87971. }
  87972. };
  87973. /**
  87974. * Renormalize the mesh and patch it up if there are no weights
  87975. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  87976. * However in the case of zero weights then we set just a single influence to 1.
  87977. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  87978. */
  87979. Mesh.prototype.cleanMatrixWeights = function () {
  87980. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  87981. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind)) {
  87982. this.normalizeSkinWeightsAndExtra();
  87983. }
  87984. else {
  87985. this.normalizeSkinFourWeights();
  87986. }
  87987. }
  87988. };
  87989. // faster 4 weight version.
  87990. Mesh.prototype.normalizeSkinFourWeights = function () {
  87991. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  87992. var numWeights = matricesWeights.length;
  87993. for (var a = 0; a < numWeights; a += 4) {
  87994. // accumulate weights
  87995. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  87996. // check for invalid weight and just set it to 1.
  87997. if (t === 0) {
  87998. matricesWeights[a] = 1;
  87999. }
  88000. else {
  88001. // renormalize so everything adds to 1 use reciprical
  88002. var recip = 1 / t;
  88003. matricesWeights[a] *= recip;
  88004. matricesWeights[a + 1] *= recip;
  88005. matricesWeights[a + 2] *= recip;
  88006. matricesWeights[a + 3] *= recip;
  88007. }
  88008. }
  88009. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  88010. };
  88011. // handle special case of extra verts. (in theory gltf can handle 12 influences)
  88012. Mesh.prototype.normalizeSkinWeightsAndExtra = function () {
  88013. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  88014. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  88015. var numWeights = matricesWeights.length;
  88016. for (var a = 0; a < numWeights; a += 4) {
  88017. // accumulate weights
  88018. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  88019. t += matricesWeightsExtra[a] + matricesWeightsExtra[a + 1] + matricesWeightsExtra[a + 2] + matricesWeightsExtra[a + 3];
  88020. // check for invalid weight and just set it to 1.
  88021. if (t === 0) {
  88022. matricesWeights[a] = 1;
  88023. }
  88024. else {
  88025. // renormalize so everything adds to 1 use reciprical
  88026. var recip = 1 / t;
  88027. matricesWeights[a] *= recip;
  88028. matricesWeights[a + 1] *= recip;
  88029. matricesWeights[a + 2] *= recip;
  88030. matricesWeights[a + 3] *= recip;
  88031. // same goes for extras
  88032. matricesWeightsExtra[a] *= recip;
  88033. matricesWeightsExtra[a + 1] *= recip;
  88034. matricesWeightsExtra[a + 2] *= recip;
  88035. matricesWeightsExtra[a + 3] *= recip;
  88036. }
  88037. }
  88038. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  88039. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeightsExtra);
  88040. };
  88041. /**
  88042. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  88043. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  88044. * the user know there was an issue with importing the mesh
  88045. * @returns a validation object with skinned, valid and report string
  88046. */
  88047. Mesh.prototype.validateSkinning = function () {
  88048. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  88049. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  88050. if (matricesWeights === null || this.skeleton == null) {
  88051. return { skinned: false, valid: true, report: "not skinned" };
  88052. }
  88053. var numWeights = matricesWeights.length;
  88054. var numberNotSorted = 0;
  88055. var missingWeights = 0;
  88056. var maxUsedWeights = 0;
  88057. var numberNotNormalized = 0;
  88058. var numInfluences = matricesWeightsExtra === null ? 4 : 8;
  88059. var usedWeightCounts = new Array();
  88060. for (var a = 0; a <= numInfluences; a++) {
  88061. usedWeightCounts[a] = 0;
  88062. }
  88063. var toleranceEpsilon = 0.001;
  88064. for (var a = 0; a < numWeights; a += 4) {
  88065. var lastWeight = matricesWeights[a];
  88066. var t = lastWeight;
  88067. var usedWeights = t === 0 ? 0 : 1;
  88068. for (var b = 1; b < numInfluences; b++) {
  88069. var d = b < 4 ? matricesWeights[a + b] : matricesWeightsExtra[a + b - 4];
  88070. if (d > lastWeight) {
  88071. numberNotSorted++;
  88072. }
  88073. if (d !== 0) {
  88074. usedWeights++;
  88075. }
  88076. t += d;
  88077. lastWeight = d;
  88078. }
  88079. // count the buffer weights usage
  88080. usedWeightCounts[usedWeights]++;
  88081. // max influences
  88082. if (usedWeights > maxUsedWeights) {
  88083. maxUsedWeights = usedWeights;
  88084. }
  88085. // check for invalid weight and just set it to 1.
  88086. if (t === 0) {
  88087. missingWeights++;
  88088. }
  88089. else {
  88090. // renormalize so everything adds to 1 use reciprical
  88091. var recip = 1 / t;
  88092. var tolerance = 0;
  88093. for (b = 0; b < numInfluences; b++) {
  88094. if (b < 4) {
  88095. tolerance += Math.abs(matricesWeights[a + b] - (matricesWeights[a + b] * recip));
  88096. }
  88097. else {
  88098. tolerance += Math.abs(matricesWeightsExtra[a + b - 4] - (matricesWeightsExtra[a + b - 4] * recip));
  88099. }
  88100. }
  88101. // arbitary epsilon value for dicdating not normalized
  88102. if (tolerance > toleranceEpsilon) {
  88103. numberNotNormalized++;
  88104. }
  88105. }
  88106. }
  88107. // validate bone indices are in range of the skeleton
  88108. var numBones = this.skeleton.bones.length;
  88109. var matricesIndices = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  88110. var matricesIndicesExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind);
  88111. var numBadBoneIndices = 0;
  88112. for (var a = 0; a < numWeights; a++) {
  88113. for (var b = 0; b < numInfluences; b++) {
  88114. var index = b < 4 ? matricesIndices[b] : matricesIndicesExtra[b - 4];
  88115. if (index >= numBones || index < 0) {
  88116. numBadBoneIndices++;
  88117. }
  88118. }
  88119. }
  88120. // log mesh stats
  88121. var output = "Number of Weights = " + numWeights / 4 + "\nMaximum influences = " + maxUsedWeights +
  88122. "\nMissing Weights = " + missingWeights + "\nNot Sorted = " + numberNotSorted +
  88123. "\nNot Normalized = " + numberNotNormalized + "\nWeightCounts = [" + usedWeightCounts + "]" +
  88124. "\nNumber of bones = " + numBones + "\nBad Bone Indices = " + numBadBoneIndices;
  88125. return { skinned: true, valid: missingWeights === 0 && numberNotNormalized === 0 && numBadBoneIndices === 0, report: output };
  88126. };
  88127. /** @hidden */
  88128. Mesh.prototype._checkDelayState = function () {
  88129. var scene = this.getScene();
  88130. if (this._geometry) {
  88131. this._geometry.load(scene);
  88132. }
  88133. else if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  88134. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING;
  88135. this._queueLoad(scene);
  88136. }
  88137. return this;
  88138. };
  88139. Mesh.prototype._queueLoad = function (scene) {
  88140. var _this = this;
  88141. scene._addPendingData(this);
  88142. var getBinaryData = (this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1);
  88143. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadFile(this.delayLoadingFile, function (data) {
  88144. if (data instanceof ArrayBuffer) {
  88145. _this._delayLoadingFunction(data, _this);
  88146. }
  88147. else {
  88148. _this._delayLoadingFunction(JSON.parse(data), _this);
  88149. }
  88150. _this.instances.forEach(function (instance) {
  88151. instance._syncSubMeshes();
  88152. });
  88153. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADED;
  88154. scene._removePendingData(_this);
  88155. }, function () { }, scene.offlineProvider, getBinaryData);
  88156. return this;
  88157. };
  88158. /**
  88159. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  88160. * A mesh is in the frustum if its bounding box intersects the frustum
  88161. * @param frustumPlanes defines the frustum to test
  88162. * @returns true if the mesh is in the frustum planes
  88163. */
  88164. Mesh.prototype.isInFrustum = function (frustumPlanes) {
  88165. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  88166. return false;
  88167. }
  88168. if (!_super.prototype.isInFrustum.call(this, frustumPlanes)) {
  88169. return false;
  88170. }
  88171. this._checkDelayState();
  88172. return true;
  88173. };
  88174. /**
  88175. * Sets the mesh material by the material or multiMaterial `id` property
  88176. * @param id is a string identifying the material or the multiMaterial
  88177. * @returns the current mesh
  88178. */
  88179. Mesh.prototype.setMaterialByID = function (id) {
  88180. var materials = this.getScene().materials;
  88181. var index;
  88182. for (index = materials.length - 1; index > -1; index--) {
  88183. if (materials[index].id === id) {
  88184. this.material = materials[index];
  88185. return this;
  88186. }
  88187. }
  88188. // Multi
  88189. var multiMaterials = this.getScene().multiMaterials;
  88190. for (index = multiMaterials.length - 1; index > -1; index--) {
  88191. if (multiMaterials[index].id === id) {
  88192. this.material = multiMaterials[index];
  88193. return this;
  88194. }
  88195. }
  88196. return this;
  88197. };
  88198. /**
  88199. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  88200. * @returns an array of IAnimatable
  88201. */
  88202. Mesh.prototype.getAnimatables = function () {
  88203. var results = new Array();
  88204. if (this.material) {
  88205. results.push(this.material);
  88206. }
  88207. if (this.skeleton) {
  88208. results.push(this.skeleton);
  88209. }
  88210. return results;
  88211. };
  88212. /**
  88213. * Modifies the mesh geometry according to the passed transformation matrix.
  88214. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  88215. * The mesh normals are modified using the same transformation.
  88216. * Note that, under the hood, this method sets a new VertexBuffer each call.
  88217. * @param transform defines the transform matrix to use
  88218. * @see http://doc.babylonjs.com/resources/baking_transformations
  88219. * @returns the current mesh
  88220. */
  88221. Mesh.prototype.bakeTransformIntoVertices = function (transform) {
  88222. // Position
  88223. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  88224. return this;
  88225. }
  88226. var submeshes = this.subMeshes.splice(0);
  88227. this._resetPointsArrayCache();
  88228. var data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  88229. var temp = new Array();
  88230. var index;
  88231. for (index = 0; index < data.length; index += 3) {
  88232. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).toArray(temp, index);
  88233. }
  88234. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind).isUpdatable());
  88235. // Normals
  88236. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  88237. data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  88238. temp = [];
  88239. for (index = 0; index < data.length; index += 3) {
  88240. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormal(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).normalize().toArray(temp, index);
  88241. }
  88242. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind).isUpdatable());
  88243. }
  88244. // flip faces?
  88245. if (transform.m[0] * transform.m[5] * transform.m[10] < 0) {
  88246. this.flipFaces();
  88247. }
  88248. // Restore submeshes
  88249. this.releaseSubMeshes();
  88250. this.subMeshes = submeshes;
  88251. return this;
  88252. };
  88253. /**
  88254. * Modifies the mesh geometry according to its own current World Matrix.
  88255. * The mesh World Matrix is then reset.
  88256. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  88257. * Note that, under the hood, this method sets a new VertexBuffer each call.
  88258. * @see http://doc.babylonjs.com/resources/baking_transformations
  88259. * @returns the current mesh
  88260. */
  88261. Mesh.prototype.bakeCurrentTransformIntoVertices = function () {
  88262. this.bakeTransformIntoVertices(this.computeWorldMatrix(true));
  88263. this.scaling.copyFromFloats(1, 1, 1);
  88264. this.position.copyFromFloats(0, 0, 0);
  88265. this.rotation.copyFromFloats(0, 0, 0);
  88266. //only if quaternion is already set
  88267. if (this.rotationQuaternion) {
  88268. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].Identity();
  88269. }
  88270. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  88271. return this;
  88272. };
  88273. Object.defineProperty(Mesh.prototype, "_positions", {
  88274. // Cache
  88275. /** @hidden */
  88276. get: function () {
  88277. if (this._geometry) {
  88278. return this._geometry._positions;
  88279. }
  88280. return null;
  88281. },
  88282. enumerable: true,
  88283. configurable: true
  88284. });
  88285. /** @hidden */
  88286. Mesh.prototype._resetPointsArrayCache = function () {
  88287. if (this._geometry) {
  88288. this._geometry._resetPointsArrayCache();
  88289. }
  88290. return this;
  88291. };
  88292. /** @hidden */
  88293. Mesh.prototype._generatePointsArray = function () {
  88294. if (this._geometry) {
  88295. return this._geometry._generatePointsArray();
  88296. }
  88297. return false;
  88298. };
  88299. /**
  88300. * Returns a new Mesh object generated from the current mesh properties.
  88301. * This method must not get confused with createInstance()
  88302. * @param name is a string, the name given to the new mesh
  88303. * @param newParent can be any Node object (default `null`)
  88304. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  88305. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  88306. * @returns a new mesh
  88307. */
  88308. Mesh.prototype.clone = function (name, newParent, doNotCloneChildren, clonePhysicsImpostor) {
  88309. if (name === void 0) { name = ""; }
  88310. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  88311. return new Mesh(name, this.getScene(), newParent, this, doNotCloneChildren, clonePhysicsImpostor);
  88312. };
  88313. /**
  88314. * Releases resources associated with this mesh.
  88315. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88316. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88317. */
  88318. Mesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  88319. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  88320. this.morphTargetManager = null;
  88321. if (this._geometry) {
  88322. this._geometry.releaseForMesh(this, true);
  88323. }
  88324. if (this._onBeforeDrawObservable) {
  88325. this._onBeforeDrawObservable.clear();
  88326. }
  88327. if (this._onBeforeBindObservable) {
  88328. this._onBeforeBindObservable.clear();
  88329. }
  88330. if (this._onBeforeRenderObservable) {
  88331. this._onBeforeRenderObservable.clear();
  88332. }
  88333. if (this._onAfterRenderObservable) {
  88334. this._onAfterRenderObservable.clear();
  88335. }
  88336. // Sources
  88337. if (this._scene.useClonedMeshhMap) {
  88338. if (this.meshMap) {
  88339. for (var uniqueId in this.meshMap) {
  88340. var mesh = this.meshMap[uniqueId];
  88341. if (mesh) {
  88342. mesh._source = null;
  88343. this.meshMap[uniqueId] = undefined;
  88344. }
  88345. }
  88346. }
  88347. if (this._source && this._source.meshMap) {
  88348. this._source.meshMap[this.uniqueId] = undefined;
  88349. }
  88350. }
  88351. else {
  88352. var meshes = this.getScene().meshes;
  88353. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  88354. var abstractMesh = meshes_1[_i];
  88355. var mesh = abstractMesh;
  88356. if (mesh._source && mesh._source === this) {
  88357. mesh._source = null;
  88358. }
  88359. }
  88360. }
  88361. this._source = null;
  88362. // Instances
  88363. if (this._instanceDataStorage.instancesBuffer) {
  88364. this._instanceDataStorage.instancesBuffer.dispose();
  88365. this._instanceDataStorage.instancesBuffer = null;
  88366. }
  88367. while (this.instances.length) {
  88368. this.instances[0].dispose();
  88369. }
  88370. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  88371. };
  88372. /**
  88373. * Modifies the mesh geometry according to a displacement map.
  88374. * 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.
  88375. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  88376. * @param url is a string, the URL from the image file is to be downloaded.
  88377. * @param minHeight is the lower limit of the displacement.
  88378. * @param maxHeight is the upper limit of the displacement.
  88379. * @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.
  88380. * @param uvOffset is an optional vector2 used to offset UV.
  88381. * @param uvScale is an optional vector2 used to scale UV.
  88382. * @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.
  88383. * @returns the Mesh.
  88384. */
  88385. Mesh.prototype.applyDisplacementMap = function (url, minHeight, maxHeight, onSuccess, uvOffset, uvScale, forceUpdate) {
  88386. var _this = this;
  88387. if (forceUpdate === void 0) { forceUpdate = false; }
  88388. var scene = this.getScene();
  88389. var onload = function (img) {
  88390. // Getting height map data
  88391. var canvas = document.createElement("canvas");
  88392. var context = canvas.getContext("2d");
  88393. var heightMapWidth = img.width;
  88394. var heightMapHeight = img.height;
  88395. canvas.width = heightMapWidth;
  88396. canvas.height = heightMapHeight;
  88397. context.drawImage(img, 0, 0);
  88398. // Create VertexData from map data
  88399. //Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  88400. var buffer = context.getImageData(0, 0, heightMapWidth, heightMapHeight).data;
  88401. _this.applyDisplacementMapFromBuffer(buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate);
  88402. //execute success callback, if set
  88403. if (onSuccess) {
  88404. onSuccess(_this);
  88405. }
  88406. };
  88407. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  88408. return this;
  88409. };
  88410. /**
  88411. * Modifies the mesh geometry according to a displacementMap buffer.
  88412. * 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.
  88413. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  88414. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  88415. * @param heightMapWidth is the width of the buffer image.
  88416. * @param heightMapHeight is the height of the buffer image.
  88417. * @param minHeight is the lower limit of the displacement.
  88418. * @param maxHeight is the upper limit of the displacement.
  88419. * @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.
  88420. * @param uvOffset is an optional vector2 used to offset UV.
  88421. * @param uvScale is an optional vector2 used to scale UV.
  88422. * @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.
  88423. * @returns the Mesh.
  88424. */
  88425. Mesh.prototype.applyDisplacementMapFromBuffer = function (buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate) {
  88426. if (forceUpdate === void 0) { forceUpdate = false; }
  88427. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)
  88428. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)
  88429. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind)) {
  88430. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing");
  88431. return this;
  88432. }
  88433. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, true, true);
  88434. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  88435. var uvs = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  88436. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  88437. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  88438. var uv = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  88439. uvOffset = uvOffset || _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  88440. uvScale = uvScale || new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](1, 1);
  88441. for (var index = 0; index < positions.length; index += 3) {
  88442. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(positions, index, position);
  88443. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(normals, index, normal);
  88444. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].FromArrayToRef(uvs, (index / 3) * 2, uv);
  88445. // Compute height
  88446. var u = ((Math.abs(uv.x * uvScale.x + uvOffset.x) * heightMapWidth) % heightMapWidth) | 0;
  88447. var v = ((Math.abs(uv.y * uvScale.y + uvOffset.y) * heightMapHeight) % heightMapHeight) | 0;
  88448. var pos = (u + v * heightMapWidth) * 4;
  88449. var r = buffer[pos] / 255.0;
  88450. var g = buffer[pos + 1] / 255.0;
  88451. var b = buffer[pos + 2] / 255.0;
  88452. var gradient = r * 0.3 + g * 0.59 + b * 0.11;
  88453. normal.normalize();
  88454. normal.scaleInPlace(minHeight + (maxHeight - minHeight) * gradient);
  88455. position = position.add(normal);
  88456. position.toArray(positions, index);
  88457. }
  88458. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, this.getIndices(), normals);
  88459. if (forceUpdate) {
  88460. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  88461. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  88462. }
  88463. else {
  88464. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  88465. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  88466. }
  88467. return this;
  88468. };
  88469. /**
  88470. * Modify the mesh to get a flat shading rendering.
  88471. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  88472. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  88473. * @returns current mesh
  88474. */
  88475. Mesh.prototype.convertToFlatShadedMesh = function () {
  88476. var kinds = this.getVerticesDataKinds();
  88477. var vbs = {};
  88478. var data = {};
  88479. var newdata = {};
  88480. var updatableNormals = false;
  88481. var kindIndex;
  88482. var kind;
  88483. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  88484. kind = kinds[kindIndex];
  88485. var vertexBuffer = this.getVertexBuffer(kind);
  88486. if (kind === _buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) {
  88487. updatableNormals = vertexBuffer.isUpdatable();
  88488. kinds.splice(kindIndex, 1);
  88489. kindIndex--;
  88490. continue;
  88491. }
  88492. vbs[kind] = vertexBuffer;
  88493. data[kind] = vbs[kind].getData();
  88494. newdata[kind] = [];
  88495. }
  88496. // Save previous submeshes
  88497. var previousSubmeshes = this.subMeshes.slice(0);
  88498. var indices = this.getIndices();
  88499. var totalIndices = this.getTotalIndices();
  88500. // Generating unique vertices per face
  88501. var index;
  88502. for (index = 0; index < totalIndices; index++) {
  88503. var vertexIndex = indices[index];
  88504. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  88505. kind = kinds[kindIndex];
  88506. var stride = vbs[kind].getStrideSize();
  88507. for (var offset = 0; offset < stride; offset++) {
  88508. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  88509. }
  88510. }
  88511. }
  88512. // Updating faces & normal
  88513. var normals = [];
  88514. var positions = newdata[_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  88515. for (index = 0; index < totalIndices; index += 3) {
  88516. indices[index] = index;
  88517. indices[index + 1] = index + 1;
  88518. indices[index + 2] = index + 2;
  88519. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, index * 3);
  88520. var p2 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 1) * 3);
  88521. var p3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 2) * 3);
  88522. var p1p2 = p1.subtract(p2);
  88523. var p3p2 = p3.subtract(p2);
  88524. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Cross(p1p2, p3p2));
  88525. // Store same normals for every vertex
  88526. for (var localIndex = 0; localIndex < 3; localIndex++) {
  88527. normals.push(normal.x);
  88528. normals.push(normal.y);
  88529. normals.push(normal.z);
  88530. }
  88531. }
  88532. this.setIndices(indices);
  88533. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, updatableNormals);
  88534. // Updating vertex buffers
  88535. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  88536. kind = kinds[kindIndex];
  88537. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  88538. }
  88539. // Updating submeshes
  88540. this.releaseSubMeshes();
  88541. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  88542. var previousOne = previousSubmeshes[submeshIndex];
  88543. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  88544. }
  88545. this.synchronizeInstances();
  88546. return this;
  88547. };
  88548. /**
  88549. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  88550. * In other words, more vertices, no more indices and a single bigger VBO.
  88551. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  88552. * @returns current mesh
  88553. */
  88554. Mesh.prototype.convertToUnIndexedMesh = function () {
  88555. var kinds = this.getVerticesDataKinds();
  88556. var vbs = {};
  88557. var data = {};
  88558. var newdata = {};
  88559. var kindIndex;
  88560. var kind;
  88561. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  88562. kind = kinds[kindIndex];
  88563. var vertexBuffer = this.getVertexBuffer(kind);
  88564. vbs[kind] = vertexBuffer;
  88565. data[kind] = vbs[kind].getData();
  88566. newdata[kind] = [];
  88567. }
  88568. // Save previous submeshes
  88569. var previousSubmeshes = this.subMeshes.slice(0);
  88570. var indices = this.getIndices();
  88571. var totalIndices = this.getTotalIndices();
  88572. // Generating unique vertices per face
  88573. var index;
  88574. for (index = 0; index < totalIndices; index++) {
  88575. var vertexIndex = indices[index];
  88576. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  88577. kind = kinds[kindIndex];
  88578. var stride = vbs[kind].getStrideSize();
  88579. for (var offset = 0; offset < stride; offset++) {
  88580. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  88581. }
  88582. }
  88583. }
  88584. // Updating indices
  88585. for (index = 0; index < totalIndices; index += 3) {
  88586. indices[index] = index;
  88587. indices[index + 1] = index + 1;
  88588. indices[index + 2] = index + 2;
  88589. }
  88590. this.setIndices(indices);
  88591. // Updating vertex buffers
  88592. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  88593. kind = kinds[kindIndex];
  88594. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  88595. }
  88596. // Updating submeshes
  88597. this.releaseSubMeshes();
  88598. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  88599. var previousOne = previousSubmeshes[submeshIndex];
  88600. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  88601. }
  88602. this._unIndexed = true;
  88603. this.synchronizeInstances();
  88604. return this;
  88605. };
  88606. /**
  88607. * Inverses facet orientations.
  88608. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88609. * @param flipNormals will also inverts the normals
  88610. * @returns current mesh
  88611. */
  88612. Mesh.prototype.flipFaces = function (flipNormals) {
  88613. if (flipNormals === void 0) { flipNormals = false; }
  88614. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  88615. var i;
  88616. if (flipNormals && this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) && vertex_data.normals) {
  88617. for (i = 0; i < vertex_data.normals.length; i++) {
  88618. vertex_data.normals[i] *= -1;
  88619. }
  88620. }
  88621. if (vertex_data.indices) {
  88622. var temp;
  88623. for (i = 0; i < vertex_data.indices.length; i += 3) {
  88624. // reassign indices
  88625. temp = vertex_data.indices[i + 1];
  88626. vertex_data.indices[i + 1] = vertex_data.indices[i + 2];
  88627. vertex_data.indices[i + 2] = temp;
  88628. }
  88629. }
  88630. vertex_data.applyToMesh(this);
  88631. return this;
  88632. };
  88633. /**
  88634. * Increase the number of facets and hence vertices in a mesh
  88635. * Vertex normals are interpolated from existing vertex normals
  88636. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88637. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  88638. */
  88639. Mesh.prototype.increaseVertices = function (numberPerEdge) {
  88640. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  88641. var uvs = vertex_data.uvs;
  88642. var currentIndices = vertex_data.indices;
  88643. var positions = vertex_data.positions;
  88644. var normals = vertex_data.normals;
  88645. if (currentIndices === null || positions === null || normals === null || uvs === null) {
  88646. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("VertexData contains null entries");
  88647. }
  88648. else {
  88649. var segments = numberPerEdge + 1; //segments per current facet edge, become sides of new facets
  88650. var tempIndices = new Array();
  88651. for (var i = 0; i < segments + 1; i++) {
  88652. tempIndices[i] = new Array();
  88653. }
  88654. var a; //vertex index of one end of a side
  88655. var b; //vertex index of other end of the side
  88656. var deltaPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](0, 0, 0);
  88657. var deltaNormal = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](0, 0, 0);
  88658. var deltaUV = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](0, 0);
  88659. var indices = new Array();
  88660. var vertexIndex = new Array();
  88661. var side = new Array();
  88662. var len;
  88663. var positionPtr = positions.length;
  88664. var uvPtr = uvs.length;
  88665. for (var i = 0; i < currentIndices.length; i += 3) {
  88666. vertexIndex[0] = currentIndices[i];
  88667. vertexIndex[1] = currentIndices[i + 1];
  88668. vertexIndex[2] = currentIndices[i + 2];
  88669. for (var j = 0; j < 3; j++) {
  88670. a = vertexIndex[j];
  88671. b = vertexIndex[(j + 1) % 3];
  88672. if (side[a] === undefined && side[b] === undefined) {
  88673. side[a] = new Array();
  88674. side[b] = new Array();
  88675. }
  88676. else {
  88677. if (side[a] === undefined) {
  88678. side[a] = new Array();
  88679. }
  88680. if (side[b] === undefined) {
  88681. side[b] = new Array();
  88682. }
  88683. }
  88684. if (side[a][b] === undefined && side[b][a] === undefined) {
  88685. side[a][b] = [];
  88686. deltaPosition.x = (positions[3 * b] - positions[3 * a]) / segments;
  88687. deltaPosition.y = (positions[3 * b + 1] - positions[3 * a + 1]) / segments;
  88688. deltaPosition.z = (positions[3 * b + 2] - positions[3 * a + 2]) / segments;
  88689. deltaNormal.x = (normals[3 * b] - normals[3 * a]) / segments;
  88690. deltaNormal.y = (normals[3 * b + 1] - normals[3 * a + 1]) / segments;
  88691. deltaNormal.z = (normals[3 * b + 2] - normals[3 * a + 2]) / segments;
  88692. deltaUV.x = (uvs[2 * b] - uvs[2 * a]) / segments;
  88693. deltaUV.y = (uvs[2 * b + 1] - uvs[2 * a + 1]) / segments;
  88694. side[a][b].push(a);
  88695. for (var k = 1; k < segments; k++) {
  88696. side[a][b].push(positions.length / 3);
  88697. positions[positionPtr] = positions[3 * a] + k * deltaPosition.x;
  88698. normals[positionPtr++] = normals[3 * a] + k * deltaNormal.x;
  88699. positions[positionPtr] = positions[3 * a + 1] + k * deltaPosition.y;
  88700. normals[positionPtr++] = normals[3 * a + 1] + k * deltaNormal.y;
  88701. positions[positionPtr] = positions[3 * a + 2] + k * deltaPosition.z;
  88702. normals[positionPtr++] = normals[3 * a + 2] + k * deltaNormal.z;
  88703. uvs[uvPtr++] = uvs[2 * a] + k * deltaUV.x;
  88704. uvs[uvPtr++] = uvs[2 * a + 1] + k * deltaUV.y;
  88705. }
  88706. side[a][b].push(b);
  88707. side[b][a] = new Array();
  88708. len = side[a][b].length;
  88709. for (var idx = 0; idx < len; idx++) {
  88710. side[b][a][idx] = side[a][b][len - 1 - idx];
  88711. }
  88712. }
  88713. }
  88714. //Calculate positions, normals and uvs of new internal vertices
  88715. tempIndices[0][0] = currentIndices[i];
  88716. tempIndices[1][0] = side[currentIndices[i]][currentIndices[i + 1]][1];
  88717. tempIndices[1][1] = side[currentIndices[i]][currentIndices[i + 2]][1];
  88718. for (var k = 2; k < segments; k++) {
  88719. tempIndices[k][0] = side[currentIndices[i]][currentIndices[i + 1]][k];
  88720. tempIndices[k][k] = side[currentIndices[i]][currentIndices[i + 2]][k];
  88721. deltaPosition.x = (positions[3 * tempIndices[k][k]] - positions[3 * tempIndices[k][0]]) / k;
  88722. deltaPosition.y = (positions[3 * tempIndices[k][k] + 1] - positions[3 * tempIndices[k][0] + 1]) / k;
  88723. deltaPosition.z = (positions[3 * tempIndices[k][k] + 2] - positions[3 * tempIndices[k][0] + 2]) / k;
  88724. deltaNormal.x = (normals[3 * tempIndices[k][k]] - normals[3 * tempIndices[k][0]]) / k;
  88725. deltaNormal.y = (normals[3 * tempIndices[k][k] + 1] - normals[3 * tempIndices[k][0] + 1]) / k;
  88726. deltaNormal.z = (normals[3 * tempIndices[k][k] + 2] - normals[3 * tempIndices[k][0] + 2]) / k;
  88727. deltaUV.x = (uvs[2 * tempIndices[k][k]] - uvs[2 * tempIndices[k][0]]) / k;
  88728. deltaUV.y = (uvs[2 * tempIndices[k][k] + 1] - uvs[2 * tempIndices[k][0] + 1]) / k;
  88729. for (var j = 1; j < k; j++) {
  88730. tempIndices[k][j] = positions.length / 3;
  88731. positions[positionPtr] = positions[3 * tempIndices[k][0]] + j * deltaPosition.x;
  88732. normals[positionPtr++] = normals[3 * tempIndices[k][0]] + j * deltaNormal.x;
  88733. positions[positionPtr] = positions[3 * tempIndices[k][0] + 1] + j * deltaPosition.y;
  88734. normals[positionPtr++] = normals[3 * tempIndices[k][0] + 1] + j * deltaNormal.y;
  88735. positions[positionPtr] = positions[3 * tempIndices[k][0] + 2] + j * deltaPosition.z;
  88736. normals[positionPtr++] = normals[3 * tempIndices[k][0] + 2] + j * deltaNormal.z;
  88737. uvs[uvPtr++] = uvs[2 * tempIndices[k][0]] + j * deltaUV.x;
  88738. uvs[uvPtr++] = uvs[2 * tempIndices[k][0] + 1] + j * deltaUV.y;
  88739. }
  88740. }
  88741. tempIndices[segments] = side[currentIndices[i + 1]][currentIndices[i + 2]];
  88742. // reform indices
  88743. indices.push(tempIndices[0][0], tempIndices[1][0], tempIndices[1][1]);
  88744. for (var k = 1; k < segments; k++) {
  88745. for (var j = 0; j < k; j++) {
  88746. indices.push(tempIndices[k][j], tempIndices[k + 1][j], tempIndices[k + 1][j + 1]);
  88747. indices.push(tempIndices[k][j], tempIndices[k + 1][j + 1], tempIndices[k][j + 1]);
  88748. }
  88749. indices.push(tempIndices[k][j], tempIndices[k + 1][j], tempIndices[k + 1][j + 1]);
  88750. }
  88751. }
  88752. vertex_data.indices = indices;
  88753. vertex_data.applyToMesh(this);
  88754. }
  88755. };
  88756. /**
  88757. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  88758. * This will undo any application of covertToFlatShadedMesh
  88759. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88760. */
  88761. Mesh.prototype.forceSharedVertices = function () {
  88762. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  88763. var currentUVs = vertex_data.uvs;
  88764. var currentIndices = vertex_data.indices;
  88765. var currentPositions = vertex_data.positions;
  88766. var currentNormals = vertex_data.normals;
  88767. if (currentIndices === null || currentPositions === null || currentNormals === null || currentUVs === null) {
  88768. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("VertexData contains null entries");
  88769. }
  88770. else {
  88771. var positions = new Array();
  88772. var indices = new Array();
  88773. var uvs = new Array();
  88774. var pstring = new Array(); //lists facet vertex positions (a,b,c) as string "a|b|c"
  88775. var indexPtr = 0; // pointer to next available index value
  88776. var uniquePositions = new Array(); // unique vertex positions
  88777. var ptr; // pointer to element in uniquePositions
  88778. var facet;
  88779. for (var i = 0; i < currentIndices.length; i += 3) {
  88780. facet = [currentIndices[i], currentIndices[i + 1], currentIndices[i + 2]]; //facet vertex indices
  88781. pstring = new Array();
  88782. for (var j = 0; j < 3; j++) {
  88783. pstring[j] = "";
  88784. for (var k = 0; k < 3; k++) {
  88785. //small values make 0
  88786. if (Math.abs(currentPositions[3 * facet[j] + k]) < 0.00000001) {
  88787. currentPositions[3 * facet[j] + k] = 0;
  88788. }
  88789. pstring[j] += currentPositions[3 * facet[j] + k] + "|";
  88790. }
  88791. pstring[j] = pstring[j].slice(0, -1);
  88792. }
  88793. //check facet vertices to see that none are repeated
  88794. // do not process any facet that has a repeated vertex, ie is a line
  88795. if (!(pstring[0] == pstring[1] || pstring[0] == pstring[2] || pstring[1] == pstring[2])) {
  88796. //for each facet position check if already listed in uniquePositions
  88797. // if not listed add to uniquePositions and set index pointer
  88798. // if listed use its index in uniquePositions and new index pointer
  88799. for (var j = 0; j < 3; j++) {
  88800. ptr = uniquePositions.indexOf(pstring[j]);
  88801. if (ptr < 0) {
  88802. uniquePositions.push(pstring[j]);
  88803. ptr = indexPtr++;
  88804. //not listed so add individual x, y, z coordinates to positions
  88805. for (var k = 0; k < 3; k++) {
  88806. positions.push(currentPositions[3 * facet[j] + k]);
  88807. }
  88808. for (var k = 0; k < 2; k++) {
  88809. uvs.push(currentUVs[2 * facet[j] + k]);
  88810. }
  88811. }
  88812. // add new index pointer to indices array
  88813. indices.push(ptr);
  88814. }
  88815. }
  88816. }
  88817. var normals = new Array();
  88818. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, indices, normals);
  88819. //create new vertex data object and update
  88820. vertex_data.positions = positions;
  88821. vertex_data.indices = indices;
  88822. vertex_data.normals = normals;
  88823. vertex_data.uvs = uvs;
  88824. vertex_data.applyToMesh(this);
  88825. }
  88826. };
  88827. // Instances
  88828. /** @hidden */
  88829. Mesh._instancedMeshFactory = function (name, mesh) {
  88830. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("InstancedMesh");
  88831. };
  88832. /** @hidden */
  88833. Mesh._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  88834. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("PhysicsImpostor");
  88835. };
  88836. /**
  88837. * Creates a new InstancedMesh object from the mesh model.
  88838. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88839. * @param name defines the name of the new instance
  88840. * @returns a new InstancedMesh
  88841. */
  88842. Mesh.prototype.createInstance = function (name) {
  88843. return Mesh._instancedMeshFactory(name, this);
  88844. };
  88845. /**
  88846. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  88847. * After this call, all the mesh instances have the same submeshes than the current mesh.
  88848. * @returns the current mesh
  88849. */
  88850. Mesh.prototype.synchronizeInstances = function () {
  88851. for (var instanceIndex = 0; instanceIndex < this.instances.length; instanceIndex++) {
  88852. var instance = this.instances[instanceIndex];
  88853. instance._syncSubMeshes();
  88854. }
  88855. return this;
  88856. };
  88857. /**
  88858. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  88859. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  88860. * This should be used together with the simplification to avoid disappearing triangles.
  88861. * @param successCallback an optional success callback to be called after the optimization finished.
  88862. * @returns the current mesh
  88863. */
  88864. Mesh.prototype.optimizeIndices = function (successCallback) {
  88865. var _this = this;
  88866. var indices = this.getIndices();
  88867. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  88868. if (!positions || !indices) {
  88869. return this;
  88870. }
  88871. var vectorPositions = new Array();
  88872. for (var pos = 0; pos < positions.length; pos = pos + 3) {
  88873. vectorPositions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, pos));
  88874. }
  88875. var dupes = new Array();
  88876. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["AsyncLoop"].SyncAsyncForLoop(vectorPositions.length, 40, function (iteration) {
  88877. var realPos = vectorPositions.length - 1 - iteration;
  88878. var testedPosition = vectorPositions[realPos];
  88879. for (var j = 0; j < realPos; ++j) {
  88880. var againstPosition = vectorPositions[j];
  88881. if (testedPosition.equals(againstPosition)) {
  88882. dupes[realPos] = j;
  88883. break;
  88884. }
  88885. }
  88886. }, function () {
  88887. for (var i = 0; i < indices.length; ++i) {
  88888. indices[i] = dupes[indices[i]] || indices[i];
  88889. }
  88890. //indices are now reordered
  88891. var originalSubMeshes = _this.subMeshes.slice(0);
  88892. _this.setIndices(indices);
  88893. _this.subMeshes = originalSubMeshes;
  88894. if (successCallback) {
  88895. successCallback(_this);
  88896. }
  88897. });
  88898. return this;
  88899. };
  88900. /**
  88901. * Serialize current mesh
  88902. * @param serializationObject defines the object which will receive the serialization data
  88903. */
  88904. Mesh.prototype.serialize = function (serializationObject) {
  88905. serializationObject.name = this.name;
  88906. serializationObject.id = this.id;
  88907. serializationObject.type = this.getClassName();
  88908. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(this)) {
  88909. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(this);
  88910. }
  88911. serializationObject.position = this.position.asArray();
  88912. if (this.rotationQuaternion) {
  88913. serializationObject.rotationQuaternion = this.rotationQuaternion.asArray();
  88914. }
  88915. else if (this.rotation) {
  88916. serializationObject.rotation = this.rotation.asArray();
  88917. }
  88918. serializationObject.scaling = this.scaling.asArray();
  88919. if (this._postMultiplyPivotMatrix) {
  88920. serializationObject.pivotMatrix = this.getPivotMatrix().asArray();
  88921. }
  88922. else {
  88923. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  88924. }
  88925. serializationObject.isEnabled = this.isEnabled(false);
  88926. serializationObject.isVisible = this.isVisible;
  88927. serializationObject.infiniteDistance = this.infiniteDistance;
  88928. serializationObject.pickable = this.isPickable;
  88929. serializationObject.receiveShadows = this.receiveShadows;
  88930. serializationObject.billboardMode = this.billboardMode;
  88931. serializationObject.visibility = this.visibility;
  88932. serializationObject.checkCollisions = this.checkCollisions;
  88933. serializationObject.isBlocker = this.isBlocker;
  88934. // Parent
  88935. if (this.parent) {
  88936. serializationObject.parentId = this.parent.id;
  88937. }
  88938. // Geometry
  88939. serializationObject.isUnIndexed = this.isUnIndexed;
  88940. var geometry = this._geometry;
  88941. if (geometry) {
  88942. var geometryId = geometry.id;
  88943. serializationObject.geometryId = geometryId;
  88944. // SubMeshes
  88945. serializationObject.subMeshes = [];
  88946. for (var subIndex = 0; subIndex < this.subMeshes.length; subIndex++) {
  88947. var subMesh = this.subMeshes[subIndex];
  88948. serializationObject.subMeshes.push({
  88949. materialIndex: subMesh.materialIndex,
  88950. verticesStart: subMesh.verticesStart,
  88951. verticesCount: subMesh.verticesCount,
  88952. indexStart: subMesh.indexStart,
  88953. indexCount: subMesh.indexCount
  88954. });
  88955. }
  88956. }
  88957. // Material
  88958. if (this.material) {
  88959. serializationObject.materialId = this.material.id;
  88960. }
  88961. else {
  88962. this.material = null;
  88963. }
  88964. // Morph targets
  88965. if (this.morphTargetManager) {
  88966. serializationObject.morphTargetManagerId = this.morphTargetManager.uniqueId;
  88967. }
  88968. // Skeleton
  88969. if (this.skeleton) {
  88970. serializationObject.skeletonId = this.skeleton.id;
  88971. }
  88972. // Physics
  88973. //TODO implement correct serialization for physics impostors.
  88974. var impostor = this.getPhysicsImpostor();
  88975. if (impostor) {
  88976. serializationObject.physicsMass = impostor.getParam("mass");
  88977. serializationObject.physicsFriction = impostor.getParam("friction");
  88978. serializationObject.physicsRestitution = impostor.getParam("mass");
  88979. serializationObject.physicsImpostor = impostor.type;
  88980. }
  88981. // Metadata
  88982. if (this.metadata) {
  88983. serializationObject.metadata = this.metadata;
  88984. }
  88985. // Instances
  88986. serializationObject.instances = [];
  88987. for (var index = 0; index < this.instances.length; index++) {
  88988. var instance = this.instances[index];
  88989. if (instance.doNotSerialize) {
  88990. continue;
  88991. }
  88992. var serializationInstance = {
  88993. name: instance.name,
  88994. id: instance.id,
  88995. position: instance.position.asArray(),
  88996. scaling: instance.scaling.asArray()
  88997. };
  88998. if (instance.parent) {
  88999. serializationInstance.parentId = instance.parent.id;
  89000. }
  89001. if (instance.rotationQuaternion) {
  89002. serializationInstance.rotationQuaternion = instance.rotationQuaternion.asArray();
  89003. }
  89004. else if (instance.rotation) {
  89005. serializationInstance.rotation = instance.rotation.asArray();
  89006. }
  89007. serializationObject.instances.push(serializationInstance);
  89008. // Animations
  89009. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(instance, serializationInstance);
  89010. serializationInstance.ranges = instance.serializeAnimationRanges();
  89011. }
  89012. //
  89013. // Animations
  89014. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  89015. serializationObject.ranges = this.serializeAnimationRanges();
  89016. // Layer mask
  89017. serializationObject.layerMask = this.layerMask;
  89018. // Alpha
  89019. serializationObject.alphaIndex = this.alphaIndex;
  89020. serializationObject.hasVertexAlpha = this.hasVertexAlpha;
  89021. // Overlay
  89022. serializationObject.overlayAlpha = this.overlayAlpha;
  89023. serializationObject.overlayColor = this.overlayColor.asArray();
  89024. serializationObject.renderOverlay = this.renderOverlay;
  89025. // Fog
  89026. serializationObject.applyFog = this.applyFog;
  89027. // Action Manager
  89028. if (this.actionManager) {
  89029. serializationObject.actions = this.actionManager.serialize(this.name);
  89030. }
  89031. };
  89032. /** @hidden */
  89033. Mesh.prototype._syncGeometryWithMorphTargetManager = function () {
  89034. if (!this.geometry) {
  89035. return;
  89036. }
  89037. this._markSubMeshesAsAttributesDirty();
  89038. var morphTargetManager = this._morphTargetManager;
  89039. if (morphTargetManager && morphTargetManager.vertexCount) {
  89040. if (morphTargetManager.vertexCount !== this.getTotalVertices()) {
  89041. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count.");
  89042. this.morphTargetManager = null;
  89043. return;
  89044. }
  89045. for (var index = 0; index < morphTargetManager.numInfluencers; index++) {
  89046. var morphTarget = morphTargetManager.getActiveTarget(index);
  89047. var positions = morphTarget.getPositions();
  89048. if (!positions) {
  89049. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Invalid morph target. Target must have positions.");
  89050. return;
  89051. }
  89052. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index, positions, false, 3);
  89053. var normals = morphTarget.getNormals();
  89054. if (normals) {
  89055. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index, normals, false, 3);
  89056. }
  89057. var tangents = morphTarget.getTangents();
  89058. if (tangents) {
  89059. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index, tangents, false, 3);
  89060. }
  89061. }
  89062. }
  89063. else {
  89064. var index = 0;
  89065. // Positions
  89066. while (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index)) {
  89067. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index);
  89068. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index)) {
  89069. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index);
  89070. }
  89071. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index)) {
  89072. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index);
  89073. }
  89074. index++;
  89075. }
  89076. }
  89077. };
  89078. /**
  89079. * Returns a new Mesh object parsed from the source provided.
  89080. * @param parsedMesh is the source
  89081. * @param scene defines the hosting scene
  89082. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  89083. * @returns a new Mesh
  89084. */
  89085. Mesh.Parse = function (parsedMesh, scene, rootUrl) {
  89086. var mesh;
  89087. if (parsedMesh.type && parsedMesh.type === "GroundMesh") {
  89088. mesh = Mesh._GroundMeshParser(parsedMesh, scene);
  89089. }
  89090. else {
  89091. mesh = new Mesh(parsedMesh.name, scene);
  89092. }
  89093. mesh.id = parsedMesh.id;
  89094. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  89095. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(mesh, parsedMesh.tags);
  89096. }
  89097. mesh.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.position);
  89098. if (parsedMesh.metadata !== undefined) {
  89099. mesh.metadata = parsedMesh.metadata;
  89100. }
  89101. if (parsedMesh.rotationQuaternion) {
  89102. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedMesh.rotationQuaternion);
  89103. }
  89104. else if (parsedMesh.rotation) {
  89105. mesh.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.rotation);
  89106. }
  89107. mesh.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.scaling);
  89108. if (parsedMesh.localMatrix) {
  89109. mesh.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.localMatrix));
  89110. }
  89111. else if (parsedMesh.pivotMatrix) {
  89112. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.pivotMatrix));
  89113. }
  89114. mesh.setEnabled(parsedMesh.isEnabled);
  89115. mesh.isVisible = parsedMesh.isVisible;
  89116. mesh.infiniteDistance = parsedMesh.infiniteDistance;
  89117. mesh.showBoundingBox = parsedMesh.showBoundingBox;
  89118. mesh.showSubMeshesBoundingBox = parsedMesh.showSubMeshesBoundingBox;
  89119. if (parsedMesh.applyFog !== undefined) {
  89120. mesh.applyFog = parsedMesh.applyFog;
  89121. }
  89122. if (parsedMesh.pickable !== undefined) {
  89123. mesh.isPickable = parsedMesh.pickable;
  89124. }
  89125. if (parsedMesh.alphaIndex !== undefined) {
  89126. mesh.alphaIndex = parsedMesh.alphaIndex;
  89127. }
  89128. mesh.receiveShadows = parsedMesh.receiveShadows;
  89129. mesh.billboardMode = parsedMesh.billboardMode;
  89130. if (parsedMesh.visibility !== undefined) {
  89131. mesh.visibility = parsedMesh.visibility;
  89132. }
  89133. mesh.checkCollisions = parsedMesh.checkCollisions;
  89134. if (parsedMesh.isBlocker !== undefined) {
  89135. mesh.isBlocker = parsedMesh.isBlocker;
  89136. }
  89137. mesh._shouldGenerateFlatShading = parsedMesh.useFlatShading;
  89138. // freezeWorldMatrix
  89139. if (parsedMesh.freezeWorldMatrix) {
  89140. mesh._waitingFreezeWorldMatrix = parsedMesh.freezeWorldMatrix;
  89141. }
  89142. // Parent
  89143. if (parsedMesh.parentId) {
  89144. mesh._waitingParentId = parsedMesh.parentId;
  89145. }
  89146. // Actions
  89147. if (parsedMesh.actions !== undefined) {
  89148. mesh._waitingActions = parsedMesh.actions;
  89149. }
  89150. // Overlay
  89151. if (parsedMesh.overlayAlpha !== undefined) {
  89152. mesh.overlayAlpha = parsedMesh.overlayAlpha;
  89153. }
  89154. if (parsedMesh.overlayColor !== undefined) {
  89155. mesh.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Color3"].FromArray(parsedMesh.overlayColor);
  89156. }
  89157. if (parsedMesh.renderOverlay !== undefined) {
  89158. mesh.renderOverlay = parsedMesh.renderOverlay;
  89159. }
  89160. // Geometry
  89161. mesh.isUnIndexed = !!parsedMesh.isUnIndexed;
  89162. mesh.hasVertexAlpha = parsedMesh.hasVertexAlpha;
  89163. if (parsedMesh.delayLoadingFile) {
  89164. mesh.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED;
  89165. mesh.delayLoadingFile = rootUrl + parsedMesh.delayLoadingFile;
  89166. 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));
  89167. if (parsedMesh._binaryInfo) {
  89168. mesh._binaryInfo = parsedMesh._binaryInfo;
  89169. }
  89170. mesh._delayInfo = [];
  89171. if (parsedMesh.hasUVs) {
  89172. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  89173. }
  89174. if (parsedMesh.hasUVs2) {
  89175. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  89176. }
  89177. if (parsedMesh.hasUVs3) {
  89178. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV3Kind);
  89179. }
  89180. if (parsedMesh.hasUVs4) {
  89181. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV4Kind);
  89182. }
  89183. if (parsedMesh.hasUVs5) {
  89184. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV5Kind);
  89185. }
  89186. if (parsedMesh.hasUVs6) {
  89187. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV6Kind);
  89188. }
  89189. if (parsedMesh.hasColors) {
  89190. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  89191. }
  89192. if (parsedMesh.hasMatricesIndices) {
  89193. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  89194. }
  89195. if (parsedMesh.hasMatricesWeights) {
  89196. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  89197. }
  89198. mesh._delayLoadingFunction = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry;
  89199. if (_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental) {
  89200. mesh._checkDelayState();
  89201. }
  89202. }
  89203. else {
  89204. _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry(parsedMesh, mesh);
  89205. }
  89206. // Material
  89207. if (parsedMesh.materialId) {
  89208. mesh.setMaterialByID(parsedMesh.materialId);
  89209. }
  89210. else {
  89211. mesh.material = null;
  89212. }
  89213. // Morph targets
  89214. if (parsedMesh.morphTargetManagerId > -1) {
  89215. mesh.morphTargetManager = scene.getMorphTargetManagerById(parsedMesh.morphTargetManagerId);
  89216. }
  89217. // Skeleton
  89218. if (parsedMesh.skeletonId > -1) {
  89219. mesh.skeleton = scene.getLastSkeletonByID(parsedMesh.skeletonId);
  89220. if (parsedMesh.numBoneInfluencers) {
  89221. mesh.numBoneInfluencers = parsedMesh.numBoneInfluencers;
  89222. }
  89223. }
  89224. // Animations
  89225. if (parsedMesh.animations) {
  89226. for (var animationIndex = 0; animationIndex < parsedMesh.animations.length; animationIndex++) {
  89227. var parsedAnimation = parsedMesh.animations[animationIndex];
  89228. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  89229. if (internalClass) {
  89230. mesh.animations.push(internalClass.Parse(parsedAnimation));
  89231. }
  89232. }
  89233. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(mesh, parsedMesh, scene);
  89234. }
  89235. if (parsedMesh.autoAnimate) {
  89236. scene.beginAnimation(mesh, parsedMesh.autoAnimateFrom, parsedMesh.autoAnimateTo, parsedMesh.autoAnimateLoop, parsedMesh.autoAnimateSpeed || 1.0);
  89237. }
  89238. // Layer Mask
  89239. if (parsedMesh.layerMask && (!isNaN(parsedMesh.layerMask))) {
  89240. mesh.layerMask = Math.abs(parseInt(parsedMesh.layerMask));
  89241. }
  89242. else {
  89243. mesh.layerMask = 0x0FFFFFFF;
  89244. }
  89245. // Physics
  89246. if (parsedMesh.physicsImpostor) {
  89247. Mesh._PhysicsImpostorParser(scene, mesh, parsedMesh);
  89248. }
  89249. // Instances
  89250. if (parsedMesh.instances) {
  89251. for (var index = 0; index < parsedMesh.instances.length; index++) {
  89252. var parsedInstance = parsedMesh.instances[index];
  89253. var instance = mesh.createInstance(parsedInstance.name);
  89254. if (parsedInstance.id) {
  89255. instance.id = parsedInstance.id;
  89256. }
  89257. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  89258. if (parsedInstance.tags) {
  89259. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedInstance.tags);
  89260. }
  89261. else {
  89262. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedMesh.tags);
  89263. }
  89264. }
  89265. instance.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.position);
  89266. if (parsedInstance.parentId) {
  89267. instance._waitingParentId = parsedInstance.parentId;
  89268. }
  89269. if (parsedInstance.rotationQuaternion) {
  89270. instance.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedInstance.rotationQuaternion);
  89271. }
  89272. else if (parsedInstance.rotation) {
  89273. instance.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.rotation);
  89274. }
  89275. instance.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.scaling);
  89276. if (parsedInstance.checkCollisions != undefined && parsedInstance.checkCollisions != null) {
  89277. instance.checkCollisions = parsedInstance.checkCollisions;
  89278. }
  89279. if (parsedInstance.pickable != undefined && parsedInstance.pickable != null) {
  89280. instance.isPickable = parsedInstance.pickable;
  89281. }
  89282. if (parsedInstance.showBoundingBox != undefined && parsedInstance.showBoundingBox != null) {
  89283. instance.showBoundingBox = parsedInstance.showBoundingBox;
  89284. }
  89285. if (parsedInstance.showSubMeshesBoundingBox != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  89286. instance.showSubMeshesBoundingBox = parsedInstance.showSubMeshesBoundingBox;
  89287. }
  89288. if (parsedInstance.alphaIndex != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  89289. instance.alphaIndex = parsedInstance.alphaIndex;
  89290. }
  89291. // Physics
  89292. if (parsedInstance.physicsImpostor) {
  89293. Mesh._PhysicsImpostorParser(scene, instance, parsedInstance);
  89294. }
  89295. // Animation
  89296. if (parsedInstance.animations) {
  89297. for (animationIndex = 0; animationIndex < parsedInstance.animations.length; animationIndex++) {
  89298. parsedAnimation = parsedInstance.animations[animationIndex];
  89299. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  89300. if (internalClass) {
  89301. instance.animations.push(internalClass.Parse(parsedAnimation));
  89302. }
  89303. }
  89304. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(instance, parsedInstance, scene);
  89305. if (parsedInstance.autoAnimate) {
  89306. scene.beginAnimation(instance, parsedInstance.autoAnimateFrom, parsedInstance.autoAnimateTo, parsedInstance.autoAnimateLoop, parsedInstance.autoAnimateSpeed || 1.0);
  89307. }
  89308. }
  89309. }
  89310. }
  89311. return mesh;
  89312. };
  89313. /**
  89314. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  89315. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89316. * @param name defines the name of the mesh to create
  89317. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  89318. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  89319. * @param closePath creates a seam between the first and the last points of each path of the path array
  89320. * @param offset is taken in account only if the `pathArray` is containing a single path
  89321. * @param scene defines the hosting scene
  89322. * @param updatable defines if the mesh must be flagged as updatable
  89323. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89324. * @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)
  89325. * @returns a new Mesh
  89326. */
  89327. Mesh.CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  89328. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89329. };
  89330. /**
  89331. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  89332. * @param name defines the name of the mesh to create
  89333. * @param radius sets the radius size (float) of the polygon (default 0.5)
  89334. * @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
  89335. * @param scene defines the hosting scene
  89336. * @param updatable defines if the mesh must be flagged as updatable
  89337. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89338. * @returns a new Mesh
  89339. */
  89340. Mesh.CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  89341. if (scene === void 0) { scene = null; }
  89342. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89343. };
  89344. /**
  89345. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  89346. * @param name defines the name of the mesh to create
  89347. * @param size sets the size (float) of each box side (default 1)
  89348. * @param scene defines the hosting scene
  89349. * @param updatable defines if the mesh must be flagged as updatable
  89350. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89351. * @returns a new Mesh
  89352. */
  89353. Mesh.CreateBox = function (name, size, scene, updatable, sideOrientation) {
  89354. if (scene === void 0) { scene = null; }
  89355. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89356. };
  89357. /**
  89358. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  89359. * @param name defines the name of the mesh to create
  89360. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  89361. * @param diameter sets the diameter size (float) of the sphere (default 1)
  89362. * @param scene defines the hosting scene
  89363. * @param updatable defines if the mesh must be flagged as updatable
  89364. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89365. * @returns a new Mesh
  89366. */
  89367. Mesh.CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  89368. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89369. };
  89370. /**
  89371. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  89372. * @param name defines the name of the mesh to create
  89373. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  89374. * @param diameter sets the diameter size (float) of the sphere (default 1)
  89375. * @param scene defines the hosting scene
  89376. * @returns a new Mesh
  89377. */
  89378. Mesh.CreateHemisphere = function (name, segments, diameter, scene) {
  89379. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89380. };
  89381. /**
  89382. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  89383. * @param name defines the name of the mesh to create
  89384. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  89385. * @param diameterTop set the top cap diameter (floats, default 1)
  89386. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  89387. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  89388. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  89389. * @param scene defines the hosting scene
  89390. * @param updatable defines if the mesh must be flagged as updatable
  89391. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89392. * @returns a new Mesh
  89393. */
  89394. Mesh.CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  89395. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89396. };
  89397. // Torus (Code from SharpDX.org)
  89398. /**
  89399. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  89400. * @param name defines the name of the mesh to create
  89401. * @param diameter sets the diameter size (float) of the torus (default 1)
  89402. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  89403. * @param tessellation sets the number of torus sides (postive integer, default 16)
  89404. * @param scene defines the hosting scene
  89405. * @param updatable defines if the mesh must be flagged as updatable
  89406. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89407. * @returns a new Mesh
  89408. */
  89409. Mesh.CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  89410. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89411. };
  89412. /**
  89413. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  89414. * @param name defines the name of the mesh to create
  89415. * @param radius sets the global radius size (float) of the torus knot (default 2)
  89416. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  89417. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  89418. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  89419. * @param p the number of windings on X axis (positive integers, default 2)
  89420. * @param q the number of windings on Y axis (positive integers, default 3)
  89421. * @param scene defines the hosting scene
  89422. * @param updatable defines if the mesh must be flagged as updatable
  89423. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89424. * @returns a new Mesh
  89425. */
  89426. Mesh.CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  89427. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89428. };
  89429. /**
  89430. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  89431. * @param name defines the name of the mesh to create
  89432. * @param points is an array successive Vector3
  89433. * @param scene defines the hosting scene
  89434. * @param updatable defines if the mesh must be flagged as updatable
  89435. * @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).
  89436. * @returns a new Mesh
  89437. */
  89438. Mesh.CreateLines = function (name, points, scene, updatable, instance) {
  89439. if (scene === void 0) { scene = null; }
  89440. if (updatable === void 0) { updatable = false; }
  89441. if (instance === void 0) { instance = null; }
  89442. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89443. };
  89444. /**
  89445. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  89446. * @param name defines the name of the mesh to create
  89447. * @param points is an array successive Vector3
  89448. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  89449. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  89450. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  89451. * @param scene defines the hosting scene
  89452. * @param updatable defines if the mesh must be flagged as updatable
  89453. * @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)
  89454. * @returns a new Mesh
  89455. */
  89456. Mesh.CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  89457. if (scene === void 0) { scene = null; }
  89458. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89459. };
  89460. /**
  89461. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  89462. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  89463. * 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.
  89464. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89465. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  89466. * Remember you can only change the shape positions, not their number when updating a polygon.
  89467. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  89468. * @param name defines the name of the mesh to create
  89469. * @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
  89470. * @param scene defines the hosting scene
  89471. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  89472. * @param updatable defines if the mesh must be flagged as updatable
  89473. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89474. * @param earcutInjection can be used to inject your own earcut reference
  89475. * @returns a new Mesh
  89476. */
  89477. Mesh.CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  89478. if (earcutInjection === void 0) { earcutInjection = earcut; }
  89479. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89480. };
  89481. /**
  89482. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  89483. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  89484. * @param name defines the name of the mesh to create
  89485. * @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
  89486. * @param depth defines the height of extrusion
  89487. * @param scene defines the hosting scene
  89488. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  89489. * @param updatable defines if the mesh must be flagged as updatable
  89490. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89491. * @param earcutInjection can be used to inject your own earcut reference
  89492. * @returns a new Mesh
  89493. */
  89494. Mesh.ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  89495. if (earcutInjection === void 0) { earcutInjection = earcut; }
  89496. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89497. };
  89498. /**
  89499. * Creates an extruded shape mesh.
  89500. * 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
  89501. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89502. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  89503. * @param name defines the name of the mesh to create
  89504. * @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
  89505. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  89506. * @param scale is the value to scale the shape
  89507. * @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
  89508. * @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
  89509. * @param scene defines the hosting scene
  89510. * @param updatable defines if the mesh must be flagged as updatable
  89511. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89512. * @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)
  89513. * @returns a new Mesh
  89514. */
  89515. Mesh.ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  89516. if (scene === void 0) { scene = null; }
  89517. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89518. };
  89519. /**
  89520. * Creates an custom extruded shape mesh.
  89521. * The custom extrusion is a parametric shape.
  89522. * It has no predefined shape. Its final shape will depend on the input parameters.
  89523. * Please consider using the same method from the MeshBuilder class instead
  89524. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  89525. * @param name defines the name of the mesh to create
  89526. * @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
  89527. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  89528. * @param scaleFunction is a custom Javascript function called on each path point
  89529. * @param rotationFunction is a custom Javascript function called on each path point
  89530. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  89531. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  89532. * @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
  89533. * @param scene defines the hosting scene
  89534. * @param updatable defines if the mesh must be flagged as updatable
  89535. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89536. * @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)
  89537. * @returns a new Mesh
  89538. */
  89539. Mesh.ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  89540. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89541. };
  89542. /**
  89543. * Creates lathe mesh.
  89544. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  89545. * Please consider using the same method from the MeshBuilder class instead
  89546. * @param name defines the name of the mesh to create
  89547. * @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
  89548. * @param radius is the radius value of the lathe
  89549. * @param tessellation is the side number of the lathe.
  89550. * @param scene defines the hosting scene
  89551. * @param updatable defines if the mesh must be flagged as updatable
  89552. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89553. * @returns a new Mesh
  89554. */
  89555. Mesh.CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  89556. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89557. };
  89558. /**
  89559. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  89560. * @param name defines the name of the mesh to create
  89561. * @param size sets the size (float) of both sides of the plane at once (default 1)
  89562. * @param scene defines the hosting scene
  89563. * @param updatable defines if the mesh must be flagged as updatable
  89564. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89565. * @returns a new Mesh
  89566. */
  89567. Mesh.CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  89568. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89569. };
  89570. /**
  89571. * Creates a ground mesh.
  89572. * Please consider using the same method from the MeshBuilder class instead
  89573. * @param name defines the name of the mesh to create
  89574. * @param width set the width of the ground
  89575. * @param height set the height of the ground
  89576. * @param subdivisions sets the number of subdivisions per side
  89577. * @param scene defines the hosting scene
  89578. * @param updatable defines if the mesh must be flagged as updatable
  89579. * @returns a new Mesh
  89580. */
  89581. Mesh.CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  89582. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89583. };
  89584. /**
  89585. * Creates a tiled ground mesh.
  89586. * Please consider using the same method from the MeshBuilder class instead
  89587. * @param name defines the name of the mesh to create
  89588. * @param xmin set the ground minimum X coordinate
  89589. * @param zmin set the ground minimum Y coordinate
  89590. * @param xmax set the ground maximum X coordinate
  89591. * @param zmax set the ground maximum Z coordinate
  89592. * @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
  89593. * @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
  89594. * @param scene defines the hosting scene
  89595. * @param updatable defines if the mesh must be flagged as updatable
  89596. * @returns a new Mesh
  89597. */
  89598. Mesh.CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  89599. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89600. };
  89601. /**
  89602. * Creates a ground mesh from a height map.
  89603. * Please consider using the same method from the MeshBuilder class instead
  89604. * @see http://doc.babylonjs.com/babylon101/height_map
  89605. * @param name defines the name of the mesh to create
  89606. * @param url sets the URL of the height map image resource
  89607. * @param width set the ground width size
  89608. * @param height set the ground height size
  89609. * @param subdivisions sets the number of subdivision per side
  89610. * @param minHeight is the minimum altitude on the ground
  89611. * @param maxHeight is the maximum altitude on the ground
  89612. * @param scene defines the hosting scene
  89613. * @param updatable defines if the mesh must be flagged as updatable
  89614. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  89615. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  89616. * @returns a new Mesh
  89617. */
  89618. Mesh.CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  89619. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89620. };
  89621. /**
  89622. * Creates a tube mesh.
  89623. * The tube is a parametric shape.
  89624. * It has no predefined shape. Its final shape will depend on the input parameters.
  89625. * Please consider using the same method from the MeshBuilder class instead
  89626. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89627. * @param name defines the name of the mesh to create
  89628. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  89629. * @param radius sets the tube radius size
  89630. * @param tessellation is the number of sides on the tubular surface
  89631. * @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
  89632. * @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
  89633. * @param scene defines the hosting scene
  89634. * @param updatable defines if the mesh must be flagged as updatable
  89635. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89636. * @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)
  89637. * @returns a new Mesh
  89638. */
  89639. Mesh.CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  89640. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89641. };
  89642. /**
  89643. * Creates a polyhedron mesh.
  89644. * Please consider using the same method from the MeshBuilder class instead.
  89645. * * 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
  89646. * * The parameter `size` (positive float, default 1) sets the polygon size
  89647. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  89648. * * 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`
  89649. * * 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
  89650. * * 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)`)
  89651. * * 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
  89652. * * 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
  89653. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89654. * * 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
  89655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89656. * @param name defines the name of the mesh to create
  89657. * @param options defines the options used to create the mesh
  89658. * @param scene defines the hosting scene
  89659. * @returns a new Mesh
  89660. */
  89661. Mesh.CreatePolyhedron = function (name, options, scene) {
  89662. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89663. };
  89664. /**
  89665. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  89666. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  89667. * * 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`)
  89668. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  89669. * * 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
  89670. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89671. * * 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
  89672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89673. * @param name defines the name of the mesh
  89674. * @param options defines the options used to create the mesh
  89675. * @param scene defines the hosting scene
  89676. * @returns a new Mesh
  89677. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  89678. */
  89679. Mesh.CreateIcoSphere = function (name, options, scene) {
  89680. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89681. };
  89682. /**
  89683. * Creates a decal mesh.
  89684. * Please consider using the same method from the MeshBuilder class instead.
  89685. * A decal is a mesh usually applied as a model onto the surface of another mesh
  89686. * @param name defines the name of the mesh
  89687. * @param sourceMesh defines the mesh receiving the decal
  89688. * @param position sets the position of the decal in world coordinates
  89689. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  89690. * @param size sets the decal scaling
  89691. * @param angle sets the angle to rotate the decal
  89692. * @returns a new Mesh
  89693. */
  89694. Mesh.CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  89695. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89696. };
  89697. // Skeletons
  89698. /**
  89699. * Prepare internal position array for software CPU skinning
  89700. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  89701. */
  89702. Mesh.prototype.setPositionsForCPUSkinning = function () {
  89703. if (!this._sourcePositions) {
  89704. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  89705. if (!source) {
  89706. return this._sourcePositions;
  89707. }
  89708. this._sourcePositions = new Float32Array(source);
  89709. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  89710. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, source, true);
  89711. }
  89712. }
  89713. return this._sourcePositions;
  89714. };
  89715. /**
  89716. * Prepare internal normal array for software CPU skinning
  89717. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  89718. */
  89719. Mesh.prototype.setNormalsForCPUSkinning = function () {
  89720. if (!this._sourceNormals) {
  89721. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  89722. if (!source) {
  89723. return this._sourceNormals;
  89724. }
  89725. this._sourceNormals = new Float32Array(source);
  89726. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  89727. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, source, true);
  89728. }
  89729. }
  89730. return this._sourceNormals;
  89731. };
  89732. /**
  89733. * Updates the vertex buffer by applying transformation from the bones
  89734. * @param skeleton defines the skeleton to apply to current mesh
  89735. * @returns the current mesh
  89736. */
  89737. Mesh.prototype.applySkeleton = function (skeleton) {
  89738. if (!this.geometry) {
  89739. return this;
  89740. }
  89741. if (this.geometry._softwareSkinningFrameId == this.getScene().getFrameId()) {
  89742. return this;
  89743. }
  89744. this.geometry._softwareSkinningFrameId = this.getScene().getFrameId();
  89745. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  89746. return this;
  89747. }
  89748. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  89749. return this;
  89750. }
  89751. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind)) {
  89752. return this;
  89753. }
  89754. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  89755. return this;
  89756. }
  89757. if (!this._sourcePositions) {
  89758. var submeshes = this.subMeshes.slice();
  89759. this.setPositionsForCPUSkinning();
  89760. this.subMeshes = submeshes;
  89761. }
  89762. if (!this._sourceNormals) {
  89763. this.setNormalsForCPUSkinning();
  89764. }
  89765. // positionsData checks for not being Float32Array will only pass at most once
  89766. var positionsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  89767. if (!positionsData) {
  89768. return this;
  89769. }
  89770. if (!(positionsData instanceof Float32Array)) {
  89771. positionsData = new Float32Array(positionsData);
  89772. }
  89773. // normalsData checks for not being Float32Array will only pass at most once
  89774. var normalsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  89775. if (!normalsData) {
  89776. return this;
  89777. }
  89778. if (!(normalsData instanceof Float32Array)) {
  89779. normalsData = new Float32Array(normalsData);
  89780. }
  89781. var matricesIndicesData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  89782. var matricesWeightsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  89783. if (!matricesWeightsData || !matricesIndicesData) {
  89784. return this;
  89785. }
  89786. var needExtras = this.numBoneInfluencers > 4;
  89787. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  89788. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  89789. var skeletonMatrices = skeleton.getTransformMatrices(this);
  89790. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  89791. var finalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  89792. var tempMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  89793. var matWeightIdx = 0;
  89794. var inf;
  89795. for (var index = 0; index < positionsData.length; index += 3, matWeightIdx += 4) {
  89796. var weight;
  89797. for (inf = 0; inf < 4; inf++) {
  89798. weight = matricesWeightsData[matWeightIdx + inf];
  89799. if (weight > 0) {
  89800. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  89801. finalMatrix.addToSelf(tempMatrix);
  89802. }
  89803. }
  89804. if (needExtras) {
  89805. for (inf = 0; inf < 4; inf++) {
  89806. weight = matricesWeightsExtraData[matWeightIdx + inf];
  89807. if (weight > 0) {
  89808. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  89809. finalMatrix.addToSelf(tempMatrix);
  89810. }
  89811. }
  89812. }
  89813. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinatesFromFloatsToRef(this._sourcePositions[index], this._sourcePositions[index + 1], this._sourcePositions[index + 2], finalMatrix, tempVector3);
  89814. tempVector3.toArray(positionsData, index);
  89815. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalFromFloatsToRef(this._sourceNormals[index], this._sourceNormals[index + 1], this._sourceNormals[index + 2], finalMatrix, tempVector3);
  89816. tempVector3.toArray(normalsData, index);
  89817. finalMatrix.reset();
  89818. }
  89819. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positionsData);
  89820. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normalsData);
  89821. return this;
  89822. };
  89823. // Tools
  89824. /**
  89825. * 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
  89826. * @param meshes defines the list of meshes to scan
  89827. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  89828. */
  89829. Mesh.MinMax = function (meshes) {
  89830. var minVector = null;
  89831. var maxVector = null;
  89832. meshes.forEach(function (mesh) {
  89833. var boundingInfo = mesh.getBoundingInfo();
  89834. var boundingBox = boundingInfo.boundingBox;
  89835. if (!minVector || !maxVector) {
  89836. minVector = boundingBox.minimumWorld;
  89837. maxVector = boundingBox.maximumWorld;
  89838. }
  89839. else {
  89840. minVector.minimizeInPlace(boundingBox.minimumWorld);
  89841. maxVector.maximizeInPlace(boundingBox.maximumWorld);
  89842. }
  89843. });
  89844. if (!minVector || !maxVector) {
  89845. return {
  89846. min: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero(),
  89847. max: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero()
  89848. };
  89849. }
  89850. return {
  89851. min: minVector,
  89852. max: maxVector
  89853. };
  89854. };
  89855. /**
  89856. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  89857. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  89858. * @returns a vector3
  89859. */
  89860. Mesh.Center = function (meshesOrMinMaxVector) {
  89861. var minMaxVector = (meshesOrMinMaxVector instanceof Array) ? Mesh.MinMax(meshesOrMinMaxVector) : meshesOrMinMaxVector;
  89862. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Center(minMaxVector.min, minMaxVector.max);
  89863. };
  89864. /**
  89865. * Merge the array of meshes into a single mesh for performance reasons.
  89866. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  89867. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  89868. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  89869. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  89870. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  89871. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  89872. * @returns a new mesh
  89873. */
  89874. Mesh.MergeMeshes = function (meshes, disposeSource, allow32BitsIndices, meshSubclass, subdivideWithSubMeshes, multiMultiMaterials) {
  89875. if (disposeSource === void 0) { disposeSource = true; }
  89876. var index;
  89877. if (!allow32BitsIndices) {
  89878. var totalVertices = 0;
  89879. // Counting vertices
  89880. for (index = 0; index < meshes.length; index++) {
  89881. if (meshes[index]) {
  89882. totalVertices += meshes[index].getTotalVertices();
  89883. if (totalVertices > 65536) {
  89884. _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");
  89885. return null;
  89886. }
  89887. }
  89888. }
  89889. }
  89890. if (multiMultiMaterials) {
  89891. var newMultiMaterial = null;
  89892. var subIndex;
  89893. var matIndex;
  89894. subdivideWithSubMeshes = false;
  89895. }
  89896. var materialArray = new Array();
  89897. var materialIndexArray = new Array();
  89898. // Merge
  89899. var vertexData = null;
  89900. var otherVertexData;
  89901. var indiceArray = new Array();
  89902. var source = null;
  89903. for (index = 0; index < meshes.length; index++) {
  89904. if (meshes[index]) {
  89905. var mesh = meshes[index];
  89906. var wm = mesh.computeWorldMatrix(true);
  89907. otherVertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(mesh, true, true);
  89908. otherVertexData.transform(wm);
  89909. if (vertexData) {
  89910. vertexData.merge(otherVertexData, allow32BitsIndices);
  89911. }
  89912. else {
  89913. vertexData = otherVertexData;
  89914. source = mesh;
  89915. }
  89916. if (subdivideWithSubMeshes) {
  89917. indiceArray.push(mesh.getTotalIndices());
  89918. }
  89919. if (multiMultiMaterials) {
  89920. if (mesh.material) {
  89921. var material = mesh.material;
  89922. if (material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__["MultiMaterial"]) {
  89923. for (matIndex = 0; matIndex < material.subMaterials.length; matIndex++) {
  89924. if (materialArray.indexOf(material.subMaterials[matIndex]) < 0) {
  89925. materialArray.push(material.subMaterials[matIndex]);
  89926. }
  89927. }
  89928. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  89929. materialIndexArray.push(materialArray.indexOf(material.subMaterials[mesh.subMeshes[subIndex].materialIndex]));
  89930. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  89931. }
  89932. }
  89933. else {
  89934. if (materialArray.indexOf(material) < 0) {
  89935. materialArray.push(material);
  89936. }
  89937. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  89938. materialIndexArray.push(materialArray.indexOf(material));
  89939. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  89940. }
  89941. }
  89942. }
  89943. else {
  89944. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  89945. materialIndexArray.push(0);
  89946. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  89947. }
  89948. }
  89949. }
  89950. }
  89951. }
  89952. source = source;
  89953. if (!meshSubclass) {
  89954. meshSubclass = new Mesh(source.name + "_merged", source.getScene());
  89955. }
  89956. vertexData.applyToMesh(meshSubclass);
  89957. // Setting properties
  89958. meshSubclass.checkCollisions = source.checkCollisions;
  89959. // Cleaning
  89960. if (disposeSource) {
  89961. for (index = 0; index < meshes.length; index++) {
  89962. if (meshes[index]) {
  89963. meshes[index].dispose();
  89964. }
  89965. }
  89966. }
  89967. // Subdivide
  89968. if (subdivideWithSubMeshes || multiMultiMaterials) {
  89969. //-- removal of global submesh
  89970. meshSubclass.releaseSubMeshes();
  89971. index = 0;
  89972. var offset = 0;
  89973. //-- apply subdivision according to index table
  89974. while (index < indiceArray.length) {
  89975. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, indiceArray[index], meshSubclass);
  89976. offset += indiceArray[index];
  89977. index++;
  89978. }
  89979. }
  89980. if (multiMultiMaterials) {
  89981. newMultiMaterial = new _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__["MultiMaterial"](source.name + "_merged", source.getScene());
  89982. newMultiMaterial.subMaterials = materialArray;
  89983. for (subIndex = 0; subIndex < meshSubclass.subMeshes.length; subIndex++) {
  89984. meshSubclass.subMeshes[subIndex].materialIndex = materialIndexArray[subIndex];
  89985. }
  89986. meshSubclass.material = newMultiMaterial;
  89987. }
  89988. else {
  89989. meshSubclass.material = source.material;
  89990. }
  89991. return meshSubclass;
  89992. };
  89993. /** @hidden */
  89994. Mesh.prototype.addInstance = function (instance) {
  89995. instance._indexInSourceMeshInstanceArray = this.instances.length;
  89996. this.instances.push(instance);
  89997. };
  89998. /** @hidden */
  89999. Mesh.prototype.removeInstance = function (instance) {
  90000. // Remove from mesh
  90001. var index = instance._indexInSourceMeshInstanceArray;
  90002. if (index != -1) {
  90003. if (index !== this.instances.length - 1) {
  90004. var last = this.instances[this.instances.length - 1];
  90005. this.instances[index] = last;
  90006. last._indexInSourceMeshInstanceArray = index;
  90007. }
  90008. instance._indexInSourceMeshInstanceArray = -1;
  90009. this.instances.pop();
  90010. }
  90011. };
  90012. // Consts
  90013. /**
  90014. * Mesh side orientation : usually the external or front surface
  90015. */
  90016. Mesh.FRONTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].FRONTSIDE;
  90017. /**
  90018. * Mesh side orientation : usually the internal or back surface
  90019. */
  90020. Mesh.BACKSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].BACKSIDE;
  90021. /**
  90022. * Mesh side orientation : both internal and external or front and back surfaces
  90023. */
  90024. Mesh.DOUBLESIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DOUBLESIDE;
  90025. /**
  90026. * Mesh side orientation : by default, `FRONTSIDE`
  90027. */
  90028. Mesh.DEFAULTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DEFAULTSIDE;
  90029. /**
  90030. * Mesh cap setting : no cap
  90031. */
  90032. Mesh.NO_CAP = 0;
  90033. /**
  90034. * Mesh cap setting : one cap at the beginning of the mesh
  90035. */
  90036. Mesh.CAP_START = 1;
  90037. /**
  90038. * Mesh cap setting : one cap at the end of the mesh
  90039. */
  90040. Mesh.CAP_END = 2;
  90041. /**
  90042. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  90043. */
  90044. Mesh.CAP_ALL = 3;
  90045. // Statics
  90046. /** @hidden */
  90047. Mesh._GroundMeshParser = function (parsedMesh, scene) {
  90048. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("GroundMesh");
  90049. };
  90050. return Mesh;
  90051. }(_abstractMesh__WEBPACK_IMPORTED_MODULE_10__["AbstractMesh"]));
  90052. /***/ }),
  90053. /***/ "./Meshes/mesh.vertexData.ts":
  90054. /*!***********************************!*\
  90055. !*** ./Meshes/mesh.vertexData.ts ***!
  90056. \***********************************/
  90057. /*! exports provided: VertexData */
  90058. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90059. "use strict";
  90060. __webpack_require__.r(__webpack_exports__);
  90061. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return VertexData; });
  90062. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  90063. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  90064. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  90065. /**
  90066. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  90067. */
  90068. var VertexData = /** @class */ (function () {
  90069. function VertexData() {
  90070. }
  90071. /**
  90072. * Uses the passed data array to set the set the values for the specified kind of data
  90073. * @param data a linear array of floating numbers
  90074. * @param kind the type of data that is being set, eg positions, colors etc
  90075. */
  90076. VertexData.prototype.set = function (data, kind) {
  90077. switch (kind) {
  90078. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind:
  90079. this.positions = data;
  90080. break;
  90081. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind:
  90082. this.normals = data;
  90083. break;
  90084. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind:
  90085. this.tangents = data;
  90086. break;
  90087. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind:
  90088. this.uvs = data;
  90089. break;
  90090. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind:
  90091. this.uvs2 = data;
  90092. break;
  90093. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind:
  90094. this.uvs3 = data;
  90095. break;
  90096. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind:
  90097. this.uvs4 = data;
  90098. break;
  90099. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind:
  90100. this.uvs5 = data;
  90101. break;
  90102. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind:
  90103. this.uvs6 = data;
  90104. break;
  90105. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind:
  90106. this.colors = data;
  90107. break;
  90108. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind:
  90109. this.matricesIndices = data;
  90110. break;
  90111. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind:
  90112. this.matricesWeights = data;
  90113. break;
  90114. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind:
  90115. this.matricesIndicesExtra = data;
  90116. break;
  90117. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind:
  90118. this.matricesWeightsExtra = data;
  90119. break;
  90120. }
  90121. };
  90122. /**
  90123. * Associates the vertexData to the passed Mesh.
  90124. * Sets it as updatable or not (default `false`)
  90125. * @param mesh the mesh the vertexData is applied to
  90126. * @param updatable when used and having the value true allows new data to update the vertexData
  90127. * @returns the VertexData
  90128. */
  90129. VertexData.prototype.applyToMesh = function (mesh, updatable) {
  90130. this._applyTo(mesh, updatable);
  90131. return this;
  90132. };
  90133. /**
  90134. * Associates the vertexData to the passed Geometry.
  90135. * Sets it as updatable or not (default `false`)
  90136. * @param geometry the geometry the vertexData is applied to
  90137. * @param updatable when used and having the value true allows new data to update the vertexData
  90138. * @returns VertexData
  90139. */
  90140. VertexData.prototype.applyToGeometry = function (geometry, updatable) {
  90141. this._applyTo(geometry, updatable);
  90142. return this;
  90143. };
  90144. /**
  90145. * Updates the associated mesh
  90146. * @param mesh the mesh to be updated
  90147. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  90148. * @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
  90149. * @returns VertexData
  90150. */
  90151. VertexData.prototype.updateMesh = function (mesh) {
  90152. this._update(mesh);
  90153. return this;
  90154. };
  90155. /**
  90156. * Updates the associated geometry
  90157. * @param geometry the geometry to be updated
  90158. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  90159. * @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
  90160. * @returns VertexData.
  90161. */
  90162. VertexData.prototype.updateGeometry = function (geometry) {
  90163. this._update(geometry);
  90164. return this;
  90165. };
  90166. VertexData.prototype._applyTo = function (meshOrGeometry, updatable) {
  90167. if (updatable === void 0) { updatable = false; }
  90168. if (this.positions) {
  90169. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updatable);
  90170. }
  90171. if (this.normals) {
  90172. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updatable);
  90173. }
  90174. if (this.tangents) {
  90175. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updatable);
  90176. }
  90177. if (this.uvs) {
  90178. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updatable);
  90179. }
  90180. if (this.uvs2) {
  90181. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updatable);
  90182. }
  90183. if (this.uvs3) {
  90184. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updatable);
  90185. }
  90186. if (this.uvs4) {
  90187. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updatable);
  90188. }
  90189. if (this.uvs5) {
  90190. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updatable);
  90191. }
  90192. if (this.uvs6) {
  90193. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updatable);
  90194. }
  90195. if (this.colors) {
  90196. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updatable);
  90197. }
  90198. if (this.matricesIndices) {
  90199. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updatable);
  90200. }
  90201. if (this.matricesWeights) {
  90202. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updatable);
  90203. }
  90204. if (this.matricesIndicesExtra) {
  90205. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updatable);
  90206. }
  90207. if (this.matricesWeightsExtra) {
  90208. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updatable);
  90209. }
  90210. if (this.indices) {
  90211. meshOrGeometry.setIndices(this.indices, null, updatable);
  90212. }
  90213. else {
  90214. meshOrGeometry.setIndices([], null);
  90215. }
  90216. return this;
  90217. };
  90218. VertexData.prototype._update = function (meshOrGeometry, updateExtends, makeItUnique) {
  90219. if (this.positions) {
  90220. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updateExtends, makeItUnique);
  90221. }
  90222. if (this.normals) {
  90223. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updateExtends, makeItUnique);
  90224. }
  90225. if (this.tangents) {
  90226. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updateExtends, makeItUnique);
  90227. }
  90228. if (this.uvs) {
  90229. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updateExtends, makeItUnique);
  90230. }
  90231. if (this.uvs2) {
  90232. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updateExtends, makeItUnique);
  90233. }
  90234. if (this.uvs3) {
  90235. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updateExtends, makeItUnique);
  90236. }
  90237. if (this.uvs4) {
  90238. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updateExtends, makeItUnique);
  90239. }
  90240. if (this.uvs5) {
  90241. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updateExtends, makeItUnique);
  90242. }
  90243. if (this.uvs6) {
  90244. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updateExtends, makeItUnique);
  90245. }
  90246. if (this.colors) {
  90247. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updateExtends, makeItUnique);
  90248. }
  90249. if (this.matricesIndices) {
  90250. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updateExtends, makeItUnique);
  90251. }
  90252. if (this.matricesWeights) {
  90253. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updateExtends, makeItUnique);
  90254. }
  90255. if (this.matricesIndicesExtra) {
  90256. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updateExtends, makeItUnique);
  90257. }
  90258. if (this.matricesWeightsExtra) {
  90259. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updateExtends, makeItUnique);
  90260. }
  90261. if (this.indices) {
  90262. meshOrGeometry.setIndices(this.indices, null);
  90263. }
  90264. return this;
  90265. };
  90266. /**
  90267. * Transforms each position and each normal of the vertexData according to the passed Matrix
  90268. * @param matrix the transforming matrix
  90269. * @returns the VertexData
  90270. */
  90271. VertexData.prototype.transform = function (matrix) {
  90272. var flip = matrix.m[0] * matrix.m[5] * matrix.m[10] < 0;
  90273. var transformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  90274. var index;
  90275. if (this.positions) {
  90276. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  90277. for (index = 0; index < this.positions.length; index += 3) {
  90278. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.positions, index, position);
  90279. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(position, matrix, transformed);
  90280. this.positions[index] = transformed.x;
  90281. this.positions[index + 1] = transformed.y;
  90282. this.positions[index + 2] = transformed.z;
  90283. }
  90284. }
  90285. if (this.normals) {
  90286. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  90287. for (index = 0; index < this.normals.length; index += 3) {
  90288. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.normals, index, normal);
  90289. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(normal, matrix, transformed);
  90290. this.normals[index] = transformed.x;
  90291. this.normals[index + 1] = transformed.y;
  90292. this.normals[index + 2] = transformed.z;
  90293. }
  90294. }
  90295. if (this.tangents) {
  90296. var tangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  90297. var tangentTransformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  90298. for (index = 0; index < this.tangents.length; index += 4) {
  90299. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].FromArrayToRef(this.tangents, index, tangent);
  90300. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].TransformNormalToRef(tangent, matrix, tangentTransformed);
  90301. this.tangents[index] = tangentTransformed.x;
  90302. this.tangents[index + 1] = tangentTransformed.y;
  90303. this.tangents[index + 2] = tangentTransformed.z;
  90304. this.tangents[index + 3] = tangentTransformed.w;
  90305. }
  90306. }
  90307. if (flip && this.indices) {
  90308. for (index = 0; index < this.indices.length; index += 3) {
  90309. var tmp = this.indices[index + 1];
  90310. this.indices[index + 1] = this.indices[index + 2];
  90311. this.indices[index + 2] = tmp;
  90312. }
  90313. }
  90314. return this;
  90315. };
  90316. /**
  90317. * Merges the passed VertexData into the current one
  90318. * @param other the VertexData to be merged into the current one
  90319. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  90320. * @returns the modified VertexData
  90321. */
  90322. VertexData.prototype.merge = function (other, use32BitsIndices) {
  90323. if (use32BitsIndices === void 0) { use32BitsIndices = false; }
  90324. this._validate();
  90325. other._validate();
  90326. if (!this.normals !== !other.normals ||
  90327. !this.tangents !== !other.tangents ||
  90328. !this.uvs !== !other.uvs ||
  90329. !this.uvs2 !== !other.uvs2 ||
  90330. !this.uvs3 !== !other.uvs3 ||
  90331. !this.uvs4 !== !other.uvs4 ||
  90332. !this.uvs5 !== !other.uvs5 ||
  90333. !this.uvs6 !== !other.uvs6 ||
  90334. !this.colors !== !other.colors ||
  90335. !this.matricesIndices !== !other.matricesIndices ||
  90336. !this.matricesWeights !== !other.matricesWeights ||
  90337. !this.matricesIndicesExtra !== !other.matricesIndicesExtra ||
  90338. !this.matricesWeightsExtra !== !other.matricesWeightsExtra) {
  90339. throw new Error("Cannot merge vertex data that do not have the same set of attributes");
  90340. }
  90341. if (other.indices) {
  90342. if (!this.indices) {
  90343. this.indices = [];
  90344. }
  90345. var offset = this.positions ? this.positions.length / 3 : 0;
  90346. var isSrcTypedArray = this.indices.BYTES_PER_ELEMENT !== undefined;
  90347. if (isSrcTypedArray) {
  90348. var len = this.indices.length + other.indices.length;
  90349. var temp = use32BitsIndices || this.indices instanceof Uint32Array ? new Uint32Array(len) : new Uint16Array(len);
  90350. temp.set(this.indices);
  90351. var decal = this.indices.length;
  90352. for (var index = 0; index < other.indices.length; index++) {
  90353. temp[decal + index] = other.indices[index] + offset;
  90354. }
  90355. this.indices = temp;
  90356. }
  90357. else {
  90358. for (var index = 0; index < other.indices.length; index++) {
  90359. this.indices.push(other.indices[index] + offset);
  90360. }
  90361. }
  90362. }
  90363. this.positions = this._mergeElement(this.positions, other.positions);
  90364. this.normals = this._mergeElement(this.normals, other.normals);
  90365. this.tangents = this._mergeElement(this.tangents, other.tangents);
  90366. this.uvs = this._mergeElement(this.uvs, other.uvs);
  90367. this.uvs2 = this._mergeElement(this.uvs2, other.uvs2);
  90368. this.uvs3 = this._mergeElement(this.uvs3, other.uvs3);
  90369. this.uvs4 = this._mergeElement(this.uvs4, other.uvs4);
  90370. this.uvs5 = this._mergeElement(this.uvs5, other.uvs5);
  90371. this.uvs6 = this._mergeElement(this.uvs6, other.uvs6);
  90372. this.colors = this._mergeElement(this.colors, other.colors);
  90373. this.matricesIndices = this._mergeElement(this.matricesIndices, other.matricesIndices);
  90374. this.matricesWeights = this._mergeElement(this.matricesWeights, other.matricesWeights);
  90375. this.matricesIndicesExtra = this._mergeElement(this.matricesIndicesExtra, other.matricesIndicesExtra);
  90376. this.matricesWeightsExtra = this._mergeElement(this.matricesWeightsExtra, other.matricesWeightsExtra);
  90377. return this;
  90378. };
  90379. VertexData.prototype._mergeElement = function (source, other) {
  90380. if (!source) {
  90381. return other;
  90382. }
  90383. if (!other) {
  90384. return source;
  90385. }
  90386. var len = other.length + source.length;
  90387. var isSrcTypedArray = source instanceof Float32Array;
  90388. var isOthTypedArray = other instanceof Float32Array;
  90389. // use non-loop method when the source is Float32Array
  90390. if (isSrcTypedArray) {
  90391. var ret32 = new Float32Array(len);
  90392. ret32.set(source);
  90393. ret32.set(other, source.length);
  90394. return ret32;
  90395. // source is number[], when other is also use concat
  90396. }
  90397. else if (!isOthTypedArray) {
  90398. return source.concat(other);
  90399. // source is a number[], but other is a Float32Array, loop required
  90400. }
  90401. else {
  90402. var ret = source.slice(0); // copy source to a separate array
  90403. for (var i = 0, len = other.length; i < len; i++) {
  90404. ret.push(other[i]);
  90405. }
  90406. return ret;
  90407. }
  90408. };
  90409. VertexData.prototype._validate = function () {
  90410. if (!this.positions) {
  90411. throw new Error("Positions are required");
  90412. }
  90413. var getElementCount = function (kind, values) {
  90414. var stride = _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].DeduceStride(kind);
  90415. if ((values.length % stride) !== 0) {
  90416. throw new Error("The " + kind + "s array count must be a multiple of " + stride);
  90417. }
  90418. return values.length / stride;
  90419. };
  90420. var positionsElementCount = getElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions);
  90421. var validateElementCount = function (kind, values) {
  90422. var elementCount = getElementCount(kind, values);
  90423. if (elementCount !== positionsElementCount) {
  90424. throw new Error("The " + kind + "s element count (" + elementCount + ") does not match the positions count (" + positionsElementCount + ")");
  90425. }
  90426. };
  90427. if (this.normals) {
  90428. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals);
  90429. }
  90430. if (this.tangents) {
  90431. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents);
  90432. }
  90433. if (this.uvs) {
  90434. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs);
  90435. }
  90436. if (this.uvs2) {
  90437. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2);
  90438. }
  90439. if (this.uvs3) {
  90440. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3);
  90441. }
  90442. if (this.uvs4) {
  90443. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4);
  90444. }
  90445. if (this.uvs5) {
  90446. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5);
  90447. }
  90448. if (this.uvs6) {
  90449. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6);
  90450. }
  90451. if (this.colors) {
  90452. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors);
  90453. }
  90454. if (this.matricesIndices) {
  90455. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices);
  90456. }
  90457. if (this.matricesWeights) {
  90458. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights);
  90459. }
  90460. if (this.matricesIndicesExtra) {
  90461. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra);
  90462. }
  90463. if (this.matricesWeightsExtra) {
  90464. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra);
  90465. }
  90466. };
  90467. /**
  90468. * Serializes the VertexData
  90469. * @returns a serialized object
  90470. */
  90471. VertexData.prototype.serialize = function () {
  90472. var serializationObject = this.serialize();
  90473. if (this.positions) {
  90474. serializationObject.positions = this.positions;
  90475. }
  90476. if (this.normals) {
  90477. serializationObject.normals = this.normals;
  90478. }
  90479. if (this.tangents) {
  90480. serializationObject.tangents = this.tangents;
  90481. }
  90482. if (this.uvs) {
  90483. serializationObject.uvs = this.uvs;
  90484. }
  90485. if (this.uvs2) {
  90486. serializationObject.uvs2 = this.uvs2;
  90487. }
  90488. if (this.uvs3) {
  90489. serializationObject.uvs3 = this.uvs3;
  90490. }
  90491. if (this.uvs4) {
  90492. serializationObject.uvs4 = this.uvs4;
  90493. }
  90494. if (this.uvs5) {
  90495. serializationObject.uvs5 = this.uvs5;
  90496. }
  90497. if (this.uvs6) {
  90498. serializationObject.uvs6 = this.uvs6;
  90499. }
  90500. if (this.colors) {
  90501. serializationObject.colors = this.colors;
  90502. }
  90503. if (this.matricesIndices) {
  90504. serializationObject.matricesIndices = this.matricesIndices;
  90505. serializationObject.matricesIndices._isExpanded = true;
  90506. }
  90507. if (this.matricesWeights) {
  90508. serializationObject.matricesWeights = this.matricesWeights;
  90509. }
  90510. if (this.matricesIndicesExtra) {
  90511. serializationObject.matricesIndicesExtra = this.matricesIndicesExtra;
  90512. serializationObject.matricesIndicesExtra._isExpanded = true;
  90513. }
  90514. if (this.matricesWeightsExtra) {
  90515. serializationObject.matricesWeightsExtra = this.matricesWeightsExtra;
  90516. }
  90517. serializationObject.indices = this.indices;
  90518. return serializationObject;
  90519. };
  90520. // Statics
  90521. /**
  90522. * Extracts the vertexData from a mesh
  90523. * @param mesh the mesh from which to extract the VertexData
  90524. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  90525. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  90526. * @returns the object VertexData associated to the passed mesh
  90527. */
  90528. VertexData.ExtractFromMesh = function (mesh, copyWhenShared, forceCopy) {
  90529. return VertexData._ExtractFrom(mesh, copyWhenShared, forceCopy);
  90530. };
  90531. /**
  90532. * Extracts the vertexData from the geometry
  90533. * @param geometry the geometry from which to extract the VertexData
  90534. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  90535. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  90536. * @returns the object VertexData associated to the passed mesh
  90537. */
  90538. VertexData.ExtractFromGeometry = function (geometry, copyWhenShared, forceCopy) {
  90539. return VertexData._ExtractFrom(geometry, copyWhenShared, forceCopy);
  90540. };
  90541. VertexData._ExtractFrom = function (meshOrGeometry, copyWhenShared, forceCopy) {
  90542. var result = new VertexData();
  90543. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind)) {
  90544. result.positions = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, copyWhenShared, forceCopy);
  90545. }
  90546. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  90547. result.normals = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, copyWhenShared, forceCopy);
  90548. }
  90549. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind)) {
  90550. result.tangents = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, copyWhenShared, forceCopy);
  90551. }
  90552. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  90553. result.uvs = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, copyWhenShared, forceCopy);
  90554. }
  90555. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  90556. result.uvs2 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, copyWhenShared, forceCopy);
  90557. }
  90558. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind)) {
  90559. result.uvs3 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, copyWhenShared, forceCopy);
  90560. }
  90561. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind)) {
  90562. result.uvs4 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, copyWhenShared, forceCopy);
  90563. }
  90564. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind)) {
  90565. result.uvs5 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, copyWhenShared, forceCopy);
  90566. }
  90567. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind)) {
  90568. result.uvs6 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, copyWhenShared, forceCopy);
  90569. }
  90570. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind)) {
  90571. result.colors = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, copyWhenShared, forceCopy);
  90572. }
  90573. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind)) {
  90574. result.matricesIndices = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, copyWhenShared, forceCopy);
  90575. }
  90576. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind)) {
  90577. result.matricesWeights = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, copyWhenShared, forceCopy);
  90578. }
  90579. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind)) {
  90580. result.matricesIndicesExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, copyWhenShared, forceCopy);
  90581. }
  90582. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind)) {
  90583. result.matricesWeightsExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, copyWhenShared, forceCopy);
  90584. }
  90585. result.indices = meshOrGeometry.getIndices(copyWhenShared, forceCopy);
  90586. return result;
  90587. };
  90588. /**
  90589. * Creates the VertexData for a Ribbon
  90590. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  90591. * * pathArray array of paths, each of which an array of successive Vector3
  90592. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  90593. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  90594. * * 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
  90595. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90596. * * 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)
  90597. * * 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)
  90598. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  90599. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  90600. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  90601. * @returns the VertexData of the ribbon
  90602. */
  90603. VertexData.CreateRibbon = function (options) {
  90604. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ribbonBuilder");
  90605. };
  90606. /**
  90607. * Creates the VertexData for a box
  90608. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90609. * * size sets the width, height and depth of the box to the value of size, optional default 1
  90610. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  90611. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  90612. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  90613. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  90614. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  90615. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90616. * * 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)
  90617. * * 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)
  90618. * @returns the VertexData of the box
  90619. */
  90620. VertexData.CreateBox = function (options) {
  90621. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("boxBuilder");
  90622. };
  90623. /**
  90624. * Creates the VertexData for an ellipsoid, defaults to a sphere
  90625. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90626. * * segments sets the number of horizontal strips optional, default 32
  90627. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  90628. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  90629. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  90630. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  90631. * * 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
  90632. * * 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
  90633. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90634. * * 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)
  90635. * * 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)
  90636. * @returns the VertexData of the ellipsoid
  90637. */
  90638. VertexData.CreateSphere = function (options) {
  90639. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("sphereBuilder");
  90640. };
  90641. /**
  90642. * Creates the VertexData for a cylinder, cone or prism
  90643. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90644. * * height sets the height (y direction) of the cylinder, optional, default 2
  90645. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  90646. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  90647. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  90648. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90649. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  90650. * * 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
  90651. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90652. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90653. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  90654. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  90655. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90656. * * 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)
  90657. * * 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)
  90658. * @returns the VertexData of the cylinder, cone or prism
  90659. */
  90660. VertexData.CreateCylinder = function (options) {
  90661. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("cylinderBuilder");
  90662. };
  90663. /**
  90664. * Creates the VertexData for a torus
  90665. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90666. * * diameter the diameter of the torus, optional default 1
  90667. * * thickness the diameter of the tube forming the torus, optional default 0.5
  90668. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90669. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90670. * * 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)
  90671. * * 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)
  90672. * @returns the VertexData of the torus
  90673. */
  90674. VertexData.CreateTorus = function (options) {
  90675. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusBuilder");
  90676. };
  90677. /**
  90678. * Creates the VertexData of the LineSystem
  90679. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  90680. * - lines an array of lines, each line being an array of successive Vector3
  90681. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  90682. * @returns the VertexData of the LineSystem
  90683. */
  90684. VertexData.CreateLineSystem = function (options) {
  90685. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  90686. };
  90687. /**
  90688. * Create the VertexData for a DashedLines
  90689. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  90690. * - points an array successive Vector3
  90691. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  90692. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  90693. * - dashNb the intended total number of dashes, optional, default 200
  90694. * @returns the VertexData for the DashedLines
  90695. */
  90696. VertexData.CreateDashedLines = function (options) {
  90697. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  90698. };
  90699. /**
  90700. * Creates the VertexData for a Ground
  90701. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  90702. * - width the width (x direction) of the ground, optional, default 1
  90703. * - height the height (z direction) of the ground, optional, default 1
  90704. * - subdivisions the number of subdivisions per side, optional, default 1
  90705. * @returns the VertexData of the Ground
  90706. */
  90707. VertexData.CreateGround = function (options) {
  90708. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  90709. };
  90710. /**
  90711. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  90712. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  90713. * * xmin the ground minimum X coordinate, optional, default -1
  90714. * * zmin the ground minimum Z coordinate, optional, default -1
  90715. * * xmax the ground maximum X coordinate, optional, default 1
  90716. * * zmax the ground maximum Z coordinate, optional, default 1
  90717. * * 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}
  90718. * * 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}
  90719. * @returns the VertexData of the TiledGround
  90720. */
  90721. VertexData.CreateTiledGround = function (options) {
  90722. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  90723. };
  90724. /**
  90725. * Creates the VertexData of the Ground designed from a heightmap
  90726. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  90727. * * width the width (x direction) of the ground
  90728. * * height the height (z direction) of the ground
  90729. * * subdivisions the number of subdivisions per side
  90730. * * minHeight the minimum altitude on the ground, optional, default 0
  90731. * * maxHeight the maximum altitude on the ground, optional default 1
  90732. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  90733. * * buffer the array holding the image color data
  90734. * * bufferWidth the width of image
  90735. * * bufferHeight the height of image
  90736. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  90737. * @returns the VertexData of the Ground designed from a heightmap
  90738. */
  90739. VertexData.CreateGroundFromHeightMap = function (options) {
  90740. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  90741. };
  90742. /**
  90743. * Creates the VertexData for a Plane
  90744. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  90745. * * size sets the width and height of the plane to the value of size, optional default 1
  90746. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  90747. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  90748. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90749. * * 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)
  90750. * * 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)
  90751. * @returns the VertexData of the box
  90752. */
  90753. VertexData.CreatePlane = function (options) {
  90754. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("planeBuilder");
  90755. };
  90756. /**
  90757. * Creates the VertexData of the Disc or regular Polygon
  90758. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  90759. * * radius the radius of the disc, optional default 0.5
  90760. * * tessellation the number of polygon sides, optional, default 64
  90761. * * 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
  90762. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90763. * * 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)
  90764. * * 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)
  90765. * @returns the VertexData of the box
  90766. */
  90767. VertexData.CreateDisc = function (options) {
  90768. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("discBuilder");
  90769. };
  90770. /**
  90771. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  90772. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  90773. * @param polygon a mesh built from polygonTriangulation.build()
  90774. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90775. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90776. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90777. * @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)
  90778. * @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)
  90779. * @returns the VertexData of the Polygon
  90780. */
  90781. VertexData.CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  90782. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polygonBuilder");
  90783. };
  90784. /**
  90785. * Creates the VertexData of the IcoSphere
  90786. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  90787. * * radius the radius of the IcoSphere, optional default 1
  90788. * * radiusX allows stretching in the x direction, optional, default radius
  90789. * * radiusY allows stretching in the y direction, optional, default radius
  90790. * * radiusZ allows stretching in the z direction, optional, default radius
  90791. * * flat when true creates a flat shaded mesh, optional, default true
  90792. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90793. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90794. * * 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)
  90795. * * 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)
  90796. * @returns the VertexData of the IcoSphere
  90797. */
  90798. VertexData.CreateIcoSphere = function (options) {
  90799. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("icoSphereBuilder");
  90800. };
  90801. // inspired from // http://stemkoski.github.io/Three.js/Polyhedra.html
  90802. /**
  90803. * Creates the VertexData for a Polyhedron
  90804. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  90805. * * type provided types are:
  90806. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  90807. * * 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)
  90808. * * size the size of the IcoSphere, optional default 1
  90809. * * sizeX allows stretching in the x direction, optional, default size
  90810. * * sizeY allows stretching in the y direction, optional, default size
  90811. * * sizeZ allows stretching in the z direction, optional, default size
  90812. * * 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
  90813. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90814. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90815. * * flat when true creates a flat shaded mesh, optional, default true
  90816. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90817. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90818. * * 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)
  90819. * * 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)
  90820. * @returns the VertexData of the Polyhedron
  90821. */
  90822. VertexData.CreatePolyhedron = function (options) {
  90823. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polyhedronBuilder");
  90824. };
  90825. // based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/away3d/primitives/TorusKnot.as?spec=svn2473&r=2473
  90826. /**
  90827. * Creates the VertexData for a TorusKnot
  90828. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  90829. * * radius the radius of the torus knot, optional, default 2
  90830. * * tube the thickness of the tube, optional, default 0.5
  90831. * * radialSegments the number of sides on each tube segments, optional, default 32
  90832. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  90833. * * p the number of windings around the z axis, optional, default 2
  90834. * * q the number of windings around the x axis, optional, default 3
  90835. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90836. * * 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)
  90837. * * 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)
  90838. * @returns the VertexData of the Torus Knot
  90839. */
  90840. VertexData.CreateTorusKnot = function (options) {
  90841. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusKnotBuilder");
  90842. };
  90843. // Tools
  90844. /**
  90845. * Compute normals for given positions and indices
  90846. * @param positions an array of vertex positions, [...., x, y, z, ......]
  90847. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  90848. * @param normals an array of vertex normals, [...., x, y, z, ......]
  90849. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  90850. * * facetNormals : optional array of facet normals (vector3)
  90851. * * facetPositions : optional array of facet positions (vector3)
  90852. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  90853. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  90854. * * bInfo : optional bounding info, required for facetPartitioning computation
  90855. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  90856. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  90857. * * useRightHandedSystem: optional boolean to for right handed system computation
  90858. * * depthSort : optional boolean to enable the facet depth sort computation
  90859. * * distanceTo : optional Vector3 to compute the facet depth from this location
  90860. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  90861. */
  90862. VertexData.ComputeNormals = function (positions, indices, normals, options) {
  90863. // temporary scalar variables
  90864. var index = 0; // facet index
  90865. var p1p2x = 0.0; // p1p2 vector x coordinate
  90866. var p1p2y = 0.0; // p1p2 vector y coordinate
  90867. var p1p2z = 0.0; // p1p2 vector z coordinate
  90868. var p3p2x = 0.0; // p3p2 vector x coordinate
  90869. var p3p2y = 0.0; // p3p2 vector y coordinate
  90870. var p3p2z = 0.0; // p3p2 vector z coordinate
  90871. var faceNormalx = 0.0; // facet normal x coordinate
  90872. var faceNormaly = 0.0; // facet normal y coordinate
  90873. var faceNormalz = 0.0; // facet normal z coordinate
  90874. var length = 0.0; // facet normal length before normalization
  90875. var v1x = 0; // vector1 x index in the positions array
  90876. var v1y = 0; // vector1 y index in the positions array
  90877. var v1z = 0; // vector1 z index in the positions array
  90878. var v2x = 0; // vector2 x index in the positions array
  90879. var v2y = 0; // vector2 y index in the positions array
  90880. var v2z = 0; // vector2 z index in the positions array
  90881. var v3x = 0; // vector3 x index in the positions array
  90882. var v3y = 0; // vector3 y index in the positions array
  90883. var v3z = 0; // vector3 z index in the positions array
  90884. var computeFacetNormals = false;
  90885. var computeFacetPositions = false;
  90886. var computeFacetPartitioning = false;
  90887. var computeDepthSort = false;
  90888. var faceNormalSign = 1;
  90889. var ratio = 0;
  90890. var distanceTo = null;
  90891. if (options) {
  90892. computeFacetNormals = (options.facetNormals) ? true : false;
  90893. computeFacetPositions = (options.facetPositions) ? true : false;
  90894. computeFacetPartitioning = (options.facetPartitioning) ? true : false;
  90895. faceNormalSign = (options.useRightHandedSystem === true) ? -1 : 1;
  90896. ratio = options.ratio || 0;
  90897. computeDepthSort = (options.depthSort) ? true : false;
  90898. distanceTo = (options.distanceTo);
  90899. if (computeDepthSort) {
  90900. if (distanceTo === undefined) {
  90901. distanceTo = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  90902. }
  90903. var depthSortedFacets = options.depthSortedFacets;
  90904. }
  90905. }
  90906. // facetPartitioning reinit if needed
  90907. var xSubRatio = 0;
  90908. var ySubRatio = 0;
  90909. var zSubRatio = 0;
  90910. var subSq = 0;
  90911. if (computeFacetPartitioning && options && options.bbSize) {
  90912. var ox = 0; // X partitioning index for facet position
  90913. var oy = 0; // Y partinioning index for facet position
  90914. var oz = 0; // Z partinioning index for facet position
  90915. var b1x = 0; // X partitioning index for facet v1 vertex
  90916. var b1y = 0; // Y partitioning index for facet v1 vertex
  90917. var b1z = 0; // z partitioning index for facet v1 vertex
  90918. var b2x = 0; // X partitioning index for facet v2 vertex
  90919. var b2y = 0; // Y partitioning index for facet v2 vertex
  90920. var b2z = 0; // Z partitioning index for facet v2 vertex
  90921. var b3x = 0; // X partitioning index for facet v3 vertex
  90922. var b3y = 0; // Y partitioning index for facet v3 vertex
  90923. var b3z = 0; // Z partitioning index for facet v3 vertex
  90924. var block_idx_o = 0; // facet barycenter block index
  90925. var block_idx_v1 = 0; // v1 vertex block index
  90926. var block_idx_v2 = 0; // v2 vertex block index
  90927. var block_idx_v3 = 0; // v3 vertex block index
  90928. var bbSizeMax = (options.bbSize.x > options.bbSize.y) ? options.bbSize.x : options.bbSize.y;
  90929. bbSizeMax = (bbSizeMax > options.bbSize.z) ? bbSizeMax : options.bbSize.z;
  90930. xSubRatio = options.subDiv.X * ratio / options.bbSize.x;
  90931. ySubRatio = options.subDiv.Y * ratio / options.bbSize.y;
  90932. zSubRatio = options.subDiv.Z * ratio / options.bbSize.z;
  90933. subSq = options.subDiv.max * options.subDiv.max;
  90934. options.facetPartitioning.length = 0;
  90935. }
  90936. // reset the normals
  90937. for (index = 0; index < positions.length; index++) {
  90938. normals[index] = 0.0;
  90939. }
  90940. // Loop : 1 indice triplet = 1 facet
  90941. var nbFaces = (indices.length / 3) | 0;
  90942. for (index = 0; index < nbFaces; index++) {
  90943. // get the indexes of the coordinates of each vertex of the facet
  90944. v1x = indices[index * 3] * 3;
  90945. v1y = v1x + 1;
  90946. v1z = v1x + 2;
  90947. v2x = indices[index * 3 + 1] * 3;
  90948. v2y = v2x + 1;
  90949. v2z = v2x + 2;
  90950. v3x = indices[index * 3 + 2] * 3;
  90951. v3y = v3x + 1;
  90952. v3z = v3x + 2;
  90953. p1p2x = positions[v1x] - positions[v2x]; // compute two vectors per facet : p1p2 and p3p2
  90954. p1p2y = positions[v1y] - positions[v2y];
  90955. p1p2z = positions[v1z] - positions[v2z];
  90956. p3p2x = positions[v3x] - positions[v2x];
  90957. p3p2y = positions[v3y] - positions[v2y];
  90958. p3p2z = positions[v3z] - positions[v2z];
  90959. // compute the face normal with the cross product
  90960. faceNormalx = faceNormalSign * (p1p2y * p3p2z - p1p2z * p3p2y);
  90961. faceNormaly = faceNormalSign * (p1p2z * p3p2x - p1p2x * p3p2z);
  90962. faceNormalz = faceNormalSign * (p1p2x * p3p2y - p1p2y * p3p2x);
  90963. // normalize this normal and store it in the array facetData
  90964. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  90965. length = (length === 0) ? 1.0 : length;
  90966. faceNormalx /= length;
  90967. faceNormaly /= length;
  90968. faceNormalz /= length;
  90969. if (computeFacetNormals && options) {
  90970. options.facetNormals[index].x = faceNormalx;
  90971. options.facetNormals[index].y = faceNormaly;
  90972. options.facetNormals[index].z = faceNormalz;
  90973. }
  90974. if (computeFacetPositions && options) {
  90975. // compute and the facet barycenter coordinates in the array facetPositions
  90976. options.facetPositions[index].x = (positions[v1x] + positions[v2x] + positions[v3x]) / 3.0;
  90977. options.facetPositions[index].y = (positions[v1y] + positions[v2y] + positions[v3y]) / 3.0;
  90978. options.facetPositions[index].z = (positions[v1z] + positions[v2z] + positions[v3z]) / 3.0;
  90979. }
  90980. if (computeFacetPartitioning && options) {
  90981. // store the facet indexes in arrays in the main facetPartitioning array :
  90982. // compute each facet vertex (+ facet barycenter) index in the partiniong array
  90983. ox = Math.floor((options.facetPositions[index].x - options.bInfo.minimum.x * ratio) * xSubRatio);
  90984. oy = Math.floor((options.facetPositions[index].y - options.bInfo.minimum.y * ratio) * ySubRatio);
  90985. oz = Math.floor((options.facetPositions[index].z - options.bInfo.minimum.z * ratio) * zSubRatio);
  90986. b1x = Math.floor((positions[v1x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  90987. b1y = Math.floor((positions[v1y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  90988. b1z = Math.floor((positions[v1z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  90989. b2x = Math.floor((positions[v2x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  90990. b2y = Math.floor((positions[v2y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  90991. b2z = Math.floor((positions[v2z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  90992. b3x = Math.floor((positions[v3x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  90993. b3y = Math.floor((positions[v3y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  90994. b3z = Math.floor((positions[v3z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  90995. block_idx_v1 = b1x + options.subDiv.max * b1y + subSq * b1z;
  90996. block_idx_v2 = b2x + options.subDiv.max * b2y + subSq * b2z;
  90997. block_idx_v3 = b3x + options.subDiv.max * b3y + subSq * b3z;
  90998. block_idx_o = ox + options.subDiv.max * oy + subSq * oz;
  90999. options.facetPartitioning[block_idx_o] = options.facetPartitioning[block_idx_o] ? options.facetPartitioning[block_idx_o] : new Array();
  91000. options.facetPartitioning[block_idx_v1] = options.facetPartitioning[block_idx_v1] ? options.facetPartitioning[block_idx_v1] : new Array();
  91001. options.facetPartitioning[block_idx_v2] = options.facetPartitioning[block_idx_v2] ? options.facetPartitioning[block_idx_v2] : new Array();
  91002. options.facetPartitioning[block_idx_v3] = options.facetPartitioning[block_idx_v3] ? options.facetPartitioning[block_idx_v3] : new Array();
  91003. // push each facet index in each block containing the vertex
  91004. options.facetPartitioning[block_idx_v1].push(index);
  91005. if (block_idx_v2 != block_idx_v1) {
  91006. options.facetPartitioning[block_idx_v2].push(index);
  91007. }
  91008. if (!(block_idx_v3 == block_idx_v2 || block_idx_v3 == block_idx_v1)) {
  91009. options.facetPartitioning[block_idx_v3].push(index);
  91010. }
  91011. if (!(block_idx_o == block_idx_v1 || block_idx_o == block_idx_v2 || block_idx_o == block_idx_v3)) {
  91012. options.facetPartitioning[block_idx_o].push(index);
  91013. }
  91014. }
  91015. if (computeDepthSort && options && options.facetPositions) {
  91016. var dsf = depthSortedFacets[index];
  91017. dsf.ind = index * 3;
  91018. dsf.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(options.facetPositions[index], distanceTo);
  91019. }
  91020. // compute the normals anyway
  91021. normals[v1x] += faceNormalx; // accumulate all the normals per face
  91022. normals[v1y] += faceNormaly;
  91023. normals[v1z] += faceNormalz;
  91024. normals[v2x] += faceNormalx;
  91025. normals[v2y] += faceNormaly;
  91026. normals[v2z] += faceNormalz;
  91027. normals[v3x] += faceNormalx;
  91028. normals[v3y] += faceNormaly;
  91029. normals[v3z] += faceNormalz;
  91030. }
  91031. // last normalization of each normal
  91032. for (index = 0; index < normals.length / 3; index++) {
  91033. faceNormalx = normals[index * 3];
  91034. faceNormaly = normals[index * 3 + 1];
  91035. faceNormalz = normals[index * 3 + 2];
  91036. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  91037. length = (length === 0) ? 1.0 : length;
  91038. faceNormalx /= length;
  91039. faceNormaly /= length;
  91040. faceNormalz /= length;
  91041. normals[index * 3] = faceNormalx;
  91042. normals[index * 3 + 1] = faceNormaly;
  91043. normals[index * 3 + 2] = faceNormalz;
  91044. }
  91045. };
  91046. /** @hidden */
  91047. VertexData._ComputeSides = function (sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs) {
  91048. var li = indices.length;
  91049. var ln = normals.length;
  91050. var i;
  91051. var n;
  91052. sideOrientation = sideOrientation || VertexData.DEFAULTSIDE;
  91053. switch (sideOrientation) {
  91054. case VertexData.FRONTSIDE:
  91055. // nothing changed
  91056. break;
  91057. case VertexData.BACKSIDE:
  91058. var tmp;
  91059. // indices
  91060. for (i = 0; i < li; i += 3) {
  91061. tmp = indices[i];
  91062. indices[i] = indices[i + 2];
  91063. indices[i + 2] = tmp;
  91064. }
  91065. // normals
  91066. for (n = 0; n < ln; n++) {
  91067. normals[n] = -normals[n];
  91068. }
  91069. break;
  91070. case VertexData.DOUBLESIDE:
  91071. // positions
  91072. var lp = positions.length;
  91073. var l = lp / 3;
  91074. for (var p = 0; p < lp; p++) {
  91075. positions[lp + p] = positions[p];
  91076. }
  91077. // indices
  91078. for (i = 0; i < li; i += 3) {
  91079. indices[i + li] = indices[i + 2] + l;
  91080. indices[i + 1 + li] = indices[i + 1] + l;
  91081. indices[i + 2 + li] = indices[i] + l;
  91082. }
  91083. // normals
  91084. for (n = 0; n < ln; n++) {
  91085. normals[ln + n] = -normals[n];
  91086. }
  91087. // uvs
  91088. var lu = uvs.length;
  91089. var u = 0;
  91090. for (u = 0; u < lu; u++) {
  91091. uvs[u + lu] = uvs[u];
  91092. }
  91093. frontUVs = frontUVs ? frontUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  91094. backUVs = backUVs ? backUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  91095. u = 0;
  91096. for (i = 0; i < lu / 2; i++) {
  91097. uvs[u] = frontUVs.x + (frontUVs.z - frontUVs.x) * uvs[u];
  91098. uvs[u + 1] = frontUVs.y + (frontUVs.w - frontUVs.y) * uvs[u + 1];
  91099. uvs[u + lu] = backUVs.x + (backUVs.z - backUVs.x) * uvs[u + lu];
  91100. uvs[u + lu + 1] = backUVs.y + (backUVs.w - backUVs.y) * uvs[u + lu + 1];
  91101. u += 2;
  91102. }
  91103. break;
  91104. }
  91105. };
  91106. /**
  91107. * Applies VertexData created from the imported parameters to the geometry
  91108. * @param parsedVertexData the parsed data from an imported file
  91109. * @param geometry the geometry to apply the VertexData to
  91110. */
  91111. VertexData.ImportVertexData = function (parsedVertexData, geometry) {
  91112. var vertexData = new VertexData();
  91113. // positions
  91114. var positions = parsedVertexData.positions;
  91115. if (positions) {
  91116. vertexData.set(positions, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  91117. }
  91118. // normals
  91119. var normals = parsedVertexData.normals;
  91120. if (normals) {
  91121. vertexData.set(normals, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  91122. }
  91123. // tangents
  91124. var tangents = parsedVertexData.tangents;
  91125. if (tangents) {
  91126. vertexData.set(tangents, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind);
  91127. }
  91128. // uvs
  91129. var uvs = parsedVertexData.uvs;
  91130. if (uvs) {
  91131. vertexData.set(uvs, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  91132. }
  91133. // uv2s
  91134. var uv2s = parsedVertexData.uv2s;
  91135. if (uv2s) {
  91136. vertexData.set(uv2s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  91137. }
  91138. // uv3s
  91139. var uv3s = parsedVertexData.uv3s;
  91140. if (uv3s) {
  91141. vertexData.set(uv3s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind);
  91142. }
  91143. // uv4s
  91144. var uv4s = parsedVertexData.uv4s;
  91145. if (uv4s) {
  91146. vertexData.set(uv4s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind);
  91147. }
  91148. // uv5s
  91149. var uv5s = parsedVertexData.uv5s;
  91150. if (uv5s) {
  91151. vertexData.set(uv5s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind);
  91152. }
  91153. // uv6s
  91154. var uv6s = parsedVertexData.uv6s;
  91155. if (uv6s) {
  91156. vertexData.set(uv6s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind);
  91157. }
  91158. // colors
  91159. var colors = parsedVertexData.colors;
  91160. if (colors) {
  91161. vertexData.set(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"].CheckColors4(colors, positions.length / 3), _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  91162. }
  91163. // matricesIndices
  91164. var matricesIndices = parsedVertexData.matricesIndices;
  91165. if (matricesIndices) {
  91166. vertexData.set(matricesIndices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  91167. }
  91168. // matricesWeights
  91169. var matricesWeights = parsedVertexData.matricesWeights;
  91170. if (matricesWeights) {
  91171. vertexData.set(matricesWeights, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  91172. }
  91173. // indices
  91174. var indices = parsedVertexData.indices;
  91175. if (indices) {
  91176. vertexData.indices = indices;
  91177. }
  91178. geometry.setAllVerticesData(vertexData, parsedVertexData.updatable);
  91179. };
  91180. /**
  91181. * Mesh side orientation : usually the external or front surface
  91182. */
  91183. VertexData.FRONTSIDE = 0;
  91184. /**
  91185. * Mesh side orientation : usually the internal or back surface
  91186. */
  91187. VertexData.BACKSIDE = 1;
  91188. /**
  91189. * Mesh side orientation : both internal and external or front and back surfaces
  91190. */
  91191. VertexData.DOUBLESIDE = 2;
  91192. /**
  91193. * Mesh side orientation : by default, `FRONTSIDE`
  91194. */
  91195. VertexData.DEFAULTSIDE = 0;
  91196. return VertexData;
  91197. }());
  91198. /***/ }),
  91199. /***/ "./Meshes/meshBuilder.ts":
  91200. /*!*******************************!*\
  91201. !*** ./Meshes/meshBuilder.ts ***!
  91202. \*******************************/
  91203. /*! exports provided: MeshBuilder */
  91204. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91205. "use strict";
  91206. __webpack_require__.r(__webpack_exports__);
  91207. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return MeshBuilder; });
  91208. /* harmony import */ var _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Builders/ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  91209. /* harmony import */ var _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  91210. /* harmony import */ var _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  91211. /* harmony import */ var _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  91212. /* harmony import */ var _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  91213. /* harmony import */ var _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  91214. /* harmony import */ var _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Builders/torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  91215. /* harmony import */ var _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  91216. /* harmony import */ var _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Builders/polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  91217. /* harmony import */ var _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Builders/shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  91218. /* harmony import */ var _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Builders/latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  91219. /* harmony import */ var _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  91220. /* harmony import */ var _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  91221. /* harmony import */ var _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Builders/tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  91222. /* harmony import */ var _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  91223. /* harmony import */ var _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Builders/icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  91224. /* harmony import */ var _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Builders/decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  91225. /**
  91226. * Class containing static functions to help procedurally build meshes
  91227. */
  91228. var MeshBuilder = /** @class */ (function () {
  91229. function MeshBuilder() {
  91230. }
  91231. /**
  91232. * Creates a box mesh
  91233. * * The parameter `size` sets the size (float) of each box side (default 1)
  91234. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  91235. * * 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)
  91236. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  91237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91238. * * 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
  91239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91240. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  91241. * @param name defines the name of the mesh
  91242. * @param options defines the options used to create the mesh
  91243. * @param scene defines the hosting scene
  91244. * @returns the box mesh
  91245. */
  91246. MeshBuilder.CreateBox = function (name, options, scene) {
  91247. if (scene === void 0) { scene = null; }
  91248. return _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(name, options, scene);
  91249. };
  91250. /**
  91251. * Creates a sphere mesh
  91252. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  91253. * * 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`)
  91254. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  91255. * * 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
  91256. * * 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)
  91257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91258. * * 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
  91259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91260. * @param name defines the name of the mesh
  91261. * @param options defines the options used to create the mesh
  91262. * @param scene defines the hosting scene
  91263. * @returns the sphere mesh
  91264. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  91265. */
  91266. MeshBuilder.CreateSphere = function (name, options, scene) {
  91267. return _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"].CreateSphere(name, options, scene);
  91268. };
  91269. /**
  91270. * Creates a plane polygonal mesh. By default, this is a disc
  91271. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  91272. * * 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
  91273. * * 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
  91274. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91275. * * 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
  91276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91277. * @param name defines the name of the mesh
  91278. * @param options defines the options used to create the mesh
  91279. * @param scene defines the hosting scene
  91280. * @returns the plane polygonal mesh
  91281. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  91282. */
  91283. MeshBuilder.CreateDisc = function (name, options, scene) {
  91284. if (scene === void 0) { scene = null; }
  91285. return _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"].CreateDisc(name, options, scene);
  91286. };
  91287. /**
  91288. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  91289. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  91290. * * 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`)
  91291. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  91292. * * 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
  91293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91294. * * 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
  91295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91296. * @param name defines the name of the mesh
  91297. * @param options defines the options used to create the mesh
  91298. * @param scene defines the hosting scene
  91299. * @returns the icosahedron mesh
  91300. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  91301. */
  91302. MeshBuilder.CreateIcoSphere = function (name, options, scene) {
  91303. return _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__["IcoSphereBuilder"].CreateIcoSphere(name, options, scene);
  91304. };
  91305. /**
  91306. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  91307. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  91308. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  91309. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  91310. * * 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
  91311. * * 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
  91312. * * 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
  91313. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91314. * * 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
  91315. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  91316. * * 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
  91317. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  91318. * * 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
  91319. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  91320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91321. * @param name defines the name of the mesh
  91322. * @param options defines the options used to create the mesh
  91323. * @param scene defines the hosting scene
  91324. * @returns the ribbon mesh
  91325. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  91326. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  91327. */
  91328. MeshBuilder.CreateRibbon = function (name, options, scene) {
  91329. if (scene === void 0) { scene = null; }
  91330. return _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"].CreateRibbon(name, options, scene);
  91331. };
  91332. /**
  91333. * Creates a cylinder or a cone mesh
  91334. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  91335. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  91336. * * 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.
  91337. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  91338. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  91339. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  91340. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  91341. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  91342. * * 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).
  91343. * * 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
  91344. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  91345. * * 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
  91346. * * 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.
  91347. * * If `enclose` is false, a ring surface is one element.
  91348. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  91349. * * 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
  91350. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91351. * * 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
  91352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91353. * @param name defines the name of the mesh
  91354. * @param options defines the options used to create the mesh
  91355. * @param scene defines the hosting scene
  91356. * @returns the cylinder mesh
  91357. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  91358. */
  91359. MeshBuilder.CreateCylinder = function (name, options, scene) {
  91360. return _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder(name, options, scene);
  91361. };
  91362. /**
  91363. * Creates a torus mesh
  91364. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  91365. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  91366. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  91367. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91368. * * 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
  91369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91370. * @param name defines the name of the mesh
  91371. * @param options defines the options used to create the mesh
  91372. * @param scene defines the hosting scene
  91373. * @returns the torus mesh
  91374. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  91375. */
  91376. MeshBuilder.CreateTorus = function (name, options, scene) {
  91377. return _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__["TorusBuilder"].CreateTorus(name, options, scene);
  91378. };
  91379. /**
  91380. * Creates a torus knot mesh
  91381. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  91382. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  91383. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  91384. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  91385. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91386. * * 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
  91387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91388. * @param name defines the name of the mesh
  91389. * @param options defines the options used to create the mesh
  91390. * @param scene defines the hosting scene
  91391. * @returns the torus knot mesh
  91392. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  91393. */
  91394. MeshBuilder.CreateTorusKnot = function (name, options, scene) {
  91395. return _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusKnotBuilder"].CreateTorusKnot(name, options, scene);
  91396. };
  91397. /**
  91398. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  91399. * * 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
  91400. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  91401. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  91402. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  91403. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  91404. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  91405. * * 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
  91406. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  91407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91408. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  91409. * @param name defines the name of the new line system
  91410. * @param options defines the options used to create the line system
  91411. * @param scene defines the hosting scene
  91412. * @returns a new line system mesh
  91413. */
  91414. MeshBuilder.CreateLineSystem = function (name, options, scene) {
  91415. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLineSystem(name, options, scene);
  91416. };
  91417. /**
  91418. * Creates a line mesh
  91419. * 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
  91420. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  91421. * * The parameter `points` is an array successive Vector3
  91422. * * 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
  91423. * * The optional parameter `colors` is an array of successive Color4, one per line point
  91424. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  91425. * * When updating an instance, remember that only point positions can change, not the number of points
  91426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91427. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  91428. * @param name defines the name of the new line system
  91429. * @param options defines the options used to create the line system
  91430. * @param scene defines the hosting scene
  91431. * @returns a new line mesh
  91432. */
  91433. MeshBuilder.CreateLines = function (name, options, scene) {
  91434. if (scene === void 0) { scene = null; }
  91435. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLines(name, options, scene);
  91436. };
  91437. /**
  91438. * Creates a dashed line mesh
  91439. * * 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
  91440. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  91441. * * The parameter `points` is an array successive Vector3
  91442. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  91443. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  91444. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  91445. * * 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
  91446. * * When updating an instance, remember that only point positions can change, not the number of points
  91447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91448. * @param name defines the name of the mesh
  91449. * @param options defines the options used to create the mesh
  91450. * @param scene defines the hosting scene
  91451. * @returns the dashed line mesh
  91452. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  91453. */
  91454. MeshBuilder.CreateDashedLines = function (name, options, scene) {
  91455. if (scene === void 0) { scene = null; }
  91456. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateDashedLines(name, options, scene);
  91457. };
  91458. /**
  91459. * 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.
  91460. * * 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.
  91461. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  91462. * * 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.
  91463. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  91464. * * 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
  91465. * * 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
  91466. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  91467. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91468. * * 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
  91469. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  91470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91471. * @param name defines the name of the mesh
  91472. * @param options defines the options used to create the mesh
  91473. * @param scene defines the hosting scene
  91474. * @returns the extruded shape mesh
  91475. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  91476. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91477. */
  91478. MeshBuilder.ExtrudeShape = function (name, options, scene) {
  91479. if (scene === void 0) { scene = null; }
  91480. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShape(name, options, scene);
  91481. };
  91482. /**
  91483. * Creates an custom extruded shape mesh.
  91484. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  91485. * * 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.
  91486. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  91487. * * 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
  91488. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  91489. * * 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
  91490. * * It must returns a float value that will be the scale value applied to the shape on each path point
  91491. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  91492. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  91493. * * 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
  91494. * * 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
  91495. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  91496. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91497. * * 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
  91498. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  91499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91500. * @param name defines the name of the mesh
  91501. * @param options defines the options used to create the mesh
  91502. * @param scene defines the hosting scene
  91503. * @returns the custom extruded shape mesh
  91504. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  91505. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  91506. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91507. */
  91508. MeshBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  91509. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShapeCustom(name, options, scene);
  91510. };
  91511. /**
  91512. * Creates lathe mesh.
  91513. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  91514. * * 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
  91515. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  91516. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  91517. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  91518. * * 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
  91519. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  91520. * * 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
  91521. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91522. * * 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
  91523. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  91524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91525. * @param name defines the name of the mesh
  91526. * @param options defines the options used to create the mesh
  91527. * @param scene defines the hosting scene
  91528. * @returns the lathe mesh
  91529. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  91530. */
  91531. MeshBuilder.CreateLathe = function (name, options, scene) {
  91532. return _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__["LatheBuilder"].CreateLathe(name, options, scene);
  91533. };
  91534. /**
  91535. * Creates a plane mesh
  91536. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  91537. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  91538. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  91539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91540. * * 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
  91541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91542. * @param name defines the name of the mesh
  91543. * @param options defines the options used to create the mesh
  91544. * @param scene defines the hosting scene
  91545. * @returns the plane mesh
  91546. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  91547. */
  91548. MeshBuilder.CreatePlane = function (name, options, scene) {
  91549. return _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__["PlaneBuilder"].CreatePlane(name, options, scene);
  91550. };
  91551. /**
  91552. * Creates a ground mesh
  91553. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  91554. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  91555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91556. * @param name defines the name of the mesh
  91557. * @param options defines the options used to create the mesh
  91558. * @param scene defines the hosting scene
  91559. * @returns the ground mesh
  91560. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  91561. */
  91562. MeshBuilder.CreateGround = function (name, options, scene) {
  91563. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGround(name, options, scene);
  91564. };
  91565. /**
  91566. * Creates a tiled ground mesh
  91567. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  91568. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  91569. * * 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
  91570. * * 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
  91571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91572. * @param name defines the name of the mesh
  91573. * @param options defines the options used to create the mesh
  91574. * @param scene defines the hosting scene
  91575. * @returns the tiled ground mesh
  91576. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  91577. */
  91578. MeshBuilder.CreateTiledGround = function (name, options, scene) {
  91579. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateTiledGround(name, options, scene);
  91580. };
  91581. /**
  91582. * Creates a ground mesh from a height map
  91583. * * The parameter `url` sets the URL of the height map image resource.
  91584. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  91585. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  91586. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  91587. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  91588. * * 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.
  91589. * * 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).
  91590. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  91591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91592. * @param name defines the name of the mesh
  91593. * @param url defines the url to the height map
  91594. * @param options defines the options used to create the mesh
  91595. * @param scene defines the hosting scene
  91596. * @returns the ground mesh
  91597. * @see https://doc.babylonjs.com/babylon101/height_map
  91598. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  91599. */
  91600. MeshBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  91601. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGroundFromHeightMap(name, url, options, scene);
  91602. };
  91603. /**
  91604. * Creates a polygon mesh
  91605. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  91606. * * 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
  91607. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91609. * * 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)
  91610. * * Remember you can only change the shape positions, not their number when updating a polygon
  91611. * @param name defines the name of the mesh
  91612. * @param options defines the options used to create the mesh
  91613. * @param scene defines the hosting scene
  91614. * @param earcutInjection can be used to inject your own earcut reference
  91615. * @returns the polygon mesh
  91616. */
  91617. MeshBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  91618. if (earcutInjection === void 0) { earcutInjection = earcut; }
  91619. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].CreatePolygon(name, options, scene, earcutInjection);
  91620. };
  91621. /**
  91622. * Creates an extruded polygon mesh, with depth in the Y direction.
  91623. * * 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)
  91624. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  91625. * @param name defines the name of the mesh
  91626. * @param options defines the options used to create the mesh
  91627. * @param scene defines the hosting scene
  91628. * @param earcutInjection can be used to inject your own earcut reference
  91629. * @returns the polygon mesh
  91630. */
  91631. MeshBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  91632. if (earcutInjection === void 0) { earcutInjection = earcut; }
  91633. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].ExtrudePolygon(name, options, scene, earcutInjection);
  91634. };
  91635. /**
  91636. * Creates a tube mesh.
  91637. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  91638. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  91639. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  91640. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  91641. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  91642. * * 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)
  91643. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  91644. * * 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
  91645. * * 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
  91646. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91647. * * 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
  91648. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  91649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91650. * @param name defines the name of the mesh
  91651. * @param options defines the options used to create the mesh
  91652. * @param scene defines the hosting scene
  91653. * @returns the tube mesh
  91654. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  91655. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  91656. */
  91657. MeshBuilder.CreateTube = function (name, options, scene) {
  91658. return _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__["TubeBuilder"].CreateTube(name, options, scene);
  91659. };
  91660. /**
  91661. * Creates a polyhedron mesh
  91662. * * 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
  91663. * * The parameter `size` (positive float, default 1) sets the polygon size
  91664. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  91665. * * 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`
  91666. * * 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
  91667. * * 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)`)
  91668. * * 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
  91669. * * 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
  91670. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91671. * * 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
  91672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91673. * @param name defines the name of the mesh
  91674. * @param options defines the options used to create the mesh
  91675. * @param scene defines the hosting scene
  91676. * @returns the polyhedron mesh
  91677. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  91678. */
  91679. MeshBuilder.CreatePolyhedron = function (name, options, scene) {
  91680. return _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__["PolyhedronBuilder"].CreatePolyhedron(name, options, scene);
  91681. };
  91682. /**
  91683. * Creates a decal mesh.
  91684. * 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
  91685. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  91686. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  91687. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  91688. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  91689. * @param name defines the name of the mesh
  91690. * @param sourceMesh defines the mesh where the decal must be applied
  91691. * @param options defines the options used to create the mesh
  91692. * @param scene defines the hosting scene
  91693. * @returns the decal mesh
  91694. * @see https://doc.babylonjs.com/how_to/decals
  91695. */
  91696. MeshBuilder.CreateDecal = function (name, sourceMesh, options) {
  91697. return _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"].CreateDecal(name, sourceMesh, options);
  91698. };
  91699. return MeshBuilder;
  91700. }());
  91701. /***/ }),
  91702. /***/ "./Meshes/meshSimplification.ts":
  91703. /*!**************************************!*\
  91704. !*** ./Meshes/meshSimplification.ts ***!
  91705. \**************************************/
  91706. /*! exports provided: SimplificationSettings, SimplificationQueue, SimplificationType */
  91707. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91708. "use strict";
  91709. __webpack_require__.r(__webpack_exports__);
  91710. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return SimplificationSettings; });
  91711. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return SimplificationQueue; });
  91712. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return SimplificationType; });
  91713. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  91714. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  91715. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  91716. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  91717. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  91718. /**
  91719. * Class used to specify simplification options
  91720. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  91721. */
  91722. var SimplificationSettings = /** @class */ (function () {
  91723. /**
  91724. * Creates a SimplificationSettings
  91725. * @param quality expected quality
  91726. * @param distance distance when this optimized version should be used
  91727. * @param optimizeMesh already optimized mesh
  91728. */
  91729. function SimplificationSettings(
  91730. /** expected quality */
  91731. quality,
  91732. /** distance when this optimized version should be used */
  91733. distance,
  91734. /** already optimized mesh */
  91735. optimizeMesh) {
  91736. this.quality = quality;
  91737. this.distance = distance;
  91738. this.optimizeMesh = optimizeMesh;
  91739. }
  91740. return SimplificationSettings;
  91741. }());
  91742. /**
  91743. * Queue used to order the simplification tasks
  91744. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  91745. */
  91746. var SimplificationQueue = /** @class */ (function () {
  91747. /**
  91748. * Creates a new queue
  91749. */
  91750. function SimplificationQueue() {
  91751. this.running = false;
  91752. this._simplificationArray = [];
  91753. }
  91754. /**
  91755. * Adds a new simplification task
  91756. * @param task defines a task to add
  91757. */
  91758. SimplificationQueue.prototype.addTask = function (task) {
  91759. this._simplificationArray.push(task);
  91760. };
  91761. /**
  91762. * Execute next task
  91763. */
  91764. SimplificationQueue.prototype.executeNext = function () {
  91765. var task = this._simplificationArray.pop();
  91766. if (task) {
  91767. this.running = true;
  91768. this.runSimplification(task);
  91769. }
  91770. else {
  91771. this.running = false;
  91772. }
  91773. };
  91774. /**
  91775. * Execute a simplification task
  91776. * @param task defines the task to run
  91777. */
  91778. SimplificationQueue.prototype.runSimplification = function (task) {
  91779. var _this = this;
  91780. if (task.parallelProcessing) {
  91781. //parallel simplifier
  91782. task.settings.forEach(function (setting) {
  91783. var simplifier = _this.getSimplifier(task);
  91784. simplifier.simplify(setting, function (newMesh) {
  91785. task.mesh.addLODLevel(setting.distance, newMesh);
  91786. newMesh.isVisible = true;
  91787. //check if it is the last
  91788. if (setting.quality === task.settings[task.settings.length - 1].quality && task.successCallback) {
  91789. //all done, run the success callback.
  91790. task.successCallback();
  91791. }
  91792. _this.executeNext();
  91793. });
  91794. });
  91795. }
  91796. else {
  91797. //single simplifier.
  91798. var simplifier = this.getSimplifier(task);
  91799. var runDecimation = function (setting, callback) {
  91800. simplifier.simplify(setting, function (newMesh) {
  91801. task.mesh.addLODLevel(setting.distance, newMesh);
  91802. newMesh.isVisible = true;
  91803. //run the next quality level
  91804. callback();
  91805. });
  91806. };
  91807. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(task.settings.length, function (loop) {
  91808. runDecimation(task.settings[loop.index], function () {
  91809. loop.executeNext();
  91810. });
  91811. }, function () {
  91812. //execution ended, run the success callback.
  91813. if (task.successCallback) {
  91814. task.successCallback();
  91815. }
  91816. _this.executeNext();
  91817. });
  91818. }
  91819. };
  91820. SimplificationQueue.prototype.getSimplifier = function (task) {
  91821. switch (task.simplificationType) {
  91822. case SimplificationType.QUADRATIC:
  91823. default:
  91824. return new QuadraticErrorSimplification(task.mesh);
  91825. }
  91826. };
  91827. return SimplificationQueue;
  91828. }());
  91829. /**
  91830. * The implemented types of simplification
  91831. * At the moment only Quadratic Error Decimation is implemented
  91832. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  91833. */
  91834. var SimplificationType;
  91835. (function (SimplificationType) {
  91836. /** Quadratic error decimation */
  91837. SimplificationType[SimplificationType["QUADRATIC"] = 0] = "QUADRATIC";
  91838. })(SimplificationType || (SimplificationType = {}));
  91839. var DecimationTriangle = /** @class */ (function () {
  91840. function DecimationTriangle(vertices) {
  91841. this.vertices = vertices;
  91842. this.error = new Array(4);
  91843. this.deleted = false;
  91844. this.isDirty = false;
  91845. this.deletePending = false;
  91846. this.borderFactor = 0;
  91847. }
  91848. return DecimationTriangle;
  91849. }());
  91850. var DecimationVertex = /** @class */ (function () {
  91851. function DecimationVertex(position, id) {
  91852. this.position = position;
  91853. this.id = id;
  91854. this.isBorder = true;
  91855. this.q = new QuadraticMatrix();
  91856. this.triangleCount = 0;
  91857. this.triangleStart = 0;
  91858. this.originalOffsets = [];
  91859. }
  91860. DecimationVertex.prototype.updatePosition = function (newPosition) {
  91861. this.position.copyFrom(newPosition);
  91862. };
  91863. return DecimationVertex;
  91864. }());
  91865. var QuadraticMatrix = /** @class */ (function () {
  91866. function QuadraticMatrix(data) {
  91867. this.data = new Array(10);
  91868. for (var i = 0; i < 10; ++i) {
  91869. if (data && data[i]) {
  91870. this.data[i] = data[i];
  91871. }
  91872. else {
  91873. this.data[i] = 0;
  91874. }
  91875. }
  91876. }
  91877. QuadraticMatrix.prototype.det = function (a11, a12, a13, a21, a22, a23, a31, a32, a33) {
  91878. var det = this.data[a11] * this.data[a22] * this.data[a33] + this.data[a13] * this.data[a21] * this.data[a32] +
  91879. this.data[a12] * this.data[a23] * this.data[a31] - this.data[a13] * this.data[a22] * this.data[a31] -
  91880. this.data[a11] * this.data[a23] * this.data[a32] - this.data[a12] * this.data[a21] * this.data[a33];
  91881. return det;
  91882. };
  91883. QuadraticMatrix.prototype.addInPlace = function (matrix) {
  91884. for (var i = 0; i < 10; ++i) {
  91885. this.data[i] += matrix.data[i];
  91886. }
  91887. };
  91888. QuadraticMatrix.prototype.addArrayInPlace = function (data) {
  91889. for (var i = 0; i < 10; ++i) {
  91890. this.data[i] += data[i];
  91891. }
  91892. };
  91893. QuadraticMatrix.prototype.add = function (matrix) {
  91894. var m = new QuadraticMatrix();
  91895. for (var i = 0; i < 10; ++i) {
  91896. m.data[i] = this.data[i] + matrix.data[i];
  91897. }
  91898. return m;
  91899. };
  91900. QuadraticMatrix.FromData = function (a, b, c, d) {
  91901. return new QuadraticMatrix(QuadraticMatrix.DataFromNumbers(a, b, c, d));
  91902. };
  91903. //returning an array to avoid garbage collection
  91904. QuadraticMatrix.DataFromNumbers = function (a, b, c, d) {
  91905. return [a * a, a * b, a * c, a * d, b * b, b * c, b * d, c * c, c * d, d * d];
  91906. };
  91907. return QuadraticMatrix;
  91908. }());
  91909. var Reference = /** @class */ (function () {
  91910. function Reference(vertexId, triangleId) {
  91911. this.vertexId = vertexId;
  91912. this.triangleId = triangleId;
  91913. }
  91914. return Reference;
  91915. }());
  91916. /**
  91917. * An implementation of the Quadratic Error simplification algorithm.
  91918. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  91919. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  91920. * @author RaananW
  91921. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  91922. */
  91923. var QuadraticErrorSimplification = /** @class */ (function () {
  91924. function QuadraticErrorSimplification(_mesh) {
  91925. this._mesh = _mesh;
  91926. this.syncIterations = 5000;
  91927. this.aggressiveness = 7;
  91928. this.decimationIterations = 100;
  91929. this.boundingBoxEpsilon = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"];
  91930. }
  91931. QuadraticErrorSimplification.prototype.simplify = function (settings, successCallback) {
  91932. var _this = this;
  91933. this.initDecimatedMesh();
  91934. //iterating through the submeshes array, one after the other.
  91935. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this._mesh.subMeshes.length, function (loop) {
  91936. _this.initWithMesh(loop.index, function () {
  91937. _this.runDecimation(settings, loop.index, function () {
  91938. loop.executeNext();
  91939. });
  91940. }, settings.optimizeMesh);
  91941. }, function () {
  91942. setTimeout(function () {
  91943. successCallback(_this._reconstructedMesh);
  91944. }, 0);
  91945. });
  91946. };
  91947. QuadraticErrorSimplification.prototype.runDecimation = function (settings, submeshIndex, successCallback) {
  91948. var _this = this;
  91949. var targetCount = ~~(this.triangles.length * settings.quality);
  91950. var deletedTriangles = 0;
  91951. var triangleCount = this.triangles.length;
  91952. var iterationFunction = function (iteration, callback) {
  91953. setTimeout(function () {
  91954. if (iteration % 5 === 0) {
  91955. _this.updateMesh(iteration === 0);
  91956. }
  91957. for (var i = 0; i < _this.triangles.length; ++i) {
  91958. _this.triangles[i].isDirty = false;
  91959. }
  91960. var threshold = 0.000000001 * Math.pow((iteration + 3), _this.aggressiveness);
  91961. var trianglesIterator = function (i) {
  91962. var tIdx = ~~(((_this.triangles.length / 2) + i) % _this.triangles.length);
  91963. var t = _this.triangles[tIdx];
  91964. if (!t) {
  91965. return;
  91966. }
  91967. if (t.error[3] > threshold || t.deleted || t.isDirty) {
  91968. return;
  91969. }
  91970. for (var j = 0; j < 3; ++j) {
  91971. if (t.error[j] < threshold) {
  91972. var deleted0 = [];
  91973. var deleted1 = [];
  91974. var v0 = t.vertices[j];
  91975. var v1 = t.vertices[(j + 1) % 3];
  91976. if (v0.isBorder || v1.isBorder) {
  91977. continue;
  91978. }
  91979. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  91980. // var n = Vector3.Zero();
  91981. // var uv = Vector2.Zero();
  91982. // var color = new Color4(0, 0, 0, 1);
  91983. _this.calculateError(v0, v1, p);
  91984. var delTr = new Array();
  91985. if (_this.isFlipped(v0, v1, p, deleted0, delTr)) {
  91986. continue;
  91987. }
  91988. if (_this.isFlipped(v1, v0, p, deleted1, delTr)) {
  91989. continue;
  91990. }
  91991. if (deleted0.indexOf(true) < 0 || deleted1.indexOf(true) < 0) {
  91992. continue;
  91993. }
  91994. var uniqueArray = new Array();
  91995. delTr.forEach(function (deletedT) {
  91996. if (uniqueArray.indexOf(deletedT) === -1) {
  91997. deletedT.deletePending = true;
  91998. uniqueArray.push(deletedT);
  91999. }
  92000. });
  92001. if (uniqueArray.length % 2 !== 0) {
  92002. continue;
  92003. }
  92004. v0.q = v1.q.add(v0.q);
  92005. v0.updatePosition(p);
  92006. var tStart = _this.references.length;
  92007. deletedTriangles = _this.updateTriangles(v0, v0, deleted0, deletedTriangles);
  92008. deletedTriangles = _this.updateTriangles(v0, v1, deleted1, deletedTriangles);
  92009. var tCount = _this.references.length - tStart;
  92010. if (tCount <= v0.triangleCount) {
  92011. if (tCount) {
  92012. for (var c = 0; c < tCount; c++) {
  92013. _this.references[v0.triangleStart + c] = _this.references[tStart + c];
  92014. }
  92015. }
  92016. }
  92017. else {
  92018. v0.triangleStart = tStart;
  92019. }
  92020. v0.triangleCount = tCount;
  92021. break;
  92022. }
  92023. }
  92024. };
  92025. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, trianglesIterator, callback, function () { return (triangleCount - deletedTriangles <= targetCount); });
  92026. }, 0);
  92027. };
  92028. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this.decimationIterations, function (loop) {
  92029. if (triangleCount - deletedTriangles <= targetCount) {
  92030. loop.breakLoop();
  92031. }
  92032. else {
  92033. iterationFunction(loop.index, function () {
  92034. loop.executeNext();
  92035. });
  92036. }
  92037. }, function () {
  92038. setTimeout(function () {
  92039. //reconstruct this part of the mesh
  92040. _this.reconstructMesh(submeshIndex);
  92041. successCallback();
  92042. }, 0);
  92043. });
  92044. };
  92045. QuadraticErrorSimplification.prototype.initWithMesh = function (submeshIndex, callback, optimizeMesh) {
  92046. var _this = this;
  92047. this.vertices = [];
  92048. this.triangles = [];
  92049. var positionData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  92050. var indices = this._mesh.getIndices();
  92051. var submesh = this._mesh.subMeshes[submeshIndex];
  92052. var findInVertices = function (positionToSearch) {
  92053. if (optimizeMesh) {
  92054. for (var ii = 0; ii < _this.vertices.length; ++ii) {
  92055. if (_this.vertices[ii].position.equals(positionToSearch)) {
  92056. return _this.vertices[ii];
  92057. }
  92058. }
  92059. }
  92060. return null;
  92061. };
  92062. var vertexReferences = [];
  92063. var vertexInit = function (i) {
  92064. if (!positionData) {
  92065. return;
  92066. }
  92067. var offset = i + submesh.verticesStart;
  92068. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positionData, offset * 3);
  92069. var vertex = findInVertices(position) || new DecimationVertex(position, _this.vertices.length);
  92070. vertex.originalOffsets.push(offset);
  92071. if (vertex.id === _this.vertices.length) {
  92072. _this.vertices.push(vertex);
  92073. }
  92074. vertexReferences.push(vertex.id);
  92075. };
  92076. //var totalVertices = mesh.getTotalVertices();
  92077. var totalVertices = submesh.verticesCount;
  92078. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(totalVertices, (this.syncIterations / 4) >> 0, vertexInit, function () {
  92079. var indicesInit = function (i) {
  92080. if (!indices) {
  92081. return;
  92082. }
  92083. var offset = (submesh.indexStart / 3) + i;
  92084. var pos = (offset * 3);
  92085. var i0 = indices[pos + 0];
  92086. var i1 = indices[pos + 1];
  92087. var i2 = indices[pos + 2];
  92088. var v0 = _this.vertices[vertexReferences[i0 - submesh.verticesStart]];
  92089. var v1 = _this.vertices[vertexReferences[i1 - submesh.verticesStart]];
  92090. var v2 = _this.vertices[vertexReferences[i2 - submesh.verticesStart]];
  92091. var triangle = new DecimationTriangle([v0, v1, v2]);
  92092. triangle.originalOffset = pos;
  92093. _this.triangles.push(triangle);
  92094. };
  92095. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(submesh.indexCount / 3, _this.syncIterations, indicesInit, function () {
  92096. _this.init(callback);
  92097. });
  92098. });
  92099. };
  92100. QuadraticErrorSimplification.prototype.init = function (callback) {
  92101. var _this = this;
  92102. var triangleInit1 = function (i) {
  92103. var t = _this.triangles[i];
  92104. 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();
  92105. for (var j = 0; j < 3; j++) {
  92106. 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))));
  92107. }
  92108. };
  92109. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(this.triangles.length, this.syncIterations, triangleInit1, function () {
  92110. var triangleInit2 = function (i) {
  92111. var t = _this.triangles[i];
  92112. for (var j = 0; j < 3; ++j) {
  92113. t.error[j] = _this.calculateError(t.vertices[j], t.vertices[(j + 1) % 3]);
  92114. }
  92115. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  92116. };
  92117. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, triangleInit2, function () {
  92118. callback();
  92119. });
  92120. });
  92121. };
  92122. QuadraticErrorSimplification.prototype.reconstructMesh = function (submeshIndex) {
  92123. var newTriangles = [];
  92124. var i;
  92125. for (i = 0; i < this.vertices.length; ++i) {
  92126. this.vertices[i].triangleCount = 0;
  92127. }
  92128. var t;
  92129. var j;
  92130. for (i = 0; i < this.triangles.length; ++i) {
  92131. if (!this.triangles[i].deleted) {
  92132. t = this.triangles[i];
  92133. for (j = 0; j < 3; ++j) {
  92134. t.vertices[j].triangleCount = 1;
  92135. }
  92136. newTriangles.push(t);
  92137. }
  92138. }
  92139. var newPositionData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind) || []);
  92140. var newNormalData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind) || []);
  92141. var newUVsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind) || []);
  92142. var newColorsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind) || []);
  92143. var normalData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  92144. var uvs = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  92145. var colorsData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  92146. var vertexCount = 0;
  92147. for (i = 0; i < this.vertices.length; ++i) {
  92148. var vertex = this.vertices[i];
  92149. vertex.id = vertexCount;
  92150. if (vertex.triangleCount) {
  92151. vertex.originalOffsets.forEach(function (originalOffset) {
  92152. if (!normalData) {
  92153. return;
  92154. }
  92155. newPositionData.push(vertex.position.x);
  92156. newPositionData.push(vertex.position.y);
  92157. newPositionData.push(vertex.position.z);
  92158. newNormalData.push(normalData[originalOffset * 3]);
  92159. newNormalData.push(normalData[(originalOffset * 3) + 1]);
  92160. newNormalData.push(normalData[(originalOffset * 3) + 2]);
  92161. if (uvs && uvs.length) {
  92162. newUVsData.push(uvs[(originalOffset * 2)]);
  92163. newUVsData.push(uvs[(originalOffset * 2) + 1]);
  92164. }
  92165. else if (colorsData && colorsData.length) {
  92166. newColorsData.push(colorsData[(originalOffset * 4)]);
  92167. newColorsData.push(colorsData[(originalOffset * 4) + 1]);
  92168. newColorsData.push(colorsData[(originalOffset * 4) + 2]);
  92169. newColorsData.push(colorsData[(originalOffset * 4) + 3]);
  92170. }
  92171. ++vertexCount;
  92172. });
  92173. }
  92174. }
  92175. var startingIndex = this._reconstructedMesh.getTotalIndices();
  92176. var startingVertex = this._reconstructedMesh.getTotalVertices();
  92177. var submeshesArray = this._reconstructedMesh.subMeshes;
  92178. this._reconstructedMesh.subMeshes = [];
  92179. var newIndicesArray = this._reconstructedMesh.getIndices(); //[];
  92180. var originalIndices = this._mesh.getIndices();
  92181. for (i = 0; i < newTriangles.length; ++i) {
  92182. t = newTriangles[i]; //now get the new referencing point for each vertex
  92183. [0, 1, 2].forEach(function (idx) {
  92184. var id = originalIndices[t.originalOffset + idx];
  92185. var offset = t.vertices[idx].originalOffsets.indexOf(id);
  92186. if (offset < 0) {
  92187. offset = 0;
  92188. }
  92189. newIndicesArray.push(t.vertices[idx].id + offset + startingVertex);
  92190. });
  92191. }
  92192. //overwriting the old vertex buffers and indices.
  92193. this._reconstructedMesh.setIndices(newIndicesArray);
  92194. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, newPositionData);
  92195. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, newNormalData);
  92196. if (newUVsData.length > 0) {
  92197. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, newUVsData);
  92198. }
  92199. if (newColorsData.length > 0) {
  92200. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, newColorsData);
  92201. }
  92202. //create submesh
  92203. var originalSubmesh = this._mesh.subMeshes[submeshIndex];
  92204. if (submeshIndex > 0) {
  92205. this._reconstructedMesh.subMeshes = [];
  92206. submeshesArray.forEach(function (submesh) {
  92207. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(submesh.materialIndex, submesh.verticesStart, submesh.verticesCount, /* 0, newPositionData.length/3, */ submesh.indexStart, submesh.indexCount, submesh.getMesh());
  92208. });
  92209. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(originalSubmesh.materialIndex, startingVertex, vertexCount, /* 0, newPositionData.length / 3, */ startingIndex, newTriangles.length * 3, this._reconstructedMesh);
  92210. }
  92211. };
  92212. QuadraticErrorSimplification.prototype.initDecimatedMesh = function () {
  92213. this._reconstructedMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this._mesh.name + "Decimated", this._mesh.getScene());
  92214. this._reconstructedMesh.material = this._mesh.material;
  92215. this._reconstructedMesh.parent = this._mesh.parent;
  92216. this._reconstructedMesh.isVisible = false;
  92217. this._reconstructedMesh.renderingGroupId = this._mesh.renderingGroupId;
  92218. };
  92219. QuadraticErrorSimplification.prototype.isFlipped = function (vertex1, vertex2, point, deletedArray, delTr) {
  92220. for (var i = 0; i < vertex1.triangleCount; ++i) {
  92221. var t = this.triangles[this.references[vertex1.triangleStart + i].triangleId];
  92222. if (t.deleted) {
  92223. continue;
  92224. }
  92225. var s = this.references[vertex1.triangleStart + i].vertexId;
  92226. var v1 = t.vertices[(s + 1) % 3];
  92227. var v2 = t.vertices[(s + 2) % 3];
  92228. if ((v1 === vertex2 || v2 === vertex2)) {
  92229. deletedArray[i] = true;
  92230. delTr.push(t);
  92231. continue;
  92232. }
  92233. var d1 = v1.position.subtract(point);
  92234. d1 = d1.normalize();
  92235. var d2 = v2.position.subtract(point);
  92236. d2 = d2.normalize();
  92237. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(d1, d2)) > 0.999) {
  92238. return true;
  92239. }
  92240. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(d1, d2).normalize();
  92241. deletedArray[i] = false;
  92242. if (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(normal, t.normal) < 0.2) {
  92243. return true;
  92244. }
  92245. }
  92246. return false;
  92247. };
  92248. QuadraticErrorSimplification.prototype.updateTriangles = function (origVertex, vertex, deletedArray, deletedTriangles) {
  92249. var newDeleted = deletedTriangles;
  92250. for (var i = 0; i < vertex.triangleCount; ++i) {
  92251. var ref = this.references[vertex.triangleStart + i];
  92252. var t = this.triangles[ref.triangleId];
  92253. if (t.deleted) {
  92254. continue;
  92255. }
  92256. if (deletedArray[i] && t.deletePending) {
  92257. t.deleted = true;
  92258. newDeleted++;
  92259. continue;
  92260. }
  92261. t.vertices[ref.vertexId] = origVertex;
  92262. t.isDirty = true;
  92263. t.error[0] = this.calculateError(t.vertices[0], t.vertices[1]) + (t.borderFactor / 2);
  92264. t.error[1] = this.calculateError(t.vertices[1], t.vertices[2]) + (t.borderFactor / 2);
  92265. t.error[2] = this.calculateError(t.vertices[2], t.vertices[0]) + (t.borderFactor / 2);
  92266. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  92267. this.references.push(ref);
  92268. }
  92269. return newDeleted;
  92270. };
  92271. QuadraticErrorSimplification.prototype.identifyBorder = function () {
  92272. for (var i = 0; i < this.vertices.length; ++i) {
  92273. var vCount = [];
  92274. var vId = [];
  92275. var v = this.vertices[i];
  92276. var j;
  92277. for (j = 0; j < v.triangleCount; ++j) {
  92278. var triangle = this.triangles[this.references[v.triangleStart + j].triangleId];
  92279. for (var ii = 0; ii < 3; ii++) {
  92280. var ofs = 0;
  92281. var vv = triangle.vertices[ii];
  92282. while (ofs < vCount.length) {
  92283. if (vId[ofs] === vv.id) {
  92284. break;
  92285. }
  92286. ++ofs;
  92287. }
  92288. if (ofs === vCount.length) {
  92289. vCount.push(1);
  92290. vId.push(vv.id);
  92291. }
  92292. else {
  92293. vCount[ofs]++;
  92294. }
  92295. }
  92296. }
  92297. for (j = 0; j < vCount.length; ++j) {
  92298. if (vCount[j] === 1) {
  92299. this.vertices[vId[j]].isBorder = true;
  92300. }
  92301. else {
  92302. this.vertices[vId[j]].isBorder = false;
  92303. }
  92304. }
  92305. }
  92306. };
  92307. QuadraticErrorSimplification.prototype.updateMesh = function (identifyBorders) {
  92308. if (identifyBorders === void 0) { identifyBorders = false; }
  92309. var i;
  92310. if (!identifyBorders) {
  92311. var newTrianglesVector = [];
  92312. for (i = 0; i < this.triangles.length; ++i) {
  92313. if (!this.triangles[i].deleted) {
  92314. newTrianglesVector.push(this.triangles[i]);
  92315. }
  92316. }
  92317. this.triangles = newTrianglesVector;
  92318. }
  92319. for (i = 0; i < this.vertices.length; ++i) {
  92320. this.vertices[i].triangleCount = 0;
  92321. this.vertices[i].triangleStart = 0;
  92322. }
  92323. var t;
  92324. var j;
  92325. var v;
  92326. for (i = 0; i < this.triangles.length; ++i) {
  92327. t = this.triangles[i];
  92328. for (j = 0; j < 3; ++j) {
  92329. v = t.vertices[j];
  92330. v.triangleCount++;
  92331. }
  92332. }
  92333. var tStart = 0;
  92334. for (i = 0; i < this.vertices.length; ++i) {
  92335. this.vertices[i].triangleStart = tStart;
  92336. tStart += this.vertices[i].triangleCount;
  92337. this.vertices[i].triangleCount = 0;
  92338. }
  92339. var newReferences = new Array(this.triangles.length * 3);
  92340. for (i = 0; i < this.triangles.length; ++i) {
  92341. t = this.triangles[i];
  92342. for (j = 0; j < 3; ++j) {
  92343. v = t.vertices[j];
  92344. newReferences[v.triangleStart + v.triangleCount] = new Reference(j, i);
  92345. v.triangleCount++;
  92346. }
  92347. }
  92348. this.references = newReferences;
  92349. if (identifyBorders) {
  92350. this.identifyBorder();
  92351. }
  92352. };
  92353. QuadraticErrorSimplification.prototype.vertexError = function (q, point) {
  92354. var x = point.x;
  92355. var y = point.y;
  92356. var z = point.z;
  92357. 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
  92358. + 2 * q.data[5] * y * z + 2 * q.data[6] * y + q.data[7] * z * z + 2 * q.data[8] * z + q.data[9];
  92359. };
  92360. QuadraticErrorSimplification.prototype.calculateError = function (vertex1, vertex2, pointResult) {
  92361. var q = vertex1.q.add(vertex2.q);
  92362. var border = vertex1.isBorder && vertex2.isBorder;
  92363. var error = 0;
  92364. var qDet = q.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
  92365. if (qDet !== 0 && !border) {
  92366. if (!pointResult) {
  92367. pointResult = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  92368. }
  92369. pointResult.x = -1 / qDet * (q.det(1, 2, 3, 4, 5, 6, 5, 7, 8));
  92370. pointResult.y = 1 / qDet * (q.det(0, 2, 3, 1, 5, 6, 2, 7, 8));
  92371. pointResult.z = -1 / qDet * (q.det(0, 1, 3, 1, 4, 6, 2, 5, 8));
  92372. error = this.vertexError(q, pointResult);
  92373. }
  92374. else {
  92375. var p3 = (vertex1.position.add(vertex2.position)).divide(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](2, 2, 2));
  92376. //var norm3 = (vertex1.normal.add(vertex2.normal)).divide(new Vector3(2, 2, 2)).normalize();
  92377. var error1 = this.vertexError(q, vertex1.position);
  92378. var error2 = this.vertexError(q, vertex2.position);
  92379. var error3 = this.vertexError(q, p3);
  92380. error = Math.min(error1, error2, error3);
  92381. if (error === error1) {
  92382. if (pointResult) {
  92383. pointResult.copyFrom(vertex1.position);
  92384. }
  92385. }
  92386. else if (error === error2) {
  92387. if (pointResult) {
  92388. pointResult.copyFrom(vertex2.position);
  92389. }
  92390. }
  92391. else {
  92392. if (pointResult) {
  92393. pointResult.copyFrom(p3);
  92394. }
  92395. }
  92396. }
  92397. return error;
  92398. };
  92399. return QuadraticErrorSimplification;
  92400. }());
  92401. /***/ }),
  92402. /***/ "./Meshes/meshSimplificationSceneComponent.ts":
  92403. /*!****************************************************!*\
  92404. !*** ./Meshes/meshSimplificationSceneComponent.ts ***!
  92405. \****************************************************/
  92406. /*! exports provided: SimplicationQueueSceneComponent */
  92407. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92408. "use strict";
  92409. __webpack_require__.r(__webpack_exports__);
  92410. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return SimplicationQueueSceneComponent; });
  92411. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  92412. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  92413. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  92414. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  92415. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "simplificationQueue", {
  92416. get: function () {
  92417. if (!this._simplificationQueue) {
  92418. this._simplificationQueue = new _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationQueue"]();
  92419. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE);
  92420. if (!component) {
  92421. component = new SimplicationQueueSceneComponent(this);
  92422. this._addComponent(component);
  92423. }
  92424. }
  92425. return this._simplificationQueue;
  92426. },
  92427. set: function (value) {
  92428. this._simplificationQueue = value;
  92429. },
  92430. enumerable: true,
  92431. configurable: true
  92432. });
  92433. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].prototype.simplify = function (settings, parallelProcessing, simplificationType, successCallback) {
  92434. if (parallelProcessing === void 0) { parallelProcessing = true; }
  92435. if (simplificationType === void 0) { simplificationType = _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationType"].QUADRATIC; }
  92436. this.getScene().simplificationQueue.addTask({
  92437. settings: settings,
  92438. parallelProcessing: parallelProcessing,
  92439. mesh: this,
  92440. simplificationType: simplificationType,
  92441. successCallback: successCallback
  92442. });
  92443. return this;
  92444. };
  92445. /**
  92446. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  92447. * created in a scene
  92448. */
  92449. var SimplicationQueueSceneComponent = /** @class */ (function () {
  92450. /**
  92451. * Creates a new instance of the component for the given scene
  92452. * @param scene Defines the scene to register the component in
  92453. */
  92454. function SimplicationQueueSceneComponent(scene) {
  92455. /**
  92456. * The component name helpfull to identify the component in the list of scene components.
  92457. */
  92458. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE;
  92459. this.scene = scene;
  92460. }
  92461. /**
  92462. * Registers the component in a given scene
  92463. */
  92464. SimplicationQueueSceneComponent.prototype.register = function () {
  92465. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE, this, this._beforeCameraUpdate);
  92466. };
  92467. /**
  92468. * Rebuilds the elements related to this component in case of
  92469. * context lost for instance.
  92470. */
  92471. SimplicationQueueSceneComponent.prototype.rebuild = function () {
  92472. // Nothing to do for this component
  92473. };
  92474. /**
  92475. * Disposes the component and the associated ressources
  92476. */
  92477. SimplicationQueueSceneComponent.prototype.dispose = function () {
  92478. // Nothing to do for this component
  92479. };
  92480. SimplicationQueueSceneComponent.prototype._beforeCameraUpdate = function () {
  92481. if (this.scene._simplificationQueue && !this.scene._simplificationQueue.running) {
  92482. this.scene._simplificationQueue.executeNext();
  92483. }
  92484. };
  92485. return SimplicationQueueSceneComponent;
  92486. }());
  92487. /***/ }),
  92488. /***/ "./Meshes/polygonMesh.ts":
  92489. /*!*******************************!*\
  92490. !*** ./Meshes/polygonMesh.ts ***!
  92491. \*******************************/
  92492. /*! exports provided: Polygon, PolygonMeshBuilder */
  92493. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92494. "use strict";
  92495. __webpack_require__.r(__webpack_exports__);
  92496. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return Polygon; });
  92497. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return PolygonMeshBuilder; });
  92498. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  92499. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  92500. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  92501. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  92502. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  92503. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  92504. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  92505. /**
  92506. * Vector2 wth index property
  92507. */
  92508. var IndexedVector2 = /** @class */ (function (_super) {
  92509. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IndexedVector2, _super);
  92510. function IndexedVector2(original,
  92511. /** Index of the vector2 */
  92512. index) {
  92513. var _this = _super.call(this, original.x, original.y) || this;
  92514. _this.index = index;
  92515. return _this;
  92516. }
  92517. return IndexedVector2;
  92518. }(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"]));
  92519. /**
  92520. * Defines points to create a polygon
  92521. */
  92522. var PolygonPoints = /** @class */ (function () {
  92523. function PolygonPoints() {
  92524. this.elements = new Array();
  92525. }
  92526. PolygonPoints.prototype.add = function (originalPoints) {
  92527. var _this = this;
  92528. var result = new Array();
  92529. originalPoints.forEach(function (point) {
  92530. if (result.length === 0 || !point.equalsWithEpsilon(result[0])) {
  92531. var newPoint = new IndexedVector2(point, _this.elements.length);
  92532. result.push(newPoint);
  92533. _this.elements.push(newPoint);
  92534. }
  92535. });
  92536. return result;
  92537. };
  92538. PolygonPoints.prototype.computeBounds = function () {
  92539. var lmin = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  92540. var lmax = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  92541. this.elements.forEach(function (point) {
  92542. // x
  92543. if (point.x < lmin.x) {
  92544. lmin.x = point.x;
  92545. }
  92546. else if (point.x > lmax.x) {
  92547. lmax.x = point.x;
  92548. }
  92549. // y
  92550. if (point.y < lmin.y) {
  92551. lmin.y = point.y;
  92552. }
  92553. else if (point.y > lmax.y) {
  92554. lmax.y = point.y;
  92555. }
  92556. });
  92557. return {
  92558. min: lmin,
  92559. max: lmax,
  92560. width: lmax.x - lmin.x,
  92561. height: lmax.y - lmin.y
  92562. };
  92563. };
  92564. return PolygonPoints;
  92565. }());
  92566. /**
  92567. * Polygon
  92568. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  92569. */
  92570. var Polygon = /** @class */ (function () {
  92571. function Polygon() {
  92572. }
  92573. /**
  92574. * Creates a rectangle
  92575. * @param xmin bottom X coord
  92576. * @param ymin bottom Y coord
  92577. * @param xmax top X coord
  92578. * @param ymax top Y coord
  92579. * @returns points that make the resulting rectation
  92580. */
  92581. Polygon.Rectangle = function (xmin, ymin, xmax, ymax) {
  92582. return [
  92583. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymin),
  92584. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymin),
  92585. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymax),
  92586. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymax)
  92587. ];
  92588. };
  92589. /**
  92590. * Creates a circle
  92591. * @param radius radius of circle
  92592. * @param cx scale in x
  92593. * @param cy scale in y
  92594. * @param numberOfSides number of sides that make up the circle
  92595. * @returns points that make the resulting circle
  92596. */
  92597. Polygon.Circle = function (radius, cx, cy, numberOfSides) {
  92598. if (cx === void 0) { cx = 0; }
  92599. if (cy === void 0) { cy = 0; }
  92600. if (numberOfSides === void 0) { numberOfSides = 32; }
  92601. var result = new Array();
  92602. var angle = 0;
  92603. var increment = (Math.PI * 2) / numberOfSides;
  92604. for (var i = 0; i < numberOfSides; i++) {
  92605. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](cx + Math.cos(angle) * radius, cy + Math.sin(angle) * radius));
  92606. angle -= increment;
  92607. }
  92608. return result;
  92609. };
  92610. /**
  92611. * Creates a polygon from input string
  92612. * @param input Input polygon data
  92613. * @returns the parsed points
  92614. */
  92615. Polygon.Parse = function (input) {
  92616. var floats = input.split(/[^-+eE\.\d]+/).map(parseFloat).filter(function (val) { return (!isNaN(val)); });
  92617. var i, result = [];
  92618. for (i = 0; i < (floats.length & 0x7FFFFFFE); i += 2) {
  92619. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](floats[i], floats[i + 1]));
  92620. }
  92621. return result;
  92622. };
  92623. /**
  92624. * Starts building a polygon from x and y coordinates
  92625. * @param x x coordinate
  92626. * @param y y coordinate
  92627. * @returns the started path2
  92628. */
  92629. Polygon.StartingAt = function (x, y) {
  92630. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"].StartingAt(x, y);
  92631. };
  92632. return Polygon;
  92633. }());
  92634. /**
  92635. * Builds a polygon
  92636. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  92637. */
  92638. var PolygonMeshBuilder = /** @class */ (function () {
  92639. /**
  92640. * Creates a PolygonMeshBuilder
  92641. * @param name name of the builder
  92642. * @param contours Path of the polygon
  92643. * @param scene scene to add to when creating the mesh
  92644. * @param earcutInjection can be used to inject your own earcut reference
  92645. */
  92646. function PolygonMeshBuilder(name, contours, scene, earcutInjection) {
  92647. if (earcutInjection === void 0) { earcutInjection = earcut; }
  92648. this._points = new PolygonPoints();
  92649. this._outlinepoints = new PolygonPoints();
  92650. this._holes = new Array();
  92651. this._epoints = new Array();
  92652. this._eholes = new Array();
  92653. this.bjsEarcut = earcutInjection;
  92654. this._name = name;
  92655. this._scene = scene || _Engines_engine__WEBPACK_IMPORTED_MODULE_6__["Engine"].LastCreatedScene;
  92656. var points;
  92657. if (contours instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"]) {
  92658. points = contours.getPoints();
  92659. }
  92660. else {
  92661. points = contours;
  92662. }
  92663. this._addToepoint(points);
  92664. this._points.add(points);
  92665. this._outlinepoints.add(points);
  92666. if (typeof this.bjsEarcut === 'undefined') {
  92667. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Earcut was not found, the polygon will not be built.");
  92668. }
  92669. }
  92670. PolygonMeshBuilder.prototype._addToepoint = function (points) {
  92671. for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
  92672. var p = points_1[_i];
  92673. this._epoints.push(p.x, p.y);
  92674. }
  92675. };
  92676. /**
  92677. * Adds a whole within the polygon
  92678. * @param hole Array of points defining the hole
  92679. * @returns this
  92680. */
  92681. PolygonMeshBuilder.prototype.addHole = function (hole) {
  92682. this._points.add(hole);
  92683. var holepoints = new PolygonPoints();
  92684. holepoints.add(hole);
  92685. this._holes.push(holepoints);
  92686. this._eholes.push(this._epoints.length / 2);
  92687. this._addToepoint(hole);
  92688. return this;
  92689. };
  92690. /**
  92691. * Creates the polygon
  92692. * @param updatable If the mesh should be updatable
  92693. * @param depth The depth of the mesh created
  92694. * @returns the created mesh
  92695. */
  92696. PolygonMeshBuilder.prototype.build = function (updatable, depth) {
  92697. if (updatable === void 0) { updatable = false; }
  92698. if (depth === void 0) { depth = 0; }
  92699. var result = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this._name, this._scene);
  92700. var vertexData = this.buildVertexData(depth);
  92701. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, vertexData.positions, updatable);
  92702. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, vertexData.normals, updatable);
  92703. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind, vertexData.uvs, updatable);
  92704. result.setIndices(vertexData.indices);
  92705. return result;
  92706. };
  92707. /**
  92708. * Creates the polygon
  92709. * @param depth The depth of the mesh created
  92710. * @returns the created VertexData
  92711. */
  92712. PolygonMeshBuilder.prototype.buildVertexData = function (depth) {
  92713. var _this = this;
  92714. if (depth === void 0) { depth = 0; }
  92715. var result = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"]();
  92716. var normals = new Array();
  92717. var positions = new Array();
  92718. var uvs = new Array();
  92719. var bounds = this._points.computeBounds();
  92720. this._points.elements.forEach(function (p) {
  92721. normals.push(0, 1.0, 0);
  92722. positions.push(p.x, 0, p.y);
  92723. uvs.push((p.x - bounds.min.x) / bounds.width, (p.y - bounds.min.y) / bounds.height);
  92724. });
  92725. var indices = new Array();
  92726. var res = this.bjsEarcut(this._epoints, this._eholes, 2);
  92727. for (var i = 0; i < res.length; i++) {
  92728. indices.push(res[i]);
  92729. }
  92730. if (depth > 0) {
  92731. var positionscount = (positions.length / 3); //get the current pointcount
  92732. this._points.elements.forEach(function (p) {
  92733. normals.push(0, -1.0, 0);
  92734. positions.push(p.x, -depth, p.y);
  92735. uvs.push(1 - (p.x - bounds.min.x) / bounds.width, 1 - (p.y - bounds.min.y) / bounds.height);
  92736. });
  92737. var totalCount = indices.length;
  92738. for (var i = 0; i < totalCount; i += 3) {
  92739. var i0 = indices[i + 0];
  92740. var i1 = indices[i + 1];
  92741. var i2 = indices[i + 2];
  92742. indices.push(i2 + positionscount);
  92743. indices.push(i1 + positionscount);
  92744. indices.push(i0 + positionscount);
  92745. }
  92746. //Add the sides
  92747. this.addSide(positions, normals, uvs, indices, bounds, this._outlinepoints, depth, false);
  92748. this._holes.forEach(function (hole) {
  92749. _this.addSide(positions, normals, uvs, indices, bounds, hole, depth, true);
  92750. });
  92751. }
  92752. result.indices = indices;
  92753. result.positions = positions;
  92754. result.normals = normals;
  92755. result.uvs = uvs;
  92756. return result;
  92757. };
  92758. /**
  92759. * Adds a side to the polygon
  92760. * @param positions points that make the polygon
  92761. * @param normals normals of the polygon
  92762. * @param uvs uvs of the polygon
  92763. * @param indices indices of the polygon
  92764. * @param bounds bounds of the polygon
  92765. * @param points points of the polygon
  92766. * @param depth depth of the polygon
  92767. * @param flip flip of the polygon
  92768. */
  92769. PolygonMeshBuilder.prototype.addSide = function (positions, normals, uvs, indices, bounds, points, depth, flip) {
  92770. var StartIndex = positions.length / 3;
  92771. var ulength = 0;
  92772. for (var i = 0; i < points.elements.length; i++) {
  92773. var p = points.elements[i];
  92774. var p1;
  92775. if ((i + 1) > points.elements.length - 1) {
  92776. p1 = points.elements[0];
  92777. }
  92778. else {
  92779. p1 = points.elements[i + 1];
  92780. }
  92781. positions.push(p.x, 0, p.y);
  92782. positions.push(p.x, -depth, p.y);
  92783. positions.push(p1.x, 0, p1.y);
  92784. positions.push(p1.x, -depth, p1.y);
  92785. var v1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p.x, 0, p.y);
  92786. var v2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p1.x, 0, p1.y);
  92787. var v3 = v2.subtract(v1);
  92788. var v4 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1, 0);
  92789. var vn = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(v3, v4);
  92790. vn = vn.normalize();
  92791. uvs.push(ulength / bounds.width, 0);
  92792. uvs.push(ulength / bounds.width, 1);
  92793. ulength += v3.length();
  92794. uvs.push((ulength / bounds.width), 0);
  92795. uvs.push((ulength / bounds.width), 1);
  92796. if (!flip) {
  92797. normals.push(-vn.x, -vn.y, -vn.z);
  92798. normals.push(-vn.x, -vn.y, -vn.z);
  92799. normals.push(-vn.x, -vn.y, -vn.z);
  92800. normals.push(-vn.x, -vn.y, -vn.z);
  92801. indices.push(StartIndex);
  92802. indices.push(StartIndex + 1);
  92803. indices.push(StartIndex + 2);
  92804. indices.push(StartIndex + 1);
  92805. indices.push(StartIndex + 3);
  92806. indices.push(StartIndex + 2);
  92807. }
  92808. else {
  92809. normals.push(vn.x, vn.y, vn.z);
  92810. normals.push(vn.x, vn.y, vn.z);
  92811. normals.push(vn.x, vn.y, vn.z);
  92812. normals.push(vn.x, vn.y, vn.z);
  92813. indices.push(StartIndex);
  92814. indices.push(StartIndex + 2);
  92815. indices.push(StartIndex + 1);
  92816. indices.push(StartIndex + 1);
  92817. indices.push(StartIndex + 2);
  92818. indices.push(StartIndex + 3);
  92819. }
  92820. StartIndex += 4;
  92821. }
  92822. };
  92823. return PolygonMeshBuilder;
  92824. }());
  92825. /***/ }),
  92826. /***/ "./Meshes/subMesh.ts":
  92827. /*!***************************!*\
  92828. !*** ./Meshes/subMesh.ts ***!
  92829. \***************************/
  92830. /*! exports provided: BaseSubMesh, SubMesh */
  92831. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92832. "use strict";
  92833. __webpack_require__.r(__webpack_exports__);
  92834. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return BaseSubMesh; });
  92835. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return SubMesh; });
  92836. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  92837. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  92838. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  92839. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  92840. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  92841. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  92842. /**
  92843. * Base class for submeshes
  92844. */
  92845. var BaseSubMesh = /** @class */ (function () {
  92846. function BaseSubMesh() {
  92847. }
  92848. Object.defineProperty(BaseSubMesh.prototype, "effect", {
  92849. /**
  92850. * Gets associated effect
  92851. */
  92852. get: function () {
  92853. return this._materialEffect;
  92854. },
  92855. enumerable: true,
  92856. configurable: true
  92857. });
  92858. /**
  92859. * Sets associated effect (effect used to render this submesh)
  92860. * @param effect defines the effect to associate with
  92861. * @param defines defines the set of defines used to compile this effect
  92862. */
  92863. BaseSubMesh.prototype.setEffect = function (effect, defines) {
  92864. if (defines === void 0) { defines = null; }
  92865. if (this._materialEffect === effect) {
  92866. if (!effect) {
  92867. this._materialDefines = null;
  92868. }
  92869. return;
  92870. }
  92871. this._materialDefines = defines;
  92872. this._materialEffect = effect;
  92873. };
  92874. return BaseSubMesh;
  92875. }());
  92876. /**
  92877. * Defines a subdivision inside a mesh
  92878. */
  92879. var SubMesh = /** @class */ (function (_super) {
  92880. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SubMesh, _super);
  92881. /**
  92882. * Creates a new submesh
  92883. * @param materialIndex defines the material index to use
  92884. * @param verticesStart defines vertex index start
  92885. * @param verticesCount defines vertices count
  92886. * @param indexStart defines index start
  92887. * @param indexCount defines indices count
  92888. * @param mesh defines the parent mesh
  92889. * @param renderingMesh defines an optional rendering mesh
  92890. * @param createBoundingBox defines if bounding box should be created for this submesh
  92891. */
  92892. function SubMesh(
  92893. /** the material index to use */
  92894. materialIndex,
  92895. /** vertex index start */
  92896. verticesStart,
  92897. /** vertices count */
  92898. verticesCount,
  92899. /** index start */
  92900. indexStart,
  92901. /** indices count */
  92902. indexCount, mesh, renderingMesh, createBoundingBox) {
  92903. if (createBoundingBox === void 0) { createBoundingBox = true; }
  92904. var _this = _super.call(this) || this;
  92905. _this.materialIndex = materialIndex;
  92906. _this.verticesStart = verticesStart;
  92907. _this.verticesCount = verticesCount;
  92908. _this.indexStart = indexStart;
  92909. _this.indexCount = indexCount;
  92910. /** @hidden */
  92911. _this._renderId = 0;
  92912. _this._mesh = mesh;
  92913. _this._renderingMesh = renderingMesh || mesh;
  92914. mesh.subMeshes.push(_this);
  92915. _this._trianglePlanes = [];
  92916. _this._id = mesh.subMeshes.length - 1;
  92917. if (createBoundingBox) {
  92918. _this.refreshBoundingInfo();
  92919. mesh.computeWorldMatrix(true);
  92920. }
  92921. return _this;
  92922. }
  92923. /**
  92924. * Add a new submesh to a mesh
  92925. * @param materialIndex defines the material index to use
  92926. * @param verticesStart defines vertex index start
  92927. * @param verticesCount defines vertices count
  92928. * @param indexStart defines index start
  92929. * @param indexCount defines indices count
  92930. * @param mesh defines the parent mesh
  92931. * @param renderingMesh defines an optional rendering mesh
  92932. * @param createBoundingBox defines if bounding box should be created for this submesh
  92933. * @returns the new submesh
  92934. */
  92935. SubMesh.AddToMesh = function (materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox) {
  92936. if (createBoundingBox === void 0) { createBoundingBox = true; }
  92937. return new SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox);
  92938. };
  92939. Object.defineProperty(SubMesh.prototype, "IsGlobal", {
  92940. /**
  92941. * Returns true if this submesh covers the entire parent mesh
  92942. * @ignorenaming
  92943. */
  92944. get: function () {
  92945. return (this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices());
  92946. },
  92947. enumerable: true,
  92948. configurable: true
  92949. });
  92950. /**
  92951. * Returns the submesh BoudingInfo object
  92952. * @returns current bounding info (or mesh's one if the submesh is global)
  92953. */
  92954. SubMesh.prototype.getBoundingInfo = function () {
  92955. if (this.IsGlobal) {
  92956. return this._mesh.getBoundingInfo();
  92957. }
  92958. return this._boundingInfo;
  92959. };
  92960. /**
  92961. * Sets the submesh BoundingInfo
  92962. * @param boundingInfo defines the new bounding info to use
  92963. * @returns the SubMesh
  92964. */
  92965. SubMesh.prototype.setBoundingInfo = function (boundingInfo) {
  92966. this._boundingInfo = boundingInfo;
  92967. return this;
  92968. };
  92969. /**
  92970. * Returns the mesh of the current submesh
  92971. * @return the parent mesh
  92972. */
  92973. SubMesh.prototype.getMesh = function () {
  92974. return this._mesh;
  92975. };
  92976. /**
  92977. * Returns the rendering mesh of the submesh
  92978. * @returns the rendering mesh (could be different from parent mesh)
  92979. */
  92980. SubMesh.prototype.getRenderingMesh = function () {
  92981. return this._renderingMesh;
  92982. };
  92983. /**
  92984. * Returns the submesh material
  92985. * @returns null or the current material
  92986. */
  92987. SubMesh.prototype.getMaterial = function () {
  92988. var rootMaterial = this._renderingMesh.material;
  92989. if (rootMaterial === null || rootMaterial === undefined) {
  92990. return this._mesh.getScene().defaultMaterial;
  92991. }
  92992. else if (rootMaterial.getSubMaterial) {
  92993. var multiMaterial = rootMaterial;
  92994. var effectiveMaterial = multiMaterial.getSubMaterial(this.materialIndex);
  92995. if (this._currentMaterial !== effectiveMaterial) {
  92996. this._currentMaterial = effectiveMaterial;
  92997. this._materialDefines = null;
  92998. }
  92999. return effectiveMaterial;
  93000. }
  93001. return rootMaterial;
  93002. };
  93003. // Methods
  93004. /**
  93005. * Sets a new updated BoundingInfo object to the submesh
  93006. * @returns the SubMesh
  93007. */
  93008. SubMesh.prototype.refreshBoundingInfo = function () {
  93009. this._lastColliderWorldVertices = null;
  93010. if (this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) {
  93011. return this;
  93012. }
  93013. var data = this._renderingMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  93014. if (!data) {
  93015. this._boundingInfo = this._mesh.getBoundingInfo();
  93016. return this;
  93017. }
  93018. var indices = this._renderingMesh.getIndices();
  93019. var extend;
  93020. //is this the only submesh?
  93021. if (this.indexStart === 0 && this.indexCount === indices.length) {
  93022. var boundingInfo = this._renderingMesh.getBoundingInfo();
  93023. //the rendering mesh's bounding info can be used, it is the standard submesh for all indices.
  93024. extend = { minimum: boundingInfo.minimum.clone(), maximum: boundingInfo.maximum.clone() };
  93025. }
  93026. else {
  93027. extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);
  93028. }
  93029. if (this._boundingInfo) {
  93030. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  93031. }
  93032. else {
  93033. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](extend.minimum, extend.maximum);
  93034. }
  93035. return this;
  93036. };
  93037. /** @hidden */
  93038. SubMesh.prototype._checkCollision = function (collider) {
  93039. var boundingInfo = this.getBoundingInfo();
  93040. return boundingInfo._checkCollision(collider);
  93041. };
  93042. /**
  93043. * Updates the submesh BoundingInfo
  93044. * @param world defines the world matrix to use to update the bounding info
  93045. * @returns the submesh
  93046. */
  93047. SubMesh.prototype.updateBoundingInfo = function (world) {
  93048. var boundingInfo = this.getBoundingInfo();
  93049. if (!boundingInfo) {
  93050. this.refreshBoundingInfo();
  93051. boundingInfo = this.getBoundingInfo();
  93052. }
  93053. boundingInfo.update(world);
  93054. return this;
  93055. };
  93056. /**
  93057. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  93058. * @param frustumPlanes defines the frustum planes
  93059. * @returns true if the submesh is intersecting with the frustum
  93060. */
  93061. SubMesh.prototype.isInFrustum = function (frustumPlanes) {
  93062. var boundingInfo = this.getBoundingInfo();
  93063. if (!boundingInfo) {
  93064. return false;
  93065. }
  93066. return boundingInfo.isInFrustum(frustumPlanes, this._mesh.cullingStrategy);
  93067. };
  93068. /**
  93069. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  93070. * @param frustumPlanes defines the frustum planes
  93071. * @returns true if the submesh is inside the frustum
  93072. */
  93073. SubMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  93074. var boundingInfo = this.getBoundingInfo();
  93075. if (!boundingInfo) {
  93076. return false;
  93077. }
  93078. return boundingInfo.isCompletelyInFrustum(frustumPlanes);
  93079. };
  93080. /**
  93081. * Renders the submesh
  93082. * @param enableAlphaMode defines if alpha needs to be used
  93083. * @returns the submesh
  93084. */
  93085. SubMesh.prototype.render = function (enableAlphaMode) {
  93086. this._renderingMesh.render(this, enableAlphaMode);
  93087. return this;
  93088. };
  93089. /**
  93090. * @hidden
  93091. */
  93092. SubMesh.prototype._getLinesIndexBuffer = function (indices, engine) {
  93093. if (!this._linesIndexBuffer) {
  93094. var linesIndices = [];
  93095. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  93096. linesIndices.push(indices[index], indices[index + 1], indices[index + 1], indices[index + 2], indices[index + 2], indices[index]);
  93097. }
  93098. this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);
  93099. this._linesIndexCount = linesIndices.length;
  93100. }
  93101. return this._linesIndexBuffer;
  93102. };
  93103. /**
  93104. * Checks if the submesh intersects with a ray
  93105. * @param ray defines the ray to test
  93106. * @returns true is the passed ray intersects the submesh bounding box
  93107. */
  93108. SubMesh.prototype.canIntersects = function (ray) {
  93109. var boundingInfo = this.getBoundingInfo();
  93110. if (!boundingInfo) {
  93111. return false;
  93112. }
  93113. return ray.intersectsBox(boundingInfo.boundingBox);
  93114. };
  93115. /**
  93116. * Intersects current submesh with a ray
  93117. * @param ray defines the ray to test
  93118. * @param positions defines mesh's positions array
  93119. * @param indices defines mesh's indices array
  93120. * @param fastCheck defines if only bounding info should be used
  93121. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93122. * @returns intersection info or null if no intersection
  93123. */
  93124. SubMesh.prototype.intersects = function (ray, positions, indices, fastCheck, trianglePredicate) {
  93125. var material = this.getMaterial();
  93126. if (!material) {
  93127. return null;
  93128. }
  93129. switch (material.fillMode) {
  93130. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_PointListDrawMode:
  93131. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineListDrawMode:
  93132. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineLoopDrawMode:
  93133. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineStripDrawMode:
  93134. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleFanDrawMode:
  93135. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleStripDrawMode:
  93136. return null;
  93137. }
  93138. // LineMesh first as it's also a Mesh...
  93139. if (this._mesh.getClassName() === "InstancedLinesMesh" || this._mesh.getClassName() === "LinesMesh") {
  93140. return this._intersectLines(ray, positions, indices, this._mesh.intersectionThreshold, fastCheck);
  93141. }
  93142. return this._intersectTriangles(ray, positions, indices, fastCheck, trianglePredicate);
  93143. };
  93144. /** @hidden */
  93145. SubMesh.prototype._intersectLines = function (ray, positions, indices, intersectionThreshold, fastCheck) {
  93146. var intersectInfo = null;
  93147. // Line test
  93148. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 2) {
  93149. var p0 = positions[indices[index]];
  93150. var p1 = positions[indices[index + 1]];
  93151. var length = ray.intersectionSegment(p0, p1, intersectionThreshold);
  93152. if (length < 0) {
  93153. continue;
  93154. }
  93155. if (fastCheck || !intersectInfo || length < intersectInfo.distance) {
  93156. intersectInfo = new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](null, null, length);
  93157. intersectInfo.faceId = index / 2;
  93158. if (fastCheck) {
  93159. break;
  93160. }
  93161. }
  93162. }
  93163. return intersectInfo;
  93164. };
  93165. /** @hidden */
  93166. SubMesh.prototype._intersectTriangles = function (ray, positions, indices, fastCheck, trianglePredicate) {
  93167. var intersectInfo = null;
  93168. // Triangles test
  93169. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  93170. var p0 = positions[indices[index]];
  93171. var p1 = positions[indices[index + 1]];
  93172. var p2 = positions[indices[index + 2]];
  93173. if (trianglePredicate && !trianglePredicate(p0, p1, p2, ray)) {
  93174. continue;
  93175. }
  93176. var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
  93177. if (currentIntersectInfo) {
  93178. if (currentIntersectInfo.distance < 0) {
  93179. continue;
  93180. }
  93181. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  93182. intersectInfo = currentIntersectInfo;
  93183. intersectInfo.faceId = index / 3;
  93184. if (fastCheck) {
  93185. break;
  93186. }
  93187. }
  93188. }
  93189. }
  93190. return intersectInfo;
  93191. };
  93192. /** @hidden */
  93193. SubMesh.prototype._rebuild = function () {
  93194. if (this._linesIndexBuffer) {
  93195. this._linesIndexBuffer = null;
  93196. }
  93197. };
  93198. // Clone
  93199. /**
  93200. * Creates a new submesh from the passed mesh
  93201. * @param newMesh defines the new hosting mesh
  93202. * @param newRenderingMesh defines an optional rendering mesh
  93203. * @returns the new submesh
  93204. */
  93205. SubMesh.prototype.clone = function (newMesh, newRenderingMesh) {
  93206. var result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);
  93207. if (!this.IsGlobal) {
  93208. var boundingInfo = this.getBoundingInfo();
  93209. if (!boundingInfo) {
  93210. return result;
  93211. }
  93212. result._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](boundingInfo.minimum, boundingInfo.maximum);
  93213. }
  93214. return result;
  93215. };
  93216. // Dispose
  93217. /**
  93218. * Release associated resources
  93219. */
  93220. SubMesh.prototype.dispose = function () {
  93221. if (this._linesIndexBuffer) {
  93222. this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer);
  93223. this._linesIndexBuffer = null;
  93224. }
  93225. // Remove from mesh
  93226. var index = this._mesh.subMeshes.indexOf(this);
  93227. this._mesh.subMeshes.splice(index, 1);
  93228. };
  93229. /**
  93230. * Gets the class name
  93231. * @returns the string "SubMesh".
  93232. */
  93233. SubMesh.prototype.getClassName = function () {
  93234. return "SubMesh";
  93235. };
  93236. // Statics
  93237. /**
  93238. * Creates a new submesh from indices data
  93239. * @param materialIndex the index of the main mesh material
  93240. * @param startIndex the index where to start the copy in the mesh indices array
  93241. * @param indexCount the number of indices to copy then from the startIndex
  93242. * @param mesh the main mesh to create the submesh from
  93243. * @param renderingMesh the optional rendering mesh
  93244. * @returns a new submesh
  93245. */
  93246. SubMesh.CreateFromIndices = function (materialIndex, startIndex, indexCount, mesh, renderingMesh) {
  93247. var minVertexIndex = Number.MAX_VALUE;
  93248. var maxVertexIndex = -Number.MAX_VALUE;
  93249. var whatWillRender = (renderingMesh || mesh);
  93250. var indices = whatWillRender.getIndices();
  93251. for (var index = startIndex; index < startIndex + indexCount; index++) {
  93252. var vertexIndex = indices[index];
  93253. if (vertexIndex < minVertexIndex) {
  93254. minVertexIndex = vertexIndex;
  93255. }
  93256. if (vertexIndex > maxVertexIndex) {
  93257. maxVertexIndex = vertexIndex;
  93258. }
  93259. }
  93260. return new SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh);
  93261. };
  93262. return SubMesh;
  93263. }(BaseSubMesh));
  93264. /***/ }),
  93265. /***/ "./Meshes/trailMesh.ts":
  93266. /*!*****************************!*\
  93267. !*** ./Meshes/trailMesh.ts ***!
  93268. \*****************************/
  93269. /*! exports provided: TrailMesh */
  93270. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93271. "use strict";
  93272. __webpack_require__.r(__webpack_exports__);
  93273. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return TrailMesh; });
  93274. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  93275. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  93276. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  93277. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  93278. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  93279. /**
  93280. * Class used to create a trail following a mesh
  93281. */
  93282. var TrailMesh = /** @class */ (function (_super) {
  93283. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TrailMesh, _super);
  93284. /**
  93285. * @constructor
  93286. * @param name The value used by scene.getMeshByName() to do a lookup.
  93287. * @param generator The mesh to generate a trail.
  93288. * @param scene The scene to add this mesh to.
  93289. * @param diameter Diameter of trailing mesh. Default is 1.
  93290. * @param length Length of trailing mesh. Default is 60.
  93291. * @param autoStart Automatically start trailing mesh. Default true.
  93292. */
  93293. function TrailMesh(name, generator, scene, diameter, length, autoStart) {
  93294. if (diameter === void 0) { diameter = 1; }
  93295. if (length === void 0) { length = 60; }
  93296. if (autoStart === void 0) { autoStart = true; }
  93297. var _this = _super.call(this, name, scene) || this;
  93298. _this._sectionPolygonPointsCount = 4;
  93299. _this._running = false;
  93300. _this._autoStart = autoStart;
  93301. _this._generator = generator;
  93302. _this._diameter = diameter;
  93303. _this._length = length;
  93304. _this._sectionVectors = [];
  93305. _this._sectionNormalVectors = [];
  93306. for (var i = 0; i < _this._sectionPolygonPointsCount; i++) {
  93307. _this._sectionVectors[i] = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  93308. _this._sectionNormalVectors[i] = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  93309. }
  93310. _this._createMesh();
  93311. return _this;
  93312. }
  93313. /**
  93314. * "TrailMesh"
  93315. * @returns "TrailMesh"
  93316. */
  93317. TrailMesh.prototype.getClassName = function () {
  93318. return "TrailMesh";
  93319. };
  93320. TrailMesh.prototype._createMesh = function () {
  93321. var data = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__["VertexData"]();
  93322. var positions = [];
  93323. var normals = [];
  93324. var indices = [];
  93325. var meshCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  93326. if (this._generator._boundingInfo) {
  93327. meshCenter = this._generator._boundingInfo.boundingBox.centerWorld;
  93328. }
  93329. var alpha = 2 * Math.PI / this._sectionPolygonPointsCount;
  93330. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  93331. positions.push(meshCenter.x + Math.cos(i * alpha) * this._diameter, meshCenter.y + Math.sin(i * alpha) * this._diameter, meshCenter.z);
  93332. }
  93333. for (var i = 1; i <= this._length; i++) {
  93334. for (var j = 0; j < this._sectionPolygonPointsCount; j++) {
  93335. positions.push(meshCenter.x + Math.cos(j * alpha) * this._diameter, meshCenter.y + Math.sin(j * alpha) * this._diameter, meshCenter.z);
  93336. }
  93337. var l = positions.length / 3 - 2 * this._sectionPolygonPointsCount;
  93338. for (var j = 0; j < this._sectionPolygonPointsCount - 1; j++) {
  93339. indices.push(l + j, l + j + this._sectionPolygonPointsCount, l + j + this._sectionPolygonPointsCount + 1);
  93340. indices.push(l + j, l + j + this._sectionPolygonPointsCount + 1, l + j + 1);
  93341. }
  93342. indices.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount - 1 + this._sectionPolygonPointsCount, l + this._sectionPolygonPointsCount);
  93343. indices.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount, l);
  93344. }
  93345. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__["VertexData"].ComputeNormals(positions, indices, normals);
  93346. data.positions = positions;
  93347. data.normals = normals;
  93348. data.indices = indices;
  93349. data.applyToMesh(this, true);
  93350. if (this._autoStart) {
  93351. this.start();
  93352. }
  93353. };
  93354. /**
  93355. * Start trailing mesh.
  93356. */
  93357. TrailMesh.prototype.start = function () {
  93358. var _this = this;
  93359. if (!this._running) {
  93360. this._running = true;
  93361. this._beforeRenderObserver = this.getScene().onBeforeRenderObservable.add(function () {
  93362. _this.update();
  93363. });
  93364. }
  93365. };
  93366. /**
  93367. * Stop trailing mesh.
  93368. */
  93369. TrailMesh.prototype.stop = function () {
  93370. if (this._beforeRenderObserver && this._running) {
  93371. this._running = false;
  93372. this.getScene().onBeforeRenderObservable.remove(this._beforeRenderObserver);
  93373. }
  93374. };
  93375. /**
  93376. * Update trailing mesh geometry.
  93377. */
  93378. TrailMesh.prototype.update = function () {
  93379. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind);
  93380. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind);
  93381. var wm = this._generator.getWorldMatrix();
  93382. if (positions && normals) {
  93383. for (var i = 3 * this._sectionPolygonPointsCount; i < positions.length; i++) {
  93384. positions[i - 3 * this._sectionPolygonPointsCount] = positions[i] - normals[i] / this._length * this._diameter;
  93385. }
  93386. for (var i = 3 * this._sectionPolygonPointsCount; i < normals.length; i++) {
  93387. normals[i - 3 * this._sectionPolygonPointsCount] = normals[i];
  93388. }
  93389. var l = positions.length - 3 * this._sectionPolygonPointsCount;
  93390. var alpha = 2 * Math.PI / this._sectionPolygonPointsCount;
  93391. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  93392. this._sectionVectors[i].copyFromFloats(Math.cos(i * alpha) * this._diameter, Math.sin(i * alpha) * this._diameter, 0);
  93393. this._sectionNormalVectors[i].copyFromFloats(Math.cos(i * alpha), Math.sin(i * alpha), 0);
  93394. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._sectionVectors[i], wm, this._sectionVectors[i]);
  93395. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this._sectionNormalVectors[i], wm, this._sectionNormalVectors[i]);
  93396. }
  93397. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  93398. positions[l + 3 * i] = this._sectionVectors[i].x;
  93399. positions[l + 3 * i + 1] = this._sectionVectors[i].y;
  93400. positions[l + 3 * i + 2] = this._sectionVectors[i].z;
  93401. normals[l + 3 * i] = this._sectionNormalVectors[i].x;
  93402. normals[l + 3 * i + 1] = this._sectionNormalVectors[i].y;
  93403. normals[l + 3 * i + 2] = this._sectionNormalVectors[i].z;
  93404. }
  93405. this.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, positions, true, false);
  93406. this.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, normals, true, false);
  93407. }
  93408. };
  93409. /**
  93410. * Returns a new TrailMesh object.
  93411. * @param name is a string, the name given to the new mesh
  93412. * @param newGenerator use new generator object for cloned trail mesh
  93413. * @returns a new mesh
  93414. */
  93415. TrailMesh.prototype.clone = function (name, newGenerator) {
  93416. if (name === void 0) { name = ""; }
  93417. return new TrailMesh(name, (newGenerator === undefined ? this._generator : newGenerator), this.getScene(), this._diameter, this._length, this._autoStart);
  93418. };
  93419. /**
  93420. * Serializes this trail mesh
  93421. * @param serializationObject object to write serialization to
  93422. */
  93423. TrailMesh.prototype.serialize = function (serializationObject) {
  93424. _super.prototype.serialize.call(this, serializationObject);
  93425. };
  93426. /**
  93427. * Parses a serialized trail mesh
  93428. * @param parsedMesh the serialized mesh
  93429. * @param scene the scene to create the trail mesh in
  93430. * @returns the created trail mesh
  93431. */
  93432. TrailMesh.Parse = function (parsedMesh, scene) {
  93433. return new TrailMesh(parsedMesh.name, parsedMesh._generator, scene, parsedMesh._diameter, parsedMesh._length, parsedMesh._autoStart);
  93434. };
  93435. return TrailMesh;
  93436. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]));
  93437. /***/ }),
  93438. /***/ "./Meshes/transformNode.ts":
  93439. /*!*********************************!*\
  93440. !*** ./Meshes/transformNode.ts ***!
  93441. \*********************************/
  93442. /*! exports provided: TransformNode */
  93443. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93444. "use strict";
  93445. __webpack_require__.r(__webpack_exports__);
  93446. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return TransformNode; });
  93447. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  93448. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  93449. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  93450. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  93451. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  93452. /**
  93453. * 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.
  93454. * @see https://doc.babylonjs.com/how_to/transformnode
  93455. */
  93456. var TransformNode = /** @class */ (function (_super) {
  93457. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TransformNode, _super);
  93458. function TransformNode(name, scene, isPure) {
  93459. if (scene === void 0) { scene = null; }
  93460. if (isPure === void 0) { isPure = true; }
  93461. var _this = _super.call(this, name, scene) || this;
  93462. _this._forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  93463. _this._forwardInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  93464. _this._up = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0);
  93465. _this._right = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  93466. _this._rightInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-1, 0, 0);
  93467. // Properties
  93468. _this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  93469. _this._rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  93470. _this._scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].One();
  93471. _this._isDirty = false;
  93472. /**
  93473. * Set the billboard mode. Default is 0.
  93474. *
  93475. * | Value | Type | Description |
  93476. * | --- | --- | --- |
  93477. * | 0 | BILLBOARDMODE_NONE | |
  93478. * | 1 | BILLBOARDMODE_X | |
  93479. * | 2 | BILLBOARDMODE_Y | |
  93480. * | 4 | BILLBOARDMODE_Z | |
  93481. * | 7 | BILLBOARDMODE_ALL | |
  93482. *
  93483. */
  93484. _this.billboardMode = TransformNode.BILLBOARDMODE_NONE;
  93485. /**
  93486. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  93487. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  93488. */
  93489. _this.preserveParentRotationForBillboard = false;
  93490. /**
  93491. * 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
  93492. */
  93493. _this.scalingDeterminant = 1;
  93494. /**
  93495. * Sets the distance of the object to max, often used by skybox
  93496. */
  93497. _this.infiniteDistance = false;
  93498. /**
  93499. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  93500. * By default the system will update normals to compensate
  93501. */
  93502. _this.ignoreNonUniformScaling = false;
  93503. /** @hidden */
  93504. _this._localMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  93505. _this._absolutePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  93506. _this._pivotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  93507. _this._postMultiplyPivotMatrix = false;
  93508. _this._tempMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  93509. _this._tempMatrix2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  93510. _this._isWorldMatrixFrozen = false;
  93511. /** @hidden */
  93512. _this._indexInSceneTransformNodesArray = -1;
  93513. /**
  93514. * An event triggered after the world matrix is updated
  93515. */
  93516. _this.onAfterWorldMatrixUpdateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  93517. _this._nonUniformScaling = false;
  93518. if (isPure) {
  93519. _this.getScene().addTransformNode(_this);
  93520. }
  93521. return _this;
  93522. }
  93523. /**
  93524. * Gets a string identifying the name of the class
  93525. * @returns "TransformNode" string
  93526. */
  93527. TransformNode.prototype.getClassName = function () {
  93528. return "TransformNode";
  93529. };
  93530. Object.defineProperty(TransformNode.prototype, "position", {
  93531. /**
  93532. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  93533. */
  93534. get: function () {
  93535. return this._position;
  93536. },
  93537. set: function (newPosition) {
  93538. this._position = newPosition;
  93539. this._isDirty = true;
  93540. },
  93541. enumerable: true,
  93542. configurable: true
  93543. });
  93544. Object.defineProperty(TransformNode.prototype, "rotation", {
  93545. /**
  93546. * 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)).
  93547. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  93548. */
  93549. get: function () {
  93550. return this._rotation;
  93551. },
  93552. set: function (newRotation) {
  93553. this._rotation = newRotation;
  93554. this._isDirty = true;
  93555. },
  93556. enumerable: true,
  93557. configurable: true
  93558. });
  93559. Object.defineProperty(TransformNode.prototype, "scaling", {
  93560. /**
  93561. * 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)).
  93562. */
  93563. get: function () {
  93564. return this._scaling;
  93565. },
  93566. set: function (newScaling) {
  93567. this._scaling = newScaling;
  93568. this._isDirty = true;
  93569. },
  93570. enumerable: true,
  93571. configurable: true
  93572. });
  93573. Object.defineProperty(TransformNode.prototype, "rotationQuaternion", {
  93574. /**
  93575. * 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).
  93576. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  93577. */
  93578. get: function () {
  93579. return this._rotationQuaternion;
  93580. },
  93581. set: function (quaternion) {
  93582. this._rotationQuaternion = quaternion;
  93583. //reset the rotation vector.
  93584. if (quaternion) {
  93585. this.rotation.setAll(0.0);
  93586. }
  93587. },
  93588. enumerable: true,
  93589. configurable: true
  93590. });
  93591. Object.defineProperty(TransformNode.prototype, "forward", {
  93592. /**
  93593. * The forward direction of that transform in world space.
  93594. */
  93595. get: function () {
  93596. 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()));
  93597. },
  93598. enumerable: true,
  93599. configurable: true
  93600. });
  93601. Object.defineProperty(TransformNode.prototype, "up", {
  93602. /**
  93603. * The up direction of that transform in world space.
  93604. */
  93605. get: function () {
  93606. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this._up, this.getWorldMatrix()));
  93607. },
  93608. enumerable: true,
  93609. configurable: true
  93610. });
  93611. Object.defineProperty(TransformNode.prototype, "right", {
  93612. /**
  93613. * The right direction of that transform in world space.
  93614. */
  93615. get: function () {
  93616. 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()));
  93617. },
  93618. enumerable: true,
  93619. configurable: true
  93620. });
  93621. /**
  93622. * Copies the parameter passed Matrix into the mesh Pose matrix.
  93623. * @param matrix the matrix to copy the pose from
  93624. * @returns this TransformNode.
  93625. */
  93626. TransformNode.prototype.updatePoseMatrix = function (matrix) {
  93627. this._poseMatrix.copyFrom(matrix);
  93628. return this;
  93629. };
  93630. /**
  93631. * Returns the mesh Pose matrix.
  93632. * @returns the pose matrix
  93633. */
  93634. TransformNode.prototype.getPoseMatrix = function () {
  93635. return this._poseMatrix;
  93636. };
  93637. /** @hidden */
  93638. TransformNode.prototype._isSynchronized = function () {
  93639. if (this._isDirty) {
  93640. return false;
  93641. }
  93642. if (this.billboardMode !== this._cache.billboardMode || this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  93643. return false;
  93644. }
  93645. if (this._cache.pivotMatrixUpdated) {
  93646. return false;
  93647. }
  93648. if (this.infiniteDistance) {
  93649. return false;
  93650. }
  93651. if (!this._cache.position.equals(this._position)) {
  93652. return false;
  93653. }
  93654. if (this._rotationQuaternion) {
  93655. if (!this._cache.rotationQuaternion.equals(this._rotationQuaternion)) {
  93656. return false;
  93657. }
  93658. }
  93659. if (!this._cache.rotation.equals(this._rotation)) {
  93660. return false;
  93661. }
  93662. if (!this._cache.scaling.equals(this._scaling)) {
  93663. return false;
  93664. }
  93665. return true;
  93666. };
  93667. /** @hidden */
  93668. TransformNode.prototype._initCache = function () {
  93669. _super.prototype._initCache.call(this);
  93670. this._cache.localMatrixUpdated = false;
  93671. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  93672. this._cache.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  93673. this._cache.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  93674. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](0, 0, 0, 0);
  93675. this._cache.billboardMode = -1;
  93676. this._cache.infiniteDistance = false;
  93677. };
  93678. /**
  93679. * Flag the transform node as dirty (Forcing it to update everything)
  93680. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  93681. * @returns this transform node
  93682. */
  93683. TransformNode.prototype.markAsDirty = function (property) {
  93684. if (property === "rotation") {
  93685. this.rotationQuaternion = null;
  93686. }
  93687. this._currentRenderId = Number.MAX_VALUE;
  93688. this._isDirty = true;
  93689. return this;
  93690. };
  93691. Object.defineProperty(TransformNode.prototype, "absolutePosition", {
  93692. /**
  93693. * Returns the current mesh absolute position.
  93694. * Returns a Vector3.
  93695. */
  93696. get: function () {
  93697. return this._absolutePosition;
  93698. },
  93699. enumerable: true,
  93700. configurable: true
  93701. });
  93702. /**
  93703. * Sets a new matrix to apply before all other transformation
  93704. * @param matrix defines the transform matrix
  93705. * @returns the current TransformNode
  93706. */
  93707. TransformNode.prototype.setPreTransformMatrix = function (matrix) {
  93708. return this.setPivotMatrix(matrix, false);
  93709. };
  93710. /**
  93711. * Sets a new pivot matrix to the current node
  93712. * @param matrix defines the new pivot matrix to use
  93713. * @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
  93714. * @returns the current TransformNode
  93715. */
  93716. TransformNode.prototype.setPivotMatrix = function (matrix, postMultiplyPivotMatrix) {
  93717. if (postMultiplyPivotMatrix === void 0) { postMultiplyPivotMatrix = true; }
  93718. this._pivotMatrix.copyFrom(matrix);
  93719. this._cache.pivotMatrixUpdated = true;
  93720. this._postMultiplyPivotMatrix = postMultiplyPivotMatrix;
  93721. if (this._postMultiplyPivotMatrix) {
  93722. if (!this._pivotMatrixInverse) {
  93723. this._pivotMatrixInverse = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._pivotMatrix);
  93724. }
  93725. else {
  93726. this._pivotMatrix.invertToRef(this._pivotMatrixInverse);
  93727. }
  93728. }
  93729. return this;
  93730. };
  93731. /**
  93732. * Returns the mesh pivot matrix.
  93733. * Default : Identity.
  93734. * @returns the matrix
  93735. */
  93736. TransformNode.prototype.getPivotMatrix = function () {
  93737. return this._pivotMatrix;
  93738. };
  93739. /**
  93740. * Prevents the World matrix to be computed any longer.
  93741. * @returns the TransformNode.
  93742. */
  93743. TransformNode.prototype.freezeWorldMatrix = function () {
  93744. this._isWorldMatrixFrozen = false; // no guarantee world is not already frozen, switch off temporarily
  93745. this.computeWorldMatrix(true);
  93746. this._isWorldMatrixFrozen = true;
  93747. return this;
  93748. };
  93749. /**
  93750. * Allows back the World matrix computation.
  93751. * @returns the TransformNode.
  93752. */
  93753. TransformNode.prototype.unfreezeWorldMatrix = function () {
  93754. this._isWorldMatrixFrozen = false;
  93755. this.computeWorldMatrix(true);
  93756. return this;
  93757. };
  93758. Object.defineProperty(TransformNode.prototype, "isWorldMatrixFrozen", {
  93759. /**
  93760. * True if the World matrix has been frozen.
  93761. */
  93762. get: function () {
  93763. return this._isWorldMatrixFrozen;
  93764. },
  93765. enumerable: true,
  93766. configurable: true
  93767. });
  93768. /**
  93769. * Retuns the mesh absolute position in the World.
  93770. * @returns a Vector3.
  93771. */
  93772. TransformNode.prototype.getAbsolutePosition = function () {
  93773. this.computeWorldMatrix();
  93774. return this._absolutePosition;
  93775. };
  93776. /**
  93777. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  93778. * @param absolutePosition the absolute position to set
  93779. * @returns the TransformNode.
  93780. */
  93781. TransformNode.prototype.setAbsolutePosition = function (absolutePosition) {
  93782. if (!absolutePosition) {
  93783. return this;
  93784. }
  93785. var absolutePositionX;
  93786. var absolutePositionY;
  93787. var absolutePositionZ;
  93788. if (absolutePosition.x === undefined) {
  93789. if (arguments.length < 3) {
  93790. return this;
  93791. }
  93792. absolutePositionX = arguments[0];
  93793. absolutePositionY = arguments[1];
  93794. absolutePositionZ = arguments[2];
  93795. }
  93796. else {
  93797. absolutePositionX = absolutePosition.x;
  93798. absolutePositionY = absolutePosition.y;
  93799. absolutePositionZ = absolutePosition.z;
  93800. }
  93801. if (this.parent) {
  93802. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  93803. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  93804. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(absolutePositionX, absolutePositionY, absolutePositionZ, invertParentWorldMatrix, this.position);
  93805. }
  93806. else {
  93807. this.position.x = absolutePositionX;
  93808. this.position.y = absolutePositionY;
  93809. this.position.z = absolutePositionZ;
  93810. }
  93811. return this;
  93812. };
  93813. /**
  93814. * Sets the mesh position in its local space.
  93815. * @param vector3 the position to set in localspace
  93816. * @returns the TransformNode.
  93817. */
  93818. TransformNode.prototype.setPositionWithLocalVector = function (vector3) {
  93819. this.computeWorldMatrix();
  93820. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(vector3, this._localMatrix);
  93821. return this;
  93822. };
  93823. /**
  93824. * Returns the mesh position in the local space from the current World matrix values.
  93825. * @returns a new Vector3.
  93826. */
  93827. TransformNode.prototype.getPositionExpressedInLocalSpace = function () {
  93828. this.computeWorldMatrix();
  93829. var invLocalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  93830. this._localMatrix.invertToRef(invLocalWorldMatrix);
  93831. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this.position, invLocalWorldMatrix);
  93832. };
  93833. /**
  93834. * Translates the mesh along the passed Vector3 in its local space.
  93835. * @param vector3 the distance to translate in localspace
  93836. * @returns the TransformNode.
  93837. */
  93838. TransformNode.prototype.locallyTranslate = function (vector3) {
  93839. this.computeWorldMatrix(true);
  93840. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(vector3, this._localMatrix);
  93841. return this;
  93842. };
  93843. /**
  93844. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  93845. * @param targetPoint the position (must be in same space as current mesh) to look at
  93846. * @param yawCor optional yaw (y-axis) correction in radians
  93847. * @param pitchCor optional pitch (x-axis) correction in radians
  93848. * @param rollCor optional roll (z-axis) correction in radians
  93849. * @param space the choosen space of the target
  93850. * @returns the TransformNode.
  93851. */
  93852. TransformNode.prototype.lookAt = function (targetPoint, yawCor, pitchCor, rollCor, space) {
  93853. if (yawCor === void 0) { yawCor = 0; }
  93854. if (pitchCor === void 0) { pitchCor = 0; }
  93855. if (rollCor === void 0) { rollCor = 0; }
  93856. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  93857. var dv = TransformNode._lookAtVectorCache;
  93858. var pos = space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL ? this.position : this.getAbsolutePosition();
  93859. targetPoint.subtractToRef(pos, dv);
  93860. this.setDirection(dv, yawCor, pitchCor, rollCor);
  93861. // Correct for parent's rotation offset
  93862. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD && this.parent) {
  93863. if (this.rotationQuaternion) {
  93864. // Get local rotation matrix of the looking object
  93865. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  93866. this.rotationQuaternion.toRotationMatrix(rotationMatrix);
  93867. // Offset rotation by parent's inverted rotation matrix to correct in world space
  93868. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  93869. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  93870. parentRotationMatrix.invert();
  93871. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  93872. this.rotationQuaternion.fromRotationMatrix(rotationMatrix);
  93873. }
  93874. else {
  93875. // Get local rotation matrix of the looking object
  93876. var quaternionRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  93877. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, quaternionRotation);
  93878. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  93879. quaternionRotation.toRotationMatrix(rotationMatrix);
  93880. // Offset rotation by parent's inverted rotation matrix to correct in world space
  93881. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  93882. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  93883. parentRotationMatrix.invert();
  93884. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  93885. quaternionRotation.fromRotationMatrix(rotationMatrix);
  93886. quaternionRotation.toEulerAnglesToRef(this.rotation);
  93887. }
  93888. }
  93889. return this;
  93890. };
  93891. /**
  93892. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  93893. * This Vector3 is expressed in the World space.
  93894. * @param localAxis axis to rotate
  93895. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  93896. */
  93897. TransformNode.prototype.getDirection = function (localAxis) {
  93898. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  93899. this.getDirectionToRef(localAxis, result);
  93900. return result;
  93901. };
  93902. /**
  93903. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  93904. * localAxis is expressed in the mesh local space.
  93905. * result is computed in the Wordl space from the mesh World matrix.
  93906. * @param localAxis axis to rotate
  93907. * @param result the resulting transformnode
  93908. * @returns this TransformNode.
  93909. */
  93910. TransformNode.prototype.getDirectionToRef = function (localAxis, result) {
  93911. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  93912. return this;
  93913. };
  93914. /**
  93915. * Sets this transform node rotation to the given local axis.
  93916. * @param localAxis the axis in local space
  93917. * @param yawCor optional yaw (y-axis) correction in radians
  93918. * @param pitchCor optional pitch (x-axis) correction in radians
  93919. * @param rollCor optional roll (z-axis) correction in radians
  93920. * @returns this TransformNode
  93921. */
  93922. TransformNode.prototype.setDirection = function (localAxis, yawCor, pitchCor, rollCor) {
  93923. if (yawCor === void 0) { yawCor = 0; }
  93924. if (pitchCor === void 0) { pitchCor = 0; }
  93925. if (rollCor === void 0) { rollCor = 0; }
  93926. var yaw = -Math.atan2(localAxis.z, localAxis.x) + Math.PI / 2;
  93927. var len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);
  93928. var pitch = -Math.atan2(localAxis.y, len);
  93929. if (this.rotationQuaternion) {
  93930. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(yaw + yawCor, pitch + pitchCor, rollCor, this.rotationQuaternion);
  93931. }
  93932. else {
  93933. this.rotation.x = pitch + pitchCor;
  93934. this.rotation.y = yaw + yawCor;
  93935. this.rotation.z = rollCor;
  93936. }
  93937. return this;
  93938. };
  93939. /**
  93940. * Sets a new pivot point to the current node
  93941. * @param point defines the new pivot point to use
  93942. * @param space defines if the point is in world or local space (local by default)
  93943. * @returns the current TransformNode
  93944. */
  93945. TransformNode.prototype.setPivotPoint = function (point, space) {
  93946. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  93947. if (this.getScene().getRenderId() == 0) {
  93948. this.computeWorldMatrix(true);
  93949. }
  93950. var wm = this.getWorldMatrix();
  93951. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD) {
  93952. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  93953. wm.invertToRef(tmat);
  93954. point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(point, tmat);
  93955. }
  93956. return this.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(-point.x, -point.y, -point.z), true);
  93957. };
  93958. /**
  93959. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  93960. * @returns the pivot point
  93961. */
  93962. TransformNode.prototype.getPivotPoint = function () {
  93963. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  93964. this.getPivotPointToRef(point);
  93965. return point;
  93966. };
  93967. /**
  93968. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  93969. * @param result the vector3 to store the result
  93970. * @returns this TransformNode.
  93971. */
  93972. TransformNode.prototype.getPivotPointToRef = function (result) {
  93973. result.x = -this._pivotMatrix.m[12];
  93974. result.y = -this._pivotMatrix.m[13];
  93975. result.z = -this._pivotMatrix.m[14];
  93976. return this;
  93977. };
  93978. /**
  93979. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  93980. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  93981. */
  93982. TransformNode.prototype.getAbsolutePivotPoint = function () {
  93983. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  93984. this.getAbsolutePivotPointToRef(point);
  93985. return point;
  93986. };
  93987. /**
  93988. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  93989. * @param result vector3 to store the result
  93990. * @returns this TransformNode.
  93991. */
  93992. TransformNode.prototype.getAbsolutePivotPointToRef = function (result) {
  93993. result.x = this._pivotMatrix.m[12];
  93994. result.y = this._pivotMatrix.m[13];
  93995. result.z = this._pivotMatrix.m[14];
  93996. this.getPivotPointToRef(result);
  93997. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(result, this.getWorldMatrix(), result);
  93998. return this;
  93999. };
  94000. /**
  94001. * Defines the passed node as the parent of the current node.
  94002. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  94003. * @see https://doc.babylonjs.com/how_to/parenting
  94004. * @param node the node ot set as the parent
  94005. * @returns this TransformNode.
  94006. */
  94007. TransformNode.prototype.setParent = function (node) {
  94008. if (!node && !this.parent) {
  94009. return this;
  94010. }
  94011. var quatRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  94012. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  94013. var scale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  94014. if (!node) {
  94015. if (this.parent && this.parent.computeWorldMatrix) {
  94016. this.parent.computeWorldMatrix(true);
  94017. }
  94018. this.computeWorldMatrix(true);
  94019. this.getWorldMatrix().decompose(scale, quatRotation, position);
  94020. }
  94021. else {
  94022. var diffMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  94023. var invParentMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  94024. this.computeWorldMatrix(true);
  94025. node.computeWorldMatrix(true);
  94026. node.getWorldMatrix().invertToRef(invParentMatrix);
  94027. this.getWorldMatrix().multiplyToRef(invParentMatrix, diffMatrix);
  94028. diffMatrix.decompose(scale, quatRotation, position);
  94029. }
  94030. if (this.rotationQuaternion) {
  94031. this.rotationQuaternion.copyFrom(quatRotation);
  94032. }
  94033. else {
  94034. quatRotation.toEulerAnglesToRef(this.rotation);
  94035. }
  94036. this.scaling.copyFrom(scale);
  94037. this.position.copyFrom(position);
  94038. this.parent = node;
  94039. return this;
  94040. };
  94041. Object.defineProperty(TransformNode.prototype, "nonUniformScaling", {
  94042. /**
  94043. * True if the scaling property of this object is non uniform eg. (1,2,1)
  94044. */
  94045. get: function () {
  94046. return this._nonUniformScaling;
  94047. },
  94048. enumerable: true,
  94049. configurable: true
  94050. });
  94051. /** @hidden */
  94052. TransformNode.prototype._updateNonUniformScalingState = function (value) {
  94053. if (this._nonUniformScaling === value) {
  94054. return false;
  94055. }
  94056. this._nonUniformScaling = value;
  94057. return true;
  94058. };
  94059. /**
  94060. * Attach the current TransformNode to another TransformNode associated with a bone
  94061. * @param bone Bone affecting the TransformNode
  94062. * @param affectedTransformNode TransformNode associated with the bone
  94063. * @returns this object
  94064. */
  94065. TransformNode.prototype.attachToBone = function (bone, affectedTransformNode) {
  94066. this._transformToBoneReferal = affectedTransformNode;
  94067. this.parent = bone;
  94068. if (bone.getWorldMatrix().determinant() < 0) {
  94069. this.scalingDeterminant *= -1;
  94070. }
  94071. return this;
  94072. };
  94073. /**
  94074. * Detach the transform node if its associated with a bone
  94075. * @returns this object
  94076. */
  94077. TransformNode.prototype.detachFromBone = function () {
  94078. if (!this.parent) {
  94079. return this;
  94080. }
  94081. if (this.parent.getWorldMatrix().determinant() < 0) {
  94082. this.scalingDeterminant *= -1;
  94083. }
  94084. this._transformToBoneReferal = null;
  94085. this.parent = null;
  94086. return this;
  94087. };
  94088. /**
  94089. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  94090. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  94091. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  94092. * The passed axis is also normalized.
  94093. * @param axis the axis to rotate around
  94094. * @param amount the amount to rotate in radians
  94095. * @param space Space to rotate in (Default: local)
  94096. * @returns the TransformNode.
  94097. */
  94098. TransformNode.prototype.rotate = function (axis, amount, space) {
  94099. axis.normalize();
  94100. if (!this.rotationQuaternion) {
  94101. this.rotationQuaternion = this.rotation.toQuaternion();
  94102. this.rotation.setAll(0);
  94103. }
  94104. var rotationQuaternion;
  94105. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  94106. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  94107. this.rotationQuaternion.multiplyToRef(rotationQuaternion, this.rotationQuaternion);
  94108. }
  94109. else {
  94110. if (this.parent) {
  94111. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  94112. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  94113. axis = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(axis, invertParentWorldMatrix);
  94114. }
  94115. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  94116. rotationQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  94117. }
  94118. return this;
  94119. };
  94120. /**
  94121. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  94122. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  94123. * The passed axis is also normalized. .
  94124. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  94125. * @param point the point to rotate around
  94126. * @param axis the axis to rotate around
  94127. * @param amount the amount to rotate in radians
  94128. * @returns the TransformNode
  94129. */
  94130. TransformNode.prototype.rotateAround = function (point, axis, amount) {
  94131. axis.normalize();
  94132. if (!this.rotationQuaternion) {
  94133. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  94134. this.rotation.setAll(0);
  94135. }
  94136. var tmpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  94137. var finalScale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  94138. var finalTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[2];
  94139. var finalRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  94140. var translationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]; // T
  94141. var translationMatrixInv = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1]; // T'
  94142. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[2]; // R
  94143. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[3]; // T' x R x T
  94144. point.subtractToRef(this.position, tmpVector);
  94145. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(tmpVector.x, tmpVector.y, tmpVector.z, translationMatrix); // T
  94146. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-tmpVector.x, -tmpVector.y, -tmpVector.z, translationMatrixInv); // T'
  94147. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(axis, amount, rotationMatrix); // R
  94148. translationMatrixInv.multiplyToRef(rotationMatrix, finalMatrix); // T' x R
  94149. finalMatrix.multiplyToRef(translationMatrix, finalMatrix); // T' x R x T
  94150. finalMatrix.decompose(finalScale, finalRotation, finalTranslation);
  94151. this.position.addInPlace(finalTranslation);
  94152. finalRotation.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  94153. return this;
  94154. };
  94155. /**
  94156. * Translates the mesh along the axis vector for the passed distance in the given space.
  94157. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  94158. * @param axis the axis to translate in
  94159. * @param distance the distance to translate
  94160. * @param space Space to rotate in (Default: local)
  94161. * @returns the TransformNode.
  94162. */
  94163. TransformNode.prototype.translate = function (axis, distance, space) {
  94164. var displacementVector = axis.scale(distance);
  94165. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  94166. var tempV3 = this.getPositionExpressedInLocalSpace().add(displacementVector);
  94167. this.setPositionWithLocalVector(tempV3);
  94168. }
  94169. else {
  94170. this.setAbsolutePosition(this.getAbsolutePosition().add(displacementVector));
  94171. }
  94172. return this;
  94173. };
  94174. /**
  94175. * Adds a rotation step to the mesh current rotation.
  94176. * x, y, z are Euler angles expressed in radians.
  94177. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  94178. * This means this rotation is made in the mesh local space only.
  94179. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  94180. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  94181. * ```javascript
  94182. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  94183. * ```
  94184. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  94185. * 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.
  94186. * @param x Rotation to add
  94187. * @param y Rotation to add
  94188. * @param z Rotation to add
  94189. * @returns the TransformNode.
  94190. */
  94191. TransformNode.prototype.addRotation = function (x, y, z) {
  94192. var rotationQuaternion;
  94193. if (this.rotationQuaternion) {
  94194. rotationQuaternion = this.rotationQuaternion;
  94195. }
  94196. else {
  94197. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[1];
  94198. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, rotationQuaternion);
  94199. }
  94200. var accumulation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  94201. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(y, x, z, accumulation);
  94202. rotationQuaternion.multiplyInPlace(accumulation);
  94203. if (!this.rotationQuaternion) {
  94204. rotationQuaternion.toEulerAnglesToRef(this.rotation);
  94205. }
  94206. return this;
  94207. };
  94208. /**
  94209. * Computes the world matrix of the node
  94210. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  94211. * @returns the world matrix
  94212. */
  94213. TransformNode.prototype.computeWorldMatrix = function (force) {
  94214. if (this._isWorldMatrixFrozen) {
  94215. return this._worldMatrix;
  94216. }
  94217. if (!force && this.isSynchronized()) {
  94218. this._currentRenderId = this.getScene().getRenderId();
  94219. return this._worldMatrix;
  94220. }
  94221. this._updateCache();
  94222. this._cache.position.copyFrom(this.position);
  94223. this._cache.scaling.copyFrom(this.scaling);
  94224. this._cache.pivotMatrixUpdated = false;
  94225. this._cache.billboardMode = this.billboardMode;
  94226. this._cache.infiniteDistance = this.infiniteDistance;
  94227. this._currentRenderId = this.getScene().getRenderId();
  94228. this._childUpdateId++;
  94229. this._isDirty = false;
  94230. // Scaling
  94231. _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]);
  94232. // Rotation
  94233. //rotate, if quaternion is set and rotation was used
  94234. if (this.rotationQuaternion) {
  94235. var len = this.rotation.length();
  94236. if (len) {
  94237. this.rotationQuaternion.multiplyInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z));
  94238. this.rotation.copyFromFloats(0, 0, 0);
  94239. }
  94240. }
  94241. if (this.rotationQuaternion) {
  94242. this.rotationQuaternion.toRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  94243. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  94244. }
  94245. else {
  94246. _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]);
  94247. this._cache.rotation.copyFrom(this.rotation);
  94248. }
  94249. // Translation
  94250. var camera = this.getScene().activeCamera;
  94251. if (this.infiniteDistance && !this.parent && camera) {
  94252. var cameraWorldMatrix = camera.getWorldMatrix();
  94253. var cameraGlobalPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](cameraWorldMatrix.m[12], cameraWorldMatrix.m[13], cameraWorldMatrix.m[14]);
  94254. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(this.position.x + cameraGlobalPosition.x, this.position.y + cameraGlobalPosition.y, this.position.z + cameraGlobalPosition.z, this._tempMatrix2);
  94255. }
  94256. else {
  94257. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, this._tempMatrix2);
  94258. }
  94259. // Composing transformations
  94260. this._pivotMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[4]);
  94261. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[4].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0], this._tempMatrix);
  94262. // Post multiply inverse of pivotMatrix
  94263. if (this._postMultiplyPivotMatrix) {
  94264. this._tempMatrix.multiplyToRef(this._pivotMatrixInverse, this._tempMatrix);
  94265. }
  94266. // Local world
  94267. this._tempMatrix.multiplyToRef(this._tempMatrix2, this._localMatrix);
  94268. // Parent
  94269. if (this.parent && this.parent.getWorldMatrix) {
  94270. // We do not want parent rotation
  94271. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE && !this.preserveParentRotationForBillboard) {
  94272. if (this._transformToBoneReferal) {
  94273. this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7]);
  94274. }
  94275. else {
  94276. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7].copyFrom(this.parent.getWorldMatrix());
  94277. }
  94278. // Extract scaling and translation from parent
  94279. var translation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5];
  94280. var scale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[6];
  94281. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7].decompose(scale, undefined, translation);
  94282. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(scale.x, scale.y, scale.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7]);
  94283. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7].setTranslation(translation);
  94284. this._localMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7], this._worldMatrix);
  94285. }
  94286. else {
  94287. if (this._transformToBoneReferal) {
  94288. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  94289. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix);
  94290. }
  94291. else {
  94292. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  94293. }
  94294. }
  94295. this._markSyncedWithParent();
  94296. }
  94297. else {
  94298. this._worldMatrix.copyFrom(this._localMatrix);
  94299. }
  94300. // Billboarding (testing PG:http://www.babylonjs-playground.com/#UJEIL#13)
  94301. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE && camera) {
  94302. var storedTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  94303. this._worldMatrix.getTranslationToRef(storedTranslation); // Save translation
  94304. // Cancel camera rotation
  94305. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].copyFrom(camera.getViewMatrix());
  94306. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].setTranslationFromFloats(0, 0, 0);
  94307. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  94308. if ((this.billboardMode & TransformNode.BILLBOARDMODE_ALL) !== TransformNode.BILLBOARDMODE_ALL) {
  94309. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0].decompose(undefined, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0], undefined);
  94310. var eulerAngles = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  94311. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0].toEulerAnglesToRef(eulerAngles);
  94312. if ((this.billboardMode & TransformNode.BILLBOARDMODE_X) !== TransformNode.BILLBOARDMODE_X) {
  94313. eulerAngles.x = 0;
  94314. }
  94315. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Y) !== TransformNode.BILLBOARDMODE_Y) {
  94316. eulerAngles.y = 0;
  94317. }
  94318. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Z) !== TransformNode.BILLBOARDMODE_Z) {
  94319. eulerAngles.z = 0;
  94320. }
  94321. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(eulerAngles.y, eulerAngles.x, eulerAngles.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  94322. }
  94323. this._worldMatrix.setTranslationFromFloats(0, 0, 0);
  94324. this._worldMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0], this._worldMatrix);
  94325. // Restore translation
  94326. this._worldMatrix.setTranslation(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0]);
  94327. }
  94328. // Normal matrix
  94329. if (!this.ignoreNonUniformScaling) {
  94330. if (this.scaling.isNonUniform) {
  94331. this._updateNonUniformScalingState(true);
  94332. }
  94333. else if (this.parent && this.parent._nonUniformScaling) {
  94334. this._updateNonUniformScalingState(this.parent._nonUniformScaling);
  94335. }
  94336. else {
  94337. this._updateNonUniformScalingState(false);
  94338. }
  94339. }
  94340. else {
  94341. this._updateNonUniformScalingState(false);
  94342. }
  94343. this._afterComputeWorldMatrix();
  94344. // Absolute position
  94345. this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]);
  94346. // Callbacks
  94347. this.onAfterWorldMatrixUpdateObservable.notifyObservers(this);
  94348. if (!this._poseMatrix) {
  94349. this._poseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._worldMatrix);
  94350. }
  94351. // Cache the determinant
  94352. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  94353. return this._worldMatrix;
  94354. };
  94355. TransformNode.prototype._afterComputeWorldMatrix = function () {
  94356. };
  94357. /**
  94358. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  94359. * @param func callback function to add
  94360. *
  94361. * @returns the TransformNode.
  94362. */
  94363. TransformNode.prototype.registerAfterWorldMatrixUpdate = function (func) {
  94364. this.onAfterWorldMatrixUpdateObservable.add(func);
  94365. return this;
  94366. };
  94367. /**
  94368. * Removes a registered callback function.
  94369. * @param func callback function to remove
  94370. * @returns the TransformNode.
  94371. */
  94372. TransformNode.prototype.unregisterAfterWorldMatrixUpdate = function (func) {
  94373. this.onAfterWorldMatrixUpdateObservable.removeCallback(func);
  94374. return this;
  94375. };
  94376. /**
  94377. * Gets the position of the current mesh in camera space
  94378. * @param camera defines the camera to use
  94379. * @returns a position
  94380. */
  94381. TransformNode.prototype.getPositionInCameraSpace = function (camera) {
  94382. if (camera === void 0) { camera = null; }
  94383. if (!camera) {
  94384. camera = this.getScene().activeCamera;
  94385. }
  94386. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this.absolutePosition, camera.getViewMatrix());
  94387. };
  94388. /**
  94389. * Returns the distance from the mesh to the active camera
  94390. * @param camera defines the camera to use
  94391. * @returns the distance
  94392. */
  94393. TransformNode.prototype.getDistanceToCamera = function (camera) {
  94394. if (camera === void 0) { camera = null; }
  94395. if (!camera) {
  94396. camera = this.getScene().activeCamera;
  94397. }
  94398. return this.absolutePosition.subtract(camera.position).length();
  94399. };
  94400. /**
  94401. * Clone the current transform node
  94402. * @param name Name of the new clone
  94403. * @param newParent New parent for the clone
  94404. * @param doNotCloneChildren Do not clone children hierarchy
  94405. * @returns the new transform node
  94406. */
  94407. TransformNode.prototype.clone = function (name, newParent, doNotCloneChildren) {
  94408. var _this = this;
  94409. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new TransformNode(name, _this.getScene()); }, this);
  94410. result.name = name;
  94411. result.id = name;
  94412. if (newParent) {
  94413. result.parent = newParent;
  94414. }
  94415. if (!doNotCloneChildren) {
  94416. // Children
  94417. var directDescendants = this.getDescendants(true);
  94418. for (var index = 0; index < directDescendants.length; index++) {
  94419. var child = directDescendants[index];
  94420. if (child.clone) {
  94421. child.clone(name + "." + child.name, result);
  94422. }
  94423. }
  94424. }
  94425. return result;
  94426. };
  94427. /**
  94428. * Serializes the objects information.
  94429. * @param currentSerializationObject defines the object to serialize in
  94430. * @returns the serialized object
  94431. */
  94432. TransformNode.prototype.serialize = function (currentSerializationObject) {
  94433. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, currentSerializationObject);
  94434. serializationObject.type = this.getClassName();
  94435. // Parent
  94436. if (this.parent) {
  94437. serializationObject.parentId = this.parent.id;
  94438. }
  94439. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  94440. serializationObject.isEnabled = this.isEnabled();
  94441. // Parent
  94442. if (this.parent) {
  94443. serializationObject.parentId = this.parent.id;
  94444. }
  94445. return serializationObject;
  94446. };
  94447. // Statics
  94448. /**
  94449. * Returns a new TransformNode object parsed from the source provided.
  94450. * @param parsedTransformNode is the source.
  94451. * @param scene the scne the object belongs to
  94452. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  94453. * @returns a new TransformNode object parsed from the source provided.
  94454. */
  94455. TransformNode.Parse = function (parsedTransformNode, scene, rootUrl) {
  94456. var transformNode = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new TransformNode(parsedTransformNode.name, scene); }, parsedTransformNode, scene, rootUrl);
  94457. if (parsedTransformNode.localMatrix) {
  94458. transformNode.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.localMatrix));
  94459. }
  94460. else if (parsedTransformNode.pivotMatrix) {
  94461. transformNode.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.pivotMatrix));
  94462. }
  94463. transformNode.setEnabled(parsedTransformNode.isEnabled);
  94464. // Parent
  94465. if (parsedTransformNode.parentId) {
  94466. transformNode._waitingParentId = parsedTransformNode.parentId;
  94467. }
  94468. return transformNode;
  94469. };
  94470. /**
  94471. * Get all child-transformNodes of this node
  94472. * @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
  94473. * @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
  94474. * @returns an array of TransformNode
  94475. */
  94476. TransformNode.prototype.getChildTransformNodes = function (directDescendantsOnly, predicate) {
  94477. var results = [];
  94478. this._getDescendants(results, directDescendantsOnly, function (node) {
  94479. return ((!predicate || predicate(node)) && (node instanceof TransformNode));
  94480. });
  94481. return results;
  94482. };
  94483. /**
  94484. * Releases resources associated with this transform node.
  94485. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94486. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94487. */
  94488. TransformNode.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  94489. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  94490. // Animations
  94491. this.getScene().stopAnimation(this);
  94492. // Remove from scene
  94493. this.getScene().removeTransformNode(this);
  94494. this.onAfterWorldMatrixUpdateObservable.clear();
  94495. if (doNotRecurse) {
  94496. var transformNodes = this.getChildTransformNodes(true);
  94497. for (var _i = 0, transformNodes_1 = transformNodes; _i < transformNodes_1.length; _i++) {
  94498. var transformNode = transformNodes_1[_i];
  94499. transformNode.parent = null;
  94500. transformNode.computeWorldMatrix(true);
  94501. }
  94502. }
  94503. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  94504. };
  94505. // Statics
  94506. /**
  94507. * Object will not rotate to face the camera
  94508. */
  94509. TransformNode.BILLBOARDMODE_NONE = 0;
  94510. /**
  94511. * Object will rotate to face the camera but only on the x axis
  94512. */
  94513. TransformNode.BILLBOARDMODE_X = 1;
  94514. /**
  94515. * Object will rotate to face the camera but only on the y axis
  94516. */
  94517. TransformNode.BILLBOARDMODE_Y = 2;
  94518. /**
  94519. * Object will rotate to face the camera but only on the z axis
  94520. */
  94521. TransformNode.BILLBOARDMODE_Z = 4;
  94522. /**
  94523. * Object will rotate to face the camera
  94524. */
  94525. TransformNode.BILLBOARDMODE_ALL = 7;
  94526. TransformNode._lookAtVectorCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  94527. TransformNode._rotationAxisCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  94528. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  94529. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  94530. ], TransformNode.prototype, "_position", void 0);
  94531. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  94532. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("rotation")
  94533. ], TransformNode.prototype, "_rotation", void 0);
  94534. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  94535. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsQuaternion"])("rotationQuaternion")
  94536. ], TransformNode.prototype, "_rotationQuaternion", void 0);
  94537. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  94538. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("scaling")
  94539. ], TransformNode.prototype, "_scaling", void 0);
  94540. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  94541. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  94542. ], TransformNode.prototype, "billboardMode", void 0);
  94543. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  94544. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  94545. ], TransformNode.prototype, "scalingDeterminant", void 0);
  94546. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  94547. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  94548. ], TransformNode.prototype, "infiniteDistance", void 0);
  94549. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  94550. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  94551. ], TransformNode.prototype, "ignoreNonUniformScaling", void 0);
  94552. return TransformNode;
  94553. }(_node__WEBPACK_IMPORTED_MODULE_4__["Node"]));
  94554. /***/ }),
  94555. /***/ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts":
  94556. /*!***************************************************************!*\
  94557. !*** ./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts ***!
  94558. \***************************************************************/
  94559. /*! exports provided: CubeMapToSphericalPolynomialTools */
  94560. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94561. "use strict";
  94562. __webpack_require__.r(__webpack_exports__);
  94563. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return CubeMapToSphericalPolynomialTools; });
  94564. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  94565. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  94566. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  94567. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  94568. var FileFaceOrientation = /** @class */ (function () {
  94569. function FileFaceOrientation(name, worldAxisForNormal, worldAxisForFileX, worldAxisForFileY) {
  94570. this.name = name;
  94571. this.worldAxisForNormal = worldAxisForNormal;
  94572. this.worldAxisForFileX = worldAxisForFileX;
  94573. this.worldAxisForFileY = worldAxisForFileY;
  94574. }
  94575. return FileFaceOrientation;
  94576. }());
  94577. /**
  94578. * Helper class dealing with the extraction of spherical polynomial dataArray
  94579. * from a cube map.
  94580. */
  94581. var CubeMapToSphericalPolynomialTools = /** @class */ (function () {
  94582. function CubeMapToSphericalPolynomialTools() {
  94583. }
  94584. /**
  94585. * Converts a texture to the according Spherical Polynomial data.
  94586. * This extracts the first 3 orders only as they are the only one used in the lighting.
  94587. *
  94588. * @param texture The texture to extract the information from.
  94589. * @return The Spherical Polynomial data.
  94590. */
  94591. CubeMapToSphericalPolynomialTools.ConvertCubeMapTextureToSphericalPolynomial = function (texture) {
  94592. if (!texture.isCube) {
  94593. // Only supports cube Textures currently.
  94594. return null;
  94595. }
  94596. var size = texture.getSize().width;
  94597. var right = texture.readPixels(0);
  94598. var left = texture.readPixels(1);
  94599. var up;
  94600. var down;
  94601. if (texture.isRenderTarget) {
  94602. up = texture.readPixels(3);
  94603. down = texture.readPixels(2);
  94604. }
  94605. else {
  94606. up = texture.readPixels(2);
  94607. down = texture.readPixels(3);
  94608. }
  94609. var front = texture.readPixels(4);
  94610. var back = texture.readPixels(5);
  94611. var gammaSpace = texture.gammaSpace;
  94612. // Always read as RGBA.
  94613. var format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA;
  94614. var type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  94615. if (texture.textureType && texture.textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  94616. type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_FLOAT;
  94617. }
  94618. var cubeInfo = {
  94619. size: size,
  94620. right: right,
  94621. left: left,
  94622. up: up,
  94623. down: down,
  94624. front: front,
  94625. back: back,
  94626. format: format,
  94627. type: type,
  94628. gammaSpace: gammaSpace,
  94629. };
  94630. return this.ConvertCubeMapToSphericalPolynomial(cubeInfo);
  94631. };
  94632. /**
  94633. * Converts a cubemap to the according Spherical Polynomial data.
  94634. * This extracts the first 3 orders only as they are the only one used in the lighting.
  94635. *
  94636. * @param cubeInfo The Cube map to extract the information from.
  94637. * @return The Spherical Polynomial data.
  94638. */
  94639. CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial = function (cubeInfo) {
  94640. var sphericalHarmonics = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]();
  94641. var totalSolidAngle = 0.0;
  94642. // The (u,v) range is [-1,+1], so the distance between each texel is 2/Size.
  94643. var du = 2.0 / cubeInfo.size;
  94644. var dv = du;
  94645. // The (u,v) of the first texel is half a texel from the corner (-1,-1).
  94646. var minUV = du * 0.5 - 1.0;
  94647. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  94648. var fileFace = this.FileFaces[faceIndex];
  94649. var dataArray = cubeInfo[fileFace.name];
  94650. var v = minUV;
  94651. // TODO: we could perform the summation directly into a SphericalPolynomial (SP), which is more efficient than SphericalHarmonic (SH).
  94652. // This is possible because during the summation we do not need the SH-specific properties, e.g. orthogonality.
  94653. // Because SP is still linear, so summation is fine in that basis.
  94654. var stride = cubeInfo.format === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA ? 4 : 3;
  94655. for (var y = 0; y < cubeInfo.size; y++) {
  94656. var u = minUV;
  94657. for (var x = 0; x < cubeInfo.size; x++) {
  94658. // World direction (not normalised)
  94659. var worldDirection = fileFace.worldAxisForFileX.scale(u).add(fileFace.worldAxisForFileY.scale(v)).add(fileFace.worldAxisForNormal);
  94660. worldDirection.normalize();
  94661. var deltaSolidAngle = Math.pow(1.0 + u * u + v * v, -3.0 / 2.0);
  94662. var r = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 0];
  94663. var g = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 1];
  94664. var b = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 2];
  94665. // Handle Integer types.
  94666. if (cubeInfo.type === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  94667. r /= 255;
  94668. g /= 255;
  94669. b /= 255;
  94670. }
  94671. // Handle Gamma space textures.
  94672. if (cubeInfo.gammaSpace) {
  94673. r = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(r), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  94674. g = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(g), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  94675. b = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(b), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  94676. }
  94677. var color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](r, g, b);
  94678. sphericalHarmonics.addLight(worldDirection, color, deltaSolidAngle);
  94679. totalSolidAngle += deltaSolidAngle;
  94680. u += du;
  94681. }
  94682. v += dv;
  94683. }
  94684. }
  94685. // Solid angle for entire sphere is 4*pi
  94686. var sphereSolidAngle = 4.0 * Math.PI;
  94687. // Adjust the solid angle to allow for how many faces we processed.
  94688. var facesProcessed = 6.0;
  94689. var expectedSolidAngle = sphereSolidAngle * facesProcessed / 6.0;
  94690. // Adjust the harmonics so that the accumulated solid angle matches the expected solid angle.
  94691. // This is needed because the numerical integration over the cube uses a
  94692. // small angle approximation of solid angle for each texel (see deltaSolidAngle),
  94693. // and also to compensate for accumulative error due to float precision in the summation.
  94694. var correctionFactor = expectedSolidAngle / totalSolidAngle;
  94695. sphericalHarmonics.scale(correctionFactor);
  94696. sphericalHarmonics.convertIncidentRadianceToIrradiance();
  94697. sphericalHarmonics.convertIrradianceToLambertianRadiance();
  94698. return _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"].FromHarmonics(sphericalHarmonics);
  94699. };
  94700. CubeMapToSphericalPolynomialTools.FileFaces = [
  94701. 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)),
  94702. 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)),
  94703. 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)),
  94704. 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)),
  94705. 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)),
  94706. 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
  94707. ];
  94708. return CubeMapToSphericalPolynomialTools;
  94709. }());
  94710. /***/ }),
  94711. /***/ "./Misc/HighDynamicRange/hdr.ts":
  94712. /*!**************************************!*\
  94713. !*** ./Misc/HighDynamicRange/hdr.ts ***!
  94714. \**************************************/
  94715. /*! exports provided: HDRTools */
  94716. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94717. "use strict";
  94718. __webpack_require__.r(__webpack_exports__);
  94719. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return HDRTools; });
  94720. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  94721. /**
  94722. * This groups tools to convert HDR texture to native colors array.
  94723. */
  94724. var HDRTools = /** @class */ (function () {
  94725. function HDRTools() {
  94726. }
  94727. HDRTools.Ldexp = function (mantissa, exponent) {
  94728. if (exponent > 1023) {
  94729. return mantissa * Math.pow(2, 1023) * Math.pow(2, exponent - 1023);
  94730. }
  94731. if (exponent < -1074) {
  94732. return mantissa * Math.pow(2, -1074) * Math.pow(2, exponent + 1074);
  94733. }
  94734. return mantissa * Math.pow(2, exponent);
  94735. };
  94736. HDRTools.Rgbe2float = function (float32array, red, green, blue, exponent, index) {
  94737. if (exponent > 0) { /*nonzero pixel*/
  94738. exponent = this.Ldexp(1.0, exponent - (128 + 8));
  94739. float32array[index + 0] = red * exponent;
  94740. float32array[index + 1] = green * exponent;
  94741. float32array[index + 2] = blue * exponent;
  94742. }
  94743. else {
  94744. float32array[index + 0] = 0;
  94745. float32array[index + 1] = 0;
  94746. float32array[index + 2] = 0;
  94747. }
  94748. };
  94749. HDRTools.readStringLine = function (uint8array, startIndex) {
  94750. var line = "";
  94751. var character = "";
  94752. for (var i = startIndex; i < uint8array.length - startIndex; i++) {
  94753. character = String.fromCharCode(uint8array[i]);
  94754. if (character == "\n") {
  94755. break;
  94756. }
  94757. line += character;
  94758. }
  94759. return line;
  94760. };
  94761. /**
  94762. * Reads header information from an RGBE texture stored in a native array.
  94763. * More information on this format are available here:
  94764. * https://en.wikipedia.org/wiki/RGBE_image_format
  94765. *
  94766. * @param uint8array The binary file stored in native array.
  94767. * @return The header information.
  94768. */
  94769. HDRTools.RGBE_ReadHeader = function (uint8array) {
  94770. var height = 0;
  94771. var width = 0;
  94772. var line = this.readStringLine(uint8array, 0);
  94773. if (line[0] != '#' || line[1] != '?') {
  94774. throw "Bad HDR Format.";
  94775. }
  94776. var endOfHeader = false;
  94777. var findFormat = false;
  94778. var lineIndex = 0;
  94779. do {
  94780. lineIndex += (line.length + 1);
  94781. line = this.readStringLine(uint8array, lineIndex);
  94782. if (line == "FORMAT=32-bit_rle_rgbe") {
  94783. findFormat = true;
  94784. }
  94785. else if (line.length == 0) {
  94786. endOfHeader = true;
  94787. }
  94788. } while (!endOfHeader);
  94789. if (!findFormat) {
  94790. throw "HDR Bad header format, unsupported FORMAT";
  94791. }
  94792. lineIndex += (line.length + 1);
  94793. line = this.readStringLine(uint8array, lineIndex);
  94794. var sizeRegexp = /^\-Y (.*) \+X (.*)$/g;
  94795. var match = sizeRegexp.exec(line);
  94796. // TODO. Support +Y and -X if needed.
  94797. if (!match || match.length < 3) {
  94798. throw "HDR Bad header format, no size";
  94799. }
  94800. width = parseInt(match[2]);
  94801. height = parseInt(match[1]);
  94802. if (width < 8 || width > 0x7fff) {
  94803. throw "HDR Bad header format, unsupported size";
  94804. }
  94805. lineIndex += (line.length + 1);
  94806. return {
  94807. height: height,
  94808. width: width,
  94809. dataPosition: lineIndex
  94810. };
  94811. };
  94812. /**
  94813. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  94814. * This RGBE texture needs to store the information as a panorama.
  94815. *
  94816. * More information on this format are available here:
  94817. * https://en.wikipedia.org/wiki/RGBE_image_format
  94818. *
  94819. * @param buffer The binary file stored in an array buffer.
  94820. * @param size The expected size of the extracted cubemap.
  94821. * @return The Cube Map information.
  94822. */
  94823. HDRTools.GetCubeMapTextureData = function (buffer, size) {
  94824. var uint8array = new Uint8Array(buffer);
  94825. var hdrInfo = this.RGBE_ReadHeader(uint8array);
  94826. var data = this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  94827. var cubeMapData = _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"].ConvertPanoramaToCubemap(data, hdrInfo.width, hdrInfo.height, size);
  94828. return cubeMapData;
  94829. };
  94830. /**
  94831. * Returns the pixels data extracted from an RGBE texture.
  94832. * This pixels will be stored left to right up to down in the R G B order in one array.
  94833. *
  94834. * More information on this format are available here:
  94835. * https://en.wikipedia.org/wiki/RGBE_image_format
  94836. *
  94837. * @param uint8array The binary file stored in an array buffer.
  94838. * @param hdrInfo The header information of the file.
  94839. * @return The pixels data in RGB right to left up to down order.
  94840. */
  94841. HDRTools.RGBE_ReadPixels = function (uint8array, hdrInfo) {
  94842. // Keep for multi format supports.
  94843. return this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  94844. };
  94845. HDRTools.RGBE_ReadPixels_RLE = function (uint8array, hdrInfo) {
  94846. var num_scanlines = hdrInfo.height;
  94847. var scanline_width = hdrInfo.width;
  94848. var a, b, c, d, count;
  94849. var dataIndex = hdrInfo.dataPosition;
  94850. var index = 0, endIndex = 0, i = 0;
  94851. var scanLineArrayBuffer = new ArrayBuffer(scanline_width * 4); // four channel R G B E
  94852. var scanLineArray = new Uint8Array(scanLineArrayBuffer);
  94853. // 3 channels of 4 bytes per pixel in float.
  94854. var resultBuffer = new ArrayBuffer(hdrInfo.width * hdrInfo.height * 4 * 3);
  94855. var resultArray = new Float32Array(resultBuffer);
  94856. // read in each successive scanline
  94857. while (num_scanlines > 0) {
  94858. a = uint8array[dataIndex++];
  94859. b = uint8array[dataIndex++];
  94860. c = uint8array[dataIndex++];
  94861. d = uint8array[dataIndex++];
  94862. if (a != 2 || b != 2 || (c & 0x80)) {
  94863. // this file is not run length encoded
  94864. throw "HDR Bad header format, not RLE";
  94865. }
  94866. if (((c << 8) | d) != scanline_width) {
  94867. throw "HDR Bad header format, wrong scan line width";
  94868. }
  94869. index = 0;
  94870. // read each of the four channels for the scanline into the buffer
  94871. for (i = 0; i < 4; i++) {
  94872. endIndex = (i + 1) * scanline_width;
  94873. while (index < endIndex) {
  94874. a = uint8array[dataIndex++];
  94875. b = uint8array[dataIndex++];
  94876. if (a > 128) {
  94877. // a run of the same value
  94878. count = a - 128;
  94879. if ((count == 0) || (count > endIndex - index)) {
  94880. throw "HDR Bad Format, bad scanline data (run)";
  94881. }
  94882. while (count-- > 0) {
  94883. scanLineArray[index++] = b;
  94884. }
  94885. }
  94886. else {
  94887. // a non-run
  94888. count = a;
  94889. if ((count == 0) || (count > endIndex - index)) {
  94890. throw "HDR Bad Format, bad scanline data (non-run)";
  94891. }
  94892. scanLineArray[index++] = b;
  94893. if (--count > 0) {
  94894. for (var j = 0; j < count; j++) {
  94895. scanLineArray[index++] = uint8array[dataIndex++];
  94896. }
  94897. }
  94898. }
  94899. }
  94900. }
  94901. // now convert data from buffer into floats
  94902. for (i = 0; i < scanline_width; i++) {
  94903. a = scanLineArray[i];
  94904. b = scanLineArray[i + scanline_width];
  94905. c = scanLineArray[i + 2 * scanline_width];
  94906. d = scanLineArray[i + 3 * scanline_width];
  94907. this.Rgbe2float(resultArray, a, b, c, d, (hdrInfo.height - num_scanlines) * scanline_width * 3 + i * 3);
  94908. }
  94909. num_scanlines--;
  94910. }
  94911. return resultArray;
  94912. };
  94913. return HDRTools;
  94914. }());
  94915. /***/ }),
  94916. /***/ "./Misc/HighDynamicRange/index.ts":
  94917. /*!****************************************!*\
  94918. !*** ./Misc/HighDynamicRange/index.ts ***!
  94919. \****************************************/
  94920. /*! exports provided: CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools */
  94921. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94922. "use strict";
  94923. __webpack_require__.r(__webpack_exports__);
  94924. /* harmony import */ var _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  94925. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  94926. /* harmony import */ var _hdr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hdr */ "./Misc/HighDynamicRange/hdr.ts");
  94927. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _hdr__WEBPACK_IMPORTED_MODULE_1__["HDRTools"]; });
  94928. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  94929. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__["PanoramaToCubeMapTools"]; });
  94930. /***/ }),
  94931. /***/ "./Misc/HighDynamicRange/panoramaToCubemap.ts":
  94932. /*!****************************************************!*\
  94933. !*** ./Misc/HighDynamicRange/panoramaToCubemap.ts ***!
  94934. \****************************************************/
  94935. /*! exports provided: PanoramaToCubeMapTools */
  94936. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94937. "use strict";
  94938. __webpack_require__.r(__webpack_exports__);
  94939. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return PanoramaToCubeMapTools; });
  94940. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  94941. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  94942. /**
  94943. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  94944. */
  94945. var PanoramaToCubeMapTools = /** @class */ (function () {
  94946. function PanoramaToCubeMapTools() {
  94947. }
  94948. /**
  94949. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  94950. *
  94951. * @param float32Array The source data.
  94952. * @param inputWidth The width of the input panorama.
  94953. * @param inputHeight The height of the input panorama.
  94954. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  94955. * @return The cubemap data
  94956. */
  94957. PanoramaToCubeMapTools.ConvertPanoramaToCubemap = function (float32Array, inputWidth, inputHeight, size) {
  94958. if (!float32Array) {
  94959. throw "ConvertPanoramaToCubemap: input cannot be null";
  94960. }
  94961. if (float32Array.length != inputWidth * inputHeight * 3) {
  94962. throw "ConvertPanoramaToCubemap: input size is wrong";
  94963. }
  94964. var textureFront = this.CreateCubemapTexture(size, this.FACE_FRONT, float32Array, inputWidth, inputHeight);
  94965. var textureBack = this.CreateCubemapTexture(size, this.FACE_BACK, float32Array, inputWidth, inputHeight);
  94966. var textureLeft = this.CreateCubemapTexture(size, this.FACE_LEFT, float32Array, inputWidth, inputHeight);
  94967. var textureRight = this.CreateCubemapTexture(size, this.FACE_RIGHT, float32Array, inputWidth, inputHeight);
  94968. var textureUp = this.CreateCubemapTexture(size, this.FACE_UP, float32Array, inputWidth, inputHeight);
  94969. var textureDown = this.CreateCubemapTexture(size, this.FACE_DOWN, float32Array, inputWidth, inputHeight);
  94970. return {
  94971. front: textureFront,
  94972. back: textureBack,
  94973. left: textureLeft,
  94974. right: textureRight,
  94975. up: textureUp,
  94976. down: textureDown,
  94977. size: size,
  94978. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_FLOAT,
  94979. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGB,
  94980. gammaSpace: false,
  94981. };
  94982. };
  94983. PanoramaToCubeMapTools.CreateCubemapTexture = function (texSize, faceData, float32Array, inputWidth, inputHeight) {
  94984. var buffer = new ArrayBuffer(texSize * texSize * 4 * 3);
  94985. var textureArray = new Float32Array(buffer);
  94986. var rotDX1 = faceData[1].subtract(faceData[0]).scale(1 / texSize);
  94987. var rotDX2 = faceData[3].subtract(faceData[2]).scale(1 / texSize);
  94988. var dy = 1 / texSize;
  94989. var fy = 0;
  94990. for (var y = 0; y < texSize; y++) {
  94991. var xv1 = faceData[0];
  94992. var xv2 = faceData[2];
  94993. for (var x = 0; x < texSize; x++) {
  94994. var v = xv2.subtract(xv1).scale(fy).add(xv1);
  94995. v.normalize();
  94996. var color = this.CalcProjectionSpherical(v, float32Array, inputWidth, inputHeight);
  94997. // 3 channels per pixels
  94998. textureArray[y * texSize * 3 + (x * 3) + 0] = color.r;
  94999. textureArray[y * texSize * 3 + (x * 3) + 1] = color.g;
  95000. textureArray[y * texSize * 3 + (x * 3) + 2] = color.b;
  95001. xv1 = xv1.add(rotDX1);
  95002. xv2 = xv2.add(rotDX2);
  95003. }
  95004. fy += dy;
  95005. }
  95006. return textureArray;
  95007. };
  95008. PanoramaToCubeMapTools.CalcProjectionSpherical = function (vDir, float32Array, inputWidth, inputHeight) {
  95009. var theta = Math.atan2(vDir.z, vDir.x);
  95010. var phi = Math.acos(vDir.y);
  95011. while (theta < -Math.PI) {
  95012. theta += 2 * Math.PI;
  95013. }
  95014. while (theta > Math.PI) {
  95015. theta -= 2 * Math.PI;
  95016. }
  95017. var dx = theta / Math.PI;
  95018. var dy = phi / Math.PI;
  95019. // recenter.
  95020. dx = dx * 0.5 + 0.5;
  95021. var px = Math.round(dx * inputWidth);
  95022. if (px < 0) {
  95023. px = 0;
  95024. }
  95025. else if (px >= inputWidth) {
  95026. px = inputWidth - 1;
  95027. }
  95028. var py = Math.round(dy * inputHeight);
  95029. if (py < 0) {
  95030. py = 0;
  95031. }
  95032. else if (py >= inputHeight) {
  95033. py = inputHeight - 1;
  95034. }
  95035. var inputY = (inputHeight - py - 1);
  95036. var r = float32Array[inputY * inputWidth * 3 + (px * 3) + 0];
  95037. var g = float32Array[inputY * inputWidth * 3 + (px * 3) + 1];
  95038. var b = float32Array[inputY * inputWidth * 3 + (px * 3) + 2];
  95039. return {
  95040. r: r,
  95041. g: g,
  95042. b: b
  95043. };
  95044. };
  95045. PanoramaToCubeMapTools.FACE_FRONT = [
  95046. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  95047. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  95048. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  95049. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0)
  95050. ];
  95051. PanoramaToCubeMapTools.FACE_BACK = [
  95052. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  95053. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  95054. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0),
  95055. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0)
  95056. ];
  95057. PanoramaToCubeMapTools.FACE_RIGHT = [
  95058. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  95059. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  95060. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  95061. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  95062. ];
  95063. PanoramaToCubeMapTools.FACE_LEFT = [
  95064. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  95065. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  95066. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  95067. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0)
  95068. ];
  95069. PanoramaToCubeMapTools.FACE_DOWN = [
  95070. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  95071. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  95072. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  95073. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  95074. ];
  95075. PanoramaToCubeMapTools.FACE_UP = [
  95076. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  95077. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  95078. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  95079. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0)
  95080. ];
  95081. return PanoramaToCubeMapTools;
  95082. }());
  95083. /***/ }),
  95084. /***/ "./Misc/andOrNotEvaluator.ts":
  95085. /*!***********************************!*\
  95086. !*** ./Misc/andOrNotEvaluator.ts ***!
  95087. \***********************************/
  95088. /*! exports provided: AndOrNotEvaluator */
  95089. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95090. "use strict";
  95091. __webpack_require__.r(__webpack_exports__);
  95092. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return AndOrNotEvaluator; });
  95093. /**
  95094. * Class used to evalaute queries containing `and` and `or` operators
  95095. */
  95096. var AndOrNotEvaluator = /** @class */ (function () {
  95097. function AndOrNotEvaluator() {
  95098. }
  95099. /**
  95100. * Evaluate a query
  95101. * @param query defines the query to evaluate
  95102. * @param evaluateCallback defines the callback used to filter result
  95103. * @returns true if the query matches
  95104. */
  95105. AndOrNotEvaluator.Eval = function (query, evaluateCallback) {
  95106. if (!query.match(/\([^\(\)]*\)/g)) {
  95107. query = AndOrNotEvaluator._HandleParenthesisContent(query, evaluateCallback);
  95108. }
  95109. else {
  95110. query = query.replace(/\([^\(\)]*\)/g, function (r) {
  95111. // remove parenthesis
  95112. r = r.slice(1, r.length - 1);
  95113. return AndOrNotEvaluator._HandleParenthesisContent(r, evaluateCallback);
  95114. });
  95115. }
  95116. if (query === "true") {
  95117. return true;
  95118. }
  95119. if (query === "false") {
  95120. return false;
  95121. }
  95122. return AndOrNotEvaluator.Eval(query, evaluateCallback);
  95123. };
  95124. AndOrNotEvaluator._HandleParenthesisContent = function (parenthesisContent, evaluateCallback) {
  95125. evaluateCallback = evaluateCallback || (function (r) {
  95126. return r === "true" ? true : false;
  95127. });
  95128. var result;
  95129. var or = parenthesisContent.split("||");
  95130. for (var i in or) {
  95131. if (or.hasOwnProperty(i)) {
  95132. var ori = AndOrNotEvaluator._SimplifyNegation(or[i].trim());
  95133. var and = ori.split("&&");
  95134. if (and.length > 1) {
  95135. for (var j = 0; j < and.length; ++j) {
  95136. var andj = AndOrNotEvaluator._SimplifyNegation(and[j].trim());
  95137. if (andj !== "true" && andj !== "false") {
  95138. if (andj[0] === "!") {
  95139. result = !evaluateCallback(andj.substring(1));
  95140. }
  95141. else {
  95142. result = evaluateCallback(andj);
  95143. }
  95144. }
  95145. else {
  95146. result = andj === "true" ? true : false;
  95147. }
  95148. if (!result) { // no need to continue since 'false && ... && ...' will always return false
  95149. ori = "false";
  95150. break;
  95151. }
  95152. }
  95153. }
  95154. if (result || ori === "true") { // no need to continue since 'true || ... || ...' will always return true
  95155. result = true;
  95156. break;
  95157. }
  95158. // result equals false (or undefined)
  95159. if (ori !== "true" && ori !== "false") {
  95160. if (ori[0] === "!") {
  95161. result = !evaluateCallback(ori.substring(1));
  95162. }
  95163. else {
  95164. result = evaluateCallback(ori);
  95165. }
  95166. }
  95167. else {
  95168. result = ori === "true" ? true : false;
  95169. }
  95170. }
  95171. }
  95172. // the whole parenthesis scope is replaced by 'true' or 'false'
  95173. return result ? "true" : "false";
  95174. };
  95175. AndOrNotEvaluator._SimplifyNegation = function (booleanString) {
  95176. booleanString = booleanString.replace(/^[\s!]+/, function (r) {
  95177. // remove whitespaces
  95178. r = r.replace(/[\s]/g, function () { return ""; });
  95179. return r.length % 2 ? "!" : "";
  95180. });
  95181. booleanString = booleanString.trim();
  95182. if (booleanString === "!true") {
  95183. booleanString = "false";
  95184. }
  95185. else if (booleanString === "!false") {
  95186. booleanString = "true";
  95187. }
  95188. return booleanString;
  95189. };
  95190. return AndOrNotEvaluator;
  95191. }());
  95192. /***/ }),
  95193. /***/ "./Misc/arrayTools.ts":
  95194. /*!****************************!*\
  95195. !*** ./Misc/arrayTools.ts ***!
  95196. \****************************/
  95197. /*! exports provided: ArrayTools */
  95198. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95199. "use strict";
  95200. __webpack_require__.r(__webpack_exports__);
  95201. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayTools", function() { return ArrayTools; });
  95202. /**
  95203. * Class containing a set of static utilities functions for arrays.
  95204. */
  95205. var ArrayTools = /** @class */ (function () {
  95206. function ArrayTools() {
  95207. }
  95208. /**
  95209. * Returns an array of the given size filled with element built from the given constructor and the paramters
  95210. * @param size the number of element to construct and put in the array
  95211. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  95212. * @returns a new array filled with new objects
  95213. */
  95214. ArrayTools.BuildArray = function (size, itemBuilder) {
  95215. var a = [];
  95216. for (var i = 0; i < size; ++i) {
  95217. a.push(itemBuilder());
  95218. }
  95219. return a;
  95220. };
  95221. return ArrayTools;
  95222. }());
  95223. /***/ }),
  95224. /***/ "./Misc/assetsManager.ts":
  95225. /*!*******************************!*\
  95226. !*** ./Misc/assetsManager.ts ***!
  95227. \*******************************/
  95228. /*! exports provided: AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, EquiRectangularCubeTextureAssetTask, AssetsManager */
  95229. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95230. "use strict";
  95231. __webpack_require__.r(__webpack_exports__);
  95232. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return AssetTaskState; });
  95233. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return AbstractAssetTask; });
  95234. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return AssetsProgressEvent; });
  95235. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return MeshAssetTask; });
  95236. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return TextFileAssetTask; });
  95237. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return BinaryFileAssetTask; });
  95238. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return ImageAssetTask; });
  95239. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return TextureAssetTask; });
  95240. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return CubeTextureAssetTask; });
  95241. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return HDRCubeTextureAssetTask; });
  95242. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTextureAssetTask", function() { return EquiRectangularCubeTextureAssetTask; });
  95243. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return AssetsManager; });
  95244. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  95245. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  95246. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  95247. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  95248. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  95249. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  95250. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  95251. /* harmony import */ var _Materials_Textures_equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/equiRectangularCubeTexture */ "./Materials/Textures/equiRectangularCubeTexture.ts");
  95252. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  95253. /**
  95254. * Defines the list of states available for a task inside a AssetsManager
  95255. */
  95256. var AssetTaskState;
  95257. (function (AssetTaskState) {
  95258. /**
  95259. * Initialization
  95260. */
  95261. AssetTaskState[AssetTaskState["INIT"] = 0] = "INIT";
  95262. /**
  95263. * Running
  95264. */
  95265. AssetTaskState[AssetTaskState["RUNNING"] = 1] = "RUNNING";
  95266. /**
  95267. * Done
  95268. */
  95269. AssetTaskState[AssetTaskState["DONE"] = 2] = "DONE";
  95270. /**
  95271. * Error
  95272. */
  95273. AssetTaskState[AssetTaskState["ERROR"] = 3] = "ERROR";
  95274. })(AssetTaskState || (AssetTaskState = {}));
  95275. /**
  95276. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  95277. */
  95278. var AbstractAssetTask = /** @class */ (function () {
  95279. /**
  95280. * Creates a new AssetsManager
  95281. * @param name defines the name of the task
  95282. */
  95283. function AbstractAssetTask(
  95284. /**
  95285. * Task name
  95286. */ name) {
  95287. this.name = name;
  95288. this._isCompleted = false;
  95289. this._taskState = AssetTaskState.INIT;
  95290. }
  95291. Object.defineProperty(AbstractAssetTask.prototype, "isCompleted", {
  95292. /**
  95293. * Get if the task is completed
  95294. */
  95295. get: function () {
  95296. return this._isCompleted;
  95297. },
  95298. enumerable: true,
  95299. configurable: true
  95300. });
  95301. Object.defineProperty(AbstractAssetTask.prototype, "taskState", {
  95302. /**
  95303. * Gets the current state of the task
  95304. */
  95305. get: function () {
  95306. return this._taskState;
  95307. },
  95308. enumerable: true,
  95309. configurable: true
  95310. });
  95311. Object.defineProperty(AbstractAssetTask.prototype, "errorObject", {
  95312. /**
  95313. * Gets the current error object (if task is in error)
  95314. */
  95315. get: function () {
  95316. return this._errorObject;
  95317. },
  95318. enumerable: true,
  95319. configurable: true
  95320. });
  95321. /**
  95322. * Internal only
  95323. * @hidden
  95324. */
  95325. AbstractAssetTask.prototype._setErrorObject = function (message, exception) {
  95326. if (this._errorObject) {
  95327. return;
  95328. }
  95329. this._errorObject = {
  95330. message: message,
  95331. exception: exception
  95332. };
  95333. };
  95334. /**
  95335. * Execute the current task
  95336. * @param scene defines the scene where you want your assets to be loaded
  95337. * @param onSuccess is a callback called when the task is successfully executed
  95338. * @param onError is a callback called if an error occurs
  95339. */
  95340. AbstractAssetTask.prototype.run = function (scene, onSuccess, onError) {
  95341. var _this = this;
  95342. this._taskState = AssetTaskState.RUNNING;
  95343. this.runTask(scene, function () {
  95344. _this.onDoneCallback(onSuccess, onError);
  95345. }, function (msg, exception) {
  95346. _this.onErrorCallback(onError, msg, exception);
  95347. });
  95348. };
  95349. /**
  95350. * Execute the current task
  95351. * @param scene defines the scene where you want your assets to be loaded
  95352. * @param onSuccess is a callback called when the task is successfully executed
  95353. * @param onError is a callback called if an error occurs
  95354. */
  95355. AbstractAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  95356. throw new Error("runTask is not implemented");
  95357. };
  95358. /**
  95359. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  95360. * This can be used with failed tasks that have the reason for failure fixed.
  95361. */
  95362. AbstractAssetTask.prototype.reset = function () {
  95363. this._taskState = AssetTaskState.INIT;
  95364. };
  95365. AbstractAssetTask.prototype.onErrorCallback = function (onError, message, exception) {
  95366. this._taskState = AssetTaskState.ERROR;
  95367. this._errorObject = {
  95368. message: message,
  95369. exception: exception
  95370. };
  95371. if (this.onError) {
  95372. this.onError(this, message, exception);
  95373. }
  95374. onError();
  95375. };
  95376. AbstractAssetTask.prototype.onDoneCallback = function (onSuccess, onError) {
  95377. try {
  95378. this._taskState = AssetTaskState.DONE;
  95379. this._isCompleted = true;
  95380. if (this.onSuccess) {
  95381. this.onSuccess(this);
  95382. }
  95383. onSuccess();
  95384. }
  95385. catch (e) {
  95386. this.onErrorCallback(onError, "Task is done, error executing success callback(s)", e);
  95387. }
  95388. };
  95389. return AbstractAssetTask;
  95390. }());
  95391. /**
  95392. * Class used to share progress information about assets loading
  95393. */
  95394. var AssetsProgressEvent = /** @class */ (function () {
  95395. /**
  95396. * Creates a AssetsProgressEvent
  95397. * @param remainingCount defines the number of remaining tasks to process
  95398. * @param totalCount defines the total number of tasks
  95399. * @param task defines the task that was just processed
  95400. */
  95401. function AssetsProgressEvent(remainingCount, totalCount, task) {
  95402. this.remainingCount = remainingCount;
  95403. this.totalCount = totalCount;
  95404. this.task = task;
  95405. }
  95406. return AssetsProgressEvent;
  95407. }());
  95408. /**
  95409. * Define a task used by AssetsManager to load meshes
  95410. */
  95411. var MeshAssetTask = /** @class */ (function (_super) {
  95412. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshAssetTask, _super);
  95413. /**
  95414. * Creates a new MeshAssetTask
  95415. * @param name defines the name of the task
  95416. * @param meshesNames defines the list of mesh's names you want to load
  95417. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  95418. * @param sceneFilename defines the filename of the scene to load from
  95419. */
  95420. function MeshAssetTask(
  95421. /**
  95422. * Defines the name of the task
  95423. */
  95424. name,
  95425. /**
  95426. * Defines the list of mesh's names you want to load
  95427. */
  95428. meshesNames,
  95429. /**
  95430. * Defines the root url to use as a base to load your meshes and associated resources
  95431. */
  95432. rootUrl,
  95433. /**
  95434. * Defines the filename of the scene to load from
  95435. */
  95436. sceneFilename) {
  95437. var _this = _super.call(this, name) || this;
  95438. _this.name = name;
  95439. _this.meshesNames = meshesNames;
  95440. _this.rootUrl = rootUrl;
  95441. _this.sceneFilename = sceneFilename;
  95442. return _this;
  95443. }
  95444. /**
  95445. * Execute the current task
  95446. * @param scene defines the scene where you want your assets to be loaded
  95447. * @param onSuccess is a callback called when the task is successfully executed
  95448. * @param onError is a callback called if an error occurs
  95449. */
  95450. MeshAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  95451. var _this = this;
  95452. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh(this.meshesNames, this.rootUrl, this.sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  95453. _this.loadedMeshes = meshes;
  95454. _this.loadedParticleSystems = particleSystems;
  95455. _this.loadedSkeletons = skeletons;
  95456. _this.loadedAnimationGroups = animationGroups;
  95457. onSuccess();
  95458. }, null, function (scene, message, exception) {
  95459. onError(message, exception);
  95460. });
  95461. };
  95462. return MeshAssetTask;
  95463. }(AbstractAssetTask));
  95464. /**
  95465. * Define a task used by AssetsManager to load text content
  95466. */
  95467. var TextFileAssetTask = /** @class */ (function (_super) {
  95468. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextFileAssetTask, _super);
  95469. /**
  95470. * Creates a new TextFileAssetTask object
  95471. * @param name defines the name of the task
  95472. * @param url defines the location of the file to load
  95473. */
  95474. function TextFileAssetTask(
  95475. /**
  95476. * Defines the name of the task
  95477. */
  95478. name,
  95479. /**
  95480. * Defines the location of the file to load
  95481. */
  95482. url) {
  95483. var _this = _super.call(this, name) || this;
  95484. _this.name = name;
  95485. _this.url = url;
  95486. return _this;
  95487. }
  95488. /**
  95489. * Execute the current task
  95490. * @param scene defines the scene where you want your assets to be loaded
  95491. * @param onSuccess is a callback called when the task is successfully executed
  95492. * @param onError is a callback called if an error occurs
  95493. */
  95494. TextFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  95495. var _this = this;
  95496. scene._loadFile(this.url, function (data) {
  95497. _this.text = data;
  95498. onSuccess();
  95499. }, undefined, false, false, function (request, exception) {
  95500. if (request) {
  95501. onError(request.status + " " + request.statusText, exception);
  95502. }
  95503. });
  95504. };
  95505. return TextFileAssetTask;
  95506. }(AbstractAssetTask));
  95507. /**
  95508. * Define a task used by AssetsManager to load binary data
  95509. */
  95510. var BinaryFileAssetTask = /** @class */ (function (_super) {
  95511. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BinaryFileAssetTask, _super);
  95512. /**
  95513. * Creates a new BinaryFileAssetTask object
  95514. * @param name defines the name of the new task
  95515. * @param url defines the location of the file to load
  95516. */
  95517. function BinaryFileAssetTask(
  95518. /**
  95519. * Defines the name of the task
  95520. */
  95521. name,
  95522. /**
  95523. * Defines the location of the file to load
  95524. */
  95525. url) {
  95526. var _this = _super.call(this, name) || this;
  95527. _this.name = name;
  95528. _this.url = url;
  95529. return _this;
  95530. }
  95531. /**
  95532. * Execute the current task
  95533. * @param scene defines the scene where you want your assets to be loaded
  95534. * @param onSuccess is a callback called when the task is successfully executed
  95535. * @param onError is a callback called if an error occurs
  95536. */
  95537. BinaryFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  95538. var _this = this;
  95539. scene._loadFile(this.url, function (data) {
  95540. _this.data = data;
  95541. onSuccess();
  95542. }, undefined, true, true, function (request, exception) {
  95543. if (request) {
  95544. onError(request.status + " " + request.statusText, exception);
  95545. }
  95546. });
  95547. };
  95548. return BinaryFileAssetTask;
  95549. }(AbstractAssetTask));
  95550. /**
  95551. * Define a task used by AssetsManager to load images
  95552. */
  95553. var ImageAssetTask = /** @class */ (function (_super) {
  95554. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageAssetTask, _super);
  95555. /**
  95556. * Creates a new ImageAssetTask
  95557. * @param name defines the name of the task
  95558. * @param url defines the location of the image to load
  95559. */
  95560. function ImageAssetTask(
  95561. /**
  95562. * Defines the name of the task
  95563. */
  95564. name,
  95565. /**
  95566. * Defines the location of the image to load
  95567. */
  95568. url) {
  95569. var _this = _super.call(this, name) || this;
  95570. _this.name = name;
  95571. _this.url = url;
  95572. return _this;
  95573. }
  95574. /**
  95575. * Execute the current task
  95576. * @param scene defines the scene where you want your assets to be loaded
  95577. * @param onSuccess is a callback called when the task is successfully executed
  95578. * @param onError is a callback called if an error occurs
  95579. */
  95580. ImageAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  95581. var _this = this;
  95582. var img = new Image();
  95583. _tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(this.url, img);
  95584. img.onload = function () {
  95585. _this.image = img;
  95586. onSuccess();
  95587. };
  95588. img.onerror = function (err) {
  95589. onError("Error loading image", err);
  95590. };
  95591. img.src = this.url;
  95592. };
  95593. return ImageAssetTask;
  95594. }(AbstractAssetTask));
  95595. /**
  95596. * Define a task used by AssetsManager to load 2D textures
  95597. */
  95598. var TextureAssetTask = /** @class */ (function (_super) {
  95599. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureAssetTask, _super);
  95600. /**
  95601. * Creates a new TextureAssetTask object
  95602. * @param name defines the name of the task
  95603. * @param url defines the location of the file to load
  95604. * @param noMipmap defines if mipmap should not be generated (default is false)
  95605. * @param invertY defines if texture must be inverted on Y axis (default is false)
  95606. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  95607. */
  95608. function TextureAssetTask(
  95609. /**
  95610. * Defines the name of the task
  95611. */
  95612. name,
  95613. /**
  95614. * Defines the location of the file to load
  95615. */
  95616. url,
  95617. /**
  95618. * Defines if mipmap should not be generated (default is false)
  95619. */
  95620. noMipmap,
  95621. /**
  95622. * Defines if texture must be inverted on Y axis (default is false)
  95623. */
  95624. invertY,
  95625. /**
  95626. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  95627. */
  95628. samplingMode) {
  95629. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  95630. var _this = _super.call(this, name) || this;
  95631. _this.name = name;
  95632. _this.url = url;
  95633. _this.noMipmap = noMipmap;
  95634. _this.invertY = invertY;
  95635. _this.samplingMode = samplingMode;
  95636. return _this;
  95637. }
  95638. /**
  95639. * Execute the current task
  95640. * @param scene defines the scene where you want your assets to be loaded
  95641. * @param onSuccess is a callback called when the task is successfully executed
  95642. * @param onError is a callback called if an error occurs
  95643. */
  95644. TextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  95645. var onload = function () {
  95646. onSuccess();
  95647. };
  95648. var onerror = function (message, exception) {
  95649. onError(message, exception);
  95650. };
  95651. this.texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](this.url, scene, this.noMipmap, this.invertY, this.samplingMode, onload, onerror);
  95652. };
  95653. return TextureAssetTask;
  95654. }(AbstractAssetTask));
  95655. /**
  95656. * Define a task used by AssetsManager to load cube textures
  95657. */
  95658. var CubeTextureAssetTask = /** @class */ (function (_super) {
  95659. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTextureAssetTask, _super);
  95660. /**
  95661. * Creates a new CubeTextureAssetTask
  95662. * @param name defines the name of the task
  95663. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  95664. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  95665. * @param noMipmap defines if mipmaps should not be generated (default is false)
  95666. * @param files defines the explicit list of files (undefined by default)
  95667. */
  95668. function CubeTextureAssetTask(
  95669. /**
  95670. * Defines the name of the task
  95671. */
  95672. name,
  95673. /**
  95674. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  95675. */
  95676. url,
  95677. /**
  95678. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  95679. */
  95680. extensions,
  95681. /**
  95682. * Defines if mipmaps should not be generated (default is false)
  95683. */
  95684. noMipmap,
  95685. /**
  95686. * Defines the explicit list of files (undefined by default)
  95687. */
  95688. files) {
  95689. var _this = _super.call(this, name) || this;
  95690. _this.name = name;
  95691. _this.url = url;
  95692. _this.extensions = extensions;
  95693. _this.noMipmap = noMipmap;
  95694. _this.files = files;
  95695. return _this;
  95696. }
  95697. /**
  95698. * Execute the current task
  95699. * @param scene defines the scene where you want your assets to be loaded
  95700. * @param onSuccess is a callback called when the task is successfully executed
  95701. * @param onError is a callback called if an error occurs
  95702. */
  95703. CubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  95704. var onload = function () {
  95705. onSuccess();
  95706. };
  95707. var onerror = function (message, exception) {
  95708. onError(message, exception);
  95709. };
  95710. this.texture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__["CubeTexture"](this.url, scene, this.extensions, this.noMipmap, this.files, onload, onerror);
  95711. };
  95712. return CubeTextureAssetTask;
  95713. }(AbstractAssetTask));
  95714. /**
  95715. * Define a task used by AssetsManager to load HDR cube textures
  95716. */
  95717. var HDRCubeTextureAssetTask = /** @class */ (function (_super) {
  95718. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTextureAssetTask, _super);
  95719. /**
  95720. * Creates a new HDRCubeTextureAssetTask object
  95721. * @param name defines the name of the task
  95722. * @param url defines the location of the file to load
  95723. * @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.
  95724. * @param noMipmap defines if mipmaps should not be generated (default is false)
  95725. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  95726. * @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)
  95727. * @param reserved Internal use only
  95728. */
  95729. function HDRCubeTextureAssetTask(
  95730. /**
  95731. * Defines the name of the task
  95732. */
  95733. name,
  95734. /**
  95735. * Defines the location of the file to load
  95736. */
  95737. url,
  95738. /**
  95739. * Defines the desired size (the more it increases the longer the generation will be)
  95740. */
  95741. size,
  95742. /**
  95743. * Defines if mipmaps should not be generated (default is false)
  95744. */
  95745. noMipmap,
  95746. /**
  95747. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  95748. */
  95749. generateHarmonics,
  95750. /**
  95751. * 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)
  95752. */
  95753. gammaSpace,
  95754. /**
  95755. * Internal Use Only
  95756. */
  95757. reserved) {
  95758. if (noMipmap === void 0) { noMipmap = false; }
  95759. if (generateHarmonics === void 0) { generateHarmonics = true; }
  95760. if (gammaSpace === void 0) { gammaSpace = false; }
  95761. if (reserved === void 0) { reserved = false; }
  95762. var _this = _super.call(this, name) || this;
  95763. _this.name = name;
  95764. _this.url = url;
  95765. _this.size = size;
  95766. _this.noMipmap = noMipmap;
  95767. _this.generateHarmonics = generateHarmonics;
  95768. _this.gammaSpace = gammaSpace;
  95769. _this.reserved = reserved;
  95770. return _this;
  95771. }
  95772. /**
  95773. * Execute the current task
  95774. * @param scene defines the scene where you want your assets to be loaded
  95775. * @param onSuccess is a callback called when the task is successfully executed
  95776. * @param onError is a callback called if an error occurs
  95777. */
  95778. HDRCubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  95779. var onload = function () {
  95780. onSuccess();
  95781. };
  95782. var onerror = function (message, exception) {
  95783. onError(message, exception);
  95784. };
  95785. 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);
  95786. };
  95787. return HDRCubeTextureAssetTask;
  95788. }(AbstractAssetTask));
  95789. /**
  95790. * Define a task used by AssetsManager to load Equirectangular cube textures
  95791. */
  95792. var EquiRectangularCubeTextureAssetTask = /** @class */ (function (_super) {
  95793. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](EquiRectangularCubeTextureAssetTask, _super);
  95794. /**
  95795. * Creates a new EquiRectangularCubeTextureAssetTask object
  95796. * @param name defines the name of the task
  95797. * @param url defines the location of the file to load
  95798. * @param size defines the desired size (the more it increases the longer the generation will be)
  95799. * If the size is omitted this implies you are using a preprocessed cubemap.
  95800. * @param noMipmap defines if mipmaps should not be generated (default is false)
  95801. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  95802. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  95803. * (default is true)
  95804. */
  95805. function EquiRectangularCubeTextureAssetTask(
  95806. /**
  95807. * Defines the name of the task
  95808. */
  95809. name,
  95810. /**
  95811. * Defines the location of the file to load
  95812. */
  95813. url,
  95814. /**
  95815. * Defines the desired size (the more it increases the longer the generation will be)
  95816. */
  95817. size,
  95818. /**
  95819. * Defines if mipmaps should not be generated (default is false)
  95820. */
  95821. noMipmap,
  95822. /**
  95823. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  95824. * but the standard material would require them in Gamma space) (default is true)
  95825. */
  95826. gammaSpace) {
  95827. if (noMipmap === void 0) { noMipmap = false; }
  95828. if (gammaSpace === void 0) { gammaSpace = true; }
  95829. var _this = _super.call(this, name) || this;
  95830. _this.name = name;
  95831. _this.url = url;
  95832. _this.size = size;
  95833. _this.noMipmap = noMipmap;
  95834. _this.gammaSpace = gammaSpace;
  95835. return _this;
  95836. }
  95837. /**
  95838. * Execute the current task
  95839. * @param scene defines the scene where you want your assets to be loaded
  95840. * @param onSuccess is a callback called when the task is successfully executed
  95841. * @param onError is a callback called if an error occurs
  95842. */
  95843. EquiRectangularCubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  95844. var onload = function () {
  95845. onSuccess();
  95846. };
  95847. var onerror = function (message, exception) {
  95848. onError(message, exception);
  95849. };
  95850. this.texture = new _Materials_Textures_equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_7__["EquiRectangularCubeTexture"](this.url, scene, this.size, this.noMipmap, this.gammaSpace, onload, onerror);
  95851. };
  95852. return EquiRectangularCubeTextureAssetTask;
  95853. }(AbstractAssetTask));
  95854. /**
  95855. * This class can be used to easily import assets into a scene
  95856. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  95857. */
  95858. var AssetsManager = /** @class */ (function () {
  95859. /**
  95860. * Creates a new AssetsManager
  95861. * @param scene defines the scene to work on
  95862. */
  95863. function AssetsManager(scene) {
  95864. this._isLoading = false;
  95865. this._tasks = new Array();
  95866. this._waitingTasksCount = 0;
  95867. this._totalTasksCount = 0;
  95868. /**
  95869. * Observable called when all tasks are processed
  95870. */
  95871. this.onTaskSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  95872. /**
  95873. * Observable called when a task had an error
  95874. */
  95875. this.onTaskErrorObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  95876. /**
  95877. * Observable called when all tasks were executed
  95878. */
  95879. this.onTasksDoneObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  95880. /**
  95881. * Observable called when a task is done (whatever the result is)
  95882. */
  95883. this.onProgressObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  95884. /**
  95885. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  95886. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95887. */
  95888. this.useDefaultLoadingScreen = true;
  95889. this._scene = scene;
  95890. }
  95891. /**
  95892. * Add a MeshAssetTask to the list of active tasks
  95893. * @param taskName defines the name of the new task
  95894. * @param meshesNames defines the name of meshes to load
  95895. * @param rootUrl defines the root url to use to locate files
  95896. * @param sceneFilename defines the filename of the scene file
  95897. * @returns a new MeshAssetTask object
  95898. */
  95899. AssetsManager.prototype.addMeshTask = function (taskName, meshesNames, rootUrl, sceneFilename) {
  95900. var task = new MeshAssetTask(taskName, meshesNames, rootUrl, sceneFilename);
  95901. this._tasks.push(task);
  95902. return task;
  95903. };
  95904. /**
  95905. * Add a TextFileAssetTask to the list of active tasks
  95906. * @param taskName defines the name of the new task
  95907. * @param url defines the url of the file to load
  95908. * @returns a new TextFileAssetTask object
  95909. */
  95910. AssetsManager.prototype.addTextFileTask = function (taskName, url) {
  95911. var task = new TextFileAssetTask(taskName, url);
  95912. this._tasks.push(task);
  95913. return task;
  95914. };
  95915. /**
  95916. * Add a BinaryFileAssetTask to the list of active tasks
  95917. * @param taskName defines the name of the new task
  95918. * @param url defines the url of the file to load
  95919. * @returns a new BinaryFileAssetTask object
  95920. */
  95921. AssetsManager.prototype.addBinaryFileTask = function (taskName, url) {
  95922. var task = new BinaryFileAssetTask(taskName, url);
  95923. this._tasks.push(task);
  95924. return task;
  95925. };
  95926. /**
  95927. * Add a ImageAssetTask to the list of active tasks
  95928. * @param taskName defines the name of the new task
  95929. * @param url defines the url of the file to load
  95930. * @returns a new ImageAssetTask object
  95931. */
  95932. AssetsManager.prototype.addImageTask = function (taskName, url) {
  95933. var task = new ImageAssetTask(taskName, url);
  95934. this._tasks.push(task);
  95935. return task;
  95936. };
  95937. /**
  95938. * Add a TextureAssetTask to the list of active tasks
  95939. * @param taskName defines the name of the new task
  95940. * @param url defines the url of the file to load
  95941. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  95942. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  95943. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  95944. * @returns a new TextureAssetTask object
  95945. */
  95946. AssetsManager.prototype.addTextureTask = function (taskName, url, noMipmap, invertY, samplingMode) {
  95947. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  95948. var task = new TextureAssetTask(taskName, url, noMipmap, invertY, samplingMode);
  95949. this._tasks.push(task);
  95950. return task;
  95951. };
  95952. /**
  95953. * Add a CubeTextureAssetTask to the list of active tasks
  95954. * @param taskName defines the name of the new task
  95955. * @param url defines the url of the file to load
  95956. * @param extensions defines the extension to use to load the cube map (can be null)
  95957. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  95958. * @param files defines the list of files to load (can be null)
  95959. * @returns a new CubeTextureAssetTask object
  95960. */
  95961. AssetsManager.prototype.addCubeTextureTask = function (taskName, url, extensions, noMipmap, files) {
  95962. var task = new CubeTextureAssetTask(taskName, url, extensions, noMipmap, files);
  95963. this._tasks.push(task);
  95964. return task;
  95965. };
  95966. /**
  95967. *
  95968. * Add a HDRCubeTextureAssetTask to the list of active tasks
  95969. * @param taskName defines the name of the new task
  95970. * @param url defines the url of the file to load
  95971. * @param size defines the size you want for the cubemap (can be null)
  95972. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  95973. * @param generateHarmonics defines if you want to automatically generate (true by default)
  95974. * @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)
  95975. * @param reserved Internal use only
  95976. * @returns a new HDRCubeTextureAssetTask object
  95977. */
  95978. AssetsManager.prototype.addHDRCubeTextureTask = function (taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved) {
  95979. if (noMipmap === void 0) { noMipmap = false; }
  95980. if (generateHarmonics === void 0) { generateHarmonics = true; }
  95981. if (gammaSpace === void 0) { gammaSpace = false; }
  95982. if (reserved === void 0) { reserved = false; }
  95983. var task = new HDRCubeTextureAssetTask(taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved);
  95984. this._tasks.push(task);
  95985. return task;
  95986. };
  95987. /**
  95988. *
  95989. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  95990. * @param taskName defines the name of the new task
  95991. * @param url defines the url of the file to load
  95992. * @param size defines the size you want for the cubemap (can be null)
  95993. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  95994. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  95995. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  95996. * @returns a new EquiRectangularCubeTextureAssetTask object
  95997. */
  95998. AssetsManager.prototype.addEquiRectangularCubeTextureAssetTask = function (taskName, url, size, noMipmap, gammaSpace) {
  95999. if (noMipmap === void 0) { noMipmap = false; }
  96000. if (gammaSpace === void 0) { gammaSpace = true; }
  96001. var task = new EquiRectangularCubeTextureAssetTask(taskName, url, size, noMipmap, gammaSpace);
  96002. this._tasks.push(task);
  96003. return task;
  96004. };
  96005. /**
  96006. * Remove a task from the assets manager.
  96007. * @param task the task to remove
  96008. */
  96009. AssetsManager.prototype.removeTask = function (task) {
  96010. var index = this._tasks.indexOf(task);
  96011. if (index > -1) {
  96012. this._tasks.splice(index, 1);
  96013. }
  96014. };
  96015. AssetsManager.prototype._decreaseWaitingTasksCount = function (task) {
  96016. this._waitingTasksCount--;
  96017. try {
  96018. if (this.onProgress) {
  96019. this.onProgress(this._waitingTasksCount, this._totalTasksCount, task);
  96020. }
  96021. this.onProgressObservable.notifyObservers(new AssetsProgressEvent(this._waitingTasksCount, this._totalTasksCount, task));
  96022. }
  96023. catch (e) {
  96024. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Error("Error running progress callbacks.");
  96025. console.log(e);
  96026. }
  96027. if (this._waitingTasksCount === 0) {
  96028. try {
  96029. if (this.onFinish) {
  96030. this.onFinish(this._tasks);
  96031. }
  96032. // Let's remove successfull tasks
  96033. var currentTasks = this._tasks.slice();
  96034. for (var _i = 0, currentTasks_1 = currentTasks; _i < currentTasks_1.length; _i++) {
  96035. var task = currentTasks_1[_i];
  96036. if (task.taskState === AssetTaskState.DONE) {
  96037. var index = this._tasks.indexOf(task);
  96038. if (index > -1) {
  96039. this._tasks.splice(index, 1);
  96040. }
  96041. }
  96042. }
  96043. this.onTasksDoneObservable.notifyObservers(this._tasks);
  96044. }
  96045. catch (e) {
  96046. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Error("Error running tasks-done callbacks.");
  96047. console.log(e);
  96048. }
  96049. this._isLoading = false;
  96050. this._scene.getEngine().hideLoadingUI();
  96051. }
  96052. };
  96053. AssetsManager.prototype._runTask = function (task) {
  96054. var _this = this;
  96055. var done = function () {
  96056. try {
  96057. if (_this.onTaskSuccess) {
  96058. _this.onTaskSuccess(task);
  96059. }
  96060. _this.onTaskSuccessObservable.notifyObservers(task);
  96061. _this._decreaseWaitingTasksCount(task);
  96062. }
  96063. catch (e) {
  96064. error("Error executing task success callbacks", e);
  96065. }
  96066. };
  96067. var error = function (message, exception) {
  96068. task._setErrorObject(message, exception);
  96069. if (_this.onTaskError) {
  96070. _this.onTaskError(task);
  96071. }
  96072. _this.onTaskErrorObservable.notifyObservers(task);
  96073. _this._decreaseWaitingTasksCount(task);
  96074. };
  96075. task.run(this._scene, done, error);
  96076. };
  96077. /**
  96078. * Reset the AssetsManager and remove all tasks
  96079. * @return the current instance of the AssetsManager
  96080. */
  96081. AssetsManager.prototype.reset = function () {
  96082. this._isLoading = false;
  96083. this._tasks = new Array();
  96084. return this;
  96085. };
  96086. /**
  96087. * Start the loading process
  96088. * @return the current instance of the AssetsManager
  96089. */
  96090. AssetsManager.prototype.load = function () {
  96091. if (this._isLoading) {
  96092. return this;
  96093. }
  96094. this._isLoading = true;
  96095. this._waitingTasksCount = this._tasks.length;
  96096. this._totalTasksCount = this._tasks.length;
  96097. if (this._waitingTasksCount === 0) {
  96098. this._isLoading = false;
  96099. if (this.onFinish) {
  96100. this.onFinish(this._tasks);
  96101. }
  96102. this.onTasksDoneObservable.notifyObservers(this._tasks);
  96103. return this;
  96104. }
  96105. if (this.useDefaultLoadingScreen) {
  96106. this._scene.getEngine().displayLoadingUI();
  96107. }
  96108. for (var index = 0; index < this._tasks.length; index++) {
  96109. var task = this._tasks[index];
  96110. if (task.taskState === AssetTaskState.INIT) {
  96111. this._runTask(task);
  96112. }
  96113. }
  96114. return this;
  96115. };
  96116. /**
  96117. * Start the loading process as an async operation
  96118. * @return a promise returning the list of failed tasks
  96119. */
  96120. AssetsManager.prototype.loadAsync = function () {
  96121. var _this = this;
  96122. return new Promise(function (resolve, reject) {
  96123. _this.onTasksDoneObservable.addOnce(function (remainingTasks) {
  96124. if (remainingTasks && remainingTasks.length) {
  96125. reject(remainingTasks);
  96126. }
  96127. else {
  96128. resolve();
  96129. }
  96130. });
  96131. });
  96132. };
  96133. return AssetsManager;
  96134. }());
  96135. /***/ }),
  96136. /***/ "./Misc/brdfTextureTools.ts":
  96137. /*!**********************************!*\
  96138. !*** ./Misc/brdfTextureTools.ts ***!
  96139. \**********************************/
  96140. /*! exports provided: BRDFTextureTools */
  96141. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96142. "use strict";
  96143. __webpack_require__.r(__webpack_exports__);
  96144. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BRDFTextureTools", function() { return BRDFTextureTools; });
  96145. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  96146. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  96147. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  96148. /**
  96149. * Class used to host texture specific utilities
  96150. */
  96151. var BRDFTextureTools = /** @class */ (function () {
  96152. function BRDFTextureTools() {
  96153. }
  96154. /**
  96155. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  96156. * @param texture the texture to expand.
  96157. */
  96158. BRDFTextureTools._ExpandDefaultBRDFTexture = function (texture) {
  96159. // Gets everything ready.
  96160. var engine = texture.getEngine();
  96161. var caps = engine.getCaps();
  96162. var expandTexture = false;
  96163. // If half float available we can uncompress the texture
  96164. if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  96165. expandTexture = true;
  96166. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_HALF_FLOAT;
  96167. }
  96168. // If full float available we can uncompress the texture
  96169. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  96170. expandTexture = true;
  96171. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_FLOAT;
  96172. }
  96173. // Expand the texture if possible
  96174. if (expandTexture) {
  96175. // Do not use during decode.
  96176. texture.isReady = false;
  96177. // Simply run through the decode PP.
  96178. var rgbdPostProcess_1 = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]("rgbdDecode", "rgbdDecode", null, null, 1, null, _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE, engine, false, undefined, texture.type, undefined, null, false);
  96179. texture._isRGBD = false;
  96180. texture.invertY = false;
  96181. // Hold the output of the decoding.
  96182. var expandedTexture_1 = engine.createRenderTargetTexture(texture.width, {
  96183. generateDepthBuffer: false,
  96184. generateMipMaps: false,
  96185. generateStencilBuffer: false,
  96186. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  96187. type: texture.type,
  96188. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGBA
  96189. });
  96190. rgbdPostProcess_1.getEffect().executeWhenCompiled(function () {
  96191. // PP Render Pass
  96192. rgbdPostProcess_1.onApply = function (effect) {
  96193. effect._bindTexture("textureSampler", texture);
  96194. effect.setFloat2("scale", 1, 1);
  96195. };
  96196. engine.scenes[0].postProcessManager.directRender([rgbdPostProcess_1], expandedTexture_1, true);
  96197. // Cleanup
  96198. engine.restoreDefaultFramebuffer();
  96199. engine._releaseTexture(texture);
  96200. engine._releaseFramebufferObjects(expandedTexture_1);
  96201. if (rgbdPostProcess_1) {
  96202. rgbdPostProcess_1.dispose();
  96203. }
  96204. // Internal Swap
  96205. expandedTexture_1._swapAndDie(texture);
  96206. // Ready to get rolling again.
  96207. texture.isReady = true;
  96208. });
  96209. }
  96210. };
  96211. /**
  96212. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  96213. * @param scene defines the hosting scene
  96214. * @returns the environment BRDF texture
  96215. */
  96216. BRDFTextureTools.GetEnvironmentBRDFTexture = function (scene) {
  96217. var _this = this;
  96218. if (!scene.environmentBRDFTexture) {
  96219. // Forces Delayed Texture Loading to prevent undefined error whilst setting RGBD values.
  96220. var useDelayedTextureLoading = scene.useDelayedTextureLoading;
  96221. scene.useDelayedTextureLoading = false;
  96222. 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);
  96223. texture._texture._isRGBD = true;
  96224. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  96225. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  96226. scene.environmentBRDFTexture = texture;
  96227. scene.useDelayedTextureLoading = useDelayedTextureLoading;
  96228. texture.onLoadObservable.addOnce(function () {
  96229. _this._ExpandDefaultBRDFTexture(texture._texture);
  96230. });
  96231. }
  96232. return scene.environmentBRDFTexture;
  96233. };
  96234. BRDFTextureTools._environmentBRDFBase64Texture = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAgAElEQVR4Xuy9Ccx261oW9q5v/r7/33ufgalSbWtiTJsmTZOmSdOkpVKsWhxAxIJFQaCKUkpFiiBFKjKPh3PO7hjb2LmNnYxtjbGtbY21rQGkgCgiIKPMM5x99ruatZ7puq/7up/nWd/3bzzABjb/9675Xeu5hnt41rv8s+evW9fz+ZT+W9N/63o6re3v+nlfvq2CbdZT2hbW7dukDbf/a/9uS3G7E69Ln9PifK50sHSMvD2ur3+XY/E2++dyPelDPoU7Jm9XTm2uab86vJ56gvSd80dzXflA+Zul74PHwGuGv/MXLv+kL4Lfp56r3DM8ef6utE10Xnu97fra7uWi2/etZ8BV/F3F+fdni/8Dn9O4KSvt/cxPMa+HY5Qx024OHF3cM7zHdcsy3uAeuu3wPve3S2OVthHH09v5e9BuCT0HHgPlHsjz+3uxNALYAJ9JgAigALyBmQGPQEcAxwRQgVhIogwcIoAG2HYsM1gR3IokEDD5biMBhMeSoLXkweCoAxsGcDoX3Xi3nkCFACnfiQaPARECgPaVAMZjEuAsNttAjIBZSY8HXHkuFctt4Npj2e8+B/ImFOnwEcg9SPEqcNdyDBSZemwipBkwmvMwocG9Gm6nCDUisHpb+iSRTp+2kQTQAJ9cACt8cwRN/Ss5IJBJ7a2qC0AHYK4gUkpuQE2uoTiJfMPw4epjeqdRXYE5Rhu0me7aGCwIKtfFD0sAmklCgWBmG3utbfCrfdtlBUpK6qUIpwCkkUYDIg4yp4QhAeW9GDBwLR6glgysC8PvZq6o2MJMT3jdhtKqI0WiMfeTCMhs54BqzwNPyLueclxzS/3+XQI0jtSSQrmly4ecv249Z+U/gQOoNj+HBKj+yhGEtn9/2C10qLaWLH5Tz6KykeI3FTb7wM0uRJMWlZtmQwgXFgAr23VwDGRjADoPOgMIQ1pigNdnCrbviaqvFMopuDpvHjB8/RXoeI8ydGp4RAM2x13NzQtr74BkQoFZlceBDQTugIlaixa7kbn5nl3wNgVNpxGKi2OvQxJmjOJ24riNB/sKX0VJPS/zjNfTTgAp9s95AIj9K9DPqPQc22+nS6C0eYAGZJMLyF+sPPwGVggXypcH8HggA5gwbCjHhy9v1Z7yDIY4Gie3nIMGrQHUUNVBVeq14rnyOeiBvWjVl8QgQoZ6NajErESk0n0wx4CLFLuXJ5gOE4J8gtV4cW2RlYbvrO5lVWMk10KU6lpwrHbBr8cHn8+EMdH5YPl2H4gANhCmPEABLTsBp/5k+Y1TwGReWlGTgqiy6WFrxXcEQQTilLw8mUP5AIh1pbJnTgUrOiYIVBZKMAXqW7GISigAyjbYgkWfyyqyTTI5ZckLokEehQNxAs8TYMHF8X3w+3kSrcc1qozPAsAUqbfLX8B5AKgyFGBidOcIiB8JAMdZWV4fGak/nU+Sd0BC266CANbTqdp+zPZHmX9Uf1Txju1HxS6DbeeAZtOtavtKAILAhw9B1aCNjhyJELDZrldlFwRB1YT2nJtUNnVTBPJ41Y+dAQwOE2eD6+EBWZ4FDDRUFmUn7ZiLzjkgGbgOTTTintG1y2QiuKh2ZSKrLoDDVt4RI90jc28CMunnC/AK27iBhEB+FHgme78rtk2w5b+vcguSAKLyH5YCfT6ghAgFeAh+H9PXBxcBPiKICjo4fnEE+ODLk1NJQ7M9PACXK2iqgTa1DTpPHo59FYGgNZuM9T1AoBphFMIPIhXPMzG1Q/jBVYceAobVqCElHYo+uzwBPKvGyXBuY1O9YjZBQzOP312TK4PAVjDw/Hn/p5CEJKI2puq15C/jXFz7kiZB2CPLckzzzIPjlMtbPuT89WtK/rUSoOkFMDV/KvflEp6pCnCtH614yRPU0AAScxjvlwGABFFGlgQ12MJD+QCt7HX88bEE2aRFFnhGOdBO5hWsLDOx/mzZT6meSgAa9cLrYnA6O0yqxSDpbG/uFRAXwDWPYUsG1s2Le91Yp8CJsK5VM6wYUJyMGLLqjESsCcykC80XsddknltlRSC/fL+GBFAdXXw97fDrafnnzl+fG4FyIrAAPggD9nsTNQIhsLfziwqAVX+r5IcqAQKMxZlYUBaSQVUog4jWgXJhCGKah1QlQIUDZlDSQCm804n1+6rfQOAqEALA0SCMcwdeqZyqONKIQBsAVoBWKlcvRKnq6YHSKmAa/LJKUZFBJMf3tEdeJvmGY05cIx1XkXIlH8re8/J0SeK6I3LMvQCSAHQYULL8OhfApT6X2BN2v4YSRxW/Hivf4ALcScuPAx9JxxIHwKY6AXiIfC5+mHBNj63rW2cAwyMiDiQnygJ3AQzEZ+6BG+iCGBQ4BqD1cTHlKFTJUA3kyi0RyHF8EAAVWOg+vBCSqLeMFFnct64jOXAcW6SM8wHbLcgEUNT/3BKA2BJsWnoFAahKgGv79V2Bs5WAWkbkHAAMirgnoA1ajN8REKHay/IesCzkDdrzfMR6/B5moHuLORMu1PtKipbG9wGldsSgQVSpqdkWECRtRcPyn1DQGTVvl+rPh7pYOA2tvKxE8DOBJJuq+4/i7rj0SKpN9zA9QpFQbV9EtBxbZ1uPUcYDuAlDAEn5z83i7yRgld91AXZiftMXkG9oAartCqQKQOgIhOKHMX8elsbWF8mgdRSnm0QfJry4SoCEhAwND9EMjFE+wCXXJlS/o7ZK9RXwDhNDl0jsgJ2r81cpz8a0MpfrkJNA53sQqWsHXI8mCXZdCDImRAHmuvljjiO+Z+0FUG5GCMLy6/YcAAB/B30igdOZ4/2dDRJBIKCNQyggxfheNfn4kh8qsSGKei6v5l7VDyQEcSBzWIEKgDeTtkubWQvKg5StfBsXI4DDd2ky2EBirkt3pw3BXbFnQdjGVqSoj9weBi3fB1QqHyaIe0FEZMmmnigfNqoYwDOge4zg1AovQhcCmflOgjgbX4jrCLavWzpCa8/EOQ5xXds2y687f0ObDchdgC4M2E4wqAQYYsiDcrcRDSjVRRiQlQds/5WzAE3mHSoJlJGfIoeW8jezBDON+R7/URIQE4IyJvcJQT5XSzqCLhHJtOFN9pBVh0iil5U+5BhUnM6qw3G2UOCo4w/hkNUGtDWIa3mOgVC8CsjhtVhSN/c7ALl0J0Aqs6BkUkASUWMFiapFKoLwRCgBBJCUf9wE1MCswoEKdOcSChlQf76y8PlOGkeAeYZCMkwg+SlJ4PfIQal9uQZULKW4sAxVi2N1rr2zMusyXx/cKtZXqtrtFJxQ5C4xKBWeARc7D6F2GlAQLu4j3zoRoEwXPqRTkKMBMJt9pWLWAZbX2mON8gDTyTl4Jgbc7lrFd8HxiPdH3N9tkSGAU24DtmU+7gYsTT8lHGjlPhPz13gZFV01BWUbpWr+tazYyMOoI8TkCKg4ISgUtRIQcDwk9xhQ0u4jIQHL6m0bqDn5xANopvZ/vMZfvpGoYbscRNWbLEITA55VGMhAkZMrsfYAqQa3JBsgBiKJUTKuOg9x3PBa8ZljsjCqZojlqPIy/CFCMg6pfEe6ZvNdA+JbPrSGAG0egO36C8p+KTtYe/ttGZBzBKz+uv5fzotMPQLz/r3YRbhqAYDOgdvnDDzJIPNb4BxK8kX5AnQghqk74cJAubXqB7aWBodSMnU8Qw8MdHPMdv/cwOUEnhvEvnLRxnusgD0n0AM5CgmCMp1T2epj9ffu8XuJQFLwEZH5Z9OIH11FJoACfnohSNDwo63/DBnkyyo5gTDbv329AtpokhAOKtq23shiD21ZxIUW9VBwHACYsdomk5+HEiiTGSQ4uCsggqYg/L547mJyMZ5mNqdKRc0Eq0HDAMNrZyJS5SfaXlpqvEfRwOXjRKrIcxoitWUSI8WcUth8TYY81LPoJQs75+2SSM9F0DUYcHfcRLvFgijzdyAC2DL/rQyIQEdXYGYE1jKgz/Tbkh/Z/5QsqH3jBpQqL4AM3Fmv3QOFEDgoe9l/tZ1RAuEsROLPKo6v0VpVoGx34bBDYBxUD14EMQwciGp+CgGggMeOgq45Lnd13MZR8gjAFfYNDBUcoYturN7MmtMwTolJOoN35Ca6oUS+1uVDz38tVQFKAhBagBvQC1gpHJDgB3vPiUAX00MG38TzXtGl1e/lDdJoM5l9vGH4EF03IA+UMkBRPY0TgAcrcgpISra7TOUDhKswpBN1zen9npIAVANdDjrOHQycROMOr0xy0KrjT4C5FwO3R6nU8RHJwgN5AKPgh8EN/iRKaIJDafeAvmf+uBNAUn07GagP/jLYIkIoNzB2BVb9i8x5R+DsugFj277adAYrzcjzFQIkCkhYssIpYKtOQUkedI4qUlXeoQFmPkloQhPhPIrtVVZQgpsHY5DQi4A1TRiVw/ygNMqnnErPDgsw9TLz7lwHbPhIofsE411geVYtgtDEhFUPXVZUY8o7jMQR62n556sDaM1AUSlw2ASkbH3JI1T1hwRhecBQMTAqraw+EYCNz2dife4baDfHJRyNks3affEAYGCyIk8lEVlRZdKunVcBVA1YNUiniIE7INmhUIwMmmVKcxFIFGGNMvDTYMZcSrnO7BbbRzxae+6ufViQUZR/wX2738WFVoIICgYKW8jvQd8Bt4Xx6Aggeh9AHPejamN23ycF7Qs/mouoFrmC264z+yEYOKPP5ABZ9y64VYJOOYfIFaBSSVeAmWKRA0DlEqpbH2XFePkjHqj9TH65v6gMKfw0lpHPpxS5objAaP5FmjOhQ5PEdnyRhFMEV3cdJe3w/uNZguVpk6AiIPMABGJ1X0ffyZDUCNwgavB9SviJbiMTQGkCyglA1QFI8bypBHAuAOcHRK6g2K1uHK8tvrTx0/kAn2TD47Ux7sOB+shrdn8yhqfKASufBbi2h2FPQX7WXdUPiCPt6hUujXs7aB9VGmTnMhrkADgmPaO+Qez72CafOfdQb6JO1Kl7xgpNhDIq5Y3W1+cXOJiZ9cuH7SEA9gCUeQC5538v2aVLUZWApt4JrOkhROqPDoG2LczZrQBwchCYeBjrk+pB0rFlrGEosLswrD/OFdT7AgqGg5oVy5NLRXZ+vAKoA5C6hBreI3YzNIja9Qg1AdVvY7oRRpQl1wAVDUk9hVXKq4gDvh9/g6LgziGMQExuxwBMuIUeifVast11dZJ9LCYu1IDxh8pf/l4+7PyNtQpgfxUoE0EH/GWAaTdQ1EWECFV1RO8ArwubeoISotjfgFGp8UDRe3G6BK4KKYq5xhgUH6wAJ6s6D6gQpBznsvLwgAqsOEK68YO3s5bMhD09AlACWQQi5VIM0COwiuWjmDx0FjzvgxW/13pcSnnm2dC9jZKl5WGIHhFNACqPkc7lCGCU/TcuwLmCMeiNQzDg7gPa234RHqBysJPAhxG6hbhfwKgpxfkxMAHCgmTUwJtOEiqVrC61/EFg7Ci3AppXF9Atdh+kuFUdFaCFojm3IgECEBeK60kKAHUoZhfuS4B7lAcwKh8kHHUmH0u9nhSqkjviFgRiXI1fXwmA3wWgG39aP0BR1aPqnwY9WGhX/89DsRsKiPZfyAHg4EOlaOAC8jDEAKZOuQJUdraYUtl9vkFZP6tmgyShUB0GD37PSLldTG8SgA0AQ3VXRAT3xrgIJiiy3CoB6UDEJNa+YIYoJeciRxERlrPMMCaCZKLKvxSQmu/vzhkkEtnBgeIj+PHK6nLcNpOkeYZ0rOXX1xCAXgZi2oCx3s+WPq8zbiBfmgE6lP/KhWGcXZfBvji4iBAkmA2ZEIvS8QuBpfthldqqIZUWYdA64OLgRIUS2fUjrgEJLSozuUQmgUu6jXAbqxSOLAJra++HJ1McpC9K8Q8fRyQ9DVgDZ6G+W+WKSgxarVWoJglCnHtEIJVTpkuB9hozAeQkYGc6sCkD7oABN5AHeHUDBVTlC5mWX6X+jRwQmCVcqOUpTtzV4zfrjsAyYQMCV8XonbLfbPa/PT/rYurDDkkBO8/INeQnzOpolZlUipXWKEE9IDQf2az/oQSgIRGtvt0KRUURfiMYpNWJtaGO5SyrblSVKcfu9SWMzl9DEQ3uci09lY2Sn4ZAQDzqZZdzd8qY+OQrwdKxdJiR7tXy68//X2sF3kCArwTLLiCe/PMY9S+jEx2BBYyr2e+DQOQITJ2/Dex54Jfz0r4DV8AAQXWwyq7sPHK6Tc6MrHy8Pg8DVhAR9w5bgyN1V+oULkOw4rXZ5bpa4O/ZSKGZeJ26qnzFvlGrKjk1N+sZZoqgAoLo5R4UuTNpmVKtPgcLVCWC/B2ciwDS3gmgtgLvBJB7Ajrgt/kBTPwBkKlvIJ0zWF8v6A1KBIaVgTYgfaNQ0C8gyMEMD6oy1DME+QPnGsiiIrnU8wDDj9aPzh+pUDsFERYMHv7eJjwZqa5UdgzbiEQiIA2TewFoRCIyJhrhToj8nMqO1rcHA+a9XKslGA9g+508AYr1GCLAd1/+BXAAGwjw58AR6M3ed6x/vhKb5KOcQQXQRE9A7ari+j8QyUR2P3QEMJhVlaGJQL6hLkywKoKgsU7AZs8ZXHbboHKgBgwmKqMBxZliBbyZBKDscAs64jjnkVlGWWG+T45EgOwiwmF9xiYmDUzqeETVVSVRhKgkDiCIgFh0olCQaxl0ZmwSGdbrKTgYrBfHLGQHBFC6AakBCJOBEPcnV065AEwEFqA/QvVVCIBKZ5xE/nLVHnNVARUbB7/L8nMeQrgDAQKfjGykYHQDHEAT+UIsvgUX93XlJgFqoxKiPDSTyFMJNbmfcikiuabAzddpwTtSvn4LrrpWbvIqAx+eLiwSSt9UwOZMRNLNPDNa71UaQatzJ6b7kUBfL1qRNwIer9q4knS1mQC2o9gZgbIfQCT+ynYtUUd5AdMViKQRdAIa1dfJQZkPeArw4cZgXBqWDYGd8VraYhjmLuGo1mUYmAdkE4M8gJAQq2ry/hTj2n3QlSAcGilFaqxUVS/zyuSB0FfPIYmMlLKj6JbwgHxgRgS3RHviCPaTBGG3rcajNolZUnDrAxvfnqQ6vsqptO2W33D+pjVNBW4EMAX+mpgTicCB+isAO1U3vf0+BHCKT0qPA8e4B8wH4OCJYvSIHBhcYP10M0+5IpX4U27DNiXVLfA8Nc4m5arPt8AyyI5z9yHeQ1CR2BmIwa9IyBCmrezX17mRarXsugaNTiBqUnMuw90fIiqZVwDiFm6nKLJ1AUF1xXzXvAfdt6b+9GzpXsq8C7uPzrGJAHJ8nysBhgjodeCqDFjdgAoFirJHGf2q4FAdEACtpcEg9m84toM/zgMwucBwCcOE3ja4DocenKehOQ8FAdD80FgBR+VAsz5oJXXVBGnpo9IgAaHIlEzqiZJm+cYAQgsee96oEUiXtqicWiV0UFkogIzICwEb5DdGuQv3Pei+heszmKOKST2MChGUWBA5VAIwrwI7l5Bgu6HnWoKzbcDQHASKb+P3fqJPdwQWRmTF7FQIuurPwLPHxRIK21NPGn3gcznGOQ8kNBp0DQ8+HuQEEqtMz3HUKzZOJjOQUsIjQBYOQg1Uc71MbF0CadfplLXadOuompaDc+BkKbkNXaf3eZlCVPIc7CzpHI0g8nUJVVbfsQ2T8n2UI6IxI1xCdOzlN9YQoDQDbe8FhERgbt1V4J9OBAbqb/IGBGIdJsCtL+xmQgUcMAeB784/ytzT8XF/UFRHMNW22wHGCSwNavH9m4fQvw6rADeZ9T+UAKyXpgajzrp3yWKkxhVHHhBIvDqRZgmQXZMBemCfdVYfBIJzAJnoXJs2EIUF6YjY7Pdmp9gNIeDaMgHAj4PWXoDtkEFFQM73L3YvhxGh5QeFB9uf8EPqn8MFta5lxicnBWFyUYAVb6AELSaTEECsmAQu88B761JbCoDY21a53rgKqy5tiMCzKYqr5hQAOcnYUtnfIAutEmxqkJprNM+lkV0BZEhITSYLzGCIE1BCQNP5Bq6Bk7+Pdwd4B5Q7EOsFuTwqRNheCZYcQHkbcHshSCnxuV4A/jFQfBlIeYBmYk405dfH+sZyF+UqD2yg9N7Kl+FGg79Ty4+B3x7MlKJTEonBgAPZgjpI/HUdxcgV4MAOSKVnXwXo+ZpN/MrJVACnsqHqWPCNAFeQ0wESa7dGOQEPKHUNVbfrIQJ1LeeVYZK4z4bQ8Vv5a023KfiO+R46sgzcZL09kBeI9l1+4/mbN/mHFuD9F0HbLwTz36jsuQ/AN/6gkkfvA9BqX8Dis/xC6UmJnYpPrEfTZh6A3Nc/JLTqbO8Q+EhubVwASdXxYZOX5vqGMwEVwPuuQCWfZJKQBvMoL1GPaxQX9pIJqpjMKvakSxGACpxJlFTUSTigC7heF88XkgOCiIiGn2fbFfco32eOiKYqAeIat0XLbzp/M5QBs33fQR8QAai8aQTC5aYKgKFBUThUf87Ccx8BgM6oNzkItPjFPTCrKhuP24ZhAgGfVLGr6KyIImRQg9JE0nCMxhNtkDThEoNoYj5AwyjqBAxCvG+gvjFRdNQuOpZQS6da/KzwWkid00ehqJ0SnwPtTBhQgEXuISYARYLBfYfvh3c0x4p57ey+QCYwnoAASuafp/4CKewAwex/+Zxv9nZgUb8vpbum7pFDyF8TcgNVI8sorevK47UEg8ozCgvatqzEVoWdsyiDC9RNq71NJFq34bPMdtAUxwN7KdVUdlTZ9oESm3MH/fXOxaCq9MDZBUd5fm2IF/AmTrAqaIBAoDeupJbP2pgyxz2YpHNkVMVCX3ev7DdFDkFZ77H78rMrrmEngPYyEHgNGAK9/G1e/rkdEsGnGoJoPbkESRZGhZV7sIBI4w4AjAPRxfvgNsR+mA02gEbwUJwW2XxUZSQQHhhORTtq37Xdw1jdKw8PJhfCCHWzRDGX3VfgmU3oKVDX6hESEDXq7gPckJIFKj7rxgXGdxmFtc8Qj6X2IfdBBBiSQyUtrdae/Cw5soBUA6Fe457PtfyL529JIUDOA4zj/5wfcFl+Uv8Cyv1fPyGIXUF9qJzsK/sX8kDgvmjg98Dds/ITNp8HHD4sV/Iz5ASDbdrOm6Nn4dMDdQR6c91RYxERhVbi6v1LvcNodK8jEMm0qLgnlQw643SM56rnLeQQqam7/nwyvhfhtcgkYQ+s+Iw1qfq8g3JGR4ljPVUCaD8NHrgAUv9qz8yEoPIQAPR1fRz/s5NA6yfXdeL9+sghVJBWf+QUCv8juGFwNUs1b/OtW4hLfiOVta7BJv6G+wK5WHgoK56PRqDqkZkFhQU9g3Zs7wfhwahsicXAA0k8b5c7RIJ0NqX0mpyNWpOzKeDvJSoRM7h9OW5EXjsB+IlA7QdCqyPA+B+TfEgARaWd+peBVKgUwoVyXKfwvvMvjUNyFEYto3xAuek+BEBr13IGloVtOFCecgA8zj47V4EwaPfD2Ds+hrBwOEhZyXqOYgz6QtRsOK26uHNWMIrvlwd0e35+WNZB28s/IDDEPZKKPKveKvSiONw5BnZ+AriRy9AvFBXkQLmK8TV4Z9AjjuXDawiQmoF8CHDOoZRN/tX+gEoMj1P/FB5YgnDhgWgSUvuZUEMQAzqBpwMfHoXLFtsEHrNzE1TKUsvqAgEK1NgMF1I4BttItbsJPpOMixVMkgJcL+totbXDRF/sBBQg8I4VUmA6a+cG+w0AlrkHcR+c46lSHt+n0T49wKLzZKW398ITgXcB62n58PNf33MAthcAMv9VcYNqAMf3rgowjv+bwgrVL4MDlLRsL/cbAL8OQgSb+duCMp4S3Oxtcw68Lw675j56au9jcmWjtV1HYnFgm+jbj52EGsyjBKBSsyISFnSPyhlIex+7D3zuSArOEWUAPzpJSC6l3aUeIPF+BC6g7k6iYVzH8XXLb84E0H4dWLgAsP9NnSnpp0KEieRf2P4ryn3KiiuAovo5q6wqA5k0pCsg++1i/4w6va+107gNDzzMitvtKHlH1rer3NyRWAZLHkyjBJ9TjKjSMJNxD5yLUUPlYtQAN66C7g8DePaYBrgBCB05WOAyAbfEnQd4RDwtQekJwycCJ4jDuBrafnspKBIA/zYAv/EnBH+YB4jVv5f1d4pq1L+M3sZ2lRhggCrga/UH1uxYcEM09T6O9oXH7MIEP3XVkQsA1g7J2BU4YglBP1JjbbuVMjoiyYRqwG2A7PMMChBMmH01zQ8lJJrYkdiyYgOJDgM8Idvv+QSlB7JSdj3zD7yuZMbmw/ehPMd2PysBpNh/awkusX6uBvCEIIj504AtMTyDfWYOACblbAKvHtuAAFwHVQKUDe8n7wLwhkk7aEWmiTvTIYBxGp4cTOynLLtLOlUpd4PCVhzsQEG3YYGn+9Hx+yE8HMA7A5hdzWOPo67XLVP19OmQge4VEddjkncezNS7wudQHYyQkORQbVglMC7VuoDlt+whQJkKfLZTgWuv/xYW4Cu8EPTb0Rns21dGQOdbMFEStIm8OKtvjm+ARUAVZTwXItD+VhGA2CoF21jLuwOKRTlMoHp6D2BmrgFl2lmhXJkRtscrMoAR12bXazvMdtcOSriyTqZ8hhQcUYgwpKfATHZRgo3vT7PiFjBehe36CJz6nQMqfKGxY8ihF5rkdRQelXujCHdbtvyW87fWRqBUDoQ3A7vaP0wSUrMAwzxAuTj8t5MczIBM/2SCQZCinQ5i+sO5ASQsJhS8HnYk+bNT3CrO5YECmeVR5MKUolz0EC1h0YCr46UMjo4rgO+hgBCGIK7WPUsKSk1F/wMMcme7a7QD95FaiUys3S3nIQzstT0pDDDXb7+fJwx1T+haypgSzkCRswW5vU/9dWsigNoHkJ1AfSFIN/lX7H++pAN5gJpbQIAXJar/ti/Ssv4wyFG5wFnIUh+WETlhxbF5RCiGBArIyAmoZBiHFHUbfJR9cjAPvVeSU/0DHdAjafE58D5GgxiJqausQGgqrjbLZB+AVso5dRfVisBFSKse2DVzzl4AACAASURBVHG+d6MEnXQYBuiW2I1iK0Ew5ABYKQ+Lehii/MnyW8EBtLn/KRdQau2+5l/WlWQOhwQ2XDBKzgB3YUG5VF8StOEBxFHkCOpgDpJ6VlExD5Fvu0wmwkDq5QmUWyDQtudJqk3TfavOItnhoAnsdQxs0Z+AjSZRqRAVbjAY0UVEg85+L0sdEZAs2RB5wqBHb5IuOyCPACh2//yJvvNjVT0kGHN85VK8Q5gjq57bSOsyAWwjPs8HKEm9Eg5so8kk+loizlcFOO4/lgdw6l3IAQEkljkrLVW8PMzYRbC9MrxqQMiKzQnC4hCs+sgYPSqtuapByaPoARIm9vi62T4LgLSchAKaB5QlHLG+5iLmgcv9ENahoJ62p1R4augyOknCI7F6pOrq/E28OkpPqv441+DJwpNqu2fLbzv/jTYZKHoHwP6EN4IojCqmBHPSrwzgEsO7z+WR6ux/U3FMILJCU4LOOAGt2D5WR863wI6Se2HWP6iHz+QHQhC5EKLdA1ZY7Rj89xvF/3PHVUQEy6AioJyAUbDJON8AonIsEYCZFdghiumuPrp/oduAc1EeIu1iw8WyLCI2v/1YzfWxjIzBhKi0tSGAWgoE1Vf2Pylu3/bXLH0lgDI4JjoDEUhVwRQ4SdXREncU+wiw02EC11CTdnST6/YKEDZDbodXGdWBiprvBI8bwMbWUFYReslGHqwB0PouwcfdTE5IHxYgvKaFaGqf4bJ8z4bbgfriMzEJRoyrxbOIvscbkx8YKD187/A7bCHA5gCO2H9j++nloHZdnAdwTUC9+QAVgOQEjM1v7GrUtpPg06oMLC3zAHo95ibMQOMchCGTHjkUYmvbGEUgxeyp6UhpjUaaQROAOMg7WPUZ9BNUC26/X8uPsmqp+yAciAG7B4iKm8NldC+G+QxwBvOqLr4D5mTYNXTufQG5cnfdEOAj9hAg9QHUMmD9bFXeuYFi+00F4EAeAKoAM6RQkpL1BiPAVL4AW5FZyWViDpR+Yj2/xBETYDiwHNnk5262EdeH3zO00ex08kB0eRFshJnpDyhOgJQECcMM9N51sLrOkoiK1UWi8gg4jboLp9ZTyylnYBwUEVxQTj0GWrzrjSgr/7hQIwoB0vLlI85/s00Gyom/NiMwzwswNf9W/quhANf/XYiQL9pYaVR0tPciJyCBPJcbSLiKLfzICYzW4/HNgxxVCgTAYtLQbsG4jV55sESgFb02HmV7bgc6JTLrSS1ZpgHIce6g6jAJ8BnlDsFJ8fiTEoSkzvI7B0QYq3AP0D4UHIUT2n3g3bGksRMAhgDoAvS7AEQzkLPwg/ZgtX1WwHT/tv9PBIFAzuvH4A6AT6HBKCfg1nPTkJswVAgPIZpvfJR1FwMndBRFUUXyDMHMoIjtfpBzEE7FDjD41MtDRLa23BKqWc8obTsdK5xV3dCxKEcULQuIs+cWIiDy9TyOGHx45kOAdqZuCPCR2QHYtwDTjEByAHPlP1b4WPGLylqlbtvXmwmq2pTZVwIsCJAELCF0bToBshET3PygycfyregzMGpNCpvPa9WlQyiVKAXZwAwBk8jMfvFQwrCQDhJ1B0QGxL1SY+Qc8jWq645UkJ1LlEnnigs7qX4Y0AOWIh+7vSK3uRDAHvuo0kf3YvnI87eBA8DXgQEJgKV3th/yAC1Gty/5aPsE6l5jefE+AFNa65TpyOa3LDUkCKW7gMfvYlNR31dKzfup5J9yDfXUbMkHbkGA0JCOs73aiaiBb1xCvV+s+0CkSCZAXmy1GZyj5GR8be4KTWkLcx+VQ5zDmAPxTOhhibq5EXP9ktRniGFG6Y8Qg72+7ejLbz9/m58LUMuA29uAfMlPZvupFdgTReshwISfU3eXzFOTe1T874EunYABq2jogUFfj+gAzgBosW7XVRS1M0DpE1C6nHiwzIQJrDASjILYlMpE5xsCNmp4AnAitJlyMCQsoBsRmAYnHnkMQnYysVvokcr4PHMu4MhxPNj5/hoCaLG/sv+cDMyXS9n/Rgz5JpdYvgwu+bkdS5MBHkttC+Ymyg2QYvrEnlBgAoTO5ItkWtj7H51DJdkEwVQ5E4m2TCyNu/z+zWx01nFSTrmdXpmKWpm9b2CFFAO6Q3YKJP2kHsIXzh02Hr1IZzCTwDsC6Mcovd3HEn/6tHwUOIBU5qMXgir7X4G8HSQnBct2FWylZbjTDgxlQB3Ti31Nwo2n6qJb8Ouq8whKfO0GCYeh9qm23qvKVOKwALdT17fEg/qjcwus2tH+JibsJRO5dZgSnu58QEbSQYD78XGpt7w8aNm9pPGHA13bZqV+0gkNrj9SanVd6vu/cUpPY8N8D036uwP4qPPfCsqA4oUgNXtvW4Fr8k4QQ+KDTBQYBxelFJbf7IMq1N22uANOqtGXl4lEdhHl0c2FCO1644TeODRo18/AwLgWB7LVNyYEPSA4e26uq7iMKF+BTiOy7k+y+qTYxoHEA1wp2ygHESYIu8DxRL8nDPND8TkD7QLU9U4Rw3LEMVi3FX3fnQBaGZDtP/1GQFX5pu7JNeiQwAI5f20OA5RzYLU1CT6I9SvzdyoBhoCorTdQ9XGIQMnMPGjS5YzDiTqMxACvgyNKJPYqCAjQUd4gg50n3dghawdRS6wqpY4HpwQjXB8Dpw/eHqg6KiiJyV6zVuzHO4oIdMr5jLdFlxMreuQ6zPJKJOtp+R3GAaSOQN//r5KBAejrHAFeT5+F/S9K1xKI+UsL1TbbFgBGlQDTSOStcwGu4feZikAH8F5ZAzdR4u4AEOraWC1kfgJLgNBTkXCvYN7Abs85r7zRfi/C6jfy4cGvVXnG8s9c1xGw9p3IWL29gwgch3mGkdLPEcbyO87fLhyABbyu+2+XyxOCbPkvxWfZ/le16+UEUMlVyY9cBAMQiUKBs4YiwgmYcmO+8dVhRCFCISgcJgAksX+6JxpUbTG4HLbdxjXgMB+dN1DtvJskrIgsHDnOgdCdI7gPeHcUYc0q9VyCsOcCYgDOHLvEBnPEgFsFzmuinDl2EvbYy0efv92XAXcwxMnAAuym1CUkwFJfIgi0xLpKgM6gAC8CehmtCBBSVswTqFhWEREO9GELbz43uo3qQPyA8fE7KRiTVs3Ee5JyuYEpG23bce0w44HmCW2kknZwl2epCO5Y2KBiYh8qtOsdXedTiOTFuwAdxmhio22X2JE1wvGuIDr2TgCuFbh2/gEJkNrLWYHG1mflr0osSAKteRjnA2CgYahl9J9QCSCCqjdJxd8E+C6wjzQCkT2PYvC+zS+E2bPr5BaEk+jF3gZ8naoFq3cIWraxg0qEGsCjXIHdp6fm1i4zqUWqOusCZo93hGimlR7ifeVElt95/tvZAbye1Vr9OCiEBJAI7CYATdyeyQAAzJWDxBOKNMpXpfCALD5P+EkPB50EaIpRXbtN3WoimVdvaAD4ELTC+hp7bNYLUKtrG9h1b/GDMCQ4t3MfnX6AFq8HjijJsZ48BOseA3qkOa16PSdCJJmvcfY4RwDs4/04BBgT0NGQoW2/E4CpAuyqHGT/tynDGaje/mPdv9lkkyfougEIHyIywAlBmYjaw+lVAgY9AZksfPbfDpbqRQSAo9h+FALIfgFM01EfvbTwISHo68d+CAXEkCx6lQkAyxGyGFn9XtmS3UYMlL7CKzDOqLZSVL1MWPLFZggeY9+Z7I4dI+29/EvVAWzgxrhf2P8cX2v7rxOAwzyAidPbMfybg0WugBN3w/gfwgl2EC4bD3kGpdiiStBczAzwMI8xEe/n62U1miOEQO2NwrVr6AHYW/o2uM2A7JBF7zv0VV+rJIO1d42KNOw5tTOZdQFHlH1MPLEjOS1t/BQSj1xVb/lOANUBqOTf5gagGzAp3a7rOWTAfxGkUAFQyj+qEDhiKI+gUx3gpCOBHFVa2fcSNijrrpQ68QKRipnGHAAvE4oE76hKcCRJCDZ96DQOlQbnrHLPjo+sepQLMUCs9/7pCu/A6ADmQ4exNdfPvwdI5SDG5xEhACQLe85g+Zjzd7QqQHUAnYYgWfrLj0V0AjbbvP0FLkFWCHzXYPry+SiDRKGN3wGYrEYMWpGJnwX8Uy3+FDCVA0Fwl7+HuYFAQaOQJo3UTqzuj+fUd7ZSAefqu4Dx9TzdRcw4DSb+Adi7gOzvq92HF57DDmA5nXYCaA4AgS+mA1eHYJXe/IhojadtHkD/GAiCFC23XV5vgEss+gSh3HbGCXB+IcjOK8ArN4Gs/dT1ZshHoUcGKg+WrkuZArdudWWlUlSggRgPdm/dZ7Z9MYQwQxqjfMVRZZ8KATJxvDBnAONk+z7LxxoHwAlAOx/A2X9WfBMWZO2umX3RMhx2A3oyqE4A1FxWDcqgrjb7gBMwHYNlSASdg9RjYBJnXcXWjUAu8abKjgKwsQPR4DFA7XUf1lCD7eX4uAYoHVeCR5oBYJ90WlChLLPdd4Y0bBCy33oRdytg6mX2Pka2fjaRWckmdBZz51s+9vyd5AC4AUi0BocdgPhCD8oTjHoEhpl/DAPIXRSTKpt4fDKvPSBRHTjiBMhZWBXsEAea6lDR2wMsOQl3/IgQzHX5we7IxoEdIPxIAGuw9q+FCSFORs5ZdAb905KDkeX2uQFzno6CI8WUOP1R8T6puiOg3AugHMfyu87f2c0BVNXfS4DzCcBi+f1rvrbLs0RhbXsf6N08Qh34Cjx4XPvQzDU6BwFOoAf4KBk4kdSbDhEq0R0H9egcfQWm+wUDzpNJxyG4ezRDCLGyx4Cm40oQziX1RiQyC1gFdgXI014enFPv2XPbJKA99k4AugrQeSNw+ZWgrhPIQDfKfqAbsJMwNO3FBPpWnYCBaAaeUn3RTVgGOTYvuWUCGIFi1oc6Wt/LPUwpfnM8DOoGpcE2gsx6dr3vTMYhA4PjxVl9/p7tWiwo1DXqMKEuHbTk4r2udp2UWpHuNKg7qq5CEH3c9bT8y+fvSg7gVH4XAC1/8HLQrhPI1p8sf3oUrPzCyqucgVHR3j75lu53oF2HOW/UHciE45pxvAXsWfOwioB2m65TWfM6kCYy/BKIw/2OuwlvzS2wuoSQv7MmJ22z6/GEkvcShzO5gHFYMFLjScU+oOwvxAHMlgE3AtgdwK7qBfD8MpBm/znj75qCMDnGrwwzai0ah0I1t2FBHTzRNGHOJ0jQvwAnAJY8Bi/1LYC9g+xEFiStzDJmh975vgIL4lIW3hHFEeWOlbYHMHvdcyRiieNpIURIENA/z85nTCqaxKaTe9NEcew88vxbGfDjzn9nXdfXoQsQSAAagJK17lQFVJJPqLl8O5DJvqsZhPnyzSD1cwNMVYCPWewzq65JwsFNxWoDgvZgrG9BHoPRgEEkBkcg1/uPY3dJLuh+ZhqERMUgAvc8ITQTPU4GWpWeCyHaPnb7QVKP7k2196S4fMxpa9+6XtKhg2rMvrySBX9/71qicGMnAOsAsAXYVgBUC3CLuVVnIAx/IAP3CrFu1x9CCDPr1hUkXEP4YVTfAs8RRd633SQMM1hl/Dq7BU1PxkYmQyT+4YYuokc6wSBRhFGXdXv6NTDGRBGTTQzgx+zDJHocsGsXrNbNzCt+7GAkiKeqAxFJ9Zbn6ycXExHQ8rt3B1DmARTAp/ZffEloiqMzwNjaiw7AekLeJytzywmg6or8QRAW2ONDzC+Sdq21FwnJ5gkSkellRsUphu9Zf3negf3WwA1A2SEGR0rFAUnCKHdT6fYkIYTXQgQqLG5MLo8JCxjAjyAIysKzo1CZ+lEu4VEO4JFz/1UOwTmAfOzl95y/ew8BUhIQGoHMxKDtkFQVoAqAcQIq2VcdACp1IZV8ea7VV6g8txCze5CEwQNcH7e4CHxYlZ6IHMw2eZ0CXSG6dJmsXrwEr0sfbRrYT1D5GUCOHUH8XTmujo41tv6xRXaADOfFjwlixgU4ktiGucsleGsu95stAwYTguqYA7IPHUAiAHQADejmrUDGAaj3A3AfP7kFGeejXe6QAWTo0xeh/Qag5/DAgpfCg8gJiAYhCUY1r8Ak/goBHggBqOtQEdQ0MZATcI6jEp0Gl3IoCKEeaKN99zM5gHLo5T/3VLdALYqhR4q9r+8o8Gh/vidOgctzmOzkm1J1fLaGfDwZ75turcAfnwmglQGTC6iWv1QGqvLie/62A9vP1tqryT+4T75NGLsPyoBVM9FRuBKeSBASaZjhxMcqzCnBbHMN0i1kQmrnsLbUOYHwtWBKRWlZ2FdQANyGzog4HgPePiHw9Vu1ndl3fE0BUb3QOH/gEiYz949S+x3IHNbosEyTXWfbrQrw8efvyUnA103M30ICSwiVGIAQWvJN5AlkC7BX/gqWiAxEac928E1UBSowvfXmbsCedW8kF6u4sbUHk3i2h2AybBhm4uPwgtWJPZFdfxzEw3DBNbXMnSO67qJuXcfB9viJhKEU3qh2kPQ7Tgo2jGCnosmi4wA+4fw9YQhQ+wJqQnCQCzCkUMy6qA5E3YFSyeHijVJSuZCy/nWvamnxOOVx4Y1R3YDAnmSNDYW4dWxXYeu8bWzZGX75GgYuYaTuQxC6DEVMPD3gKb8xVvH5c3VBX2Pip4UPXTAf6MCbAbez9t24vrk6RXJRuLNNYgpzAJ9w/t71lJOADfA0LbjE/y7bn3MBocqneF3P2ustB4CarP5M7I/QRNUj1Q9sf+gEoklCZM9kiZHUWZPH05W+VR20gipFPEIMx5yCDnscGUwm554aLjhQD6oRI3fRV/y8dqIUN0MS5p5VpxKruj9mxwH83vP3ZgeQQoAW/4uWYOMEMqtEbwdyuYF8U0yMj8oILFXDgLy+FxbMVAWiNl855RbPaZ1CfRCq34A7/Caz/u1h+fPGLsErXA1LkjSYVmh3joCQIqU+ThI+NHrDXAApJitqPwwQdhpCA7bw/tgH9q/PBFR8MnegyCapPeUGOu4kCg2WT8wEYJKAriRY1Do3Can4P4PCdvpZAO+fENxoz3v2fpjwIyu/37HkPurNU/0BJuPPoBFuwwCnM4GI7XTXvmulVKDzcw/I1bxgYB8H/ryVr8AkEPQBOyaWHtHUsTAZj7OSDj8P8gixawiIZPBK7xJkF8KPwwJ4LnSNyyeev0+GAKkJKMX87e8GYKwU+EpApPYtbq+KNZP1f0zsP1MqrByqwV5vm0ziKXIpw88CwcE0aj+WLbhIEMcBnzhWX8+U4otS2GOJ4UW6gIhARtb9kCMY1PGPOoK5F4qQqovkLgI+lU97TqStU6HB8knn7/NJwN0yY9//4M1ATtmz+hq1Dyz+TAmwC2YRJhR7hA6jTtxRIIqO0QBdgOQHEB0Pvo9KzDUo0oN5gkuQbkFYWQ3c46TSAxkfbRr0gdpFZOOPq92BudbBG30soD0QnQM4WDmIHUC79kQSFtBzZcAA6EAQ/P22sy6fdP7+9XTa4n+YDYghQAF3dgNzswHTl4gn/hQyUBN/qjewNh6dggTzZFVAhQczoQJGXEMFR0LxAxO+oZvsYQHUcxk4nOxgnTn+U6sGDpgi/ozU9oUtDxp1elZ9qNod2z0MASrpEhgPHLM91Y6quxBm7AAUqWxjYPnk8/evKf73SUAVAiRQ92YFauD73EAmAaPSqnEIVNhYWdq28KZL0EVNQX1rHVUDjJmOKglRLN5JHlpAWcvecxL9dX7t44DfdwlToUSQXIus/FNIYr7SMKHyT0gKqhg9VHdJEj37bis9NQwwLqdv/3cH8K+cf2BdswOwbwYSFYGw/790DuaLktYf8wc4wDtOga0/5wK4n0A1C0X9AWa5SACa1mW1HuJ9l/H3gGkDWoUM9vhzoD5u3Xvhi/ITI7II1x+w848G+uDlINFxu0nCAxOVlC1nh+AnDXnCGYcFOO0XQgVTATjoAOD57ASQFD2FAV718fXgOE9A2fx4WUsUZl505cB8+9jqT3xm2+w6BDOLy3f/qfxCmW9QQw3KBZgsv4rlrYK76wvj8w6ooYqhzb9ne76KEaD3sxOwFJBKiPFCcwFvVAhx4LjKfjvbf2B+gCYJAOuwGnHAAUw7CEsWy+/bHQC8DkyWAHkmIIQA5Aoa0OfzAL6lF4ZuryegJvvIUQRx/h50ZELBh52ikJZ84Ri6Hr3XN0CM3PbpuYf+ul5Y4GLwHikNuvz0sWJCiYDvyKKj0uqcDMDuNgccQFf1C8kPwehdmlTvQ5UDH+q5Y051HioHIJZRE9GeA/j9579rQ4BcAeg7Aazni94AbLwZhAP14ZQ+AtnYg8ookn0qNFDHiZKHUA7kWrtU7+h8WFY0bRo79bTMQGIcyBT01NsPEu8vZtSf9b/nUoTH6ChpA761uOxnekCsVzOR2IuIwR4frqXTazBFDsWxhSFCrNTOQeyBdxoPikCUa9DLIAQNqxHqusgBbATQQoBtZaoGtLf/2L/r6757zUCiLFicQVVXmdArrgHZlpN44rNRcCYLZd+jun9+KHxt9VEJ0AzJoJ8/iGCoHUqLAUOXguGFAe08OJ2Sc7uzGLz8PZxLCBU7JrhhiHHABWjSyOfuqLYEMJTp3PqDDoD3r9/5UMvvGOiqX2B3AJ9y/sHdAfifB8MfBcXpwZkkAOTqxaBx1r89cL2NTSTWrcNcAADMgTGoAIQVAyKLmbDgsd2BnGcQjiGO9ftgZtcynzOInYQ6Bja2PNUFOIBKx6GV9miooFV/cOzAiuO5p3II1QHokOKwA5CEY1U+Z912aSjOI/27npY/sBNASgKmdwPm7L/rAlRvBAp+LIR6AHqTgcaOIN8o19orYvZIuXuKHrUIy7BA6bW38i5s2HdToGWTzN+p7YUPUe1VHm60zoIkUF0oIb0hLiAP/n78r+lKuoEDJNENPzoW+pADECU4TRAFiHZMmLBgygEooLdjV8DLGYZp3+UPnH/INgLhLwQbMpidD7CRCCbV4B0BrjnIDng5j6Ao5UDd661UDUOmpIeDH+AyY/tFt54Dew0X5qx/ulXBNdVjxTbZAV5kg8FzmatTVQEFTk8GTEz5u3bOHdl5RTT7toNS4gyJtOPMhxn+OjPIDjmAGOD+haQ9EA+IImwDHjmAdj+WP3j+IWgEKra/JPbaewJNDJ+dgv35rwzmcFJQshz1xaIOlLYfwJEIk4or33FogXY+r3ONOwS8qtQRIGH50Dmo3EOfFLT25fsWEIsGsT3PU7fB109PkwHYTc5XcH2cfVUIQpVkPZwHiN1Pc1EFeOzcvGIbhyBbjS0YRyFDPeOjHYAHv52D0NZvfy2fev5hqgLYNwPX9wLugIO3BRd34EDdgF5sa6jspsSHlQXOAzCAEYg6FLCq9xSln1TnQ12BY+s/tvz+GG249gIBGADDmn/vHJ3wZHhcva+06cPZghPqPkhA9sIDQ0YvwOK/OAewnvhYUf4Ax0UNCzKZ7gRgGoGq7Uewi98KQOBXIENJ0PQHgBoai06qbxSYXhiSQwH3wg2p6jb558hgVum7jiGoLqjynzzfUYfQcw/FMj+OFHrE4VxJMP9ehw5WbRzQuk06KmeiQw/vKPx5oxCkqv5kv75VcOEIXD6h5wAemwPwpGfyB9V9ebLHJOB29uVfPf+IqQLYMiDW+LneL5KCWBmISoFH8gBBmNAHNKs9gsL+naKIYrE7tl/afQXIkbKP1h8lBTbP6vMBUiCFi47uQxW95f5tOuo7G07wL+DwN+om+ErJbmomoAIWkM6LcADbzTNk4y17uy+KyGgZ5QFm9y3favm0nQDKZCDMAcDfBbQy9uewAADlmntUeIBAGuUBuH5f8g4dIHeSe0mYRQjBpb0af+P5Rw5gBPbR+qNkwLAkUOaBwlBVYI63EWQCFt2u7ZAC5wcOuAq2s1WRBxUMFd8710L3aLSPstwjiz9yEOb7Bd2Jj7H6qPyFgHYH8K+df1TkAGhOAP5ISDf2D0IA5wx0SLDfnKDcZwYXtwebPEQv+RerfOsALAR2QOEflRCcU2sdzcPSOkh6bqC/rgv4YTw/mSeAee46XCiJt471f2ozEc21Vw7Egss7gmMAb2PRkQk9N2vN273g0GVs9ZWjwGXoIDIB2BxAifdLjd9WBvavxO8GkPmAuPwXNgkpyy9aev2LN9FZlPQZAdk5AU8GjYDIlaADwP6AunxEFu1c6i8cdHq9dwNHEn6szGbgB92CR1xAPR78WKUClwW+AFe2x37fY26iF++XkC/cRsy1j4iC3YghjwDghxwAjS8bOliSsMRgAd+u35LDVmpdPv38Y6IT0DcEpZ8N2y5fTAxSXYGz+YCw979Yc9X6q94F4MODBstCEPPADknmEWQQAXAW7EMXwAMF5xlMOoRpwB/OEwhFd2FDQAZB8xQm/ZSb6OcEWi/+GNiW2F8EwBmMGMIoQnn0snC+ATmAf30nAOwE5CnBQAZF6eGXg6re8otCgmSftfn562OugPfLjTKFueu/+/dIJNHWUQOSAWveKqoaCGDXoRs1F02Qgbm2eq2s+QhxpXad9UMF18dDBXQEFdp+TUXlORibK2PymXAhX+9khSAC8aiRSF4z9vhDHX5MFAiqosxEHvScXEhAY4mz9WX7/d/wtWFW+f05vDNY/tD5x3UOIMf6+AYg/LWgFAqU3wUAu29m/+WuwB4ZOMBj6BDlCvLNFcCMbTzo7UQ4gIFEGyyWsLQNVyDx4QYOQOkQRMzsyUSFHpPJQ2HXvQsYAD6o0fNeKsTZlw2nCw+s/zCxGTuL/c51ZuVZZ3EU4M2eI3mM8gt4TxrgrYNKxDBa5q0+EgqGCzsByBxAfUfAdjJ6EYgDvnhRiCgDGhWnacJ2HcfxPjlonQQO+uwIuiW+/FgmKwDWfSiAeYDPgfWY8ns4DNyCULH5sAM8wjCB1wFqdxrxhPXvZvdji74fWWT1LbDngNqO1aAXxdxo8SX4B2U7vD57Dhvz1+0ciVnws9Ph614+4/wTYQ7AvSLMvAtQ/UKwfVGInDrsGnrgVWFovdC3NQAAIABJREFUg6hL0PfLZyZUcwT2e1WCA8uYypLPVAD6Vt4CWYNsDuyHiaMb44/cCJCZs/1e9brkMcg1xI7HWloFUAUqY8uFks8ouNsmfBfBhAMopeNOjb88W7TzDHj8rvx2JhsWWELwQFfkBt8jX+fyh3cCiHIAXA4E218Ayu3BJiGYKwkl9pUvB6GfFVcEUSyPA3XQF2Be/MHA058r8Lp9AzNWHiEcgV4vlwAzCjhQfJmTIMfy1OMNEniWcqxVLZbbgJfeLYAgMccKCIZtdXzsvKY7yUgBXX2HA85BvjvAX8tY7fW1yVBB5i/QGbTvtHzm+SeDHIAvB6a4f9tZTw22IKIyYK8qwOsoL1CHPcT8ZnBQX0CDoH97kB+gDGrYQuQKZtR9ZptqsDMg+w5Dx/Xdfbox/gSRBDVz5SlcjD9dKfBHm5t41Ak5trF0sPvQqafLbcw5AKPeNKMR80W95Jw7Ro75K9DhuSL4IWDLc/7tuNbbrqflM88/lacD55eClqYfyAGU14DLEmB1AtvD3E4avCLsQCJwP46c/lvOYRU03B6z7oY8MHYcOAKjqvPq3gf0/HHYOjtyCRJhkRLr/ScThzzPYTLTzzC3CUALZksmcRjSTyKqY9Iy2X044QBA0fmXftC9qERduQ9R/oATk5Gtt8fx39WGCqD8IjxZ/o1KAPmHQcorwdyPg/jJQdIRmORf3BlomoGqsyBg8mzB3ChkFN6EFzYZaId1MLlIALylIL07aFfYW9cjGExwjhKKsK1U9FjJPQHpWFtup8qVYUJNeQK4rkBNmaBQwcw6SiLi4Ld/BwlBUX6ThITABqLjkptWaH9upcj7vodyBO1KpdUPypajbZGcls86/3ROAuZfB6r23v5SkP9BEJsErL8VOGgAqgMumApswM2JQEjuWZDmG6VyBKZzz27nCMLNAdDuwEN4e7TsSuygUI5AhgqPCAnmwD4Aarn+x+YIDs0JsAN7/9TtIhTb47sBDjQWuXCFzq3seQN9GzF+u7xO5hi0SuNxvdpbEk2qHtl6f13xtvYYyx/ZCcAmAfEnws1rwrD2X1/80V4Lli4jeGX4IAfgHIFqCFI9AwQ8m/2fcQR2GwtKtupe9RWIY/ud17iy2hPIQyokE1dAT1Phg3Apg8qDV3MinzC/EKh4cSQHKhVswRPJKMfUU+8gPAn6B0YWP3QPzl3pUKSRDth6SvwiUaQwCbfF4yZCWT77/DM5CUjvBDRvB6Y3BO1gFu8LKE0KNd6eJAOX9MuKCkk45Qw80LYlUeIvr4P+QYZFyTuYc3W2l0DPg1uqe6lw0ENjmnHXlRNKSsPlthMWfvpYj+w0LHaX70N0vSZJdtBNGMIJwZm2ksQgGmvapB/lPjRAu4oukneaECy4y9iQtv5Atr84gnYP0nmWzz7/rEgC4lTg9lqwBK4A+KU6UOP5BuI6wCNiMHkDNNg8PRiJQalzAnm6TlZ2pd5+mY3xWZmPOACtwkN3AKw9RQwO7L7DTp0Tj11BMdV9qFR0dE5rUc31TCYSnXUPKg1IJAhIBFJVahHuKOuMym7/bqQy8zNgY4dAyu5afi0Z9cMC3Na6ALyO5XMqAagkYPCWYJfph7IgkkSvG5BLejJ+F6XEzNYyZCCGN+8fhPjp8QrPoFYkhARm7bM6b8kke0CidjLxAE0FtrgSoZy9aH9vrn9uymUcDBsqICfKkpHzYeurANlddpAsyhN0cf6BygEnASX4yZ53HQT1Szirb5KYMF5cCGCJYfmj558TSUCcAGTfEdjyA9uBsB+gNf3YDsB8rB4ZhLE9tgDTkHY9ATzk2YE8zhFYCzsCPDsGBE9SSQW2OFygHEbef257OPfwvJ2E5aGkYL6yg2FDBZxI5ikVD5cF5zXhBWb4RagUtw9b58MkIc8RTCjy+/pj21BFhxyt38EqvM4VJDzwdS6fe/75gABK/I6/FORzAUgI6aJ7cb8nA6OKwgVYpR+FBwrkmRj2757+9hrdW0YgFDkB8x0qSMsxbVCBD79RFjuLNFEFlyovIY81BHtg4feA0PsGPoe24pFDUcSiJ+F4YvQxe70fopQ2dgV0vPDlIH2gN/LJZwzKergduwEFbusQkEhtWFDuk8wJkAuw14Ak0v5e/s1MAOmXgV8HAGNIQD8V7nIBfmbg3hDEyT2cvWfAXrZFsDRQ+r5+VnelzGUw8+C0/QAGvEafLQANcZgsOJ+bv0McBhglJ+Da6+qEFc6S41E7wBwmK01qLT3L6XkHcN7J8p4lu3zPBhWOUby/X8WwD2CsvvgWIAQgg1Y5ExdGoAp3SoazLoEVvYUG7Y7uy4KE4fJ55/dQFYCAL2cF0u8F1sQf/VIQlg1Vpr/zHgADOH6TMCq5nAw0o/QMlAjwipR6roBcSjVdcHwA7TTQcxlLw1t9FwDwNNgBho8oL9qfCnucK1AgMkQZWfhJV6DyDHWZKMfh9YS5AVVFKGosGqgUuPk8cQhgHcG+HVQ+GgG0MYpuwRLGelr+2Pm1DgFsyhxVARDsOgm4X4J7PwDYbfGKcGvRm9I3WMH+BVxhPkCoPyQK5bkUYE3YoMEWA7kX+3uQmOOYcCJyEiLEAPCqMEKGQMPQgex8x3koZWb7Hln+npXf1z3KFYAaDhwJ2/UplXe/GkzqS6Q1EwIY+y5fL6YtfSKAGPwYBu8GaSOA02nrAsS5ALYMmMKD7UthXmA7kX9V+P7Vq7IzMYAyY9mwlu7QtvO2AvjkBDxJsFLj8VmpESp4rp66otNottXuMSIMALBLYtlrUkqYQDEmB0MTQ7AL9Z7qUCQj3214UvmBfuhgyUHnF+oA707o8bZfHdsAlSoAPTfAAIxJJIOYqhQRgA0pgFCxwkfhA4N/I9Pl88/vDQhgAy+WAfnVYNgKjIk/9U4AahvmrsBKAOkNQumGlb+L0+iBOQM7mi1YuwMGJOLUvxBGENdXaz0CuSIX+2Meo1DAQKtj6ZXi8zTcQls4UIwiT4cMlniwb36k8Hy+rmsQquavNx3BWny/rLs+zBd4wrAq7hXXEYprUEIrj47BEtvI0itSSGFB++7FFShiWP6t8+umClB/GKTG/uwGUPlFGbBafpoIlPMB9SIGGX8LCN8PgOvd37IJiN2FJRSvtZG6M3zaoItBnNdU28xn64cCKvnmgQ5LgtKdIgef+e9dCwzOQV1fuRU7MIk8REnOkYhImvF3Qgtf9ne2vpMY9MqOVlsRir0nHmR9cmAiYRKT4B2QCcf56BAsYayn5Y+fz+t6em9S+1wFSMqP9f+SGMQXgkQdgfyeQHgpSK8TUCUJUbkVYbjYXABL7seKDkpvVD0CuwIwDtd8PIjduoClwV/6t9tVeXrCAKYpL1/D8fyAV+5jIYZRWFk1sN9FAXYfpJ3wQbsF4QA6hNGz8AiS9nf+ZoI8LIhRzUfOIYjXZduwdQwF1Og0PFn4fRoppnXLF+wEsM0DwNmAhQAoDDDvCtgOZasB+8FLrsDZ/M7U4GL53ew/tOyYW2jLGxCUDUcVF4ruQgPlCgSwndXMxxY9AOgKujB2MXYnrOjE4+4cE/kBp9aySuFjbkdqjwX8cD9l73W+QJGDXoZAtSodvSwUwWaBR/vn8dFAinbcEomy5Ug6PUfAxFMIAJ0PhhD1XECMy584r+f19PpiCWDrB8i1f3QD9V0BOCdgXA2oIIjmC8gkIDiJMEkYATYCfk/RRwQShAxVqSKiQK2GbUSc3XUJZOsjMkk2O6Ya4QlEA9BEGDBVafCk8fhSYb6mQSsyAkoBFsFhXx2OVn9k+2PyaCDT4YICJ8fxM9so4kiS3sY4g1/ts/yJ19fXT8v5YrP/rRFoAzV3APZyAWKSULX04tXh3B/QqQI4BZ0OBY6qP4OG3EfpAOzG8R0S6BIFhyTYCcjHZCLCh97bFvYbgBePUghFEgfUv5la9+0fWyoUPQ+spp4slUvIy4JJP9rqd5wBKPu+FZUklVprcCty0ATkVP0FzABsxLCeli987/ra6eJ8lQgArH8lgEIG21fmkIBfEhpXA8y8ARUedHIAxuYfJAAkEA+dNGw1bPLyUKnbnjYMgTMGDT9en7lXQJEROIlBqOHASvG0AzgBuZQVI5DNgj1MBO5ohqNMEoWO/W0o4B2AdzPKKhtnEHbrHXMJeL06Zrehw35doiQYqb1yCvacNgfACcDdMHzha+vPL5frjSWA11uNf/8VoOwGaguw7QfYL4SnCZMDaD39oiRYYFh+cciAUij5QRJAE+7BiiTAysvntkqtgRw5CR9CYHZfHgtn8k2GAEWZOKCx35vuyCDmd0RgkpvC5vecwcSsQEVQBkCdY5S7zKDh79CAkvc4UBnAc9i/PaDLeas7gFePK2CzYwitPhAoKroiHU94jRiWL3pt/dnl8nQXhwD4I6FRI5BtFEpfGpN+/ZJgfeBYJaAMPyp5IhxWb0EUJsmHgx72hay/BiEeNzqGWh6QhQkFPFlU4HZU296LfJ4hQcC5ujkChF/eZ6IvQIJ2IgE5VvV23RbcmnhGCT/1k2EIUvu3tuq9mD0RcGzxWbUdQWR3VAiPyUa5l0YAREC1XGhdEB57+aL3rD+zXJ5uT6fzhc4BQDtwdgL7acqvA2GzEMf26heEqtqXGDvIERgXIBKCQYnQEQUafFHi4+2tcto8gIGryQXwXmW/pi5IV96F8HbsFo7kCDyN7UcLymoRmcQxvz2+2W744lJBLtOhAA5ivD+WCKpiypZfJBN/jFllTyDXoLKAtoBk8HtwewehtsHviODXboHDFhsWLF/88+tP7QSwbHkATP6h9S+xP1t/3SKcvmjPAdCUYdoeByWCpS0fEAKAXhOCdwt+aCJkG4A81AnshZjIVkugCWDyddTPZkCX60fnQS7Eba8gnY9zcCZiUTml+jbufzpZRKDEI3PcHOUetDuIQeqBHpBNVW0kGPs3hhwFtF27P905yHG+/WxzD7xuPS1f/HPrT1xcnu5OF+t1IoDcD2BifwQ6hgSqHEgtwjXDD+8CiKoAveWDvMBxoEckAEBy4UEhBVboTAIuOeeBWgaVpY12XOMO4HgxQWEIwJG/3kt1/yngmr3B8cTuQJOMeuOvpYZ2N6zNJ5WddBgMMFRlQxwZuHPlQFTS46GBU+fJZh/lGiJX0F/uwb8nAb/kZ9cf23IAmwvoE4B/S1DL7HtnoJN+yu4zMRTQ0HITz5M6C3LoEcJwXQBkVvEGZrweUuLqCFROQOj9QOnrAB6UFflaG+iZJIJwYxgyRGD3pIODX7kGSShh6c6SwiG1f3Q5MFb2puLevvMbeXu5A23f50MCD352Bo20EkGmzxsB/OjFxel2J4AtD+DKfyUHoNqDtxsTOYIcBuwAoFmBJjwo4ImqA327PwRzQBxuP6P2EVjztXbtPWiMSPjxeROJ2EDHAqK5g1ZXLyTJZMPuJQC3y9Lba2AV5rDHWOlQlSeJ4EBFoecODBEEnYU6BEBw4/2aVPmOVUfAd+0+dZYiQNG9lOXaFSBZ2EQkfm889k4AX/oz6w8vmQBOy3rVCKCUAqEBKOoK7LUI5zcDmRZhsPoWEEwUTVkr0TwhFHDgo0SeU00gDwaf0O5UtAv6Bpx7cOdWpNPKkh5OjRjseZ8SBoz31ZOHYrC70GLY9gsEOjULUDuCbihB8+XZlVg1Va8wo9CkhBKgrAxcrf6oysJBwPFKWFPBDO28fWLga7XOYPnSn15/cFP/zQWcLk43iQD43QA5CVjfCcDNQUnl9y/NVYEM9qZNrPTqF4S1/U/H8I7giAuIgdzIxuhqlySyEstYnQBqEn6ODmzBslOaNPCgrsQ+gVmC8S4jDgX62+rjJlLyispgw+9jtyYioJh55jgFNBwmoN2uahoc36qnBWkP5Eftvtn+ES8Aad+JY31yBpCw3B3Al/3U+gN7DuDidLP9l9qCg1eEj+YFmJ8Vy+BAd1CHuQgJXFlvZP0tcXRJYAbEodozMDKwpxS87wgYzKGrCEuZjarkvmKCUWTn6/7d6oFXW3NekSj0oB7E8J1ZgAg4RRwS2CbcKe8I9C4D933q30wafLxCjk7VSfFnwoa++jdyZutfPi9f9pPr919cphzAaTldLxfrXg7slQTxp8NMIpAcQB0ctR8AlB1mDbZBpPIAbR8P8njdvm2YxS/k1FRfba90mo/J17Q/tEH1oIGtnZ8DAEM7gwlHFVKmz8H4GNNWZUAZtjrr/cu+KqnYA7sHbL5q0QYcJfZiJfeA9jP67BU0d9AUM4rZjy7HqscMGaht6n12Mwu9wiuCQcCzU0HiWb78J9fvLTmAZSOAy9NNIgDIAVA7cCOH7dBifgCrPr/+y7T8stJbd5AufqYikI/zQkEPRAFq6kGftwMw9bdhcBUiAAgFYHZK3w0DWO91so+JDn1FJaZwXgOqjCcNXMLvLVCKvV0xfke9DbgIasiJyGOcAHyEK4C23nLNM4AfhQcR+PvLNTGE5JCvffnyn1i/u1QBdgdwuecB9jAgqgi0Xwr2MwRdVYAbgvacQCYODAnQgqOTMNoVxP8VLOP8gFJfBdZk08gh1GuEYU3bKEcwk0C0DiQmCL6urnMwLshvKYFe7nenXdhCpUG2B3YNan+kLuCDSUMRkfDgZxcSxfdG8YO23h6IkQwUAI8RAFYjJtSfkoNa/dsxl6/48fW7qgNIeYDrrRqQXgQqZge6dmDbJFQV2839L+CkDsGa1Rd2viQUiQQ8CBCoPjdgQOlKc2jD899By7DR6Qm1t8BHZYPrFSVFVuR964HSGyhRHC38Bfy8Sd5zInwwAK/PLS8NHIJNINp7wKpsSILCnmMgt1Bnu+/UGsiOVXZs/9t32vNrcF/aeY9m+/0x05i3x9HHtyRhyYYJZD0tX/Fj63dsnYA1CXhxut5CgfV0XhoBbOFA6f/nBKHN/PccgF+XnIAdoD4k8KraTwByydADSIDeZekD9Q/JgYHQcQ9dEgJdFrG/vVcAmWEfA+q9CgVYjW34gNDVnYR6e00a9lx2+jGtOxASDElioj9gnPW3ScyR5WcF7ib2yOEUQomIZLScySxtjySyEcCPrt+OBJAcwO4CLuPJQQX0pUkoA7mqPvyEmKv50zpZ2hN5AQoRFMjtEM8kMcgJ7A9I2HjlGjwRAZEQAB1QJXEQKKmPIDofxuXKLfBRrWPiUEABl8gA4mxUaT43A1Bu24nZrW73iMCC0MT9gz4DBAWC07kCqB5YIHmV98dB2w6Ae0L7ryKOEcBH6r+tX77yR9ZvUw7gtBFB/akwGw7YFuCcKwCHYJt+GuDrgBBVAQ9oVnml+p0qwKLzARGwJdg6Sj1PHKiB1hXUc1KC0V9LftQy3yBIJHh7kTqu3TsPmW7VwRKItfgxcWgngL7iEYDvJgA7JCGsOpPPY5xAIVpU2VG8zw5BOQoP9IBgSN0j0ihOYDv38lU/vP7NrQRYQoDiAPaegNN5SS/+VAQArcG7jQdlr7G7bRNuIUB2DC7Dz4Duf5YuwIAkIIEXAmxQf3Yn3RxCDGZWzP0M7lpjQtmHhXM8HYIIE36iemBy883f1KM7MDKgvR9ojsF/c84P6LcEz4Mcz6Cs8zQBdBqGGKgj8CtgoxMp1xmRgl3uE4T6WG27RAA/tH7r3glY+wC2XoDTzZYH2MKARgDtRaGt9MevC6eqgJnm65OADcAIVJ0TaEMuIAUJOjrWKGO/r49Ljggu1i6/zqu9qga0HDps3ykBWhXXbzCSx4S2WksqilBilW+uxd4B5QTwWu36jvJT9cESQR/w6nyodhFAUYWTs5u3+W5fUOERATxV/XvEgOTKcX/5nAjgB9dvKY1Aex9AqQSUZOCu5vZ9gb72314ZZhuDIgeAICt/RySgbD4s25XHbtMGQl4+yOonYPpjaAUmYIsuQ+MNOuuNNlMYwNbcaG6Y14jcgW9OYo33kIQzdisEVun5E8fcRmnhO7cBq4mFj+M/434xgBuBWSVEUPDfqKSsqk8jAEzI+Wtm8mIgxxa/3QuzjygRLl/9d9dvIgewlwJrMnDrCajNPr5F2PYE0OvDTD2fHYACPMb5A1fgQC1IgBS9Den8Vz2GIJkDiUHW+hILCg9gGlPZrlt1h6vtkoinivr4O4lH3otTgz4zr4DerhipB49djytr+Lw/gsCebx7wvJ+ezIPgsX+jy5hxAkgkcWzOxPFC7b8oD6rz2dxEuu7lq39g/caeA7AzBEvWv8T8+bPp/MOkH/QI5Gx/+uJcCVCOIG3XBlNT83oMnD+ACm4GvlB2E1fT+l7VYBRCiOahmHSMT/BvQAxdS6TyrU4sCQnupAV/HoqdsMNqq/EiVMLlY+lQgtUeaSByAibTb0qDGYD1mUZOQIcPiljwGmb/ZkC/MPs/VfufcRI2R1Cub/ma71+/YZsMdLF1AEIIAMnA6z0ZmOcHsBtIIBVvDS6Ah4RgetAZcK4SoBW/kgCouSKAemwHUjhusG7fN1D8fbhLwtiuwocYVsUBao8gD2uGmTDaD4A4kjHEGDgE+dITdUYGMak2Ac9ruicMBh1q9pAcnpD5b6roXcIs0Mueve1n1D2NuQLco/a/PScbFlgHpdZte+L1LV/zfevX7WXAy5T44xzATgSnkgzcEoHcIQgNQjgvIFcGsCRokn6mHbjlAbziCxdQv4TNBcgGoO06egnCHjCDEKJCsRv/91qJUaPVnH/WcAA/5Qo0+AWQBVDtvspZcGDwxAai2iXHNCHUWTgSr9YM5PZZKTvaYiTqNyT+ly3Ex0KEXpIPv0sBtfoeaR06BHuvl6/53vWvKgJAB5A6A/07Asx8AaP4AGjpAJoLYMBXh5Dr+MY1uKYhC275rgA4ToORbhJCYGM1wKh6zykU5R0RA4UKXqM9QfS2kU5BTFe27iSdw0Pc1hCsMxq4AXFEa8j9Of1PhU2QAxFJFDYwIPDIrIT9UMCCZr8L+f72yKOAj8GKLiLaRrkIdc0N3EguviSIJIFOaHnH96z/TyOA9Xq5WNJ8gFwFyAnBm6012AJeJATxfQDmBSGo8JT1VwRByTmboYd8gVTofq5gH4JEChVcPcUfWXhJNKTkzol0YG3CDuUICPYyd2GPrz7xFfjXk0U+wZIH+gc8JlIGg50BydAfK769B6iYNmfwhPgfMucI3OhvBdzHEUD7bmzlX5T670nAd3z3+leGDmB/Uch6KRuCavyPCcLtEoPPoOLcB+A/l+NQmS50Bx7cJiyIAC6qAZYUCgjihKKCaB3QM65hMBeh6LKBozyu0vSivN4D9BTeazFexYQbCFqIFUEoAvkFIYAXUPNnRY8qDJFFb9vbZF4E9McTgM81LO/4O+tf3gjgYgP5xem6/Lsrf8oJ7HMDttxAi//FT4nnVuCk1qU6gPmBAmKO98v2ZZBah9BsPdp9BCLkCCJHEGX9DYB61YBRJUHAP0w4kuYOld67CO8bED6aioptxbVqL+cIZPXABx1zZUN/RqvaBUqWsHoWHyktdAA5b8IWeqToCLTob7w2/nvGDURxflTjj8iiHx5wBaB9Xr72u9a/BHMBahKQcwDpdWHr/ivCtTtwSv079r+ShVJ6ArkDNxCFiXftfrbWzknDomh+eRqC/RJhA5OuBoSuYNYRhDkFHTrIpeatu/aKPIytz2AvYeBLOQZj9aE4GIYDlC/QDkBbfHQmFXTTLwZhkrGqOAP6WTKICSBOBvaBHIcFinw4dFDbLF/7nev/ERFAcQAJ/LsL2H9FuE8ATdHrdOL6Ik9Ue5hEVIFW1JxcgJnYw+ssUFsSUQCYKgIG5NNuwB+3W0IEEFv4CVcB/fZ+DkBEJ6iW9h2EZQ9FDHHyr+3FYRAThgItghPV2cLOlqL4jKz4BvDGMSF454CtVP8poMd9+27A229FEB6ko7BgTCaVCMgJbedavvY71r9YQoCS8MNOwLpsOV3ltwa3ZCA6gPIGIQwBTIKPAa/ATstMYq2/rsJDkkUBBoOOqwgE7h4pyKaf4zkCA+uZ6gFPPKo9DAdcgcz9Z1BCmbEXDlhwT+QDqOKAgz8kAPEz6A0gDHhPAArYjyGAXlPPvBvQ6q2s/iH7P3iDcHIUMUks7/zb6/8qHUCO/wsBZAeQJgjV14VlN4C9AbXjrzQHgSMAckg3DtU8/b0vM3Zf5AyicEAtFwm+qvwZcNsZ0uOxVj4tP/tZAuEx81AOLX4jCFbXvr7TWvHrQWp/TwnGxCcq6VQm5ghABRK6QuDDBFgyOZvwRRHASPWjRF4vwddzAyrWRzJCoOo3/4zsv3UKJZTogX93AO/89vUvcBLQxP9pXsDWJHS1hwIXJ/sbgibbjwlAagl28T4qegGeDgssYCnGd2U9jOfFtqIMiMdvQIri/8i6Ry5DQPNoDuBQ30A6nwUvfDowr4CP4Qmhnam3LVIEvxgUr9UnBHX5Ds8aE4IlJs7Aa3eglXKGDBjgngwAoFK1VYgwsvfz66Nk4/LOv7X++cv2SrCWBPQOYCOAXA1YL+qPiJpWYCYA/FwUNi1riouKH+QAyBUY5zCt+lEVQZcOK2xB7SX0Z+r/IekMdN+p87xPaA6j5wPweD4rcIQAmHRGVQFDCrWxxzsUJgX7uZ8DiMhFHQNDkkYqHpRdMoDmoC4BQAjWFHqWALzSWycROwHlOJZ3fdv65zAEqGVAJID29+4AlvzSUFvrL2Cn9wcWglD2v4JHhQmZMIJwwE7hRetOScKOQ9hed+Iy/a6/P1D8EPht+/2vrtprl+EhOw/8/SHTLxVZmOtgQZ2T4Rg6AFHK9Ha/DD90KKzS3lFEBKBdANpkPp+10EwOCHrlDup1POItwUwuWo2Vxe+TQnM1CvRzRLG862+s/9PFVeoDSLX/9Xq5XMq8gNIDsPcD1HkC28tCytuC9vi/5QLs5KCi9hTrLz4hmIYFLBfk0GJ0BrlS97hvoIGylxT0wN+zARLQUbigCEYAMDzmNig6IUcx+wecQuQHpglgMmesYnE4AAAgAElEQVQwRwAWpPiJATln+z3oFbBRCc3flIfo2XpW03FuwAKSHUI7lwJuDPCx+isSgT6Ad33r+mcvLtfbi8tley1YIoDcDmyagbBJCN4WJMHP/QGo/jv4CzCa8pvmoR38CuQR8CfzAlRVaFBMwCbthnx7v1rQlH4EViCEx+QBwpIiqmrfLRwigHqNVqnLGXgpHntEAArQPZCzYs8RgnAE1a1YYHRVHyoY2xE1McTxeEwWihReBAHMHmM9Le/66+uf2QlgdwBpHkBxAzQfwDiAbTvzpqDa/beBYOsU3L52Dgd25aT8gKsAJJC1TkIgCRcGFMvfs/u0jux+ze2HDUY2NxCSwyAUMJTgQD9DGBluA8KYCRv0NgBjOsdcCIBQbOSjYnzW+xmV77kCre7t7Uc+ro9A384ykx/oOYPY7iuC6C/zrmAW2GW7cQixvPtb1v9+I4AN/DUMKOEAtgOXv9u04ev6Q6JV4fPPiYEDSGW9Bn6XACz7ZiA6AqgABUB3l5VBaEnCFvM64cHmPXq5garCojyo7Lo4loa9WDrhEmaAbxWbCUWrOypu8Rc6BzAmAKXe9vg4UNvVNoBb6vAzCDmXYOkHjzMCOKp1/Hds52fUXrXz+mVj8NpzWdAXp2IJyRPI8u5vXv/b/Y1AFycggBwG2EpAmhvQXhySkoEK/MYNMPjt5/1xZ4Iw4HdhgOoPiJzAWYCYty0Oo1j/mBQqNAfE0LaLlD1W/P45WFnb59m/+t2KaNijc4228etHLkCFDHWZKZURAcg2Yq3u7CBeDAG0GFo3CcXKrkAbAbmQ5B5zmIYe9Aap5Bttw26Ft13e/U3rn94IIKt/TQRe5ETgHgbYqcHmpSEpGQjKf4gQGvh9ApDyAFL1rc1vtr6fK0hrAYwm4QiEYGJuDgIYzDZP4M5hOvjw3D0IHwgRuEMwtPP6fAreKl8QuwDb/BMpPPoF+wvD3klYsKrmInYOXjWZAJSqI9D83/ExMQRRuQGlvscJwKv2TGhQCCFyFuV6l3d/4/m/urhachVgvb7Y8gDpZ8JdMrCSAYQI6dXhSAD5rUGm7JfAjDMFfViACg3g7zqBArPYCZSuQgvIsj26AASbdQMWhna7FC6U/43MPS2H3oKxgk+SwBNyBFEQoMIL3tYTAmcOyu8aiuVZ2SKyQACV+xSRAm87H/+3bzRyB0pNLaGo0MCqtyaA4yDv2/92TruddwrLu//a+b+4vFzqK8G2dwPCJKCwMajOF9hfGVbKgBH4ySGYnEAC4YnyBPsD5+2IDLTiN/W3sbxX/BbF23Ws9WnwAYW4xB/rvQBt3sevmQF4sM1EjsCCK1J/XK6A2tbzWukIRKvyk8IBRxRzdh89Ayu0KttFYNYlPkscTDhepZsXQbseATRW7nYmbf1VeKJDiG3p8u5vWP+z1AmY1Z8SgIUQQP3NlOE0UzD/glAmgqT0ojdAJAQl+I3dz25gL9OBM6jHauCs+Yi6La2LlrvEH1KAJ450VBECZCdg6KDjEDTRKJCiYxl7Bt5CKbmGvN1zJiyI3yCk5wNwoKCIQS+z3kOpdSM7TRDxPvM2PyIDDgdmE30vngAi9dcksLz69et/kjoBKwHUMqAMBUpOoBDFnhRMYUCz+Qr8eRlXBEKVL2AvNXr7uSUfM8irwjYHgI1DKgSwjT3gHNzEINybQgCO7QHwqk6gGnv0dthFOOMSZtQ9Jo/Y7mdYiW4/BFyz6DGJNJDoPe36ppga2Lx+liDG5IDqXc7tY2qr6PF2nlxG8bklBQ/c0frR8dGBLK9+3fqnLi72RqAtAdj6AEwFgPIB0BW4v0249ARI5Qcy6ILflwtLCNDgV7Ypys7uAJenEMLsWxXaVxQcQdTGICQUkSDM3YGxmjO8IzDn7WY6DTnh1/k8Un8J3ADsFnIN6HgOdg0YMtjt/NGOKP/j1R4beR4f/7Nys+L3qwOWYhCQNpR4DPjt9/Nhgj3m8upfXf+jWgW4PN1cqARg7hDMJGHbgrfGocvTzbqcL6z157jfuoINnL2koAO/yBskgJPi5/DBx/cFYAxo+kwVAWv3AeZBV6ElkkJICSx+XQZRt1fgMeqf9pkFf5l+yv4g2t9qrT9PHO8r5ecZf33lx7VouyNC6G2DYENA279bgg5B/kYRQE/de3mBBvRRjiDRTdl+efX/Xf9kKwO2MABDgpoUzGpvXhxSl209AQjyQgCvu0agdeklBZsTqIDhBKEBOQBYKv7WE2BB3iJ4sP3UbahDBp45iOqOHoBBaz+360HIaaCH4UFUVoTlEsBB4lCDXWUBFODt3pEjeIwbUMfywO2FAx7ACuwxAeikGlp+Bu0oHPAJwrm43RJAnNhr1xNvU0hgefX/Pv/7rQzY2oA30LuKABBA7RosyzYXANWA6gYMeBMZaOXHHEGGqKsMCHKAZCAnCS3wMRzIeiwSi2zlW55AATzODRjtF1UDooTAxIeewaQbWbmN+j+xUqCgzWTB23ir75U/dgneXzQV7wGdnUSc2GO3gMlBlSj0gG3XocD8YglgjhyKrvsQokMCy+m0vPpXzv9ucQCp+SfF+xd7nO9j/50URA4gdQjmHxItRLBQebACWiQEAewJdDm+r63C6XMDuX2PgLH8wgnU/VwlwBNDcx42AMAJSirmN2ptyn7aEcR5Axs6FID3t1dv91HUoJf17b7dB5XckE2d11+2ZzDrygD6DFb3Y5b/qBMYuQMGn46v58OBPph7Ci/tP/20GB7d5hUUCaRly6v/1/pvp8lAbS4AzAnYSWBvDirZ/0wAygGcLtar2hMgwc8JQV0ZSMoN/+XPFvwFpna7ppmFMJraNwIpwLahAfcVcB6B5xM4fa7EYwHM+1njr6x/FPfTGYOE4XTsPwoXur8cxKTAtNDWe4AzUBthxJY/VngmCaXidhvrDlCxEcz9+r93GLEbsADUYG5nbvE8hx8xkAvgyx7+GLhv+3t59S+v764OAN4JUBN+OSnYEoDrdf07kcHNcpneFbAnA43659LgDmAEf/D3pu8j8LNTyFl46w4A4KY8yKSRt4O+A4799ecGcBvPxyFBrN4zVQL9HoIoQHixBBA5hjjut/DGnAFSQVluXYIKDRjQ6Dp6YG+hgz1qAUc7zljpfQIwcAPwS0KKELxFt0e2yt1b58kgdhAa/NvS5dW/tL5zJ4C9AuDtfwoF0iSgPFW4/r0t253ARgCZDPYwIKu/dAMYBiDY8z7NqlsXwGEBbseVgLatbx6KQoFY7YMQARKLHtzHk4MGzBPtxZ2aAmX/Izfhge2Jw1t4a+61ytuwQIGeKUJVArzizwLfA5v1P123Vc1GSAxS5xDAelv73/a0JNOz/kgT7ZryxZlf8sVl/m/lIGLgl+++vPp/nr/m4nKbC9A6AQvoMRSA2H8H+77NBnpIAu4/MX5RqgE504+hADoB9/cGmrmQAMnAhAW7gyjqjPkCIAKT+LPgdklEU7yzvQOeMND2H3QCtaphgwMP0RjMeMbHOAALWntmdTwLa64MzIIeodqoJUr6WRhbEjnmBBqxWfi1n+zWBNEHOFt7ZfURphFJoAtQ21uXYH1Gs/498LdAYXn1f1+/quYA9nkA2eLnRqCNGPZXhOV6P/67EwEQQCGENDloy/hDEtAAXocACdi2X4BDAvyM4Hfb1ap7dhKUGEQAa/XHDsQcKphZhFHyEMID0y6MPkH/qnEvTNBGfFbd57bTxMFQL+rJVxSBXqm9Bz7uPU4Etq17wPdOIB95J1xW3raMrXtU/x8BXhOAsu4NkBy7z9j6mW20e9hCgL+4fgX3Aeygh0qAj/8TKezgL6HB1f5Ogevl6nS7TxHegZz/k+DH/oDXIfZvLsCqO24D6l6bgXxSUIcCZd8gPDBqTIlEMwcAzxeDviozzQDU8ftkPiDs/JsDuiYTVvG2lXYA3jNwVsAm9LzCe0VXZOHjdwZ2epOUpQ0mEQ9qH8PPxPkRGaDJ96FFpNL9GP9p6s8OQH3eCOB/W78M3gewzwPY7X1xAqD8Tf2zSygOIOUA9jzCXg68OF+mGLW4gALq2BE0sCdiMOBfXjefffxfgNryBiU5Z1wCTCay7oEVHtXdA72XKDRuIoOeHQaercGMHMJEo4+aV2DBfYwQeqGDygbw9r2wQCm8pRBUdeEQzAxDezSV7POE0LH9zg+o/MAR+++3xSVo0zHUYJWeVXZLFHPALyS1vPt/OX/xNh24qT5MCqLEX4n767/FATQiSI7gct3fF2hDAAX+5gJs/A+A38mghQUq/o9CgbIcY3u/bYGjrxD4/YrSi9wBdBIyQXjAxzmC5iXsX4oongL2tK8nCG34tTtoBKCThR706axuOU0fVvD2YcEoDChA8HYfQedDAQvex9l/RQCjZRa4x9X/GPAL2Szv/gvrF17CZKCdCPYuwNwMlBN+JdY3/17lHEAmghoSXJ5ubQiA4PdEwLH/Dvha+wfwQwXBgZtcA69vVty6iwb7AgZcj9N+W+iwLx20DmuXgKCL7T6v0Uofqfsx1edwIHIBfrmmCmPY3VuJmCjsMWLgM2mosEARgl5mCWAmFLB+Ymz3lVtggPJ5ewQQ7VtgjDmE3jJPEsu7//z6Ba0PwKp/6QYsOYC9VHjZ4n8AfM0HXGy5gDo5KLmApOAF1P7vZNcT0JEMjPLzNnVbtP8cKoC6S4LAPAABHCYZVUC6RGIDNNt8b/sR1n0HoEOEo44g2p4hbz/3CQDWyhmDDOhy7Dngo6NgW2913PoIb/e96nOGAD/j/seXj8jBry/2u8HWJwF76xrEHw/86gDe9efOn3+5vRIsx/yl9FfLgpdpTgDY/jRHAGx//Xy1L98JYLk4XzUXsCkmJgWbC2jgx9i/kIFalgEP1QKv9pwLaKpucwJo/znhV8godgE8qWhEAjo0YKBiLkCBWCn8jOrPbFMsOpCC+4XeiDBmw4CYDKyu+2DBx/rKCaiEIFPEnOr3E34I0ZYz8O7A0ouO/4+ovz4DHreAu/2riCKtXd71P58/73J/KWhpBU4u4GLv7kvJvp0M9lLgen1xlbL/hgQgFNjfMLy7gJwHgERgIgGbHEygKUAvJJHj/qra1h342L4pf10nOgY1UQgSEFOKo3wAgr6XHLTvEMJwowAKAWqP5EOAx5IAgpeOUe26tvYJjt498Na9vIC1+O2IHviPt/x4VKX63i2oJRFBIPgUAWi1j+J5u1wBm4GrfEEM7j4ppLXLu/7H9XN3AoAeAGgKSuqPLiCDvZIAgj/b/0ICpgpgQoEE9Jb4KwDOy43dj8BPicE9LodtYeKQJwx0BFllIUSwoFbOoCizTQaOHIGfhmxpwQLdhwwWfk/IATzyBaIzeQCv7wz04jKU4S8kY6nCAlkpvLf8SCHHQK9AjlBt59JW3G57xBH40KCdAVXdVwdY83ukYH3B8q4/u35OygFk5S9lwKL+l+ACWP0t+Hf7X3IAez/A8voFkkBK7rVQAO1/IQN0CW1ZcgnFLVhAc3/AHAlURYeXitjwgKsCCPbob9VbYG38TG4gQYRTgQz4SQKYnA7M2j6bC7Db+TDAq35s7RVoLbTVpxj8WtubXe9XAGwiz+v9yAEw9C0oj6u/phsL/TngY8CxvPPPnD+LQ4BL6PzbYv+LDejl31zm2x3A1ZLmEOTYH/7dw4DTcr5sgH8v5AFsTqARQ7b+Bey1/s/gz58hRHCkALMJnfWn2YWzwPdhAJOEzRdYGOO2ESnY5TpsUCFDXpbbnCPwegMfL5klABsa9JN9EfRV7O+tfE/TZ+J+b8+tlvdtf0QArMYM7Nj+27i/D28mD+8H2AOMPpcjLu/8H9bPvLg43V5yCACx/5b533MBu+LveYDkGK6WDegpJ1Dsf/p3dwKnPQ/w3toQ1KoBrTKArqApfKkeKOUvio9xP6u+cAHO4rcwAGcSHksS6lAgyhcoQvBaD8oeTC8uDkHBdzv3G0sAKhBQNIAQLleqrL2lhb7510D3ZNEDu03t4ZY6VEAnEG0dq72y62P119bfUsa82isyqATwtf/d+hnJAUAIsMX8HALkEmAigaT6xQHsFYGrbP+3f1siME0PXt4LpUAsCxIRbMqf4/9CFsb2jxxBjfuBHKifQCcCmQwKLLHEGKn9yAX08wSVANyPhRxPBJY9tiFbaOSxZKD3Q3g2+uGl4zxArPk+M9CjBIasNvX9UMCnCvswR+AhlL0XiAAbxfCj2N4Tx0jn9Xr8Bss7/pvzp5cQ4HJ/H8B6vYUALfGHmX/4+2qFECD9vdn+Av6Lq9P2YyO3G/j3+H2P/fPfORfQQN5yAwh8QwI1iVjCBPVvBjK0Dtc8Qg4JIgJQLqDvBmy8H6t+QAD0UlGGu53uOxf/c9YAHcJRIogIwGp9OsOYAHRtYOQHGhBHGt9zBlbB8XoTPBqsLJx1jM+WPqIDPnaDooLxGPqWTB4HfHWM5R1/ev20y4v2PgAs+212fyeDZv139b/cY/715rKEADvwKwnc5XBgCwPu1uX1BR3AeSOBnAisAOfPuXFoW28dAeUIcq5AJwuRIFDJRckwIAd8g5DKE+j16B7y37MvHDVvOEajPyIATx8cHjQIquRhZOv1UcbVAEsJI6BHQUDbr6fhDOkZiD8e9Ec0nwMDa+x7cb2H6tMMf6EjTxzLO/7r9VMvLtb9xR4p+ZdBn2v+W24gx/07Eeyfd/ufbX+J/3MIkEOBXf2Xq9Pd6SJVAgrw939LCXBXavhcS4MW+Coc8O4A8wUJ/E3to8qAXm7dgA0HEPS4XbXy+SfNMNvf4IlAbb0AZl/q0beq3q//67pAWzrnAlitPQkcI4Aj8Lehgf7kLbungFnTr91BPwRQsJ6L9DmbgHCc8wAvTvnLkZav+S/Pn9KqACkPsCl8TvLt4C8uYF9ecwA5BChEUJJ/16e7vay4hQA7AZwvE/ghD3BKFQEJfugXSCAuPQMF4HkZTBJqYA+qBSo34FRfkYFqFS75AiCGmdeO8ctF5LsF0jEb5BD+fRdg10Ylwm2YMaDVZ47ibTBxlADQwHPIwFDVbmDGAfSIIYb0nO3XoD9a2Ovp+kjhR+tH1BDtv3z1f77+vpYETC6gZP0vU8a/qn4lgBQS7HH/5fXe9ZeTgEuy/1en7d9CAFc1D1DUvuQFQP1LjgDzAiZHsIO45BIQ6Br0NvZ/ihtoJGDCAAd6jPXt31bhdTlwPgcQ6XwM+jgc6JOBNfJlW7XUqjwDPgK9zR54kI/MfboiG20rQLfjMJBx6yhXYHW6F/Nj1kDF20xD3gFoGL9R4N/OtnzVf3r+pEQAGfw1CZjBX23/9nmL/5dN3W8urlIOoGT/M/B35c9/329/ny7Peykwlfu2f4vlb9b/XAmhdQgmABfXkPoGPDnYnEADPcwlyOofE0LJDwzCAflGIeEGahMPWvxRJSBS+p4DsG5hZP81CYz9wBwJHCEAFRJo9e4X/Y7bfF8AHIGeCcLCegR4Xh+TQl+/31gC+I/Pv/fyMjf0bBOCNsXfSGDr+tvBX4Cfkn+76m9JQEEAF9e76hcSuN+cwOYOdiDvIE8EUMGdKwPJwvtcQMsbtLZhGxY0oCP4PRH08gN2XZuR2EqDXDmwLb24XQHlUx1Ag7PP7D/dATSFHnsDHQwwLfiynrbyVtNHdl85gEjxLVlYrWUHoFRc5/yZIHpuYBzRR0DuAfyp4I9Ip+YAvvJPrR+/JQG3EuBWAUhJv9P1BvIN/JUIdvXPyn+9EcZ6c7H925J/dxdX6+3+K0OJCHYHsFyttwncRf0TGaDCa1fQHEAUFiRwJHLAvxNAo3wAVwG4q3AEfKwolL8R+E35dSIQAwLc1iq6LQPyOv95PgAoxrln/1UiEN3CDAGMlT4igHnlV87BG+1jBBCB3roB9gIMVAXcX2gCmCGP5Sv+w/PHpclAadbfRgAb6Av4S9y/EwISwN4HcLq9vC5xfwZ/jv8vrncCuC8EUElAOQF0AJAsbG6hgJxDBFxeQI/235JAI4lMHKYleFwe1B2DnCjULsDG+FFI4ElgnNzz2YMetHFdL9VX0oVRTcBSgHIADYjNcVjAItARpEr5C+AiMB8BOULZO4ftGjlXUPIMRTd7ZMDbNmdwhBTamfrhQbR2Bvx7DuDL/+T5d+0hwNLAv2f+r5abqwb668vrZP1r7H992j43B7Bl/wH8ORG4EcBdCQHQCdi/W7cguoGm/MkxDBOEUDFQpcPUkMT9AQr4Nh+gm4RY9TG5x87gMZOEElRnQgCv/rxEx/rj6j9TBNKBdQRWzeesvncA5ZjewjNQLeCRWHhfD2ZPALHVH5OBBvws2EdAHa1XBHBkn+XL/oP1Yy63PoBN+bcQIMf/l9c5BNj+zUSwkcCeF7hOwK8EUMDf/t3Vf3MBy+V6l+L/13L8j7mAMkGo5AZagjAGfysncpkwrhog6DFv0EsANmIYKX+rDkRuICKApvhRvd8TwNPtf3MBbOWbVuttojDAK7tWfQVw3DKpr1LzPgE0SPvtFAGoMAGVWqXvijOYA/yLIIAjQPYZiDnnsHzpv3f+6MuLZZ8MtIcAxf5fn26utr8LAVyXrP96k4ng9iK5gBT7b+C/Xva4v9j/i+vTQ3UAmQBqInB5rWb5k9UvxIAJwaL8UDHA0iF2DKL6Q2ehs/01b9CSf3YbjPHjsKCpc8sZ+OQgAzyO+Y8RgCWB+fg/0nxebj83mjhKAB7wiVgKiNjs4/aWCGLrrxW/ncPb9t46G9vHoB/F/KP1Mxb/MQRwdJ/lS/6d9aNKErCAf7f+1zkEqARQlD8TwfVa4/8M+rvLFPdvBPCQHcBOAOdTAftrOQFYwL65ggL45gJ8GNBCAKwWmJDAgF41D2G2nxOEHBaozyr5p2y/Ajluh8ZeZfs56u/BexT/a+tfQOj13tt6Ze0biO0RME7n+N5+5vxAi7uTA4hCALVOEQC7CAYyGnuv6J4g4m0iIP+iIYAvevf5I65yGXC3/0X5r9brqwz+q5sU/yfrvzmAlvzblf/qtIF/+3e3/fm/jQQeLjIBbCTAoUAjBgR/yf7bngEuFba+gig3gD0CbPuf0jGYiMCHBQXYZT2/G8Am/ljxkQqa/VY5AFxb8gR+WbzEqz3rPdr/eQLwYUDLIKh1s2rP2x0DPOcKUOERpBb0niBOp6U6l55LmCWEN8oB8LWNAoHli951/q0XS+rxb4m/BP6dAKoD2EgAwL+TQLL/l2j9r9f7y+vlYXcBWwhweb47Lyn+T3mAkgsoroCVH/MBLQTA3gFdHeBEoSaA8mahca8AOgZfGozmBDRN7vUCMDkUILPa6wwAg3scAign0JbZTIB3AQ3IqPhWxVm5vUvA7Xt/s/Wfs/gYViiQz4JdbZeOt/8iaP2faLsIgLM5gegcIyDPEIo6xvKFX7v+5hQCbHMA1uvN/l9t9j+DP7mAFPdf7nmA0+3lzVb6yyHA9a7+95vSZ+BvDmAH/+X16dnp6nzbgJ8IIOUBGhFwdcDmBHjeAPcQ2H4BmwhMSi+TgyIXUPoHxlODZ8KBkQOwcbzX+pG9n1H/PvBbwo2Dgaa62u57RVexPapv/DeTwQwBRKFAs/ps41vmwW8zcgW/WAjgaPy/fa/lC776/JtSG/CW9MvgL/Z/cwGb/U9uYLf/V1vdP6t/tv07AewkkP7bgP9wcXN6dnF9erZcvn6TwF7Ab11AcwboBF6rk4dUglA3EcVlQqv2SAqqOjCr/Dr5Z5t/Wj4AI38Ldjb/nAPo2/tY/b3Vt0eyII9UfkwAfJwEMEUIzWm0mNoSg1d7tuYe2O1YDcgN7iqeP7rs7wUBHAXz0e2LG1j++Feuv2F3AJdb0q9Z/+QCNsCfbi5vltuNAPbYf6v97wnATfmXDfBIAA+XN7v6P9vU//Lm9Hy9eO9VUv1GApYQwA3UUMGGBVwh0L0Ctp247wSwAuDnDbQXkPas/wwBoMpzDmDkAFDhEeYW2J4A5lS/ALQHcAtka/85qacdwMjqK7W36t4HfLkmb81HRMFWvUcK7+sE8Fjw7w7g87/s/GEbAWwlv80BXN8k+7//d7PlAHbVT+Df/0vWPxHAupf+LnPcv4F/A/6m/pkAXlqX1y4S4N9TXYAjhL37D/MEcV7gMRWC+XbhXva/vIY8mB0oJgFZE68IwJKASgRqhW8gt+t7qu9j+z7AOd73YYEigQKsFl4UR6Cs/hjsvdg+AnkvBxDnAqyT8ATRcgCjDP9svN8D7hFQH9mW8wDLH/uS84duIcBOADvw1+vrDP5EAgn81QEU9b9Z7i+v1ruLm9P91fWSlX99uLxeduXP/72UgF/An/7d3cCu9vY/mxtIpNAmENFEIpxUVLsEsVyIvz3gW4b5NeN2tmBMBOplIT4hiIafy4I2GIh0vtj1eQKYAb8CcTPhSAjNIbBKN9XluB4BaR0Bxt3Wntt9RiGAjd/fJIB2P2aThI4APvcLX/+Qq8uL2633//pmcwA5D7D/u+4EgODfcgCXN9n236TYf4v5i/pf3qzPLm+WlzYCuLhen51PP5+Bnohg3YFv3UDLDxQnwF2D+DlZfTOrsJJBATo2DuH8gWL92farvoCS6OMfIFEOwHb6aa2PC389sM8RgFJ3tuz9zz4HgGRh1RvJoSm+B7aP72fcwBzIE1mp+F8ve1zcj6HF4x1ApNBHlyuQP0X99xDgj37B+Z/ZZgJuan+9xf03hQh24G9hADiA9XYD/9Vm+wv4N9t/c3q4SjF/Uv/b00YALy2Xr9/toN8AvxQnYN2ATw5ymbCBn+cP6O7BXi4gKbt6bwB3A7b2Xp8HKOt0yQ/7ARG+jyWAfkxvXwLOCh+BfmTnrcqzSs8TQM/2Ixn0/44s/S93Angq+HcC+OzPf/2fvry8uN0SgDebA7jNZLA5gE39b5r9v0rKf3dVwb/eX93sln8jgedXxfrfnl66uj29clpeuzovmwNA8AchgUsS2vkDLUegmoZ8+3CL++EVUykAAAroSURBVDkUwLIgZ/zbJKAxAWjVj+DPZT6l7PGyWOHbPrG954SftfqYsUfgq2y+dQUjy+/t/Tzoe0m8Iwm+IyQRJQY5CXg0B3BU6WeBPbtdLzxYPuvzzv/U5gA2639zs+z/7mHAzbolBHcCKMm/jQCutth/j/vX7d+HTADPrm63uH99fnW7vHx1e9r+eyXZ//KfJ4HdGVTg49++aUj1CpQ3BtlwoCi8bwyypBCVAIvi4zyAErdj/d/W+THhZ0OAluizfqAY//ZvWm8V3y+zQI8dgFZ5TQYc51vwzzkAb917BKCAGW3PDuCXAgG8LyQAdwfwhz/n9X/y+uridkv+3dxuJHC6ubrdqwHbsj0EuLpZNtW/u7peGwHs4F835X92dbs8v9pU/2ZX/pev7k6vXFy/nuN/JADrBhIBaBJoCcG4cxAJoLx5WLYM0wtD5roA2fpz7K8IwCb4uJVHE0ADvFfz7RxK/Ru4LUGwQnMI4IFdYmmO171LaLF128cvs1UAuz5ah8vV30cJAMH1S9kBsGN5TCJw+Yw/cv4ntiagHfy3y04A1zc78HfwX+/gT7H/dVb/6xL3327gT9b/6nZ96fpueWVT/qvb01tOl++5bur/cxnojQwa+I/mBLhV2L9dKH5vQNQEZBN+HOPrz9zO44t43MiLYFXlO2XnRxY/EUSk9t6y2+x+ZPObVe+B3TuDPiG8SQAWokdDgzckCfjpn/n6P745gOub8/XtXQoBbm4365/UPxHAHvfvsf/VzXp/fbs829Q/Kf/6/Pou2f7ru9MrV3ent17drq+cTxvoy38YCvx8Sgru/xVHgJWBLWmI5cFSDrTJQPdCkVwJ4NmC/sUgUcZ/3vIfaemJQK+s/XiZBWzbPlJ2julVjK/jcgR++ZsBrAhg1va/kSHALwYH8CJCgBeSA/i0P3T+x7YGoNu7083t7XJzfbvF/nseYI//r28T+K9vlx38V7fLw/Vu+9dn13fLS9cp4ffy9d36yvX98tbru9PblqvX7hL4fzaDfPt7A74lAp8cTETguwYxIahLghgCqAQgZvltzV/N+ceY36f1UNl1lb/E9Sd6y7+N8dneKzvvFR7t/yzwtaIzyBXAjzqAxxDAiAx+KYYA7zME8Ac/7fV/9Ob24vbm9ny9EcDN3XK7hQBIAJv1v7o93V/fnh6ub9eH6xTzP7++O710fXd6+ebu9Jbr7b/709uu79e3J+AXAkguYN0/RwRAvQKibbg1BJWOQZwp2HthCJf+et1+JRTAWL7pfQ/sNr7nuD599m5AJfSsbbcqbxXcO4A5oCt1j9T8TQIoYc2L7QN4nyGAT/nU8z+yxf27A7jL1YDbXflvr2+T/b/ewL9Z/7vl2fXt6dn13en5zQ7+9eWbu2UD/ltv7k9vu3k4vd9y9Z77jQDWnQTKfxgKIBFgGJAbhUTbsJowZDsES6mPXxdWynyo8tFbfjDJx8k8m85TyTyM1ft/FzKYA3oP5M0dPA34PYv/JgH8EieAT/797/21m/Lf3adE4O3mAG53F7Db/5vbZVP+++u79eHmdrHgv1/ecvNweuvt/entG/hv7s9vP59+5tT+804guQAmgVYitKVBnEWIU4jt68PGrw23qt+SegXY0b/JynNZT8X1aOf93x70bZsE3gjoPZC/SQD9rr+ogagk0zj0+IXsA3ifcQCf+MnnX3N3d0oEcJcSgDe7+q+3O/jvNuu/3t/cnZ7d3C278t/cry/fFvA/rG+/fVje/+756YNOFz97fT79NBHARgg2HIhDgdw1OJwjYF8eqgmgB3rM67eIXgO9WHf+19p6SwocpyfrjqBn8EZgfpMAPMij0l4P0DPrflkSwO/5hPf+6vv75ADu7vdqwM3N3cXdzd2m/uvdzd3ycLOp/93p+e39ksD/sLzl9uH0trtnp7ffPjt9wN2z0wdd3b7n5fPpp06JAJgEOBTQYUBT/1IaxAlBJfmH7xDEST6+xIdKz5F8qfKrd/O0WL84gAJg/JeXqdq8An16tdSbBKB7BHp9ALPAf7MKMN8RsHzc7z7/g/cPp5v73QGsexLw9m7J4D/d394vz27u1me3D8tLt/fry3cPy1vunu3gf7+75+sH3L+0/Irbh9c/4Hz6yVMigB4JRKXBEv+rSUL0GnE38Qd7+5Xql7l6GMe3Rt+WnPMKX1Q9+jft6y08gtv//SYBqJzDTKb/KAEcJYJflg7gYz72vb/y4dmm/psLWG5v7k63t3enu9u7Dfynh9v707O7DfwPp5fvHk5vuX++vu3++fL+98/XD3x4efngh5dPv+p8+vFTIgAmAZUP4N6AKP7HdwTYdwNibb/9BFjSdGXum9pbkFulb3G4BbwHuQJ4H/SFJLZ/33cJYFQJeKP6AGbLgL8YCEDF9rPLODcx0vEX0gfw0b/z/MHPn59ubvcQYFP/9fb2frm/vV/v7+5Pz+6fLS/dPZxevn92esv9S6e3Pzw/vf/Dy6e/79nLp7//+VtO/9B68RNXiQCYBEoYsP0bhQB2fkD78RCeAdisPv/mXwx6m7zzoG5ttiU2t/82m95UHoFs/36TAHRD0Wxr8C8VBzAL9veZJOBH/vb3ftBGAPfPLm/v7k63dw+nu7v70/3tw/pw/3B6fv/s9PLDS8tbH146vf3ZS+sHPH/L8sHPX1l/1ctvW37N6fLHb86nHz2dTz8mCGALBdABYGMQTxDCl4Xa2X42wccqz026kcK3hhwEeQTs2eUYy79JAG8SQNSbP0sKf08cwG/7iPMHJAew3jw8XNzd3Z/v7p8tD/fPTs8fXjq9/Oyl5a3PXz693/NX1g986a3Lr3zlbadf/cr7nf7h08WPXJ9PP3w6n34ECOAnIAwoyUDVC8CTgLi5BxW/NOew1iewl/9KLI9Kj0BWoJ4F+psOIIH7zRDAViQUYGfB/j7jAD78w197+7Pny83Ds+X2/tly9/Cw3j97aXn+7KXl5ecvn976/JX1/V552/IrXnnb+g+89f2XX/u2D/z/2zuXnYSBMAqf0YhAW1pKuQVUVDRqCG5MUBN0oRt3bnwMX8c38EmMD+DGxBgX3qKocUc0mk5NkQk/ZWw1bozMgnBpWJ5zvv8yrbfM0QLHIzieiAH4FED7ACL9xS4APQlI7wxM7+4jOvm9pKejObng+1H9K9ErA/jeslDYOrAygH9oADs7PK3piCU1b1wzWEI3mKYZnmFazDZt5KwMypkcqtki6pbzuuTiFhz34HgIGIBIf5r8YtxHEz+I+PLmXb/YP0VOXwK/xW/0e9Rn2XUZzkcRgioBoqlA9QB69ESben+GALa231O67sV0YyRupJA00yMpy2a27aDg5FHJl7xaucKaca1V4LiEi5uuAfgEQPGf1vy0xqcNPXnCy0QcJvZgyn8n9RUBKAKQbQaGj/56kqVPBgqKVzZujBL7nzGAZrOtpczYuGmxhGUzw8myTK6IUmkSi5Uqa05Mt7c4TsFxAY4ruLjr4r8vfj/1hfBF2gu8F3W8OIwzmOJRqR5mDIoABpeJxHz9N++qBKCiHwIDaKy+JWx7LO5kPb1QhDM1g9mFGttYWfP2OY7BcQKOc3Bcd7Df7XT9/VpfHPWlgo8WeVD0UUkvS3tFAIPjyN+Inv5XGcCQGUC9/hwrlQ1tbn602FjH5u7eywHHIVwcgeOsi/v+jN9v6vn1O+AG6vEwUf/kWjDVFQGEpzwdPSoD6J9UfIX2wWWiYS8BPgCAPOYxoDrtqQAAAABJRU5ErkJggg==";
  96235. return BRDFTextureTools;
  96236. }());
  96237. /***/ }),
  96238. /***/ "./Misc/dds.ts":
  96239. /*!*********************!*\
  96240. !*** ./Misc/dds.ts ***!
  96241. \*********************/
  96242. /*! exports provided: DDSTools */
  96243. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96244. "use strict";
  96245. __webpack_require__.r(__webpack_exports__);
  96246. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return DDSTools; });
  96247. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  96248. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  96249. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  96250. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  96251. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  96252. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  96253. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  96254. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  96255. // Based on demo done by Brandon Jones - http://media.tojicode.com/webgl-samples/dds.html
  96256. // All values and structures referenced from:
  96257. // http://msdn.microsoft.com/en-us/library/bb943991.aspx/
  96258. var DDS_MAGIC = 0x20534444;
  96259. var
  96260. //DDSD_CAPS = 0x1,
  96261. //DDSD_HEIGHT = 0x2,
  96262. //DDSD_WIDTH = 0x4,
  96263. //DDSD_PITCH = 0x8,
  96264. //DDSD_PIXELFORMAT = 0x1000,
  96265. DDSD_MIPMAPCOUNT = 0x20000;
  96266. //DDSD_LINEARSIZE = 0x80000,
  96267. //DDSD_DEPTH = 0x800000;
  96268. // var DDSCAPS_COMPLEX = 0x8,
  96269. // DDSCAPS_MIPMAP = 0x400000,
  96270. // DDSCAPS_TEXTURE = 0x1000;
  96271. var DDSCAPS2_CUBEMAP = 0x200;
  96272. // DDSCAPS2_CUBEMAP_POSITIVEX = 0x400,
  96273. // DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800,
  96274. // DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000,
  96275. // DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000,
  96276. // DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000,
  96277. // DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000,
  96278. // DDSCAPS2_VOLUME = 0x200000;
  96279. var
  96280. //DDPF_ALPHAPIXELS = 0x1,
  96281. //DDPF_ALPHA = 0x2,
  96282. DDPF_FOURCC = 0x4, DDPF_RGB = 0x40,
  96283. //DDPF_YUV = 0x200,
  96284. DDPF_LUMINANCE = 0x20000;
  96285. function FourCCToInt32(value) {
  96286. return value.charCodeAt(0) +
  96287. (value.charCodeAt(1) << 8) +
  96288. (value.charCodeAt(2) << 16) +
  96289. (value.charCodeAt(3) << 24);
  96290. }
  96291. function Int32ToFourCC(value) {
  96292. return String.fromCharCode(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >> 24) & 0xff);
  96293. }
  96294. var FOURCC_DXT1 = FourCCToInt32("DXT1");
  96295. var FOURCC_DXT3 = FourCCToInt32("DXT3");
  96296. var FOURCC_DXT5 = FourCCToInt32("DXT5");
  96297. var FOURCC_DX10 = FourCCToInt32("DX10");
  96298. var FOURCC_D3DFMT_R16G16B16A16F = 113;
  96299. var FOURCC_D3DFMT_R32G32B32A32F = 116;
  96300. var DXGI_FORMAT_R16G16B16A16_FLOAT = 10;
  96301. var DXGI_FORMAT_B8G8R8X8_UNORM = 88;
  96302. var headerLengthInt = 31; // The header length in 32 bit ints
  96303. // Offsets into the header array
  96304. var off_magic = 0;
  96305. var off_size = 1;
  96306. var off_flags = 2;
  96307. var off_height = 3;
  96308. var off_width = 4;
  96309. var off_mipmapCount = 7;
  96310. var off_pfFlags = 20;
  96311. var off_pfFourCC = 21;
  96312. var off_RGBbpp = 22;
  96313. var off_RMask = 23;
  96314. var off_GMask = 24;
  96315. var off_BMask = 25;
  96316. var off_AMask = 26;
  96317. // var off_caps1 = 27;
  96318. var off_caps2 = 28;
  96319. // var off_caps3 = 29;
  96320. // var off_caps4 = 30;
  96321. var off_dxgiFormat = 32;
  96322. /**
  96323. * Class used to provide DDS decompression tools
  96324. */
  96325. var DDSTools = /** @class */ (function () {
  96326. function DDSTools() {
  96327. }
  96328. /**
  96329. * Gets DDS information from an array buffer
  96330. * @param arrayBuffer defines the array buffer to read data from
  96331. * @returns the DDS information
  96332. */
  96333. DDSTools.GetDDSInfo = function (arrayBuffer) {
  96334. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  96335. var extendedHeader = new Int32Array(arrayBuffer, 0, headerLengthInt + 4);
  96336. var mipmapCount = 1;
  96337. if (header[off_flags] & DDSD_MIPMAPCOUNT) {
  96338. mipmapCount = Math.max(1, header[off_mipmapCount]);
  96339. }
  96340. var fourCC = header[off_pfFourCC];
  96341. var dxgiFormat = (fourCC === FOURCC_DX10) ? extendedHeader[off_dxgiFormat] : 0;
  96342. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  96343. switch (fourCC) {
  96344. case FOURCC_D3DFMT_R16G16B16A16F:
  96345. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  96346. break;
  96347. case FOURCC_D3DFMT_R32G32B32A32F:
  96348. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  96349. break;
  96350. case FOURCC_DX10:
  96351. if (dxgiFormat === DXGI_FORMAT_R16G16B16A16_FLOAT) {
  96352. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  96353. break;
  96354. }
  96355. }
  96356. return {
  96357. width: header[off_width],
  96358. height: header[off_height],
  96359. mipmapCount: mipmapCount,
  96360. isFourCC: (header[off_pfFlags] & DDPF_FOURCC) === DDPF_FOURCC,
  96361. isRGB: (header[off_pfFlags] & DDPF_RGB) === DDPF_RGB,
  96362. isLuminance: (header[off_pfFlags] & DDPF_LUMINANCE) === DDPF_LUMINANCE,
  96363. isCube: (header[off_caps2] & DDSCAPS2_CUBEMAP) === DDSCAPS2_CUBEMAP,
  96364. isCompressed: (fourCC === FOURCC_DXT1 || fourCC === FOURCC_DXT3 || fourCC === FOURCC_DXT5),
  96365. dxgiFormat: dxgiFormat,
  96366. textureType: textureType
  96367. };
  96368. };
  96369. DDSTools._ToHalfFloat = function (value) {
  96370. if (!DDSTools._FloatView) {
  96371. DDSTools._FloatView = new Float32Array(1);
  96372. DDSTools._Int32View = new Int32Array(DDSTools._FloatView.buffer);
  96373. }
  96374. DDSTools._FloatView[0] = value;
  96375. var x = DDSTools._Int32View[0];
  96376. var bits = (x >> 16) & 0x8000; /* Get the sign */
  96377. var m = (x >> 12) & 0x07ff; /* Keep one extra bit for rounding */
  96378. var e = (x >> 23) & 0xff; /* Using int is faster here */
  96379. /* If zero, or denormal, or exponent underflows too much for a denormal
  96380. * half, return signed zero. */
  96381. if (e < 103) {
  96382. return bits;
  96383. }
  96384. /* If NaN, return NaN. If Inf or exponent overflow, return Inf. */
  96385. if (e > 142) {
  96386. bits |= 0x7c00;
  96387. /* If exponent was 0xff and one mantissa bit was set, it means NaN,
  96388. * not Inf, so make sure we set one mantissa bit too. */
  96389. bits |= ((e == 255) ? 0 : 1) && (x & 0x007fffff);
  96390. return bits;
  96391. }
  96392. /* If exponent underflows but not too much, return a denormal */
  96393. if (e < 113) {
  96394. m |= 0x0800;
  96395. /* Extra rounding may overflow and set mantissa to 0 and exponent
  96396. * to 1, which is OK. */
  96397. bits |= (m >> (114 - e)) + ((m >> (113 - e)) & 1);
  96398. return bits;
  96399. }
  96400. bits |= ((e - 112) << 10) | (m >> 1);
  96401. bits += m & 1;
  96402. return bits;
  96403. };
  96404. DDSTools._FromHalfFloat = function (value) {
  96405. var s = (value & 0x8000) >> 15;
  96406. var e = (value & 0x7C00) >> 10;
  96407. var f = value & 0x03FF;
  96408. if (e === 0) {
  96409. return (s ? -1 : 1) * Math.pow(2, -14) * (f / Math.pow(2, 10));
  96410. }
  96411. else if (e == 0x1F) {
  96412. return f ? NaN : ((s ? -1 : 1) * Infinity);
  96413. }
  96414. return (s ? -1 : 1) * Math.pow(2, e - 15) * (1 + (f / Math.pow(2, 10)));
  96415. };
  96416. DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  96417. var destArray = new Float32Array(dataLength);
  96418. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  96419. var index = 0;
  96420. for (var y = 0; y < height; y++) {
  96421. for (var x = 0; x < width; x++) {
  96422. var srcPos = (x + y * width) * 4;
  96423. destArray[index] = DDSTools._FromHalfFloat(srcData[srcPos]);
  96424. destArray[index + 1] = DDSTools._FromHalfFloat(srcData[srcPos + 1]);
  96425. destArray[index + 2] = DDSTools._FromHalfFloat(srcData[srcPos + 2]);
  96426. if (DDSTools.StoreLODInAlphaChannel) {
  96427. destArray[index + 3] = lod;
  96428. }
  96429. else {
  96430. destArray[index + 3] = DDSTools._FromHalfFloat(srcData[srcPos + 3]);
  96431. }
  96432. index += 4;
  96433. }
  96434. }
  96435. return destArray;
  96436. };
  96437. DDSTools._GetHalfFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  96438. if (DDSTools.StoreLODInAlphaChannel) {
  96439. var destArray = new Uint16Array(dataLength);
  96440. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  96441. var index = 0;
  96442. for (var y = 0; y < height; y++) {
  96443. for (var x = 0; x < width; x++) {
  96444. var srcPos = (x + y * width) * 4;
  96445. destArray[index] = srcData[srcPos];
  96446. destArray[index + 1] = srcData[srcPos + 1];
  96447. destArray[index + 2] = srcData[srcPos + 2];
  96448. destArray[index + 3] = DDSTools._ToHalfFloat(lod);
  96449. index += 4;
  96450. }
  96451. }
  96452. return destArray;
  96453. }
  96454. return new Uint16Array(arrayBuffer, dataOffset, dataLength);
  96455. };
  96456. DDSTools._GetFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  96457. if (DDSTools.StoreLODInAlphaChannel) {
  96458. var destArray = new Float32Array(dataLength);
  96459. var srcData = new Float32Array(arrayBuffer, dataOffset);
  96460. var index = 0;
  96461. for (var y = 0; y < height; y++) {
  96462. for (var x = 0; x < width; x++) {
  96463. var srcPos = (x + y * width) * 4;
  96464. destArray[index] = srcData[srcPos];
  96465. destArray[index + 1] = srcData[srcPos + 1];
  96466. destArray[index + 2] = srcData[srcPos + 2];
  96467. destArray[index + 3] = lod;
  96468. index += 4;
  96469. }
  96470. }
  96471. return destArray;
  96472. }
  96473. return new Float32Array(arrayBuffer, dataOffset, dataLength);
  96474. };
  96475. DDSTools._GetFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  96476. var destArray = new Uint8Array(dataLength);
  96477. var srcData = new Float32Array(arrayBuffer, dataOffset);
  96478. var index = 0;
  96479. for (var y = 0; y < height; y++) {
  96480. for (var x = 0; x < width; x++) {
  96481. var srcPos = (x + y * width) * 4;
  96482. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos]) * 255;
  96483. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 1]) * 255;
  96484. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 2]) * 255;
  96485. if (DDSTools.StoreLODInAlphaChannel) {
  96486. destArray[index + 3] = lod;
  96487. }
  96488. else {
  96489. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 3]) * 255;
  96490. }
  96491. index += 4;
  96492. }
  96493. }
  96494. return destArray;
  96495. };
  96496. DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  96497. var destArray = new Uint8Array(dataLength);
  96498. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  96499. var index = 0;
  96500. for (var y = 0; y < height; y++) {
  96501. for (var x = 0; x < width; x++) {
  96502. var srcPos = (x + y * width) * 4;
  96503. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos])) * 255;
  96504. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 1])) * 255;
  96505. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 2])) * 255;
  96506. if (DDSTools.StoreLODInAlphaChannel) {
  96507. destArray[index + 3] = lod;
  96508. }
  96509. else {
  96510. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 3])) * 255;
  96511. }
  96512. index += 4;
  96513. }
  96514. }
  96515. return destArray;
  96516. };
  96517. DDSTools._GetRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset) {
  96518. var byteArray = new Uint8Array(dataLength);
  96519. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  96520. var index = 0;
  96521. for (var y = 0; y < height; y++) {
  96522. for (var x = 0; x < width; x++) {
  96523. var srcPos = (x + y * width) * 4;
  96524. byteArray[index] = srcData[srcPos + rOffset];
  96525. byteArray[index + 1] = srcData[srcPos + gOffset];
  96526. byteArray[index + 2] = srcData[srcPos + bOffset];
  96527. byteArray[index + 3] = srcData[srcPos + aOffset];
  96528. index += 4;
  96529. }
  96530. }
  96531. return byteArray;
  96532. };
  96533. DDSTools._ExtractLongWordOrder = function (value) {
  96534. if (value === 0 || value === 255 || value === -16777216) {
  96535. return 0;
  96536. }
  96537. return 1 + DDSTools._ExtractLongWordOrder(value >> 8);
  96538. };
  96539. DDSTools._GetRGBArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset) {
  96540. var byteArray = new Uint8Array(dataLength);
  96541. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  96542. var index = 0;
  96543. for (var y = 0; y < height; y++) {
  96544. for (var x = 0; x < width; x++) {
  96545. var srcPos = (x + y * width) * 3;
  96546. byteArray[index] = srcData[srcPos + rOffset];
  96547. byteArray[index + 1] = srcData[srcPos + gOffset];
  96548. byteArray[index + 2] = srcData[srcPos + bOffset];
  96549. index += 3;
  96550. }
  96551. }
  96552. return byteArray;
  96553. };
  96554. DDSTools._GetLuminanceArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer) {
  96555. var byteArray = new Uint8Array(dataLength);
  96556. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  96557. var index = 0;
  96558. for (var y = 0; y < height; y++) {
  96559. for (var x = 0; x < width; x++) {
  96560. var srcPos = (x + y * width);
  96561. byteArray[index] = srcData[srcPos];
  96562. index++;
  96563. }
  96564. }
  96565. return byteArray;
  96566. };
  96567. /**
  96568. * Uploads DDS Levels to a Babylon Texture
  96569. * @hidden
  96570. */
  96571. DDSTools.UploadDDSLevels = function (engine, texture, arrayBuffer, info, loadMipmaps, faces, lodIndex, currentFace) {
  96572. if (lodIndex === void 0) { lodIndex = -1; }
  96573. var sphericalPolynomialFaces = null;
  96574. if (info.sphericalPolynomial) {
  96575. sphericalPolynomialFaces = new Array();
  96576. }
  96577. var ext = engine.getCaps().s3tc;
  96578. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  96579. var fourCC, width, height, dataLength = 0, dataOffset;
  96580. var byteArray, mipmapCount, mip;
  96581. var internalCompressedFormat = 0;
  96582. var blockBytes = 1;
  96583. if (header[off_magic] !== DDS_MAGIC) {
  96584. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Invalid magic number in DDS header");
  96585. return;
  96586. }
  96587. if (!info.isFourCC && !info.isRGB && !info.isLuminance) {
  96588. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
  96589. return;
  96590. }
  96591. if (info.isCompressed && !ext) {
  96592. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Compressed textures are not supported on this platform.");
  96593. return;
  96594. }
  96595. var bpp = header[off_RGBbpp];
  96596. dataOffset = header[off_size] + 4;
  96597. var computeFormats = false;
  96598. if (info.isFourCC) {
  96599. fourCC = header[off_pfFourCC];
  96600. switch (fourCC) {
  96601. case FOURCC_DXT1:
  96602. blockBytes = 8;
  96603. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT1_EXT;
  96604. break;
  96605. case FOURCC_DXT3:
  96606. blockBytes = 16;
  96607. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT3_EXT;
  96608. break;
  96609. case FOURCC_DXT5:
  96610. blockBytes = 16;
  96611. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT5_EXT;
  96612. break;
  96613. case FOURCC_D3DFMT_R16G16B16A16F:
  96614. computeFormats = true;
  96615. break;
  96616. case FOURCC_D3DFMT_R32G32B32A32F:
  96617. computeFormats = true;
  96618. break;
  96619. case FOURCC_DX10:
  96620. // There is an additionnal header so dataOffset need to be changed
  96621. dataOffset += 5 * 4; // 5 uints
  96622. var supported = false;
  96623. switch (info.dxgiFormat) {
  96624. case DXGI_FORMAT_R16G16B16A16_FLOAT:
  96625. computeFormats = true;
  96626. supported = true;
  96627. break;
  96628. case DXGI_FORMAT_B8G8R8X8_UNORM:
  96629. info.isRGB = true;
  96630. info.isFourCC = false;
  96631. bpp = 32;
  96632. supported = true;
  96633. break;
  96634. }
  96635. if (supported) {
  96636. break;
  96637. }
  96638. default:
  96639. console.error("Unsupported FourCC code:", Int32ToFourCC(fourCC));
  96640. return;
  96641. }
  96642. }
  96643. var rOffset = DDSTools._ExtractLongWordOrder(header[off_RMask]);
  96644. var gOffset = DDSTools._ExtractLongWordOrder(header[off_GMask]);
  96645. var bOffset = DDSTools._ExtractLongWordOrder(header[off_BMask]);
  96646. var aOffset = DDSTools._ExtractLongWordOrder(header[off_AMask]);
  96647. if (computeFormats) {
  96648. internalCompressedFormat = engine._getRGBABufferInternalSizedFormat(info.textureType);
  96649. }
  96650. mipmapCount = 1;
  96651. if (header[off_flags] & DDSD_MIPMAPCOUNT && loadMipmaps !== false) {
  96652. mipmapCount = Math.max(1, header[off_mipmapCount]);
  96653. }
  96654. for (var face = 0; face < faces; face++) {
  96655. width = header[off_width];
  96656. height = header[off_height];
  96657. for (mip = 0; mip < mipmapCount; ++mip) {
  96658. if (lodIndex === -1 || lodIndex === mip) {
  96659. // In case of fixed LOD, if the lod has just been uploaded, early exit.
  96660. var i = (lodIndex === -1) ? mip : 0;
  96661. if (!info.isCompressed && info.isFourCC) {
  96662. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  96663. dataLength = width * height * 4;
  96664. var floatArray = null;
  96665. if (engine._badOS || engine._badDesktopOS || (!engine.getCaps().textureHalfFloat && !engine.getCaps().textureFloat)) { // Required because iOS has many issues with float and half float generation
  96666. if (bpp === 128) {
  96667. floatArray = DDSTools._GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  96668. if (sphericalPolynomialFaces && i == 0) {
  96669. sphericalPolynomialFaces.push(DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  96670. }
  96671. }
  96672. else if (bpp === 64) {
  96673. floatArray = DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  96674. if (sphericalPolynomialFaces && i == 0) {
  96675. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  96676. }
  96677. }
  96678. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  96679. }
  96680. else {
  96681. if (bpp === 128) {
  96682. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  96683. floatArray = DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  96684. if (sphericalPolynomialFaces && i == 0) {
  96685. sphericalPolynomialFaces.push(floatArray);
  96686. }
  96687. }
  96688. else if (bpp === 64 && !engine.getCaps().textureHalfFloat) {
  96689. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  96690. floatArray = DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  96691. if (sphericalPolynomialFaces && i == 0) {
  96692. sphericalPolynomialFaces.push(floatArray);
  96693. }
  96694. }
  96695. else { // 64
  96696. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  96697. floatArray = DDSTools._GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  96698. if (sphericalPolynomialFaces && i == 0) {
  96699. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  96700. }
  96701. }
  96702. }
  96703. if (floatArray) {
  96704. engine._uploadDataToTextureDirectly(texture, floatArray, face, i);
  96705. }
  96706. }
  96707. else if (info.isRGB) {
  96708. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  96709. if (bpp === 24) {
  96710. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB;
  96711. dataLength = width * height * 3;
  96712. byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  96713. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  96714. }
  96715. else { // 32
  96716. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  96717. dataLength = width * height * 4;
  96718. byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  96719. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  96720. }
  96721. }
  96722. else if (info.isLuminance) {
  96723. var unpackAlignment = engine._getUnpackAlignement();
  96724. var unpaddedRowSize = width;
  96725. var paddedRowSize = Math.floor((width + unpackAlignment - 1) / unpackAlignment) * unpackAlignment;
  96726. dataLength = paddedRowSize * (height - 1) + unpaddedRowSize;
  96727. byteArray = DDSTools._GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  96728. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE;
  96729. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  96730. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  96731. }
  96732. else {
  96733. dataLength = Math.max(4, width) / 4 * Math.max(4, height) / 4 * blockBytes;
  96734. byteArray = new Uint8Array(arrayBuffer, dataOffset, dataLength);
  96735. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  96736. engine._uploadCompressedDataToTextureDirectly(texture, internalCompressedFormat, width, height, byteArray, face, i);
  96737. }
  96738. }
  96739. dataOffset += bpp ? (width * height * (bpp / 8)) : dataLength;
  96740. width *= 0.5;
  96741. height *= 0.5;
  96742. width = Math.max(1.0, width);
  96743. height = Math.max(1.0, height);
  96744. }
  96745. if (currentFace !== undefined) {
  96746. // Loading a single face
  96747. break;
  96748. }
  96749. }
  96750. if (sphericalPolynomialFaces && sphericalPolynomialFaces.length > 0) {
  96751. info.sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial({
  96752. size: header[off_width],
  96753. right: sphericalPolynomialFaces[0],
  96754. left: sphericalPolynomialFaces[1],
  96755. up: sphericalPolynomialFaces[2],
  96756. down: sphericalPolynomialFaces[3],
  96757. front: sphericalPolynomialFaces[4],
  96758. back: sphericalPolynomialFaces[5],
  96759. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA,
  96760. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT,
  96761. gammaSpace: false,
  96762. });
  96763. }
  96764. else {
  96765. info.sphericalPolynomial = undefined;
  96766. }
  96767. };
  96768. /**
  96769. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  96770. */
  96771. DDSTools.StoreLODInAlphaChannel = false;
  96772. return DDSTools;
  96773. }());
  96774. /**
  96775. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  96776. * @param rootUrl defines the url where the file to load is located
  96777. * @param scene defines the current scene
  96778. * @param lodScale defines scale to apply to the mip map selection
  96779. * @param lodOffset defines offset to apply to the mip map selection
  96780. * @param onLoad defines an optional callback raised when the texture is loaded
  96781. * @param onError defines an optional callback raised if there is an issue to load the texture
  96782. * @param format defines the format of the data
  96783. * @param forcedExtension defines the extension to use to pick the right loader
  96784. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  96785. * @returns the cube texture as an InternalTexture
  96786. */
  96787. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createPrefilteredCubeTexture = function (rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, createPolynomials) {
  96788. var _this = this;
  96789. if (onLoad === void 0) { onLoad = null; }
  96790. if (onError === void 0) { onError = null; }
  96791. if (forcedExtension === void 0) { forcedExtension = null; }
  96792. if (createPolynomials === void 0) { createPolynomials = true; }
  96793. var callback = function (loadData) {
  96794. if (!loadData) {
  96795. if (onLoad) {
  96796. onLoad(null);
  96797. }
  96798. return;
  96799. }
  96800. var texture = loadData.texture;
  96801. if (!createPolynomials) {
  96802. texture._sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__["SphericalPolynomial"]();
  96803. }
  96804. else if (loadData.info.sphericalPolynomial) {
  96805. texture._sphericalPolynomial = loadData.info.sphericalPolynomial;
  96806. }
  96807. texture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBEPREFILTERED;
  96808. if (_this.getCaps().textureLOD) {
  96809. // Do not add extra process if texture lod is supported.
  96810. if (onLoad) {
  96811. onLoad(texture);
  96812. }
  96813. return;
  96814. }
  96815. var mipSlices = 3;
  96816. var gl = _this._gl;
  96817. var width = loadData.width;
  96818. if (!width) {
  96819. return;
  96820. }
  96821. var textures = [];
  96822. for (var i = 0; i < mipSlices; i++) {
  96823. //compute LOD from even spacing in smoothness (matching shader calculation)
  96824. var smoothness = i / (mipSlices - 1);
  96825. var roughness = 1 - smoothness;
  96826. var minLODIndex = lodOffset; // roughness = 0
  96827. var maxLODIndex = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) * lodScale + lodOffset; // roughness = 1
  96828. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  96829. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  96830. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  96831. glTextureFromLod.type = texture.type;
  96832. glTextureFromLod.format = texture.format;
  96833. glTextureFromLod.width = Math.pow(2, Math.max(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) - mipmapIndex, 0));
  96834. glTextureFromLod.height = glTextureFromLod.width;
  96835. glTextureFromLod.isCube = true;
  96836. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, glTextureFromLod, true);
  96837. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  96838. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  96839. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  96840. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  96841. if (loadData.isDDS) {
  96842. var info = loadData.info;
  96843. var data = loadData.data;
  96844. _this._unpackFlipY(info.isCompressed);
  96845. DDSTools.UploadDDSLevels(_this, glTextureFromLod, data, info, true, 6, mipmapIndex);
  96846. }
  96847. else {
  96848. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Warn("DDS is the only prefiltered cube map supported so far.");
  96849. }
  96850. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  96851. // Wrap in a base texture for easy binding.
  96852. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__["BaseTexture"](scene);
  96853. lodTexture.isCube = true;
  96854. lodTexture._texture = glTextureFromLod;
  96855. glTextureFromLod.isReady = true;
  96856. textures.push(lodTexture);
  96857. }
  96858. texture._lodTextureHigh = textures[2];
  96859. texture._lodTextureMid = textures[1];
  96860. texture._lodTextureLow = textures[0];
  96861. if (onLoad) {
  96862. onLoad(texture);
  96863. }
  96864. };
  96865. return this.createCubeTexture(rootUrl, scene, null, false, callback, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset);
  96866. };
  96867. /***/ }),
  96868. /***/ "./Misc/decorators.ts":
  96869. /*!****************************!*\
  96870. !*** ./Misc/decorators.ts ***!
  96871. \****************************/
  96872. /*! exports provided: expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsMatrix, serializeAsCameraReference, SerializationHelper */
  96873. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96874. "use strict";
  96875. __webpack_require__.r(__webpack_exports__);
  96876. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return expandToProperty; });
  96877. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return serialize; });
  96878. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return serializeAsTexture; });
  96879. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return serializeAsColor3; });
  96880. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return serializeAsFresnelParameters; });
  96881. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return serializeAsVector2; });
  96882. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return serializeAsVector3; });
  96883. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return serializeAsMeshReference; });
  96884. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return serializeAsColorCurves; });
  96885. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return serializeAsColor4; });
  96886. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return serializeAsImageProcessingConfiguration; });
  96887. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return serializeAsQuaternion; });
  96888. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return serializeAsMatrix; });
  96889. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return serializeAsCameraReference; });
  96890. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return SerializationHelper; });
  96891. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  96892. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  96893. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  96894. var __decoratorInitialStore = {};
  96895. var __mergedStore = {};
  96896. var _copySource = function (creationFunction, source, instanciate) {
  96897. var destination = creationFunction();
  96898. // Tags
  96899. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  96900. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  96901. }
  96902. var classStore = getMergedStore(destination);
  96903. // Properties
  96904. for (var property in classStore) {
  96905. var propertyDescriptor = classStore[property];
  96906. var sourceProperty = source[property];
  96907. var propertyType = propertyDescriptor.type;
  96908. if (sourceProperty !== undefined && sourceProperty !== null && property !== "uniqueId") {
  96909. switch (propertyType) {
  96910. case 0: // Value
  96911. case 6: // Mesh reference
  96912. case 11: // Camera reference
  96913. destination[property] = sourceProperty;
  96914. break;
  96915. case 1: // Texture
  96916. destination[property] = (instanciate || sourceProperty.isRenderTarget) ? sourceProperty : sourceProperty.clone();
  96917. break;
  96918. case 2: // Color3
  96919. case 3: // FresnelParameters
  96920. case 4: // Vector2
  96921. case 5: // Vector3
  96922. case 7: // Color Curves
  96923. case 10: // Quaternion
  96924. case 12: // Matrix
  96925. destination[property] = instanciate ? sourceProperty : sourceProperty.clone();
  96926. break;
  96927. }
  96928. }
  96929. }
  96930. return destination;
  96931. };
  96932. function getDirectStore(target) {
  96933. var classKey = target.getClassName();
  96934. if (!__decoratorInitialStore[classKey]) {
  96935. __decoratorInitialStore[classKey] = {};
  96936. }
  96937. return __decoratorInitialStore[classKey];
  96938. }
  96939. /**
  96940. * Return the list of properties flagged as serializable
  96941. * @param target: host object
  96942. */
  96943. function getMergedStore(target) {
  96944. var classKey = target.getClassName();
  96945. if (__mergedStore[classKey]) {
  96946. return __mergedStore[classKey];
  96947. }
  96948. __mergedStore[classKey] = {};
  96949. var store = __mergedStore[classKey];
  96950. var currentTarget = target;
  96951. var currentKey = classKey;
  96952. while (currentKey) {
  96953. var initialStore = __decoratorInitialStore[currentKey];
  96954. for (var property in initialStore) {
  96955. store[property] = initialStore[property];
  96956. }
  96957. var parent_1 = void 0;
  96958. var done = false;
  96959. do {
  96960. parent_1 = Object.getPrototypeOf(currentTarget);
  96961. if (!parent_1.getClassName) {
  96962. done = true;
  96963. break;
  96964. }
  96965. if (parent_1.getClassName() !== currentKey) {
  96966. break;
  96967. }
  96968. currentTarget = parent_1;
  96969. } while (parent_1);
  96970. if (done) {
  96971. break;
  96972. }
  96973. currentKey = parent_1.getClassName();
  96974. currentTarget = parent_1;
  96975. }
  96976. return store;
  96977. }
  96978. function generateSerializableMember(type, sourceName) {
  96979. return function (target, propertyKey) {
  96980. var classStore = getDirectStore(target);
  96981. if (!classStore[propertyKey]) {
  96982. classStore[propertyKey] = { type: type, sourceName: sourceName };
  96983. }
  96984. };
  96985. }
  96986. function generateExpandMember(setCallback, targetKey) {
  96987. if (targetKey === void 0) { targetKey = null; }
  96988. return function (target, propertyKey) {
  96989. var key = targetKey || ("_" + propertyKey);
  96990. Object.defineProperty(target, propertyKey, {
  96991. get: function () {
  96992. return this[key];
  96993. },
  96994. set: function (value) {
  96995. if (this[key] === value) {
  96996. return;
  96997. }
  96998. this[key] = value;
  96999. target[setCallback].apply(this);
  97000. },
  97001. enumerable: true,
  97002. configurable: true
  97003. });
  97004. };
  97005. }
  97006. function expandToProperty(callback, targetKey) {
  97007. if (targetKey === void 0) { targetKey = null; }
  97008. return generateExpandMember(callback, targetKey);
  97009. }
  97010. function serialize(sourceName) {
  97011. return generateSerializableMember(0, sourceName); // value member
  97012. }
  97013. function serializeAsTexture(sourceName) {
  97014. return generateSerializableMember(1, sourceName); // texture member
  97015. }
  97016. function serializeAsColor3(sourceName) {
  97017. return generateSerializableMember(2, sourceName); // color3 member
  97018. }
  97019. function serializeAsFresnelParameters(sourceName) {
  97020. return generateSerializableMember(3, sourceName); // fresnel parameters member
  97021. }
  97022. function serializeAsVector2(sourceName) {
  97023. return generateSerializableMember(4, sourceName); // vector2 member
  97024. }
  97025. function serializeAsVector3(sourceName) {
  97026. return generateSerializableMember(5, sourceName); // vector3 member
  97027. }
  97028. function serializeAsMeshReference(sourceName) {
  97029. return generateSerializableMember(6, sourceName); // mesh reference member
  97030. }
  97031. function serializeAsColorCurves(sourceName) {
  97032. return generateSerializableMember(7, sourceName); // color curves
  97033. }
  97034. function serializeAsColor4(sourceName) {
  97035. return generateSerializableMember(8, sourceName); // color 4
  97036. }
  97037. function serializeAsImageProcessingConfiguration(sourceName) {
  97038. return generateSerializableMember(9, sourceName); // image processing
  97039. }
  97040. function serializeAsQuaternion(sourceName) {
  97041. return generateSerializableMember(10, sourceName); // quaternion member
  97042. }
  97043. function serializeAsMatrix(sourceName) {
  97044. return generateSerializableMember(12, sourceName); // matrix member
  97045. }
  97046. /**
  97047. * Decorator used to define property that can be serialized as reference to a camera
  97048. * @param sourceName defines the name of the property to decorate
  97049. */
  97050. function serializeAsCameraReference(sourceName) {
  97051. return generateSerializableMember(11, sourceName); // camera reference member
  97052. }
  97053. /**
  97054. * Class used to help serialization objects
  97055. */
  97056. var SerializationHelper = /** @class */ (function () {
  97057. function SerializationHelper() {
  97058. }
  97059. /**
  97060. * Appends the serialized animations from the source animations
  97061. * @param source Source containing the animations
  97062. * @param destination Target to store the animations
  97063. */
  97064. SerializationHelper.AppendSerializedAnimations = function (source, destination) {
  97065. if (source.animations) {
  97066. destination.animations = [];
  97067. for (var animationIndex = 0; animationIndex < source.animations.length; animationIndex++) {
  97068. var animation = source.animations[animationIndex];
  97069. destination.animations.push(animation.serialize());
  97070. }
  97071. }
  97072. };
  97073. /**
  97074. * Static function used to serialized a specific entity
  97075. * @param entity defines the entity to serialize
  97076. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  97077. * @returns a JSON compatible object representing the serialization of the entity
  97078. */
  97079. SerializationHelper.Serialize = function (entity, serializationObject) {
  97080. if (!serializationObject) {
  97081. serializationObject = {};
  97082. }
  97083. // Tags
  97084. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  97085. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].GetTags(entity);
  97086. }
  97087. var serializedProperties = getMergedStore(entity);
  97088. // Properties
  97089. for (var property in serializedProperties) {
  97090. var propertyDescriptor = serializedProperties[property];
  97091. var targetPropertyName = propertyDescriptor.sourceName || property;
  97092. var propertyType = propertyDescriptor.type;
  97093. var sourceProperty = entity[property];
  97094. if (sourceProperty !== undefined && sourceProperty !== null) {
  97095. switch (propertyType) {
  97096. case 0: // Value
  97097. serializationObject[targetPropertyName] = sourceProperty;
  97098. break;
  97099. case 1: // Texture
  97100. serializationObject[targetPropertyName] = sourceProperty.serialize();
  97101. break;
  97102. case 2: // Color3
  97103. serializationObject[targetPropertyName] = sourceProperty.asArray();
  97104. break;
  97105. case 3: // FresnelParameters
  97106. serializationObject[targetPropertyName] = sourceProperty.serialize();
  97107. break;
  97108. case 4: // Vector2
  97109. serializationObject[targetPropertyName] = sourceProperty.asArray();
  97110. break;
  97111. case 5: // Vector3
  97112. serializationObject[targetPropertyName] = sourceProperty.asArray();
  97113. break;
  97114. case 6: // Mesh reference
  97115. serializationObject[targetPropertyName] = sourceProperty.id;
  97116. break;
  97117. case 7: // Color Curves
  97118. serializationObject[targetPropertyName] = sourceProperty.serialize();
  97119. break;
  97120. case 8: // Color 4
  97121. serializationObject[targetPropertyName] = sourceProperty.asArray();
  97122. break;
  97123. case 9: // Image Processing
  97124. serializationObject[targetPropertyName] = sourceProperty.serialize();
  97125. break;
  97126. case 10: // Quaternion
  97127. serializationObject[targetPropertyName] = sourceProperty.asArray();
  97128. break;
  97129. case 11: // Camera reference
  97130. serializationObject[targetPropertyName] = sourceProperty.id;
  97131. case 12: // Matrix
  97132. serializationObject[targetPropertyName] = sourceProperty.asArray();
  97133. break;
  97134. }
  97135. }
  97136. }
  97137. return serializationObject;
  97138. };
  97139. /**
  97140. * Creates a new entity from a serialization data object
  97141. * @param creationFunction defines a function used to instanciated the new entity
  97142. * @param source defines the source serialization data
  97143. * @param scene defines the hosting scene
  97144. * @param rootUrl defines the root url for resources
  97145. * @returns a new entity
  97146. */
  97147. SerializationHelper.Parse = function (creationFunction, source, scene, rootUrl) {
  97148. if (rootUrl === void 0) { rootUrl = null; }
  97149. var destination = creationFunction();
  97150. if (!rootUrl) {
  97151. rootUrl = "";
  97152. }
  97153. // Tags
  97154. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  97155. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  97156. }
  97157. var classStore = getMergedStore(destination);
  97158. // Properties
  97159. for (var property in classStore) {
  97160. var propertyDescriptor = classStore[property];
  97161. var sourceProperty = source[propertyDescriptor.sourceName || property];
  97162. var propertyType = propertyDescriptor.type;
  97163. if (sourceProperty !== undefined && sourceProperty !== null) {
  97164. var dest = destination;
  97165. switch (propertyType) {
  97166. case 0: // Value
  97167. dest[property] = sourceProperty;
  97168. break;
  97169. case 1: // Texture
  97170. if (scene) {
  97171. dest[property] = SerializationHelper._TextureParser(sourceProperty, scene, rootUrl);
  97172. }
  97173. break;
  97174. case 2: // Color3
  97175. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(sourceProperty);
  97176. break;
  97177. case 3: // FresnelParameters
  97178. dest[property] = SerializationHelper._FresnelParametersParser(sourceProperty);
  97179. break;
  97180. case 4: // Vector2
  97181. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"].FromArray(sourceProperty);
  97182. break;
  97183. case 5: // Vector3
  97184. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(sourceProperty);
  97185. break;
  97186. case 6: // Mesh reference
  97187. if (scene) {
  97188. dest[property] = scene.getLastMeshByID(sourceProperty);
  97189. }
  97190. break;
  97191. case 7: // Color Curves
  97192. dest[property] = SerializationHelper._ColorCurvesParser(sourceProperty);
  97193. break;
  97194. case 8: // Color 4
  97195. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(sourceProperty);
  97196. break;
  97197. case 9: // Image Processing
  97198. dest[property] = SerializationHelper._ImageProcessingConfigurationParser(sourceProperty);
  97199. break;
  97200. case 10: // Quaternion
  97201. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromArray(sourceProperty);
  97202. break;
  97203. case 11: // Camera reference
  97204. if (scene) {
  97205. dest[property] = scene.getCameraByID(sourceProperty);
  97206. }
  97207. case 12: // Matrix
  97208. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromArray(sourceProperty);
  97209. break;
  97210. }
  97211. }
  97212. }
  97213. return destination;
  97214. };
  97215. /**
  97216. * Clones an object
  97217. * @param creationFunction defines the function used to instanciate the new object
  97218. * @param source defines the source object
  97219. * @returns the cloned object
  97220. */
  97221. SerializationHelper.Clone = function (creationFunction, source) {
  97222. return _copySource(creationFunction, source, false);
  97223. };
  97224. /**
  97225. * Instanciates a new object based on a source one (some data will be shared between both object)
  97226. * @param creationFunction defines the function used to instanciate the new object
  97227. * @param source defines the source object
  97228. * @returns the new object
  97229. */
  97230. SerializationHelper.Instanciate = function (creationFunction, source) {
  97231. return _copySource(creationFunction, source, true);
  97232. };
  97233. /** hidden */
  97234. SerializationHelper._ImageProcessingConfigurationParser = function (sourceProperty) {
  97235. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ImageProcessingConfiguration");
  97236. };
  97237. /** hidden */
  97238. SerializationHelper._FresnelParametersParser = function (sourceProperty) {
  97239. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("FresnelParameters");
  97240. };
  97241. /** hidden */
  97242. SerializationHelper._ColorCurvesParser = function (sourceProperty) {
  97243. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ColorCurves");
  97244. };
  97245. /** hidden */
  97246. SerializationHelper._TextureParser = function (sourceProperty, scene, rootUrl) {
  97247. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("Texture");
  97248. };
  97249. return SerializationHelper;
  97250. }());
  97251. /***/ }),
  97252. /***/ "./Misc/deepCopier.ts":
  97253. /*!****************************!*\
  97254. !*** ./Misc/deepCopier.ts ***!
  97255. \****************************/
  97256. /*! exports provided: DeepCopier */
  97257. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97258. "use strict";
  97259. __webpack_require__.r(__webpack_exports__);
  97260. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return DeepCopier; });
  97261. var cloneValue = function (source, destinationObject) {
  97262. if (!source) {
  97263. return null;
  97264. }
  97265. if (source.getClassName && source.getClassName() === "Mesh") {
  97266. return null;
  97267. }
  97268. if (source.getClassName && source.getClassName() === "SubMesh") {
  97269. return source.clone(destinationObject);
  97270. }
  97271. else if (source.clone) {
  97272. return source.clone();
  97273. }
  97274. return null;
  97275. };
  97276. /**
  97277. * Class containing a set of static utilities functions for deep copy.
  97278. */
  97279. var DeepCopier = /** @class */ (function () {
  97280. function DeepCopier() {
  97281. }
  97282. /**
  97283. * Tries to copy an object by duplicating every property
  97284. * @param source defines the source object
  97285. * @param destination defines the target object
  97286. * @param doNotCopyList defines a list of properties to avoid
  97287. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  97288. */
  97289. DeepCopier.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  97290. for (var prop in source) {
  97291. if (prop[0] === "_" && (!mustCopyList || mustCopyList.indexOf(prop) === -1)) {
  97292. continue;
  97293. }
  97294. if (doNotCopyList && doNotCopyList.indexOf(prop) !== -1) {
  97295. continue;
  97296. }
  97297. var sourceValue = source[prop];
  97298. var typeOfSourceValue = typeof sourceValue;
  97299. if (typeOfSourceValue === "function") {
  97300. continue;
  97301. }
  97302. try {
  97303. if (typeOfSourceValue === "object") {
  97304. if (sourceValue instanceof Array) {
  97305. destination[prop] = [];
  97306. if (sourceValue.length > 0) {
  97307. if (typeof sourceValue[0] == "object") {
  97308. for (var index = 0; index < sourceValue.length; index++) {
  97309. var clonedValue = cloneValue(sourceValue[index], destination);
  97310. if (destination[prop].indexOf(clonedValue) === -1) { // Test if auto inject was not done
  97311. destination[prop].push(clonedValue);
  97312. }
  97313. }
  97314. }
  97315. else {
  97316. destination[prop] = sourceValue.slice(0);
  97317. }
  97318. }
  97319. }
  97320. else {
  97321. destination[prop] = cloneValue(sourceValue, destination);
  97322. }
  97323. }
  97324. else {
  97325. destination[prop] = sourceValue;
  97326. }
  97327. }
  97328. catch (e) {
  97329. // Just ignore error (it could be because of a read-only property)
  97330. }
  97331. }
  97332. };
  97333. return DeepCopier;
  97334. }());
  97335. /***/ }),
  97336. /***/ "./Misc/deferred.ts":
  97337. /*!**************************!*\
  97338. !*** ./Misc/deferred.ts ***!
  97339. \**************************/
  97340. /*! exports provided: Deferred */
  97341. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97342. "use strict";
  97343. __webpack_require__.r(__webpack_exports__);
  97344. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return Deferred; });
  97345. /**
  97346. * Wrapper class for promise with external resolve and reject.
  97347. */
  97348. var Deferred = /** @class */ (function () {
  97349. /**
  97350. * Constructor for this deferred object.
  97351. */
  97352. function Deferred() {
  97353. var _this = this;
  97354. this.promise = new Promise(function (resolve, reject) {
  97355. _this._resolve = resolve;
  97356. _this._reject = reject;
  97357. });
  97358. }
  97359. Object.defineProperty(Deferred.prototype, "resolve", {
  97360. /**
  97361. * The resolve method of the promise associated with this deferred object.
  97362. */
  97363. get: function () {
  97364. return this._resolve;
  97365. },
  97366. enumerable: true,
  97367. configurable: true
  97368. });
  97369. Object.defineProperty(Deferred.prototype, "reject", {
  97370. /**
  97371. * The reject method of the promise associated with this deferred object.
  97372. */
  97373. get: function () {
  97374. return this._reject;
  97375. },
  97376. enumerable: true,
  97377. configurable: true
  97378. });
  97379. return Deferred;
  97380. }());
  97381. /***/ }),
  97382. /***/ "./Misc/devTools.ts":
  97383. /*!**************************!*\
  97384. !*** ./Misc/devTools.ts ***!
  97385. \**************************/
  97386. /*! exports provided: _DevTools */
  97387. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97388. "use strict";
  97389. __webpack_require__.r(__webpack_exports__);
  97390. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DevTools", function() { return _DevTools; });
  97391. /** @hidden */
  97392. var _DevTools = /** @class */ (function () {
  97393. function _DevTools() {
  97394. }
  97395. _DevTools.WarnImport = function (name) {
  97396. return name + " needs to be imported before as it contains a side-effect required by your code.";
  97397. };
  97398. return _DevTools;
  97399. }());
  97400. /***/ }),
  97401. /***/ "./Misc/domManagement.ts":
  97402. /*!*******************************!*\
  97403. !*** ./Misc/domManagement.ts ***!
  97404. \*******************************/
  97405. /*! exports provided: DomManagement */
  97406. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97407. "use strict";
  97408. __webpack_require__.r(__webpack_exports__);
  97409. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DomManagement", function() { return DomManagement; });
  97410. /**
  97411. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  97412. * Babylon.js
  97413. */
  97414. var DomManagement = /** @class */ (function () {
  97415. function DomManagement() {
  97416. }
  97417. /**
  97418. * Checks if the window object exists
  97419. * @returns true if the window object exists
  97420. */
  97421. DomManagement.IsWindowObjectExist = function () {
  97422. return (typeof window) !== "undefined";
  97423. };
  97424. /**
  97425. * Extracts text content from a DOM element hierarchy
  97426. * @param element defines the root element
  97427. * @returns a string
  97428. */
  97429. DomManagement.GetDOMTextContent = function (element) {
  97430. var result = "";
  97431. var child = element.firstChild;
  97432. while (child) {
  97433. if (child.nodeType === 3) {
  97434. result += child.textContent;
  97435. }
  97436. child = (child.nextSibling);
  97437. }
  97438. return result;
  97439. };
  97440. return DomManagement;
  97441. }());
  97442. /***/ }),
  97443. /***/ "./Misc/environmentTextureTools.ts":
  97444. /*!*****************************************!*\
  97445. !*** ./Misc/environmentTextureTools.ts ***!
  97446. \*****************************************/
  97447. /*! exports provided: EnvironmentTextureTools */
  97448. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97449. "use strict";
  97450. __webpack_require__.r(__webpack_exports__);
  97451. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return EnvironmentTextureTools; });
  97452. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  97453. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  97454. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  97455. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  97456. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  97457. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  97458. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  97459. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  97460. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  97461. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  97462. /* harmony import */ var _Shaders_rgbdEncode_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/rgbdEncode.fragment */ "./Shaders/rgbdEncode.fragment.ts");
  97463. /* harmony import */ var _Shaders_rgbdDecode_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/rgbdDecode.fragment */ "./Shaders/rgbdDecode.fragment.ts");
  97464. /**
  97465. * Sets of helpers addressing the serialization and deserialization of environment texture
  97466. * stored in a BabylonJS env file.
  97467. * Those files are usually stored as .env files.
  97468. */
  97469. var EnvironmentTextureTools = /** @class */ (function () {
  97470. function EnvironmentTextureTools() {
  97471. }
  97472. /**
  97473. * Gets the environment info from an env file.
  97474. * @param data The array buffer containing the .env bytes.
  97475. * @returns the environment file info (the json header) if successfully parsed.
  97476. */
  97477. EnvironmentTextureTools.GetEnvInfo = function (data) {
  97478. var dataView = new DataView(data);
  97479. var pos = 0;
  97480. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  97481. if (dataView.getUint8(pos++) !== EnvironmentTextureTools._MagicBytes[i]) {
  97482. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Error('Not a babylon environment map');
  97483. return null;
  97484. }
  97485. }
  97486. // Read json manifest - collect characters up to null terminator
  97487. var manifestString = '';
  97488. var charCode = 0x00;
  97489. while ((charCode = dataView.getUint8(pos++))) {
  97490. manifestString += String.fromCharCode(charCode);
  97491. }
  97492. var manifest = JSON.parse(manifestString);
  97493. if (manifest.specular) {
  97494. // Extend the header with the position of the payload.
  97495. manifest.specular.specularDataPosition = pos;
  97496. // Fallback to 0.8 exactly if lodGenerationScale is not defined for backward compatibility.
  97497. manifest.specular.lodGenerationScale = manifest.specular.lodGenerationScale || 0.8;
  97498. }
  97499. return manifest;
  97500. };
  97501. /**
  97502. * Creates an environment texture from a loaded cube texture.
  97503. * @param texture defines the cube texture to convert in env file
  97504. * @return a promise containing the environment data if succesfull.
  97505. */
  97506. EnvironmentTextureTools.CreateEnvTextureAsync = function (texture) {
  97507. var _this = this;
  97508. var internalTexture = texture.getInternalTexture();
  97509. if (!internalTexture) {
  97510. return Promise.reject("The cube texture is invalid.");
  97511. }
  97512. if (!texture._prefiltered) {
  97513. return Promise.reject("The cube texture is invalid (not prefiltered).");
  97514. }
  97515. var engine = internalTexture.getEngine();
  97516. if (engine && engine.premultipliedAlpha) {
  97517. return Promise.reject("Env texture can only be created when the engine is created with the premultipliedAlpha option set to false.");
  97518. }
  97519. if (texture.textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  97520. return Promise.reject("The cube texture should allow HDR (Full Float or Half Float).");
  97521. }
  97522. var canvas = engine.getRenderingCanvas();
  97523. if (!canvas) {
  97524. return Promise.reject("Env texture can only be created when the engine is associated to a canvas.");
  97525. }
  97526. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  97527. if (!engine.getCaps().textureFloatRender) {
  97528. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  97529. if (!engine.getCaps().textureHalfFloatRender) {
  97530. return Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.");
  97531. }
  97532. }
  97533. var cubeWidth = internalTexture.width;
  97534. var hostingScene = new _scene__WEBPACK_IMPORTED_MODULE_7__["Scene"](engine);
  97535. var specularTextures = {};
  97536. var promises = [];
  97537. // Read and collect all mipmaps data from the cube.
  97538. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(internalTexture.width);
  97539. mipmapsCount = Math.round(mipmapsCount);
  97540. var _loop_1 = function (i) {
  97541. var faceWidth = Math.pow(2, mipmapsCount - i);
  97542. var _loop_2 = function (face) {
  97543. var data = texture.readPixels(face, i);
  97544. // Creates a temp texture with the face data.
  97545. 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);
  97546. // And rgbdEncode them.
  97547. var promise = new Promise(function (resolve, reject) {
  97548. 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);
  97549. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  97550. rgbdPostProcess.onApply = function (effect) {
  97551. effect._bindTexture("textureSampler", tempTexture);
  97552. };
  97553. // As the process needs to happen on the main canvas, keep track of the current size
  97554. var currentW = engine.getRenderWidth();
  97555. var currentH = engine.getRenderHeight();
  97556. // Set the desired size for the texture
  97557. engine.setSize(faceWidth, faceWidth);
  97558. hostingScene.postProcessManager.directRender([rgbdPostProcess], null);
  97559. // Reading datas from WebGL
  97560. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ToBlob(canvas, function (blob) {
  97561. var fileReader = new FileReader();
  97562. fileReader.onload = function (event) {
  97563. var arrayBuffer = event.target.result;
  97564. specularTextures[i * 6 + face] = arrayBuffer;
  97565. resolve();
  97566. };
  97567. fileReader.readAsArrayBuffer(blob);
  97568. });
  97569. // Reapply the previous canvas size
  97570. engine.setSize(currentW, currentH);
  97571. });
  97572. });
  97573. promises.push(promise);
  97574. };
  97575. // All faces of the cube.
  97576. for (var face = 0; face < 6; face++) {
  97577. _loop_2(face);
  97578. }
  97579. };
  97580. for (var i = 0; i <= mipmapsCount; i++) {
  97581. _loop_1(i);
  97582. }
  97583. // Once all the textures haves been collected as RGBD stored in PNGs
  97584. return Promise.all(promises).then(function () {
  97585. // We can delete the hosting scene keeping track of all the creation objects
  97586. hostingScene.dispose();
  97587. // Creates the json header for the env texture
  97588. var info = {
  97589. version: 1,
  97590. width: cubeWidth,
  97591. irradiance: _this._CreateEnvTextureIrradiance(texture),
  97592. specular: {
  97593. mipmaps: [],
  97594. lodGenerationScale: texture.lodGenerationScale
  97595. }
  97596. };
  97597. // Sets the specular image data information
  97598. var position = 0;
  97599. for (var i = 0; i <= mipmapsCount; i++) {
  97600. for (var face = 0; face < 6; face++) {
  97601. var byteLength = specularTextures[i * 6 + face].byteLength;
  97602. info.specular.mipmaps.push({
  97603. length: byteLength,
  97604. position: position
  97605. });
  97606. position += byteLength;
  97607. }
  97608. }
  97609. // Encode the JSON as an array buffer
  97610. var infoString = JSON.stringify(info);
  97611. var infoBuffer = new ArrayBuffer(infoString.length + 1);
  97612. var infoView = new Uint8Array(infoBuffer); // Limited to ascii subset matching unicode.
  97613. for (var i = 0, strLen = infoString.length; i < strLen; i++) {
  97614. infoView[i] = infoString.charCodeAt(i);
  97615. }
  97616. // Ends up with a null terminator for easier parsing
  97617. infoView[infoString.length] = 0x00;
  97618. // Computes the final required size and creates the storage
  97619. var totalSize = EnvironmentTextureTools._MagicBytes.length + position + infoBuffer.byteLength;
  97620. var finalBuffer = new ArrayBuffer(totalSize);
  97621. var finalBufferView = new Uint8Array(finalBuffer);
  97622. var dataView = new DataView(finalBuffer);
  97623. // Copy the magic bytes identifying the file in
  97624. var pos = 0;
  97625. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  97626. dataView.setUint8(pos++, EnvironmentTextureTools._MagicBytes[i]);
  97627. }
  97628. // Add the json info
  97629. finalBufferView.set(new Uint8Array(infoBuffer), pos);
  97630. pos += infoBuffer.byteLength;
  97631. // Finally inserts the texture data
  97632. for (var i = 0; i <= mipmapsCount; i++) {
  97633. for (var face = 0; face < 6; face++) {
  97634. var dataBuffer = specularTextures[i * 6 + face];
  97635. finalBufferView.set(new Uint8Array(dataBuffer), pos);
  97636. pos += dataBuffer.byteLength;
  97637. }
  97638. }
  97639. // Voila
  97640. return finalBuffer;
  97641. });
  97642. };
  97643. /**
  97644. * Creates a JSON representation of the spherical data.
  97645. * @param texture defines the texture containing the polynomials
  97646. * @return the JSON representation of the spherical info
  97647. */
  97648. EnvironmentTextureTools._CreateEnvTextureIrradiance = function (texture) {
  97649. var polynmials = texture.sphericalPolynomial;
  97650. if (polynmials == null) {
  97651. return null;
  97652. }
  97653. return {
  97654. x: [polynmials.x.x, polynmials.x.y, polynmials.x.z],
  97655. y: [polynmials.y.x, polynmials.y.y, polynmials.y.z],
  97656. z: [polynmials.z.x, polynmials.z.y, polynmials.z.z],
  97657. xx: [polynmials.xx.x, polynmials.xx.y, polynmials.xx.z],
  97658. yy: [polynmials.yy.x, polynmials.yy.y, polynmials.yy.z],
  97659. zz: [polynmials.zz.x, polynmials.zz.y, polynmials.zz.z],
  97660. yz: [polynmials.yz.x, polynmials.yz.y, polynmials.yz.z],
  97661. zx: [polynmials.zx.x, polynmials.zx.y, polynmials.zx.z],
  97662. xy: [polynmials.xy.x, polynmials.xy.y, polynmials.xy.z]
  97663. };
  97664. };
  97665. /**
  97666. * Uploads the texture info contained in the env file to the GPU.
  97667. * @param texture defines the internal texture to upload to
  97668. * @param arrayBuffer defines the buffer cotaining the data to load
  97669. * @param info defines the texture info retrieved through the GetEnvInfo method
  97670. * @returns a promise
  97671. */
  97672. EnvironmentTextureTools.UploadEnvLevelsAsync = function (texture, arrayBuffer, info) {
  97673. if (info.version !== 1) {
  97674. throw new Error("Unsupported babylon environment map version \"" + info.version + "\"");
  97675. }
  97676. var specularInfo = info.specular;
  97677. if (!specularInfo) {
  97678. // Nothing else parsed so far
  97679. return Promise.resolve();
  97680. }
  97681. // Double checks the enclosed info
  97682. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(info.width);
  97683. mipmapsCount = Math.round(mipmapsCount) + 1;
  97684. if (specularInfo.mipmaps.length !== 6 * mipmapsCount) {
  97685. throw new Error("Unsupported specular mipmaps number \"" + specularInfo.mipmaps.length + "\"");
  97686. }
  97687. texture._lodGenerationScale = specularInfo.lodGenerationScale;
  97688. var imageData = new Array(mipmapsCount);
  97689. for (var i = 0; i < mipmapsCount; i++) {
  97690. imageData[i] = new Array(6);
  97691. for (var face = 0; face < 6; face++) {
  97692. var imageInfo = specularInfo.mipmaps[i * 6 + face];
  97693. imageData[i][face] = new Uint8Array(arrayBuffer, specularInfo.specularDataPosition + imageInfo.position, imageInfo.length);
  97694. }
  97695. }
  97696. return EnvironmentTextureTools.UploadLevelsAsync(texture, imageData);
  97697. };
  97698. /**
  97699. * Uploads the levels of image data to the GPU.
  97700. * @param texture defines the internal texture to upload to
  97701. * @param imageData defines the array buffer views of image data [mipmap][face]
  97702. * @returns a promise
  97703. */
  97704. EnvironmentTextureTools.UploadLevelsAsync = function (texture, imageData) {
  97705. if (!_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsExponentOfTwo(texture.width)) {
  97706. throw new Error("Texture size must be a power of two");
  97707. }
  97708. var mipmapsCount = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(texture.width)) + 1;
  97709. // Gets everything ready.
  97710. var engine = texture.getEngine();
  97711. var expandTexture = false;
  97712. var generateNonLODTextures = false;
  97713. var rgbdPostProcess = null;
  97714. var cubeRtt = null;
  97715. var lodTextures = null;
  97716. var caps = engine.getCaps();
  97717. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA;
  97718. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  97719. texture.generateMipMaps = true;
  97720. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE, texture);
  97721. // Add extra process if texture lod is not supported
  97722. if (!caps.textureLOD) {
  97723. expandTexture = false;
  97724. generateNonLODTextures = true;
  97725. lodTextures = {};
  97726. }
  97727. // in webgl 1 there are no ways to either render or copy lod level information for float textures.
  97728. else if (engine.webGLVersion < 2) {
  97729. expandTexture = false;
  97730. }
  97731. // If half float available we can uncompress the texture
  97732. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  97733. expandTexture = true;
  97734. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  97735. }
  97736. // If full float available we can uncompress the texture
  97737. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  97738. expandTexture = true;
  97739. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  97740. }
  97741. // Expand the texture if possible
  97742. if (expandTexture) {
  97743. // Simply run through the decode PP
  97744. 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);
  97745. texture._isRGBD = false;
  97746. texture.invertY = false;
  97747. cubeRtt = engine.createRenderTargetCubeTexture(texture.width, {
  97748. generateDepthBuffer: false,
  97749. generateMipMaps: true,
  97750. generateStencilBuffer: false,
  97751. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE,
  97752. type: texture.type,
  97753. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA
  97754. });
  97755. }
  97756. else {
  97757. texture._isRGBD = true;
  97758. texture.invertY = true;
  97759. // In case of missing support, applies the same patch than DDS files.
  97760. if (generateNonLODTextures) {
  97761. var mipSlices = 3;
  97762. var scale = texture._lodGenerationScale;
  97763. var offset = texture._lodGenerationOffset;
  97764. for (var i = 0; i < mipSlices; i++) {
  97765. //compute LOD from even spacing in smoothness (matching shader calculation)
  97766. var smoothness = i / (mipSlices - 1);
  97767. var roughness = 1 - smoothness;
  97768. var minLODIndex = offset; // roughness = 0
  97769. var maxLODIndex = (mipmapsCount - 1) * scale + offset; // roughness = 1 (mipmaps start from 0)
  97770. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  97771. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  97772. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](engine, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  97773. glTextureFromLod.isCube = true;
  97774. glTextureFromLod.invertY = true;
  97775. glTextureFromLod.generateMipMaps = false;
  97776. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR, glTextureFromLod);
  97777. // Wrap in a base texture for easy binding.
  97778. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"](null);
  97779. lodTexture.isCube = true;
  97780. lodTexture._texture = glTextureFromLod;
  97781. lodTextures[mipmapIndex] = lodTexture;
  97782. switch (i) {
  97783. case 0:
  97784. texture._lodTextureLow = lodTexture;
  97785. break;
  97786. case 1:
  97787. texture._lodTextureMid = lodTexture;
  97788. break;
  97789. case 2:
  97790. texture._lodTextureHigh = lodTexture;
  97791. break;
  97792. }
  97793. }
  97794. }
  97795. }
  97796. var promises = [];
  97797. var _loop_3 = function (i) {
  97798. var _loop_4 = function (face) {
  97799. // Constructs an image element from image data
  97800. var bytes = imageData[i][face];
  97801. var blob = new Blob([bytes], { type: 'image/png' });
  97802. var url = URL.createObjectURL(blob);
  97803. var image = new Image();
  97804. image.src = url;
  97805. // Enqueue promise to upload to the texture.
  97806. var promise = new Promise(function (resolve, reject) {
  97807. image.onload = function () {
  97808. if (expandTexture) {
  97809. var tempTexture_1 = engine.createTexture(null, true, true, null, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, null, function (message) {
  97810. reject(message);
  97811. }, image);
  97812. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  97813. // Uncompress the data to a RTT
  97814. rgbdPostProcess.onApply = function (effect) {
  97815. effect._bindTexture("textureSampler", tempTexture_1);
  97816. effect.setFloat2("scale", 1, 1);
  97817. };
  97818. engine.scenes[0].postProcessManager.directRender([rgbdPostProcess], cubeRtt, true, face, i);
  97819. // Cleanup
  97820. engine.restoreDefaultFramebuffer();
  97821. tempTexture_1.dispose();
  97822. window.URL.revokeObjectURL(url);
  97823. resolve();
  97824. });
  97825. }
  97826. else {
  97827. engine._uploadImageToTexture(texture, image, face, i);
  97828. // Upload the face to the non lod texture support
  97829. if (generateNonLODTextures) {
  97830. var lodTexture = lodTextures[i];
  97831. if (lodTexture) {
  97832. engine._uploadImageToTexture(lodTexture._texture, image, face, 0);
  97833. }
  97834. }
  97835. resolve();
  97836. }
  97837. };
  97838. image.onerror = function (error) {
  97839. reject(error);
  97840. };
  97841. });
  97842. promises.push(promise);
  97843. };
  97844. // All faces
  97845. for (var face = 0; face < 6; face++) {
  97846. _loop_4(face);
  97847. }
  97848. };
  97849. // All mipmaps up to provided number of images
  97850. for (var i = 0; i < imageData.length; i++) {
  97851. _loop_3(i);
  97852. }
  97853. // Fill remaining mipmaps with black textures.
  97854. if (imageData.length < mipmapsCount) {
  97855. var data = void 0;
  97856. var size = Math.pow(2, mipmapsCount - 1 - imageData.length);
  97857. var dataLength = size * size * 4;
  97858. switch (texture.type) {
  97859. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT: {
  97860. data = new Uint8Array(dataLength);
  97861. break;
  97862. }
  97863. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT: {
  97864. data = new Uint16Array(dataLength);
  97865. break;
  97866. }
  97867. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT: {
  97868. data = new Float32Array(dataLength);
  97869. break;
  97870. }
  97871. }
  97872. for (var i = imageData.length; i < mipmapsCount; i++) {
  97873. for (var face = 0; face < 6; face++) {
  97874. engine._uploadArrayBufferViewToTexture(texture, data, face, i);
  97875. }
  97876. }
  97877. }
  97878. // Once all done, finishes the cleanup and return
  97879. return Promise.all(promises).then(function () {
  97880. // Release temp RTT.
  97881. if (cubeRtt) {
  97882. engine._releaseFramebufferObjects(cubeRtt);
  97883. cubeRtt._swapAndDie(texture);
  97884. }
  97885. // Release temp Post Process.
  97886. if (rgbdPostProcess) {
  97887. rgbdPostProcess.dispose();
  97888. }
  97889. // Flag internal texture as ready in case they are in use.
  97890. if (generateNonLODTextures) {
  97891. if (texture._lodTextureHigh && texture._lodTextureHigh._texture) {
  97892. texture._lodTextureHigh._texture.isReady = true;
  97893. }
  97894. if (texture._lodTextureMid && texture._lodTextureMid._texture) {
  97895. texture._lodTextureMid._texture.isReady = true;
  97896. }
  97897. if (texture._lodTextureLow && texture._lodTextureLow._texture) {
  97898. texture._lodTextureLow._texture.isReady = true;
  97899. }
  97900. }
  97901. });
  97902. };
  97903. /**
  97904. * Uploads spherical polynomials information to the texture.
  97905. * @param texture defines the texture we are trying to upload the information to
  97906. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  97907. */
  97908. EnvironmentTextureTools.UploadEnvSpherical = function (texture, info) {
  97909. if (info.version !== 1) {
  97910. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn('Unsupported babylon environment map version "' + info.version + '"');
  97911. }
  97912. var irradianceInfo = info.irradiance;
  97913. if (!irradianceInfo) {
  97914. return;
  97915. }
  97916. var sp = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__["SphericalPolynomial"]();
  97917. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.x, 0, sp.x);
  97918. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.y, 0, sp.y);
  97919. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.z, 0, sp.z);
  97920. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xx, 0, sp.xx);
  97921. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yy, 0, sp.yy);
  97922. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zz, 0, sp.zz);
  97923. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yz, 0, sp.yz);
  97924. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zx, 0, sp.zx);
  97925. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xy, 0, sp.xy);
  97926. texture._sphericalPolynomial = sp;
  97927. };
  97928. /** @hidden */
  97929. EnvironmentTextureTools._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  97930. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  97931. internalTexture._bufferViewArrayArray = data;
  97932. internalTexture._lodGenerationScale = lodScale;
  97933. internalTexture._lodGenerationOffset = lodOffset;
  97934. internalTexture._sphericalPolynomial = sphericalPolynomial;
  97935. return EnvironmentTextureTools.UploadLevelsAsync(internalTexture, data).then(function () {
  97936. internalTexture.isReady = true;
  97937. });
  97938. };
  97939. /**
  97940. * Magic number identifying the env file.
  97941. */
  97942. EnvironmentTextureTools._MagicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];
  97943. return EnvironmentTextureTools;
  97944. }());
  97945. // References the dependencies.
  97946. _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"]._UpdateRGBDAsync = EnvironmentTextureTools._UpdateRGBDAsync;
  97947. /***/ }),
  97948. /***/ "./Misc/filesInput.ts":
  97949. /*!****************************!*\
  97950. !*** ./Misc/filesInput.ts ***!
  97951. \****************************/
  97952. /*! exports provided: FilesInput */
  97953. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97954. "use strict";
  97955. __webpack_require__.r(__webpack_exports__);
  97956. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return FilesInput; });
  97957. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  97958. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  97959. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  97960. /**
  97961. * Class used to help managing file picking and drag'n'drop
  97962. */
  97963. var FilesInput = /** @class */ (function () {
  97964. /**
  97965. * Creates a new FilesInput
  97966. * @param engine defines the rendering engine
  97967. * @param scene defines the hosting scene
  97968. * @param sceneLoadedCallback callback called when scene is loaded
  97969. * @param progressCallback callback called to track progress
  97970. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  97971. * @param textureLoadingCallback callback called when a texture is loading
  97972. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  97973. * @param onReloadCallback callback called when a reload is requested
  97974. * @param errorCallback callback call if an error occurs
  97975. */
  97976. function FilesInput(engine, scene, sceneLoadedCallback, progressCallback, additionalRenderLoopLogicCallback, textureLoadingCallback, startingProcessingFilesCallback, onReloadCallback, errorCallback) {
  97977. /**
  97978. * Callback called when a file is processed
  97979. */
  97980. this.onProcessFileCallback = function () { return true; };
  97981. this._engine = engine;
  97982. this._currentScene = scene;
  97983. this._sceneLoadedCallback = sceneLoadedCallback;
  97984. this._progressCallback = progressCallback;
  97985. this._additionalRenderLoopLogicCallback = additionalRenderLoopLogicCallback;
  97986. this._textureLoadingCallback = textureLoadingCallback;
  97987. this._startingProcessingFilesCallback = startingProcessingFilesCallback;
  97988. this._onReloadCallback = onReloadCallback;
  97989. this._errorCallback = errorCallback;
  97990. }
  97991. Object.defineProperty(FilesInput, "FilesToLoad", {
  97992. /**
  97993. * List of files ready to be loaded
  97994. */
  97995. get: function () {
  97996. return _filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad;
  97997. },
  97998. enumerable: true,
  97999. configurable: true
  98000. });
  98001. /**
  98002. * Calls this function to listen to drag'n'drop events on a specific DOM element
  98003. * @param elementToMonitor defines the DOM element to track
  98004. */
  98005. FilesInput.prototype.monitorElementForDragNDrop = function (elementToMonitor) {
  98006. var _this = this;
  98007. if (elementToMonitor) {
  98008. this._elementToMonitor = elementToMonitor;
  98009. this._dragEnterHandler = function (e) { _this.drag(e); };
  98010. this._dragOverHandler = function (e) { _this.drag(e); };
  98011. this._dropHandler = function (e) { _this.drop(e); };
  98012. this._elementToMonitor.addEventListener("dragenter", this._dragEnterHandler, false);
  98013. this._elementToMonitor.addEventListener("dragover", this._dragOverHandler, false);
  98014. this._elementToMonitor.addEventListener("drop", this._dropHandler, false);
  98015. }
  98016. };
  98017. /**
  98018. * Release all associated resources
  98019. */
  98020. FilesInput.prototype.dispose = function () {
  98021. if (!this._elementToMonitor) {
  98022. return;
  98023. }
  98024. this._elementToMonitor.removeEventListener("dragenter", this._dragEnterHandler);
  98025. this._elementToMonitor.removeEventListener("dragover", this._dragOverHandler);
  98026. this._elementToMonitor.removeEventListener("drop", this._dropHandler);
  98027. };
  98028. FilesInput.prototype.renderFunction = function () {
  98029. if (this._additionalRenderLoopLogicCallback) {
  98030. this._additionalRenderLoopLogicCallback();
  98031. }
  98032. if (this._currentScene) {
  98033. if (this._textureLoadingCallback) {
  98034. var remaining = this._currentScene.getWaitingItemsCount();
  98035. if (remaining > 0) {
  98036. this._textureLoadingCallback(remaining);
  98037. }
  98038. }
  98039. this._currentScene.render();
  98040. }
  98041. };
  98042. FilesInput.prototype.drag = function (e) {
  98043. e.stopPropagation();
  98044. e.preventDefault();
  98045. };
  98046. FilesInput.prototype.drop = function (eventDrop) {
  98047. eventDrop.stopPropagation();
  98048. eventDrop.preventDefault();
  98049. this.loadFiles(eventDrop);
  98050. };
  98051. FilesInput.prototype._traverseFolder = function (folder, files, remaining, callback) {
  98052. var _this = this;
  98053. var reader = folder.createReader();
  98054. var relativePath = folder.fullPath.replace(/^\//, "").replace(/(.+?)\/?$/, "$1/");
  98055. reader.readEntries(function (entries) {
  98056. remaining.count += entries.length;
  98057. for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  98058. var entry = entries_1[_i];
  98059. if (entry.isFile) {
  98060. entry.file(function (file) {
  98061. file.correctName = relativePath + file.name;
  98062. files.push(file);
  98063. if (--remaining.count === 0) {
  98064. callback();
  98065. }
  98066. });
  98067. }
  98068. else if (entry.isDirectory) {
  98069. _this._traverseFolder(entry, files, remaining, callback);
  98070. }
  98071. }
  98072. if (--remaining.count) {
  98073. callback();
  98074. }
  98075. });
  98076. };
  98077. FilesInput.prototype._processFiles = function (files) {
  98078. for (var i = 0; i < files.length; i++) {
  98079. var name = files[i].correctName.toLowerCase();
  98080. var extension = name.split('.').pop();
  98081. if (!this.onProcessFileCallback(files[i], name, extension)) {
  98082. continue;
  98083. }
  98084. if ((extension === "babylon" || extension === "stl" || extension === "obj" || extension === "gltf" || extension === "glb")
  98085. && name.indexOf(".binary.babylon") === -1 && name.indexOf(".incremental.babylon") === -1) {
  98086. this._sceneFileToLoad = files[i];
  98087. }
  98088. FilesInput.FilesToLoad[name] = files[i];
  98089. }
  98090. };
  98091. /**
  98092. * Load files from a drop event
  98093. * @param event defines the drop event to use as source
  98094. */
  98095. FilesInput.prototype.loadFiles = function (event) {
  98096. var _this = this;
  98097. // Handling data transfer via drag'n'drop
  98098. if (event && event.dataTransfer && event.dataTransfer.files) {
  98099. this._filesToLoad = event.dataTransfer.files;
  98100. }
  98101. // Handling files from input files
  98102. if (event && event.target && event.target.files) {
  98103. this._filesToLoad = event.target.files;
  98104. }
  98105. if (!this._filesToLoad || this._filesToLoad.length === 0) {
  98106. return;
  98107. }
  98108. if (this._startingProcessingFilesCallback) {
  98109. this._startingProcessingFilesCallback(this._filesToLoad);
  98110. }
  98111. if (this._filesToLoad && this._filesToLoad.length > 0) {
  98112. var files_1 = new Array();
  98113. var folders = [];
  98114. var items = event.dataTransfer ? event.dataTransfer.items : null;
  98115. for (var i = 0; i < this._filesToLoad.length; i++) {
  98116. var fileToLoad = this._filesToLoad[i];
  98117. var name_1 = fileToLoad.name.toLowerCase();
  98118. var entry = void 0;
  98119. fileToLoad.correctName = name_1;
  98120. if (items) {
  98121. var item = items[i];
  98122. if (item.getAsEntry) {
  98123. entry = item.getAsEntry();
  98124. }
  98125. else if (item.webkitGetAsEntry) {
  98126. entry = item.webkitGetAsEntry();
  98127. }
  98128. }
  98129. if (!entry) {
  98130. files_1.push(fileToLoad);
  98131. }
  98132. else {
  98133. if (entry.isDirectory) {
  98134. folders.push(entry);
  98135. }
  98136. else {
  98137. files_1.push(fileToLoad);
  98138. }
  98139. }
  98140. }
  98141. if (folders.length === 0) {
  98142. this._processFiles(files_1);
  98143. this._processReload();
  98144. }
  98145. else {
  98146. var remaining = { count: folders.length };
  98147. for (var _i = 0, folders_1 = folders; _i < folders_1.length; _i++) {
  98148. var folder = folders_1[_i];
  98149. this._traverseFolder(folder, files_1, remaining, function () {
  98150. _this._processFiles(files_1);
  98151. if (remaining.count === 0) {
  98152. _this._processReload();
  98153. }
  98154. });
  98155. }
  98156. }
  98157. }
  98158. };
  98159. FilesInput.prototype._processReload = function () {
  98160. if (this._onReloadCallback) {
  98161. this._onReloadCallback(this._sceneFileToLoad);
  98162. }
  98163. else {
  98164. this.reload();
  98165. }
  98166. };
  98167. /**
  98168. * Reload the current scene from the loaded files
  98169. */
  98170. FilesInput.prototype.reload = function () {
  98171. var _this = this;
  98172. // If a scene file has been provided
  98173. if (this._sceneFileToLoad) {
  98174. if (this._currentScene) {
  98175. if (_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].errorsCount > 0) {
  98176. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].ClearLogCache();
  98177. }
  98178. this._engine.stopRenderLoop();
  98179. }
  98180. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"].LoadAsync("file:", this._sceneFileToLoad, this._engine, function (progress) {
  98181. if (_this._progressCallback) {
  98182. _this._progressCallback(progress);
  98183. }
  98184. }).then(function (scene) {
  98185. if (_this._currentScene) {
  98186. _this._currentScene.dispose();
  98187. }
  98188. _this._currentScene = scene;
  98189. if (_this._sceneLoadedCallback) {
  98190. _this._sceneLoadedCallback(_this._sceneFileToLoad, _this._currentScene);
  98191. }
  98192. // Wait for textures and shaders to be ready
  98193. _this._currentScene.executeWhenReady(function () {
  98194. _this._engine.runRenderLoop(function () {
  98195. _this.renderFunction();
  98196. });
  98197. });
  98198. }).catch(function (error) {
  98199. if (_this._errorCallback) {
  98200. _this._errorCallback(_this._sceneFileToLoad, _this._currentScene, error.message);
  98201. }
  98202. });
  98203. }
  98204. else {
  98205. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Please provide a valid .babylon file.");
  98206. }
  98207. };
  98208. return FilesInput;
  98209. }());
  98210. /***/ }),
  98211. /***/ "./Misc/filesInputStore.ts":
  98212. /*!*********************************!*\
  98213. !*** ./Misc/filesInputStore.ts ***!
  98214. \*********************************/
  98215. /*! exports provided: FilesInputStore */
  98216. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98217. "use strict";
  98218. __webpack_require__.r(__webpack_exports__);
  98219. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return FilesInputStore; });
  98220. /**
  98221. * Class used to help managing file picking and drag'n'drop
  98222. * File Storage
  98223. */
  98224. var FilesInputStore = /** @class */ (function () {
  98225. function FilesInputStore() {
  98226. }
  98227. /**
  98228. * List of files ready to be loaded
  98229. */
  98230. FilesInputStore.FilesToLoad = {};
  98231. return FilesInputStore;
  98232. }());
  98233. /***/ }),
  98234. /***/ "./Misc/iInspectable.ts":
  98235. /*!******************************!*\
  98236. !*** ./Misc/iInspectable.ts ***!
  98237. \******************************/
  98238. /*! exports provided: InspectableType */
  98239. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98240. "use strict";
  98241. __webpack_require__.r(__webpack_exports__);
  98242. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return InspectableType; });
  98243. /**
  98244. * Enum that determines the text-wrapping mode to use.
  98245. */
  98246. var InspectableType;
  98247. (function (InspectableType) {
  98248. /**
  98249. * Checkbox for booleans
  98250. */
  98251. InspectableType[InspectableType["Checkbox"] = 0] = "Checkbox";
  98252. /**
  98253. * Sliders for numbers
  98254. */
  98255. InspectableType[InspectableType["Slider"] = 1] = "Slider";
  98256. /**
  98257. * Vector3
  98258. */
  98259. InspectableType[InspectableType["Vector3"] = 2] = "Vector3";
  98260. /**
  98261. * Quaternions
  98262. */
  98263. InspectableType[InspectableType["Quaternion"] = 3] = "Quaternion";
  98264. /**
  98265. * Color3
  98266. */
  98267. InspectableType[InspectableType["Color3"] = 4] = "Color3";
  98268. })(InspectableType || (InspectableType = {}));
  98269. /***/ }),
  98270. /***/ "./Misc/index.ts":
  98271. /*!***********************!*\
  98272. !*** ./Misc/index.ts ***!
  98273. \***********************/
  98274. /*! exports provided: AndOrNotEvaluator, AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, EquiRectangularCubeTextureAssetTask, AssetsManager, DDSTools, expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsMatrix, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, MeshExploder, FilesInput, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, WebRequest, InspectableType, CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools */
  98275. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98276. "use strict";
  98277. __webpack_require__.r(__webpack_exports__);
  98278. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  98279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  98280. /* harmony import */ var _assetsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./assetsManager */ "./Misc/assetsManager.ts");
  98281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetTaskState"]; });
  98282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AbstractAssetTask"]; });
  98283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsProgressEvent"]; });
  98284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["MeshAssetTask"]; });
  98285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextFileAssetTask"]; });
  98286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["BinaryFileAssetTask"]; });
  98287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["ImageAssetTask"]; });
  98288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextureAssetTask"]; });
  98289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["CubeTextureAssetTask"]; });
  98290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["HDRCubeTextureAssetTask"]; });
  98291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["EquiRectangularCubeTextureAssetTask"]; });
  98292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsManager"]; });
  98293. /* harmony import */ var _dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dds */ "./Misc/dds.ts");
  98294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"]; });
  98295. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  98296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["expandToProperty"]; });
  98297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"]; });
  98298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsTexture"]; });
  98299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor3"]; });
  98300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsFresnelParameters"]; });
  98301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector2"]; });
  98302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector3"]; });
  98303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsMeshReference"]; });
  98304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColorCurves"]; });
  98305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor4"]; });
  98306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsImageProcessingConfiguration"]; });
  98307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsQuaternion"]; });
  98308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsMatrix"]; });
  98309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsCameraReference"]; });
  98310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]; });
  98311. /* harmony import */ var _deferred__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./deferred */ "./Misc/deferred.ts");
  98312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _deferred__WEBPACK_IMPORTED_MODULE_4__["Deferred"]; });
  98313. /* harmony import */ var _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  98314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__["EnvironmentTextureTools"]; });
  98315. /* harmony import */ var _meshExploder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshExploder */ "./Misc/meshExploder.ts");
  98316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return _meshExploder__WEBPACK_IMPORTED_MODULE_6__["MeshExploder"]; });
  98317. /* harmony import */ var _filesInput__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./filesInput */ "./Misc/filesInput.ts");
  98318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _filesInput__WEBPACK_IMPORTED_MODULE_7__["FilesInput"]; });
  98319. /* harmony import */ var _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./HighDynamicRange/index */ "./Misc/HighDynamicRange/index.ts");
  98320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__["CubeMapToSphericalPolynomialTools"]; });
  98321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__["HDRTools"]; });
  98322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__["PanoramaToCubeMapTools"]; });
  98323. /* harmony import */ var _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  98324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_9__["KhronosTextureContainer"]; });
  98325. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  98326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["EventState"]; });
  98327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["Observer"]; });
  98328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["MultiObserver"]; });
  98329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["Observable"]; });
  98330. /* harmony import */ var _performanceMonitor__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./performanceMonitor */ "./Misc/performanceMonitor.ts");
  98331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_11__["PerformanceMonitor"]; });
  98332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_11__["RollingAverage"]; });
  98333. /* harmony import */ var _promise__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./promise */ "./Misc/promise.ts");
  98334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _promise__WEBPACK_IMPORTED_MODULE_12__["PromisePolyfill"]; });
  98335. /* harmony import */ var _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./sceneOptimizer */ "./Misc/sceneOptimizer.ts");
  98336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["SceneOptimization"]; });
  98337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["TextureOptimization"]; });
  98338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["HardwareScalingOptimization"]; });
  98339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["ShadowsOptimization"]; });
  98340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["PostProcessesOptimization"]; });
  98341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["LensFlaresOptimization"]; });
  98342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["CustomOptimization"]; });
  98343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["ParticlesOptimization"]; });
  98344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["RenderTargetsOptimization"]; });
  98345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["MergeMeshesOptimization"]; });
  98346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["SceneOptimizerOptions"]; });
  98347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["SceneOptimizer"]; });
  98348. /* harmony import */ var _sceneSerializer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./sceneSerializer */ "./Misc/sceneSerializer.ts");
  98349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _sceneSerializer__WEBPACK_IMPORTED_MODULE_14__["SceneSerializer"]; });
  98350. /* harmony import */ var _smartArray__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./smartArray */ "./Misc/smartArray.ts");
  98351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_15__["SmartArray"]; });
  98352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_15__["SmartArrayNoDuplicate"]; });
  98353. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  98354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _stringDictionary__WEBPACK_IMPORTED_MODULE_16__["StringDictionary"]; });
  98355. /* harmony import */ var _tags__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./tags */ "./Misc/tags.ts");
  98356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _tags__WEBPACK_IMPORTED_MODULE_17__["Tags"]; });
  98357. /* harmony import */ var _textureTools__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./textureTools */ "./Misc/textureTools.ts");
  98358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _textureTools__WEBPACK_IMPORTED_MODULE_18__["TextureTools"]; });
  98359. /* harmony import */ var _tga__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./tga */ "./Misc/tga.ts");
  98360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _tga__WEBPACK_IMPORTED_MODULE_19__["TGATools"]; });
  98361. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  98362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["ColorGradient"]; });
  98363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["Color3Gradient"]; });
  98364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["FactorGradient"]; });
  98365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["LoadFileError"]; });
  98366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["RetryStrategy"]; });
  98367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["Tools"]; });
  98368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["PerfCounter"]; });
  98369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["className"]; });
  98370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["AsyncLoop"]; });
  98371. /* harmony import */ var _videoRecorder__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./videoRecorder */ "./Misc/videoRecorder.ts");
  98372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _videoRecorder__WEBPACK_IMPORTED_MODULE_21__["VideoRecorder"]; });
  98373. /* harmony import */ var _virtualJoystick__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./virtualJoystick */ "./Misc/virtualJoystick.ts");
  98374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_22__["JoystickAxis"]; });
  98375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_22__["VirtualJoystick"]; });
  98376. /* harmony import */ var _workerPool__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./workerPool */ "./Misc/workerPool.ts");
  98377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _workerPool__WEBPACK_IMPORTED_MODULE_23__["WorkerPool"]; });
  98378. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  98379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _logger__WEBPACK_IMPORTED_MODULE_24__["Logger"]; });
  98380. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  98381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _typeStore__WEBPACK_IMPORTED_MODULE_25__["_TypeStore"]; });
  98382. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  98383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _filesInputStore__WEBPACK_IMPORTED_MODULE_26__["FilesInputStore"]; });
  98384. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  98385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _deepCopier__WEBPACK_IMPORTED_MODULE_27__["DeepCopier"]; });
  98386. /* harmony import */ var _pivotTools__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./pivotTools */ "./Misc/pivotTools.ts");
  98387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _pivotTools__WEBPACK_IMPORTED_MODULE_28__["PivotTools"]; });
  98388. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  98389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _precisionDate__WEBPACK_IMPORTED_MODULE_29__["PrecisionDate"]; });
  98390. /* harmony import */ var _screenshotTools__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./screenshotTools */ "./Misc/screenshotTools.ts");
  98391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _screenshotTools__WEBPACK_IMPORTED_MODULE_30__["ScreenshotTools"]; });
  98392. /* empty/unused harmony star reexport *//* harmony import */ var _webRequest__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./webRequest */ "./Misc/webRequest.ts");
  98393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return _webRequest__WEBPACK_IMPORTED_MODULE_31__["WebRequest"]; });
  98394. /* harmony import */ var _iInspectable__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./iInspectable */ "./Misc/iInspectable.ts");
  98395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return _iInspectable__WEBPACK_IMPORTED_MODULE_32__["InspectableType"]; });
  98396. /***/ }),
  98397. /***/ "./Misc/khronosTextureContainer.ts":
  98398. /*!*****************************************!*\
  98399. !*** ./Misc/khronosTextureContainer.ts ***!
  98400. \*****************************************/
  98401. /*! exports provided: KhronosTextureContainer */
  98402. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98403. "use strict";
  98404. __webpack_require__.r(__webpack_exports__);
  98405. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return KhronosTextureContainer; });
  98406. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  98407. /**
  98408. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  98409. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  98410. */
  98411. var KhronosTextureContainer = /** @class */ (function () {
  98412. /**
  98413. * Creates a new KhronosTextureContainer
  98414. * @param arrayBuffer contents of the KTX container file
  98415. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  98416. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  98417. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  98418. */
  98419. function KhronosTextureContainer(
  98420. /** contents of the KTX container file */
  98421. arrayBuffer, facesExpected, threeDExpected, textureArrayExpected) {
  98422. this.arrayBuffer = arrayBuffer;
  98423. /**
  98424. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  98425. */
  98426. this.isInvalid = false;
  98427. // Test that it is a ktx formatted file, based on the first 12 bytes, character representation is:
  98428. // '�', 'K', 'T', 'X', ' ', '1', '1', '�', '\r', '\n', '\x1A', '\n'
  98429. // 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
  98430. var identifier = new Uint8Array(this.arrayBuffer, 0, 12);
  98431. if (identifier[0] !== 0xAB || identifier[1] !== 0x4B || identifier[2] !== 0x54 || identifier[3] !== 0x58 || identifier[4] !== 0x20 || identifier[5] !== 0x31 ||
  98432. identifier[6] !== 0x31 || identifier[7] !== 0xBB || identifier[8] !== 0x0D || identifier[9] !== 0x0A || identifier[10] !== 0x1A || identifier[11] !== 0x0A) {
  98433. this.isInvalid = true;
  98434. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture missing KTX identifier");
  98435. return;
  98436. }
  98437. // load the reset of the header in native 32 bit uint
  98438. var dataSize = Uint32Array.BYTES_PER_ELEMENT;
  98439. var headerDataView = new DataView(this.arrayBuffer, 12, 13 * dataSize);
  98440. var endianness = headerDataView.getUint32(0, true);
  98441. var littleEndian = endianness === 0x04030201;
  98442. this.glType = headerDataView.getUint32(1 * dataSize, littleEndian); // must be 0 for compressed textures
  98443. this.glTypeSize = headerDataView.getUint32(2 * dataSize, littleEndian); // must be 1 for compressed textures
  98444. this.glFormat = headerDataView.getUint32(3 * dataSize, littleEndian); // must be 0 for compressed textures
  98445. this.glInternalFormat = headerDataView.getUint32(4 * dataSize, littleEndian); // the value of arg passed to gl.compressedTexImage2D(,,x,,,,)
  98446. this.glBaseInternalFormat = headerDataView.getUint32(5 * dataSize, littleEndian); // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only)
  98447. this.pixelWidth = headerDataView.getUint32(6 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,)
  98448. this.pixelHeight = headerDataView.getUint32(7 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,)
  98449. this.pixelDepth = headerDataView.getUint32(8 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,)
  98450. this.numberOfArrayElements = headerDataView.getUint32(9 * dataSize, littleEndian); // used for texture arrays
  98451. this.numberOfFaces = headerDataView.getUint32(10 * dataSize, littleEndian); // used for cubemap textures, should either be 1 or 6
  98452. this.numberOfMipmapLevels = headerDataView.getUint32(11 * dataSize, littleEndian); // number of levels; disregard possibility of 0 for compressed textures
  98453. this.bytesOfKeyValueData = headerDataView.getUint32(12 * dataSize, littleEndian); // the amount of space after the header for meta-data
  98454. // Make sure we have a compressed type. Not only reduces work, but probably better to let dev know they are not compressing.
  98455. if (this.glType !== 0) {
  98456. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only compressed formats currently supported");
  98457. return;
  98458. }
  98459. else {
  98460. // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.
  98461. this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
  98462. }
  98463. if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
  98464. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only 2D textures currently supported");
  98465. return;
  98466. }
  98467. if (this.numberOfArrayElements !== 0) {
  98468. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture arrays not currently supported");
  98469. return;
  98470. }
  98471. if (this.numberOfFaces !== facesExpected) {
  98472. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("number of faces expected" + facesExpected + ", but found " + this.numberOfFaces);
  98473. return;
  98474. }
  98475. // we now have a completely validated file, so could use existence of loadType as success
  98476. // would need to make this more elaborate & adjust checks above to support more than one load type
  98477. this.loadType = KhronosTextureContainer.COMPRESSED_2D;
  98478. }
  98479. /**
  98480. * Uploads KTX content to a Babylon Texture.
  98481. * It is assumed that the texture has already been created & is currently bound
  98482. * @hidden
  98483. */
  98484. KhronosTextureContainer.prototype.uploadLevels = function (texture, loadMipmaps) {
  98485. switch (this.loadType) {
  98486. case KhronosTextureContainer.COMPRESSED_2D:
  98487. this._upload2DCompressedLevels(texture, loadMipmaps);
  98488. break;
  98489. case KhronosTextureContainer.TEX_2D:
  98490. case KhronosTextureContainer.COMPRESSED_3D:
  98491. case KhronosTextureContainer.TEX_3D:
  98492. }
  98493. };
  98494. KhronosTextureContainer.prototype._upload2DCompressedLevels = function (texture, loadMipmaps) {
  98495. // initialize width & height for level 1
  98496. var dataOffset = KhronosTextureContainer.HEADER_LEN + this.bytesOfKeyValueData;
  98497. var width = this.pixelWidth;
  98498. var height = this.pixelHeight;
  98499. var mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1;
  98500. for (var level = 0; level < mipmapCount; level++) {
  98501. var imageSize = new Int32Array(this.arrayBuffer, dataOffset, 1)[0]; // size per face, since not supporting array cubemaps
  98502. dataOffset += 4; //image data starts from next multiple of 4 offset. Each face refers to same imagesize field above.
  98503. for (var face = 0; face < this.numberOfFaces; face++) {
  98504. var byteArray = new Uint8Array(this.arrayBuffer, dataOffset, imageSize);
  98505. var engine = texture.getEngine();
  98506. engine._uploadCompressedDataToTextureDirectly(texture, this.glInternalFormat, width, height, byteArray, face, level);
  98507. dataOffset += imageSize; // add size of the image for the next face/mipmap
  98508. dataOffset += 3 - ((imageSize + 3) % 4); // add padding for odd sized image
  98509. }
  98510. width = Math.max(1.0, width * 0.5);
  98511. height = Math.max(1.0, height * 0.5);
  98512. }
  98513. };
  98514. KhronosTextureContainer.HEADER_LEN = 12 + (13 * 4); // identifier + header elements (not including key value meta-data pairs)
  98515. // load types
  98516. KhronosTextureContainer.COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()
  98517. KhronosTextureContainer.COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D()
  98518. KhronosTextureContainer.TEX_2D = 2; // uses a gl.texImage2D()
  98519. KhronosTextureContainer.TEX_3D = 3; // uses a gl.texImage3D()
  98520. return KhronosTextureContainer;
  98521. }());
  98522. /***/ }),
  98523. /***/ "./Misc/logger.ts":
  98524. /*!************************!*\
  98525. !*** ./Misc/logger.ts ***!
  98526. \************************/
  98527. /*! exports provided: Logger */
  98528. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98529. "use strict";
  98530. __webpack_require__.r(__webpack_exports__);
  98531. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return Logger; });
  98532. /**
  98533. * Logger used througouht the application to allow configuration of
  98534. * the log level required for the messages.
  98535. */
  98536. var Logger = /** @class */ (function () {
  98537. function Logger() {
  98538. }
  98539. Logger._AddLogEntry = function (entry) {
  98540. Logger._LogCache = entry + Logger._LogCache;
  98541. if (Logger.OnNewCacheEntry) {
  98542. Logger.OnNewCacheEntry(entry);
  98543. }
  98544. };
  98545. Logger._FormatMessage = function (message) {
  98546. var padStr = function (i) { return (i < 10) ? "0" + i : "" + i; };
  98547. var date = new Date();
  98548. return "[" + padStr(date.getHours()) + ":" + padStr(date.getMinutes()) + ":" + padStr(date.getSeconds()) + "]: " + message;
  98549. };
  98550. Logger._LogDisabled = function (message) {
  98551. // nothing to do
  98552. };
  98553. Logger._LogEnabled = function (message) {
  98554. var formattedMessage = Logger._FormatMessage(message);
  98555. console.log("BJS - " + formattedMessage);
  98556. var entry = "<div style='color:white'>" + formattedMessage + "</div><br>";
  98557. Logger._AddLogEntry(entry);
  98558. };
  98559. Logger._WarnDisabled = function (message) {
  98560. // nothing to do
  98561. };
  98562. Logger._WarnEnabled = function (message) {
  98563. var formattedMessage = Logger._FormatMessage(message);
  98564. console.warn("BJS - " + formattedMessage);
  98565. var entry = "<div style='color:orange'>" + formattedMessage + "</div><br>";
  98566. Logger._AddLogEntry(entry);
  98567. };
  98568. Logger._ErrorDisabled = function (message) {
  98569. // nothing to do
  98570. };
  98571. Logger._ErrorEnabled = function (message) {
  98572. Logger.errorsCount++;
  98573. var formattedMessage = Logger._FormatMessage(message);
  98574. console.error("BJS - " + formattedMessage);
  98575. var entry = "<div style='color:red'>" + formattedMessage + "</div><br>";
  98576. Logger._AddLogEntry(entry);
  98577. };
  98578. Object.defineProperty(Logger, "LogCache", {
  98579. /**
  98580. * Gets current log cache (list of logs)
  98581. */
  98582. get: function () {
  98583. return Logger._LogCache;
  98584. },
  98585. enumerable: true,
  98586. configurable: true
  98587. });
  98588. /**
  98589. * Clears the log cache
  98590. */
  98591. Logger.ClearLogCache = function () {
  98592. Logger._LogCache = "";
  98593. Logger.errorsCount = 0;
  98594. };
  98595. Object.defineProperty(Logger, "LogLevels", {
  98596. /**
  98597. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  98598. */
  98599. set: function (level) {
  98600. if ((level & Logger.MessageLogLevel) === Logger.MessageLogLevel) {
  98601. Logger.Log = Logger._LogEnabled;
  98602. }
  98603. else {
  98604. Logger.Log = Logger._LogDisabled;
  98605. }
  98606. if ((level & Logger.WarningLogLevel) === Logger.WarningLogLevel) {
  98607. Logger.Warn = Logger._WarnEnabled;
  98608. }
  98609. else {
  98610. Logger.Warn = Logger._WarnDisabled;
  98611. }
  98612. if ((level & Logger.ErrorLogLevel) === Logger.ErrorLogLevel) {
  98613. Logger.Error = Logger._ErrorEnabled;
  98614. }
  98615. else {
  98616. Logger.Error = Logger._ErrorDisabled;
  98617. }
  98618. },
  98619. enumerable: true,
  98620. configurable: true
  98621. });
  98622. /**
  98623. * No log
  98624. */
  98625. Logger.NoneLogLevel = 0;
  98626. /**
  98627. * Only message logs
  98628. */
  98629. Logger.MessageLogLevel = 1;
  98630. /**
  98631. * Only warning logs
  98632. */
  98633. Logger.WarningLogLevel = 2;
  98634. /**
  98635. * Only error logs
  98636. */
  98637. Logger.ErrorLogLevel = 4;
  98638. /**
  98639. * All logs
  98640. */
  98641. Logger.AllLogLevel = 7;
  98642. Logger._LogCache = "";
  98643. /**
  98644. * Gets a value indicating the number of loading errors
  98645. * @ignorenaming
  98646. */
  98647. Logger.errorsCount = 0;
  98648. /**
  98649. * Log a message to the console
  98650. */
  98651. Logger.Log = Logger._LogEnabled;
  98652. /**
  98653. * Write a warning message to the console
  98654. */
  98655. Logger.Warn = Logger._WarnEnabled;
  98656. /**
  98657. * Write an error message to the console
  98658. */
  98659. Logger.Error = Logger._ErrorEnabled;
  98660. return Logger;
  98661. }());
  98662. /***/ }),
  98663. /***/ "./Misc/meshExploder.ts":
  98664. /*!******************************!*\
  98665. !*** ./Misc/meshExploder.ts ***!
  98666. \******************************/
  98667. /*! exports provided: MeshExploder */
  98668. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98669. "use strict";
  98670. __webpack_require__.r(__webpack_exports__);
  98671. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return MeshExploder; });
  98672. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  98673. /**
  98674. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  98675. */
  98676. var MeshExploder = /** @class */ (function () {
  98677. /**
  98678. * Explodes meshes from a center mesh.
  98679. * @param meshes The meshes to explode.
  98680. * @param centerMesh The mesh to be center of explosion.
  98681. */
  98682. function MeshExploder(meshes, centerMesh) {
  98683. this._meshesOrigins = [];
  98684. this._toCenterVectors = [];
  98685. this._scaledDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  98686. this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  98687. this._centerPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  98688. this._meshes = meshes.slice();
  98689. if (centerMesh) {
  98690. this._centerMesh = centerMesh;
  98691. }
  98692. else {
  98693. this._setCenterMesh();
  98694. }
  98695. var centerMeshIndex = this._meshes.indexOf(this._centerMesh);
  98696. if (centerMeshIndex >= 0) {
  98697. this._meshes.splice(centerMeshIndex, 1);
  98698. }
  98699. this._centerPosition = this._centerMesh.getAbsolutePosition().clone();
  98700. for (var index = 0; index < this._meshes.length; index++) {
  98701. if (this._meshes[index]) {
  98702. var mesh = this._meshes[index];
  98703. this._meshesOrigins[index] = mesh.getAbsolutePosition().clone();
  98704. this._toCenterVectors[index] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  98705. if (mesh._boundingInfo && this._centerMesh._boundingInfo) {
  98706. mesh._boundingInfo.boundingBox.centerWorld.subtractToRef(this._centerMesh._boundingInfo.boundingBox.centerWorld, this._toCenterVectors[index]);
  98707. }
  98708. }
  98709. }
  98710. }
  98711. MeshExploder.prototype._setCenterMesh = function () {
  98712. var averageCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  98713. var totalCenters = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  98714. var shortestToCenter = Number.MAX_VALUE;
  98715. for (var index = 0; index < this._meshes.length; index++) {
  98716. if (this._meshes[index]) {
  98717. var mesh = this._meshes[index];
  98718. var boundingInfo = mesh.getBoundingInfo();
  98719. if (boundingInfo) {
  98720. totalCenters.addInPlace(boundingInfo.boundingBox.centerWorld);
  98721. }
  98722. }
  98723. }
  98724. averageCenter = totalCenters.scale(1 / this._meshes.length);
  98725. for (var index = 0; index < this._meshes.length; index++) {
  98726. if (this._meshes[index]) {
  98727. var mesh = this._meshes[index];
  98728. var boundingInfo = mesh.getBoundingInfo();
  98729. if (boundingInfo) {
  98730. var distanceToCenter = boundingInfo.boundingBox.centerWorld.subtract(averageCenter).lengthSquared();
  98731. if (distanceToCenter < shortestToCenter) {
  98732. this._centerMesh = mesh;
  98733. shortestToCenter = distanceToCenter;
  98734. }
  98735. }
  98736. }
  98737. }
  98738. };
  98739. /**
  98740. * Get class name
  98741. * @returns "MeshExploder"
  98742. */
  98743. MeshExploder.prototype.getClassName = function () {
  98744. return "MeshExploder";
  98745. };
  98746. /**
  98747. * "Exploded meshes"
  98748. * @returns Array of meshes with the centerMesh at index 0.
  98749. */
  98750. MeshExploder.prototype.getMeshes = function () {
  98751. var meshArray = this._meshes.slice();
  98752. meshArray.unshift(this._centerMesh);
  98753. return meshArray;
  98754. };
  98755. /**
  98756. * Explodes meshes giving a specific direction
  98757. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  98758. */
  98759. MeshExploder.prototype.explode = function (direction) {
  98760. if (direction === void 0) { direction = 1.0; }
  98761. for (var index = 0; index < this._meshes.length; index++) {
  98762. if (this._meshes[index] && this._meshesOrigins[index] && this._toCenterVectors[index]) {
  98763. this._toCenterVectors[index].scaleToRef(direction, this._scaledDirection);
  98764. this._meshesOrigins[index].addToRef(this._scaledDirection, this._newPosition);
  98765. this._meshes[index].setAbsolutePosition(this._newPosition);
  98766. }
  98767. }
  98768. this._centerMesh.setAbsolutePosition(this._centerPosition);
  98769. };
  98770. return MeshExploder;
  98771. }());
  98772. /***/ }),
  98773. /***/ "./Misc/observable.ts":
  98774. /*!****************************!*\
  98775. !*** ./Misc/observable.ts ***!
  98776. \****************************/
  98777. /*! exports provided: EventState, Observer, MultiObserver, Observable */
  98778. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98779. "use strict";
  98780. __webpack_require__.r(__webpack_exports__);
  98781. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return EventState; });
  98782. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return Observer; });
  98783. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return MultiObserver; });
  98784. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return Observable; });
  98785. /**
  98786. * A class serves as a medium between the observable and its observers
  98787. */
  98788. var EventState = /** @class */ (function () {
  98789. /**
  98790. * Create a new EventState
  98791. * @param mask defines the mask associated with this state
  98792. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  98793. * @param target defines the original target of the state
  98794. * @param currentTarget defines the current target of the state
  98795. */
  98796. function EventState(mask, skipNextObservers, target, currentTarget) {
  98797. if (skipNextObservers === void 0) { skipNextObservers = false; }
  98798. this.initalize(mask, skipNextObservers, target, currentTarget);
  98799. }
  98800. /**
  98801. * Initialize the current event state
  98802. * @param mask defines the mask associated with this state
  98803. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  98804. * @param target defines the original target of the state
  98805. * @param currentTarget defines the current target of the state
  98806. * @returns the current event state
  98807. */
  98808. EventState.prototype.initalize = function (mask, skipNextObservers, target, currentTarget) {
  98809. if (skipNextObservers === void 0) { skipNextObservers = false; }
  98810. this.mask = mask;
  98811. this.skipNextObservers = skipNextObservers;
  98812. this.target = target;
  98813. this.currentTarget = currentTarget;
  98814. return this;
  98815. };
  98816. return EventState;
  98817. }());
  98818. /**
  98819. * Represent an Observer registered to a given Observable object.
  98820. */
  98821. var Observer = /** @class */ (function () {
  98822. /**
  98823. * Creates a new observer
  98824. * @param callback defines the callback to call when the observer is notified
  98825. * @param mask defines the mask of the observer (used to filter notifications)
  98826. * @param scope defines the current scope used to restore the JS context
  98827. */
  98828. function Observer(
  98829. /**
  98830. * Defines the callback to call when the observer is notified
  98831. */
  98832. callback,
  98833. /**
  98834. * Defines the mask of the observer (used to filter notifications)
  98835. */
  98836. mask,
  98837. /**
  98838. * Defines the current scope used to restore the JS context
  98839. */
  98840. scope) {
  98841. if (scope === void 0) { scope = null; }
  98842. this.callback = callback;
  98843. this.mask = mask;
  98844. this.scope = scope;
  98845. /** @hidden */
  98846. this._willBeUnregistered = false;
  98847. /**
  98848. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  98849. */
  98850. this.unregisterOnNextCall = false;
  98851. }
  98852. return Observer;
  98853. }());
  98854. /**
  98855. * Represent a list of observers registered to multiple Observables object.
  98856. */
  98857. var MultiObserver = /** @class */ (function () {
  98858. function MultiObserver() {
  98859. }
  98860. /**
  98861. * Release associated resources
  98862. */
  98863. MultiObserver.prototype.dispose = function () {
  98864. if (this._observers && this._observables) {
  98865. for (var index = 0; index < this._observers.length; index++) {
  98866. this._observables[index].remove(this._observers[index]);
  98867. }
  98868. }
  98869. this._observers = null;
  98870. this._observables = null;
  98871. };
  98872. /**
  98873. * Raise a callback when one of the observable will notify
  98874. * @param observables defines a list of observables to watch
  98875. * @param callback defines the callback to call on notification
  98876. * @param mask defines the mask used to filter notifications
  98877. * @param scope defines the current scope used to restore the JS context
  98878. * @returns the new MultiObserver
  98879. */
  98880. MultiObserver.Watch = function (observables, callback, mask, scope) {
  98881. if (mask === void 0) { mask = -1; }
  98882. if (scope === void 0) { scope = null; }
  98883. var result = new MultiObserver();
  98884. result._observers = new Array();
  98885. result._observables = observables;
  98886. for (var _i = 0, observables_1 = observables; _i < observables_1.length; _i++) {
  98887. var observable = observables_1[_i];
  98888. var observer = observable.add(callback, mask, false, scope);
  98889. if (observer) {
  98890. result._observers.push(observer);
  98891. }
  98892. }
  98893. return result;
  98894. };
  98895. return MultiObserver;
  98896. }());
  98897. /**
  98898. * The Observable class is a simple implementation of the Observable pattern.
  98899. *
  98900. * 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.
  98901. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  98902. * 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).
  98903. * 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.
  98904. */
  98905. var Observable = /** @class */ (function () {
  98906. /**
  98907. * Creates a new observable
  98908. * @param onObserverAdded defines a callback to call when a new observer is added
  98909. */
  98910. function Observable(onObserverAdded) {
  98911. this._observers = new Array();
  98912. this._eventState = new EventState(0);
  98913. if (onObserverAdded) {
  98914. this._onObserverAdded = onObserverAdded;
  98915. }
  98916. }
  98917. /**
  98918. * Create a new Observer with the specified callback
  98919. * @param callback the callback that will be executed for that Observer
  98920. * @param mask the mask used to filter observers
  98921. * @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.
  98922. * @param scope optional scope for the callback to be called from
  98923. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  98924. * @returns the new observer created for the callback
  98925. */
  98926. Observable.prototype.add = function (callback, mask, insertFirst, scope, unregisterOnFirstCall) {
  98927. if (mask === void 0) { mask = -1; }
  98928. if (insertFirst === void 0) { insertFirst = false; }
  98929. if (scope === void 0) { scope = null; }
  98930. if (unregisterOnFirstCall === void 0) { unregisterOnFirstCall = false; }
  98931. if (!callback) {
  98932. return null;
  98933. }
  98934. var observer = new Observer(callback, mask, scope);
  98935. observer.unregisterOnNextCall = unregisterOnFirstCall;
  98936. if (insertFirst) {
  98937. this._observers.unshift(observer);
  98938. }
  98939. else {
  98940. this._observers.push(observer);
  98941. }
  98942. if (this._onObserverAdded) {
  98943. this._onObserverAdded(observer);
  98944. }
  98945. return observer;
  98946. };
  98947. /**
  98948. * Create a new Observer with the specified callback and unregisters after the next notification
  98949. * @param callback the callback that will be executed for that Observer
  98950. * @returns the new observer created for the callback
  98951. */
  98952. Observable.prototype.addOnce = function (callback) {
  98953. return this.add(callback, undefined, undefined, undefined, true);
  98954. };
  98955. /**
  98956. * Remove an Observer from the Observable object
  98957. * @param observer the instance of the Observer to remove
  98958. * @returns false if it doesn't belong to this Observable
  98959. */
  98960. Observable.prototype.remove = function (observer) {
  98961. if (!observer) {
  98962. return false;
  98963. }
  98964. var index = this._observers.indexOf(observer);
  98965. if (index !== -1) {
  98966. this._deferUnregister(observer);
  98967. return true;
  98968. }
  98969. return false;
  98970. };
  98971. /**
  98972. * Remove a callback from the Observable object
  98973. * @param callback the callback to remove
  98974. * @param scope optional scope. If used only the callbacks with this scope will be removed
  98975. * @returns false if it doesn't belong to this Observable
  98976. */
  98977. Observable.prototype.removeCallback = function (callback, scope) {
  98978. for (var index = 0; index < this._observers.length; index++) {
  98979. if (this._observers[index].callback === callback && (!scope || scope === this._observers[index].scope)) {
  98980. this._deferUnregister(this._observers[index]);
  98981. return true;
  98982. }
  98983. }
  98984. return false;
  98985. };
  98986. Observable.prototype._deferUnregister = function (observer) {
  98987. var _this = this;
  98988. observer.unregisterOnNextCall = false;
  98989. observer._willBeUnregistered = true;
  98990. setTimeout(function () {
  98991. _this._remove(observer);
  98992. }, 0);
  98993. };
  98994. // This should only be called when not iterating over _observers to avoid callback skipping.
  98995. // Removes an observer from the _observer Array.
  98996. Observable.prototype._remove = function (observer) {
  98997. if (!observer) {
  98998. return false;
  98999. }
  99000. var index = this._observers.indexOf(observer);
  99001. if (index !== -1) {
  99002. this._observers.splice(index, 1);
  99003. return true;
  99004. }
  99005. return false;
  99006. };
  99007. /**
  99008. * Moves the observable to the top of the observer list making it get called first when notified
  99009. * @param observer the observer to move
  99010. */
  99011. Observable.prototype.makeObserverTopPriority = function (observer) {
  99012. this._remove(observer);
  99013. this._observers.unshift(observer);
  99014. };
  99015. /**
  99016. * Moves the observable to the bottom of the observer list making it get called last when notified
  99017. * @param observer the observer to move
  99018. */
  99019. Observable.prototype.makeObserverBottomPriority = function (observer) {
  99020. this._remove(observer);
  99021. this._observers.push(observer);
  99022. };
  99023. /**
  99024. * Notify all Observers by calling their respective callback with the given data
  99025. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  99026. * @param eventData defines the data to send to all observers
  99027. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  99028. * @param target defines the original target of the state
  99029. * @param currentTarget defines the current target of the state
  99030. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  99031. */
  99032. Observable.prototype.notifyObservers = function (eventData, mask, target, currentTarget) {
  99033. if (mask === void 0) { mask = -1; }
  99034. if (!this._observers.length) {
  99035. return true;
  99036. }
  99037. var state = this._eventState;
  99038. state.mask = mask;
  99039. state.target = target;
  99040. state.currentTarget = currentTarget;
  99041. state.skipNextObservers = false;
  99042. state.lastReturnValue = eventData;
  99043. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  99044. var obs = _a[_i];
  99045. if (obs._willBeUnregistered) {
  99046. continue;
  99047. }
  99048. if (obs.mask & mask) {
  99049. if (obs.scope) {
  99050. state.lastReturnValue = obs.callback.apply(obs.scope, [eventData, state]);
  99051. }
  99052. else {
  99053. state.lastReturnValue = obs.callback(eventData, state);
  99054. }
  99055. if (obs.unregisterOnNextCall) {
  99056. this._deferUnregister(obs);
  99057. }
  99058. }
  99059. if (state.skipNextObservers) {
  99060. return false;
  99061. }
  99062. }
  99063. return true;
  99064. };
  99065. /**
  99066. * Calling this will execute each callback, expecting it to be a promise or return a value.
  99067. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  99068. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  99069. * and it is crucial that all callbacks will be executed.
  99070. * The order of the callbacks is kept, callbacks are not executed parallel.
  99071. *
  99072. * @param eventData The data to be sent to each callback
  99073. * @param mask is used to filter observers defaults to -1
  99074. * @param target defines the callback target (see EventState)
  99075. * @param currentTarget defines he current object in the bubbling phase
  99076. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  99077. */
  99078. Observable.prototype.notifyObserversWithPromise = function (eventData, mask, target, currentTarget) {
  99079. var _this = this;
  99080. if (mask === void 0) { mask = -1; }
  99081. // create an empty promise
  99082. var p = Promise.resolve(eventData);
  99083. // no observers? return this promise.
  99084. if (!this._observers.length) {
  99085. return p;
  99086. }
  99087. var state = this._eventState;
  99088. state.mask = mask;
  99089. state.target = target;
  99090. state.currentTarget = currentTarget;
  99091. state.skipNextObservers = false;
  99092. // execute one callback after another (not using Promise.all, the order is important)
  99093. this._observers.forEach(function (obs) {
  99094. if (state.skipNextObservers) {
  99095. return;
  99096. }
  99097. if (obs._willBeUnregistered) {
  99098. return;
  99099. }
  99100. if (obs.mask & mask) {
  99101. if (obs.scope) {
  99102. p = p.then(function (lastReturnedValue) {
  99103. state.lastReturnValue = lastReturnedValue;
  99104. return obs.callback.apply(obs.scope, [eventData, state]);
  99105. });
  99106. }
  99107. else {
  99108. p = p.then(function (lastReturnedValue) {
  99109. state.lastReturnValue = lastReturnedValue;
  99110. return obs.callback(eventData, state);
  99111. });
  99112. }
  99113. if (obs.unregisterOnNextCall) {
  99114. _this._deferUnregister(obs);
  99115. }
  99116. }
  99117. });
  99118. // return the eventData
  99119. return p.then(function () { return eventData; });
  99120. };
  99121. /**
  99122. * Notify a specific observer
  99123. * @param observer defines the observer to notify
  99124. * @param eventData defines the data to be sent to each callback
  99125. * @param mask is used to filter observers defaults to -1
  99126. */
  99127. Observable.prototype.notifyObserver = function (observer, eventData, mask) {
  99128. if (mask === void 0) { mask = -1; }
  99129. var state = this._eventState;
  99130. state.mask = mask;
  99131. state.skipNextObservers = false;
  99132. observer.callback(eventData, state);
  99133. };
  99134. /**
  99135. * Gets a boolean indicating if the observable has at least one observer
  99136. * @returns true is the Observable has at least one Observer registered
  99137. */
  99138. Observable.prototype.hasObservers = function () {
  99139. return this._observers.length > 0;
  99140. };
  99141. /**
  99142. * Clear the list of observers
  99143. */
  99144. Observable.prototype.clear = function () {
  99145. this._observers = new Array();
  99146. this._onObserverAdded = null;
  99147. };
  99148. /**
  99149. * Clone the current observable
  99150. * @returns a new observable
  99151. */
  99152. Observable.prototype.clone = function () {
  99153. var result = new Observable();
  99154. result._observers = this._observers.slice(0);
  99155. return result;
  99156. };
  99157. /**
  99158. * Does this observable handles observer registered with a given mask
  99159. * @param mask defines the mask to be tested
  99160. * @return whether or not one observer registered with the given mask is handeled
  99161. **/
  99162. Observable.prototype.hasSpecificMask = function (mask) {
  99163. if (mask === void 0) { mask = -1; }
  99164. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  99165. var obs = _a[_i];
  99166. if (obs.mask & mask || obs.mask === mask) {
  99167. return true;
  99168. }
  99169. }
  99170. return false;
  99171. };
  99172. return Observable;
  99173. }());
  99174. /***/ }),
  99175. /***/ "./Misc/performanceMonitor.ts":
  99176. /*!************************************!*\
  99177. !*** ./Misc/performanceMonitor.ts ***!
  99178. \************************************/
  99179. /*! exports provided: PerformanceMonitor, RollingAverage */
  99180. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99181. "use strict";
  99182. __webpack_require__.r(__webpack_exports__);
  99183. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return PerformanceMonitor; });
  99184. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return RollingAverage; });
  99185. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  99186. /**
  99187. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  99188. */
  99189. var PerformanceMonitor = /** @class */ (function () {
  99190. /**
  99191. * constructor
  99192. * @param frameSampleSize The number of samples required to saturate the sliding window
  99193. */
  99194. function PerformanceMonitor(frameSampleSize) {
  99195. if (frameSampleSize === void 0) { frameSampleSize = 30; }
  99196. this._enabled = true;
  99197. this._rollingFrameTime = new RollingAverage(frameSampleSize);
  99198. }
  99199. /**
  99200. * Samples current frame
  99201. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  99202. */
  99203. PerformanceMonitor.prototype.sampleFrame = function (timeMs) {
  99204. if (timeMs === void 0) { timeMs = _precisionDate__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"].Now; }
  99205. if (!this._enabled) {
  99206. return;
  99207. }
  99208. if (this._lastFrameTimeMs != null) {
  99209. var dt = timeMs - this._lastFrameTimeMs;
  99210. this._rollingFrameTime.add(dt);
  99211. }
  99212. this._lastFrameTimeMs = timeMs;
  99213. };
  99214. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTime", {
  99215. /**
  99216. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99217. */
  99218. get: function () {
  99219. return this._rollingFrameTime.average;
  99220. },
  99221. enumerable: true,
  99222. configurable: true
  99223. });
  99224. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTimeVariance", {
  99225. /**
  99226. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99227. */
  99228. get: function () {
  99229. return this._rollingFrameTime.variance;
  99230. },
  99231. enumerable: true,
  99232. configurable: true
  99233. });
  99234. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFrameTime", {
  99235. /**
  99236. * Returns the frame time of the most recent frame
  99237. */
  99238. get: function () {
  99239. return this._rollingFrameTime.history(0);
  99240. },
  99241. enumerable: true,
  99242. configurable: true
  99243. });
  99244. Object.defineProperty(PerformanceMonitor.prototype, "averageFPS", {
  99245. /**
  99246. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  99247. */
  99248. get: function () {
  99249. return 1000.0 / this._rollingFrameTime.average;
  99250. },
  99251. enumerable: true,
  99252. configurable: true
  99253. });
  99254. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFPS", {
  99255. /**
  99256. * Returns the average framerate in frames per second using the most recent frame time
  99257. */
  99258. get: function () {
  99259. var history = this._rollingFrameTime.history(0);
  99260. if (history === 0) {
  99261. return 0;
  99262. }
  99263. return 1000.0 / history;
  99264. },
  99265. enumerable: true,
  99266. configurable: true
  99267. });
  99268. Object.defineProperty(PerformanceMonitor.prototype, "isSaturated", {
  99269. /**
  99270. * Returns true if enough samples have been taken to completely fill the sliding window
  99271. */
  99272. get: function () {
  99273. return this._rollingFrameTime.isSaturated();
  99274. },
  99275. enumerable: true,
  99276. configurable: true
  99277. });
  99278. /**
  99279. * Enables contributions to the sliding window sample set
  99280. */
  99281. PerformanceMonitor.prototype.enable = function () {
  99282. this._enabled = true;
  99283. };
  99284. /**
  99285. * Disables contributions to the sliding window sample set
  99286. * Samples will not be interpolated over the disabled period
  99287. */
  99288. PerformanceMonitor.prototype.disable = function () {
  99289. this._enabled = false;
  99290. //clear last sample to avoid interpolating over the disabled period when next enabled
  99291. this._lastFrameTimeMs = null;
  99292. };
  99293. Object.defineProperty(PerformanceMonitor.prototype, "isEnabled", {
  99294. /**
  99295. * Returns true if sampling is enabled
  99296. */
  99297. get: function () {
  99298. return this._enabled;
  99299. },
  99300. enumerable: true,
  99301. configurable: true
  99302. });
  99303. /**
  99304. * Resets performance monitor
  99305. */
  99306. PerformanceMonitor.prototype.reset = function () {
  99307. //clear last sample to avoid interpolating over the disabled period when next enabled
  99308. this._lastFrameTimeMs = null;
  99309. //wipe record
  99310. this._rollingFrameTime.reset();
  99311. };
  99312. return PerformanceMonitor;
  99313. }());
  99314. /**
  99315. * RollingAverage
  99316. *
  99317. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  99318. */
  99319. var RollingAverage = /** @class */ (function () {
  99320. /**
  99321. * constructor
  99322. * @param length The number of samples required to saturate the sliding window
  99323. */
  99324. function RollingAverage(length) {
  99325. this._samples = new Array(length);
  99326. this.reset();
  99327. }
  99328. /**
  99329. * Adds a sample to the sample set
  99330. * @param v The sample value
  99331. */
  99332. RollingAverage.prototype.add = function (v) {
  99333. //http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
  99334. var delta;
  99335. //we need to check if we've already wrapped round
  99336. if (this.isSaturated()) {
  99337. //remove bottom of stack from mean
  99338. var bottomValue = this._samples[this._pos];
  99339. delta = bottomValue - this.average;
  99340. this.average -= delta / (this._sampleCount - 1);
  99341. this._m2 -= delta * (bottomValue - this.average);
  99342. }
  99343. else {
  99344. this._sampleCount++;
  99345. }
  99346. //add new value to mean
  99347. delta = v - this.average;
  99348. this.average += delta / (this._sampleCount);
  99349. this._m2 += delta * (v - this.average);
  99350. //set the new variance
  99351. this.variance = this._m2 / (this._sampleCount - 1);
  99352. this._samples[this._pos] = v;
  99353. this._pos++;
  99354. this._pos %= this._samples.length; //positive wrap around
  99355. };
  99356. /**
  99357. * Returns previously added values or null if outside of history or outside the sliding window domain
  99358. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  99359. * @return Value previously recorded with add() or null if outside of range
  99360. */
  99361. RollingAverage.prototype.history = function (i) {
  99362. if ((i >= this._sampleCount) || (i >= this._samples.length)) {
  99363. return 0;
  99364. }
  99365. var i0 = this._wrapPosition(this._pos - 1.0);
  99366. return this._samples[this._wrapPosition(i0 - i)];
  99367. };
  99368. /**
  99369. * Returns true if enough samples have been taken to completely fill the sliding window
  99370. * @return true if sample-set saturated
  99371. */
  99372. RollingAverage.prototype.isSaturated = function () {
  99373. return this._sampleCount >= this._samples.length;
  99374. };
  99375. /**
  99376. * Resets the rolling average (equivalent to 0 samples taken so far)
  99377. */
  99378. RollingAverage.prototype.reset = function () {
  99379. this.average = 0;
  99380. this.variance = 0;
  99381. this._sampleCount = 0;
  99382. this._pos = 0;
  99383. this._m2 = 0;
  99384. };
  99385. /**
  99386. * Wraps a value around the sample range boundaries
  99387. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  99388. * @return Wrapped position in sample range
  99389. */
  99390. RollingAverage.prototype._wrapPosition = function (i) {
  99391. var max = this._samples.length;
  99392. return ((i % max) + max) % max;
  99393. };
  99394. return RollingAverage;
  99395. }());
  99396. /***/ }),
  99397. /***/ "./Misc/pivotTools.ts":
  99398. /*!****************************!*\
  99399. !*** ./Misc/pivotTools.ts ***!
  99400. \****************************/
  99401. /*! exports provided: PivotTools */
  99402. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99403. "use strict";
  99404. __webpack_require__.r(__webpack_exports__);
  99405. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return PivotTools; });
  99406. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  99407. /**
  99408. * Class containing a set of static utilities functions for managing Pivots
  99409. * @hidden
  99410. */
  99411. var PivotTools = /** @class */ (function () {
  99412. function PivotTools() {
  99413. }
  99414. /** @hidden */
  99415. PivotTools._RemoveAndStorePivotPoint = function (mesh) {
  99416. if (mesh && PivotTools._PivotCached === 0) {
  99417. // Save old pivot and set pivot to 0,0,0
  99418. mesh.getPivotPointToRef(PivotTools._OldPivotPoint);
  99419. if (!PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0)) {
  99420. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityReadOnly);
  99421. PivotTools._OldPivotPoint.subtractToRef(mesh.getPivotPoint(), PivotTools._PivotTranslation);
  99422. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  99423. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  99424. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  99425. mesh.position.addInPlace(PivotTools._PivotTmpVector);
  99426. }
  99427. }
  99428. PivotTools._PivotCached++;
  99429. };
  99430. /** @hidden */
  99431. PivotTools._RestorePivotPoint = function (mesh) {
  99432. if (mesh && !PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0) && PivotTools._PivotCached === 1) {
  99433. mesh.setPivotPoint(PivotTools._OldPivotPoint);
  99434. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  99435. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  99436. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  99437. mesh.position.subtractInPlace(PivotTools._PivotTmpVector);
  99438. }
  99439. this._PivotCached--;
  99440. };
  99441. // Stores the state of the pivot cache (_oldPivotPoint, _pivotTranslation)
  99442. // store/remove pivot point should only be applied during their outermost calls
  99443. PivotTools._PivotCached = 0;
  99444. PivotTools._OldPivotPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  99445. PivotTools._PivotTranslation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  99446. PivotTools._PivotTmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  99447. return PivotTools;
  99448. }());
  99449. /***/ }),
  99450. /***/ "./Misc/precisionDate.ts":
  99451. /*!*******************************!*\
  99452. !*** ./Misc/precisionDate.ts ***!
  99453. \*******************************/
  99454. /*! exports provided: PrecisionDate */
  99455. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99456. "use strict";
  99457. __webpack_require__.r(__webpack_exports__);
  99458. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return PrecisionDate; });
  99459. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  99460. /**
  99461. * Class containing a set of static utilities functions for precision date
  99462. */
  99463. var PrecisionDate = /** @class */ (function () {
  99464. function PrecisionDate() {
  99465. }
  99466. Object.defineProperty(PrecisionDate, "Now", {
  99467. /**
  99468. * Gets either window.performance.now() if supported or Date.now() else
  99469. */
  99470. get: function () {
  99471. if (_domManagement__WEBPACK_IMPORTED_MODULE_0__["DomManagement"].IsWindowObjectExist() && window.performance && window.performance.now) {
  99472. return window.performance.now();
  99473. }
  99474. return Date.now();
  99475. },
  99476. enumerable: true,
  99477. configurable: true
  99478. });
  99479. return PrecisionDate;
  99480. }());
  99481. /***/ }),
  99482. /***/ "./Misc/promise.ts":
  99483. /*!*************************!*\
  99484. !*** ./Misc/promise.ts ***!
  99485. \*************************/
  99486. /*! exports provided: PromisePolyfill */
  99487. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99488. "use strict";
  99489. __webpack_require__.r(__webpack_exports__);
  99490. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return PromisePolyfill; });
  99491. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  99492. var PromiseStates;
  99493. (function (PromiseStates) {
  99494. PromiseStates[PromiseStates["Pending"] = 0] = "Pending";
  99495. PromiseStates[PromiseStates["Fulfilled"] = 1] = "Fulfilled";
  99496. PromiseStates[PromiseStates["Rejected"] = 2] = "Rejected";
  99497. })(PromiseStates || (PromiseStates = {}));
  99498. var FulFillmentAgregator = /** @class */ (function () {
  99499. function FulFillmentAgregator() {
  99500. this.count = 0;
  99501. this.target = 0;
  99502. this.results = [];
  99503. }
  99504. return FulFillmentAgregator;
  99505. }());
  99506. var InternalPromise = /** @class */ (function () {
  99507. function InternalPromise(resolver) {
  99508. var _this = this;
  99509. this._state = PromiseStates.Pending;
  99510. this._children = new Array();
  99511. this._rejectWasConsumed = false;
  99512. if (!resolver) {
  99513. return;
  99514. }
  99515. try {
  99516. resolver(function (value) {
  99517. _this._resolve(value);
  99518. }, function (reason) {
  99519. _this._reject(reason);
  99520. });
  99521. }
  99522. catch (e) {
  99523. this._reject(e);
  99524. }
  99525. }
  99526. Object.defineProperty(InternalPromise.prototype, "_result", {
  99527. get: function () {
  99528. return this._resultValue;
  99529. },
  99530. set: function (value) {
  99531. this._resultValue = value;
  99532. if (this._parent && this._parent._result === undefined) {
  99533. this._parent._result = value;
  99534. }
  99535. },
  99536. enumerable: true,
  99537. configurable: true
  99538. });
  99539. InternalPromise.prototype.catch = function (onRejected) {
  99540. return this.then(undefined, onRejected);
  99541. };
  99542. InternalPromise.prototype.then = function (onFulfilled, onRejected) {
  99543. var _this = this;
  99544. var newPromise = new InternalPromise();
  99545. newPromise._onFulfilled = onFulfilled;
  99546. newPromise._onRejected = onRejected;
  99547. // Composition
  99548. this._children.push(newPromise);
  99549. newPromise._parent = this;
  99550. if (this._state !== PromiseStates.Pending) {
  99551. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  99552. if (_this._state === PromiseStates.Fulfilled || _this._rejectWasConsumed) {
  99553. var returnedValue = newPromise._resolve(_this._result);
  99554. if (returnedValue !== undefined && returnedValue !== null) {
  99555. if (returnedValue._state !== undefined) {
  99556. var returnedPromise = returnedValue;
  99557. newPromise._children.push(returnedPromise);
  99558. returnedPromise._parent = newPromise;
  99559. newPromise = returnedPromise;
  99560. }
  99561. else {
  99562. newPromise._result = returnedValue;
  99563. }
  99564. }
  99565. }
  99566. else {
  99567. newPromise._reject(_this._reason);
  99568. }
  99569. });
  99570. }
  99571. return newPromise;
  99572. };
  99573. InternalPromise.prototype._moveChildren = function (children) {
  99574. var _this = this;
  99575. var _a;
  99576. (_a = this._children).push.apply(_a, children.splice(0, children.length));
  99577. this._children.forEach(function (child) {
  99578. child._parent = _this;
  99579. });
  99580. if (this._state === PromiseStates.Fulfilled) {
  99581. for (var _i = 0, _b = this._children; _i < _b.length; _i++) {
  99582. var child = _b[_i];
  99583. child._resolve(this._result);
  99584. }
  99585. }
  99586. else if (this._state === PromiseStates.Rejected) {
  99587. for (var _c = 0, _d = this._children; _c < _d.length; _c++) {
  99588. var child = _d[_c];
  99589. child._reject(this._reason);
  99590. }
  99591. }
  99592. };
  99593. InternalPromise.prototype._resolve = function (value) {
  99594. try {
  99595. this._state = PromiseStates.Fulfilled;
  99596. var returnedValue = null;
  99597. if (this._onFulfilled) {
  99598. returnedValue = this._onFulfilled(value);
  99599. }
  99600. if (returnedValue !== undefined && returnedValue !== null) {
  99601. if (returnedValue._state !== undefined) {
  99602. // Transmit children
  99603. var returnedPromise = returnedValue;
  99604. returnedPromise._parent = this;
  99605. returnedPromise._moveChildren(this._children);
  99606. value = returnedPromise._result;
  99607. }
  99608. else {
  99609. value = returnedValue;
  99610. }
  99611. }
  99612. this._result = value;
  99613. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  99614. var child = _a[_i];
  99615. child._resolve(value);
  99616. }
  99617. this._children.length = 0;
  99618. delete this._onFulfilled;
  99619. delete this._onRejected;
  99620. }
  99621. catch (e) {
  99622. this._reject(e, true);
  99623. }
  99624. };
  99625. InternalPromise.prototype._reject = function (reason, onLocalThrow) {
  99626. if (onLocalThrow === void 0) { onLocalThrow = false; }
  99627. this._state = PromiseStates.Rejected;
  99628. this._reason = reason;
  99629. if (this._onRejected && !onLocalThrow) {
  99630. try {
  99631. this._onRejected(reason);
  99632. this._rejectWasConsumed = true;
  99633. }
  99634. catch (e) {
  99635. reason = e;
  99636. }
  99637. }
  99638. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  99639. var child = _a[_i];
  99640. if (this._rejectWasConsumed) {
  99641. child._resolve(null);
  99642. }
  99643. else {
  99644. child._reject(reason);
  99645. }
  99646. }
  99647. this._children.length = 0;
  99648. delete this._onFulfilled;
  99649. delete this._onRejected;
  99650. };
  99651. InternalPromise.resolve = function (value) {
  99652. var newPromise = new InternalPromise();
  99653. newPromise._resolve(value);
  99654. return newPromise;
  99655. };
  99656. InternalPromise._RegisterForFulfillment = function (promise, agregator, index) {
  99657. promise.then(function (value) {
  99658. agregator.results[index] = value;
  99659. agregator.count++;
  99660. if (agregator.count === agregator.target) {
  99661. agregator.rootPromise._resolve(agregator.results);
  99662. }
  99663. return null;
  99664. }, function (reason) {
  99665. if (agregator.rootPromise._state !== PromiseStates.Rejected) {
  99666. agregator.rootPromise._reject(reason);
  99667. }
  99668. });
  99669. };
  99670. InternalPromise.all = function (promises) {
  99671. var newPromise = new InternalPromise();
  99672. var agregator = new FulFillmentAgregator();
  99673. agregator.target = promises.length;
  99674. agregator.rootPromise = newPromise;
  99675. if (promises.length) {
  99676. for (var index = 0; index < promises.length; index++) {
  99677. InternalPromise._RegisterForFulfillment(promises[index], agregator, index);
  99678. }
  99679. }
  99680. else {
  99681. newPromise._resolve([]);
  99682. }
  99683. return newPromise;
  99684. };
  99685. InternalPromise.race = function (promises) {
  99686. var newPromise = new InternalPromise();
  99687. if (promises.length) {
  99688. for (var _i = 0, promises_1 = promises; _i < promises_1.length; _i++) {
  99689. var promise = promises_1[_i];
  99690. promise.then(function (value) {
  99691. if (newPromise) {
  99692. newPromise._resolve(value);
  99693. newPromise = null;
  99694. }
  99695. return null;
  99696. }, function (reason) {
  99697. if (newPromise) {
  99698. newPromise._reject(reason);
  99699. newPromise = null;
  99700. }
  99701. });
  99702. }
  99703. }
  99704. return newPromise;
  99705. };
  99706. return InternalPromise;
  99707. }());
  99708. /**
  99709. * Helper class that provides a small promise polyfill
  99710. */
  99711. var PromisePolyfill = /** @class */ (function () {
  99712. function PromisePolyfill() {
  99713. }
  99714. /**
  99715. * Static function used to check if the polyfill is required
  99716. * If this is the case then the function will inject the polyfill to window.Promise
  99717. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  99718. */
  99719. PromisePolyfill.Apply = function (force) {
  99720. if (force === void 0) { force = false; }
  99721. if (force || typeof Promise === 'undefined') {
  99722. var root = window;
  99723. root.Promise = InternalPromise;
  99724. }
  99725. };
  99726. return PromisePolyfill;
  99727. }());
  99728. /***/ }),
  99729. /***/ "./Misc/sceneOptimizer.ts":
  99730. /*!********************************!*\
  99731. !*** ./Misc/sceneOptimizer.ts ***!
  99732. \********************************/
  99733. /*! exports provided: SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer */
  99734. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99735. "use strict";
  99736. __webpack_require__.r(__webpack_exports__);
  99737. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return SceneOptimization; });
  99738. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return TextureOptimization; });
  99739. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return HardwareScalingOptimization; });
  99740. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return ShadowsOptimization; });
  99741. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return PostProcessesOptimization; });
  99742. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return LensFlaresOptimization; });
  99743. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return CustomOptimization; });
  99744. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return ParticlesOptimization; });
  99745. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return RenderTargetsOptimization; });
  99746. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return MergeMeshesOptimization; });
  99747. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return SceneOptimizerOptions; });
  99748. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return SceneOptimizer; });
  99749. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  99750. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  99751. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  99752. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  99753. /**
  99754. * Defines the root class used to create scene optimization to use with SceneOptimizer
  99755. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99756. */
  99757. var SceneOptimization = /** @class */ (function () {
  99758. /**
  99759. * Creates the SceneOptimization object
  99760. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  99761. * @param desc defines the description associated with the optimization
  99762. */
  99763. function SceneOptimization(
  99764. /**
  99765. * Defines the priority of this optimization (0 by default which means first in the list)
  99766. */
  99767. priority) {
  99768. if (priority === void 0) { priority = 0; }
  99769. this.priority = priority;
  99770. }
  99771. /**
  99772. * Gets a string describing the action executed by the current optimization
  99773. * @returns description string
  99774. */
  99775. SceneOptimization.prototype.getDescription = function () {
  99776. return "";
  99777. };
  99778. /**
  99779. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  99780. * @param scene defines the current scene where to apply this optimization
  99781. * @param optimizer defines the current optimizer
  99782. * @returns true if everything that can be done was applied
  99783. */
  99784. SceneOptimization.prototype.apply = function (scene, optimizer) {
  99785. return true;
  99786. };
  99787. return SceneOptimization;
  99788. }());
  99789. /**
  99790. * Defines an optimization used to reduce the size of render target textures
  99791. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99792. */
  99793. var TextureOptimization = /** @class */ (function (_super) {
  99794. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureOptimization, _super);
  99795. /**
  99796. * Creates the TextureOptimization object
  99797. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  99798. * @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
  99799. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  99800. */
  99801. function TextureOptimization(
  99802. /**
  99803. * Defines the priority of this optimization (0 by default which means first in the list)
  99804. */
  99805. priority,
  99806. /**
  99807. * 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
  99808. */
  99809. maximumSize,
  99810. /**
  99811. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  99812. */
  99813. step) {
  99814. if (priority === void 0) { priority = 0; }
  99815. if (maximumSize === void 0) { maximumSize = 1024; }
  99816. if (step === void 0) { step = 0.5; }
  99817. var _this = _super.call(this, priority) || this;
  99818. _this.priority = priority;
  99819. _this.maximumSize = maximumSize;
  99820. _this.step = step;
  99821. return _this;
  99822. }
  99823. /**
  99824. * Gets a string describing the action executed by the current optimization
  99825. * @returns description string
  99826. */
  99827. TextureOptimization.prototype.getDescription = function () {
  99828. return "Reducing render target texture size to " + this.maximumSize;
  99829. };
  99830. /**
  99831. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  99832. * @param scene defines the current scene where to apply this optimization
  99833. * @param optimizer defines the current optimizer
  99834. * @returns true if everything that can be done was applied
  99835. */
  99836. TextureOptimization.prototype.apply = function (scene, optimizer) {
  99837. var allDone = true;
  99838. for (var index = 0; index < scene.textures.length; index++) {
  99839. var texture = scene.textures[index];
  99840. if (!texture.canRescale || texture.getContext) {
  99841. continue;
  99842. }
  99843. var currentSize = texture.getSize();
  99844. var maxDimension = Math.max(currentSize.width, currentSize.height);
  99845. if (maxDimension > this.maximumSize) {
  99846. texture.scale(this.step);
  99847. allDone = false;
  99848. }
  99849. }
  99850. return allDone;
  99851. };
  99852. return TextureOptimization;
  99853. }(SceneOptimization));
  99854. /**
  99855. * Defines an optimization used to increase or decrease the rendering resolution
  99856. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99857. */
  99858. var HardwareScalingOptimization = /** @class */ (function (_super) {
  99859. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HardwareScalingOptimization, _super);
  99860. /**
  99861. * Creates the HardwareScalingOptimization object
  99862. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  99863. * @param maximumScale defines the maximum scale to use (2 by default)
  99864. * @param step defines the step to use between two passes (0.5 by default)
  99865. */
  99866. function HardwareScalingOptimization(
  99867. /**
  99868. * Defines the priority of this optimization (0 by default which means first in the list)
  99869. */
  99870. priority,
  99871. /**
  99872. * Defines the maximum scale to use (2 by default)
  99873. */
  99874. maximumScale,
  99875. /**
  99876. * Defines the step to use between two passes (0.5 by default)
  99877. */
  99878. step) {
  99879. if (priority === void 0) { priority = 0; }
  99880. if (maximumScale === void 0) { maximumScale = 2; }
  99881. if (step === void 0) { step = 0.25; }
  99882. var _this = _super.call(this, priority) || this;
  99883. _this.priority = priority;
  99884. _this.maximumScale = maximumScale;
  99885. _this.step = step;
  99886. _this._currentScale = -1;
  99887. _this._directionOffset = 1;
  99888. return _this;
  99889. }
  99890. /**
  99891. * Gets a string describing the action executed by the current optimization
  99892. * @return description string
  99893. */
  99894. HardwareScalingOptimization.prototype.getDescription = function () {
  99895. return "Setting hardware scaling level to " + this._currentScale;
  99896. };
  99897. /**
  99898. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  99899. * @param scene defines the current scene where to apply this optimization
  99900. * @param optimizer defines the current optimizer
  99901. * @returns true if everything that can be done was applied
  99902. */
  99903. HardwareScalingOptimization.prototype.apply = function (scene, optimizer) {
  99904. if (this._currentScale === -1) {
  99905. this._currentScale = scene.getEngine().getHardwareScalingLevel();
  99906. if (this._currentScale > this.maximumScale) {
  99907. this._directionOffset = -1;
  99908. }
  99909. }
  99910. this._currentScale += this._directionOffset * this.step;
  99911. scene.getEngine().setHardwareScalingLevel(this._currentScale);
  99912. return this._directionOffset === 1 ? this._currentScale >= this.maximumScale : this._currentScale <= this.maximumScale;
  99913. };
  99914. return HardwareScalingOptimization;
  99915. }(SceneOptimization));
  99916. /**
  99917. * Defines an optimization used to remove shadows
  99918. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99919. */
  99920. var ShadowsOptimization = /** @class */ (function (_super) {
  99921. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowsOptimization, _super);
  99922. function ShadowsOptimization() {
  99923. return _super !== null && _super.apply(this, arguments) || this;
  99924. }
  99925. /**
  99926. * Gets a string describing the action executed by the current optimization
  99927. * @return description string
  99928. */
  99929. ShadowsOptimization.prototype.getDescription = function () {
  99930. return "Turning shadows on/off";
  99931. };
  99932. /**
  99933. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  99934. * @param scene defines the current scene where to apply this optimization
  99935. * @param optimizer defines the current optimizer
  99936. * @returns true if everything that can be done was applied
  99937. */
  99938. ShadowsOptimization.prototype.apply = function (scene, optimizer) {
  99939. scene.shadowsEnabled = optimizer.isInImprovementMode;
  99940. return true;
  99941. };
  99942. return ShadowsOptimization;
  99943. }(SceneOptimization));
  99944. /**
  99945. * Defines an optimization used to turn post-processes off
  99946. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99947. */
  99948. var PostProcessesOptimization = /** @class */ (function (_super) {
  99949. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PostProcessesOptimization, _super);
  99950. function PostProcessesOptimization() {
  99951. return _super !== null && _super.apply(this, arguments) || this;
  99952. }
  99953. /**
  99954. * Gets a string describing the action executed by the current optimization
  99955. * @return description string
  99956. */
  99957. PostProcessesOptimization.prototype.getDescription = function () {
  99958. return "Turning post-processes on/off";
  99959. };
  99960. /**
  99961. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  99962. * @param scene defines the current scene where to apply this optimization
  99963. * @param optimizer defines the current optimizer
  99964. * @returns true if everything that can be done was applied
  99965. */
  99966. PostProcessesOptimization.prototype.apply = function (scene, optimizer) {
  99967. scene.postProcessesEnabled = optimizer.isInImprovementMode;
  99968. return true;
  99969. };
  99970. return PostProcessesOptimization;
  99971. }(SceneOptimization));
  99972. /**
  99973. * Defines an optimization used to turn lens flares off
  99974. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99975. */
  99976. var LensFlaresOptimization = /** @class */ (function (_super) {
  99977. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensFlaresOptimization, _super);
  99978. function LensFlaresOptimization() {
  99979. return _super !== null && _super.apply(this, arguments) || this;
  99980. }
  99981. /**
  99982. * Gets a string describing the action executed by the current optimization
  99983. * @return description string
  99984. */
  99985. LensFlaresOptimization.prototype.getDescription = function () {
  99986. return "Turning lens flares on/off";
  99987. };
  99988. /**
  99989. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  99990. * @param scene defines the current scene where to apply this optimization
  99991. * @param optimizer defines the current optimizer
  99992. * @returns true if everything that can be done was applied
  99993. */
  99994. LensFlaresOptimization.prototype.apply = function (scene, optimizer) {
  99995. scene.lensFlaresEnabled = optimizer.isInImprovementMode;
  99996. return true;
  99997. };
  99998. return LensFlaresOptimization;
  99999. }(SceneOptimization));
  100000. /**
  100001. * Defines an optimization based on user defined callback.
  100002. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100003. */
  100004. var CustomOptimization = /** @class */ (function (_super) {
  100005. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomOptimization, _super);
  100006. function CustomOptimization() {
  100007. return _super !== null && _super.apply(this, arguments) || this;
  100008. }
  100009. /**
  100010. * Gets a string describing the action executed by the current optimization
  100011. * @returns description string
  100012. */
  100013. CustomOptimization.prototype.getDescription = function () {
  100014. if (this.onGetDescription) {
  100015. return this.onGetDescription();
  100016. }
  100017. return "Running user defined callback";
  100018. };
  100019. /**
  100020. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  100021. * @param scene defines the current scene where to apply this optimization
  100022. * @param optimizer defines the current optimizer
  100023. * @returns true if everything that can be done was applied
  100024. */
  100025. CustomOptimization.prototype.apply = function (scene, optimizer) {
  100026. if (this.onApply) {
  100027. return this.onApply(scene, optimizer);
  100028. }
  100029. return true;
  100030. };
  100031. return CustomOptimization;
  100032. }(SceneOptimization));
  100033. /**
  100034. * Defines an optimization used to turn particles off
  100035. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100036. */
  100037. var ParticlesOptimization = /** @class */ (function (_super) {
  100038. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticlesOptimization, _super);
  100039. function ParticlesOptimization() {
  100040. return _super !== null && _super.apply(this, arguments) || this;
  100041. }
  100042. /**
  100043. * Gets a string describing the action executed by the current optimization
  100044. * @return description string
  100045. */
  100046. ParticlesOptimization.prototype.getDescription = function () {
  100047. return "Turning particles on/off";
  100048. };
  100049. /**
  100050. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  100051. * @param scene defines the current scene where to apply this optimization
  100052. * @param optimizer defines the current optimizer
  100053. * @returns true if everything that can be done was applied
  100054. */
  100055. ParticlesOptimization.prototype.apply = function (scene, optimizer) {
  100056. scene.particlesEnabled = optimizer.isInImprovementMode;
  100057. return true;
  100058. };
  100059. return ParticlesOptimization;
  100060. }(SceneOptimization));
  100061. /**
  100062. * Defines an optimization used to turn render targets off
  100063. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100064. */
  100065. var RenderTargetsOptimization = /** @class */ (function (_super) {
  100066. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetsOptimization, _super);
  100067. function RenderTargetsOptimization() {
  100068. return _super !== null && _super.apply(this, arguments) || this;
  100069. }
  100070. /**
  100071. * Gets a string describing the action executed by the current optimization
  100072. * @return description string
  100073. */
  100074. RenderTargetsOptimization.prototype.getDescription = function () {
  100075. return "Turning render targets off";
  100076. };
  100077. /**
  100078. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  100079. * @param scene defines the current scene where to apply this optimization
  100080. * @param optimizer defines the current optimizer
  100081. * @returns true if everything that can be done was applied
  100082. */
  100083. RenderTargetsOptimization.prototype.apply = function (scene, optimizer) {
  100084. scene.renderTargetsEnabled = optimizer.isInImprovementMode;
  100085. return true;
  100086. };
  100087. return RenderTargetsOptimization;
  100088. }(SceneOptimization));
  100089. /**
  100090. * Defines an optimization used to merge meshes with compatible materials
  100091. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100092. */
  100093. var MergeMeshesOptimization = /** @class */ (function (_super) {
  100094. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MergeMeshesOptimization, _super);
  100095. function MergeMeshesOptimization() {
  100096. var _this = _super !== null && _super.apply(this, arguments) || this;
  100097. _this._canBeMerged = function (abstractMesh) {
  100098. if (!(abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"])) {
  100099. return false;
  100100. }
  100101. var mesh = abstractMesh;
  100102. if (mesh.isDisposed()) {
  100103. return false;
  100104. }
  100105. if (!mesh.isVisible || !mesh.isEnabled()) {
  100106. return false;
  100107. }
  100108. if (mesh.instances.length > 0) {
  100109. return false;
  100110. }
  100111. if (mesh.skeleton || mesh.hasLODLevels) {
  100112. return false;
  100113. }
  100114. return true;
  100115. };
  100116. return _this;
  100117. }
  100118. Object.defineProperty(MergeMeshesOptimization, "UpdateSelectionTree", {
  100119. /**
  100120. * Gets or sets a boolean which defines if optimization octree has to be updated
  100121. */
  100122. get: function () {
  100123. return MergeMeshesOptimization._UpdateSelectionTree;
  100124. },
  100125. /**
  100126. * Gets or sets a boolean which defines if optimization octree has to be updated
  100127. */
  100128. set: function (value) {
  100129. MergeMeshesOptimization._UpdateSelectionTree = value;
  100130. },
  100131. enumerable: true,
  100132. configurable: true
  100133. });
  100134. /**
  100135. * Gets a string describing the action executed by the current optimization
  100136. * @return description string
  100137. */
  100138. MergeMeshesOptimization.prototype.getDescription = function () {
  100139. return "Merging similar meshes together";
  100140. };
  100141. /**
  100142. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  100143. * @param scene defines the current scene where to apply this optimization
  100144. * @param optimizer defines the current optimizer
  100145. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  100146. * @returns true if everything that can be done was applied
  100147. */
  100148. MergeMeshesOptimization.prototype.apply = function (scene, optimizer, updateSelectionTree) {
  100149. var globalPool = scene.meshes.slice(0);
  100150. var globalLength = globalPool.length;
  100151. for (var index = 0; index < globalLength; index++) {
  100152. var currentPool = new Array();
  100153. var current = globalPool[index];
  100154. // Checks
  100155. if (!this._canBeMerged(current)) {
  100156. continue;
  100157. }
  100158. currentPool.push(current);
  100159. // Find compatible meshes
  100160. for (var subIndex = index + 1; subIndex < globalLength; subIndex++) {
  100161. var otherMesh = globalPool[subIndex];
  100162. if (!this._canBeMerged(otherMesh)) {
  100163. continue;
  100164. }
  100165. if (otherMesh.material !== current.material) {
  100166. continue;
  100167. }
  100168. if (otherMesh.checkCollisions !== current.checkCollisions) {
  100169. continue;
  100170. }
  100171. currentPool.push(otherMesh);
  100172. globalLength--;
  100173. globalPool.splice(subIndex, 1);
  100174. subIndex--;
  100175. }
  100176. if (currentPool.length < 2) {
  100177. continue;
  100178. }
  100179. // Merge meshes
  100180. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].MergeMeshes(currentPool, undefined, true);
  100181. }
  100182. // Call the octree system optimization if it is defined.
  100183. var sceneAsAny = scene;
  100184. if (sceneAsAny.createOrUpdateSelectionOctree) {
  100185. if (updateSelectionTree != undefined) {
  100186. if (updateSelectionTree) {
  100187. sceneAsAny.createOrUpdateSelectionOctree();
  100188. }
  100189. }
  100190. else if (MergeMeshesOptimization.UpdateSelectionTree) {
  100191. sceneAsAny.createOrUpdateSelectionOctree();
  100192. }
  100193. }
  100194. return true;
  100195. };
  100196. MergeMeshesOptimization._UpdateSelectionTree = false;
  100197. return MergeMeshesOptimization;
  100198. }(SceneOptimization));
  100199. /**
  100200. * Defines a list of options used by SceneOptimizer
  100201. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100202. */
  100203. var SceneOptimizerOptions = /** @class */ (function () {
  100204. /**
  100205. * Creates a new list of options used by SceneOptimizer
  100206. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  100207. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  100208. */
  100209. function SceneOptimizerOptions(
  100210. /**
  100211. * Defines the target frame rate to reach (60 by default)
  100212. */
  100213. targetFrameRate,
  100214. /**
  100215. * Defines the interval between two checkes (2000ms by default)
  100216. */
  100217. trackerDuration) {
  100218. if (targetFrameRate === void 0) { targetFrameRate = 60; }
  100219. if (trackerDuration === void 0) { trackerDuration = 2000; }
  100220. this.targetFrameRate = targetFrameRate;
  100221. this.trackerDuration = trackerDuration;
  100222. /**
  100223. * Gets the list of optimizations to apply
  100224. */
  100225. this.optimizations = new Array();
  100226. }
  100227. /**
  100228. * Add a new optimization
  100229. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  100230. * @returns the current SceneOptimizerOptions
  100231. */
  100232. SceneOptimizerOptions.prototype.addOptimization = function (optimization) {
  100233. this.optimizations.push(optimization);
  100234. return this;
  100235. };
  100236. /**
  100237. * Add a new custom optimization
  100238. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  100239. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  100240. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  100241. * @returns the current SceneOptimizerOptions
  100242. */
  100243. SceneOptimizerOptions.prototype.addCustomOptimization = function (onApply, onGetDescription, priority) {
  100244. if (priority === void 0) { priority = 0; }
  100245. var optimization = new CustomOptimization(priority);
  100246. optimization.onApply = onApply;
  100247. optimization.onGetDescription = onGetDescription;
  100248. this.optimizations.push(optimization);
  100249. return this;
  100250. };
  100251. /**
  100252. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  100253. * @param targetFrameRate defines the target frame rate (60 by default)
  100254. * @returns a SceneOptimizerOptions object
  100255. */
  100256. SceneOptimizerOptions.LowDegradationAllowed = function (targetFrameRate) {
  100257. var result = new SceneOptimizerOptions(targetFrameRate);
  100258. var priority = 0;
  100259. result.addOptimization(new MergeMeshesOptimization(priority));
  100260. result.addOptimization(new ShadowsOptimization(priority));
  100261. result.addOptimization(new LensFlaresOptimization(priority));
  100262. // Next priority
  100263. priority++;
  100264. result.addOptimization(new PostProcessesOptimization(priority));
  100265. result.addOptimization(new ParticlesOptimization(priority));
  100266. // Next priority
  100267. priority++;
  100268. result.addOptimization(new TextureOptimization(priority, 1024));
  100269. return result;
  100270. };
  100271. /**
  100272. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  100273. * @param targetFrameRate defines the target frame rate (60 by default)
  100274. * @returns a SceneOptimizerOptions object
  100275. */
  100276. SceneOptimizerOptions.ModerateDegradationAllowed = function (targetFrameRate) {
  100277. var result = new SceneOptimizerOptions(targetFrameRate);
  100278. var priority = 0;
  100279. result.addOptimization(new MergeMeshesOptimization(priority));
  100280. result.addOptimization(new ShadowsOptimization(priority));
  100281. result.addOptimization(new LensFlaresOptimization(priority));
  100282. // Next priority
  100283. priority++;
  100284. result.addOptimization(new PostProcessesOptimization(priority));
  100285. result.addOptimization(new ParticlesOptimization(priority));
  100286. // Next priority
  100287. priority++;
  100288. result.addOptimization(new TextureOptimization(priority, 512));
  100289. // Next priority
  100290. priority++;
  100291. result.addOptimization(new RenderTargetsOptimization(priority));
  100292. // Next priority
  100293. priority++;
  100294. result.addOptimization(new HardwareScalingOptimization(priority, 2));
  100295. return result;
  100296. };
  100297. /**
  100298. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  100299. * @param targetFrameRate defines the target frame rate (60 by default)
  100300. * @returns a SceneOptimizerOptions object
  100301. */
  100302. SceneOptimizerOptions.HighDegradationAllowed = function (targetFrameRate) {
  100303. var result = new SceneOptimizerOptions(targetFrameRate);
  100304. var priority = 0;
  100305. result.addOptimization(new MergeMeshesOptimization(priority));
  100306. result.addOptimization(new ShadowsOptimization(priority));
  100307. result.addOptimization(new LensFlaresOptimization(priority));
  100308. // Next priority
  100309. priority++;
  100310. result.addOptimization(new PostProcessesOptimization(priority));
  100311. result.addOptimization(new ParticlesOptimization(priority));
  100312. // Next priority
  100313. priority++;
  100314. result.addOptimization(new TextureOptimization(priority, 256));
  100315. // Next priority
  100316. priority++;
  100317. result.addOptimization(new RenderTargetsOptimization(priority));
  100318. // Next priority
  100319. priority++;
  100320. result.addOptimization(new HardwareScalingOptimization(priority, 4));
  100321. return result;
  100322. };
  100323. return SceneOptimizerOptions;
  100324. }());
  100325. /**
  100326. * Class used to run optimizations in order to reach a target frame rate
  100327. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100328. */
  100329. var SceneOptimizer = /** @class */ (function () {
  100330. /**
  100331. * Creates a new SceneOptimizer
  100332. * @param scene defines the scene to work on
  100333. * @param options defines the options to use with the SceneOptimizer
  100334. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  100335. * @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)
  100336. */
  100337. function SceneOptimizer(scene, options, autoGeneratePriorities, improvementMode) {
  100338. if (autoGeneratePriorities === void 0) { autoGeneratePriorities = true; }
  100339. if (improvementMode === void 0) { improvementMode = false; }
  100340. var _this = this;
  100341. this._isRunning = false;
  100342. this._currentPriorityLevel = 0;
  100343. this._targetFrameRate = 60;
  100344. this._trackerDuration = 2000;
  100345. this._currentFrameRate = 0;
  100346. this._improvementMode = false;
  100347. /**
  100348. * Defines an observable called when the optimizer reaches the target frame rate
  100349. */
  100350. this.onSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  100351. /**
  100352. * Defines an observable called when the optimizer enables an optimization
  100353. */
  100354. this.onNewOptimizationAppliedObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  100355. /**
  100356. * Defines an observable called when the optimizer is not able to reach the target frame rate
  100357. */
  100358. this.onFailureObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  100359. if (!options) {
  100360. this._options = new SceneOptimizerOptions();
  100361. }
  100362. else {
  100363. this._options = options;
  100364. }
  100365. if (this._options.targetFrameRate) {
  100366. this._targetFrameRate = this._options.targetFrameRate;
  100367. }
  100368. if (this._options.trackerDuration) {
  100369. this._trackerDuration = this._options.trackerDuration;
  100370. }
  100371. if (autoGeneratePriorities) {
  100372. var priority = 0;
  100373. for (var _i = 0, _a = this._options.optimizations; _i < _a.length; _i++) {
  100374. var optim = _a[_i];
  100375. optim.priority = priority++;
  100376. }
  100377. }
  100378. this._improvementMode = improvementMode;
  100379. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene;
  100380. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  100381. _this._sceneDisposeObserver = null;
  100382. _this.dispose();
  100383. });
  100384. }
  100385. Object.defineProperty(SceneOptimizer.prototype, "isInImprovementMode", {
  100386. /**
  100387. * Gets a boolean indicating if the optimizer is in improvement mode
  100388. */
  100389. get: function () {
  100390. return this._improvementMode;
  100391. },
  100392. enumerable: true,
  100393. configurable: true
  100394. });
  100395. Object.defineProperty(SceneOptimizer.prototype, "currentPriorityLevel", {
  100396. /**
  100397. * Gets the current priority level (0 at start)
  100398. */
  100399. get: function () {
  100400. return this._currentPriorityLevel;
  100401. },
  100402. enumerable: true,
  100403. configurable: true
  100404. });
  100405. Object.defineProperty(SceneOptimizer.prototype, "currentFrameRate", {
  100406. /**
  100407. * Gets the current frame rate checked by the SceneOptimizer
  100408. */
  100409. get: function () {
  100410. return this._currentFrameRate;
  100411. },
  100412. enumerable: true,
  100413. configurable: true
  100414. });
  100415. Object.defineProperty(SceneOptimizer.prototype, "targetFrameRate", {
  100416. /**
  100417. * Gets or sets the current target frame rate (60 by default)
  100418. */
  100419. get: function () {
  100420. return this._targetFrameRate;
  100421. },
  100422. /**
  100423. * Gets or sets the current target frame rate (60 by default)
  100424. */
  100425. set: function (value) {
  100426. this._targetFrameRate = value;
  100427. },
  100428. enumerable: true,
  100429. configurable: true
  100430. });
  100431. Object.defineProperty(SceneOptimizer.prototype, "trackerDuration", {
  100432. /**
  100433. * Gets or sets the current interval between two checks (every 2000ms by default)
  100434. */
  100435. get: function () {
  100436. return this._trackerDuration;
  100437. },
  100438. /**
  100439. * Gets or sets the current interval between two checks (every 2000ms by default)
  100440. */
  100441. set: function (value) {
  100442. this._trackerDuration = value;
  100443. },
  100444. enumerable: true,
  100445. configurable: true
  100446. });
  100447. Object.defineProperty(SceneOptimizer.prototype, "optimizations", {
  100448. /**
  100449. * Gets the list of active optimizations
  100450. */
  100451. get: function () {
  100452. return this._options.optimizations;
  100453. },
  100454. enumerable: true,
  100455. configurable: true
  100456. });
  100457. /**
  100458. * Stops the current optimizer
  100459. */
  100460. SceneOptimizer.prototype.stop = function () {
  100461. this._isRunning = false;
  100462. };
  100463. /**
  100464. * Reset the optimizer to initial step (current priority level = 0)
  100465. */
  100466. SceneOptimizer.prototype.reset = function () {
  100467. this._currentPriorityLevel = 0;
  100468. };
  100469. /**
  100470. * Start the optimizer. By default it will try to reach a specific framerate
  100471. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  100472. */
  100473. SceneOptimizer.prototype.start = function () {
  100474. var _this = this;
  100475. if (this._isRunning) {
  100476. return;
  100477. }
  100478. this._isRunning = true;
  100479. // Let's wait for the scene to be ready before running our check
  100480. this._scene.executeWhenReady(function () {
  100481. setTimeout(function () {
  100482. _this._checkCurrentState();
  100483. }, _this._trackerDuration);
  100484. });
  100485. };
  100486. SceneOptimizer.prototype._checkCurrentState = function () {
  100487. var _this = this;
  100488. if (!this._isRunning) {
  100489. return;
  100490. }
  100491. var scene = this._scene;
  100492. var options = this._options;
  100493. this._currentFrameRate = Math.round(scene.getEngine().getFps());
  100494. if (this._improvementMode && this._currentFrameRate <= this._targetFrameRate ||
  100495. !this._improvementMode && this._currentFrameRate >= this._targetFrameRate) {
  100496. this._isRunning = false;
  100497. this.onSuccessObservable.notifyObservers(this);
  100498. return;
  100499. }
  100500. // Apply current level of optimizations
  100501. var allDone = true;
  100502. var noOptimizationApplied = true;
  100503. for (var index = 0; index < options.optimizations.length; index++) {
  100504. var optimization = options.optimizations[index];
  100505. if (optimization.priority === this._currentPriorityLevel) {
  100506. noOptimizationApplied = false;
  100507. allDone = allDone && optimization.apply(scene, this);
  100508. this.onNewOptimizationAppliedObservable.notifyObservers(optimization);
  100509. }
  100510. }
  100511. // If no optimization was applied, this is a failure :(
  100512. if (noOptimizationApplied) {
  100513. this._isRunning = false;
  100514. this.onFailureObservable.notifyObservers(this);
  100515. return;
  100516. }
  100517. // If all optimizations were done, move to next level
  100518. if (allDone) {
  100519. this._currentPriorityLevel++;
  100520. }
  100521. // Let's the system running for a specific amount of time before checking FPS
  100522. scene.executeWhenReady(function () {
  100523. setTimeout(function () {
  100524. _this._checkCurrentState();
  100525. }, _this._trackerDuration);
  100526. });
  100527. };
  100528. /**
  100529. * Release all resources
  100530. */
  100531. SceneOptimizer.prototype.dispose = function () {
  100532. this.stop();
  100533. this.onSuccessObservable.clear();
  100534. this.onFailureObservable.clear();
  100535. this.onNewOptimizationAppliedObservable.clear();
  100536. if (this._sceneDisposeObserver) {
  100537. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  100538. }
  100539. };
  100540. /**
  100541. * Helper function to create a SceneOptimizer with one single line of code
  100542. * @param scene defines the scene to work on
  100543. * @param options defines the options to use with the SceneOptimizer
  100544. * @param onSuccess defines a callback to call on success
  100545. * @param onFailure defines a callback to call on failure
  100546. * @returns the new SceneOptimizer object
  100547. */
  100548. SceneOptimizer.OptimizeAsync = function (scene, options, onSuccess, onFailure) {
  100549. var optimizer = new SceneOptimizer(scene, options || SceneOptimizerOptions.ModerateDegradationAllowed(), false);
  100550. if (onSuccess) {
  100551. optimizer.onSuccessObservable.add(function () {
  100552. onSuccess();
  100553. });
  100554. }
  100555. if (onFailure) {
  100556. optimizer.onFailureObservable.add(function () {
  100557. onFailure();
  100558. });
  100559. }
  100560. optimizer.start();
  100561. return optimizer;
  100562. };
  100563. return SceneOptimizer;
  100564. }());
  100565. /***/ }),
  100566. /***/ "./Misc/sceneSerializer.ts":
  100567. /*!*********************************!*\
  100568. !*** ./Misc/sceneSerializer.ts ***!
  100569. \*********************************/
  100570. /*! exports provided: SceneSerializer */
  100571. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100572. "use strict";
  100573. __webpack_require__.r(__webpack_exports__);
  100574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return SceneSerializer; });
  100575. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  100576. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  100577. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  100578. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  100579. var serializedGeometries = [];
  100580. var serializeGeometry = function (geometry, serializationGeometries) {
  100581. if (serializedGeometries[geometry.id]) {
  100582. return;
  100583. }
  100584. if (geometry.doNotSerialize) {
  100585. return;
  100586. }
  100587. serializationGeometries.vertexData.push(geometry.serializeVerticeData());
  100588. serializedGeometries[geometry.id] = true;
  100589. };
  100590. var serializeMesh = function (mesh, serializationScene) {
  100591. var serializationObject = {};
  100592. // Geometry
  100593. var geometry = mesh._geometry;
  100594. if (geometry) {
  100595. if (!mesh.getScene().getGeometryByID(geometry.id)) {
  100596. // 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
  100597. serializeGeometry(geometry, serializationScene.geometries);
  100598. }
  100599. }
  100600. // Custom
  100601. if (mesh.serialize) {
  100602. mesh.serialize(serializationObject);
  100603. }
  100604. return serializationObject;
  100605. };
  100606. var finalizeSingleMesh = function (mesh, serializationObject) {
  100607. //only works if the mesh is already loaded
  100608. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  100609. //serialize material
  100610. if (mesh.material) {
  100611. if (mesh.material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__["MultiMaterial"]) {
  100612. serializationObject.multiMaterials = serializationObject.multiMaterials || [];
  100613. serializationObject.materials = serializationObject.materials || [];
  100614. if (!serializationObject.multiMaterials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  100615. serializationObject.multiMaterials.push(mesh.material.serialize());
  100616. var _loop_1 = function (submaterial) {
  100617. if (submaterial) {
  100618. if (!serializationObject.materials.some(function (mat) { return (mat.id === submaterial.id); })) {
  100619. serializationObject.materials.push(submaterial.serialize());
  100620. }
  100621. }
  100622. };
  100623. for (var _i = 0, _a = mesh.material.subMaterials; _i < _a.length; _i++) {
  100624. var submaterial = _a[_i];
  100625. _loop_1(submaterial);
  100626. }
  100627. }
  100628. }
  100629. else {
  100630. serializationObject.materials = serializationObject.materials || [];
  100631. if (!serializationObject.materials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  100632. serializationObject.materials.push(mesh.material.serialize());
  100633. }
  100634. }
  100635. }
  100636. //serialize geometry
  100637. var geometry = mesh._geometry;
  100638. if (geometry) {
  100639. if (!serializationObject.geometries) {
  100640. serializationObject.geometries = {};
  100641. serializationObject.geometries.boxes = [];
  100642. serializationObject.geometries.spheres = [];
  100643. serializationObject.geometries.cylinders = [];
  100644. serializationObject.geometries.toruses = [];
  100645. serializationObject.geometries.grounds = [];
  100646. serializationObject.geometries.planes = [];
  100647. serializationObject.geometries.torusKnots = [];
  100648. serializationObject.geometries.vertexData = [];
  100649. }
  100650. serializeGeometry(geometry, serializationObject.geometries);
  100651. }
  100652. // Skeletons
  100653. if (mesh.skeleton) {
  100654. serializationObject.skeletons = serializationObject.skeletons || [];
  100655. serializationObject.skeletons.push(mesh.skeleton.serialize());
  100656. }
  100657. //serialize the actual mesh
  100658. serializationObject.meshes = serializationObject.meshes || [];
  100659. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  100660. }
  100661. };
  100662. /**
  100663. * Class used to serialize a scene into a string
  100664. */
  100665. var SceneSerializer = /** @class */ (function () {
  100666. function SceneSerializer() {
  100667. }
  100668. /**
  100669. * Clear cache used by a previous serialization
  100670. */
  100671. SceneSerializer.ClearCache = function () {
  100672. serializedGeometries = [];
  100673. };
  100674. /**
  100675. * Serialize a scene into a JSON compatible object
  100676. * @param scene defines the scene to serialize
  100677. * @returns a JSON compatible object
  100678. */
  100679. SceneSerializer.Serialize = function (scene) {
  100680. var serializationObject = {};
  100681. SceneSerializer.ClearCache();
  100682. // Scene
  100683. serializationObject.useDelayedTextureLoading = scene.useDelayedTextureLoading;
  100684. serializationObject.autoClear = scene.autoClear;
  100685. serializationObject.clearColor = scene.clearColor.asArray();
  100686. serializationObject.ambientColor = scene.ambientColor.asArray();
  100687. serializationObject.gravity = scene.gravity.asArray();
  100688. serializationObject.collisionsEnabled = scene.collisionsEnabled;
  100689. // Fog
  100690. if (scene.fogMode && scene.fogMode !== 0) {
  100691. serializationObject.fogMode = scene.fogMode;
  100692. serializationObject.fogColor = scene.fogColor.asArray();
  100693. serializationObject.fogStart = scene.fogStart;
  100694. serializationObject.fogEnd = scene.fogEnd;
  100695. serializationObject.fogDensity = scene.fogDensity;
  100696. }
  100697. //Physics
  100698. if (scene.isPhysicsEnabled()) {
  100699. var physicEngine = scene.getPhysicsEngine();
  100700. if (physicEngine) {
  100701. serializationObject.physicsEnabled = true;
  100702. serializationObject.physicsGravity = physicEngine.gravity.asArray();
  100703. serializationObject.physicsEngine = physicEngine.getPhysicsPluginName();
  100704. }
  100705. }
  100706. // Metadata
  100707. if (scene.metadata) {
  100708. serializationObject.metadata = scene.metadata;
  100709. }
  100710. // Morph targets
  100711. serializationObject.morphTargetManagers = [];
  100712. for (var _i = 0, _a = scene.meshes; _i < _a.length; _i++) {
  100713. var abstractMesh = _a[_i];
  100714. var manager = abstractMesh.morphTargetManager;
  100715. if (manager) {
  100716. serializationObject.morphTargetManagers.push(manager.serialize());
  100717. }
  100718. }
  100719. // Lights
  100720. serializationObject.lights = [];
  100721. var index;
  100722. var light;
  100723. for (index = 0; index < scene.lights.length; index++) {
  100724. light = scene.lights[index];
  100725. if (!light.doNotSerialize) {
  100726. serializationObject.lights.push(light.serialize());
  100727. }
  100728. }
  100729. // Cameras
  100730. serializationObject.cameras = [];
  100731. for (index = 0; index < scene.cameras.length; index++) {
  100732. var camera = scene.cameras[index];
  100733. if (!camera.doNotSerialize) {
  100734. serializationObject.cameras.push(camera.serialize());
  100735. }
  100736. }
  100737. if (scene.activeCamera) {
  100738. serializationObject.activeCameraID = scene.activeCamera.id;
  100739. }
  100740. // Animations
  100741. _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"].AppendSerializedAnimations(scene, serializationObject);
  100742. // Reflection probes
  100743. if (scene.reflectionProbes && scene.reflectionProbes.length > 0) {
  100744. serializationObject.reflectionProbes = [];
  100745. for (index = 0; index < scene.reflectionProbes.length; index++) {
  100746. var reflectionProbe = scene.reflectionProbes[index];
  100747. serializationObject.reflectionProbes.push(reflectionProbe.serialize());
  100748. }
  100749. }
  100750. // Materials
  100751. serializationObject.materials = [];
  100752. serializationObject.multiMaterials = [];
  100753. var material;
  100754. for (index = 0; index < scene.materials.length; index++) {
  100755. material = scene.materials[index];
  100756. if (!material.doNotSerialize) {
  100757. serializationObject.materials.push(material.serialize());
  100758. }
  100759. }
  100760. // MultiMaterials
  100761. serializationObject.multiMaterials = [];
  100762. for (index = 0; index < scene.multiMaterials.length; index++) {
  100763. var multiMaterial = scene.multiMaterials[index];
  100764. serializationObject.multiMaterials.push(multiMaterial.serialize());
  100765. }
  100766. // Environment texture
  100767. if (scene.environmentTexture) {
  100768. serializationObject.environmentTexture = scene.environmentTexture.name;
  100769. }
  100770. // Skeletons
  100771. serializationObject.skeletons = [];
  100772. for (index = 0; index < scene.skeletons.length; index++) {
  100773. var skeleton = scene.skeletons[index];
  100774. if (!skeleton.doNotSerialize) {
  100775. serializationObject.skeletons.push(skeleton.serialize());
  100776. }
  100777. }
  100778. // Transform nodes
  100779. serializationObject.transformNodes = [];
  100780. for (index = 0; index < scene.transformNodes.length; index++) {
  100781. serializationObject.transformNodes.push(scene.transformNodes[index].serialize());
  100782. }
  100783. // Geometries
  100784. serializationObject.geometries = {};
  100785. serializationObject.geometries.boxes = [];
  100786. serializationObject.geometries.spheres = [];
  100787. serializationObject.geometries.cylinders = [];
  100788. serializationObject.geometries.toruses = [];
  100789. serializationObject.geometries.grounds = [];
  100790. serializationObject.geometries.planes = [];
  100791. serializationObject.geometries.torusKnots = [];
  100792. serializationObject.geometries.vertexData = [];
  100793. serializedGeometries = [];
  100794. var geometries = scene.getGeometries();
  100795. for (index = 0; index < geometries.length; index++) {
  100796. var geometry = geometries[index];
  100797. if (geometry.isReady()) {
  100798. serializeGeometry(geometry, serializationObject.geometries);
  100799. }
  100800. }
  100801. // Meshes
  100802. serializationObject.meshes = [];
  100803. for (index = 0; index < scene.meshes.length; index++) {
  100804. var abstractMesh = scene.meshes[index];
  100805. if (abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]) {
  100806. var mesh = abstractMesh;
  100807. if (!mesh.doNotSerialize) {
  100808. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  100809. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  100810. }
  100811. }
  100812. }
  100813. }
  100814. // Particles Systems
  100815. serializationObject.particleSystems = [];
  100816. for (index = 0; index < scene.particleSystems.length; index++) {
  100817. serializationObject.particleSystems.push(scene.particleSystems[index].serialize());
  100818. }
  100819. // Action Manager
  100820. if (scene.actionManager) {
  100821. serializationObject.actions = scene.actionManager.serialize("scene");
  100822. }
  100823. // Components
  100824. for (var _b = 0, _c = scene._serializableComponents; _b < _c.length; _b++) {
  100825. var component = _c[_b];
  100826. component.serialize(serializationObject);
  100827. }
  100828. return serializationObject;
  100829. };
  100830. /**
  100831. * Serialize a mesh into a JSON compatible object
  100832. * @param toSerialize defines the mesh to serialize
  100833. * @param withParents defines if parents must be serialized as well
  100834. * @param withChildren defines if children must be serialized as well
  100835. * @returns a JSON compatible object
  100836. */
  100837. SceneSerializer.SerializeMesh = function (toSerialize /* Mesh || Mesh[] */, withParents, withChildren) {
  100838. if (withParents === void 0) { withParents = false; }
  100839. if (withChildren === void 0) { withChildren = false; }
  100840. var serializationObject = {};
  100841. SceneSerializer.ClearCache();
  100842. toSerialize = (toSerialize instanceof Array) ? toSerialize : [toSerialize];
  100843. if (withParents || withChildren) {
  100844. //deliberate for loop! not for each, appended should be processed as well.
  100845. for (var i = 0; i < toSerialize.length; ++i) {
  100846. if (withChildren) {
  100847. toSerialize[i].getDescendants().forEach(function (node) {
  100848. if (node instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"] && (toSerialize.indexOf(node) < 0)) {
  100849. toSerialize.push(node);
  100850. }
  100851. });
  100852. }
  100853. //make sure the array doesn't contain the object already
  100854. if (withParents && toSerialize[i].parent && (toSerialize.indexOf(toSerialize[i].parent) < 0)) {
  100855. toSerialize.push(toSerialize[i].parent);
  100856. }
  100857. }
  100858. }
  100859. toSerialize.forEach(function (mesh) {
  100860. finalizeSingleMesh(mesh, serializationObject);
  100861. });
  100862. return serializationObject;
  100863. };
  100864. return SceneSerializer;
  100865. }());
  100866. /***/ }),
  100867. /***/ "./Misc/screenshotTools.ts":
  100868. /*!*********************************!*\
  100869. !*** ./Misc/screenshotTools.ts ***!
  100870. \*********************************/
  100871. /*! exports provided: ScreenshotTools */
  100872. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100873. "use strict";
  100874. __webpack_require__.r(__webpack_exports__);
  100875. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return ScreenshotTools; });
  100876. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  100877. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  100878. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  100879. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  100880. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  100881. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  100882. /**
  100883. * Class containing a set of static utilities functions for screenshots
  100884. */
  100885. var ScreenshotTools = /** @class */ (function () {
  100886. function ScreenshotTools() {
  100887. }
  100888. /**
  100889. * Captures a screenshot of the current rendering
  100890. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100891. * @param engine defines the rendering engine
  100892. * @param camera defines the source camera
  100893. * @param size This parameter can be set to a single number or to an object with the
  100894. * following (optional) properties: precision, width, height. If a single number is passed,
  100895. * it will be used for both width and height. If an object is passed, the screenshot size
  100896. * will be derived from the parameters. The precision property is a multiplier allowing
  100897. * rendering at a higher or lower resolution
  100898. * @param successCallback defines the callback receives a single parameter which contains the
  100899. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100900. * src parameter of an <img> to display it
  100901. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  100902. * Check your browser for supported MIME types
  100903. */
  100904. ScreenshotTools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  100905. if (mimeType === void 0) { mimeType = "image/png"; }
  100906. var width;
  100907. var height;
  100908. // If a precision value is specified
  100909. if (size.precision) {
  100910. width = Math.round(engine.getRenderWidth() * size.precision);
  100911. height = Math.round(width / engine.getAspectRatio(camera));
  100912. }
  100913. else if (size.width && size.height) {
  100914. width = size.width;
  100915. height = size.height;
  100916. }
  100917. //If passing only width, computing height to keep display canvas ratio.
  100918. else if (size.width && !size.height) {
  100919. width = size.width;
  100920. height = Math.round(width / engine.getAspectRatio(camera));
  100921. }
  100922. //If passing only height, computing width to keep display canvas ratio.
  100923. else if (size.height && !size.width) {
  100924. height = size.height;
  100925. width = Math.round(height * engine.getAspectRatio(camera));
  100926. }
  100927. //Assuming here that "size" parameter is a number
  100928. else if (!isNaN(size)) {
  100929. height = size;
  100930. width = size;
  100931. }
  100932. else {
  100933. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  100934. return;
  100935. }
  100936. if (!_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas) {
  100937. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas = document.createElement('canvas');
  100938. }
  100939. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.width = width;
  100940. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.height = height;
  100941. var renderContext = _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.getContext("2d");
  100942. var ratio = engine.getRenderWidth() / engine.getRenderHeight();
  100943. var newWidth = width;
  100944. var newHeight = newWidth / ratio;
  100945. if (newHeight > height) {
  100946. newHeight = height;
  100947. newWidth = newHeight * ratio;
  100948. }
  100949. var offsetX = Math.max(0, width - newWidth) / 2;
  100950. var offsetY = Math.max(0, height - newHeight) / 2;
  100951. var renderingCanvas = engine.getRenderingCanvas();
  100952. if (renderContext && renderingCanvas) {
  100953. renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);
  100954. }
  100955. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].EncodeScreenshotCanvasData(successCallback, mimeType);
  100956. };
  100957. /**
  100958. * Generates an image screenshot from the specified camera.
  100959. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100960. * @param engine The engine to use for rendering
  100961. * @param camera The camera to use for rendering
  100962. * @param size This parameter can be set to a single number or to an object with the
  100963. * following (optional) properties: precision, width, height. If a single number is passed,
  100964. * it will be used for both width and height. If an object is passed, the screenshot size
  100965. * will be derived from the parameters. The precision property is a multiplier allowing
  100966. * rendering at a higher or lower resolution
  100967. * @param successCallback The callback receives a single parameter which contains the
  100968. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100969. * src parameter of an <img> to display it
  100970. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100971. * Check your browser for supported MIME types
  100972. * @param samples Texture samples (default: 1)
  100973. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100974. * @param fileName A name for for the downloaded file.
  100975. */
  100976. ScreenshotTools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  100977. if (mimeType === void 0) { mimeType = "image/png"; }
  100978. if (samples === void 0) { samples = 1; }
  100979. if (antialiasing === void 0) { antialiasing = false; }
  100980. var width;
  100981. var height;
  100982. //If a precision value is specified
  100983. if (size.precision) {
  100984. width = Math.round(engine.getRenderWidth() * size.precision);
  100985. height = Math.round(width / engine.getAspectRatio(camera));
  100986. size = { width: width, height: height };
  100987. }
  100988. else if (size.width && size.height) {
  100989. width = size.width;
  100990. height = size.height;
  100991. }
  100992. //If passing only width, computing height to keep display canvas ratio.
  100993. else if (size.width && !size.height) {
  100994. width = size.width;
  100995. height = Math.round(width / engine.getAspectRatio(camera));
  100996. size = { width: width, height: height };
  100997. }
  100998. //If passing only height, computing width to keep display canvas ratio.
  100999. else if (size.height && !size.width) {
  101000. height = size.height;
  101001. width = Math.round(height * engine.getAspectRatio(camera));
  101002. size = { width: width, height: height };
  101003. }
  101004. //Assuming here that "size" parameter is a number
  101005. else if (!isNaN(size)) {
  101006. height = size;
  101007. width = size;
  101008. }
  101009. else {
  101010. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  101011. return;
  101012. }
  101013. var scene = camera.getScene();
  101014. var previousCamera = null;
  101015. if (scene.activeCamera !== camera) {
  101016. previousCamera = scene.activeCamera;
  101017. scene.activeCamera = camera;
  101018. }
  101019. var renderCanvas = engine.getRenderingCanvas();
  101020. if (!renderCanvas) {
  101021. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("No rendering canvas found !");
  101022. return;
  101023. }
  101024. var originalSize = { width: renderCanvas.width, height: renderCanvas.height };
  101025. engine.setSize(width, height);
  101026. scene.render();
  101027. // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)
  101028. 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);
  101029. texture.renderList = null;
  101030. texture.samples = samples;
  101031. if (antialiasing) {
  101032. texture.addPostProcess(new _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__["FxaaPostProcess"]('antialiasing', 1.0, scene.activeCamera));
  101033. }
  101034. texture.onAfterRenderObservable.add(function () {
  101035. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].DumpFramebuffer(width, height, engine, successCallback, mimeType, fileName);
  101036. });
  101037. scene.incrementRenderId();
  101038. scene.resetCachedMaterial();
  101039. texture.render(true);
  101040. texture.dispose();
  101041. if (previousCamera) {
  101042. scene.activeCamera = previousCamera;
  101043. }
  101044. engine.setSize(originalSize.width, originalSize.height);
  101045. camera.getProjectionMatrix(true); // Force cache refresh;
  101046. };
  101047. return ScreenshotTools;
  101048. }());
  101049. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshot = ScreenshotTools.CreateScreenshot;
  101050. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshotUsingRenderTarget = ScreenshotTools.CreateScreenshotUsingRenderTarget;
  101051. /***/ }),
  101052. /***/ "./Misc/smartArray.ts":
  101053. /*!****************************!*\
  101054. !*** ./Misc/smartArray.ts ***!
  101055. \****************************/
  101056. /*! exports provided: SmartArray, SmartArrayNoDuplicate */
  101057. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101058. "use strict";
  101059. __webpack_require__.r(__webpack_exports__);
  101060. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return SmartArray; });
  101061. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return SmartArrayNoDuplicate; });
  101062. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  101063. /**
  101064. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  101065. */
  101066. var SmartArray = /** @class */ (function () {
  101067. /**
  101068. * Instantiates a Smart Array.
  101069. * @param capacity defines the default capacity of the array.
  101070. */
  101071. function SmartArray(capacity) {
  101072. /**
  101073. * The active length of the array.
  101074. */
  101075. this.length = 0;
  101076. this.data = new Array(capacity);
  101077. this._id = SmartArray._GlobalId++;
  101078. }
  101079. /**
  101080. * Pushes a value at the end of the active data.
  101081. * @param value defines the object to push in the array.
  101082. */
  101083. SmartArray.prototype.push = function (value) {
  101084. this.data[this.length++] = value;
  101085. if (this.length > this.data.length) {
  101086. this.data.length *= 2;
  101087. }
  101088. };
  101089. /**
  101090. * Iterates over the active data and apply the lambda to them.
  101091. * @param func defines the action to apply on each value.
  101092. */
  101093. SmartArray.prototype.forEach = function (func) {
  101094. for (var index = 0; index < this.length; index++) {
  101095. func(this.data[index]);
  101096. }
  101097. };
  101098. /**
  101099. * Sorts the full sets of data.
  101100. * @param compareFn defines the comparison function to apply.
  101101. */
  101102. SmartArray.prototype.sort = function (compareFn) {
  101103. this.data.sort(compareFn);
  101104. };
  101105. /**
  101106. * Resets the active data to an empty array.
  101107. */
  101108. SmartArray.prototype.reset = function () {
  101109. this.length = 0;
  101110. };
  101111. /**
  101112. * Releases all the data from the array as well as the array.
  101113. */
  101114. SmartArray.prototype.dispose = function () {
  101115. this.reset();
  101116. if (this.data) {
  101117. this.data.length = 0;
  101118. this.data = [];
  101119. }
  101120. };
  101121. /**
  101122. * Concats the active data with a given array.
  101123. * @param array defines the data to concatenate with.
  101124. */
  101125. SmartArray.prototype.concat = function (array) {
  101126. if (array.length === 0) {
  101127. return;
  101128. }
  101129. if (this.length + array.length > this.data.length) {
  101130. this.data.length = (this.length + array.length) * 2;
  101131. }
  101132. for (var index = 0; index < array.length; index++) {
  101133. this.data[this.length++] = (array.data || array)[index];
  101134. }
  101135. };
  101136. /**
  101137. * Returns the position of a value in the active data.
  101138. * @param value defines the value to find the index for
  101139. * @returns the index if found in the active data otherwise -1
  101140. */
  101141. SmartArray.prototype.indexOf = function (value) {
  101142. var position = this.data.indexOf(value);
  101143. if (position >= this.length) {
  101144. return -1;
  101145. }
  101146. return position;
  101147. };
  101148. /**
  101149. * Returns whether an element is part of the active data.
  101150. * @param value defines the value to look for
  101151. * @returns true if found in the active data otherwise false
  101152. */
  101153. SmartArray.prototype.contains = function (value) {
  101154. return this.indexOf(value) !== -1;
  101155. };
  101156. // Statics
  101157. SmartArray._GlobalId = 0;
  101158. return SmartArray;
  101159. }());
  101160. /**
  101161. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  101162. * The data in this array can only be present once
  101163. */
  101164. var SmartArrayNoDuplicate = /** @class */ (function (_super) {
  101165. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SmartArrayNoDuplicate, _super);
  101166. function SmartArrayNoDuplicate() {
  101167. var _this = _super !== null && _super.apply(this, arguments) || this;
  101168. _this._duplicateId = 0;
  101169. return _this;
  101170. }
  101171. /**
  101172. * Pushes a value at the end of the active data.
  101173. * THIS DOES NOT PREVENT DUPPLICATE DATA
  101174. * @param value defines the object to push in the array.
  101175. */
  101176. SmartArrayNoDuplicate.prototype.push = function (value) {
  101177. _super.prototype.push.call(this, value);
  101178. if (!value.__smartArrayFlags) {
  101179. value.__smartArrayFlags = {};
  101180. }
  101181. value.__smartArrayFlags[this._id] = this._duplicateId;
  101182. };
  101183. /**
  101184. * Pushes a value at the end of the active data.
  101185. * If the data is already present, it won t be added again
  101186. * @param value defines the object to push in the array.
  101187. * @returns true if added false if it was already present
  101188. */
  101189. SmartArrayNoDuplicate.prototype.pushNoDuplicate = function (value) {
  101190. if (value.__smartArrayFlags && value.__smartArrayFlags[this._id] === this._duplicateId) {
  101191. return false;
  101192. }
  101193. this.push(value);
  101194. return true;
  101195. };
  101196. /**
  101197. * Resets the active data to an empty array.
  101198. */
  101199. SmartArrayNoDuplicate.prototype.reset = function () {
  101200. _super.prototype.reset.call(this);
  101201. this._duplicateId++;
  101202. };
  101203. /**
  101204. * Concats the active data with a given array.
  101205. * This ensures no dupplicate will be present in the result.
  101206. * @param array defines the data to concatenate with.
  101207. */
  101208. SmartArrayNoDuplicate.prototype.concatWithNoDuplicate = function (array) {
  101209. if (array.length === 0) {
  101210. return;
  101211. }
  101212. if (this.length + array.length > this.data.length) {
  101213. this.data.length = (this.length + array.length) * 2;
  101214. }
  101215. for (var index = 0; index < array.length; index++) {
  101216. var item = (array.data || array)[index];
  101217. this.pushNoDuplicate(item);
  101218. }
  101219. };
  101220. return SmartArrayNoDuplicate;
  101221. }(SmartArray));
  101222. /***/ }),
  101223. /***/ "./Misc/stringDictionary.ts":
  101224. /*!**********************************!*\
  101225. !*** ./Misc/stringDictionary.ts ***!
  101226. \**********************************/
  101227. /*! exports provided: StringDictionary */
  101228. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101229. "use strict";
  101230. __webpack_require__.r(__webpack_exports__);
  101231. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return StringDictionary; });
  101232. /**
  101233. * This class implement a typical dictionary using a string as key and the generic type T as value.
  101234. * The underlying implementation relies on an associative array to ensure the best performances.
  101235. * The value can be anything including 'null' but except 'undefined'
  101236. */
  101237. var StringDictionary = /** @class */ (function () {
  101238. function StringDictionary() {
  101239. this._count = 0;
  101240. this._data = {};
  101241. }
  101242. /**
  101243. * This will clear this dictionary and copy the content from the 'source' one.
  101244. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  101245. * @param source the dictionary to take the content from and copy to this dictionary
  101246. */
  101247. StringDictionary.prototype.copyFrom = function (source) {
  101248. var _this = this;
  101249. this.clear();
  101250. source.forEach(function (t, v) { return _this.add(t, v); });
  101251. };
  101252. /**
  101253. * Get a value based from its key
  101254. * @param key the given key to get the matching value from
  101255. * @return the value if found, otherwise undefined is returned
  101256. */
  101257. StringDictionary.prototype.get = function (key) {
  101258. var val = this._data[key];
  101259. if (val !== undefined) {
  101260. return val;
  101261. }
  101262. return undefined;
  101263. };
  101264. /**
  101265. * Get a value from its key or add it if it doesn't exist.
  101266. * This method will ensure you that a given key/data will be present in the dictionary.
  101267. * @param key the given key to get the matching value from
  101268. * @param factory the factory that will create the value if the key is not present in the dictionary.
  101269. * The factory will only be invoked if there's no data for the given key.
  101270. * @return the value corresponding to the key.
  101271. */
  101272. StringDictionary.prototype.getOrAddWithFactory = function (key, factory) {
  101273. var val = this.get(key);
  101274. if (val !== undefined) {
  101275. return val;
  101276. }
  101277. val = factory(key);
  101278. if (val) {
  101279. this.add(key, val);
  101280. }
  101281. return val;
  101282. };
  101283. /**
  101284. * Get a value from its key if present in the dictionary otherwise add it
  101285. * @param key the key to get the value from
  101286. * @param val if there's no such key/value pair in the dictionary add it with this value
  101287. * @return the value corresponding to the key
  101288. */
  101289. StringDictionary.prototype.getOrAdd = function (key, val) {
  101290. var curVal = this.get(key);
  101291. if (curVal !== undefined) {
  101292. return curVal;
  101293. }
  101294. this.add(key, val);
  101295. return val;
  101296. };
  101297. /**
  101298. * Check if there's a given key in the dictionary
  101299. * @param key the key to check for
  101300. * @return true if the key is present, false otherwise
  101301. */
  101302. StringDictionary.prototype.contains = function (key) {
  101303. return this._data[key] !== undefined;
  101304. };
  101305. /**
  101306. * Add a new key and its corresponding value
  101307. * @param key the key to add
  101308. * @param value the value corresponding to the key
  101309. * @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
  101310. */
  101311. StringDictionary.prototype.add = function (key, value) {
  101312. if (this._data[key] !== undefined) {
  101313. return false;
  101314. }
  101315. this._data[key] = value;
  101316. ++this._count;
  101317. return true;
  101318. };
  101319. /**
  101320. * Update a specific value associated to a key
  101321. * @param key defines the key to use
  101322. * @param value defines the value to store
  101323. * @returns true if the value was updated (or false if the key was not found)
  101324. */
  101325. StringDictionary.prototype.set = function (key, value) {
  101326. if (this._data[key] === undefined) {
  101327. return false;
  101328. }
  101329. this._data[key] = value;
  101330. return true;
  101331. };
  101332. /**
  101333. * Get the element of the given key and remove it from the dictionary
  101334. * @param key defines the key to search
  101335. * @returns the value associated with the key or null if not found
  101336. */
  101337. StringDictionary.prototype.getAndRemove = function (key) {
  101338. var val = this.get(key);
  101339. if (val !== undefined) {
  101340. delete this._data[key];
  101341. --this._count;
  101342. return val;
  101343. }
  101344. return null;
  101345. };
  101346. /**
  101347. * Remove a key/value from the dictionary.
  101348. * @param key the key to remove
  101349. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  101350. */
  101351. StringDictionary.prototype.remove = function (key) {
  101352. if (this.contains(key)) {
  101353. delete this._data[key];
  101354. --this._count;
  101355. return true;
  101356. }
  101357. return false;
  101358. };
  101359. /**
  101360. * Clear the whole content of the dictionary
  101361. */
  101362. StringDictionary.prototype.clear = function () {
  101363. this._data = {};
  101364. this._count = 0;
  101365. };
  101366. Object.defineProperty(StringDictionary.prototype, "count", {
  101367. /**
  101368. * Gets the current count
  101369. */
  101370. get: function () {
  101371. return this._count;
  101372. },
  101373. enumerable: true,
  101374. configurable: true
  101375. });
  101376. /**
  101377. * Execute a callback on each key/val of the dictionary.
  101378. * Note that you can remove any element in this dictionary in the callback implementation
  101379. * @param callback the callback to execute on a given key/value pair
  101380. */
  101381. StringDictionary.prototype.forEach = function (callback) {
  101382. for (var cur in this._data) {
  101383. var val = this._data[cur];
  101384. callback(cur, val);
  101385. }
  101386. };
  101387. /**
  101388. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  101389. * If the callback returns null or undefined the method will iterate to the next key/value pair
  101390. * Note that you can remove any element in this dictionary in the callback implementation
  101391. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  101392. * @returns the first item
  101393. */
  101394. StringDictionary.prototype.first = function (callback) {
  101395. for (var cur in this._data) {
  101396. var val = this._data[cur];
  101397. var res = callback(cur, val);
  101398. if (res) {
  101399. return res;
  101400. }
  101401. }
  101402. return null;
  101403. };
  101404. return StringDictionary;
  101405. }());
  101406. /***/ }),
  101407. /***/ "./Misc/tags.ts":
  101408. /*!**********************!*\
  101409. !*** ./Misc/tags.ts ***!
  101410. \**********************/
  101411. /*! exports provided: Tags */
  101412. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101413. "use strict";
  101414. __webpack_require__.r(__webpack_exports__);
  101415. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return Tags; });
  101416. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  101417. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  101418. /**
  101419. * Class used to store custom tags
  101420. */
  101421. var Tags = /** @class */ (function () {
  101422. function Tags() {
  101423. }
  101424. /**
  101425. * Adds support for tags on the given object
  101426. * @param obj defines the object to use
  101427. */
  101428. Tags.EnableFor = function (obj) {
  101429. obj._tags = obj._tags || {};
  101430. obj.hasTags = function () {
  101431. return Tags.HasTags(obj);
  101432. };
  101433. obj.addTags = function (tagsString) {
  101434. return Tags.AddTagsTo(obj, tagsString);
  101435. };
  101436. obj.removeTags = function (tagsString) {
  101437. return Tags.RemoveTagsFrom(obj, tagsString);
  101438. };
  101439. obj.matchesTagsQuery = function (tagsQuery) {
  101440. return Tags.MatchesQuery(obj, tagsQuery);
  101441. };
  101442. };
  101443. /**
  101444. * Removes tags support
  101445. * @param obj defines the object to use
  101446. */
  101447. Tags.DisableFor = function (obj) {
  101448. delete obj._tags;
  101449. delete obj.hasTags;
  101450. delete obj.addTags;
  101451. delete obj.removeTags;
  101452. delete obj.matchesTagsQuery;
  101453. };
  101454. /**
  101455. * Gets a boolean indicating if the given object has tags
  101456. * @param obj defines the object to use
  101457. * @returns a boolean
  101458. */
  101459. Tags.HasTags = function (obj) {
  101460. if (!obj._tags) {
  101461. return false;
  101462. }
  101463. return !_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsEmpty(obj._tags);
  101464. };
  101465. /**
  101466. * Gets the tags available on a given object
  101467. * @param obj defines the object to use
  101468. * @param asString defines if the tags must be returned as a string instead of an array of strings
  101469. * @returns the tags
  101470. */
  101471. Tags.GetTags = function (obj, asString) {
  101472. if (asString === void 0) { asString = true; }
  101473. if (!obj._tags) {
  101474. return null;
  101475. }
  101476. if (asString) {
  101477. var tagsArray = [];
  101478. for (var tag in obj._tags) {
  101479. if (obj._tags.hasOwnProperty(tag) && obj._tags[tag] === true) {
  101480. tagsArray.push(tag);
  101481. }
  101482. }
  101483. return tagsArray.join(" ");
  101484. }
  101485. else {
  101486. return obj._tags;
  101487. }
  101488. };
  101489. /**
  101490. * Adds tags to an object
  101491. * @param obj defines the object to use
  101492. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  101493. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  101494. */
  101495. Tags.AddTagsTo = function (obj, tagsString) {
  101496. if (!tagsString) {
  101497. return;
  101498. }
  101499. if (typeof tagsString !== "string") {
  101500. return;
  101501. }
  101502. var tags = tagsString.split(" ");
  101503. tags.forEach(function (tag, index, array) {
  101504. Tags._AddTagTo(obj, tag);
  101505. });
  101506. };
  101507. /**
  101508. * @hidden
  101509. */
  101510. Tags._AddTagTo = function (obj, tag) {
  101511. tag = tag.trim();
  101512. if (tag === "" || tag === "true" || tag === "false") {
  101513. return;
  101514. }
  101515. if (tag.match(/[\s]/) || tag.match(/^([!]|([|]|[&]){2})/)) {
  101516. return;
  101517. }
  101518. Tags.EnableFor(obj);
  101519. obj._tags[tag] = true;
  101520. };
  101521. /**
  101522. * Removes specific tags from a specific object
  101523. * @param obj defines the object to use
  101524. * @param tagsString defines the tags to remove
  101525. */
  101526. Tags.RemoveTagsFrom = function (obj, tagsString) {
  101527. if (!Tags.HasTags(obj)) {
  101528. return;
  101529. }
  101530. var tags = tagsString.split(" ");
  101531. for (var t in tags) {
  101532. Tags._RemoveTagFrom(obj, tags[t]);
  101533. }
  101534. };
  101535. /**
  101536. * @hidden
  101537. */
  101538. Tags._RemoveTagFrom = function (obj, tag) {
  101539. delete obj._tags[tag];
  101540. };
  101541. /**
  101542. * Defines if tags hosted on an object match a given query
  101543. * @param obj defines the object to use
  101544. * @param tagsQuery defines the tag query
  101545. * @returns a boolean
  101546. */
  101547. Tags.MatchesQuery = function (obj, tagsQuery) {
  101548. if (tagsQuery === undefined) {
  101549. return true;
  101550. }
  101551. if (tagsQuery === "") {
  101552. return Tags.HasTags(obj);
  101553. }
  101554. return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__["AndOrNotEvaluator"].Eval(tagsQuery, function (r) { return Tags.HasTags(obj) && obj._tags[r]; });
  101555. };
  101556. return Tags;
  101557. }());
  101558. /***/ }),
  101559. /***/ "./Misc/textureTools.ts":
  101560. /*!******************************!*\
  101561. !*** ./Misc/textureTools.ts ***!
  101562. \******************************/
  101563. /*! exports provided: TextureTools */
  101564. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101565. "use strict";
  101566. __webpack_require__.r(__webpack_exports__);
  101567. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return TextureTools; });
  101568. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  101569. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  101570. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  101571. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  101572. /**
  101573. * Class used to host texture specific utilities
  101574. */
  101575. var TextureTools = /** @class */ (function () {
  101576. function TextureTools() {
  101577. }
  101578. /**
  101579. * Uses the GPU to create a copy texture rescaled at a given size
  101580. * @param texture Texture to copy from
  101581. * @param width defines the desired width
  101582. * @param height defines the desired height
  101583. * @param useBilinearMode defines if bilinear mode has to be used
  101584. * @return the generated texture
  101585. */
  101586. TextureTools.CreateResizedCopy = function (texture, width, height, useBilinearMode) {
  101587. if (useBilinearMode === void 0) { useBilinearMode = true; }
  101588. var scene = texture.getScene();
  101589. var engine = scene.getEngine();
  101590. 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);
  101591. rtt.wrapU = texture.wrapU;
  101592. rtt.wrapV = texture.wrapV;
  101593. rtt.uOffset = texture.uOffset;
  101594. rtt.vOffset = texture.vOffset;
  101595. rtt.uScale = texture.uScale;
  101596. rtt.vScale = texture.vScale;
  101597. rtt.uAng = texture.uAng;
  101598. rtt.vAng = texture.vAng;
  101599. rtt.wAng = texture.wAng;
  101600. rtt.coordinatesIndex = texture.coordinatesIndex;
  101601. rtt.level = texture.level;
  101602. rtt.anisotropicFilteringLevel = texture.anisotropicFilteringLevel;
  101603. rtt._texture.isReady = false;
  101604. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  101605. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  101606. 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);
  101607. passPostProcess.getEffect().executeWhenCompiled(function () {
  101608. passPostProcess.onApply = function (effect) {
  101609. effect.setTexture("textureSampler", texture);
  101610. };
  101611. var internalTexture = rtt.getInternalTexture();
  101612. if (internalTexture) {
  101613. scene.postProcessManager.directRender([passPostProcess], internalTexture);
  101614. engine.unBindFramebuffer(internalTexture);
  101615. rtt.disposeFramebufferObjects();
  101616. passPostProcess.dispose();
  101617. internalTexture.isReady = true;
  101618. }
  101619. });
  101620. return rtt;
  101621. };
  101622. return TextureTools;
  101623. }());
  101624. /***/ }),
  101625. /***/ "./Misc/tga.ts":
  101626. /*!*********************!*\
  101627. !*** ./Misc/tga.ts ***!
  101628. \*********************/
  101629. /*! exports provided: TGATools */
  101630. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101631. "use strict";
  101632. __webpack_require__.r(__webpack_exports__);
  101633. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return TGATools; });
  101634. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  101635. /**
  101636. * Based on jsTGALoader - Javascript loader for TGA file
  101637. * By Vincent Thibault
  101638. * @see http://blog.robrowser.com/javascript-tga-loader.html
  101639. */
  101640. var TGATools = /** @class */ (function () {
  101641. function TGATools() {
  101642. }
  101643. /**
  101644. * Gets the header of a TGA file
  101645. * @param data defines the TGA data
  101646. * @returns the header
  101647. */
  101648. TGATools.GetTGAHeader = function (data) {
  101649. var offset = 0;
  101650. var header = {
  101651. id_length: data[offset++],
  101652. colormap_type: data[offset++],
  101653. image_type: data[offset++],
  101654. colormap_index: data[offset++] | data[offset++] << 8,
  101655. colormap_length: data[offset++] | data[offset++] << 8,
  101656. colormap_size: data[offset++],
  101657. origin: [
  101658. data[offset++] | data[offset++] << 8,
  101659. data[offset++] | data[offset++] << 8
  101660. ],
  101661. width: data[offset++] | data[offset++] << 8,
  101662. height: data[offset++] | data[offset++] << 8,
  101663. pixel_size: data[offset++],
  101664. flags: data[offset++]
  101665. };
  101666. return header;
  101667. };
  101668. /**
  101669. * Uploads TGA content to a Babylon Texture
  101670. * @hidden
  101671. */
  101672. TGATools.UploadContent = function (texture, data) {
  101673. // Not enough data to contain header ?
  101674. if (data.length < 19) {
  101675. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data to contain header");
  101676. return;
  101677. }
  101678. // Read Header
  101679. var offset = 18;
  101680. var header = TGATools.GetTGAHeader(data);
  101681. // Assume it's a valid Targa file.
  101682. if (header.id_length + offset > data.length) {
  101683. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data");
  101684. return;
  101685. }
  101686. // Skip not needed data
  101687. offset += header.id_length;
  101688. var use_rle = false;
  101689. var use_pal = false;
  101690. var use_grey = false;
  101691. // Get some informations.
  101692. switch (header.image_type) {
  101693. case TGATools._TYPE_RLE_INDEXED:
  101694. use_rle = true;
  101695. case TGATools._TYPE_INDEXED:
  101696. use_pal = true;
  101697. break;
  101698. case TGATools._TYPE_RLE_RGB:
  101699. use_rle = true;
  101700. case TGATools._TYPE_RGB:
  101701. // use_rgb = true;
  101702. break;
  101703. case TGATools._TYPE_RLE_GREY:
  101704. use_rle = true;
  101705. case TGATools._TYPE_GREY:
  101706. use_grey = true;
  101707. break;
  101708. }
  101709. var pixel_data;
  101710. // var numAlphaBits = header.flags & 0xf;
  101711. var pixel_size = header.pixel_size >> 3;
  101712. var pixel_total = header.width * header.height * pixel_size;
  101713. // Read palettes
  101714. var palettes;
  101715. if (use_pal) {
  101716. palettes = data.subarray(offset, offset += header.colormap_length * (header.colormap_size >> 3));
  101717. }
  101718. // Read LRE
  101719. if (use_rle) {
  101720. pixel_data = new Uint8Array(pixel_total);
  101721. var c, count, i;
  101722. var localOffset = 0;
  101723. var pixels = new Uint8Array(pixel_size);
  101724. while (offset < pixel_total && localOffset < pixel_total) {
  101725. c = data[offset++];
  101726. count = (c & 0x7f) + 1;
  101727. // RLE pixels
  101728. if (c & 0x80) {
  101729. // Bind pixel tmp array
  101730. for (i = 0; i < pixel_size; ++i) {
  101731. pixels[i] = data[offset++];
  101732. }
  101733. // Copy pixel array
  101734. for (i = 0; i < count; ++i) {
  101735. pixel_data.set(pixels, localOffset + i * pixel_size);
  101736. }
  101737. localOffset += pixel_size * count;
  101738. }
  101739. // Raw pixels
  101740. else {
  101741. count *= pixel_size;
  101742. for (i = 0; i < count; ++i) {
  101743. pixel_data[localOffset + i] = data[offset++];
  101744. }
  101745. localOffset += count;
  101746. }
  101747. }
  101748. }
  101749. // RAW Pixels
  101750. else {
  101751. pixel_data = data.subarray(offset, offset += (use_pal ? header.width * header.height : pixel_total));
  101752. }
  101753. // Load to texture
  101754. var x_start, y_start, x_step, y_step, y_end, x_end;
  101755. switch ((header.flags & TGATools._ORIGIN_MASK) >> TGATools._ORIGIN_SHIFT) {
  101756. default:
  101757. case TGATools._ORIGIN_UL:
  101758. x_start = 0;
  101759. x_step = 1;
  101760. x_end = header.width;
  101761. y_start = 0;
  101762. y_step = 1;
  101763. y_end = header.height;
  101764. break;
  101765. case TGATools._ORIGIN_BL:
  101766. x_start = 0;
  101767. x_step = 1;
  101768. x_end = header.width;
  101769. y_start = header.height - 1;
  101770. y_step = -1;
  101771. y_end = -1;
  101772. break;
  101773. case TGATools._ORIGIN_UR:
  101774. x_start = header.width - 1;
  101775. x_step = -1;
  101776. x_end = -1;
  101777. y_start = 0;
  101778. y_step = 1;
  101779. y_end = header.height;
  101780. break;
  101781. case TGATools._ORIGIN_BR:
  101782. x_start = header.width - 1;
  101783. x_step = -1;
  101784. x_end = -1;
  101785. y_start = header.height - 1;
  101786. y_step = -1;
  101787. y_end = -1;
  101788. break;
  101789. }
  101790. // Load the specify method
  101791. var func = '_getImageData' + (use_grey ? 'Grey' : '') + (header.pixel_size) + 'bits';
  101792. var imageData = TGATools[func](header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end);
  101793. var engine = texture.getEngine();
  101794. engine._uploadDataToTextureDirectly(texture, imageData);
  101795. };
  101796. /** @hidden */
  101797. TGATools._getImageData8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  101798. var image = pixel_data, colormap = palettes;
  101799. var width = header.width, height = header.height;
  101800. var color, i = 0, x, y;
  101801. var imageData = new Uint8Array(width * height * 4);
  101802. for (y = y_start; y !== y_end; y += y_step) {
  101803. for (x = x_start; x !== x_end; x += x_step, i++) {
  101804. color = image[i];
  101805. imageData[(x + width * y) * 4 + 3] = 255;
  101806. imageData[(x + width * y) * 4 + 2] = colormap[(color * 3) + 0];
  101807. imageData[(x + width * y) * 4 + 1] = colormap[(color * 3) + 1];
  101808. imageData[(x + width * y) * 4 + 0] = colormap[(color * 3) + 2];
  101809. }
  101810. }
  101811. return imageData;
  101812. };
  101813. /** @hidden */
  101814. TGATools._getImageData16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  101815. var image = pixel_data;
  101816. var width = header.width, height = header.height;
  101817. var color, i = 0, x, y;
  101818. var imageData = new Uint8Array(width * height * 4);
  101819. for (y = y_start; y !== y_end; y += y_step) {
  101820. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  101821. color = image[i + 0] + (image[i + 1] << 8); // Inversed ?
  101822. var r = (((color & 0x7C00) >> 10) * 255) / 0x1F | 0;
  101823. var g = (((color & 0x03E0) >> 5) * 255) / 0x1F | 0;
  101824. var b = ((color & 0x001F) * 255) / 0x1F | 0;
  101825. imageData[(x + width * y) * 4 + 0] = r;
  101826. imageData[(x + width * y) * 4 + 1] = g;
  101827. imageData[(x + width * y) * 4 + 2] = b;
  101828. imageData[(x + width * y) * 4 + 3] = (color & 0x8000) ? 0 : 255;
  101829. }
  101830. }
  101831. return imageData;
  101832. };
  101833. /** @hidden */
  101834. TGATools._getImageData24bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  101835. var image = pixel_data;
  101836. var width = header.width, height = header.height;
  101837. var i = 0, x, y;
  101838. var imageData = new Uint8Array(width * height * 4);
  101839. for (y = y_start; y !== y_end; y += y_step) {
  101840. for (x = x_start; x !== x_end; x += x_step, i += 3) {
  101841. imageData[(x + width * y) * 4 + 3] = 255;
  101842. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  101843. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  101844. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  101845. }
  101846. }
  101847. return imageData;
  101848. };
  101849. /** @hidden */
  101850. TGATools._getImageData32bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  101851. var image = pixel_data;
  101852. var width = header.width, height = header.height;
  101853. var i = 0, x, y;
  101854. var imageData = new Uint8Array(width * height * 4);
  101855. for (y = y_start; y !== y_end; y += y_step) {
  101856. for (x = x_start; x !== x_end; x += x_step, i += 4) {
  101857. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  101858. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  101859. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  101860. imageData[(x + width * y) * 4 + 3] = image[i + 3];
  101861. }
  101862. }
  101863. return imageData;
  101864. };
  101865. /** @hidden */
  101866. TGATools._getImageDataGrey8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  101867. var image = pixel_data;
  101868. var width = header.width, height = header.height;
  101869. var color, i = 0, x, y;
  101870. var imageData = new Uint8Array(width * height * 4);
  101871. for (y = y_start; y !== y_end; y += y_step) {
  101872. for (x = x_start; x !== x_end; x += x_step, i++) {
  101873. color = image[i];
  101874. imageData[(x + width * y) * 4 + 0] = color;
  101875. imageData[(x + width * y) * 4 + 1] = color;
  101876. imageData[(x + width * y) * 4 + 2] = color;
  101877. imageData[(x + width * y) * 4 + 3] = 255;
  101878. }
  101879. }
  101880. return imageData;
  101881. };
  101882. /** @hidden */
  101883. TGATools._getImageDataGrey16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  101884. var image = pixel_data;
  101885. var width = header.width, height = header.height;
  101886. var i = 0, x, y;
  101887. var imageData = new Uint8Array(width * height * 4);
  101888. for (y = y_start; y !== y_end; y += y_step) {
  101889. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  101890. imageData[(x + width * y) * 4 + 0] = image[i + 0];
  101891. imageData[(x + width * y) * 4 + 1] = image[i + 0];
  101892. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  101893. imageData[(x + width * y) * 4 + 3] = image[i + 1];
  101894. }
  101895. }
  101896. return imageData;
  101897. };
  101898. //private static _TYPE_NO_DATA = 0;
  101899. TGATools._TYPE_INDEXED = 1;
  101900. TGATools._TYPE_RGB = 2;
  101901. TGATools._TYPE_GREY = 3;
  101902. TGATools._TYPE_RLE_INDEXED = 9;
  101903. TGATools._TYPE_RLE_RGB = 10;
  101904. TGATools._TYPE_RLE_GREY = 11;
  101905. TGATools._ORIGIN_MASK = 0x30;
  101906. TGATools._ORIGIN_SHIFT = 0x04;
  101907. TGATools._ORIGIN_BL = 0x00;
  101908. TGATools._ORIGIN_BR = 0x01;
  101909. TGATools._ORIGIN_UL = 0x02;
  101910. TGATools._ORIGIN_UR = 0x03;
  101911. return TGATools;
  101912. }());
  101913. /***/ }),
  101914. /***/ "./Misc/tools.ts":
  101915. /*!***********************!*\
  101916. !*** ./Misc/tools.ts ***!
  101917. \***********************/
  101918. /*! exports provided: ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop */
  101919. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101920. "use strict";
  101921. __webpack_require__.r(__webpack_exports__);
  101922. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return ColorGradient; });
  101923. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return Color3Gradient; });
  101924. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return FactorGradient; });
  101925. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return LoadFileError; });
  101926. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return RetryStrategy; });
  101927. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return Tools; });
  101928. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return PerfCounter; });
  101929. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "className", function() { return className; });
  101930. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return AsyncLoop; });
  101931. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  101932. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  101933. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  101934. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  101935. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  101936. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  101937. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  101938. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  101939. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  101940. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  101941. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  101942. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  101943. /* harmony import */ var _webRequest__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./webRequest */ "./Misc/webRequest.ts");
  101944. /** Class used to store color4 gradient */
  101945. var ColorGradient = /** @class */ (function () {
  101946. function ColorGradient() {
  101947. }
  101948. /**
  101949. * Will get a color picked randomly between color1 and color2.
  101950. * If color2 is undefined then color1 will be used
  101951. * @param result defines the target Color4 to store the result in
  101952. */
  101953. ColorGradient.prototype.getColorToRef = function (result) {
  101954. if (!this.color2) {
  101955. result.copyFrom(this.color1);
  101956. return;
  101957. }
  101958. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].LerpToRef(this.color1, this.color2, Math.random(), result);
  101959. };
  101960. return ColorGradient;
  101961. }());
  101962. /** Class used to store color 3 gradient */
  101963. var Color3Gradient = /** @class */ (function () {
  101964. function Color3Gradient() {
  101965. }
  101966. return Color3Gradient;
  101967. }());
  101968. /** Class used to store factor gradient */
  101969. var FactorGradient = /** @class */ (function () {
  101970. function FactorGradient() {
  101971. }
  101972. /**
  101973. * Will get a number picked randomly between factor1 and factor2.
  101974. * If factor2 is undefined then factor1 will be used
  101975. * @returns the picked number
  101976. */
  101977. FactorGradient.prototype.getFactor = function () {
  101978. if (this.factor2 === undefined) {
  101979. return this.factor1;
  101980. }
  101981. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Lerp(this.factor1, this.factor2, Math.random());
  101982. };
  101983. return FactorGradient;
  101984. }());
  101985. /**
  101986. * @ignore
  101987. * Application error to support additional information when loading a file
  101988. */
  101989. var LoadFileError = /** @class */ (function (_super) {
  101990. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LoadFileError, _super);
  101991. /**
  101992. * Creates a new LoadFileError
  101993. * @param message defines the message of the error
  101994. * @param request defines the optional web request
  101995. */
  101996. function LoadFileError(message,
  101997. /** defines the optional web request */
  101998. request) {
  101999. var _this = _super.call(this, message) || this;
  102000. _this.request = request;
  102001. _this.name = "LoadFileError";
  102002. LoadFileError._setPrototypeOf(_this, LoadFileError.prototype);
  102003. return _this;
  102004. }
  102005. // See https://stackoverflow.com/questions/12915412/how-do-i-extend-a-host-object-e-g-error-in-typescript
  102006. // and https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
  102007. // Polyfill for Object.setPrototypeOf if necessary.
  102008. LoadFileError._setPrototypeOf = Object.setPrototypeOf || (function (o, proto) { o.__proto__ = proto; return o; });
  102009. return LoadFileError;
  102010. }(Error));
  102011. /**
  102012. * Class used to define a retry strategy when error happens while loading assets
  102013. */
  102014. var RetryStrategy = /** @class */ (function () {
  102015. function RetryStrategy() {
  102016. }
  102017. /**
  102018. * Function used to defines an exponential back off strategy
  102019. * @param maxRetries defines the maximum number of retries (3 by default)
  102020. * @param baseInterval defines the interval between retries
  102021. * @returns the strategy function to use
  102022. */
  102023. RetryStrategy.ExponentialBackoff = function (maxRetries, baseInterval) {
  102024. if (maxRetries === void 0) { maxRetries = 3; }
  102025. if (baseInterval === void 0) { baseInterval = 500; }
  102026. return function (url, request, retryIndex) {
  102027. if (request.status !== 0 || retryIndex >= maxRetries || url.indexOf("file:") !== -1) {
  102028. return -1;
  102029. }
  102030. return Math.pow(2, retryIndex) * baseInterval;
  102031. };
  102032. };
  102033. return RetryStrategy;
  102034. }());
  102035. /**
  102036. * Class containing a set of static utilities functions
  102037. */
  102038. var Tools = /** @class */ (function () {
  102039. function Tools() {
  102040. }
  102041. /**
  102042. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  102043. * @param u defines the coordinate on X axis
  102044. * @param v defines the coordinate on Y axis
  102045. * @param width defines the width of the source data
  102046. * @param height defines the height of the source data
  102047. * @param pixels defines the source byte array
  102048. * @param color defines the output color
  102049. */
  102050. Tools.FetchToRef = function (u, v, width, height, pixels, color) {
  102051. var wrappedU = ((Math.abs(u) * width) % width) | 0;
  102052. var wrappedV = ((Math.abs(v) * height) % height) | 0;
  102053. var position = (wrappedU + wrappedV * width) * 4;
  102054. color.r = pixels[position] / 255;
  102055. color.g = pixels[position + 1] / 255;
  102056. color.b = pixels[position + 2] / 255;
  102057. color.a = pixels[position + 3] / 255;
  102058. };
  102059. /**
  102060. * Interpolates between a and b via alpha
  102061. * @param a The lower value (returned when alpha = 0)
  102062. * @param b The upper value (returned when alpha = 1)
  102063. * @param alpha The interpolation-factor
  102064. * @return The mixed value
  102065. */
  102066. Tools.Mix = function (a, b, alpha) {
  102067. return a * (1 - alpha) + b * alpha;
  102068. };
  102069. /**
  102070. * Tries to instantiate a new object from a given class name
  102071. * @param className defines the class name to instantiate
  102072. * @returns the new object or null if the system was not able to do the instantiation
  102073. */
  102074. Tools.Instantiate = function (className) {
  102075. if (Tools.RegisteredExternalClasses && Tools.RegisteredExternalClasses[className]) {
  102076. return Tools.RegisteredExternalClasses[className];
  102077. }
  102078. var internalClass = _typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass(className);
  102079. if (internalClass) {
  102080. return internalClass;
  102081. }
  102082. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(className + " not found, you may have missed an import.");
  102083. var arr = className.split(".");
  102084. var fn = (window || this);
  102085. for (var i = 0, len = arr.length; i < len; i++) {
  102086. fn = fn[arr[i]];
  102087. }
  102088. if (typeof fn !== "function") {
  102089. return null;
  102090. }
  102091. return fn;
  102092. };
  102093. /**
  102094. * Provides a slice function that will work even on IE
  102095. * @param data defines the array to slice
  102096. * @param start defines the start of the data (optional)
  102097. * @param end defines the end of the data (optional)
  102098. * @returns the new sliced array
  102099. */
  102100. Tools.Slice = function (data, start, end) {
  102101. if (data.slice) {
  102102. return data.slice(start, end);
  102103. }
  102104. return Array.prototype.slice.call(data, start, end);
  102105. };
  102106. /**
  102107. * Polyfill for setImmediate
  102108. * @param action defines the action to execute after the current execution block
  102109. */
  102110. Tools.SetImmediate = function (action) {
  102111. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && window.setImmediate) {
  102112. window.setImmediate(action);
  102113. }
  102114. else {
  102115. setTimeout(action, 1);
  102116. }
  102117. };
  102118. /**
  102119. * Function indicating if a number is an exponent of 2
  102120. * @param value defines the value to test
  102121. * @returns true if the value is an exponent of 2
  102122. */
  102123. Tools.IsExponentOfTwo = function (value) {
  102124. var count = 1;
  102125. do {
  102126. count *= 2;
  102127. } while (count < value);
  102128. return count === value;
  102129. };
  102130. /**
  102131. * Returns the nearest 32-bit single precision float representation of a Number
  102132. * @param value A Number. If the parameter is of a different type, it will get converted
  102133. * to a number or to NaN if it cannot be converted
  102134. * @returns number
  102135. */
  102136. Tools.FloatRound = function (value) {
  102137. if (Math.fround) {
  102138. return Math.fround(value);
  102139. }
  102140. return (Tools._tmpFloatArray[0] = value);
  102141. };
  102142. /**
  102143. * Find the next highest power of two.
  102144. * @param x Number to start search from.
  102145. * @return Next highest power of two.
  102146. */
  102147. Tools.CeilingPOT = function (x) {
  102148. x--;
  102149. x |= x >> 1;
  102150. x |= x >> 2;
  102151. x |= x >> 4;
  102152. x |= x >> 8;
  102153. x |= x >> 16;
  102154. x++;
  102155. return x;
  102156. };
  102157. /**
  102158. * Find the next lowest power of two.
  102159. * @param x Number to start search from.
  102160. * @return Next lowest power of two.
  102161. */
  102162. Tools.FloorPOT = function (x) {
  102163. x = x | (x >> 1);
  102164. x = x | (x >> 2);
  102165. x = x | (x >> 4);
  102166. x = x | (x >> 8);
  102167. x = x | (x >> 16);
  102168. return x - (x >> 1);
  102169. };
  102170. /**
  102171. * Find the nearest power of two.
  102172. * @param x Number to start search from.
  102173. * @return Next nearest power of two.
  102174. */
  102175. Tools.NearestPOT = function (x) {
  102176. var c = Tools.CeilingPOT(x);
  102177. var f = Tools.FloorPOT(x);
  102178. return (c - x) > (x - f) ? f : c;
  102179. };
  102180. /**
  102181. * Get the closest exponent of two
  102182. * @param value defines the value to approximate
  102183. * @param max defines the maximum value to return
  102184. * @param mode defines how to define the closest value
  102185. * @returns closest exponent of two of the given value
  102186. */
  102187. Tools.GetExponentOfTwo = function (value, max, mode) {
  102188. if (mode === void 0) { mode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST; }
  102189. var pot;
  102190. switch (mode) {
  102191. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_FLOOR:
  102192. pot = Tools.FloorPOT(value);
  102193. break;
  102194. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST:
  102195. pot = Tools.NearestPOT(value);
  102196. break;
  102197. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_CEILING:
  102198. default:
  102199. pot = Tools.CeilingPOT(value);
  102200. break;
  102201. }
  102202. return Math.min(pot, max);
  102203. };
  102204. /**
  102205. * Extracts the filename from a path
  102206. * @param path defines the path to use
  102207. * @returns the filename
  102208. */
  102209. Tools.GetFilename = function (path) {
  102210. var index = path.lastIndexOf("/");
  102211. if (index < 0) {
  102212. return path;
  102213. }
  102214. return path.substring(index + 1);
  102215. };
  102216. /**
  102217. * Extracts the "folder" part of a path (everything before the filename).
  102218. * @param uri The URI to extract the info from
  102219. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  102220. * @returns The "folder" part of the path
  102221. */
  102222. Tools.GetFolderPath = function (uri, returnUnchangedIfNoSlash) {
  102223. if (returnUnchangedIfNoSlash === void 0) { returnUnchangedIfNoSlash = false; }
  102224. var index = uri.lastIndexOf("/");
  102225. if (index < 0) {
  102226. if (returnUnchangedIfNoSlash) {
  102227. return uri;
  102228. }
  102229. return "";
  102230. }
  102231. return uri.substring(0, index + 1);
  102232. };
  102233. /**
  102234. * Convert an angle in radians to degrees
  102235. * @param angle defines the angle to convert
  102236. * @returns the angle in degrees
  102237. */
  102238. Tools.ToDegrees = function (angle) {
  102239. return angle * 180 / Math.PI;
  102240. };
  102241. /**
  102242. * Convert an angle in degrees to radians
  102243. * @param angle defines the angle to convert
  102244. * @returns the angle in radians
  102245. */
  102246. Tools.ToRadians = function (angle) {
  102247. return angle * Math.PI / 180;
  102248. };
  102249. /**
  102250. * Encode a buffer to a base64 string
  102251. * @param buffer defines the buffer to encode
  102252. * @returns the encoded string
  102253. */
  102254. Tools.EncodeArrayBufferTobase64 = function (buffer) {
  102255. var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  102256. var output = "";
  102257. var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
  102258. var i = 0;
  102259. var bytes = new Uint8Array(buffer);
  102260. while (i < bytes.length) {
  102261. chr1 = bytes[i++];
  102262. chr2 = i < bytes.length ? bytes[i++] : Number.NaN; // Not sure if the index
  102263. chr3 = i < bytes.length ? bytes[i++] : Number.NaN; // checks are needed here
  102264. enc1 = chr1 >> 2;
  102265. enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
  102266. enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
  102267. enc4 = chr3 & 63;
  102268. if (isNaN(chr2)) {
  102269. enc3 = enc4 = 64;
  102270. }
  102271. else if (isNaN(chr3)) {
  102272. enc4 = 64;
  102273. }
  102274. output += keyStr.charAt(enc1) + keyStr.charAt(enc2) +
  102275. keyStr.charAt(enc3) + keyStr.charAt(enc4);
  102276. }
  102277. return "data:image/png;base64," + output;
  102278. };
  102279. /**
  102280. * Extracts minimum and maximum values from a list of indexed positions
  102281. * @param positions defines the positions to use
  102282. * @param indices defines the indices to the positions
  102283. * @param indexStart defines the start index
  102284. * @param indexCount defines the end index
  102285. * @param bias defines bias value to add to the result
  102286. * @return minimum and maximum values
  102287. */
  102288. Tools.ExtractMinAndMaxIndexed = function (positions, indices, indexStart, indexCount, bias) {
  102289. if (bias === void 0) { bias = null; }
  102290. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  102291. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  102292. for (var index = indexStart; index < indexStart + indexCount; index++) {
  102293. var offset = indices[index] * 3;
  102294. var x = positions[offset];
  102295. var y = positions[offset + 1];
  102296. var z = positions[offset + 2];
  102297. minimum.minimizeInPlaceFromFloats(x, y, z);
  102298. maximum.maximizeInPlaceFromFloats(x, y, z);
  102299. }
  102300. if (bias) {
  102301. minimum.x -= minimum.x * bias.x + bias.y;
  102302. minimum.y -= minimum.y * bias.x + bias.y;
  102303. minimum.z -= minimum.z * bias.x + bias.y;
  102304. maximum.x += maximum.x * bias.x + bias.y;
  102305. maximum.y += maximum.y * bias.x + bias.y;
  102306. maximum.z += maximum.z * bias.x + bias.y;
  102307. }
  102308. return {
  102309. minimum: minimum,
  102310. maximum: maximum
  102311. };
  102312. };
  102313. /**
  102314. * Extracts minimum and maximum values from a list of positions
  102315. * @param positions defines the positions to use
  102316. * @param start defines the start index in the positions array
  102317. * @param count defines the number of positions to handle
  102318. * @param bias defines bias value to add to the result
  102319. * @param stride defines the stride size to use (distance between two positions in the positions array)
  102320. * @return minimum and maximum values
  102321. */
  102322. Tools.ExtractMinAndMax = function (positions, start, count, bias, stride) {
  102323. if (bias === void 0) { bias = null; }
  102324. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  102325. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  102326. if (!stride) {
  102327. stride = 3;
  102328. }
  102329. for (var index = start, offset = start * stride; index < start + count; index++, offset += stride) {
  102330. var x = positions[offset];
  102331. var y = positions[offset + 1];
  102332. var z = positions[offset + 2];
  102333. minimum.minimizeInPlaceFromFloats(x, y, z);
  102334. maximum.maximizeInPlaceFromFloats(x, y, z);
  102335. }
  102336. if (bias) {
  102337. minimum.x -= minimum.x * bias.x + bias.y;
  102338. minimum.y -= minimum.y * bias.x + bias.y;
  102339. minimum.z -= minimum.z * bias.x + bias.y;
  102340. maximum.x += maximum.x * bias.x + bias.y;
  102341. maximum.y += maximum.y * bias.x + bias.y;
  102342. maximum.z += maximum.z * bias.x + bias.y;
  102343. }
  102344. return {
  102345. minimum: minimum,
  102346. maximum: maximum
  102347. };
  102348. };
  102349. /**
  102350. * Returns an array if obj is not an array
  102351. * @param obj defines the object to evaluate as an array
  102352. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  102353. * @returns either obj directly if obj is an array or a new array containing obj
  102354. */
  102355. Tools.MakeArray = function (obj, allowsNullUndefined) {
  102356. if (allowsNullUndefined !== true && (obj === undefined || obj == null)) {
  102357. return null;
  102358. }
  102359. return Array.isArray(obj) ? obj : [obj];
  102360. };
  102361. /**
  102362. * Gets the pointer prefix to use
  102363. * @returns "pointer" if touch is enabled. Else returns "mouse"
  102364. */
  102365. Tools.GetPointerPrefix = function () {
  102366. var eventPrefix = "pointer";
  102367. // Check if pointer events are supported
  102368. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && !window.PointerEvent && !navigator.pointerEnabled) {
  102369. eventPrefix = "mouse";
  102370. }
  102371. return eventPrefix;
  102372. };
  102373. /**
  102374. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  102375. * @param func - the function to be called
  102376. * @param requester - the object that will request the next frame. Falls back to window.
  102377. * @returns frame number
  102378. */
  102379. Tools.QueueNewFrame = function (func, requester) {
  102380. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  102381. return setTimeout(func, 16);
  102382. }
  102383. if (!requester) {
  102384. requester = window;
  102385. }
  102386. if (requester.requestAnimationFrame) {
  102387. return requester.requestAnimationFrame(func);
  102388. }
  102389. else if (requester.msRequestAnimationFrame) {
  102390. return requester.msRequestAnimationFrame(func);
  102391. }
  102392. else if (requester.webkitRequestAnimationFrame) {
  102393. return requester.webkitRequestAnimationFrame(func);
  102394. }
  102395. else if (requester.mozRequestAnimationFrame) {
  102396. return requester.mozRequestAnimationFrame(func);
  102397. }
  102398. else if (requester.oRequestAnimationFrame) {
  102399. return requester.oRequestAnimationFrame(func);
  102400. }
  102401. else {
  102402. return window.setTimeout(func, 16);
  102403. }
  102404. };
  102405. /**
  102406. * Ask the browser to promote the current element to fullscreen rendering mode
  102407. * @param element defines the DOM element to promote
  102408. */
  102409. Tools.RequestFullscreen = function (element) {
  102410. var requestFunction = element.requestFullscreen || element.msRequestFullscreen || element.webkitRequestFullscreen || element.mozRequestFullScreen;
  102411. if (!requestFunction) {
  102412. return;
  102413. }
  102414. requestFunction.call(element);
  102415. };
  102416. /**
  102417. * Asks the browser to exit fullscreen mode
  102418. */
  102419. Tools.ExitFullscreen = function () {
  102420. var anyDoc = document;
  102421. if (document.exitFullscreen) {
  102422. document.exitFullscreen();
  102423. }
  102424. else if (anyDoc.mozCancelFullScreen) {
  102425. anyDoc.mozCancelFullScreen();
  102426. }
  102427. else if (anyDoc.webkitCancelFullScreen) {
  102428. anyDoc.webkitCancelFullScreen();
  102429. }
  102430. else if (anyDoc.msCancelFullScreen) {
  102431. anyDoc.msCancelFullScreen();
  102432. }
  102433. };
  102434. /**
  102435. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  102436. * @param url define the url we are trying
  102437. * @param element define the dom element where to configure the cors policy
  102438. */
  102439. Tools.SetCorsBehavior = function (url, element) {
  102440. if (url && url.indexOf("data:") === 0) {
  102441. return;
  102442. }
  102443. if (Tools.CorsBehavior) {
  102444. if (typeof (Tools.CorsBehavior) === 'string' || Tools.CorsBehavior instanceof String) {
  102445. element.crossOrigin = Tools.CorsBehavior;
  102446. }
  102447. else {
  102448. var result = Tools.CorsBehavior(url);
  102449. if (result) {
  102450. element.crossOrigin = result;
  102451. }
  102452. }
  102453. }
  102454. };
  102455. // External files
  102456. /**
  102457. * Removes unwanted characters from an url
  102458. * @param url defines the url to clean
  102459. * @returns the cleaned url
  102460. */
  102461. Tools.CleanUrl = function (url) {
  102462. url = url.replace(/#/mg, "%23");
  102463. return url;
  102464. };
  102465. /**
  102466. * Loads an image as an HTMLImageElement.
  102467. * @param input url string, ArrayBuffer, or Blob to load
  102468. * @param onLoad callback called when the image successfully loads
  102469. * @param onError callback called when the image fails to load
  102470. * @param offlineProvider offline provider for caching
  102471. * @returns the HTMLImageElement of the loaded image
  102472. */
  102473. Tools.LoadImage = function (input, onLoad, onError, offlineProvider) {
  102474. var url;
  102475. var usingObjectURL = false;
  102476. if (input instanceof ArrayBuffer) {
  102477. url = URL.createObjectURL(new Blob([input]));
  102478. usingObjectURL = true;
  102479. }
  102480. else if (input instanceof Blob) {
  102481. url = URL.createObjectURL(input);
  102482. usingObjectURL = true;
  102483. }
  102484. else {
  102485. url = Tools.CleanUrl(input);
  102486. url = Tools.PreprocessUrl(input);
  102487. }
  102488. var img = new Image();
  102489. Tools.SetCorsBehavior(url, img);
  102490. var loadHandler = function () {
  102491. img.removeEventListener("load", loadHandler);
  102492. img.removeEventListener("error", errorHandler);
  102493. onLoad(img);
  102494. // Must revoke the URL after calling onLoad to avoid security exceptions in
  102495. // certain scenarios (e.g. when hosted in vscode).
  102496. if (usingObjectURL && img.src) {
  102497. URL.revokeObjectURL(img.src);
  102498. }
  102499. };
  102500. var errorHandler = function (err) {
  102501. img.removeEventListener("load", loadHandler);
  102502. img.removeEventListener("error", errorHandler);
  102503. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error while trying to load image: " + input);
  102504. if (onError) {
  102505. onError("Error while trying to load image: " + input, err);
  102506. }
  102507. if (usingObjectURL && img.src) {
  102508. URL.revokeObjectURL(img.src);
  102509. }
  102510. };
  102511. img.addEventListener("load", loadHandler);
  102512. img.addEventListener("error", errorHandler);
  102513. var noOfflineSupport = function () {
  102514. img.src = url;
  102515. };
  102516. var loadFromOfflineSupport = function () {
  102517. if (offlineProvider) {
  102518. offlineProvider.loadImage(url, img);
  102519. }
  102520. };
  102521. if (url.substr(0, 5) !== "data:" && offlineProvider && offlineProvider.enableTexturesOffline) {
  102522. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport);
  102523. }
  102524. else {
  102525. if (url.indexOf("file:") !== -1) {
  102526. var textureName = decodeURIComponent(url.substring(5).toLowerCase());
  102527. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]) {
  102528. try {
  102529. var blobURL;
  102530. try {
  102531. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  102532. }
  102533. catch (ex) {
  102534. // Chrome doesn't support oneTimeOnly parameter
  102535. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  102536. }
  102537. img.src = blobURL;
  102538. usingObjectURL = true;
  102539. }
  102540. catch (e) {
  102541. img.src = "";
  102542. }
  102543. return img;
  102544. }
  102545. }
  102546. noOfflineSupport();
  102547. }
  102548. return img;
  102549. };
  102550. /**
  102551. * Loads a file
  102552. * @param url url string, ArrayBuffer, or Blob to load
  102553. * @param onSuccess callback called when the file successfully loads
  102554. * @param onProgress callback called while file is loading (if the server supports this mode)
  102555. * @param offlineProvider defines the offline provider for caching
  102556. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  102557. * @param onError callback called when the file fails to load
  102558. * @returns a file request object
  102559. */
  102560. Tools.LoadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  102561. url = Tools.CleanUrl(url);
  102562. url = Tools.PreprocessUrl(url);
  102563. // If file and file input are set
  102564. if (url.indexOf("file:") !== -1) {
  102565. var fileName = decodeURIComponent(url.substring(5).toLowerCase());
  102566. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName]) {
  102567. return Tools.ReadFile(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName], onSuccess, onProgress, useArrayBuffer);
  102568. }
  102569. }
  102570. var loadUrl = Tools.BaseUrl + url;
  102571. var aborted = false;
  102572. var fileRequest = {
  102573. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  102574. abort: function () { return aborted = true; },
  102575. };
  102576. var requestFile = function () {
  102577. var request = new _webRequest__WEBPACK_IMPORTED_MODULE_12__["WebRequest"]();
  102578. var retryHandle = null;
  102579. fileRequest.abort = function () {
  102580. aborted = true;
  102581. if (request.readyState !== (XMLHttpRequest.DONE || 4)) {
  102582. request.abort();
  102583. }
  102584. if (retryHandle !== null) {
  102585. clearTimeout(retryHandle);
  102586. retryHandle = null;
  102587. }
  102588. };
  102589. var retryLoop = function (retryIndex) {
  102590. request.open('GET', loadUrl);
  102591. if (useArrayBuffer) {
  102592. request.responseType = "arraybuffer";
  102593. }
  102594. if (onProgress) {
  102595. request.addEventListener("progress", onProgress);
  102596. }
  102597. var onLoadEnd = function () {
  102598. request.removeEventListener("loadend", onLoadEnd);
  102599. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  102600. fileRequest.onCompleteObservable.clear();
  102601. };
  102602. request.addEventListener("loadend", onLoadEnd);
  102603. var onReadyStateChange = function () {
  102604. if (aborted) {
  102605. return;
  102606. }
  102607. // In case of undefined state in some browsers.
  102608. if (request.readyState === (XMLHttpRequest.DONE || 4)) {
  102609. // Some browsers have issues where onreadystatechange can be called multiple times with the same value.
  102610. request.removeEventListener("readystatechange", onReadyStateChange);
  102611. if ((request.status >= 200 && request.status < 300) || (request.status === 0 && (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() || Tools.IsFileURL()))) {
  102612. onSuccess(!useArrayBuffer ? request.responseText : request.response, request.responseURL);
  102613. return;
  102614. }
  102615. var retryStrategy = Tools.DefaultRetryStrategy;
  102616. if (retryStrategy) {
  102617. var waitTime = retryStrategy(loadUrl, request, retryIndex);
  102618. if (waitTime !== -1) {
  102619. // Prevent the request from completing for retry.
  102620. request.removeEventListener("loadend", onLoadEnd);
  102621. request = new _webRequest__WEBPACK_IMPORTED_MODULE_12__["WebRequest"]();
  102622. retryHandle = setTimeout(function () { return retryLoop(retryIndex + 1); }, waitTime);
  102623. return;
  102624. }
  102625. }
  102626. var e = new LoadFileError("Error status: " + request.status + " " + request.statusText + " - Unable to load " + loadUrl, request);
  102627. if (onError) {
  102628. onError(request, e);
  102629. }
  102630. else {
  102631. throw e;
  102632. }
  102633. }
  102634. };
  102635. request.addEventListener("readystatechange", onReadyStateChange);
  102636. request.send();
  102637. };
  102638. retryLoop(0);
  102639. };
  102640. // Caching all files
  102641. if (offlineProvider && offlineProvider.enableSceneOffline) {
  102642. var noOfflineSupport_1 = function (request) {
  102643. if (request && request.status > 400) {
  102644. if (onError) {
  102645. onError(request);
  102646. }
  102647. }
  102648. else {
  102649. if (!aborted) {
  102650. requestFile();
  102651. }
  102652. }
  102653. };
  102654. var loadFromOfflineSupport = function () {
  102655. // TODO: database needs to support aborting and should return a IFileRequest
  102656. if (aborted) {
  102657. return;
  102658. }
  102659. if (offlineProvider) {
  102660. offlineProvider.loadFile(url, function (data) {
  102661. if (!aborted) {
  102662. onSuccess(data);
  102663. }
  102664. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  102665. }, onProgress ? function (event) {
  102666. if (!aborted) {
  102667. onProgress(event);
  102668. }
  102669. } : undefined, noOfflineSupport_1, useArrayBuffer);
  102670. }
  102671. };
  102672. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport_1);
  102673. }
  102674. else {
  102675. requestFile();
  102676. }
  102677. return fileRequest;
  102678. };
  102679. /**
  102680. * Load a script (identified by an url). When the url returns, the
  102681. * content of this file is added into a new script element, attached to the DOM (body element)
  102682. * @param scriptUrl defines the url of the script to laod
  102683. * @param onSuccess defines the callback called when the script is loaded
  102684. * @param onError defines the callback to call if an error occurs
  102685. * @param scriptId defines the id of the script element
  102686. */
  102687. Tools.LoadScript = function (scriptUrl, onSuccess, onError, scriptId) {
  102688. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  102689. return;
  102690. }
  102691. var head = document.getElementsByTagName('head')[0];
  102692. var script = document.createElement('script');
  102693. script.setAttribute('type', 'text/javascript');
  102694. script.setAttribute('src', scriptUrl);
  102695. if (scriptId) {
  102696. script.id = scriptId;
  102697. }
  102698. script.onload = function () {
  102699. if (onSuccess) {
  102700. onSuccess();
  102701. }
  102702. };
  102703. script.onerror = function (e) {
  102704. if (onError) {
  102705. onError("Unable to load script '" + scriptUrl + "'", e);
  102706. }
  102707. };
  102708. head.appendChild(script);
  102709. };
  102710. /**
  102711. * Load an asynchronous script (identified by an url). When the url returns, the
  102712. * content of this file is added into a new script element, attached to the DOM (body element)
  102713. * @param scriptUrl defines the url of the script to laod
  102714. * @param scriptId defines the id of the script element
  102715. * @returns a promise request object
  102716. */
  102717. Tools.LoadScriptAsync = function (scriptUrl, scriptId) {
  102718. return new Promise(function (resolve, reject) {
  102719. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  102720. resolve(false);
  102721. return;
  102722. }
  102723. var head = document.getElementsByTagName('head')[0];
  102724. var script = document.createElement('script');
  102725. script.setAttribute('type', 'text/javascript');
  102726. script.setAttribute('src', scriptUrl);
  102727. if (scriptId) {
  102728. script.id = scriptId;
  102729. }
  102730. script.onload = function () {
  102731. resolve(true);
  102732. };
  102733. script.onerror = function (e) {
  102734. resolve(false);
  102735. };
  102736. head.appendChild(script);
  102737. });
  102738. };
  102739. /**
  102740. * Loads a file from a blob
  102741. * @param fileToLoad defines the blob to use
  102742. * @param callback defines the callback to call when data is loaded
  102743. * @param progressCallback defines the callback to call during loading process
  102744. * @returns a file request object
  102745. */
  102746. Tools.ReadFileAsDataURL = function (fileToLoad, callback, progressCallback) {
  102747. var reader = new FileReader();
  102748. var request = {
  102749. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  102750. abort: function () { return reader.abort(); },
  102751. };
  102752. reader.onloadend = function (e) {
  102753. request.onCompleteObservable.notifyObservers(request);
  102754. };
  102755. reader.onload = function (e) {
  102756. //target doesn't have result from ts 1.3
  102757. callback(e.target['result']);
  102758. };
  102759. reader.onprogress = progressCallback;
  102760. reader.readAsDataURL(fileToLoad);
  102761. return request;
  102762. };
  102763. /**
  102764. * Loads a file
  102765. * @param fileToLoad defines the file to load
  102766. * @param callback defines the callback to call when data is loaded
  102767. * @param progressCallBack defines the callback to call during loading process
  102768. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  102769. * @returns a file request object
  102770. */
  102771. Tools.ReadFile = function (fileToLoad, callback, progressCallBack, useArrayBuffer) {
  102772. var reader = new FileReader();
  102773. var request = {
  102774. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  102775. abort: function () { return reader.abort(); },
  102776. };
  102777. reader.onloadend = function (e) { return request.onCompleteObservable.notifyObservers(request); };
  102778. reader.onerror = function (e) {
  102779. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log("Error while reading file: " + fileToLoad.name);
  102780. callback(JSON.stringify({ autoClear: true, clearColor: [1, 0, 0], ambientColor: [0, 0, 0], gravity: [0, -9.807, 0], meshes: [], cameras: [], lights: [] }));
  102781. };
  102782. reader.onload = function (e) {
  102783. //target doesn't have result from ts 1.3
  102784. callback(e.target['result']);
  102785. };
  102786. if (progressCallBack) {
  102787. reader.onprogress = progressCallBack;
  102788. }
  102789. if (!useArrayBuffer) {
  102790. // Asynchronous read
  102791. reader.readAsText(fileToLoad);
  102792. }
  102793. else {
  102794. reader.readAsArrayBuffer(fileToLoad);
  102795. }
  102796. return request;
  102797. };
  102798. /**
  102799. * Creates a data url from a given string content
  102800. * @param content defines the content to convert
  102801. * @returns the new data url link
  102802. */
  102803. Tools.FileAsURL = function (content) {
  102804. var fileBlob = new Blob([content]);
  102805. var url = window.URL || window.webkitURL;
  102806. var link = url.createObjectURL(fileBlob);
  102807. return link;
  102808. };
  102809. /**
  102810. * Format the given number to a specific decimal format
  102811. * @param value defines the number to format
  102812. * @param decimals defines the number of decimals to use
  102813. * @returns the formatted string
  102814. */
  102815. Tools.Format = function (value, decimals) {
  102816. if (decimals === void 0) { decimals = 2; }
  102817. return value.toFixed(decimals);
  102818. };
  102819. /**
  102820. * Checks if a given vector is inside a specific range
  102821. * @param v defines the vector to test
  102822. * @param min defines the minimum range
  102823. * @param max defines the maximum range
  102824. */
  102825. Tools.CheckExtends = function (v, min, max) {
  102826. min.minimizeInPlace(v);
  102827. max.maximizeInPlace(v);
  102828. };
  102829. /**
  102830. * Tries to copy an object by duplicating every property
  102831. * @param source defines the source object
  102832. * @param destination defines the target object
  102833. * @param doNotCopyList defines a list of properties to avoid
  102834. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  102835. */
  102836. Tools.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  102837. _deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source, destination, doNotCopyList, mustCopyList);
  102838. };
  102839. /**
  102840. * Gets a boolean indicating if the given object has no own property
  102841. * @param obj defines the object to test
  102842. * @returns true if object has no own property
  102843. */
  102844. Tools.IsEmpty = function (obj) {
  102845. for (var i in obj) {
  102846. if (obj.hasOwnProperty(i)) {
  102847. return false;
  102848. }
  102849. }
  102850. return true;
  102851. };
  102852. /**
  102853. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  102854. * @param str Source string
  102855. * @param suffix Suffix to search for in the source string
  102856. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  102857. */
  102858. Tools.EndsWith = function (str, suffix) {
  102859. return str.indexOf(suffix, str.length - suffix.length) !== -1;
  102860. };
  102861. /**
  102862. * Function used to register events at window level
  102863. * @param events defines the events to register
  102864. */
  102865. Tools.RegisterTopRootEvents = function (events) {
  102866. for (var index = 0; index < events.length; index++) {
  102867. var event = events[index];
  102868. window.addEventListener(event.name, event.handler, false);
  102869. try {
  102870. if (window.parent) {
  102871. window.parent.addEventListener(event.name, event.handler, false);
  102872. }
  102873. }
  102874. catch (e) {
  102875. // Silently fails...
  102876. }
  102877. }
  102878. };
  102879. /**
  102880. * Function used to unregister events from window level
  102881. * @param events defines the events to unregister
  102882. */
  102883. Tools.UnregisterTopRootEvents = function (events) {
  102884. for (var index = 0; index < events.length; index++) {
  102885. var event = events[index];
  102886. window.removeEventListener(event.name, event.handler);
  102887. try {
  102888. if (window.parent) {
  102889. window.parent.removeEventListener(event.name, event.handler);
  102890. }
  102891. }
  102892. catch (e) {
  102893. // Silently fails...
  102894. }
  102895. }
  102896. };
  102897. /**
  102898. * Dumps the current bound framebuffer
  102899. * @param width defines the rendering width
  102900. * @param height defines the rendering height
  102901. * @param engine defines the hosting engine
  102902. * @param successCallback defines the callback triggered once the data are available
  102903. * @param mimeType defines the mime type of the result
  102904. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  102905. */
  102906. Tools.DumpFramebuffer = function (width, height, engine, successCallback, mimeType, fileName) {
  102907. if (mimeType === void 0) { mimeType = "image/png"; }
  102908. // Read the contents of the framebuffer
  102909. var numberOfChannelsByLine = width * 4;
  102910. var halfHeight = height / 2;
  102911. //Reading datas from WebGL
  102912. var data = engine.readPixels(0, 0, width, height);
  102913. //To flip image on Y axis.
  102914. for (var i = 0; i < halfHeight; i++) {
  102915. for (var j = 0; j < numberOfChannelsByLine; j++) {
  102916. var currentCell = j + i * numberOfChannelsByLine;
  102917. var targetLine = height - i - 1;
  102918. var targetCell = j + targetLine * numberOfChannelsByLine;
  102919. var temp = data[currentCell];
  102920. data[currentCell] = data[targetCell];
  102921. data[targetCell] = temp;
  102922. }
  102923. }
  102924. // Create a 2D canvas to store the result
  102925. if (!Tools._ScreenshotCanvas) {
  102926. Tools._ScreenshotCanvas = document.createElement('canvas');
  102927. }
  102928. Tools._ScreenshotCanvas.width = width;
  102929. Tools._ScreenshotCanvas.height = height;
  102930. var context = Tools._ScreenshotCanvas.getContext('2d');
  102931. if (context) {
  102932. // Copy the pixels to a 2D canvas
  102933. var imageData = context.createImageData(width, height);
  102934. var castData = (imageData.data);
  102935. castData.set(data);
  102936. context.putImageData(imageData, 0, 0);
  102937. Tools.EncodeScreenshotCanvasData(successCallback, mimeType, fileName);
  102938. }
  102939. };
  102940. /**
  102941. * Converts the canvas data to blob.
  102942. * This acts as a polyfill for browsers not supporting the to blob function.
  102943. * @param canvas Defines the canvas to extract the data from
  102944. * @param successCallback Defines the callback triggered once the data are available
  102945. * @param mimeType Defines the mime type of the result
  102946. */
  102947. Tools.ToBlob = function (canvas, successCallback, mimeType) {
  102948. if (mimeType === void 0) { mimeType = "image/png"; }
  102949. // We need HTMLCanvasElement.toBlob for HD screenshots
  102950. if (!canvas.toBlob) {
  102951. // low performance polyfill based on toDataURL (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob)
  102952. canvas.toBlob = function (callback, type, quality) {
  102953. var _this = this;
  102954. setTimeout(function () {
  102955. var binStr = atob(_this.toDataURL(type, quality).split(',')[1]), len = binStr.length, arr = new Uint8Array(len);
  102956. for (var i = 0; i < len; i++) {
  102957. arr[i] = binStr.charCodeAt(i);
  102958. }
  102959. callback(new Blob([arr]));
  102960. });
  102961. };
  102962. }
  102963. canvas.toBlob(function (blob) {
  102964. successCallback(blob);
  102965. }, mimeType);
  102966. };
  102967. /**
  102968. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  102969. * @param successCallback defines the callback triggered once the data are available
  102970. * @param mimeType defines the mime type of the result
  102971. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  102972. */
  102973. Tools.EncodeScreenshotCanvasData = function (successCallback, mimeType, fileName) {
  102974. if (mimeType === void 0) { mimeType = "image/png"; }
  102975. if (successCallback) {
  102976. var base64Image = Tools._ScreenshotCanvas.toDataURL(mimeType);
  102977. successCallback(base64Image);
  102978. }
  102979. else {
  102980. this.ToBlob(Tools._ScreenshotCanvas, function (blob) {
  102981. //Creating a link if the browser have the download attribute on the a tag, to automatically start download generated image.
  102982. if (("download" in document.createElement("a"))) {
  102983. if (!fileName) {
  102984. var date = new Date();
  102985. var stringDate = (date.getFullYear() + "-" + (date.getMonth() + 1)).slice(2) + "-" + date.getDate() + "_" + date.getHours() + "-" + ('0' + date.getMinutes()).slice(-2);
  102986. fileName = "screenshot_" + stringDate + ".png";
  102987. }
  102988. Tools.Download(blob, fileName);
  102989. }
  102990. else {
  102991. var url = URL.createObjectURL(blob);
  102992. var newWindow = window.open("");
  102993. if (!newWindow) {
  102994. return;
  102995. }
  102996. var img = newWindow.document.createElement("img");
  102997. img.onload = function () {
  102998. // no longer need to read the blob so it's revoked
  102999. URL.revokeObjectURL(url);
  103000. };
  103001. img.src = url;
  103002. newWindow.document.body.appendChild(img);
  103003. }
  103004. }, mimeType);
  103005. }
  103006. };
  103007. /**
  103008. * Downloads a blob in the browser
  103009. * @param blob defines the blob to download
  103010. * @param fileName defines the name of the downloaded file
  103011. */
  103012. Tools.Download = function (blob, fileName) {
  103013. if (navigator && navigator.msSaveBlob) {
  103014. navigator.msSaveBlob(blob, fileName);
  103015. return;
  103016. }
  103017. var url = window.URL.createObjectURL(blob);
  103018. var a = document.createElement("a");
  103019. document.body.appendChild(a);
  103020. a.style.display = "none";
  103021. a.href = url;
  103022. a.download = fileName;
  103023. a.addEventListener("click", function () {
  103024. if (a.parentElement) {
  103025. a.parentElement.removeChild(a);
  103026. }
  103027. });
  103028. a.click();
  103029. window.URL.revokeObjectURL(url);
  103030. };
  103031. /**
  103032. * Captures a screenshot of the current rendering
  103033. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  103034. * @param engine defines the rendering engine
  103035. * @param camera defines the source camera
  103036. * @param size This parameter can be set to a single number or to an object with the
  103037. * following (optional) properties: precision, width, height. If a single number is passed,
  103038. * it will be used for both width and height. If an object is passed, the screenshot size
  103039. * will be derived from the parameters. The precision property is a multiplier allowing
  103040. * rendering at a higher or lower resolution
  103041. * @param successCallback defines the callback receives a single parameter which contains the
  103042. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  103043. * src parameter of an <img> to display it
  103044. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  103045. * Check your browser for supported MIME types
  103046. */
  103047. Tools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  103048. if (mimeType === void 0) { mimeType = "image/png"; }
  103049. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  103050. };
  103051. /**
  103052. * Generates an image screenshot from the specified camera.
  103053. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  103054. * @param engine The engine to use for rendering
  103055. * @param camera The camera to use for rendering
  103056. * @param size This parameter can be set to a single number or to an object with the
  103057. * following (optional) properties: precision, width, height. If a single number is passed,
  103058. * it will be used for both width and height. If an object is passed, the screenshot size
  103059. * will be derived from the parameters. The precision property is a multiplier allowing
  103060. * rendering at a higher or lower resolution
  103061. * @param successCallback The callback receives a single parameter which contains the
  103062. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  103063. * src parameter of an <img> to display it
  103064. * @param mimeType The MIME type of the screenshot image (default: image/png).
  103065. * Check your browser for supported MIME types
  103066. * @param samples Texture samples (default: 1)
  103067. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  103068. * @param fileName A name for for the downloaded file.
  103069. */
  103070. Tools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  103071. if (mimeType === void 0) { mimeType = "image/png"; }
  103072. if (samples === void 0) { samples = 1; }
  103073. if (antialiasing === void 0) { antialiasing = false; }
  103074. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  103075. };
  103076. /**
  103077. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103078. * Be aware Math.random() could cause collisions, but:
  103079. * "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"
  103080. * @returns a pseudo random id
  103081. */
  103082. Tools.RandomId = function () {
  103083. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  103084. var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
  103085. return v.toString(16);
  103086. });
  103087. };
  103088. /**
  103089. * Test if the given uri is a base64 string
  103090. * @param uri The uri to test
  103091. * @return True if the uri is a base64 string or false otherwise
  103092. */
  103093. Tools.IsBase64 = function (uri) {
  103094. return uri.length < 5 ? false : uri.substr(0, 5) === "data:";
  103095. };
  103096. /**
  103097. * Decode the given base64 uri.
  103098. * @param uri The uri to decode
  103099. * @return The decoded base64 data.
  103100. */
  103101. Tools.DecodeBase64 = function (uri) {
  103102. var decodedString = atob(uri.split(",")[1]);
  103103. var bufferLength = decodedString.length;
  103104. var bufferView = new Uint8Array(new ArrayBuffer(bufferLength));
  103105. for (var i = 0; i < bufferLength; i++) {
  103106. bufferView[i] = decodedString.charCodeAt(i);
  103107. }
  103108. return bufferView.buffer;
  103109. };
  103110. Object.defineProperty(Tools, "errorsCount", {
  103111. /**
  103112. * Gets a value indicating the number of loading errors
  103113. * @ignorenaming
  103114. */
  103115. get: function () {
  103116. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].errorsCount;
  103117. },
  103118. enumerable: true,
  103119. configurable: true
  103120. });
  103121. /**
  103122. * Log a message to the console
  103123. * @param message defines the message to log
  103124. */
  103125. Tools.Log = function (message) {
  103126. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log(message);
  103127. };
  103128. /**
  103129. * Write a warning message to the console
  103130. * @param message defines the message to log
  103131. */
  103132. Tools.Warn = function (message) {
  103133. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(message);
  103134. };
  103135. /**
  103136. * Write an error message to the console
  103137. * @param message defines the message to log
  103138. */
  103139. Tools.Error = function (message) {
  103140. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error(message);
  103141. };
  103142. Object.defineProperty(Tools, "LogCache", {
  103143. /**
  103144. * Gets current log cache (list of logs)
  103145. */
  103146. get: function () {
  103147. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogCache;
  103148. },
  103149. enumerable: true,
  103150. configurable: true
  103151. });
  103152. /**
  103153. * Clears the log cache
  103154. */
  103155. Tools.ClearLogCache = function () {
  103156. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ClearLogCache();
  103157. };
  103158. Object.defineProperty(Tools, "LogLevels", {
  103159. /**
  103160. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  103161. */
  103162. set: function (level) {
  103163. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogLevels = level;
  103164. },
  103165. enumerable: true,
  103166. configurable: true
  103167. });
  103168. /**
  103169. * Checks if the loaded document was accessed via `file:`-Protocol.
  103170. * @returns boolean
  103171. */
  103172. Tools.IsFileURL = function () {
  103173. return location.protocol === "file:";
  103174. };
  103175. Object.defineProperty(Tools, "PerformanceLogLevel", {
  103176. /**
  103177. * Sets the current performance log level
  103178. */
  103179. set: function (level) {
  103180. if ((level & Tools.PerformanceUserMarkLogLevel) === Tools.PerformanceUserMarkLogLevel) {
  103181. Tools.StartPerformanceCounter = Tools._StartUserMark;
  103182. Tools.EndPerformanceCounter = Tools._EndUserMark;
  103183. return;
  103184. }
  103185. if ((level & Tools.PerformanceConsoleLogLevel) === Tools.PerformanceConsoleLogLevel) {
  103186. Tools.StartPerformanceCounter = Tools._StartPerformanceConsole;
  103187. Tools.EndPerformanceCounter = Tools._EndPerformanceConsole;
  103188. return;
  103189. }
  103190. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  103191. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  103192. },
  103193. enumerable: true,
  103194. configurable: true
  103195. });
  103196. Tools._StartPerformanceCounterDisabled = function (counterName, condition) {
  103197. };
  103198. Tools._EndPerformanceCounterDisabled = function (counterName, condition) {
  103199. };
  103200. Tools._StartUserMark = function (counterName, condition) {
  103201. if (condition === void 0) { condition = true; }
  103202. if (!Tools._performance) {
  103203. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  103204. return;
  103205. }
  103206. Tools._performance = window.performance;
  103207. }
  103208. if (!condition || !Tools._performance.mark) {
  103209. return;
  103210. }
  103211. Tools._performance.mark(counterName + "-Begin");
  103212. };
  103213. Tools._EndUserMark = function (counterName, condition) {
  103214. if (condition === void 0) { condition = true; }
  103215. if (!condition || !Tools._performance.mark) {
  103216. return;
  103217. }
  103218. Tools._performance.mark(counterName + "-End");
  103219. Tools._performance.measure(counterName, counterName + "-Begin", counterName + "-End");
  103220. };
  103221. Tools._StartPerformanceConsole = function (counterName, condition) {
  103222. if (condition === void 0) { condition = true; }
  103223. if (!condition) {
  103224. return;
  103225. }
  103226. Tools._StartUserMark(counterName, condition);
  103227. if (console.time) {
  103228. console.time(counterName);
  103229. }
  103230. };
  103231. Tools._EndPerformanceConsole = function (counterName, condition) {
  103232. if (condition === void 0) { condition = true; }
  103233. if (!condition) {
  103234. return;
  103235. }
  103236. Tools._EndUserMark(counterName, condition);
  103237. if (console.time) {
  103238. console.timeEnd(counterName);
  103239. }
  103240. };
  103241. Object.defineProperty(Tools, "Now", {
  103242. /**
  103243. * Gets either window.performance.now() if supported or Date.now() else
  103244. */
  103245. get: function () {
  103246. return _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  103247. },
  103248. enumerable: true,
  103249. configurable: true
  103250. });
  103251. /**
  103252. * This method will return the name of the class used to create the instance of the given object.
  103253. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  103254. * @param object the object to get the class name from
  103255. * @param isType defines if the object is actually a type
  103256. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  103257. */
  103258. Tools.GetClassName = function (object, isType) {
  103259. if (isType === void 0) { isType = false; }
  103260. var name = null;
  103261. if (!isType && object.getClassName) {
  103262. name = object.getClassName();
  103263. }
  103264. else {
  103265. if (object instanceof Object) {
  103266. var classObj = isType ? object : Object.getPrototypeOf(object);
  103267. name = classObj.constructor["__bjsclassName__"];
  103268. }
  103269. if (!name) {
  103270. name = typeof object;
  103271. }
  103272. }
  103273. return name;
  103274. };
  103275. /**
  103276. * Gets the first element of an array satisfying a given predicate
  103277. * @param array defines the array to browse
  103278. * @param predicate defines the predicate to use
  103279. * @returns null if not found or the element
  103280. */
  103281. Tools.First = function (array, predicate) {
  103282. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  103283. var el = array_1[_i];
  103284. if (predicate(el)) {
  103285. return el;
  103286. }
  103287. }
  103288. return null;
  103289. };
  103290. /**
  103291. * This method will return the name of the full name of the class, including its owning module (if any).
  103292. * 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).
  103293. * @param object the object to get the class name from
  103294. * @param isType defines if the object is actually a type
  103295. * @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.
  103296. * @ignorenaming
  103297. */
  103298. Tools.getFullClassName = function (object, isType) {
  103299. if (isType === void 0) { isType = false; }
  103300. var className = null;
  103301. var moduleName = null;
  103302. if (!isType && object.getClassName) {
  103303. className = object.getClassName();
  103304. }
  103305. else {
  103306. if (object instanceof Object) {
  103307. var classObj = isType ? object : Object.getPrototypeOf(object);
  103308. className = classObj.constructor["__bjsclassName__"];
  103309. moduleName = classObj.constructor["__bjsmoduleName__"];
  103310. }
  103311. if (!className) {
  103312. className = typeof object;
  103313. }
  103314. }
  103315. if (!className) {
  103316. return null;
  103317. }
  103318. return ((moduleName != null) ? (moduleName + ".") : "") + className;
  103319. };
  103320. /**
  103321. * Returns a promise that resolves after the given amount of time.
  103322. * @param delay Number of milliseconds to delay
  103323. * @returns Promise that resolves after the given amount of time
  103324. */
  103325. Tools.DelayAsync = function (delay) {
  103326. return new Promise(function (resolve) {
  103327. setTimeout(function () {
  103328. resolve();
  103329. }, delay);
  103330. });
  103331. };
  103332. /**
  103333. * Gets the current gradient from an array of IValueGradient
  103334. * @param ratio defines the current ratio to get
  103335. * @param gradients defines the array of IValueGradient
  103336. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  103337. */
  103338. Tools.GetCurrentGradient = function (ratio, gradients, updateFunc) {
  103339. for (var gradientIndex = 0; gradientIndex < gradients.length - 1; gradientIndex++) {
  103340. var currentGradient = gradients[gradientIndex];
  103341. var nextGradient = gradients[gradientIndex + 1];
  103342. if (ratio >= currentGradient.gradient && ratio <= nextGradient.gradient) {
  103343. var scale = (ratio - currentGradient.gradient) / (nextGradient.gradient - currentGradient.gradient);
  103344. updateFunc(currentGradient, nextGradient, scale);
  103345. return;
  103346. }
  103347. }
  103348. // Use last index if over
  103349. var lastIndex = gradients.length - 1;
  103350. updateFunc(gradients[lastIndex], gradients[lastIndex], 1.0);
  103351. };
  103352. /**
  103353. * Gets or sets the base URL to use to load assets
  103354. */
  103355. Tools.BaseUrl = "";
  103356. /**
  103357. * Enable/Disable Custom HTTP Request Headers globally.
  103358. * default = false
  103359. * @see CustomRequestHeaders
  103360. */
  103361. Tools.UseCustomRequestHeaders = false;
  103362. /**
  103363. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  103364. * i.e. when loading files, where the server/service expects an Authorization header
  103365. */
  103366. Tools.CustomRequestHeaders = _webRequest__WEBPACK_IMPORTED_MODULE_12__["WebRequest"].CustomRequestHeaders;
  103367. /**
  103368. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  103369. */
  103370. Tools.DefaultRetryStrategy = RetryStrategy.ExponentialBackoff();
  103371. /**
  103372. * Default behaviour for cors in the application.
  103373. * It can be a string if the expected behavior is identical in the entire app.
  103374. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  103375. */
  103376. Tools.CorsBehavior = "anonymous";
  103377. /**
  103378. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  103379. * @ignorenaming
  103380. */
  103381. Tools.UseFallbackTexture = true;
  103382. /**
  103383. * Use this object to register external classes like custom textures or material
  103384. * to allow the laoders to instantiate them
  103385. */
  103386. Tools.RegisteredExternalClasses = {};
  103387. /**
  103388. * Texture content used if a texture cannot loaded
  103389. * @ignorenaming
  103390. */
  103391. 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";
  103392. Tools._tmpFloatArray = new Float32Array(1);
  103393. /**
  103394. * Extracts text content from a DOM element hierarchy
  103395. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  103396. */
  103397. Tools.GetDOMTextContent = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].GetDOMTextContent;
  103398. /**
  103399. * Gets or sets a function used to pre-process url before using them to load assets
  103400. */
  103401. Tools.PreprocessUrl = function (url) {
  103402. return url;
  103403. };
  103404. // Logs
  103405. /**
  103406. * No log
  103407. */
  103408. Tools.NoneLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].NoneLogLevel;
  103409. /**
  103410. * Only message logs
  103411. */
  103412. Tools.MessageLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].MessageLogLevel;
  103413. /**
  103414. * Only warning logs
  103415. */
  103416. Tools.WarningLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].WarningLogLevel;
  103417. /**
  103418. * Only error logs
  103419. */
  103420. Tools.ErrorLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ErrorLogLevel;
  103421. /**
  103422. * All logs
  103423. */
  103424. Tools.AllLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].AllLogLevel;
  103425. /**
  103426. * Checks if the window object exists
  103427. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  103428. */
  103429. Tools.IsWindowObjectExist = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist;
  103430. // Performances
  103431. /**
  103432. * No performance log
  103433. */
  103434. Tools.PerformanceNoneLogLevel = 0;
  103435. /**
  103436. * Use user marks to log performance
  103437. */
  103438. Tools.PerformanceUserMarkLogLevel = 1;
  103439. /**
  103440. * Log performance to the console
  103441. */
  103442. Tools.PerformanceConsoleLogLevel = 2;
  103443. /**
  103444. * Starts a performance counter
  103445. */
  103446. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  103447. /**
  103448. * Ends a specific performance coutner
  103449. */
  103450. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  103451. return Tools;
  103452. }());
  103453. /**
  103454. * This class is used to track a performance counter which is number based.
  103455. * The user has access to many properties which give statistics of different nature.
  103456. *
  103457. * The implementer can track two kinds of Performance Counter: time and count.
  103458. * 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.
  103459. * 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.
  103460. */
  103461. var PerfCounter = /** @class */ (function () {
  103462. /**
  103463. * Creates a new counter
  103464. */
  103465. function PerfCounter() {
  103466. this._startMonitoringTime = 0;
  103467. this._min = 0;
  103468. this._max = 0;
  103469. this._average = 0;
  103470. this._lastSecAverage = 0;
  103471. this._current = 0;
  103472. this._totalValueCount = 0;
  103473. this._totalAccumulated = 0;
  103474. this._lastSecAccumulated = 0;
  103475. this._lastSecTime = 0;
  103476. this._lastSecValueCount = 0;
  103477. }
  103478. Object.defineProperty(PerfCounter.prototype, "min", {
  103479. /**
  103480. * Returns the smallest value ever
  103481. */
  103482. get: function () {
  103483. return this._min;
  103484. },
  103485. enumerable: true,
  103486. configurable: true
  103487. });
  103488. Object.defineProperty(PerfCounter.prototype, "max", {
  103489. /**
  103490. * Returns the biggest value ever
  103491. */
  103492. get: function () {
  103493. return this._max;
  103494. },
  103495. enumerable: true,
  103496. configurable: true
  103497. });
  103498. Object.defineProperty(PerfCounter.prototype, "average", {
  103499. /**
  103500. * Returns the average value since the performance counter is running
  103501. */
  103502. get: function () {
  103503. return this._average;
  103504. },
  103505. enumerable: true,
  103506. configurable: true
  103507. });
  103508. Object.defineProperty(PerfCounter.prototype, "lastSecAverage", {
  103509. /**
  103510. * Returns the average value of the last second the counter was monitored
  103511. */
  103512. get: function () {
  103513. return this._lastSecAverage;
  103514. },
  103515. enumerable: true,
  103516. configurable: true
  103517. });
  103518. Object.defineProperty(PerfCounter.prototype, "current", {
  103519. /**
  103520. * Returns the current value
  103521. */
  103522. get: function () {
  103523. return this._current;
  103524. },
  103525. enumerable: true,
  103526. configurable: true
  103527. });
  103528. Object.defineProperty(PerfCounter.prototype, "total", {
  103529. /**
  103530. * Gets the accumulated total
  103531. */
  103532. get: function () {
  103533. return this._totalAccumulated;
  103534. },
  103535. enumerable: true,
  103536. configurable: true
  103537. });
  103538. Object.defineProperty(PerfCounter.prototype, "count", {
  103539. /**
  103540. * Gets the total value count
  103541. */
  103542. get: function () {
  103543. return this._totalValueCount;
  103544. },
  103545. enumerable: true,
  103546. configurable: true
  103547. });
  103548. /**
  103549. * Call this method to start monitoring a new frame.
  103550. * 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.
  103551. */
  103552. PerfCounter.prototype.fetchNewFrame = function () {
  103553. this._totalValueCount++;
  103554. this._current = 0;
  103555. this._lastSecValueCount++;
  103556. };
  103557. /**
  103558. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  103559. * @param newCount the count value to add to the monitored count
  103560. * @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.
  103561. */
  103562. PerfCounter.prototype.addCount = function (newCount, fetchResult) {
  103563. if (!PerfCounter.Enabled) {
  103564. return;
  103565. }
  103566. this._current += newCount;
  103567. if (fetchResult) {
  103568. this._fetchResult();
  103569. }
  103570. };
  103571. /**
  103572. * Start monitoring this performance counter
  103573. */
  103574. PerfCounter.prototype.beginMonitoring = function () {
  103575. if (!PerfCounter.Enabled) {
  103576. return;
  103577. }
  103578. this._startMonitoringTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  103579. };
  103580. /**
  103581. * Compute the time lapsed since the previous beginMonitoring() call.
  103582. * @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
  103583. */
  103584. PerfCounter.prototype.endMonitoring = function (newFrame) {
  103585. if (newFrame === void 0) { newFrame = true; }
  103586. if (!PerfCounter.Enabled) {
  103587. return;
  103588. }
  103589. if (newFrame) {
  103590. this.fetchNewFrame();
  103591. }
  103592. var currentTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  103593. this._current = currentTime - this._startMonitoringTime;
  103594. if (newFrame) {
  103595. this._fetchResult();
  103596. }
  103597. };
  103598. PerfCounter.prototype._fetchResult = function () {
  103599. this._totalAccumulated += this._current;
  103600. this._lastSecAccumulated += this._current;
  103601. // Min/Max update
  103602. this._min = Math.min(this._min, this._current);
  103603. this._max = Math.max(this._max, this._current);
  103604. this._average = this._totalAccumulated / this._totalValueCount;
  103605. // Reset last sec?
  103606. var now = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  103607. if ((now - this._lastSecTime) > 1000) {
  103608. this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount;
  103609. this._lastSecTime = now;
  103610. this._lastSecAccumulated = 0;
  103611. this._lastSecValueCount = 0;
  103612. }
  103613. };
  103614. /**
  103615. * Gets or sets a global boolean to turn on and off all the counters
  103616. */
  103617. PerfCounter.Enabled = true;
  103618. return PerfCounter;
  103619. }());
  103620. /**
  103621. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  103622. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  103623. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  103624. * @param name The name of the class, case should be preserved
  103625. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  103626. */
  103627. function className(name, module) {
  103628. return function (target) {
  103629. target["__bjsclassName__"] = name;
  103630. target["__bjsmoduleName__"] = (module != null) ? module : null;
  103631. };
  103632. }
  103633. /**
  103634. * An implementation of a loop for asynchronous functions.
  103635. */
  103636. var AsyncLoop = /** @class */ (function () {
  103637. /**
  103638. * Constructor.
  103639. * @param iterations the number of iterations.
  103640. * @param func the function to run each iteration
  103641. * @param successCallback the callback that will be called upon succesful execution
  103642. * @param offset starting offset.
  103643. */
  103644. function AsyncLoop(
  103645. /**
  103646. * Defines the number of iterations for the loop
  103647. */
  103648. iterations, func, successCallback, offset) {
  103649. if (offset === void 0) { offset = 0; }
  103650. this.iterations = iterations;
  103651. this.index = offset - 1;
  103652. this._done = false;
  103653. this._fn = func;
  103654. this._successCallback = successCallback;
  103655. }
  103656. /**
  103657. * Execute the next iteration. Must be called after the last iteration was finished.
  103658. */
  103659. AsyncLoop.prototype.executeNext = function () {
  103660. if (!this._done) {
  103661. if (this.index + 1 < this.iterations) {
  103662. ++this.index;
  103663. this._fn(this);
  103664. }
  103665. else {
  103666. this.breakLoop();
  103667. }
  103668. }
  103669. };
  103670. /**
  103671. * Break the loop and run the success callback.
  103672. */
  103673. AsyncLoop.prototype.breakLoop = function () {
  103674. this._done = true;
  103675. this._successCallback();
  103676. };
  103677. /**
  103678. * Create and run an async loop.
  103679. * @param iterations the number of iterations.
  103680. * @param fn the function to run each iteration
  103681. * @param successCallback the callback that will be called upon succesful execution
  103682. * @param offset starting offset.
  103683. * @returns the created async loop object
  103684. */
  103685. AsyncLoop.Run = function (iterations, fn, successCallback, offset) {
  103686. if (offset === void 0) { offset = 0; }
  103687. var loop = new AsyncLoop(iterations, fn, successCallback, offset);
  103688. loop.executeNext();
  103689. return loop;
  103690. };
  103691. /**
  103692. * A for-loop that will run a given number of iterations synchronous and the rest async.
  103693. * @param iterations total number of iterations
  103694. * @param syncedIterations number of synchronous iterations in each async iteration.
  103695. * @param fn the function to call each iteration.
  103696. * @param callback a success call back that will be called when iterating stops.
  103697. * @param breakFunction a break condition (optional)
  103698. * @param timeout timeout settings for the setTimeout function. default - 0.
  103699. * @returns the created async loop object
  103700. */
  103701. AsyncLoop.SyncAsyncForLoop = function (iterations, syncedIterations, fn, callback, breakFunction, timeout) {
  103702. if (timeout === void 0) { timeout = 0; }
  103703. return AsyncLoop.Run(Math.ceil(iterations / syncedIterations), function (loop) {
  103704. if (breakFunction && breakFunction()) {
  103705. loop.breakLoop();
  103706. }
  103707. else {
  103708. setTimeout(function () {
  103709. for (var i = 0; i < syncedIterations; ++i) {
  103710. var iteration = (loop.index * syncedIterations) + i;
  103711. if (iteration >= iterations) {
  103712. break;
  103713. }
  103714. fn(iteration);
  103715. if (breakFunction && breakFunction()) {
  103716. loop.breakLoop();
  103717. break;
  103718. }
  103719. }
  103720. loop.executeNext();
  103721. }, timeout);
  103722. }
  103723. }, callback);
  103724. };
  103725. return AsyncLoop;
  103726. }());
  103727. /***/ }),
  103728. /***/ "./Misc/typeStore.ts":
  103729. /*!***************************!*\
  103730. !*** ./Misc/typeStore.ts ***!
  103731. \***************************/
  103732. /*! exports provided: _TypeStore */
  103733. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103734. "use strict";
  103735. __webpack_require__.r(__webpack_exports__);
  103736. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _TypeStore; });
  103737. /** @hidden */
  103738. var _TypeStore = /** @class */ (function () {
  103739. function _TypeStore() {
  103740. }
  103741. /** @hidden */
  103742. _TypeStore.GetClass = function (fqdn) {
  103743. if (this.RegisteredTypes && this.RegisteredTypes[fqdn]) {
  103744. return this.RegisteredTypes[fqdn];
  103745. }
  103746. return null;
  103747. };
  103748. /** @hidden */
  103749. _TypeStore.RegisteredTypes = {};
  103750. return _TypeStore;
  103751. }());
  103752. /***/ }),
  103753. /***/ "./Misc/videoRecorder.ts":
  103754. /*!*******************************!*\
  103755. !*** ./Misc/videoRecorder.ts ***!
  103756. \*******************************/
  103757. /*! exports provided: VideoRecorder */
  103758. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103759. "use strict";
  103760. __webpack_require__.r(__webpack_exports__);
  103761. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return VideoRecorder; });
  103762. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  103763. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  103764. /**
  103765. * This can helps recording videos from BabylonJS.
  103766. * This is based on the available WebRTC functionalities of the browser.
  103767. *
  103768. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  103769. */
  103770. var VideoRecorder = /** @class */ (function () {
  103771. /**
  103772. * Create a new VideoCapture object which can help converting what you see in Babylon to
  103773. * a video file.
  103774. * @param engine Defines the BabylonJS Engine you wish to record
  103775. * @param options Defines options that can be used to customized the capture
  103776. */
  103777. function VideoRecorder(engine, options) {
  103778. if (options === void 0) { options = null; }
  103779. if (!VideoRecorder.IsSupported(engine)) {
  103780. throw "Your browser does not support recording so far.";
  103781. }
  103782. var canvas = engine.getRenderingCanvas();
  103783. if (!canvas) {
  103784. throw "The babylon engine must have a canvas to be recorded";
  103785. }
  103786. this._canvas = canvas;
  103787. this._canvas.isRecording = false;
  103788. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, VideoRecorder._defaultOptions, options);
  103789. var stream = this._canvas.captureStream(this._options.fps);
  103790. if (this._options.audioTracks) {
  103791. for (var _i = 0, _a = this._options.audioTracks; _i < _a.length; _i++) {
  103792. var track = _a[_i];
  103793. stream.addTrack(track);
  103794. }
  103795. }
  103796. this._mediaRecorder = new MediaRecorder(stream, { mimeType: this._options.mimeType });
  103797. this._mediaRecorder.ondataavailable = this._handleDataAvailable.bind(this);
  103798. this._mediaRecorder.onerror = this._handleError.bind(this);
  103799. this._mediaRecorder.onstop = this._handleStop.bind(this);
  103800. }
  103801. /**
  103802. * Returns wehther or not the VideoRecorder is available in your browser.
  103803. * @param engine Defines the Babylon Engine to check the support for
  103804. * @returns true if supported otherwise false
  103805. */
  103806. VideoRecorder.IsSupported = function (engine) {
  103807. var canvas = engine.getRenderingCanvas();
  103808. return (!!canvas && typeof canvas.captureStream === "function");
  103809. };
  103810. Object.defineProperty(VideoRecorder.prototype, "isRecording", {
  103811. /**
  103812. * True wether a recording is already in progress.
  103813. */
  103814. get: function () {
  103815. return !!this._canvas && this._canvas.isRecording;
  103816. },
  103817. enumerable: true,
  103818. configurable: true
  103819. });
  103820. /**
  103821. * Stops the current recording before the default capture timeout passed in the startRecording
  103822. * functions.
  103823. */
  103824. VideoRecorder.prototype.stopRecording = function () {
  103825. if (!this._canvas || !this._mediaRecorder) {
  103826. return;
  103827. }
  103828. if (!this.isRecording) {
  103829. return;
  103830. }
  103831. this._canvas.isRecording = false;
  103832. this._mediaRecorder.stop();
  103833. };
  103834. /**
  103835. * Starts recording the canvas for a max duration specified in parameters.
  103836. * @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.
  103837. * @param maxDuration Defines the maximum recording time in seconds.
  103838. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  103839. * @return a promise callback at the end of the recording with the video data in Blob.
  103840. */
  103841. VideoRecorder.prototype.startRecording = function (fileName, maxDuration) {
  103842. var _this = this;
  103843. if (fileName === void 0) { fileName = "babylonjs.webm"; }
  103844. if (maxDuration === void 0) { maxDuration = 7; }
  103845. if (!this._canvas || !this._mediaRecorder) {
  103846. throw "Recorder has already been disposed";
  103847. }
  103848. if (this.isRecording) {
  103849. throw "Recording already in progress";
  103850. }
  103851. if (maxDuration > 0) {
  103852. setTimeout(function () {
  103853. _this.stopRecording();
  103854. }, maxDuration * 1000);
  103855. }
  103856. this._fileName = fileName;
  103857. this._recordedChunks = [];
  103858. this._resolve = null;
  103859. this._reject = null;
  103860. this._canvas.isRecording = true;
  103861. this._mediaRecorder.start(this._options.recordChunckSize);
  103862. return new Promise(function (resolve, reject) {
  103863. _this._resolve = resolve;
  103864. _this._reject = reject;
  103865. });
  103866. };
  103867. /**
  103868. * Releases internal resources used during the recording.
  103869. */
  103870. VideoRecorder.prototype.dispose = function () {
  103871. this._canvas = null;
  103872. this._mediaRecorder = null;
  103873. this._recordedChunks = [];
  103874. this._fileName = null;
  103875. this._resolve = null;
  103876. this._reject = null;
  103877. };
  103878. VideoRecorder.prototype._handleDataAvailable = function (event) {
  103879. if (event.data.size > 0) {
  103880. this._recordedChunks.push(event.data);
  103881. }
  103882. };
  103883. VideoRecorder.prototype._handleError = function (event) {
  103884. this.stopRecording();
  103885. if (this._reject) {
  103886. this._reject(event.error);
  103887. }
  103888. else {
  103889. throw new event.error();
  103890. }
  103891. };
  103892. VideoRecorder.prototype._handleStop = function () {
  103893. this.stopRecording();
  103894. var superBuffer = new Blob(this._recordedChunks);
  103895. if (this._resolve) {
  103896. this._resolve(superBuffer);
  103897. }
  103898. window.URL.createObjectURL(superBuffer);
  103899. if (this._fileName) {
  103900. _tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Download(superBuffer, this._fileName);
  103901. }
  103902. };
  103903. VideoRecorder._defaultOptions = {
  103904. mimeType: "video/webm",
  103905. fps: 25,
  103906. recordChunckSize: 3000
  103907. };
  103908. return VideoRecorder;
  103909. }());
  103910. /***/ }),
  103911. /***/ "./Misc/virtualJoystick.ts":
  103912. /*!*********************************!*\
  103913. !*** ./Misc/virtualJoystick.ts ***!
  103914. \*********************************/
  103915. /*! exports provided: JoystickAxis, VirtualJoystick */
  103916. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103917. "use strict";
  103918. __webpack_require__.r(__webpack_exports__);
  103919. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return JoystickAxis; });
  103920. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return VirtualJoystick; });
  103921. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  103922. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  103923. // Mainly based on these 2 articles :
  103924. // 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
  103925. // & on Seb Lee-Delisle original work: http://seb.ly/2011/04/multi-touch-game-controller-in-javascripthtml5-for-ipad/
  103926. /**
  103927. * Defines the potential axis of a Joystick
  103928. */
  103929. var JoystickAxis;
  103930. (function (JoystickAxis) {
  103931. /** X axis */
  103932. JoystickAxis[JoystickAxis["X"] = 0] = "X";
  103933. /** Y axis */
  103934. JoystickAxis[JoystickAxis["Y"] = 1] = "Y";
  103935. /** Z axis */
  103936. JoystickAxis[JoystickAxis["Z"] = 2] = "Z";
  103937. })(JoystickAxis || (JoystickAxis = {}));
  103938. /**
  103939. * Class used to define virtual joystick (used in touch mode)
  103940. */
  103941. var VirtualJoystick = /** @class */ (function () {
  103942. /**
  103943. * Creates a new virtual joystick
  103944. * @param leftJoystick defines that the joystick is for left hand (false by default)
  103945. */
  103946. function VirtualJoystick(leftJoystick) {
  103947. var _this = this;
  103948. if (leftJoystick) {
  103949. this._leftJoystick = true;
  103950. }
  103951. else {
  103952. this._leftJoystick = false;
  103953. }
  103954. VirtualJoystick._globalJoystickIndex++;
  103955. // By default left & right arrow keys are moving the X
  103956. // and up & down keys are moving the Y
  103957. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  103958. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  103959. this.reverseLeftRight = false;
  103960. this.reverseUpDown = false;
  103961. // collections of pointers
  103962. this._touches = new _stringDictionary__WEBPACK_IMPORTED_MODULE_1__["StringDictionary"]();
  103963. this.deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103964. this._joystickSensibility = 25;
  103965. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  103966. this._onResize = function (evt) {
  103967. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  103968. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  103969. if (VirtualJoystick.Canvas) {
  103970. VirtualJoystick.Canvas.width = VirtualJoystick.vjCanvasWidth;
  103971. VirtualJoystick.Canvas.height = VirtualJoystick.vjCanvasHeight;
  103972. }
  103973. VirtualJoystick.halfWidth = VirtualJoystick.vjCanvasWidth / 2;
  103974. };
  103975. // injecting a canvas element on top of the canvas 3D game
  103976. if (!VirtualJoystick.Canvas) {
  103977. window.addEventListener("resize", this._onResize, false);
  103978. VirtualJoystick.Canvas = document.createElement("canvas");
  103979. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  103980. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  103981. VirtualJoystick.Canvas.width = window.innerWidth;
  103982. VirtualJoystick.Canvas.height = window.innerHeight;
  103983. VirtualJoystick.Canvas.style.width = "100%";
  103984. VirtualJoystick.Canvas.style.height = "100%";
  103985. VirtualJoystick.Canvas.style.position = "absolute";
  103986. VirtualJoystick.Canvas.style.backgroundColor = "transparent";
  103987. VirtualJoystick.Canvas.style.top = "0px";
  103988. VirtualJoystick.Canvas.style.left = "0px";
  103989. VirtualJoystick.Canvas.style.zIndex = "5";
  103990. VirtualJoystick.Canvas.style.msTouchAction = "none";
  103991. // Support for jQuery PEP polyfill
  103992. VirtualJoystick.Canvas.setAttribute("touch-action", "none");
  103993. var context = VirtualJoystick.Canvas.getContext('2d');
  103994. if (!context) {
  103995. throw new Error("Unable to create canvas for virtual joystick");
  103996. }
  103997. VirtualJoystick.vjCanvasContext = context;
  103998. VirtualJoystick.vjCanvasContext.strokeStyle = "#ffffff";
  103999. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  104000. document.body.appendChild(VirtualJoystick.Canvas);
  104001. }
  104002. VirtualJoystick.halfWidth = VirtualJoystick.Canvas.width / 2;
  104003. this.pressed = false;
  104004. // default joystick color
  104005. this._joystickColor = "cyan";
  104006. this._joystickPointerID = -1;
  104007. // current joystick position
  104008. this._joystickPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  104009. this._joystickPreviousPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  104010. // origin joystick position
  104011. this._joystickPointerStartPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  104012. this._deltaJoystickVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  104013. this._onPointerDownHandlerRef = function (evt) {
  104014. _this._onPointerDown(evt);
  104015. };
  104016. this._onPointerMoveHandlerRef = function (evt) {
  104017. _this._onPointerMove(evt);
  104018. };
  104019. this._onPointerUpHandlerRef = function (evt) {
  104020. _this._onPointerUp(evt);
  104021. };
  104022. VirtualJoystick.Canvas.addEventListener('pointerdown', this._onPointerDownHandlerRef, false);
  104023. VirtualJoystick.Canvas.addEventListener('pointermove', this._onPointerMoveHandlerRef, false);
  104024. VirtualJoystick.Canvas.addEventListener('pointerup', this._onPointerUpHandlerRef, false);
  104025. VirtualJoystick.Canvas.addEventListener('pointerout', this._onPointerUpHandlerRef, false);
  104026. VirtualJoystick.Canvas.addEventListener("contextmenu", function (evt) {
  104027. evt.preventDefault(); // Disables system menu
  104028. }, false);
  104029. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  104030. }
  104031. /**
  104032. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  104033. * @param newJoystickSensibility defines the new sensibility
  104034. */
  104035. VirtualJoystick.prototype.setJoystickSensibility = function (newJoystickSensibility) {
  104036. this._joystickSensibility = newJoystickSensibility;
  104037. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  104038. };
  104039. VirtualJoystick.prototype._onPointerDown = function (e) {
  104040. var positionOnScreenCondition;
  104041. e.preventDefault();
  104042. if (this._leftJoystick === true) {
  104043. positionOnScreenCondition = (e.clientX < VirtualJoystick.halfWidth);
  104044. }
  104045. else {
  104046. positionOnScreenCondition = (e.clientX > VirtualJoystick.halfWidth);
  104047. }
  104048. if (positionOnScreenCondition && this._joystickPointerID < 0) {
  104049. // First contact will be dedicated to the virtual joystick
  104050. this._joystickPointerID = e.pointerId;
  104051. this._joystickPointerStartPos.x = e.clientX;
  104052. this._joystickPointerStartPos.y = e.clientY;
  104053. this._joystickPointerPos = this._joystickPointerStartPos.clone();
  104054. this._joystickPreviousPointerPos = this._joystickPointerStartPos.clone();
  104055. this._deltaJoystickVector.x = 0;
  104056. this._deltaJoystickVector.y = 0;
  104057. this.pressed = true;
  104058. this._touches.add(e.pointerId.toString(), e);
  104059. }
  104060. else {
  104061. // You can only trigger the action buttons with a joystick declared
  104062. if (VirtualJoystick._globalJoystickIndex < 2 && this._action) {
  104063. this._action();
  104064. this._touches.add(e.pointerId.toString(), { x: e.clientX, y: e.clientY, prevX: e.clientX, prevY: e.clientY });
  104065. }
  104066. }
  104067. };
  104068. VirtualJoystick.prototype._onPointerMove = function (e) {
  104069. // If the current pointer is the one associated to the joystick (first touch contact)
  104070. if (this._joystickPointerID == e.pointerId) {
  104071. this._joystickPointerPos.x = e.clientX;
  104072. this._joystickPointerPos.y = e.clientY;
  104073. this._deltaJoystickVector = this._joystickPointerPos.clone();
  104074. this._deltaJoystickVector = this._deltaJoystickVector.subtract(this._joystickPointerStartPos);
  104075. var directionLeftRight = this.reverseLeftRight ? -1 : 1;
  104076. var deltaJoystickX = directionLeftRight * this._deltaJoystickVector.x / this._inversedSensibility;
  104077. switch (this._axisTargetedByLeftAndRight) {
  104078. case JoystickAxis.X:
  104079. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickX));
  104080. break;
  104081. case JoystickAxis.Y:
  104082. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickX));
  104083. break;
  104084. case JoystickAxis.Z:
  104085. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickX));
  104086. break;
  104087. }
  104088. var directionUpDown = this.reverseUpDown ? 1 : -1;
  104089. var deltaJoystickY = directionUpDown * this._deltaJoystickVector.y / this._inversedSensibility;
  104090. switch (this._axisTargetedByUpAndDown) {
  104091. case JoystickAxis.X:
  104092. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickY));
  104093. break;
  104094. case JoystickAxis.Y:
  104095. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickY));
  104096. break;
  104097. case JoystickAxis.Z:
  104098. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickY));
  104099. break;
  104100. }
  104101. }
  104102. else {
  104103. var data = this._touches.get(e.pointerId.toString());
  104104. if (data) {
  104105. data.x = e.clientX;
  104106. data.y = e.clientY;
  104107. }
  104108. }
  104109. };
  104110. VirtualJoystick.prototype._onPointerUp = function (e) {
  104111. if (this._joystickPointerID == e.pointerId) {
  104112. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPointerStartPos.x - 64, this._joystickPointerStartPos.y - 64, 128, 128);
  104113. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x - 42, this._joystickPreviousPointerPos.y - 42, 84, 84);
  104114. this._joystickPointerID = -1;
  104115. this.pressed = false;
  104116. }
  104117. else {
  104118. var touch = this._touches.get(e.pointerId.toString());
  104119. if (touch) {
  104120. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  104121. }
  104122. }
  104123. this._deltaJoystickVector.x = 0;
  104124. this._deltaJoystickVector.y = 0;
  104125. this._touches.remove(e.pointerId.toString());
  104126. };
  104127. /**
  104128. * Change the color of the virtual joystick
  104129. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  104130. */
  104131. VirtualJoystick.prototype.setJoystickColor = function (newColor) {
  104132. this._joystickColor = newColor;
  104133. };
  104134. /**
  104135. * Defines a callback to call when the joystick is touched
  104136. * @param action defines the callback
  104137. */
  104138. VirtualJoystick.prototype.setActionOnTouch = function (action) {
  104139. this._action = action;
  104140. };
  104141. /**
  104142. * Defines which axis you'd like to control for left & right
  104143. * @param axis defines the axis to use
  104144. */
  104145. VirtualJoystick.prototype.setAxisForLeftRight = function (axis) {
  104146. switch (axis) {
  104147. case JoystickAxis.X:
  104148. case JoystickAxis.Y:
  104149. case JoystickAxis.Z:
  104150. this._axisTargetedByLeftAndRight = axis;
  104151. break;
  104152. default:
  104153. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  104154. break;
  104155. }
  104156. };
  104157. /**
  104158. * Defines which axis you'd like to control for up & down
  104159. * @param axis defines the axis to use
  104160. */
  104161. VirtualJoystick.prototype.setAxisForUpDown = function (axis) {
  104162. switch (axis) {
  104163. case JoystickAxis.X:
  104164. case JoystickAxis.Y:
  104165. case JoystickAxis.Z:
  104166. this._axisTargetedByUpAndDown = axis;
  104167. break;
  104168. default:
  104169. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  104170. break;
  104171. }
  104172. };
  104173. VirtualJoystick.prototype._drawVirtualJoystick = function () {
  104174. var _this = this;
  104175. if (this.pressed) {
  104176. this._touches.forEach(function (key, touch) {
  104177. if (touch.pointerId === _this._joystickPointerID) {
  104178. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPointerStartPos.x - 64, _this._joystickPointerStartPos.y - 64, 128, 128);
  104179. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPreviousPointerPos.x - 42, _this._joystickPreviousPointerPos.y - 42, 84, 84);
  104180. VirtualJoystick.vjCanvasContext.beginPath();
  104181. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  104182. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  104183. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 40, 0, Math.PI * 2, true);
  104184. VirtualJoystick.vjCanvasContext.stroke();
  104185. VirtualJoystick.vjCanvasContext.closePath();
  104186. VirtualJoystick.vjCanvasContext.beginPath();
  104187. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  104188. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  104189. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 60, 0, Math.PI * 2, true);
  104190. VirtualJoystick.vjCanvasContext.stroke();
  104191. VirtualJoystick.vjCanvasContext.closePath();
  104192. VirtualJoystick.vjCanvasContext.beginPath();
  104193. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  104194. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerPos.x, _this._joystickPointerPos.y, 40, 0, Math.PI * 2, true);
  104195. VirtualJoystick.vjCanvasContext.stroke();
  104196. VirtualJoystick.vjCanvasContext.closePath();
  104197. _this._joystickPreviousPointerPos = _this._joystickPointerPos.clone();
  104198. }
  104199. else {
  104200. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  104201. VirtualJoystick.vjCanvasContext.beginPath();
  104202. VirtualJoystick.vjCanvasContext.fillStyle = "white";
  104203. VirtualJoystick.vjCanvasContext.beginPath();
  104204. VirtualJoystick.vjCanvasContext.strokeStyle = "red";
  104205. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  104206. VirtualJoystick.vjCanvasContext.arc(touch.x, touch.y, 40, 0, Math.PI * 2, true);
  104207. VirtualJoystick.vjCanvasContext.stroke();
  104208. VirtualJoystick.vjCanvasContext.closePath();
  104209. touch.prevX = touch.x;
  104210. touch.prevY = touch.y;
  104211. }
  104212. });
  104213. }
  104214. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  104215. };
  104216. /**
  104217. * Release internal HTML canvas
  104218. */
  104219. VirtualJoystick.prototype.releaseCanvas = function () {
  104220. if (VirtualJoystick.Canvas) {
  104221. VirtualJoystick.Canvas.removeEventListener('pointerdown', this._onPointerDownHandlerRef);
  104222. VirtualJoystick.Canvas.removeEventListener('pointermove', this._onPointerMoveHandlerRef);
  104223. VirtualJoystick.Canvas.removeEventListener('pointerup', this._onPointerUpHandlerRef);
  104224. VirtualJoystick.Canvas.removeEventListener('pointerout', this._onPointerUpHandlerRef);
  104225. window.removeEventListener("resize", this._onResize);
  104226. document.body.removeChild(VirtualJoystick.Canvas);
  104227. VirtualJoystick.Canvas = null;
  104228. }
  104229. };
  104230. // Used to draw the virtual joystick inside a 2D canvas on top of the WebGL rendering canvas
  104231. VirtualJoystick._globalJoystickIndex = 0;
  104232. return VirtualJoystick;
  104233. }());
  104234. /***/ }),
  104235. /***/ "./Misc/webRequest.ts":
  104236. /*!****************************!*\
  104237. !*** ./Misc/webRequest.ts ***!
  104238. \****************************/
  104239. /*! exports provided: WebRequest */
  104240. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104241. "use strict";
  104242. __webpack_require__.r(__webpack_exports__);
  104243. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return WebRequest; });
  104244. /**
  104245. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  104246. */
  104247. var WebRequest = /** @class */ (function () {
  104248. function WebRequest() {
  104249. this._xhr = new XMLHttpRequest();
  104250. }
  104251. WebRequest.prototype._injectCustomRequestHeaders = function () {
  104252. for (var key in WebRequest.CustomRequestHeaders) {
  104253. var val = WebRequest.CustomRequestHeaders[key];
  104254. if (val) {
  104255. this._xhr.setRequestHeader(key, val);
  104256. }
  104257. }
  104258. };
  104259. Object.defineProperty(WebRequest.prototype, "onprogress", {
  104260. /**
  104261. * Gets or sets a function to be called when loading progress changes
  104262. */
  104263. get: function () {
  104264. return this._xhr.onprogress;
  104265. },
  104266. set: function (value) {
  104267. this._xhr.onprogress = value;
  104268. },
  104269. enumerable: true,
  104270. configurable: true
  104271. });
  104272. Object.defineProperty(WebRequest.prototype, "readyState", {
  104273. /**
  104274. * Returns client's state
  104275. */
  104276. get: function () {
  104277. return this._xhr.readyState;
  104278. },
  104279. enumerable: true,
  104280. configurable: true
  104281. });
  104282. Object.defineProperty(WebRequest.prototype, "status", {
  104283. /**
  104284. * Returns client's status
  104285. */
  104286. get: function () {
  104287. return this._xhr.status;
  104288. },
  104289. enumerable: true,
  104290. configurable: true
  104291. });
  104292. Object.defineProperty(WebRequest.prototype, "statusText", {
  104293. /**
  104294. * Returns client's status as a text
  104295. */
  104296. get: function () {
  104297. return this._xhr.statusText;
  104298. },
  104299. enumerable: true,
  104300. configurable: true
  104301. });
  104302. Object.defineProperty(WebRequest.prototype, "response", {
  104303. /**
  104304. * Returns client's response
  104305. */
  104306. get: function () {
  104307. return this._xhr.response;
  104308. },
  104309. enumerable: true,
  104310. configurable: true
  104311. });
  104312. Object.defineProperty(WebRequest.prototype, "responseURL", {
  104313. /**
  104314. * Returns client's response url
  104315. */
  104316. get: function () {
  104317. return this._xhr.responseURL;
  104318. },
  104319. enumerable: true,
  104320. configurable: true
  104321. });
  104322. Object.defineProperty(WebRequest.prototype, "responseText", {
  104323. /**
  104324. * Returns client's response as text
  104325. */
  104326. get: function () {
  104327. return this._xhr.responseText;
  104328. },
  104329. enumerable: true,
  104330. configurable: true
  104331. });
  104332. Object.defineProperty(WebRequest.prototype, "responseType", {
  104333. /**
  104334. * Gets or sets the expected response type
  104335. */
  104336. get: function () {
  104337. return this._xhr.responseType;
  104338. },
  104339. set: function (value) {
  104340. this._xhr.responseType = value;
  104341. },
  104342. enumerable: true,
  104343. configurable: true
  104344. });
  104345. WebRequest.prototype.addEventListener = function (type, listener, options) {
  104346. this._xhr.addEventListener(type, listener, options);
  104347. };
  104348. WebRequest.prototype.removeEventListener = function (type, listener, options) {
  104349. this._xhr.removeEventListener(type, listener, options);
  104350. };
  104351. /**
  104352. * Cancels any network activity
  104353. */
  104354. WebRequest.prototype.abort = function () {
  104355. this._xhr.abort();
  104356. };
  104357. /**
  104358. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  104359. * @param body defines an optional request body
  104360. */
  104361. WebRequest.prototype.send = function (body) {
  104362. if (WebRequest.CustomRequestHeaders) {
  104363. this._injectCustomRequestHeaders();
  104364. }
  104365. this._xhr.send(body);
  104366. };
  104367. /**
  104368. * Sets the request method, request URL
  104369. * @param method defines the method to use (GET, POST, etc..)
  104370. * @param url defines the url to connect with
  104371. */
  104372. WebRequest.prototype.open = function (method, url) {
  104373. for (var _i = 0, _a = WebRequest.CustomRequestModifiers; _i < _a.length; _i++) {
  104374. var update = _a[_i];
  104375. update(this._xhr);
  104376. }
  104377. return this._xhr.open(method, url, true);
  104378. };
  104379. /**
  104380. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  104381. * i.e. when loading files, where the server/service expects an Authorization header
  104382. */
  104383. WebRequest.CustomRequestHeaders = {};
  104384. /**
  104385. * Add callback functions in this array to update all the requests before they get sent to the network
  104386. */
  104387. WebRequest.CustomRequestModifiers = new Array();
  104388. return WebRequest;
  104389. }());
  104390. /***/ }),
  104391. /***/ "./Misc/workerPool.ts":
  104392. /*!****************************!*\
  104393. !*** ./Misc/workerPool.ts ***!
  104394. \****************************/
  104395. /*! exports provided: WorkerPool */
  104396. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104397. "use strict";
  104398. __webpack_require__.r(__webpack_exports__);
  104399. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return WorkerPool; });
  104400. /**
  104401. * Helper class to push actions to a pool of workers.
  104402. */
  104403. var WorkerPool = /** @class */ (function () {
  104404. /**
  104405. * Constructor
  104406. * @param workers Array of workers to use for actions
  104407. */
  104408. function WorkerPool(workers) {
  104409. this._pendingActions = new Array();
  104410. this._workerInfos = workers.map(function (worker) { return ({
  104411. worker: worker,
  104412. active: false
  104413. }); });
  104414. }
  104415. /**
  104416. * Terminates all workers and clears any pending actions.
  104417. */
  104418. WorkerPool.prototype.dispose = function () {
  104419. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  104420. var workerInfo = _a[_i];
  104421. workerInfo.worker.terminate();
  104422. }
  104423. delete this._workerInfos;
  104424. delete this._pendingActions;
  104425. };
  104426. /**
  104427. * Pushes an action to the worker pool. If all the workers are active, the action will be
  104428. * pended until a worker has completed its action.
  104429. * @param action The action to perform. Call onComplete when the action is complete.
  104430. */
  104431. WorkerPool.prototype.push = function (action) {
  104432. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  104433. var workerInfo = _a[_i];
  104434. if (!workerInfo.active) {
  104435. this._execute(workerInfo, action);
  104436. return;
  104437. }
  104438. }
  104439. this._pendingActions.push(action);
  104440. };
  104441. WorkerPool.prototype._execute = function (workerInfo, action) {
  104442. var _this = this;
  104443. workerInfo.active = true;
  104444. action(workerInfo.worker, function () {
  104445. workerInfo.active = false;
  104446. var nextAction = _this._pendingActions.shift();
  104447. if (nextAction) {
  104448. _this._execute(workerInfo, nextAction);
  104449. }
  104450. });
  104451. };
  104452. return WorkerPool;
  104453. }());
  104454. /***/ }),
  104455. /***/ "./Morph/index.ts":
  104456. /*!************************!*\
  104457. !*** ./Morph/index.ts ***!
  104458. \************************/
  104459. /*! exports provided: MorphTarget, MorphTargetManager */
  104460. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104461. "use strict";
  104462. __webpack_require__.r(__webpack_exports__);
  104463. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  104464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _morphTarget__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  104465. /* harmony import */ var _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./morphTargetManager */ "./Morph/morphTargetManager.ts");
  104466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__["MorphTargetManager"]; });
  104467. /***/ }),
  104468. /***/ "./Morph/morphTarget.ts":
  104469. /*!******************************!*\
  104470. !*** ./Morph/morphTarget.ts ***!
  104471. \******************************/
  104472. /*! exports provided: MorphTarget */
  104473. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104474. "use strict";
  104475. __webpack_require__.r(__webpack_exports__);
  104476. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return MorphTarget; });
  104477. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  104478. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  104479. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  104480. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  104481. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  104482. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  104483. /**
  104484. * Defines a target to use with MorphTargetManager
  104485. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  104486. */
  104487. var MorphTarget = /** @class */ (function () {
  104488. /**
  104489. * Creates a new MorphTarget
  104490. * @param name defines the name of the target
  104491. * @param influence defines the influence to use
  104492. * @param scene defines the scene the morphtarget belongs to
  104493. */
  104494. function MorphTarget(
  104495. /** defines the name of the target */
  104496. name, influence, scene) {
  104497. if (influence === void 0) { influence = 0; }
  104498. if (scene === void 0) { scene = null; }
  104499. this.name = name;
  104500. /**
  104501. * Gets or sets the list of animations
  104502. */
  104503. this.animations = new Array();
  104504. this._positions = null;
  104505. this._normals = null;
  104506. this._tangents = null;
  104507. /**
  104508. * Observable raised when the influence changes
  104509. */
  104510. this.onInfluenceChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  104511. /** @hidden */
  104512. this._onDataLayoutChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  104513. this._animationPropertiesOverride = null;
  104514. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  104515. this.influence = influence;
  104516. }
  104517. Object.defineProperty(MorphTarget.prototype, "influence", {
  104518. /**
  104519. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  104520. */
  104521. get: function () {
  104522. return this._influence;
  104523. },
  104524. set: function (influence) {
  104525. if (this._influence === influence) {
  104526. return;
  104527. }
  104528. var previous = this._influence;
  104529. this._influence = influence;
  104530. if (this.onInfluenceChanged.hasObservers) {
  104531. this.onInfluenceChanged.notifyObservers(previous === 0 || influence === 0);
  104532. }
  104533. },
  104534. enumerable: true,
  104535. configurable: true
  104536. });
  104537. Object.defineProperty(MorphTarget.prototype, "animationPropertiesOverride", {
  104538. /**
  104539. * Gets or sets the animation properties override
  104540. */
  104541. get: function () {
  104542. if (!this._animationPropertiesOverride && this._scene) {
  104543. return this._scene.animationPropertiesOverride;
  104544. }
  104545. return this._animationPropertiesOverride;
  104546. },
  104547. set: function (value) {
  104548. this._animationPropertiesOverride = value;
  104549. },
  104550. enumerable: true,
  104551. configurable: true
  104552. });
  104553. Object.defineProperty(MorphTarget.prototype, "hasPositions", {
  104554. /**
  104555. * Gets a boolean defining if the target contains position data
  104556. */
  104557. get: function () {
  104558. return !!this._positions;
  104559. },
  104560. enumerable: true,
  104561. configurable: true
  104562. });
  104563. Object.defineProperty(MorphTarget.prototype, "hasNormals", {
  104564. /**
  104565. * Gets a boolean defining if the target contains normal data
  104566. */
  104567. get: function () {
  104568. return !!this._normals;
  104569. },
  104570. enumerable: true,
  104571. configurable: true
  104572. });
  104573. Object.defineProperty(MorphTarget.prototype, "hasTangents", {
  104574. /**
  104575. * Gets a boolean defining if the target contains tangent data
  104576. */
  104577. get: function () {
  104578. return !!this._tangents;
  104579. },
  104580. enumerable: true,
  104581. configurable: true
  104582. });
  104583. /**
  104584. * Affects position data to this target
  104585. * @param data defines the position data to use
  104586. */
  104587. MorphTarget.prototype.setPositions = function (data) {
  104588. var hadPositions = this.hasPositions;
  104589. this._positions = data;
  104590. if (hadPositions !== this.hasPositions) {
  104591. this._onDataLayoutChanged.notifyObservers(undefined);
  104592. }
  104593. };
  104594. /**
  104595. * Gets the position data stored in this target
  104596. * @returns a FloatArray containing the position data (or null if not present)
  104597. */
  104598. MorphTarget.prototype.getPositions = function () {
  104599. return this._positions;
  104600. };
  104601. /**
  104602. * Affects normal data to this target
  104603. * @param data defines the normal data to use
  104604. */
  104605. MorphTarget.prototype.setNormals = function (data) {
  104606. var hadNormals = this.hasNormals;
  104607. this._normals = data;
  104608. if (hadNormals !== this.hasNormals) {
  104609. this._onDataLayoutChanged.notifyObservers(undefined);
  104610. }
  104611. };
  104612. /**
  104613. * Gets the normal data stored in this target
  104614. * @returns a FloatArray containing the normal data (or null if not present)
  104615. */
  104616. MorphTarget.prototype.getNormals = function () {
  104617. return this._normals;
  104618. };
  104619. /**
  104620. * Affects tangent data to this target
  104621. * @param data defines the tangent data to use
  104622. */
  104623. MorphTarget.prototype.setTangents = function (data) {
  104624. var hadTangents = this.hasTangents;
  104625. this._tangents = data;
  104626. if (hadTangents !== this.hasTangents) {
  104627. this._onDataLayoutChanged.notifyObservers(undefined);
  104628. }
  104629. };
  104630. /**
  104631. * Gets the tangent data stored in this target
  104632. * @returns a FloatArray containing the tangent data (or null if not present)
  104633. */
  104634. MorphTarget.prototype.getTangents = function () {
  104635. return this._tangents;
  104636. };
  104637. /**
  104638. * Serializes the current target into a Serialization object
  104639. * @returns the serialized object
  104640. */
  104641. MorphTarget.prototype.serialize = function () {
  104642. var serializationObject = {};
  104643. serializationObject.name = this.name;
  104644. serializationObject.influence = this.influence;
  104645. serializationObject.positions = Array.prototype.slice.call(this.getPositions());
  104646. if (this.id != null) {
  104647. serializationObject.id = this.id;
  104648. }
  104649. if (this.hasNormals) {
  104650. serializationObject.normals = Array.prototype.slice.call(this.getNormals());
  104651. }
  104652. if (this.hasTangents) {
  104653. serializationObject.tangents = Array.prototype.slice.call(this.getTangents());
  104654. }
  104655. // Animations
  104656. _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  104657. return serializationObject;
  104658. };
  104659. /**
  104660. * Returns the string "MorphTarget"
  104661. * @returns "MorphTarget"
  104662. */
  104663. MorphTarget.prototype.getClassName = function () {
  104664. return "MorphTarget";
  104665. };
  104666. // Statics
  104667. /**
  104668. * Creates a new target from serialized data
  104669. * @param serializationObject defines the serialized data to use
  104670. * @returns a new MorphTarget
  104671. */
  104672. MorphTarget.Parse = function (serializationObject) {
  104673. var result = new MorphTarget(serializationObject.name, serializationObject.influence);
  104674. result.setPositions(serializationObject.positions);
  104675. if (serializationObject.id != null) {
  104676. result.id = serializationObject.id;
  104677. }
  104678. if (serializationObject.normals) {
  104679. result.setNormals(serializationObject.normals);
  104680. }
  104681. if (serializationObject.tangents) {
  104682. result.setTangents(serializationObject.tangents);
  104683. }
  104684. // Animations
  104685. if (serializationObject.animations) {
  104686. for (var animationIndex = 0; animationIndex < serializationObject.animations.length; animationIndex++) {
  104687. var parsedAnimation = serializationObject.animations[animationIndex];
  104688. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  104689. if (internalClass) {
  104690. result.animations.push(internalClass.Parse(parsedAnimation));
  104691. }
  104692. }
  104693. }
  104694. return result;
  104695. };
  104696. /**
  104697. * Creates a MorphTarget from mesh data
  104698. * @param mesh defines the source mesh
  104699. * @param name defines the name to use for the new target
  104700. * @param influence defines the influence to attach to the target
  104701. * @returns a new MorphTarget
  104702. */
  104703. MorphTarget.FromMesh = function (mesh, name, influence) {
  104704. if (!name) {
  104705. name = mesh.name;
  104706. }
  104707. var result = new MorphTarget(name, influence, mesh.getScene());
  104708. result.setPositions(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind));
  104709. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  104710. result.setNormals(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind));
  104711. }
  104712. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  104713. result.setTangents(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind));
  104714. }
  104715. return result;
  104716. };
  104717. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  104718. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["serialize"])()
  104719. ], MorphTarget.prototype, "id", void 0);
  104720. return MorphTarget;
  104721. }());
  104722. /***/ }),
  104723. /***/ "./Morph/morphTargetManager.ts":
  104724. /*!*************************************!*\
  104725. !*** ./Morph/morphTargetManager.ts ***!
  104726. \*************************************/
  104727. /*! exports provided: MorphTargetManager */
  104728. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104729. "use strict";
  104730. __webpack_require__.r(__webpack_exports__);
  104731. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return MorphTargetManager; });
  104732. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  104733. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  104734. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  104735. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  104736. /**
  104737. * This class is used to deform meshes using morphing between different targets
  104738. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  104739. */
  104740. var MorphTargetManager = /** @class */ (function () {
  104741. /**
  104742. * Creates a new MorphTargetManager
  104743. * @param scene defines the current scene
  104744. */
  104745. function MorphTargetManager(scene) {
  104746. if (scene === void 0) { scene = null; }
  104747. this._targets = new Array();
  104748. this._targetInfluenceChangedObservers = new Array();
  104749. this._targetDataLayoutChangedObservers = new Array();
  104750. this._activeTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  104751. this._supportsNormals = false;
  104752. this._supportsTangents = false;
  104753. this._vertexCount = 0;
  104754. this._uniqueId = 0;
  104755. this._tempInfluences = new Array();
  104756. if (!scene) {
  104757. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  104758. }
  104759. this._scene = scene;
  104760. if (this._scene) {
  104761. this._scene.morphTargetManagers.push(this);
  104762. this._uniqueId = this._scene.getUniqueId();
  104763. }
  104764. }
  104765. Object.defineProperty(MorphTargetManager.prototype, "uniqueId", {
  104766. /**
  104767. * Gets the unique ID of this manager
  104768. */
  104769. get: function () {
  104770. return this._uniqueId;
  104771. },
  104772. enumerable: true,
  104773. configurable: true
  104774. });
  104775. Object.defineProperty(MorphTargetManager.prototype, "vertexCount", {
  104776. /**
  104777. * Gets the number of vertices handled by this manager
  104778. */
  104779. get: function () {
  104780. return this._vertexCount;
  104781. },
  104782. enumerable: true,
  104783. configurable: true
  104784. });
  104785. Object.defineProperty(MorphTargetManager.prototype, "supportsNormals", {
  104786. /**
  104787. * Gets a boolean indicating if this manager supports morphing of normals
  104788. */
  104789. get: function () {
  104790. return this._supportsNormals;
  104791. },
  104792. enumerable: true,
  104793. configurable: true
  104794. });
  104795. Object.defineProperty(MorphTargetManager.prototype, "supportsTangents", {
  104796. /**
  104797. * Gets a boolean indicating if this manager supports morphing of tangents
  104798. */
  104799. get: function () {
  104800. return this._supportsTangents;
  104801. },
  104802. enumerable: true,
  104803. configurable: true
  104804. });
  104805. Object.defineProperty(MorphTargetManager.prototype, "numTargets", {
  104806. /**
  104807. * Gets the number of targets stored in this manager
  104808. */
  104809. get: function () {
  104810. return this._targets.length;
  104811. },
  104812. enumerable: true,
  104813. configurable: true
  104814. });
  104815. Object.defineProperty(MorphTargetManager.prototype, "numInfluencers", {
  104816. /**
  104817. * Gets the number of influencers (ie. the number of targets with influences > 0)
  104818. */
  104819. get: function () {
  104820. return this._activeTargets.length;
  104821. },
  104822. enumerable: true,
  104823. configurable: true
  104824. });
  104825. Object.defineProperty(MorphTargetManager.prototype, "influences", {
  104826. /**
  104827. * Gets the list of influences (one per target)
  104828. */
  104829. get: function () {
  104830. return this._influences;
  104831. },
  104832. enumerable: true,
  104833. configurable: true
  104834. });
  104835. /**
  104836. * Gets the active target at specified index. An active target is a target with an influence > 0
  104837. * @param index defines the index to check
  104838. * @returns the requested target
  104839. */
  104840. MorphTargetManager.prototype.getActiveTarget = function (index) {
  104841. return this._activeTargets.data[index];
  104842. };
  104843. /**
  104844. * Gets the target at specified index
  104845. * @param index defines the index to check
  104846. * @returns the requested target
  104847. */
  104848. MorphTargetManager.prototype.getTarget = function (index) {
  104849. return this._targets[index];
  104850. };
  104851. /**
  104852. * Add a new target to this manager
  104853. * @param target defines the target to add
  104854. */
  104855. MorphTargetManager.prototype.addTarget = function (target) {
  104856. var _this = this;
  104857. this._targets.push(target);
  104858. this._targetInfluenceChangedObservers.push(target.onInfluenceChanged.add(function (needUpdate) {
  104859. _this._syncActiveTargets(needUpdate);
  104860. }));
  104861. this._targetDataLayoutChangedObservers.push(target._onDataLayoutChanged.add(function () {
  104862. _this._syncActiveTargets(true);
  104863. }));
  104864. this._syncActiveTargets(true);
  104865. };
  104866. /**
  104867. * Removes a target from the manager
  104868. * @param target defines the target to remove
  104869. */
  104870. MorphTargetManager.prototype.removeTarget = function (target) {
  104871. var index = this._targets.indexOf(target);
  104872. if (index >= 0) {
  104873. this._targets.splice(index, 1);
  104874. target.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(index, 1)[0]);
  104875. target._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(index, 1)[0]);
  104876. this._syncActiveTargets(true);
  104877. }
  104878. };
  104879. /**
  104880. * Serializes the current manager into a Serialization object
  104881. * @returns the serialized object
  104882. */
  104883. MorphTargetManager.prototype.serialize = function () {
  104884. var serializationObject = {};
  104885. serializationObject.id = this.uniqueId;
  104886. serializationObject.targets = [];
  104887. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  104888. var target = _a[_i];
  104889. serializationObject.targets.push(target.serialize());
  104890. }
  104891. return serializationObject;
  104892. };
  104893. MorphTargetManager.prototype._syncActiveTargets = function (needUpdate) {
  104894. var influenceCount = 0;
  104895. this._activeTargets.reset();
  104896. this._supportsNormals = true;
  104897. this._supportsTangents = true;
  104898. this._vertexCount = 0;
  104899. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  104900. var target = _a[_i];
  104901. if (target.influence === 0) {
  104902. continue;
  104903. }
  104904. this._activeTargets.push(target);
  104905. this._tempInfluences[influenceCount++] = target.influence;
  104906. this._supportsNormals = this._supportsNormals && target.hasNormals;
  104907. this._supportsTangents = this._supportsTangents && target.hasTangents;
  104908. var positions = target.getPositions();
  104909. if (positions) {
  104910. var vertexCount = positions.length / 3;
  104911. if (this._vertexCount === 0) {
  104912. this._vertexCount = vertexCount;
  104913. }
  104914. else if (this._vertexCount !== vertexCount) {
  104915. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Incompatible target. Targets must all have the same vertices count.");
  104916. return;
  104917. }
  104918. }
  104919. }
  104920. if (!this._influences || this._influences.length !== influenceCount) {
  104921. this._influences = new Float32Array(influenceCount);
  104922. }
  104923. for (var index = 0; index < influenceCount; index++) {
  104924. this._influences[index] = this._tempInfluences[index];
  104925. }
  104926. if (needUpdate) {
  104927. this.synchronize();
  104928. }
  104929. };
  104930. /**
  104931. * Syncrhonize the targets with all the meshes using this morph target manager
  104932. */
  104933. MorphTargetManager.prototype.synchronize = function () {
  104934. if (!this._scene) {
  104935. return;
  104936. }
  104937. // Flag meshes as dirty to resync with the active targets
  104938. for (var _i = 0, _a = this._scene.meshes; _i < _a.length; _i++) {
  104939. var mesh = _a[_i];
  104940. if (mesh.morphTargetManager === this) {
  104941. mesh._syncGeometryWithMorphTargetManager();
  104942. }
  104943. }
  104944. };
  104945. // Statics
  104946. /**
  104947. * Creates a new MorphTargetManager from serialized data
  104948. * @param serializationObject defines the serialized data
  104949. * @param scene defines the hosting scene
  104950. * @returns the new MorphTargetManager
  104951. */
  104952. MorphTargetManager.Parse = function (serializationObject, scene) {
  104953. var result = new MorphTargetManager(scene);
  104954. result._uniqueId = serializationObject.id;
  104955. for (var _i = 0, _a = serializationObject.targets; _i < _a.length; _i++) {
  104956. var targetData = _a[_i];
  104957. result.addTarget(_morphTarget__WEBPACK_IMPORTED_MODULE_3__["MorphTarget"].Parse(targetData));
  104958. }
  104959. return result;
  104960. };
  104961. return MorphTargetManager;
  104962. }());
  104963. /***/ }),
  104964. /***/ "./Offline/database.ts":
  104965. /*!*****************************!*\
  104966. !*** ./Offline/database.ts ***!
  104967. \*****************************/
  104968. /*! exports provided: Database */
  104969. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104970. "use strict";
  104971. __webpack_require__.r(__webpack_exports__);
  104972. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return Database; });
  104973. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  104974. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  104975. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tga */ "./Misc/tga.ts");
  104976. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  104977. /* harmony import */ var _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/webRequest */ "./Misc/webRequest.ts");
  104978. // Sets the default offline provider to Babylon.js
  104979. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].OfflineProviderFactory = function (urlToScene, callbackManifestChecked, disableManifestCheck) {
  104980. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  104981. return new Database(urlToScene, callbackManifestChecked, disableManifestCheck);
  104982. };
  104983. /**
  104984. * Class used to enable access to IndexedDB
  104985. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  104986. */
  104987. var Database = /** @class */ (function () {
  104988. /**
  104989. * Creates a new Database
  104990. * @param urlToScene defines the url to load the scene
  104991. * @param callbackManifestChecked defines the callback to use when manifest is checked
  104992. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  104993. */
  104994. function Database(urlToScene, callbackManifestChecked, disableManifestCheck) {
  104995. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  104996. var _this = this;
  104997. // Handling various flavors of prefixed version of IndexedDB
  104998. this._idbFactory = (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB);
  104999. this._callbackManifestChecked = callbackManifestChecked;
  105000. this._currentSceneUrl = Database._ReturnFullUrlLocation(urlToScene);
  105001. this._db = null;
  105002. this._enableSceneOffline = false;
  105003. this._enableTexturesOffline = false;
  105004. this._manifestVersionFound = 0;
  105005. this._mustUpdateRessources = false;
  105006. this._hasReachedQuota = false;
  105007. if (!Database.IDBStorageEnabled) {
  105008. this._callbackManifestChecked(true);
  105009. }
  105010. else {
  105011. if (disableManifestCheck) {
  105012. this._enableSceneOffline = true;
  105013. this._enableTexturesOffline = true;
  105014. this._manifestVersionFound = 1;
  105015. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  105016. _this._callbackManifestChecked(true);
  105017. });
  105018. }
  105019. else {
  105020. this._checkManifestFile();
  105021. }
  105022. }
  105023. }
  105024. Object.defineProperty(Database.prototype, "enableSceneOffline", {
  105025. /**
  105026. * Gets a boolean indicating if scene must be saved in the database
  105027. */
  105028. get: function () {
  105029. return this._enableSceneOffline;
  105030. },
  105031. enumerable: true,
  105032. configurable: true
  105033. });
  105034. Object.defineProperty(Database.prototype, "enableTexturesOffline", {
  105035. /**
  105036. * Gets a boolean indicating if textures must be saved in the database
  105037. */
  105038. get: function () {
  105039. return this._enableTexturesOffline;
  105040. },
  105041. enumerable: true,
  105042. configurable: true
  105043. });
  105044. Database.prototype._checkManifestFile = function () {
  105045. var _this = this;
  105046. var noManifestFile = function () {
  105047. _this._enableSceneOffline = false;
  105048. _this._enableTexturesOffline = false;
  105049. _this._callbackManifestChecked(false);
  105050. };
  105051. var timeStampUsed = false;
  105052. var manifestURL = this._currentSceneUrl + ".manifest";
  105053. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__["WebRequest"]();
  105054. if (navigator.onLine) {
  105055. // Adding a timestamp to by-pass browsers' cache
  105056. timeStampUsed = true;
  105057. manifestURL = manifestURL + (manifestURL.match(/\?/) == null ? "?" : "&") + Date.now();
  105058. }
  105059. xhr.open("GET", manifestURL);
  105060. xhr.addEventListener("load", function () {
  105061. if (xhr.status === 200 || Database._ValidateXHRData(xhr, 1)) {
  105062. try {
  105063. var manifestFile = JSON.parse(xhr.response);
  105064. _this._enableSceneOffline = manifestFile.enableSceneOffline;
  105065. _this._enableTexturesOffline = manifestFile.enableTexturesOffline && Database.IsUASupportingBlobStorage;
  105066. if (manifestFile.version && !isNaN(parseInt(manifestFile.version))) {
  105067. _this._manifestVersionFound = manifestFile.version;
  105068. }
  105069. if (_this._callbackManifestChecked) {
  105070. _this._callbackManifestChecked(true);
  105071. }
  105072. }
  105073. catch (ex) {
  105074. noManifestFile();
  105075. }
  105076. }
  105077. else {
  105078. noManifestFile();
  105079. }
  105080. }, false);
  105081. xhr.addEventListener("error", function () {
  105082. if (timeStampUsed) {
  105083. timeStampUsed = false;
  105084. // Let's retry without the timeStamp
  105085. // It could fail when coupled with HTML5 Offline API
  105086. var retryManifestURL = _this._currentSceneUrl + ".manifest";
  105087. xhr.open("GET", retryManifestURL);
  105088. xhr.send();
  105089. }
  105090. else {
  105091. noManifestFile();
  105092. }
  105093. }, false);
  105094. try {
  105095. xhr.send();
  105096. }
  105097. catch (ex) {
  105098. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error on XHR send request.");
  105099. this._callbackManifestChecked(false);
  105100. }
  105101. };
  105102. /**
  105103. * Open the database and make it available
  105104. * @param successCallback defines the callback to call on success
  105105. * @param errorCallback defines the callback to call on error
  105106. */
  105107. Database.prototype.open = function (successCallback, errorCallback) {
  105108. var _this = this;
  105109. var handleError = function () {
  105110. _this._isSupported = false;
  105111. if (errorCallback) {
  105112. errorCallback();
  105113. }
  105114. };
  105115. if (!this._idbFactory || !(this._enableSceneOffline || this._enableTexturesOffline)) {
  105116. // Your browser doesn't support IndexedDB
  105117. this._isSupported = false;
  105118. if (errorCallback) {
  105119. errorCallback();
  105120. }
  105121. }
  105122. else {
  105123. // If the DB hasn't been opened or created yet
  105124. if (!this._db) {
  105125. this._hasReachedQuota = false;
  105126. this._isSupported = true;
  105127. var request = this._idbFactory.open("babylonjs", 1);
  105128. // Could occur if user is blocking the quota for the DB and/or doesn't grant access to IndexedDB
  105129. request.onerror = function () {
  105130. handleError();
  105131. };
  105132. // executes when a version change transaction cannot complete due to other active transactions
  105133. request.onblocked = function () {
  105134. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("IDB request blocked. Please reload the page.");
  105135. handleError();
  105136. };
  105137. // DB has been opened successfully
  105138. request.onsuccess = function () {
  105139. _this._db = request.result;
  105140. successCallback();
  105141. };
  105142. // Initialization of the DB. Creating Scenes & Textures stores
  105143. request.onupgradeneeded = function (event) {
  105144. _this._db = (event.target).result;
  105145. if (_this._db) {
  105146. try {
  105147. _this._db.createObjectStore("scenes", { keyPath: "sceneUrl" });
  105148. _this._db.createObjectStore("versions", { keyPath: "sceneUrl" });
  105149. _this._db.createObjectStore("textures", { keyPath: "textureUrl" });
  105150. }
  105151. catch (ex) {
  105152. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while creating object stores. Exception: " + ex.message);
  105153. handleError();
  105154. }
  105155. }
  105156. };
  105157. }
  105158. // DB has already been created and opened
  105159. else {
  105160. if (successCallback) {
  105161. successCallback();
  105162. }
  105163. }
  105164. }
  105165. };
  105166. /**
  105167. * Loads an image from the database
  105168. * @param url defines the url to load from
  105169. * @param image defines the target DOM image
  105170. */
  105171. Database.prototype.loadImage = function (url, image) {
  105172. var _this = this;
  105173. var completeURL = Database._ReturnFullUrlLocation(url);
  105174. var saveAndLoadImage = function () {
  105175. if (!_this._hasReachedQuota && _this._db !== null) {
  105176. // the texture is not yet in the DB, let's try to save it
  105177. _this._saveImageIntoDBAsync(completeURL, image);
  105178. }
  105179. // If the texture is not in the DB and we've reached the DB quota limit
  105180. // let's load it directly from the web
  105181. else {
  105182. image.src = url;
  105183. }
  105184. };
  105185. if (!this._mustUpdateRessources) {
  105186. this._loadImageFromDBAsync(completeURL, image, saveAndLoadImage);
  105187. }
  105188. // First time we're download the images or update requested in the manifest file by a version change
  105189. else {
  105190. saveAndLoadImage();
  105191. }
  105192. };
  105193. Database.prototype._loadImageFromDBAsync = function (url, image, notInDBCallback) {
  105194. if (this._isSupported && this._db !== null) {
  105195. var texture;
  105196. var transaction = this._db.transaction(["textures"]);
  105197. transaction.onabort = function () {
  105198. image.src = url;
  105199. };
  105200. transaction.oncomplete = function () {
  105201. var blobTextureURL;
  105202. if (texture) {
  105203. var URL = window.URL || window.webkitURL;
  105204. blobTextureURL = URL.createObjectURL(texture.data);
  105205. image.onerror = function () {
  105206. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading image from blob URL: " + blobTextureURL + " switching back to web url: " + url);
  105207. image.src = url;
  105208. };
  105209. image.src = blobTextureURL;
  105210. }
  105211. else {
  105212. notInDBCallback();
  105213. }
  105214. };
  105215. var getRequest = transaction.objectStore("textures").get(url);
  105216. getRequest.onsuccess = function (event) {
  105217. texture = (event.target).result;
  105218. };
  105219. getRequest.onerror = function () {
  105220. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading texture " + url + " from DB.");
  105221. image.src = url;
  105222. };
  105223. }
  105224. else {
  105225. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  105226. image.src = url;
  105227. }
  105228. };
  105229. Database.prototype._saveImageIntoDBAsync = function (url, image) {
  105230. var _this = this;
  105231. if (this._isSupported) {
  105232. // In case of error (type not supported or quota exceeded), we're at least sending back XHR data to allow texture loading later on
  105233. var generateBlobUrl = function () {
  105234. var blobTextureURL;
  105235. if (blob) {
  105236. var URL = window.URL || window.webkitURL;
  105237. try {
  105238. blobTextureURL = URL.createObjectURL(blob);
  105239. }
  105240. // Chrome is raising a type error if we're setting the oneTimeOnly parameter
  105241. catch (ex) {
  105242. blobTextureURL = URL.createObjectURL(blob);
  105243. }
  105244. }
  105245. if (blobTextureURL) {
  105246. image.src = blobTextureURL;
  105247. }
  105248. };
  105249. if (Database.IsUASupportingBlobStorage) { // Create XHR
  105250. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__["WebRequest"](), blob;
  105251. xhr.open("GET", url);
  105252. xhr.responseType = "blob";
  105253. xhr.addEventListener("load", function () {
  105254. if (xhr.status === 200 && _this._db) {
  105255. // Blob as response (XHR2)
  105256. blob = xhr.response;
  105257. var transaction = _this._db.transaction(["textures"], "readwrite");
  105258. // the transaction could abort because of a QuotaExceededError error
  105259. transaction.onabort = function (event) {
  105260. try {
  105261. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  105262. var srcElement = (event.srcElement || event.target);
  105263. var error = srcElement.error;
  105264. if (error && error.name === "QuotaExceededError") {
  105265. _this._hasReachedQuota = true;
  105266. }
  105267. }
  105268. catch (ex) { }
  105269. generateBlobUrl();
  105270. };
  105271. transaction.oncomplete = function () {
  105272. generateBlobUrl();
  105273. };
  105274. var newTexture = { textureUrl: url, data: blob };
  105275. try {
  105276. // Put the blob into the dabase
  105277. var addRequest = transaction.objectStore("textures").put(newTexture);
  105278. addRequest.onsuccess = function () {
  105279. };
  105280. addRequest.onerror = function () {
  105281. generateBlobUrl();
  105282. };
  105283. }
  105284. catch (ex) {
  105285. // "DataCloneError" generated by Chrome when you try to inject blob into IndexedDB
  105286. if (ex.code === 25) {
  105287. Database.IsUASupportingBlobStorage = false;
  105288. _this._enableTexturesOffline = false;
  105289. }
  105290. image.src = url;
  105291. }
  105292. }
  105293. else {
  105294. image.src = url;
  105295. }
  105296. }, false);
  105297. xhr.addEventListener("error", function () {
  105298. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in XHR request in BABYLON.Database.");
  105299. image.src = url;
  105300. }, false);
  105301. xhr.send();
  105302. }
  105303. else {
  105304. image.src = url;
  105305. }
  105306. }
  105307. else {
  105308. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  105309. image.src = url;
  105310. }
  105311. };
  105312. Database.prototype._checkVersionFromDB = function (url, versionLoaded) {
  105313. var _this = this;
  105314. var updateVersion = function () {
  105315. // the version is not yet in the DB or we need to update it
  105316. _this._saveVersionIntoDBAsync(url, versionLoaded);
  105317. };
  105318. this._loadVersionFromDBAsync(url, versionLoaded, updateVersion);
  105319. };
  105320. Database.prototype._loadVersionFromDBAsync = function (url, callback, updateInDBCallback) {
  105321. var _this = this;
  105322. if (this._isSupported && this._db) {
  105323. var version;
  105324. try {
  105325. var transaction = this._db.transaction(["versions"]);
  105326. transaction.oncomplete = function () {
  105327. if (version) {
  105328. // If the version in the JSON file is different from the version in DB
  105329. if (_this._manifestVersionFound !== version.data) {
  105330. _this._mustUpdateRessources = true;
  105331. updateInDBCallback();
  105332. }
  105333. else {
  105334. callback(version.data);
  105335. }
  105336. }
  105337. // version was not found in DB
  105338. else {
  105339. _this._mustUpdateRessources = true;
  105340. updateInDBCallback();
  105341. }
  105342. };
  105343. transaction.onabort = function () {
  105344. callback(-1);
  105345. };
  105346. var getRequest = transaction.objectStore("versions").get(url);
  105347. getRequest.onsuccess = function (event) {
  105348. version = (event.target).result;
  105349. };
  105350. getRequest.onerror = function () {
  105351. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading version for scene " + url + " from DB.");
  105352. callback(-1);
  105353. };
  105354. }
  105355. catch (ex) {
  105356. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (READ OP). Exception: " + ex.message);
  105357. callback(-1);
  105358. }
  105359. }
  105360. else {
  105361. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  105362. callback(-1);
  105363. }
  105364. };
  105365. Database.prototype._saveVersionIntoDBAsync = function (url, callback) {
  105366. var _this = this;
  105367. if (this._isSupported && !this._hasReachedQuota && this._db) {
  105368. try {
  105369. // Open a transaction to the database
  105370. var transaction = this._db.transaction(["versions"], "readwrite");
  105371. // the transaction could abort because of a QuotaExceededError error
  105372. transaction.onabort = function (event) {
  105373. try { //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  105374. var error = event.srcElement['error'];
  105375. if (error && error.name === "QuotaExceededError") {
  105376. _this._hasReachedQuota = true;
  105377. }
  105378. }
  105379. catch (ex) { }
  105380. callback(-1);
  105381. };
  105382. transaction.oncomplete = function () {
  105383. callback(_this._manifestVersionFound);
  105384. };
  105385. var newVersion = { sceneUrl: url, data: this._manifestVersionFound };
  105386. // Put the scene into the database
  105387. var addRequest = transaction.objectStore("versions").put(newVersion);
  105388. addRequest.onsuccess = function () {
  105389. };
  105390. addRequest.onerror = function () {
  105391. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add version request in BABYLON.Database.");
  105392. };
  105393. }
  105394. catch (ex) {
  105395. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (WRITE OP). Exception: " + ex.message);
  105396. callback(-1);
  105397. }
  105398. }
  105399. else {
  105400. callback(-1);
  105401. }
  105402. };
  105403. /**
  105404. * Loads a file from database
  105405. * @param url defines the URL to load from
  105406. * @param sceneLoaded defines a callback to call on success
  105407. * @param progressCallBack defines a callback to call when progress changed
  105408. * @param errorCallback defines a callback to call on error
  105409. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  105410. */
  105411. Database.prototype.loadFile = function (url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer) {
  105412. var _this = this;
  105413. var completeUrl = Database._ReturnFullUrlLocation(url);
  105414. var saveAndLoadFile = function () {
  105415. // the scene is not yet in the DB, let's try to save it
  105416. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  105417. };
  105418. this._checkVersionFromDB(completeUrl, function (version) {
  105419. if (version !== -1) {
  105420. if (!_this._mustUpdateRessources) {
  105421. _this._loadFileAsync(completeUrl, sceneLoaded, saveAndLoadFile);
  105422. }
  105423. else {
  105424. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  105425. }
  105426. }
  105427. else {
  105428. if (errorCallback) {
  105429. errorCallback();
  105430. }
  105431. }
  105432. });
  105433. };
  105434. Database.prototype._loadFileAsync = function (url, callback, notInDBCallback) {
  105435. if (this._isSupported && this._db) {
  105436. var targetStore;
  105437. if (url.indexOf(".babylon") !== -1) {
  105438. targetStore = "scenes";
  105439. }
  105440. else {
  105441. targetStore = "textures";
  105442. }
  105443. var file;
  105444. var transaction = this._db.transaction([targetStore]);
  105445. transaction.oncomplete = function () {
  105446. if (file) {
  105447. callback(file.data);
  105448. }
  105449. // file was not found in DB
  105450. else {
  105451. notInDBCallback();
  105452. }
  105453. };
  105454. transaction.onabort = function () {
  105455. notInDBCallback();
  105456. };
  105457. var getRequest = transaction.objectStore(targetStore).get(url);
  105458. getRequest.onsuccess = function (event) {
  105459. file = (event.target).result;
  105460. };
  105461. getRequest.onerror = function () {
  105462. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading file " + url + " from DB.");
  105463. notInDBCallback();
  105464. };
  105465. }
  105466. else {
  105467. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  105468. callback();
  105469. }
  105470. };
  105471. Database.prototype._saveFileAsync = function (url, callback, progressCallback, useArrayBuffer, errorCallback) {
  105472. var _this = this;
  105473. if (this._isSupported) {
  105474. var targetStore;
  105475. if (url.indexOf(".babylon") !== -1) {
  105476. targetStore = "scenes";
  105477. }
  105478. else {
  105479. targetStore = "textures";
  105480. }
  105481. // Create XHR
  105482. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__["WebRequest"]();
  105483. var fileData;
  105484. xhr.open("GET", url + "?" + Date.now());
  105485. if (useArrayBuffer) {
  105486. xhr.responseType = "arraybuffer";
  105487. }
  105488. if (progressCallback) {
  105489. xhr.onprogress = progressCallback;
  105490. }
  105491. xhr.addEventListener("load", function () {
  105492. if (xhr.status === 200 || (xhr.status < 400 && Database._ValidateXHRData(xhr, !useArrayBuffer ? 1 : 6))) {
  105493. // Blob as response (XHR2)
  105494. fileData = !useArrayBuffer ? xhr.responseText : xhr.response;
  105495. if (!_this._hasReachedQuota && _this._db) {
  105496. // Open a transaction to the database
  105497. var transaction = _this._db.transaction([targetStore], "readwrite");
  105498. // the transaction could abort because of a QuotaExceededError error
  105499. transaction.onabort = function (event) {
  105500. try {
  105501. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  105502. var error = event.srcElement['error'];
  105503. if (error && error.name === "QuotaExceededError") {
  105504. _this._hasReachedQuota = true;
  105505. }
  105506. }
  105507. catch (ex) { }
  105508. callback(fileData);
  105509. };
  105510. transaction.oncomplete = function () {
  105511. callback(fileData);
  105512. };
  105513. var newFile;
  105514. if (targetStore === "scenes") {
  105515. newFile = { sceneUrl: url, data: fileData, version: _this._manifestVersionFound };
  105516. }
  105517. else {
  105518. newFile = { textureUrl: url, data: fileData };
  105519. }
  105520. try {
  105521. // Put the scene into the database
  105522. var addRequest = transaction.objectStore(targetStore).put(newFile);
  105523. addRequest.onsuccess = function () {
  105524. };
  105525. addRequest.onerror = function () {
  105526. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add file request in BABYLON.Database.");
  105527. };
  105528. }
  105529. catch (ex) {
  105530. callback(fileData);
  105531. }
  105532. }
  105533. else {
  105534. callback(fileData);
  105535. }
  105536. }
  105537. else {
  105538. if (xhr.status >= 400 && errorCallback) {
  105539. errorCallback(xhr);
  105540. }
  105541. else {
  105542. callback();
  105543. }
  105544. }
  105545. }, false);
  105546. xhr.addEventListener("error", function () {
  105547. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("error on XHR request.");
  105548. callback();
  105549. }, false);
  105550. xhr.send();
  105551. }
  105552. else {
  105553. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or Babylon.js Database is not open.");
  105554. callback();
  105555. }
  105556. };
  105557. /**
  105558. * Validates if xhr data is correct
  105559. * @param xhr defines the request to validate
  105560. * @param dataType defines the expected data type
  105561. * @returns true if data is correct
  105562. */
  105563. Database._ValidateXHRData = function (xhr, dataType) {
  105564. // 1 for text (.babylon, manifest and shaders), 2 for TGA, 4 for DDS, 7 for all
  105565. if (dataType === void 0) { dataType = 7; }
  105566. try {
  105567. if (dataType & 1) {
  105568. if (xhr.responseText && xhr.responseText.length > 0) {
  105569. return true;
  105570. }
  105571. else if (dataType === 1) {
  105572. return false;
  105573. }
  105574. }
  105575. if (dataType & 2) {
  105576. // Check header width and height since there is no "TGA" magic number
  105577. var tgaHeader = _Misc_tga__WEBPACK_IMPORTED_MODULE_2__["TGATools"].GetTGAHeader(xhr.response);
  105578. if (tgaHeader.width && tgaHeader.height && tgaHeader.width > 0 && tgaHeader.height > 0) {
  105579. return true;
  105580. }
  105581. else if (dataType === 2) {
  105582. return false;
  105583. }
  105584. }
  105585. if (dataType & 4) {
  105586. // Check for the "DDS" magic number
  105587. var ddsHeader = new Uint8Array(xhr.response, 0, 3);
  105588. if (ddsHeader[0] === 68 && ddsHeader[1] === 68 && ddsHeader[2] === 83) {
  105589. return true;
  105590. }
  105591. else {
  105592. return false;
  105593. }
  105594. }
  105595. }
  105596. catch (e) {
  105597. // Global protection
  105598. }
  105599. return false;
  105600. };
  105601. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  105602. Database.IsUASupportingBlobStorage = true;
  105603. /**
  105604. * Gets a boolean indicating if Database storate is enabled (off by default)
  105605. */
  105606. Database.IDBStorageEnabled = false;
  105607. Database._ParseURL = function (url) {
  105608. var a = document.createElement('a');
  105609. a.href = url;
  105610. var urlWithoutHash = url.substring(0, url.lastIndexOf("#"));
  105611. var fileName = url.substring(urlWithoutHash.lastIndexOf("/") + 1, url.length);
  105612. var absLocation = url.substring(0, url.indexOf(fileName, 0));
  105613. return absLocation;
  105614. };
  105615. Database._ReturnFullUrlLocation = function (url) {
  105616. if (url.indexOf("http:/") === -1 && url.indexOf("https:/") === -1) {
  105617. return (Database._ParseURL(window.location.href) + url);
  105618. }
  105619. else {
  105620. return url;
  105621. }
  105622. };
  105623. return Database;
  105624. }());
  105625. /***/ }),
  105626. /***/ "./Offline/index.ts":
  105627. /*!**************************!*\
  105628. !*** ./Offline/index.ts ***!
  105629. \**************************/
  105630. /*! exports provided: Database */
  105631. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105632. "use strict";
  105633. __webpack_require__.r(__webpack_exports__);
  105634. /* harmony import */ var _database__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./database */ "./Offline/database.ts");
  105635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _database__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  105636. /***/ }),
  105637. /***/ "./Particles/EmitterTypes/boxParticleEmitter.ts":
  105638. /*!******************************************************!*\
  105639. !*** ./Particles/EmitterTypes/boxParticleEmitter.ts ***!
  105640. \******************************************************/
  105641. /*! exports provided: BoxParticleEmitter */
  105642. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105643. "use strict";
  105644. __webpack_require__.r(__webpack_exports__);
  105645. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return BoxParticleEmitter; });
  105646. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  105647. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  105648. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  105649. /**
  105650. * Particle emitter emitting particles from the inside of a box.
  105651. * It emits the particles randomly between 2 given directions.
  105652. */
  105653. var BoxParticleEmitter = /** @class */ (function () {
  105654. /**
  105655. * Creates a new instance BoxParticleEmitter
  105656. */
  105657. function BoxParticleEmitter() {
  105658. /**
  105659. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  105660. */
  105661. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  105662. /**
  105663. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  105664. */
  105665. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  105666. /**
  105667. * 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.
  105668. */
  105669. this.minEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-0.5, -0.5, -0.5);
  105670. /**
  105671. * 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.
  105672. */
  105673. this.maxEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.5, 0.5, 0.5);
  105674. }
  105675. /**
  105676. * Called by the particle System when the direction is computed for the created particle.
  105677. * @param worldMatrix is the world matrix of the particle system
  105678. * @param directionToUpdate is the direction vector to update with the result
  105679. * @param particle is the particle we are computed the direction for
  105680. */
  105681. BoxParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  105682. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  105683. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  105684. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  105685. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  105686. };
  105687. /**
  105688. * Called by the particle System when the position is computed for the created particle.
  105689. * @param worldMatrix is the world matrix of the particle system
  105690. * @param positionToUpdate is the position vector to update with the result
  105691. * @param particle is the particle we are computed the position for
  105692. */
  105693. BoxParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  105694. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.x, this.maxEmitBox.x);
  105695. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.y, this.maxEmitBox.y);
  105696. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.z, this.maxEmitBox.z);
  105697. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  105698. };
  105699. /**
  105700. * Clones the current emitter and returns a copy of it
  105701. * @returns the new emitter
  105702. */
  105703. BoxParticleEmitter.prototype.clone = function () {
  105704. var newOne = new BoxParticleEmitter();
  105705. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  105706. return newOne;
  105707. };
  105708. /**
  105709. * Called by the GPUParticleSystem to setup the update shader
  105710. * @param effect defines the update shader
  105711. */
  105712. BoxParticleEmitter.prototype.applyToShader = function (effect) {
  105713. effect.setVector3("direction1", this.direction1);
  105714. effect.setVector3("direction2", this.direction2);
  105715. effect.setVector3("minEmitBox", this.minEmitBox);
  105716. effect.setVector3("maxEmitBox", this.maxEmitBox);
  105717. };
  105718. /**
  105719. * Returns a string to use to update the GPU particles update shader
  105720. * @returns a string containng the defines string
  105721. */
  105722. BoxParticleEmitter.prototype.getEffectDefines = function () {
  105723. return "#define BOXEMITTER";
  105724. };
  105725. /**
  105726. * Returns the string "BoxParticleEmitter"
  105727. * @returns a string containing the class name
  105728. */
  105729. BoxParticleEmitter.prototype.getClassName = function () {
  105730. return "BoxParticleEmitter";
  105731. };
  105732. /**
  105733. * Serializes the particle system to a JSON object.
  105734. * @returns the JSON object
  105735. */
  105736. BoxParticleEmitter.prototype.serialize = function () {
  105737. var serializationObject = {};
  105738. serializationObject.type = this.getClassName();
  105739. serializationObject.direction1 = this.direction1.asArray();
  105740. serializationObject.direction2 = this.direction2.asArray();
  105741. serializationObject.minEmitBox = this.minEmitBox.asArray();
  105742. serializationObject.maxEmitBox = this.maxEmitBox.asArray();
  105743. return serializationObject;
  105744. };
  105745. /**
  105746. * Parse properties from a JSON object
  105747. * @param serializationObject defines the JSON object
  105748. */
  105749. BoxParticleEmitter.prototype.parse = function (serializationObject) {
  105750. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  105751. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  105752. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.minEmitBox, 0, this.minEmitBox);
  105753. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.maxEmitBox, 0, this.maxEmitBox);
  105754. };
  105755. return BoxParticleEmitter;
  105756. }());
  105757. /***/ }),
  105758. /***/ "./Particles/EmitterTypes/coneParticleEmitter.ts":
  105759. /*!*******************************************************!*\
  105760. !*** ./Particles/EmitterTypes/coneParticleEmitter.ts ***!
  105761. \*******************************************************/
  105762. /*! exports provided: ConeParticleEmitter */
  105763. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105764. "use strict";
  105765. __webpack_require__.r(__webpack_exports__);
  105766. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return ConeParticleEmitter; });
  105767. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  105768. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  105769. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  105770. /**
  105771. * Particle emitter emitting particles from the inside of a cone.
  105772. * It emits the particles alongside the cone volume from the base to the particle.
  105773. * The emission direction might be randomized.
  105774. */
  105775. var ConeParticleEmitter = /** @class */ (function () {
  105776. /**
  105777. * Creates a new instance ConeParticleEmitter
  105778. * @param radius the radius of the emission cone (1 by default)
  105779. * @param angle the cone base angle (PI by default)
  105780. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  105781. */
  105782. function ConeParticleEmitter(radius, angle,
  105783. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  105784. directionRandomizer) {
  105785. if (radius === void 0) { radius = 1; }
  105786. if (angle === void 0) { angle = Math.PI; }
  105787. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  105788. this.directionRandomizer = directionRandomizer;
  105789. /**
  105790. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  105791. */
  105792. this.radiusRange = 1;
  105793. /**
  105794. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  105795. */
  105796. this.heightRange = 1;
  105797. /**
  105798. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  105799. */
  105800. this.emitFromSpawnPointOnly = false;
  105801. this.angle = angle;
  105802. this.radius = radius;
  105803. }
  105804. Object.defineProperty(ConeParticleEmitter.prototype, "radius", {
  105805. /**
  105806. * Gets or sets the radius of the emission cone
  105807. */
  105808. get: function () {
  105809. return this._radius;
  105810. },
  105811. set: function (value) {
  105812. this._radius = value;
  105813. this._buildHeight();
  105814. },
  105815. enumerable: true,
  105816. configurable: true
  105817. });
  105818. Object.defineProperty(ConeParticleEmitter.prototype, "angle", {
  105819. /**
  105820. * Gets or sets the angle of the emission cone
  105821. */
  105822. get: function () {
  105823. return this._angle;
  105824. },
  105825. set: function (value) {
  105826. this._angle = value;
  105827. this._buildHeight();
  105828. },
  105829. enumerable: true,
  105830. configurable: true
  105831. });
  105832. ConeParticleEmitter.prototype._buildHeight = function () {
  105833. if (this._angle !== 0) {
  105834. this._height = this._radius / Math.tan(this._angle / 2);
  105835. }
  105836. else {
  105837. this._height = 1;
  105838. }
  105839. };
  105840. /**
  105841. * Called by the particle System when the direction is computed for the created particle.
  105842. * @param worldMatrix is the world matrix of the particle system
  105843. * @param directionToUpdate is the direction vector to update with the result
  105844. * @param particle is the particle we are computed the direction for
  105845. */
  105846. ConeParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  105847. if (Math.abs(Math.cos(this._angle)) === 1.0) {
  105848. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(0, 1.0, 0, worldMatrix, directionToUpdate);
  105849. }
  105850. else {
  105851. // measure the direction Vector from the emitter to the particle.
  105852. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  105853. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  105854. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  105855. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  105856. direction.x += randX;
  105857. direction.y += randY;
  105858. direction.z += randZ;
  105859. direction.normalize();
  105860. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  105861. }
  105862. };
  105863. /**
  105864. * Called by the particle System when the position is computed for the created particle.
  105865. * @param worldMatrix is the world matrix of the particle system
  105866. * @param positionToUpdate is the position vector to update with the result
  105867. * @param particle is the particle we are computed the position for
  105868. */
  105869. ConeParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  105870. var s = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, Math.PI * 2);
  105871. var h;
  105872. if (!this.emitFromSpawnPointOnly) {
  105873. h = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.heightRange);
  105874. // Better distribution in a cone at normal angles.
  105875. h = 1 - h * h;
  105876. }
  105877. else {
  105878. h = 0.0001;
  105879. }
  105880. var radius = this._radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this._radius * this.radiusRange);
  105881. radius = radius * h;
  105882. var randX = radius * Math.sin(s);
  105883. var randZ = radius * Math.cos(s);
  105884. var randY = h * this._height;
  105885. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  105886. };
  105887. /**
  105888. * Clones the current emitter and returns a copy of it
  105889. * @returns the new emitter
  105890. */
  105891. ConeParticleEmitter.prototype.clone = function () {
  105892. var newOne = new ConeParticleEmitter(this._radius, this._angle, this.directionRandomizer);
  105893. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  105894. return newOne;
  105895. };
  105896. /**
  105897. * Called by the GPUParticleSystem to setup the update shader
  105898. * @param effect defines the update shader
  105899. */
  105900. ConeParticleEmitter.prototype.applyToShader = function (effect) {
  105901. effect.setFloat2("radius", this._radius, this.radiusRange);
  105902. effect.setFloat("coneAngle", this._angle);
  105903. effect.setFloat2("height", this._height, this.heightRange);
  105904. effect.setFloat("directionRandomizer", this.directionRandomizer);
  105905. };
  105906. /**
  105907. * Returns a string to use to update the GPU particles update shader
  105908. * @returns a string containng the defines string
  105909. */
  105910. ConeParticleEmitter.prototype.getEffectDefines = function () {
  105911. var defines = "#define CONEEMITTER";
  105912. if (this.emitFromSpawnPointOnly) {
  105913. defines += "\n#define CONEEMITTERSPAWNPOINT";
  105914. }
  105915. return defines;
  105916. };
  105917. /**
  105918. * Returns the string "ConeParticleEmitter"
  105919. * @returns a string containing the class name
  105920. */
  105921. ConeParticleEmitter.prototype.getClassName = function () {
  105922. return "ConeParticleEmitter";
  105923. };
  105924. /**
  105925. * Serializes the particle system to a JSON object.
  105926. * @returns the JSON object
  105927. */
  105928. ConeParticleEmitter.prototype.serialize = function () {
  105929. var serializationObject = {};
  105930. serializationObject.type = this.getClassName();
  105931. serializationObject.radius = this._radius;
  105932. serializationObject.angle = this._angle;
  105933. serializationObject.directionRandomizer = this.directionRandomizer;
  105934. return serializationObject;
  105935. };
  105936. /**
  105937. * Parse properties from a JSON object
  105938. * @param serializationObject defines the JSON object
  105939. */
  105940. ConeParticleEmitter.prototype.parse = function (serializationObject) {
  105941. this.radius = serializationObject.radius;
  105942. this.angle = serializationObject.angle;
  105943. this.directionRandomizer = serializationObject.directionRandomizer;
  105944. };
  105945. return ConeParticleEmitter;
  105946. }());
  105947. /***/ }),
  105948. /***/ "./Particles/EmitterTypes/cylinderParticleEmitter.ts":
  105949. /*!***********************************************************!*\
  105950. !*** ./Particles/EmitterTypes/cylinderParticleEmitter.ts ***!
  105951. \***********************************************************/
  105952. /*! exports provided: CylinderParticleEmitter, CylinderDirectedParticleEmitter */
  105953. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105954. "use strict";
  105955. __webpack_require__.r(__webpack_exports__);
  105956. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return CylinderParticleEmitter; });
  105957. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return CylinderDirectedParticleEmitter; });
  105958. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  105959. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  105960. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  105961. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  105962. /**
  105963. * Particle emitter emitting particles from the inside of a cylinder.
  105964. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  105965. */
  105966. var CylinderParticleEmitter = /** @class */ (function () {
  105967. /**
  105968. * Creates a new instance CylinderParticleEmitter
  105969. * @param radius the radius of the emission cylinder (1 by default)
  105970. * @param height the height of the emission cylinder (1 by default)
  105971. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  105972. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  105973. */
  105974. function CylinderParticleEmitter(
  105975. /**
  105976. * The radius of the emission cylinder.
  105977. */
  105978. radius,
  105979. /**
  105980. * The height of the emission cylinder.
  105981. */
  105982. height,
  105983. /**
  105984. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  105985. */
  105986. radiusRange,
  105987. /**
  105988. * How much to randomize the particle direction [0-1].
  105989. */
  105990. directionRandomizer) {
  105991. if (radius === void 0) { radius = 1; }
  105992. if (height === void 0) { height = 1; }
  105993. if (radiusRange === void 0) { radiusRange = 1; }
  105994. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  105995. this.radius = radius;
  105996. this.height = height;
  105997. this.radiusRange = radiusRange;
  105998. this.directionRandomizer = directionRandomizer;
  105999. }
  106000. /**
  106001. * Called by the particle System when the direction is computed for the created particle.
  106002. * @param worldMatrix is the world matrix of the particle system
  106003. * @param directionToUpdate is the direction vector to update with the result
  106004. * @param particle is the particle we are computed the direction for
  106005. */
  106006. CylinderParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  106007. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  106008. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2);
  106009. var angle = Math.atan2(direction.x, direction.z);
  106010. angle += _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer;
  106011. direction.y = randY; // set direction y to rand y to mirror normal of cylinder surface
  106012. direction.x = Math.sin(angle);
  106013. direction.z = Math.cos(angle);
  106014. direction.normalize();
  106015. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  106016. };
  106017. /**
  106018. * Called by the particle System when the position is computed for the created particle.
  106019. * @param worldMatrix is the world matrix of the particle system
  106020. * @param positionToUpdate is the position vector to update with the result
  106021. * @param particle is the particle we are computed the position for
  106022. */
  106023. CylinderParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  106024. var yPos = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.height / 2, this.height / 2);
  106025. var angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  106026. // Pick a properly distributed point within the circle https://programming.guide/random-point-within-circle.html
  106027. var radiusDistribution = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1);
  106028. var positionRadius = Math.sqrt(radiusDistribution) * this.radius;
  106029. var xPos = positionRadius * Math.cos(angle);
  106030. var zPos = positionRadius * Math.sin(angle);
  106031. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, worldMatrix, positionToUpdate);
  106032. };
  106033. /**
  106034. * Clones the current emitter and returns a copy of it
  106035. * @returns the new emitter
  106036. */
  106037. CylinderParticleEmitter.prototype.clone = function () {
  106038. var newOne = new CylinderParticleEmitter(this.radius, this.directionRandomizer);
  106039. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  106040. return newOne;
  106041. };
  106042. /**
  106043. * Called by the GPUParticleSystem to setup the update shader
  106044. * @param effect defines the update shader
  106045. */
  106046. CylinderParticleEmitter.prototype.applyToShader = function (effect) {
  106047. effect.setFloat("radius", this.radius);
  106048. effect.setFloat("height", this.height);
  106049. effect.setFloat("radiusRange", this.radiusRange);
  106050. effect.setFloat("directionRandomizer", this.directionRandomizer);
  106051. };
  106052. /**
  106053. * Returns a string to use to update the GPU particles update shader
  106054. * @returns a string containng the defines string
  106055. */
  106056. CylinderParticleEmitter.prototype.getEffectDefines = function () {
  106057. return "#define CYLINDEREMITTER";
  106058. };
  106059. /**
  106060. * Returns the string "CylinderParticleEmitter"
  106061. * @returns a string containing the class name
  106062. */
  106063. CylinderParticleEmitter.prototype.getClassName = function () {
  106064. return "CylinderParticleEmitter";
  106065. };
  106066. /**
  106067. * Serializes the particle system to a JSON object.
  106068. * @returns the JSON object
  106069. */
  106070. CylinderParticleEmitter.prototype.serialize = function () {
  106071. var serializationObject = {};
  106072. serializationObject.type = this.getClassName();
  106073. serializationObject.radius = this.radius;
  106074. serializationObject.height = this.height;
  106075. serializationObject.radiusRange = this.radiusRange;
  106076. serializationObject.directionRandomizer = this.directionRandomizer;
  106077. return serializationObject;
  106078. };
  106079. /**
  106080. * Parse properties from a JSON object
  106081. * @param serializationObject defines the JSON object
  106082. */
  106083. CylinderParticleEmitter.prototype.parse = function (serializationObject) {
  106084. this.radius = serializationObject.radius;
  106085. this.height = serializationObject.height;
  106086. this.radiusRange = serializationObject.radiusRange;
  106087. this.directionRandomizer = serializationObject.directionRandomizer;
  106088. };
  106089. return CylinderParticleEmitter;
  106090. }());
  106091. /**
  106092. * Particle emitter emitting particles from the inside of a cylinder.
  106093. * It emits the particles randomly between two vectors.
  106094. */
  106095. var CylinderDirectedParticleEmitter = /** @class */ (function (_super) {
  106096. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderDirectedParticleEmitter, _super);
  106097. /**
  106098. * Creates a new instance CylinderDirectedParticleEmitter
  106099. * @param radius the radius of the emission cylinder (1 by default)
  106100. * @param height the height of the emission cylinder (1 by default)
  106101. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  106102. * @param direction1 the min limit of the emission direction (up vector by default)
  106103. * @param direction2 the max limit of the emission direction (up vector by default)
  106104. */
  106105. function CylinderDirectedParticleEmitter(radius, height, radiusRange,
  106106. /**
  106107. * The min limit of the emission direction.
  106108. */
  106109. direction1,
  106110. /**
  106111. * The max limit of the emission direction.
  106112. */
  106113. direction2) {
  106114. if (radius === void 0) { radius = 1; }
  106115. if (height === void 0) { height = 1; }
  106116. if (radiusRange === void 0) { radiusRange = 1; }
  106117. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  106118. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  106119. var _this = _super.call(this, radius, height, radiusRange) || this;
  106120. _this.direction1 = direction1;
  106121. _this.direction2 = direction2;
  106122. return _this;
  106123. }
  106124. /**
  106125. * Called by the particle System when the direction is computed for the created particle.
  106126. * @param worldMatrix is the world matrix of the particle system
  106127. * @param directionToUpdate is the direction vector to update with the result
  106128. * @param particle is the particle we are computed the direction for
  106129. */
  106130. CylinderDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  106131. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  106132. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  106133. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  106134. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  106135. };
  106136. /**
  106137. * Clones the current emitter and returns a copy of it
  106138. * @returns the new emitter
  106139. */
  106140. CylinderDirectedParticleEmitter.prototype.clone = function () {
  106141. var newOne = new CylinderDirectedParticleEmitter(this.radius, this.height, this.radiusRange, this.direction1, this.direction2);
  106142. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  106143. return newOne;
  106144. };
  106145. /**
  106146. * Called by the GPUParticleSystem to setup the update shader
  106147. * @param effect defines the update shader
  106148. */
  106149. CylinderDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  106150. effect.setFloat("radius", this.radius);
  106151. effect.setFloat("height", this.height);
  106152. effect.setFloat("radiusRange", this.radiusRange);
  106153. effect.setVector3("direction1", this.direction1);
  106154. effect.setVector3("direction2", this.direction2);
  106155. };
  106156. /**
  106157. * Returns a string to use to update the GPU particles update shader
  106158. * @returns a string containng the defines string
  106159. */
  106160. CylinderDirectedParticleEmitter.prototype.getEffectDefines = function () {
  106161. return "#define CYLINDEREMITTER\n#define DIRECTEDCYLINDEREMITTER";
  106162. };
  106163. /**
  106164. * Returns the string "CylinderDirectedParticleEmitter"
  106165. * @returns a string containing the class name
  106166. */
  106167. CylinderDirectedParticleEmitter.prototype.getClassName = function () {
  106168. return "CylinderDirectedParticleEmitter";
  106169. };
  106170. /**
  106171. * Serializes the particle system to a JSON object.
  106172. * @returns the JSON object
  106173. */
  106174. CylinderDirectedParticleEmitter.prototype.serialize = function () {
  106175. var serializationObject = _super.prototype.serialize.call(this);
  106176. serializationObject.direction1 = this.direction1.asArray();
  106177. serializationObject.direction2 = this.direction2.asArray();
  106178. return serializationObject;
  106179. };
  106180. /**
  106181. * Parse properties from a JSON object
  106182. * @param serializationObject defines the JSON object
  106183. */
  106184. CylinderDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  106185. _super.prototype.parse.call(this, serializationObject);
  106186. this.direction1.copyFrom(serializationObject.direction1);
  106187. this.direction2.copyFrom(serializationObject.direction2);
  106188. };
  106189. return CylinderDirectedParticleEmitter;
  106190. }(CylinderParticleEmitter));
  106191. /***/ }),
  106192. /***/ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts":
  106193. /*!**************************************************************!*\
  106194. !*** ./Particles/EmitterTypes/hemisphericParticleEmitter.ts ***!
  106195. \**************************************************************/
  106196. /*! exports provided: HemisphericParticleEmitter */
  106197. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106198. "use strict";
  106199. __webpack_require__.r(__webpack_exports__);
  106200. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return HemisphericParticleEmitter; });
  106201. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  106202. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  106203. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  106204. /**
  106205. * Particle emitter emitting particles from the inside of a hemisphere.
  106206. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  106207. */
  106208. var HemisphericParticleEmitter = /** @class */ (function () {
  106209. /**
  106210. * Creates a new instance HemisphericParticleEmitter
  106211. * @param radius the radius of the emission hemisphere (1 by default)
  106212. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  106213. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  106214. */
  106215. function HemisphericParticleEmitter(
  106216. /**
  106217. * The radius of the emission hemisphere.
  106218. */
  106219. radius,
  106220. /**
  106221. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  106222. */
  106223. radiusRange,
  106224. /**
  106225. * How much to randomize the particle direction [0-1].
  106226. */
  106227. directionRandomizer) {
  106228. if (radius === void 0) { radius = 1; }
  106229. if (radiusRange === void 0) { radiusRange = 1; }
  106230. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  106231. this.radius = radius;
  106232. this.radiusRange = radiusRange;
  106233. this.directionRandomizer = directionRandomizer;
  106234. }
  106235. /**
  106236. * Called by the particle System when the direction is computed for the created particle.
  106237. * @param worldMatrix is the world matrix of the particle system
  106238. * @param directionToUpdate is the direction vector to update with the result
  106239. * @param particle is the particle we are computed the direction for
  106240. */
  106241. HemisphericParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  106242. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  106243. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  106244. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  106245. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  106246. direction.x += randX;
  106247. direction.y += randY;
  106248. direction.z += randZ;
  106249. direction.normalize();
  106250. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  106251. };
  106252. /**
  106253. * Called by the particle System when the position is computed for the created particle.
  106254. * @param worldMatrix is the world matrix of the particle system
  106255. * @param positionToUpdate is the position vector to update with the result
  106256. * @param particle is the particle we are computed the position for
  106257. */
  106258. HemisphericParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  106259. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  106260. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  106261. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  106262. var theta = Math.acos(2 * v - 1);
  106263. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  106264. var randY = randRadius * Math.cos(theta);
  106265. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  106266. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, Math.abs(randY), randZ, worldMatrix, positionToUpdate);
  106267. };
  106268. /**
  106269. * Clones the current emitter and returns a copy of it
  106270. * @returns the new emitter
  106271. */
  106272. HemisphericParticleEmitter.prototype.clone = function () {
  106273. var newOne = new HemisphericParticleEmitter(this.radius, this.directionRandomizer);
  106274. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  106275. return newOne;
  106276. };
  106277. /**
  106278. * Called by the GPUParticleSystem to setup the update shader
  106279. * @param effect defines the update shader
  106280. */
  106281. HemisphericParticleEmitter.prototype.applyToShader = function (effect) {
  106282. effect.setFloat("radius", this.radius);
  106283. effect.setFloat("radiusRange", this.radiusRange);
  106284. effect.setFloat("directionRandomizer", this.directionRandomizer);
  106285. };
  106286. /**
  106287. * Returns a string to use to update the GPU particles update shader
  106288. * @returns a string containng the defines string
  106289. */
  106290. HemisphericParticleEmitter.prototype.getEffectDefines = function () {
  106291. return "#define HEMISPHERICEMITTER";
  106292. };
  106293. /**
  106294. * Returns the string "HemisphericParticleEmitter"
  106295. * @returns a string containing the class name
  106296. */
  106297. HemisphericParticleEmitter.prototype.getClassName = function () {
  106298. return "HemisphericParticleEmitter";
  106299. };
  106300. /**
  106301. * Serializes the particle system to a JSON object.
  106302. * @returns the JSON object
  106303. */
  106304. HemisphericParticleEmitter.prototype.serialize = function () {
  106305. var serializationObject = {};
  106306. serializationObject.type = this.getClassName();
  106307. serializationObject.radius = this.radius;
  106308. serializationObject.radiusRange = this.radiusRange;
  106309. serializationObject.directionRandomizer = this.directionRandomizer;
  106310. return serializationObject;
  106311. };
  106312. /**
  106313. * Parse properties from a JSON object
  106314. * @param serializationObject defines the JSON object
  106315. */
  106316. HemisphericParticleEmitter.prototype.parse = function (serializationObject) {
  106317. this.radius = serializationObject.radius;
  106318. this.radiusRange = serializationObject.radiusRange;
  106319. this.directionRandomizer = serializationObject.directionRandomizer;
  106320. };
  106321. return HemisphericParticleEmitter;
  106322. }());
  106323. /***/ }),
  106324. /***/ "./Particles/EmitterTypes/index.ts":
  106325. /*!*****************************************!*\
  106326. !*** ./Particles/EmitterTypes/index.ts ***!
  106327. \*****************************************/
  106328. /*! exports provided: BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  106329. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106330. "use strict";
  106331. __webpack_require__.r(__webpack_exports__);
  106332. /* harmony import */ var _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  106333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  106334. /* harmony import */ var _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./coneParticleEmitter */ "./Particles/EmitterTypes/coneParticleEmitter.ts");
  106335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  106336. /* harmony import */ var _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cylinderParticleEmitter */ "./Particles/EmitterTypes/cylinderParticleEmitter.ts");
  106337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"]; });
  106338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"]; });
  106339. /* harmony import */ var _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hemisphericParticleEmitter */ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts");
  106340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__["HemisphericParticleEmitter"]; });
  106341. /* harmony import */ var _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pointParticleEmitter */ "./Particles/EmitterTypes/pointParticleEmitter.ts");
  106342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__["PointParticleEmitter"]; });
  106343. /* harmony import */ var _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./sphereParticleEmitter */ "./Particles/EmitterTypes/sphereParticleEmitter.ts");
  106344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereParticleEmitter"]; });
  106345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereDirectedParticleEmitter"]; });
  106346. /***/ }),
  106347. /***/ "./Particles/EmitterTypes/pointParticleEmitter.ts":
  106348. /*!********************************************************!*\
  106349. !*** ./Particles/EmitterTypes/pointParticleEmitter.ts ***!
  106350. \********************************************************/
  106351. /*! exports provided: PointParticleEmitter */
  106352. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106353. "use strict";
  106354. __webpack_require__.r(__webpack_exports__);
  106355. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return PointParticleEmitter; });
  106356. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  106357. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  106358. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  106359. /**
  106360. * Particle emitter emitting particles from a point.
  106361. * It emits the particles randomly between 2 given directions.
  106362. */
  106363. var PointParticleEmitter = /** @class */ (function () {
  106364. /**
  106365. * Creates a new instance PointParticleEmitter
  106366. */
  106367. function PointParticleEmitter() {
  106368. /**
  106369. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  106370. */
  106371. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  106372. /**
  106373. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  106374. */
  106375. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  106376. }
  106377. /**
  106378. * Called by the particle System when the direction is computed for the created particle.
  106379. * @param worldMatrix is the world matrix of the particle system
  106380. * @param directionToUpdate is the direction vector to update with the result
  106381. * @param particle is the particle we are computed the direction for
  106382. */
  106383. PointParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  106384. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  106385. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  106386. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  106387. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  106388. };
  106389. /**
  106390. * Called by the particle System when the position is computed for the created particle.
  106391. * @param worldMatrix is the world matrix of the particle system
  106392. * @param positionToUpdate is the position vector to update with the result
  106393. * @param particle is the particle we are computed the position for
  106394. */
  106395. PointParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  106396. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0, 0, 0, worldMatrix, positionToUpdate);
  106397. };
  106398. /**
  106399. * Clones the current emitter and returns a copy of it
  106400. * @returns the new emitter
  106401. */
  106402. PointParticleEmitter.prototype.clone = function () {
  106403. var newOne = new PointParticleEmitter();
  106404. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  106405. return newOne;
  106406. };
  106407. /**
  106408. * Called by the GPUParticleSystem to setup the update shader
  106409. * @param effect defines the update shader
  106410. */
  106411. PointParticleEmitter.prototype.applyToShader = function (effect) {
  106412. effect.setVector3("direction1", this.direction1);
  106413. effect.setVector3("direction2", this.direction2);
  106414. };
  106415. /**
  106416. * Returns a string to use to update the GPU particles update shader
  106417. * @returns a string containng the defines string
  106418. */
  106419. PointParticleEmitter.prototype.getEffectDefines = function () {
  106420. return "#define POINTEMITTER";
  106421. };
  106422. /**
  106423. * Returns the string "PointParticleEmitter"
  106424. * @returns a string containing the class name
  106425. */
  106426. PointParticleEmitter.prototype.getClassName = function () {
  106427. return "PointParticleEmitter";
  106428. };
  106429. /**
  106430. * Serializes the particle system to a JSON object.
  106431. * @returns the JSON object
  106432. */
  106433. PointParticleEmitter.prototype.serialize = function () {
  106434. var serializationObject = {};
  106435. serializationObject.type = this.getClassName();
  106436. serializationObject.direction1 = this.direction1.asArray();
  106437. serializationObject.direction2 = this.direction2.asArray();
  106438. return serializationObject;
  106439. };
  106440. /**
  106441. * Parse properties from a JSON object
  106442. * @param serializationObject defines the JSON object
  106443. */
  106444. PointParticleEmitter.prototype.parse = function (serializationObject) {
  106445. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  106446. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  106447. };
  106448. return PointParticleEmitter;
  106449. }());
  106450. /***/ }),
  106451. /***/ "./Particles/EmitterTypes/sphereParticleEmitter.ts":
  106452. /*!*********************************************************!*\
  106453. !*** ./Particles/EmitterTypes/sphereParticleEmitter.ts ***!
  106454. \*********************************************************/
  106455. /*! exports provided: SphereParticleEmitter, SphereDirectedParticleEmitter */
  106456. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106457. "use strict";
  106458. __webpack_require__.r(__webpack_exports__);
  106459. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return SphereParticleEmitter; });
  106460. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return SphereDirectedParticleEmitter; });
  106461. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  106462. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  106463. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  106464. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  106465. /**
  106466. * Particle emitter emitting particles from the inside of a sphere.
  106467. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  106468. */
  106469. var SphereParticleEmitter = /** @class */ (function () {
  106470. /**
  106471. * Creates a new instance SphereParticleEmitter
  106472. * @param radius the radius of the emission sphere (1 by default)
  106473. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  106474. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  106475. */
  106476. function SphereParticleEmitter(
  106477. /**
  106478. * The radius of the emission sphere.
  106479. */
  106480. radius,
  106481. /**
  106482. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  106483. */
  106484. radiusRange,
  106485. /**
  106486. * How much to randomize the particle direction [0-1].
  106487. */
  106488. directionRandomizer) {
  106489. if (radius === void 0) { radius = 1; }
  106490. if (radiusRange === void 0) { radiusRange = 1; }
  106491. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  106492. this.radius = radius;
  106493. this.radiusRange = radiusRange;
  106494. this.directionRandomizer = directionRandomizer;
  106495. }
  106496. /**
  106497. * Called by the particle System when the direction is computed for the created particle.
  106498. * @param worldMatrix is the world matrix of the particle system
  106499. * @param directionToUpdate is the direction vector to update with the result
  106500. * @param particle is the particle we are computed the direction for
  106501. */
  106502. SphereParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  106503. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  106504. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  106505. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  106506. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  106507. direction.x += randX;
  106508. direction.y += randY;
  106509. direction.z += randZ;
  106510. direction.normalize();
  106511. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  106512. };
  106513. /**
  106514. * Called by the particle System when the position is computed for the created particle.
  106515. * @param worldMatrix is the world matrix of the particle system
  106516. * @param positionToUpdate is the position vector to update with the result
  106517. * @param particle is the particle we are computed the position for
  106518. */
  106519. SphereParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  106520. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  106521. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  106522. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  106523. var theta = Math.acos(2 * v - 1);
  106524. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  106525. var randY = randRadius * Math.cos(theta);
  106526. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  106527. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  106528. };
  106529. /**
  106530. * Clones the current emitter and returns a copy of it
  106531. * @returns the new emitter
  106532. */
  106533. SphereParticleEmitter.prototype.clone = function () {
  106534. var newOne = new SphereParticleEmitter(this.radius, this.directionRandomizer);
  106535. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  106536. return newOne;
  106537. };
  106538. /**
  106539. * Called by the GPUParticleSystem to setup the update shader
  106540. * @param effect defines the update shader
  106541. */
  106542. SphereParticleEmitter.prototype.applyToShader = function (effect) {
  106543. effect.setFloat("radius", this.radius);
  106544. effect.setFloat("radiusRange", this.radiusRange);
  106545. effect.setFloat("directionRandomizer", this.directionRandomizer);
  106546. };
  106547. /**
  106548. * Returns a string to use to update the GPU particles update shader
  106549. * @returns a string containng the defines string
  106550. */
  106551. SphereParticleEmitter.prototype.getEffectDefines = function () {
  106552. return "#define SPHEREEMITTER";
  106553. };
  106554. /**
  106555. * Returns the string "SphereParticleEmitter"
  106556. * @returns a string containing the class name
  106557. */
  106558. SphereParticleEmitter.prototype.getClassName = function () {
  106559. return "SphereParticleEmitter";
  106560. };
  106561. /**
  106562. * Serializes the particle system to a JSON object.
  106563. * @returns the JSON object
  106564. */
  106565. SphereParticleEmitter.prototype.serialize = function () {
  106566. var serializationObject = {};
  106567. serializationObject.type = this.getClassName();
  106568. serializationObject.radius = this.radius;
  106569. serializationObject.radiusRange = this.radiusRange;
  106570. serializationObject.directionRandomizer = this.directionRandomizer;
  106571. return serializationObject;
  106572. };
  106573. /**
  106574. * Parse properties from a JSON object
  106575. * @param serializationObject defines the JSON object
  106576. */
  106577. SphereParticleEmitter.prototype.parse = function (serializationObject) {
  106578. this.radius = serializationObject.radius;
  106579. this.radiusRange = serializationObject.radiusRange;
  106580. this.directionRandomizer = serializationObject.directionRandomizer;
  106581. };
  106582. return SphereParticleEmitter;
  106583. }());
  106584. /**
  106585. * Particle emitter emitting particles from the inside of a sphere.
  106586. * It emits the particles randomly between two vectors.
  106587. */
  106588. var SphereDirectedParticleEmitter = /** @class */ (function (_super) {
  106589. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SphereDirectedParticleEmitter, _super);
  106590. /**
  106591. * Creates a new instance SphereDirectedParticleEmitter
  106592. * @param radius the radius of the emission sphere (1 by default)
  106593. * @param direction1 the min limit of the emission direction (up vector by default)
  106594. * @param direction2 the max limit of the emission direction (up vector by default)
  106595. */
  106596. function SphereDirectedParticleEmitter(radius,
  106597. /**
  106598. * The min limit of the emission direction.
  106599. */
  106600. direction1,
  106601. /**
  106602. * The max limit of the emission direction.
  106603. */
  106604. direction2) {
  106605. if (radius === void 0) { radius = 1; }
  106606. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  106607. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  106608. var _this = _super.call(this, radius) || this;
  106609. _this.direction1 = direction1;
  106610. _this.direction2 = direction2;
  106611. return _this;
  106612. }
  106613. /**
  106614. * Called by the particle System when the direction is computed for the created particle.
  106615. * @param worldMatrix is the world matrix of the particle system
  106616. * @param directionToUpdate is the direction vector to update with the result
  106617. * @param particle is the particle we are computed the direction for
  106618. */
  106619. SphereDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  106620. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  106621. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  106622. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  106623. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  106624. };
  106625. /**
  106626. * Clones the current emitter and returns a copy of it
  106627. * @returns the new emitter
  106628. */
  106629. SphereDirectedParticleEmitter.prototype.clone = function () {
  106630. var newOne = new SphereDirectedParticleEmitter(this.radius, this.direction1, this.direction2);
  106631. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  106632. return newOne;
  106633. };
  106634. /**
  106635. * Called by the GPUParticleSystem to setup the update shader
  106636. * @param effect defines the update shader
  106637. */
  106638. SphereDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  106639. effect.setFloat("radius", this.radius);
  106640. effect.setFloat("radiusRange", this.radiusRange);
  106641. effect.setVector3("direction1", this.direction1);
  106642. effect.setVector3("direction2", this.direction2);
  106643. };
  106644. /**
  106645. * Returns a string to use to update the GPU particles update shader
  106646. * @returns a string containng the defines string
  106647. */
  106648. SphereDirectedParticleEmitter.prototype.getEffectDefines = function () {
  106649. return "#define SPHEREEMITTER\n#define DIRECTEDSPHEREEMITTER";
  106650. };
  106651. /**
  106652. * Returns the string "SphereDirectedParticleEmitter"
  106653. * @returns a string containing the class name
  106654. */
  106655. SphereDirectedParticleEmitter.prototype.getClassName = function () {
  106656. return "SphereDirectedParticleEmitter";
  106657. };
  106658. /**
  106659. * Serializes the particle system to a JSON object.
  106660. * @returns the JSON object
  106661. */
  106662. SphereDirectedParticleEmitter.prototype.serialize = function () {
  106663. var serializationObject = _super.prototype.serialize.call(this);
  106664. serializationObject.direction1 = this.direction1.asArray();
  106665. serializationObject.direction2 = this.direction2.asArray();
  106666. return serializationObject;
  106667. };
  106668. /**
  106669. * Parse properties from a JSON object
  106670. * @param serializationObject defines the JSON object
  106671. */
  106672. SphereDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  106673. _super.prototype.parse.call(this, serializationObject);
  106674. this.direction1.copyFrom(serializationObject.direction1);
  106675. this.direction2.copyFrom(serializationObject.direction2);
  106676. };
  106677. return SphereDirectedParticleEmitter;
  106678. }(SphereParticleEmitter));
  106679. /***/ }),
  106680. /***/ "./Particles/baseParticleSystem.ts":
  106681. /*!*****************************************!*\
  106682. !*** ./Particles/baseParticleSystem.ts ***!
  106683. \*****************************************/
  106684. /*! exports provided: BaseParticleSystem */
  106685. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106686. "use strict";
  106687. __webpack_require__.r(__webpack_exports__);
  106688. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return BaseParticleSystem; });
  106689. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  106690. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  106691. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  106692. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  106693. /**
  106694. * This represents the base class for particle system in Babylon.
  106695. * 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.
  106696. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  106697. * @example https://doc.babylonjs.com/babylon101/particles
  106698. */
  106699. var BaseParticleSystem = /** @class */ (function () {
  106700. /**
  106701. * Instantiates a particle system.
  106702. * 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.
  106703. * @param name The name of the particle system
  106704. */
  106705. function BaseParticleSystem(name) {
  106706. /**
  106707. * List of animations used by the particle system.
  106708. */
  106709. this.animations = [];
  106710. /**
  106711. * The rendering group used by the Particle system to chose when to render.
  106712. */
  106713. this.renderingGroupId = 0;
  106714. /**
  106715. * The emitter represents the Mesh or position we are attaching the particle system to.
  106716. */
  106717. this.emitter = null;
  106718. /**
  106719. * The maximum number of particles to emit per frame
  106720. */
  106721. this.emitRate = 10;
  106722. /**
  106723. * If you want to launch only a few particles at once, that can be done, as well.
  106724. */
  106725. this.manualEmitCount = -1;
  106726. /**
  106727. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  106728. */
  106729. this.updateSpeed = 0.01;
  106730. /**
  106731. * The amount of time the particle system is running (depends of the overall update speed).
  106732. */
  106733. this.targetStopDuration = 0;
  106734. /**
  106735. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  106736. */
  106737. this.disposeOnStop = false;
  106738. /**
  106739. * Minimum power of emitting particles.
  106740. */
  106741. this.minEmitPower = 1;
  106742. /**
  106743. * Maximum power of emitting particles.
  106744. */
  106745. this.maxEmitPower = 1;
  106746. /**
  106747. * Minimum life time of emitting particles.
  106748. */
  106749. this.minLifeTime = 1;
  106750. /**
  106751. * Maximum life time of emitting particles.
  106752. */
  106753. this.maxLifeTime = 1;
  106754. /**
  106755. * Minimum Size of emitting particles.
  106756. */
  106757. this.minSize = 1;
  106758. /**
  106759. * Maximum Size of emitting particles.
  106760. */
  106761. this.maxSize = 1;
  106762. /**
  106763. * Minimum scale of emitting particles on X axis.
  106764. */
  106765. this.minScaleX = 1;
  106766. /**
  106767. * Maximum scale of emitting particles on X axis.
  106768. */
  106769. this.maxScaleX = 1;
  106770. /**
  106771. * Minimum scale of emitting particles on Y axis.
  106772. */
  106773. this.minScaleY = 1;
  106774. /**
  106775. * Maximum scale of emitting particles on Y axis.
  106776. */
  106777. this.maxScaleY = 1;
  106778. /**
  106779. * Gets or sets the minimal initial rotation in radians.
  106780. */
  106781. this.minInitialRotation = 0;
  106782. /**
  106783. * Gets or sets the maximal initial rotation in radians.
  106784. */
  106785. this.maxInitialRotation = 0;
  106786. /**
  106787. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  106788. */
  106789. this.minAngularSpeed = 0;
  106790. /**
  106791. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  106792. */
  106793. this.maxAngularSpeed = 0;
  106794. /**
  106795. * The layer mask we are rendering the particles through.
  106796. */
  106797. this.layerMask = 0x0FFFFFFF;
  106798. /**
  106799. * This can help using your own shader to render the particle system.
  106800. * The according effect will be created
  106801. */
  106802. this.customShader = null;
  106803. /**
  106804. * By default particle system starts as soon as they are created. This prevents the
  106805. * automatic start to happen and let you decide when to start emitting particles.
  106806. */
  106807. this.preventAutoStart = false;
  106808. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  106809. this.noiseStrength = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](10, 10, 10);
  106810. /**
  106811. * Callback triggered when the particle animation is ending.
  106812. */
  106813. this.onAnimationEnd = null;
  106814. /**
  106815. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  106816. */
  106817. this.blendMode = BaseParticleSystem.BLENDMODE_ONEONE;
  106818. /**
  106819. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  106820. * to override the particles.
  106821. */
  106822. this.forceDepthWrite = false;
  106823. /** 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 */
  106824. this.preWarmCycles = 0;
  106825. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  106826. this.preWarmStepOffset = 1;
  106827. /**
  106828. * 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)
  106829. */
  106830. this.spriteCellChangeSpeed = 1;
  106831. /**
  106832. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  106833. */
  106834. this.startSpriteCellID = 0;
  106835. /**
  106836. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  106837. */
  106838. this.endSpriteCellID = 0;
  106839. /**
  106840. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  106841. */
  106842. this.spriteCellWidth = 0;
  106843. /**
  106844. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  106845. */
  106846. this.spriteCellHeight = 0;
  106847. /**
  106848. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  106849. */
  106850. this.spriteRandomStartCell = false;
  106851. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  106852. this.translationPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  106853. /**
  106854. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  106855. */
  106856. this.beginAnimationOnStart = false;
  106857. /**
  106858. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  106859. */
  106860. this.beginAnimationFrom = 0;
  106861. /**
  106862. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  106863. */
  106864. this.beginAnimationTo = 60;
  106865. /**
  106866. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  106867. */
  106868. this.beginAnimationLoop = false;
  106869. /**
  106870. * Gets or sets a world offset applied to all particles
  106871. */
  106872. this.worldOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  106873. /**
  106874. * You can use gravity if you want to give an orientation to your particles.
  106875. */
  106876. this.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106877. this._colorGradients = null;
  106878. this._sizeGradients = null;
  106879. this._lifeTimeGradients = null;
  106880. this._angularSpeedGradients = null;
  106881. this._velocityGradients = null;
  106882. this._limitVelocityGradients = null;
  106883. this._dragGradients = null;
  106884. this._emitRateGradients = null;
  106885. this._startSizeGradients = null;
  106886. this._rampGradients = null;
  106887. this._colorRemapGradients = null;
  106888. this._alphaRemapGradients = null;
  106889. /**
  106890. * Defines the delay in milliseconds before starting the system (0 by default)
  106891. */
  106892. this.startDelay = 0;
  106893. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  106894. this.limitVelocityDamping = 0.4;
  106895. /**
  106896. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  106897. */
  106898. this.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  106899. /**
  106900. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  106901. */
  106902. this.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  106903. /**
  106904. * Color the particle will have at the end of its lifetime
  106905. */
  106906. this.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 1.0);
  106907. /**
  106908. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  106909. */
  106910. this.textureMask = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  106911. /** @hidden */
  106912. this._isSubEmitter = false;
  106913. /**
  106914. * Gets or sets the billboard mode to use when isBillboardBased = true.
  106915. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  106916. */
  106917. this.billboardMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  106918. this._isBillboardBased = true;
  106919. /**
  106920. * Local cache of defines for image processing.
  106921. */
  106922. this._imageProcessingConfigurationDefines = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__["ImageProcessingConfigurationDefines"]();
  106923. this.id = name;
  106924. this.name = name;
  106925. }
  106926. Object.defineProperty(BaseParticleSystem.prototype, "noiseTexture", {
  106927. /**
  106928. * Gets or sets a texture used to add random noise to particle positions
  106929. */
  106930. get: function () {
  106931. return this._noiseTexture;
  106932. },
  106933. set: function (value) {
  106934. if (this._noiseTexture === value) {
  106935. return;
  106936. }
  106937. this._noiseTexture = value;
  106938. this._reset();
  106939. },
  106940. enumerable: true,
  106941. configurable: true
  106942. });
  106943. Object.defineProperty(BaseParticleSystem.prototype, "isAnimationSheetEnabled", {
  106944. /**
  106945. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  106946. */
  106947. get: function () {
  106948. return this._isAnimationSheetEnabled;
  106949. },
  106950. set: function (value) {
  106951. if (this._isAnimationSheetEnabled == value) {
  106952. return;
  106953. }
  106954. this._isAnimationSheetEnabled = value;
  106955. this._reset();
  106956. },
  106957. enumerable: true,
  106958. configurable: true
  106959. });
  106960. /**
  106961. * Get hosting scene
  106962. * @returns the scene
  106963. */
  106964. BaseParticleSystem.prototype.getScene = function () {
  106965. return this._scene;
  106966. };
  106967. BaseParticleSystem.prototype._hasTargetStopDurationDependantGradient = function () {
  106968. return (this._startSizeGradients && this._startSizeGradients.length > 0)
  106969. || (this._emitRateGradients && this._emitRateGradients.length > 0)
  106970. || (this._lifeTimeGradients && this._lifeTimeGradients.length > 0);
  106971. };
  106972. /**
  106973. * Gets the current list of drag gradients.
  106974. * You must use addDragGradient and removeDragGradient to udpate this list
  106975. * @returns the list of drag gradients
  106976. */
  106977. BaseParticleSystem.prototype.getDragGradients = function () {
  106978. return this._dragGradients;
  106979. };
  106980. /**
  106981. * Gets the current list of limit velocity gradients.
  106982. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  106983. * @returns the list of limit velocity gradients
  106984. */
  106985. BaseParticleSystem.prototype.getLimitVelocityGradients = function () {
  106986. return this._limitVelocityGradients;
  106987. };
  106988. /**
  106989. * Gets the current list of color gradients.
  106990. * You must use addColorGradient and removeColorGradient to udpate this list
  106991. * @returns the list of color gradients
  106992. */
  106993. BaseParticleSystem.prototype.getColorGradients = function () {
  106994. return this._colorGradients;
  106995. };
  106996. /**
  106997. * Gets the current list of size gradients.
  106998. * You must use addSizeGradient and removeSizeGradient to udpate this list
  106999. * @returns the list of size gradients
  107000. */
  107001. BaseParticleSystem.prototype.getSizeGradients = function () {
  107002. return this._sizeGradients;
  107003. };
  107004. /**
  107005. * Gets the current list of color remap gradients.
  107006. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  107007. * @returns the list of color remap gradients
  107008. */
  107009. BaseParticleSystem.prototype.getColorRemapGradients = function () {
  107010. return this._colorRemapGradients;
  107011. };
  107012. /**
  107013. * Gets the current list of alpha remap gradients.
  107014. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  107015. * @returns the list of alpha remap gradients
  107016. */
  107017. BaseParticleSystem.prototype.getAlphaRemapGradients = function () {
  107018. return this._alphaRemapGradients;
  107019. };
  107020. /**
  107021. * Gets the current list of life time gradients.
  107022. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  107023. * @returns the list of life time gradients
  107024. */
  107025. BaseParticleSystem.prototype.getLifeTimeGradients = function () {
  107026. return this._lifeTimeGradients;
  107027. };
  107028. /**
  107029. * Gets the current list of angular speed gradients.
  107030. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  107031. * @returns the list of angular speed gradients
  107032. */
  107033. BaseParticleSystem.prototype.getAngularSpeedGradients = function () {
  107034. return this._angularSpeedGradients;
  107035. };
  107036. /**
  107037. * Gets the current list of velocity gradients.
  107038. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  107039. * @returns the list of velocity gradients
  107040. */
  107041. BaseParticleSystem.prototype.getVelocityGradients = function () {
  107042. return this._velocityGradients;
  107043. };
  107044. /**
  107045. * Gets the current list of start size gradients.
  107046. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  107047. * @returns the list of start size gradients
  107048. */
  107049. BaseParticleSystem.prototype.getStartSizeGradients = function () {
  107050. return this._startSizeGradients;
  107051. };
  107052. /**
  107053. * Gets the current list of emit rate gradients.
  107054. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  107055. * @returns the list of emit rate gradients
  107056. */
  107057. BaseParticleSystem.prototype.getEmitRateGradients = function () {
  107058. return this._emitRateGradients;
  107059. };
  107060. Object.defineProperty(BaseParticleSystem.prototype, "direction1", {
  107061. /**
  107062. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  107063. * This only works when particleEmitterTyps is a BoxParticleEmitter
  107064. */
  107065. get: function () {
  107066. if (this.particleEmitterType.direction1) {
  107067. return this.particleEmitterType.direction1;
  107068. }
  107069. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107070. },
  107071. set: function (value) {
  107072. if (this.particleEmitterType.direction1) {
  107073. this.particleEmitterType.direction1 = value;
  107074. }
  107075. },
  107076. enumerable: true,
  107077. configurable: true
  107078. });
  107079. Object.defineProperty(BaseParticleSystem.prototype, "direction2", {
  107080. /**
  107081. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  107082. * This only works when particleEmitterTyps is a BoxParticleEmitter
  107083. */
  107084. get: function () {
  107085. if (this.particleEmitterType.direction2) {
  107086. return this.particleEmitterType.direction2;
  107087. }
  107088. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107089. },
  107090. set: function (value) {
  107091. if (this.particleEmitterType.direction2) {
  107092. this.particleEmitterType.direction2 = value;
  107093. }
  107094. },
  107095. enumerable: true,
  107096. configurable: true
  107097. });
  107098. Object.defineProperty(BaseParticleSystem.prototype, "minEmitBox", {
  107099. /**
  107100. * 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.
  107101. * This only works when particleEmitterTyps is a BoxParticleEmitter
  107102. */
  107103. get: function () {
  107104. if (this.particleEmitterType.minEmitBox) {
  107105. return this.particleEmitterType.minEmitBox;
  107106. }
  107107. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107108. },
  107109. set: function (value) {
  107110. if (this.particleEmitterType.minEmitBox) {
  107111. this.particleEmitterType.minEmitBox = value;
  107112. }
  107113. },
  107114. enumerable: true,
  107115. configurable: true
  107116. });
  107117. Object.defineProperty(BaseParticleSystem.prototype, "maxEmitBox", {
  107118. /**
  107119. * 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.
  107120. * This only works when particleEmitterTyps is a BoxParticleEmitter
  107121. */
  107122. get: function () {
  107123. if (this.particleEmitterType.maxEmitBox) {
  107124. return this.particleEmitterType.maxEmitBox;
  107125. }
  107126. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107127. },
  107128. set: function (value) {
  107129. if (this.particleEmitterType.maxEmitBox) {
  107130. this.particleEmitterType.maxEmitBox = value;
  107131. }
  107132. },
  107133. enumerable: true,
  107134. configurable: true
  107135. });
  107136. Object.defineProperty(BaseParticleSystem.prototype, "isBillboardBased", {
  107137. /**
  107138. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  107139. */
  107140. get: function () {
  107141. return this._isBillboardBased;
  107142. },
  107143. set: function (value) {
  107144. if (this._isBillboardBased === value) {
  107145. return;
  107146. }
  107147. this._isBillboardBased = value;
  107148. this._reset();
  107149. },
  107150. enumerable: true,
  107151. configurable: true
  107152. });
  107153. Object.defineProperty(BaseParticleSystem.prototype, "imageProcessingConfiguration", {
  107154. /**
  107155. * Gets the image processing configuration used either in this material.
  107156. */
  107157. get: function () {
  107158. return this._imageProcessingConfiguration;
  107159. },
  107160. /**
  107161. * Sets the Default image processing configuration used either in the this material.
  107162. *
  107163. * If sets to null, the scene one is in use.
  107164. */
  107165. set: function (value) {
  107166. this._attachImageProcessingConfiguration(value);
  107167. },
  107168. enumerable: true,
  107169. configurable: true
  107170. });
  107171. /**
  107172. * Attaches a new image processing configuration to the Standard Material.
  107173. * @param configuration
  107174. */
  107175. BaseParticleSystem.prototype._attachImageProcessingConfiguration = function (configuration) {
  107176. if (configuration === this._imageProcessingConfiguration) {
  107177. return;
  107178. }
  107179. // Pick the scene configuration if needed.
  107180. if (!configuration) {
  107181. this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration;
  107182. }
  107183. else {
  107184. this._imageProcessingConfiguration = configuration;
  107185. }
  107186. };
  107187. /** @hidden */
  107188. BaseParticleSystem.prototype._reset = function () {
  107189. };
  107190. /** @hidden */
  107191. BaseParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  107192. if (!gradients) {
  107193. return this;
  107194. }
  107195. var index = 0;
  107196. for (var _i = 0, gradients_1 = gradients; _i < gradients_1.length; _i++) {
  107197. var valueGradient = gradients_1[_i];
  107198. if (valueGradient.gradient === gradient) {
  107199. gradients.splice(index, 1);
  107200. break;
  107201. }
  107202. index++;
  107203. }
  107204. if (texture) {
  107205. texture.dispose();
  107206. }
  107207. return this;
  107208. };
  107209. /**
  107210. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  107211. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  107212. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  107213. * @returns the emitter
  107214. */
  107215. BaseParticleSystem.prototype.createPointEmitter = function (direction1, direction2) {
  107216. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["PointParticleEmitter"]();
  107217. particleEmitter.direction1 = direction1;
  107218. particleEmitter.direction2 = direction2;
  107219. this.particleEmitterType = particleEmitter;
  107220. return particleEmitter;
  107221. };
  107222. /**
  107223. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  107224. * @param radius The radius of the hemisphere to emit from
  107225. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  107226. * @returns the emitter
  107227. */
  107228. BaseParticleSystem.prototype.createHemisphericEmitter = function (radius, radiusRange) {
  107229. if (radius === void 0) { radius = 1; }
  107230. if (radiusRange === void 0) { radiusRange = 1; }
  107231. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["HemisphericParticleEmitter"](radius, radiusRange);
  107232. this.particleEmitterType = particleEmitter;
  107233. return particleEmitter;
  107234. };
  107235. /**
  107236. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  107237. * @param radius The radius of the sphere to emit from
  107238. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  107239. * @returns the emitter
  107240. */
  107241. BaseParticleSystem.prototype.createSphereEmitter = function (radius, radiusRange) {
  107242. if (radius === void 0) { radius = 1; }
  107243. if (radiusRange === void 0) { radiusRange = 1; }
  107244. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereParticleEmitter"](radius, radiusRange);
  107245. this.particleEmitterType = particleEmitter;
  107246. return particleEmitter;
  107247. };
  107248. /**
  107249. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  107250. * @param radius The radius of the sphere to emit from
  107251. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  107252. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  107253. * @returns the emitter
  107254. */
  107255. BaseParticleSystem.prototype.createDirectedSphereEmitter = function (radius, direction1, direction2) {
  107256. if (radius === void 0) { radius = 1; }
  107257. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  107258. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  107259. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereDirectedParticleEmitter"](radius, direction1, direction2);
  107260. this.particleEmitterType = particleEmitter;
  107261. return particleEmitter;
  107262. };
  107263. /**
  107264. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  107265. * @param radius The radius of the emission cylinder
  107266. * @param height The height of the emission cylinder
  107267. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  107268. * @param directionRandomizer How much to randomize the particle direction [0-1]
  107269. * @returns the emitter
  107270. */
  107271. BaseParticleSystem.prototype.createCylinderEmitter = function (radius, height, radiusRange, directionRandomizer) {
  107272. if (radius === void 0) { radius = 1; }
  107273. if (height === void 0) { height = 1; }
  107274. if (radiusRange === void 0) { radiusRange = 1; }
  107275. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  107276. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"](radius, height, radiusRange, directionRandomizer);
  107277. this.particleEmitterType = particleEmitter;
  107278. return particleEmitter;
  107279. };
  107280. /**
  107281. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  107282. * @param radius The radius of the cylinder to emit from
  107283. * @param height The height of the emission cylinder
  107284. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  107285. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  107286. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  107287. * @returns the emitter
  107288. */
  107289. BaseParticleSystem.prototype.createDirectedCylinderEmitter = function (radius, height, radiusRange, direction1, direction2) {
  107290. if (radius === void 0) { radius = 1; }
  107291. if (height === void 0) { height = 1; }
  107292. if (radiusRange === void 0) { radiusRange = 1; }
  107293. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  107294. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  107295. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"](radius, height, radiusRange, direction1, direction2);
  107296. this.particleEmitterType = particleEmitter;
  107297. return particleEmitter;
  107298. };
  107299. /**
  107300. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  107301. * @param radius The radius of the cone to emit from
  107302. * @param angle The base angle of the cone
  107303. * @returns the emitter
  107304. */
  107305. BaseParticleSystem.prototype.createConeEmitter = function (radius, angle) {
  107306. if (radius === void 0) { radius = 1; }
  107307. if (angle === void 0) { angle = Math.PI / 4; }
  107308. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["ConeParticleEmitter"](radius, angle);
  107309. this.particleEmitterType = particleEmitter;
  107310. return particleEmitter;
  107311. };
  107312. /**
  107313. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  107314. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  107315. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  107316. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  107317. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  107318. * @returns the emitter
  107319. */
  107320. BaseParticleSystem.prototype.createBoxEmitter = function (direction1, direction2, minEmitBox, maxEmitBox) {
  107321. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["BoxParticleEmitter"]();
  107322. this.particleEmitterType = particleEmitter;
  107323. this.direction1 = direction1;
  107324. this.direction2 = direction2;
  107325. this.minEmitBox = minEmitBox;
  107326. this.maxEmitBox = maxEmitBox;
  107327. return particleEmitter;
  107328. };
  107329. /**
  107330. * Source color is added to the destination color without alpha affecting the result
  107331. */
  107332. BaseParticleSystem.BLENDMODE_ONEONE = 0;
  107333. /**
  107334. * Blend current color and particle color using particle’s alpha
  107335. */
  107336. BaseParticleSystem.BLENDMODE_STANDARD = 1;
  107337. /**
  107338. * Add current color and particle color multiplied by particle’s alpha
  107339. */
  107340. BaseParticleSystem.BLENDMODE_ADD = 2;
  107341. /**
  107342. * Multiply current color with particle color
  107343. */
  107344. BaseParticleSystem.BLENDMODE_MULTIPLY = 3;
  107345. /**
  107346. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  107347. */
  107348. BaseParticleSystem.BLENDMODE_MULTIPLYADD = 4;
  107349. return BaseParticleSystem;
  107350. }());
  107351. /***/ }),
  107352. /***/ "./Particles/gpuParticleSystem.ts":
  107353. /*!****************************************!*\
  107354. !*** ./Particles/gpuParticleSystem.ts ***!
  107355. \****************************************/
  107356. /*! exports provided: GPUParticleSystem */
  107357. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107358. "use strict";
  107359. __webpack_require__.r(__webpack_exports__);
  107360. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return GPUParticleSystem; });
  107361. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  107362. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  107363. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  107364. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  107365. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  107366. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  107367. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  107368. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  107369. /* harmony import */ var _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Particles/EmitterTypes/boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  107370. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  107371. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  107372. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  107373. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  107374. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  107375. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  107376. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  107377. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  107378. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  107379. /* harmony import */ var _Shaders_gpuUpdateParticles_fragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.fragment */ "./Shaders/gpuUpdateParticles.fragment.ts");
  107380. /* harmony import */ var _Shaders_gpuUpdateParticles_vertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.vertex */ "./Shaders/gpuUpdateParticles.vertex.ts");
  107381. /* harmony import */ var _Shaders_gpuRenderParticles_fragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.fragment */ "./Shaders/gpuRenderParticles.fragment.ts");
  107382. /* harmony import */ var _Shaders_gpuRenderParticles_vertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.vertex */ "./Shaders/gpuRenderParticles.vertex.ts");
  107383. /**
  107384. * This represents a GPU particle system in Babylon
  107385. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  107386. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  107387. */
  107388. var GPUParticleSystem = /** @class */ (function (_super) {
  107389. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GPUParticleSystem, _super);
  107390. /**
  107391. * Instantiates a GPU particle system.
  107392. * 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.
  107393. * @param name The name of the particle system
  107394. * @param options The options used to create the system
  107395. * @param scene The scene the particle system belongs to
  107396. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  107397. */
  107398. function GPUParticleSystem(name, options, scene, isAnimationSheetEnabled) {
  107399. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  107400. var _this = _super.call(this, name) || this;
  107401. /**
  107402. * The layer mask we are rendering the particles through.
  107403. */
  107404. _this.layerMask = 0x0FFFFFFF;
  107405. _this._accumulatedCount = 0;
  107406. _this._targetIndex = 0;
  107407. _this._currentRenderId = -1;
  107408. _this._started = false;
  107409. _this._stopped = false;
  107410. _this._timeDelta = 0;
  107411. _this._actualFrame = 0;
  107412. _this._rawTextureWidth = 256;
  107413. /**
  107414. * An event triggered when the system is disposed.
  107415. */
  107416. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  107417. /**
  107418. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  107419. * to override the particles.
  107420. */
  107421. _this.forceDepthWrite = false;
  107422. _this._preWarmDone = false;
  107423. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  107424. // Setup the default processing configuration to the scene.
  107425. _this._attachImageProcessingConfiguration(null);
  107426. _this._engine = _this._scene.getEngine();
  107427. if (!options.randomTextureSize) {
  107428. delete options.randomTextureSize;
  107429. }
  107430. var fullOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ capacity: 50000, randomTextureSize: _this._engine.getCaps().maxTextureSize }, options);
  107431. var optionsAsNumber = options;
  107432. if (isFinite(optionsAsNumber)) {
  107433. fullOptions.capacity = optionsAsNumber;
  107434. }
  107435. _this._capacity = fullOptions.capacity;
  107436. _this._activeCount = fullOptions.capacity;
  107437. _this._currentActiveCount = 0;
  107438. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  107439. _this._scene.particleSystems.push(_this);
  107440. _this._updateEffectOptions = {
  107441. attributes: ["position", "age", "life", "seed", "size", "color", "direction", "initialDirection", "angle", "cellIndex", "cellStartOffset", "noiseCoordinates1", "noiseCoordinates2"],
  107442. uniformsNames: ["currentCount", "timeDelta", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "scaleRange", "gravity", "emitPower",
  107443. "direction1", "direction2", "minEmitBox", "maxEmitBox", "radius", "directionRandomizer", "height", "coneAngle", "stopFactor",
  107444. "angleRange", "radiusRange", "cellInfos", "noiseStrength", "limitVelocityDamping"],
  107445. uniformBuffersNames: [],
  107446. samplers: ["randomSampler", "randomSampler2", "sizeGradientSampler", "angularSpeedGradientSampler", "velocityGradientSampler", "limitVelocityGradientSampler", "noiseSampler", "dragGradientSampler"],
  107447. defines: "",
  107448. fallbacks: null,
  107449. onCompiled: null,
  107450. onError: null,
  107451. indexParameters: null,
  107452. maxSimultaneousLights: 0,
  107453. transformFeedbackVaryings: []
  107454. };
  107455. _this.particleEmitterType = new _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__["BoxParticleEmitter"]();
  107456. // Random data
  107457. var maxTextureSize = Math.min(_this._engine.getCaps().maxTextureSize, fullOptions.randomTextureSize);
  107458. var d = [];
  107459. for (var i = 0; i < maxTextureSize; ++i) {
  107460. d.push(Math.random());
  107461. d.push(Math.random());
  107462. d.push(Math.random());
  107463. d.push(Math.random());
  107464. }
  107465. _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);
  107466. _this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  107467. _this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  107468. d = [];
  107469. for (var i = 0; i < maxTextureSize; ++i) {
  107470. d.push(Math.random());
  107471. d.push(Math.random());
  107472. d.push(Math.random());
  107473. d.push(Math.random());
  107474. }
  107475. _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);
  107476. _this._randomTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  107477. _this._randomTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  107478. _this._randomTextureSize = maxTextureSize;
  107479. return _this;
  107480. }
  107481. Object.defineProperty(GPUParticleSystem, "IsSupported", {
  107482. /**
  107483. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  107484. */
  107485. get: function () {
  107486. if (!_Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine) {
  107487. return false;
  107488. }
  107489. return _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine.webGLVersion > 1;
  107490. },
  107491. enumerable: true,
  107492. configurable: true
  107493. });
  107494. /**
  107495. * Gets the maximum number of particles active at the same time.
  107496. * @returns The max number of active particles.
  107497. */
  107498. GPUParticleSystem.prototype.getCapacity = function () {
  107499. return this._capacity;
  107500. };
  107501. Object.defineProperty(GPUParticleSystem.prototype, "activeParticleCount", {
  107502. /**
  107503. * Gets or set the number of active particles
  107504. */
  107505. get: function () {
  107506. return this._activeCount;
  107507. },
  107508. set: function (value) {
  107509. this._activeCount = Math.min(value, this._capacity);
  107510. },
  107511. enumerable: true,
  107512. configurable: true
  107513. });
  107514. /**
  107515. * Is this system ready to be used/rendered
  107516. * @return true if the system is ready
  107517. */
  107518. GPUParticleSystem.prototype.isReady = function () {
  107519. if (!this._updateEffect) {
  107520. this._recreateUpdateEffect();
  107521. this._recreateRenderEffect();
  107522. return false;
  107523. }
  107524. if (!this.emitter || !this._updateEffect.isReady() || !this._imageProcessingConfiguration.isReady() || !this._renderEffect.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  107525. return false;
  107526. }
  107527. return true;
  107528. };
  107529. /**
  107530. * Gets if the system has been started. (Note: this will still be true after stop is called)
  107531. * @returns True if it has been started, otherwise false.
  107532. */
  107533. GPUParticleSystem.prototype.isStarted = function () {
  107534. return this._started;
  107535. };
  107536. /**
  107537. * Starts the particle system and begins to emit
  107538. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  107539. */
  107540. GPUParticleSystem.prototype.start = function (delay) {
  107541. var _this = this;
  107542. if (delay === void 0) { delay = this.startDelay; }
  107543. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  107544. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  107545. }
  107546. if (delay) {
  107547. setTimeout(function () {
  107548. _this.start(0);
  107549. }, delay);
  107550. return;
  107551. }
  107552. this._started = true;
  107553. this._stopped = false;
  107554. this._preWarmDone = false;
  107555. // Animations
  107556. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  107557. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  107558. }
  107559. };
  107560. /**
  107561. * Stops the particle system.
  107562. */
  107563. GPUParticleSystem.prototype.stop = function () {
  107564. this._stopped = true;
  107565. };
  107566. /**
  107567. * Remove all active particles
  107568. */
  107569. GPUParticleSystem.prototype.reset = function () {
  107570. this._releaseBuffers();
  107571. this._releaseVAOs();
  107572. this._currentActiveCount = 0;
  107573. this._targetIndex = 0;
  107574. };
  107575. /**
  107576. * Returns the string "GPUParticleSystem"
  107577. * @returns a string containing the class name
  107578. */
  107579. GPUParticleSystem.prototype.getClassName = function () {
  107580. return "GPUParticleSystem";
  107581. };
  107582. GPUParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  107583. _super.prototype._removeGradientAndTexture.call(this, gradient, gradients, texture);
  107584. this._releaseBuffers();
  107585. return this;
  107586. };
  107587. /**
  107588. * Adds a new color gradient
  107589. * @param gradient defines the gradient to use (between 0 and 1)
  107590. * @param color1 defines the color to affect to the specified gradient
  107591. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  107592. * @returns the current particle system
  107593. */
  107594. GPUParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  107595. if (!this._colorGradients) {
  107596. this._colorGradients = [];
  107597. }
  107598. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  107599. colorGradient.gradient = gradient;
  107600. colorGradient.color1 = color1;
  107601. this._colorGradients.push(colorGradient);
  107602. this._colorGradients.sort(function (a, b) {
  107603. if (a.gradient < b.gradient) {
  107604. return -1;
  107605. }
  107606. else if (a.gradient > b.gradient) {
  107607. return 1;
  107608. }
  107609. return 0;
  107610. });
  107611. if (this._colorGradientsTexture) {
  107612. this._colorGradientsTexture.dispose();
  107613. this._colorGradientsTexture = null;
  107614. }
  107615. this._releaseBuffers();
  107616. return this;
  107617. };
  107618. /**
  107619. * Remove a specific color gradient
  107620. * @param gradient defines the gradient to remove
  107621. * @returns the current particle system
  107622. */
  107623. GPUParticleSystem.prototype.removeColorGradient = function (gradient) {
  107624. this._removeGradientAndTexture(gradient, this._colorGradients, this._colorGradientsTexture);
  107625. this._colorGradientsTexture = null;
  107626. return this;
  107627. };
  107628. GPUParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor) {
  107629. var valueGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  107630. valueGradient.gradient = gradient;
  107631. valueGradient.factor1 = factor;
  107632. factorGradients.push(valueGradient);
  107633. factorGradients.sort(function (a, b) {
  107634. if (a.gradient < b.gradient) {
  107635. return -1;
  107636. }
  107637. else if (a.gradient > b.gradient) {
  107638. return 1;
  107639. }
  107640. return 0;
  107641. });
  107642. this._releaseBuffers();
  107643. };
  107644. /**
  107645. * Adds a new size gradient
  107646. * @param gradient defines the gradient to use (between 0 and 1)
  107647. * @param factor defines the size factor to affect to the specified gradient
  107648. * @returns the current particle system
  107649. */
  107650. GPUParticleSystem.prototype.addSizeGradient = function (gradient, factor) {
  107651. if (!this._sizeGradients) {
  107652. this._sizeGradients = [];
  107653. }
  107654. this._addFactorGradient(this._sizeGradients, gradient, factor);
  107655. if (this._sizeGradientsTexture) {
  107656. this._sizeGradientsTexture.dispose();
  107657. this._sizeGradientsTexture = null;
  107658. }
  107659. this._releaseBuffers();
  107660. return this;
  107661. };
  107662. /**
  107663. * Remove a specific size gradient
  107664. * @param gradient defines the gradient to remove
  107665. * @returns the current particle system
  107666. */
  107667. GPUParticleSystem.prototype.removeSizeGradient = function (gradient) {
  107668. this._removeGradientAndTexture(gradient, this._sizeGradients, this._sizeGradientsTexture);
  107669. this._sizeGradientsTexture = null;
  107670. return this;
  107671. };
  107672. /**
  107673. * Adds a new angular speed gradient
  107674. * @param gradient defines the gradient to use (between 0 and 1)
  107675. * @param factor defines the angular speed to affect to the specified gradient
  107676. * @returns the current particle system
  107677. */
  107678. GPUParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor) {
  107679. if (!this._angularSpeedGradients) {
  107680. this._angularSpeedGradients = [];
  107681. }
  107682. this._addFactorGradient(this._angularSpeedGradients, gradient, factor);
  107683. if (this._angularSpeedGradientsTexture) {
  107684. this._angularSpeedGradientsTexture.dispose();
  107685. this._angularSpeedGradientsTexture = null;
  107686. }
  107687. this._releaseBuffers();
  107688. return this;
  107689. };
  107690. /**
  107691. * Remove a specific angular speed gradient
  107692. * @param gradient defines the gradient to remove
  107693. * @returns the current particle system
  107694. */
  107695. GPUParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  107696. this._removeGradientAndTexture(gradient, this._angularSpeedGradients, this._angularSpeedGradientsTexture);
  107697. this._angularSpeedGradientsTexture = null;
  107698. return this;
  107699. };
  107700. /**
  107701. * Adds a new velocity gradient
  107702. * @param gradient defines the gradient to use (between 0 and 1)
  107703. * @param factor defines the velocity to affect to the specified gradient
  107704. * @returns the current particle system
  107705. */
  107706. GPUParticleSystem.prototype.addVelocityGradient = function (gradient, factor) {
  107707. if (!this._velocityGradients) {
  107708. this._velocityGradients = [];
  107709. }
  107710. this._addFactorGradient(this._velocityGradients, gradient, factor);
  107711. if (this._velocityGradientsTexture) {
  107712. this._velocityGradientsTexture.dispose();
  107713. this._velocityGradientsTexture = null;
  107714. }
  107715. this._releaseBuffers();
  107716. return this;
  107717. };
  107718. /**
  107719. * Remove a specific velocity gradient
  107720. * @param gradient defines the gradient to remove
  107721. * @returns the current particle system
  107722. */
  107723. GPUParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  107724. this._removeGradientAndTexture(gradient, this._velocityGradients, this._velocityGradientsTexture);
  107725. this._velocityGradientsTexture = null;
  107726. return this;
  107727. };
  107728. /**
  107729. * Adds a new limit velocity gradient
  107730. * @param gradient defines the gradient to use (between 0 and 1)
  107731. * @param factor defines the limit velocity value to affect to the specified gradient
  107732. * @returns the current particle system
  107733. */
  107734. GPUParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor) {
  107735. if (!this._limitVelocityGradients) {
  107736. this._limitVelocityGradients = [];
  107737. }
  107738. this._addFactorGradient(this._limitVelocityGradients, gradient, factor);
  107739. if (this._limitVelocityGradientsTexture) {
  107740. this._limitVelocityGradientsTexture.dispose();
  107741. this._limitVelocityGradientsTexture = null;
  107742. }
  107743. this._releaseBuffers();
  107744. return this;
  107745. };
  107746. /**
  107747. * Remove a specific limit velocity gradient
  107748. * @param gradient defines the gradient to remove
  107749. * @returns the current particle system
  107750. */
  107751. GPUParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  107752. this._removeGradientAndTexture(gradient, this._limitVelocityGradients, this._limitVelocityGradientsTexture);
  107753. this._limitVelocityGradientsTexture = null;
  107754. return this;
  107755. };
  107756. /**
  107757. * Adds a new drag gradient
  107758. * @param gradient defines the gradient to use (between 0 and 1)
  107759. * @param factor defines the drag value to affect to the specified gradient
  107760. * @returns the current particle system
  107761. */
  107762. GPUParticleSystem.prototype.addDragGradient = function (gradient, factor) {
  107763. if (!this._dragGradients) {
  107764. this._dragGradients = [];
  107765. }
  107766. this._addFactorGradient(this._dragGradients, gradient, factor);
  107767. if (this._dragGradientsTexture) {
  107768. this._dragGradientsTexture.dispose();
  107769. this._dragGradientsTexture = null;
  107770. }
  107771. this._releaseBuffers();
  107772. return this;
  107773. };
  107774. /**
  107775. * Remove a specific drag gradient
  107776. * @param gradient defines the gradient to remove
  107777. * @returns the current particle system
  107778. */
  107779. GPUParticleSystem.prototype.removeDragGradient = function (gradient) {
  107780. this._removeGradientAndTexture(gradient, this._dragGradients, this._dragGradientsTexture);
  107781. this._dragGradientsTexture = null;
  107782. return this;
  107783. };
  107784. /**
  107785. * Not supported by GPUParticleSystem
  107786. * @param gradient defines the gradient to use (between 0 and 1)
  107787. * @param factor defines the emit rate value to affect to the specified gradient
  107788. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107789. * @returns the current particle system
  107790. */
  107791. GPUParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  107792. // Do nothing as emit rate is not supported by GPUParticleSystem
  107793. return this;
  107794. };
  107795. /**
  107796. * Not supported by GPUParticleSystem
  107797. * @param gradient defines the gradient to remove
  107798. * @returns the current particle system
  107799. */
  107800. GPUParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  107801. // Do nothing as emit rate is not supported by GPUParticleSystem
  107802. return this;
  107803. };
  107804. /**
  107805. * Not supported by GPUParticleSystem
  107806. * @param gradient defines the gradient to use (between 0 and 1)
  107807. * @param factor defines the start size value to affect to the specified gradient
  107808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107809. * @returns the current particle system
  107810. */
  107811. GPUParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  107812. // Do nothing as start size is not supported by GPUParticleSystem
  107813. return this;
  107814. };
  107815. /**
  107816. * Not supported by GPUParticleSystem
  107817. * @param gradient defines the gradient to remove
  107818. * @returns the current particle system
  107819. */
  107820. GPUParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  107821. // Do nothing as start size is not supported by GPUParticleSystem
  107822. return this;
  107823. };
  107824. /**
  107825. * Not supported by GPUParticleSystem
  107826. * @param gradient defines the gradient to use (between 0 and 1)
  107827. * @param min defines the color remap minimal range
  107828. * @param max defines the color remap maximal range
  107829. * @returns the current particle system
  107830. */
  107831. GPUParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  107832. // Do nothing as start size is not supported by GPUParticleSystem
  107833. return this;
  107834. };
  107835. /**
  107836. * Not supported by GPUParticleSystem
  107837. * @param gradient defines the gradient to remove
  107838. * @returns the current particle system
  107839. */
  107840. GPUParticleSystem.prototype.removeColorRemapGradient = function () {
  107841. // Do nothing as start size is not supported by GPUParticleSystem
  107842. return this;
  107843. };
  107844. /**
  107845. * Not supported by GPUParticleSystem
  107846. * @param gradient defines the gradient to use (between 0 and 1)
  107847. * @param min defines the alpha remap minimal range
  107848. * @param max defines the alpha remap maximal range
  107849. * @returns the current particle system
  107850. */
  107851. GPUParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  107852. // Do nothing as start size is not supported by GPUParticleSystem
  107853. return this;
  107854. };
  107855. /**
  107856. * Not supported by GPUParticleSystem
  107857. * @param gradient defines the gradient to remove
  107858. * @returns the current particle system
  107859. */
  107860. GPUParticleSystem.prototype.removeAlphaRemapGradient = function () {
  107861. // Do nothing as start size is not supported by GPUParticleSystem
  107862. return this;
  107863. };
  107864. /**
  107865. * Not supported by GPUParticleSystem
  107866. * @param gradient defines the gradient to use (between 0 and 1)
  107867. * @param color defines the color to affect to the specified gradient
  107868. * @returns the current particle system
  107869. */
  107870. GPUParticleSystem.prototype.addRampGradient = function (gradient, color) {
  107871. //Not supported by GPUParticleSystem
  107872. return this;
  107873. };
  107874. /**
  107875. * Not supported by GPUParticleSystem
  107876. * @param gradient defines the gradient to remove
  107877. * @returns the current particle system
  107878. */
  107879. GPUParticleSystem.prototype.removeRampGradient = function () {
  107880. //Not supported by GPUParticleSystem
  107881. return this;
  107882. };
  107883. /**
  107884. * Not supported by GPUParticleSystem
  107885. * @returns the list of ramp gradients
  107886. */
  107887. GPUParticleSystem.prototype.getRampGradients = function () {
  107888. return null;
  107889. };
  107890. Object.defineProperty(GPUParticleSystem.prototype, "useRampGradients", {
  107891. /**
  107892. * Not supported by GPUParticleSystem
  107893. * Gets or sets a boolean indicating that ramp gradients must be used
  107894. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  107895. */
  107896. get: function () {
  107897. //Not supported by GPUParticleSystem
  107898. return false;
  107899. },
  107900. set: function (value) {
  107901. //Not supported by GPUParticleSystem
  107902. },
  107903. enumerable: true,
  107904. configurable: true
  107905. });
  107906. /**
  107907. * Not supported by GPUParticleSystem
  107908. * @param gradient defines the gradient to use (between 0 and 1)
  107909. * @param factor defines the life time factor to affect to the specified gradient
  107910. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107911. * @returns the current particle system
  107912. */
  107913. GPUParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  107914. //Not supported by GPUParticleSystem
  107915. return this;
  107916. };
  107917. /**
  107918. * Not supported by GPUParticleSystem
  107919. * @param gradient defines the gradient to remove
  107920. * @returns the current particle system
  107921. */
  107922. GPUParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  107923. //Not supported by GPUParticleSystem
  107924. return this;
  107925. };
  107926. GPUParticleSystem.prototype._reset = function () {
  107927. this._releaseBuffers();
  107928. };
  107929. GPUParticleSystem.prototype._createUpdateVAO = function (source) {
  107930. var updateVertexBuffers = {};
  107931. updateVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3);
  107932. updateVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1);
  107933. updateVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1);
  107934. updateVertexBuffers["seed"] = source.createVertexBuffer("seed", 5, 4);
  107935. updateVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3);
  107936. var offset = 12;
  107937. if (!this._colorGradientsTexture) {
  107938. updateVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4);
  107939. offset += 4;
  107940. }
  107941. updateVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3);
  107942. offset += 3;
  107943. if (!this._isBillboardBased) {
  107944. updateVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3);
  107945. offset += 3;
  107946. }
  107947. if (this._angularSpeedGradientsTexture) {
  107948. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1);
  107949. offset += 1;
  107950. }
  107951. else {
  107952. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 2);
  107953. offset += 2;
  107954. }
  107955. if (this._isAnimationSheetEnabled) {
  107956. updateVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1);
  107957. offset += 1;
  107958. if (this.spriteRandomStartCell) {
  107959. updateVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1);
  107960. offset += 1;
  107961. }
  107962. }
  107963. if (this.noiseTexture) {
  107964. updateVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3);
  107965. offset += 3;
  107966. updateVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3);
  107967. offset += 3;
  107968. }
  107969. var vao = this._engine.recordVertexArrayObject(updateVertexBuffers, null, this._updateEffect);
  107970. this._engine.bindArrayBuffer(null);
  107971. return vao;
  107972. };
  107973. GPUParticleSystem.prototype._createRenderVAO = function (source, spriteSource) {
  107974. var renderVertexBuffers = {};
  107975. renderVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3, this._attributesStrideSize, true);
  107976. renderVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1, this._attributesStrideSize, true);
  107977. renderVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1, this._attributesStrideSize, true);
  107978. renderVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3, this._attributesStrideSize, true);
  107979. var offset = 12;
  107980. if (!this._colorGradientsTexture) {
  107981. renderVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4, this._attributesStrideSize, true);
  107982. offset += 4;
  107983. }
  107984. if (this.billboardMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED) {
  107985. renderVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3, this._attributesStrideSize, true);
  107986. }
  107987. offset += 3; // Direction
  107988. if (!this._isBillboardBased) {
  107989. renderVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3, this._attributesStrideSize, true);
  107990. offset += 3;
  107991. }
  107992. renderVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1, this._attributesStrideSize, true);
  107993. if (this._angularSpeedGradientsTexture) {
  107994. offset++;
  107995. }
  107996. else {
  107997. offset += 2;
  107998. }
  107999. if (this._isAnimationSheetEnabled) {
  108000. renderVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1, this._attributesStrideSize, true);
  108001. offset += 1;
  108002. if (this.spriteRandomStartCell) {
  108003. renderVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1, this._attributesStrideSize, true);
  108004. offset += 1;
  108005. }
  108006. }
  108007. if (this.noiseTexture) {
  108008. renderVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3, this._attributesStrideSize, true);
  108009. offset += 3;
  108010. renderVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3, this._attributesStrideSize, true);
  108011. offset += 3;
  108012. }
  108013. renderVertexBuffers["offset"] = spriteSource.createVertexBuffer("offset", 0, 2);
  108014. renderVertexBuffers["uv"] = spriteSource.createVertexBuffer("uv", 2, 2);
  108015. var vao = this._engine.recordVertexArrayObject(renderVertexBuffers, null, this._renderEffect);
  108016. this._engine.bindArrayBuffer(null);
  108017. return vao;
  108018. };
  108019. GPUParticleSystem.prototype._initialize = function (force) {
  108020. if (force === void 0) { force = false; }
  108021. if (this._buffer0 && !force) {
  108022. return;
  108023. }
  108024. var engine = this._scene.getEngine();
  108025. var data = new Array();
  108026. this._attributesStrideSize = 21;
  108027. this._targetIndex = 0;
  108028. if (!this.isBillboardBased) {
  108029. this._attributesStrideSize += 3;
  108030. }
  108031. if (this._colorGradientsTexture) {
  108032. this._attributesStrideSize -= 4;
  108033. }
  108034. if (this._angularSpeedGradientsTexture) {
  108035. this._attributesStrideSize -= 1;
  108036. }
  108037. if (this._isAnimationSheetEnabled) {
  108038. this._attributesStrideSize += 1;
  108039. if (this.spriteRandomStartCell) {
  108040. this._attributesStrideSize += 1;
  108041. }
  108042. }
  108043. if (this.noiseTexture) {
  108044. this._attributesStrideSize += 6;
  108045. }
  108046. for (var particleIndex = 0; particleIndex < this._capacity; particleIndex++) {
  108047. // position
  108048. data.push(0.0);
  108049. data.push(0.0);
  108050. data.push(0.0);
  108051. // Age and life
  108052. data.push(0.0); // create the particle as a dead one to create a new one at start
  108053. data.push(0.0);
  108054. // Seed
  108055. data.push(Math.random());
  108056. data.push(Math.random());
  108057. data.push(Math.random());
  108058. data.push(Math.random());
  108059. // Size
  108060. data.push(0.0);
  108061. data.push(0.0);
  108062. data.push(0.0);
  108063. if (!this._colorGradientsTexture) {
  108064. // color
  108065. data.push(0.0);
  108066. data.push(0.0);
  108067. data.push(0.0);
  108068. data.push(0.0);
  108069. }
  108070. // direction
  108071. data.push(0.0);
  108072. data.push(0.0);
  108073. data.push(0.0);
  108074. if (!this.isBillboardBased) {
  108075. // initialDirection
  108076. data.push(0.0);
  108077. data.push(0.0);
  108078. data.push(0.0);
  108079. }
  108080. // angle
  108081. data.push(0.0);
  108082. if (!this._angularSpeedGradientsTexture) {
  108083. data.push(0.0);
  108084. }
  108085. if (this._isAnimationSheetEnabled) {
  108086. data.push(0.0);
  108087. if (this.spriteRandomStartCell) {
  108088. data.push(0.0);
  108089. }
  108090. }
  108091. if (this.noiseTexture) { // Random coordinates for reading into noise texture
  108092. data.push(Math.random());
  108093. data.push(Math.random());
  108094. data.push(Math.random());
  108095. data.push(Math.random());
  108096. data.push(Math.random());
  108097. data.push(Math.random());
  108098. }
  108099. }
  108100. // Sprite data
  108101. var spriteData = new Float32Array([0.5, 0.5, 1, 1,
  108102. -0.5, 0.5, 0, 1,
  108103. -0.5, -0.5, 0, 0,
  108104. 0.5, -0.5, 1, 0]);
  108105. // Buffers
  108106. this._buffer0 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  108107. this._buffer1 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  108108. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 4);
  108109. // Update VAO
  108110. this._updateVAO = [];
  108111. this._updateVAO.push(this._createUpdateVAO(this._buffer0));
  108112. this._updateVAO.push(this._createUpdateVAO(this._buffer1));
  108113. // Render VAO
  108114. this._renderVAO = [];
  108115. this._renderVAO.push(this._createRenderVAO(this._buffer1, this._spriteBuffer));
  108116. this._renderVAO.push(this._createRenderVAO(this._buffer0, this._spriteBuffer));
  108117. // Links
  108118. this._sourceBuffer = this._buffer0;
  108119. this._targetBuffer = this._buffer1;
  108120. };
  108121. /** @hidden */
  108122. GPUParticleSystem.prototype._recreateUpdateEffect = function () {
  108123. var defines = this.particleEmitterType ? this.particleEmitterType.getEffectDefines() : "";
  108124. if (this._isBillboardBased) {
  108125. defines += "\n#define BILLBOARD";
  108126. }
  108127. if (this._colorGradientsTexture) {
  108128. defines += "\n#define COLORGRADIENTS";
  108129. }
  108130. if (this._sizeGradientsTexture) {
  108131. defines += "\n#define SIZEGRADIENTS";
  108132. }
  108133. if (this._angularSpeedGradientsTexture) {
  108134. defines += "\n#define ANGULARSPEEDGRADIENTS";
  108135. }
  108136. if (this._velocityGradientsTexture) {
  108137. defines += "\n#define VELOCITYGRADIENTS";
  108138. }
  108139. if (this._limitVelocityGradientsTexture) {
  108140. defines += "\n#define LIMITVELOCITYGRADIENTS";
  108141. }
  108142. if (this._dragGradientsTexture) {
  108143. defines += "\n#define DRAGGRADIENTS";
  108144. }
  108145. if (this.isAnimationSheetEnabled) {
  108146. defines += "\n#define ANIMATESHEET";
  108147. if (this.spriteRandomStartCell) {
  108148. defines += "\n#define ANIMATESHEETRANDOMSTART";
  108149. }
  108150. }
  108151. if (this.noiseTexture) {
  108152. defines += "\n#define NOISE";
  108153. }
  108154. if (this._updateEffect && this._updateEffectOptions.defines === defines) {
  108155. return;
  108156. }
  108157. this._updateEffectOptions.transformFeedbackVaryings = ["outPosition", "outAge", "outLife", "outSeed", "outSize"];
  108158. if (!this._colorGradientsTexture) {
  108159. this._updateEffectOptions.transformFeedbackVaryings.push("outColor");
  108160. }
  108161. this._updateEffectOptions.transformFeedbackVaryings.push("outDirection");
  108162. if (!this._isBillboardBased) {
  108163. this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection");
  108164. }
  108165. this._updateEffectOptions.transformFeedbackVaryings.push("outAngle");
  108166. if (this.isAnimationSheetEnabled) {
  108167. this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex");
  108168. if (this.spriteRandomStartCell) {
  108169. this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset");
  108170. }
  108171. }
  108172. if (this.noiseTexture) {
  108173. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1");
  108174. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2");
  108175. }
  108176. this._updateEffectOptions.defines = defines;
  108177. this._updateEffect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["Effect"]("gpuUpdateParticles", this._updateEffectOptions, this._scene.getEngine());
  108178. };
  108179. /** @hidden */
  108180. GPUParticleSystem.prototype._recreateRenderEffect = function () {
  108181. var defines = "";
  108182. if (this._scene.clipPlane) {
  108183. defines = "\n#define CLIPPLANE";
  108184. }
  108185. if (this._scene.clipPlane2) {
  108186. defines = "\n#define CLIPPLANE2";
  108187. }
  108188. if (this._scene.clipPlane3) {
  108189. defines = "\n#define CLIPPLANE3";
  108190. }
  108191. if (this._scene.clipPlane4) {
  108192. defines = "\n#define CLIPPLANE4";
  108193. }
  108194. if (this.blendMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY) {
  108195. defines = "\n#define BLENDMULTIPLYMODE";
  108196. }
  108197. if (this._isBillboardBased) {
  108198. defines += "\n#define BILLBOARD";
  108199. switch (this.billboardMode) {
  108200. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_Y:
  108201. defines += "\n#define BILLBOARDY";
  108202. break;
  108203. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED:
  108204. defines += "\n#define BILLBOARDSTRETCHED";
  108205. break;
  108206. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_ALL:
  108207. default:
  108208. break;
  108209. }
  108210. }
  108211. if (this._colorGradientsTexture) {
  108212. defines += "\n#define COLORGRADIENTS";
  108213. }
  108214. if (this.isAnimationSheetEnabled) {
  108215. defines += "\n#define ANIMATESHEET";
  108216. }
  108217. if (this._imageProcessingConfiguration) {
  108218. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  108219. defines += "\n" + this._imageProcessingConfigurationDefines.toString();
  108220. }
  108221. if (this._renderEffect && this._renderEffect.defines === defines) {
  108222. return;
  108223. }
  108224. var uniforms = ["worldOffset", "view", "projection", "colorDead", "invView", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "sheetInfos", "translationPivot", "eyePosition"];
  108225. var samplers = ["textureSampler", "colorGradientSampler"];
  108226. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]) {
  108227. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._imageProcessingConfigurationDefines);
  108228. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  108229. }
  108230. 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);
  108231. };
  108232. /**
  108233. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  108234. * @param preWarm defines if we are in the pre-warmimg phase
  108235. */
  108236. GPUParticleSystem.prototype.animate = function (preWarm) {
  108237. if (preWarm === void 0) { preWarm = false; }
  108238. this._timeDelta = this.updateSpeed * (preWarm ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  108239. this._actualFrame += this._timeDelta;
  108240. if (!this._stopped) {
  108241. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  108242. this.stop();
  108243. }
  108244. }
  108245. };
  108246. GPUParticleSystem.prototype._createFactorGradientTexture = function (factorGradients, textureName) {
  108247. var texture = this[textureName];
  108248. if (!factorGradients || !factorGradients.length || texture) {
  108249. return;
  108250. }
  108251. var data = new Float32Array(this._rawTextureWidth);
  108252. for (var x = 0; x < this._rawTextureWidth; x++) {
  108253. var ratio = x / this._rawTextureWidth;
  108254. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, factorGradients, function (currentGradient, nextGradient, scale) {
  108255. data[x] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  108256. });
  108257. }
  108258. 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);
  108259. };
  108260. GPUParticleSystem.prototype._createSizeGradientTexture = function () {
  108261. this._createFactorGradientTexture(this._sizeGradients, "_sizeGradientsTexture");
  108262. };
  108263. GPUParticleSystem.prototype._createAngularSpeedGradientTexture = function () {
  108264. this._createFactorGradientTexture(this._angularSpeedGradients, "_angularSpeedGradientsTexture");
  108265. };
  108266. GPUParticleSystem.prototype._createVelocityGradientTexture = function () {
  108267. this._createFactorGradientTexture(this._velocityGradients, "_velocityGradientsTexture");
  108268. };
  108269. GPUParticleSystem.prototype._createLimitVelocityGradientTexture = function () {
  108270. this._createFactorGradientTexture(this._limitVelocityGradients, "_limitVelocityGradientsTexture");
  108271. };
  108272. GPUParticleSystem.prototype._createDragGradientTexture = function () {
  108273. this._createFactorGradientTexture(this._dragGradients, "_dragGradientsTexture");
  108274. };
  108275. GPUParticleSystem.prototype._createColorGradientTexture = function () {
  108276. if (!this._colorGradients || !this._colorGradients.length || this._colorGradientsTexture) {
  108277. return;
  108278. }
  108279. var data = new Uint8Array(this._rawTextureWidth * 4);
  108280. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color4[0];
  108281. for (var x = 0; x < this._rawTextureWidth; x++) {
  108282. var ratio = x / this._rawTextureWidth;
  108283. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._colorGradients, function (currentGradient, nextGradient, scale) {
  108284. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(currentGradient.color1, nextGradient.color1, scale, tmpColor);
  108285. data[x * 4] = tmpColor.r * 255;
  108286. data[x * 4 + 1] = tmpColor.g * 255;
  108287. data[x * 4 + 2] = tmpColor.b * 255;
  108288. data[x * 4 + 3] = tmpColor.a * 255;
  108289. });
  108290. }
  108291. 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);
  108292. };
  108293. /**
  108294. * Renders the particle system in its current state
  108295. * @param preWarm defines if the system should only update the particles but not render them
  108296. * @returns the current number of particles
  108297. */
  108298. GPUParticleSystem.prototype.render = function (preWarm) {
  108299. if (preWarm === void 0) { preWarm = false; }
  108300. if (!this._started) {
  108301. return 0;
  108302. }
  108303. this._createColorGradientTexture();
  108304. this._createSizeGradientTexture();
  108305. this._createAngularSpeedGradientTexture();
  108306. this._createVelocityGradientTexture();
  108307. this._createLimitVelocityGradientTexture();
  108308. this._createDragGradientTexture();
  108309. this._recreateUpdateEffect();
  108310. this._recreateRenderEffect();
  108311. if (!this.isReady()) {
  108312. return 0;
  108313. }
  108314. if (!preWarm) {
  108315. if (!this._preWarmDone && this.preWarmCycles) {
  108316. for (var index = 0; index < this.preWarmCycles; index++) {
  108317. this.animate(true);
  108318. this.render(true);
  108319. }
  108320. this._preWarmDone = true;
  108321. }
  108322. if (this._currentRenderId === this._scene.getFrameId()) {
  108323. return 0;
  108324. }
  108325. this._currentRenderId = this._scene.getFrameId();
  108326. }
  108327. // Get everything ready to render
  108328. this._initialize();
  108329. this._accumulatedCount += this.emitRate * this._timeDelta;
  108330. if (this._accumulatedCount > 1) {
  108331. var intPart = this._accumulatedCount | 0;
  108332. this._accumulatedCount -= intPart;
  108333. this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + intPart);
  108334. }
  108335. if (!this._currentActiveCount) {
  108336. return 0;
  108337. }
  108338. // Enable update effect
  108339. this._engine.enableEffect(this._updateEffect);
  108340. this._engine.setState(false);
  108341. this._updateEffect.setFloat("currentCount", this._currentActiveCount);
  108342. this._updateEffect.setFloat("timeDelta", this._timeDelta);
  108343. this._updateEffect.setFloat("stopFactor", this._stopped ? 0 : 1);
  108344. this._updateEffect.setTexture("randomSampler", this._randomTexture);
  108345. this._updateEffect.setTexture("randomSampler2", this._randomTexture2);
  108346. this._updateEffect.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime);
  108347. this._updateEffect.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower);
  108348. if (!this._colorGradientsTexture) {
  108349. this._updateEffect.setDirectColor4("color1", this.color1);
  108350. this._updateEffect.setDirectColor4("color2", this.color2);
  108351. }
  108352. this._updateEffect.setFloat2("sizeRange", this.minSize, this.maxSize);
  108353. this._updateEffect.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY);
  108354. this._updateEffect.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation);
  108355. this._updateEffect.setVector3("gravity", this.gravity);
  108356. if (this._sizeGradientsTexture) {
  108357. this._updateEffect.setTexture("sizeGradientSampler", this._sizeGradientsTexture);
  108358. }
  108359. if (this._angularSpeedGradientsTexture) {
  108360. this._updateEffect.setTexture("angularSpeedGradientSampler", this._angularSpeedGradientsTexture);
  108361. }
  108362. if (this._velocityGradientsTexture) {
  108363. this._updateEffect.setTexture("velocityGradientSampler", this._velocityGradientsTexture);
  108364. }
  108365. if (this._limitVelocityGradientsTexture) {
  108366. this._updateEffect.setTexture("limitVelocityGradientSampler", this._limitVelocityGradientsTexture);
  108367. this._updateEffect.setFloat("limitVelocityDamping", this.limitVelocityDamping);
  108368. }
  108369. if (this._dragGradientsTexture) {
  108370. this._updateEffect.setTexture("dragGradientSampler", this._dragGradientsTexture);
  108371. }
  108372. if (this.particleEmitterType) {
  108373. this.particleEmitterType.applyToShader(this._updateEffect);
  108374. }
  108375. if (this._isAnimationSheetEnabled) {
  108376. this._updateEffect.setFloat3("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed);
  108377. }
  108378. if (this.noiseTexture) {
  108379. this._updateEffect.setTexture("noiseSampler", this.noiseTexture);
  108380. this._updateEffect.setVector3("noiseStrength", this.noiseStrength);
  108381. }
  108382. var emitterWM;
  108383. if (this.emitter.position) {
  108384. var emitterMesh = this.emitter;
  108385. emitterWM = emitterMesh.getWorldMatrix();
  108386. }
  108387. else {
  108388. var emitterPosition = this.emitter;
  108389. emitterWM = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  108390. }
  108391. this._updateEffect.setMatrix("emitterWM", emitterWM);
  108392. // Bind source VAO
  108393. this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex], null);
  108394. // Update
  108395. this._engine.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer());
  108396. this._engine.setRasterizerState(false);
  108397. this._engine.beginTransformFeedback(true);
  108398. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].PointListDrawMode, 0, this._currentActiveCount);
  108399. this._engine.endTransformFeedback();
  108400. this._engine.setRasterizerState(true);
  108401. this._engine.bindTransformFeedbackBuffer(null);
  108402. if (!preWarm) {
  108403. // Enable render effect
  108404. this._engine.enableEffect(this._renderEffect);
  108405. var viewMatrix = this._scene.getViewMatrix();
  108406. this._renderEffect.setMatrix("view", viewMatrix);
  108407. this._renderEffect.setMatrix("projection", this._scene.getProjectionMatrix());
  108408. this._renderEffect.setTexture("textureSampler", this.particleTexture);
  108409. this._renderEffect.setVector2("translationPivot", this.translationPivot);
  108410. this._renderEffect.setVector3("worldOffset", this.worldOffset);
  108411. if (this._colorGradientsTexture) {
  108412. this._renderEffect.setTexture("colorGradientSampler", this._colorGradientsTexture);
  108413. }
  108414. else {
  108415. this._renderEffect.setDirectColor4("colorDead", this.colorDead);
  108416. }
  108417. if (this._isAnimationSheetEnabled && this.particleTexture) {
  108418. var baseSize = this.particleTexture.getBaseSize();
  108419. this._renderEffect.setFloat3("sheetInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  108420. }
  108421. if (this._isBillboardBased) {
  108422. var camera = this._scene.activeCamera;
  108423. this._renderEffect.setVector3("eyePosition", camera.globalPosition);
  108424. }
  108425. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  108426. var invView = viewMatrix.clone();
  108427. invView.invert();
  108428. this._renderEffect.setMatrix("invView", invView);
  108429. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindClipPlane(this._renderEffect, this._scene);
  108430. }
  108431. // image processing
  108432. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  108433. this._imageProcessingConfiguration.bind(this._renderEffect);
  108434. }
  108435. // Draw order
  108436. switch (this.blendMode) {
  108437. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ADD:
  108438. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ADD);
  108439. break;
  108440. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ONEONE:
  108441. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ONEONE);
  108442. break;
  108443. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_STANDARD:
  108444. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_COMBINE);
  108445. break;
  108446. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY:
  108447. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_MULTIPLY);
  108448. break;
  108449. }
  108450. if (this.forceDepthWrite) {
  108451. this._engine.setDepthWrite(true);
  108452. }
  108453. // Bind source VAO
  108454. this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex], null);
  108455. // Render
  108456. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].TriangleFanDrawMode, 0, 4, this._currentActiveCount);
  108457. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_DISABLE);
  108458. }
  108459. // Switch VAOs
  108460. this._targetIndex++;
  108461. if (this._targetIndex === 2) {
  108462. this._targetIndex = 0;
  108463. }
  108464. // Switch buffers
  108465. var tmpBuffer = this._sourceBuffer;
  108466. this._sourceBuffer = this._targetBuffer;
  108467. this._targetBuffer = tmpBuffer;
  108468. return this._currentActiveCount;
  108469. };
  108470. /**
  108471. * Rebuilds the particle system
  108472. */
  108473. GPUParticleSystem.prototype.rebuild = function () {
  108474. this._initialize(true);
  108475. };
  108476. GPUParticleSystem.prototype._releaseBuffers = function () {
  108477. if (this._buffer0) {
  108478. this._buffer0.dispose();
  108479. this._buffer0 = null;
  108480. }
  108481. if (this._buffer1) {
  108482. this._buffer1.dispose();
  108483. this._buffer1 = null;
  108484. }
  108485. if (this._spriteBuffer) {
  108486. this._spriteBuffer.dispose();
  108487. this._spriteBuffer = null;
  108488. }
  108489. };
  108490. GPUParticleSystem.prototype._releaseVAOs = function () {
  108491. if (!this._updateVAO) {
  108492. return;
  108493. }
  108494. for (var index = 0; index < this._updateVAO.length; index++) {
  108495. this._engine.releaseVertexArrayObject(this._updateVAO[index]);
  108496. }
  108497. this._updateVAO = [];
  108498. for (var index = 0; index < this._renderVAO.length; index++) {
  108499. this._engine.releaseVertexArrayObject(this._renderVAO[index]);
  108500. }
  108501. this._renderVAO = [];
  108502. };
  108503. /**
  108504. * Disposes the particle system and free the associated resources
  108505. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  108506. */
  108507. GPUParticleSystem.prototype.dispose = function (disposeTexture) {
  108508. if (disposeTexture === void 0) { disposeTexture = true; }
  108509. var index = this._scene.particleSystems.indexOf(this);
  108510. if (index > -1) {
  108511. this._scene.particleSystems.splice(index, 1);
  108512. }
  108513. this._releaseBuffers();
  108514. this._releaseVAOs();
  108515. if (this._colorGradientsTexture) {
  108516. this._colorGradientsTexture.dispose();
  108517. this._colorGradientsTexture = null;
  108518. }
  108519. if (this._sizeGradientsTexture) {
  108520. this._sizeGradientsTexture.dispose();
  108521. this._sizeGradientsTexture = null;
  108522. }
  108523. if (this._angularSpeedGradientsTexture) {
  108524. this._angularSpeedGradientsTexture.dispose();
  108525. this._angularSpeedGradientsTexture = null;
  108526. }
  108527. if (this._velocityGradientsTexture) {
  108528. this._velocityGradientsTexture.dispose();
  108529. this._velocityGradientsTexture = null;
  108530. }
  108531. if (this._limitVelocityGradientsTexture) {
  108532. this._limitVelocityGradientsTexture.dispose();
  108533. this._limitVelocityGradientsTexture = null;
  108534. }
  108535. if (this._dragGradientsTexture) {
  108536. this._dragGradientsTexture.dispose();
  108537. this._dragGradientsTexture = null;
  108538. }
  108539. if (this._randomTexture) {
  108540. this._randomTexture.dispose();
  108541. this._randomTexture = null;
  108542. }
  108543. if (this._randomTexture2) {
  108544. this._randomTexture2.dispose();
  108545. this._randomTexture2 = null;
  108546. }
  108547. if (disposeTexture && this.particleTexture) {
  108548. this.particleTexture.dispose();
  108549. this.particleTexture = null;
  108550. }
  108551. if (disposeTexture && this.noiseTexture) {
  108552. this.noiseTexture.dispose();
  108553. this.noiseTexture = null;
  108554. }
  108555. // Callback
  108556. this.onDisposeObservable.notifyObservers(this);
  108557. this.onDisposeObservable.clear();
  108558. };
  108559. /**
  108560. * Clones the particle system.
  108561. * @param name The name of the cloned object
  108562. * @param newEmitter The new emitter to use
  108563. * @returns the cloned particle system
  108564. */
  108565. GPUParticleSystem.prototype.clone = function (name, newEmitter) {
  108566. var result = new GPUParticleSystem(name, { capacity: this._capacity, randomTextureSize: this._randomTextureSize }, this._scene);
  108567. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__["DeepCopier"].DeepCopy(this, result);
  108568. if (newEmitter === undefined) {
  108569. newEmitter = this.emitter;
  108570. }
  108571. result.emitter = newEmitter;
  108572. if (this.particleTexture) {
  108573. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"](this.particleTexture.url, this._scene);
  108574. }
  108575. return result;
  108576. };
  108577. /**
  108578. * Serializes the particle system to a JSON object.
  108579. * @returns the JSON object
  108580. */
  108581. GPUParticleSystem.prototype.serialize = function () {
  108582. var serializationObject = {};
  108583. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Serialize(serializationObject, this);
  108584. serializationObject.activeParticleCount = this.activeParticleCount;
  108585. return serializationObject;
  108586. };
  108587. /**
  108588. * Parses a JSON object to create a GPU particle system.
  108589. * @param parsedParticleSystem The JSON object to parse
  108590. * @param scene The scene to create the particle system in
  108591. * @param rootUrl The root url to use to load external dependencies like texture
  108592. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  108593. * @returns the parsed GPU particle system
  108594. */
  108595. GPUParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  108596. if (doNotStart === void 0) { doNotStart = false; }
  108597. var name = parsedParticleSystem.name;
  108598. var particleSystem = new GPUParticleSystem(name, { capacity: parsedParticleSystem.capacity, randomTextureSize: parsedParticleSystem.randomTextureSize }, scene);
  108599. if (parsedParticleSystem.activeParticleCount) {
  108600. particleSystem.activeParticleCount = parsedParticleSystem.activeParticleCount;
  108601. }
  108602. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  108603. // Auto start
  108604. if (parsedParticleSystem.preventAutoStart) {
  108605. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  108606. }
  108607. if (!doNotStart && !particleSystem.preventAutoStart) {
  108608. particleSystem.start();
  108609. }
  108610. return particleSystem;
  108611. };
  108612. return GPUParticleSystem;
  108613. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__["BaseParticleSystem"]));
  108614. /***/ }),
  108615. /***/ "./Particles/index.ts":
  108616. /*!****************************!*\
  108617. !*** ./Particles/index.ts ***!
  108618. \****************************/
  108619. /*! exports provided: BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  108620. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108621. "use strict";
  108622. __webpack_require__.r(__webpack_exports__);
  108623. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  108624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  108625. /* harmony import */ var _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  108626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["BoxParticleEmitter"]; });
  108627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  108628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderParticleEmitter"]; });
  108629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderDirectedParticleEmitter"]; });
  108630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["HemisphericParticleEmitter"]; });
  108631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["PointParticleEmitter"]; });
  108632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereParticleEmitter"]; });
  108633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereDirectedParticleEmitter"]; });
  108634. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  108635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__["GPUParticleSystem"]; });
  108636. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  108637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _particle__WEBPACK_IMPORTED_MODULE_3__["Particle"]; });
  108638. /* harmony import */ var _particleHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleHelper */ "./Particles/particleHelper.ts");
  108639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _particleHelper__WEBPACK_IMPORTED_MODULE_4__["ParticleHelper"]; });
  108640. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  108641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _particleSystem__WEBPACK_IMPORTED_MODULE_5__["ParticleSystem"]; });
  108642. /* harmony import */ var _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystemComponent */ "./Particles/particleSystemComponent.ts");
  108643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__["_IDoNeedToBeInTheBuild"]; });
  108644. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  108645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__["ParticleSystemSet"]; });
  108646. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  108647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["SolidParticle"]; });
  108648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["ModelShape"]; });
  108649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["DepthSortedParticle"]; });
  108650. /* harmony import */ var _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./solidParticleSystem */ "./Particles/solidParticleSystem.ts");
  108651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__["SolidParticleSystem"]; });
  108652. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  108653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitterType"]; });
  108654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitter"]; });
  108655. /***/ }),
  108656. /***/ "./Particles/particle.ts":
  108657. /*!*******************************!*\
  108658. !*** ./Particles/particle.ts ***!
  108659. \*******************************/
  108660. /*! exports provided: Particle */
  108661. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108662. "use strict";
  108663. __webpack_require__.r(__webpack_exports__);
  108664. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return Particle; });
  108665. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  108666. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  108667. /**
  108668. * A particle represents one of the element emitted by a particle system.
  108669. * This is mainly define by its coordinates, direction, velocity and age.
  108670. */
  108671. var Particle = /** @class */ (function () {
  108672. /**
  108673. * Creates a new instance Particle
  108674. * @param particleSystem the particle system the particle belongs to
  108675. */
  108676. function Particle(
  108677. /**
  108678. * The particle system the particle belongs to.
  108679. */
  108680. particleSystem) {
  108681. this.particleSystem = particleSystem;
  108682. /**
  108683. * The world position of the particle in the scene.
  108684. */
  108685. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  108686. /**
  108687. * The world direction of the particle in the scene.
  108688. */
  108689. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  108690. /**
  108691. * The color of the particle.
  108692. */
  108693. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  108694. /**
  108695. * The color change of the particle per step.
  108696. */
  108697. this.colorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  108698. /**
  108699. * Defines how long will the life of the particle be.
  108700. */
  108701. this.lifeTime = 1.0;
  108702. /**
  108703. * The current age of the particle.
  108704. */
  108705. this.age = 0;
  108706. /**
  108707. * The current size of the particle.
  108708. */
  108709. this.size = 0;
  108710. /**
  108711. * The current scale of the particle.
  108712. */
  108713. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](1, 1);
  108714. /**
  108715. * The current angle of the particle.
  108716. */
  108717. this.angle = 0;
  108718. /**
  108719. * Defines how fast is the angle changing.
  108720. */
  108721. this.angularSpeed = 0;
  108722. /**
  108723. * Defines the cell index used by the particle to be rendered from a sprite.
  108724. */
  108725. this.cellIndex = 0;
  108726. /** @hidden */
  108727. this._attachedSubEmitters = null;
  108728. /** @hidden */
  108729. this._currentColor1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  108730. /** @hidden */
  108731. this._currentColor2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  108732. /** @hidden */
  108733. this._currentSize1 = 0;
  108734. /** @hidden */
  108735. this._currentSize2 = 0;
  108736. /** @hidden */
  108737. this._currentAngularSpeed1 = 0;
  108738. /** @hidden */
  108739. this._currentAngularSpeed2 = 0;
  108740. /** @hidden */
  108741. this._currentVelocity1 = 0;
  108742. /** @hidden */
  108743. this._currentVelocity2 = 0;
  108744. /** @hidden */
  108745. this._currentLimitVelocity1 = 0;
  108746. /** @hidden */
  108747. this._currentLimitVelocity2 = 0;
  108748. /** @hidden */
  108749. this._currentDrag1 = 0;
  108750. /** @hidden */
  108751. this._currentDrag2 = 0;
  108752. this.id = Particle._Count++;
  108753. if (!this.particleSystem.isAnimationSheetEnabled) {
  108754. return;
  108755. }
  108756. this.updateCellInfoFromSystem();
  108757. }
  108758. Particle.prototype.updateCellInfoFromSystem = function () {
  108759. this.cellIndex = this.particleSystem.startSpriteCellID;
  108760. };
  108761. /**
  108762. * Defines how the sprite cell index is updated for the particle
  108763. */
  108764. Particle.prototype.updateCellIndex = function () {
  108765. var offsetAge = this.age;
  108766. var changeSpeed = this.particleSystem.spriteCellChangeSpeed;
  108767. if (this.particleSystem.spriteRandomStartCell) {
  108768. if (this._randomCellOffset === undefined) {
  108769. this._randomCellOffset = Math.random() * this.lifeTime;
  108770. }
  108771. if (changeSpeed === 0) { // Special case when speed = 0 meaning we want to stay on initial cell
  108772. changeSpeed = 1;
  108773. offsetAge = this._randomCellOffset;
  108774. }
  108775. else {
  108776. offsetAge += this._randomCellOffset;
  108777. }
  108778. }
  108779. var dist = (this._initialEndSpriteCellID - this._initialStartSpriteCellID);
  108780. var ratio = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(((offsetAge * changeSpeed) % this.lifeTime) / this.lifeTime);
  108781. this.cellIndex = this._initialStartSpriteCellID + (ratio * dist) | 0;
  108782. };
  108783. /** @hidden */
  108784. Particle.prototype._inheritParticleInfoToSubEmitter = function (subEmitter) {
  108785. if (subEmitter.particleSystem.emitter.position) {
  108786. var emitterMesh = subEmitter.particleSystem.emitter;
  108787. emitterMesh.position.copyFrom(this.position);
  108788. if (subEmitter.inheritDirection) {
  108789. emitterMesh.position.subtractToRef(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  108790. // Look at using Y as forward
  108791. emitterMesh.lookAt(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0], 0, Math.PI / 2);
  108792. }
  108793. }
  108794. else {
  108795. var emitterPosition = subEmitter.particleSystem.emitter;
  108796. emitterPosition.copyFrom(this.position);
  108797. }
  108798. // Set inheritedVelocityOffset to be used when new particles are created
  108799. this.direction.scaleToRef(subEmitter.inheritedVelocityAmount / 2, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  108800. subEmitter.particleSystem._inheritedVelocityOffset.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  108801. };
  108802. /** @hidden */
  108803. Particle.prototype._inheritParticleInfoToSubEmitters = function () {
  108804. var _this = this;
  108805. if (this._attachedSubEmitters && this._attachedSubEmitters.length > 0) {
  108806. this._attachedSubEmitters.forEach(function (subEmitter) {
  108807. _this._inheritParticleInfoToSubEmitter(subEmitter);
  108808. });
  108809. }
  108810. };
  108811. /** @hidden */
  108812. Particle.prototype._reset = function () {
  108813. this.age = 0;
  108814. this._currentColorGradient = null;
  108815. this._currentSizeGradient = null;
  108816. this._currentAngularSpeedGradient = null;
  108817. this._currentVelocityGradient = null;
  108818. this._currentLimitVelocityGradient = null;
  108819. this._currentDragGradient = null;
  108820. this.cellIndex = this.particleSystem.startSpriteCellID;
  108821. this._randomCellOffset = undefined;
  108822. };
  108823. /**
  108824. * Copy the properties of particle to another one.
  108825. * @param other the particle to copy the information to.
  108826. */
  108827. Particle.prototype.copyTo = function (other) {
  108828. other.position.copyFrom(this.position);
  108829. if (this._initialDirection) {
  108830. if (other._initialDirection) {
  108831. other._initialDirection.copyFrom(this._initialDirection);
  108832. }
  108833. else {
  108834. other._initialDirection = this._initialDirection.clone();
  108835. }
  108836. }
  108837. else {
  108838. other._initialDirection = null;
  108839. }
  108840. other.direction.copyFrom(this.direction);
  108841. other.color.copyFrom(this.color);
  108842. other.colorStep.copyFrom(this.colorStep);
  108843. other.lifeTime = this.lifeTime;
  108844. other.age = this.age;
  108845. other._randomCellOffset = this._randomCellOffset;
  108846. other.size = this.size;
  108847. other.scale.copyFrom(this.scale);
  108848. other.angle = this.angle;
  108849. other.angularSpeed = this.angularSpeed;
  108850. other.particleSystem = this.particleSystem;
  108851. other.cellIndex = this.cellIndex;
  108852. other.id = this.id;
  108853. other._attachedSubEmitters = this._attachedSubEmitters;
  108854. if (this._currentColorGradient) {
  108855. other._currentColorGradient = this._currentColorGradient;
  108856. other._currentColor1.copyFrom(this._currentColor1);
  108857. other._currentColor2.copyFrom(this._currentColor2);
  108858. }
  108859. if (this._currentSizeGradient) {
  108860. other._currentSizeGradient = this._currentSizeGradient;
  108861. other._currentSize1 = this._currentSize1;
  108862. other._currentSize2 = this._currentSize2;
  108863. }
  108864. if (this._currentAngularSpeedGradient) {
  108865. other._currentAngularSpeedGradient = this._currentAngularSpeedGradient;
  108866. other._currentAngularSpeed1 = this._currentAngularSpeed1;
  108867. other._currentAngularSpeed2 = this._currentAngularSpeed2;
  108868. }
  108869. if (this._currentVelocityGradient) {
  108870. other._currentVelocityGradient = this._currentVelocityGradient;
  108871. other._currentVelocity1 = this._currentVelocity1;
  108872. other._currentVelocity2 = this._currentVelocity2;
  108873. }
  108874. if (this._currentLimitVelocityGradient) {
  108875. other._currentLimitVelocityGradient = this._currentLimitVelocityGradient;
  108876. other._currentLimitVelocity1 = this._currentLimitVelocity1;
  108877. other._currentLimitVelocity2 = this._currentLimitVelocity2;
  108878. }
  108879. if (this._currentDragGradient) {
  108880. other._currentDragGradient = this._currentDragGradient;
  108881. other._currentDrag1 = this._currentDrag1;
  108882. other._currentDrag2 = this._currentDrag2;
  108883. }
  108884. if (this.particleSystem.isAnimationSheetEnabled) {
  108885. other._initialStartSpriteCellID = this._initialStartSpriteCellID;
  108886. other._initialEndSpriteCellID = this._initialEndSpriteCellID;
  108887. }
  108888. if (this.particleSystem.useRampGradients) {
  108889. other.remapData.copyFrom(this.remapData);
  108890. }
  108891. if (this._randomNoiseCoordinates1) {
  108892. if (other._randomNoiseCoordinates1) {
  108893. other._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1);
  108894. other._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2);
  108895. }
  108896. else {
  108897. other._randomNoiseCoordinates1 = this._randomNoiseCoordinates1.clone();
  108898. other._randomNoiseCoordinates2 = this._randomNoiseCoordinates2.clone();
  108899. }
  108900. }
  108901. };
  108902. Particle._Count = 0;
  108903. return Particle;
  108904. }());
  108905. /***/ }),
  108906. /***/ "./Particles/particleHelper.ts":
  108907. /*!*************************************!*\
  108908. !*** ./Particles/particleHelper.ts ***!
  108909. \*************************************/
  108910. /*! exports provided: ParticleHelper */
  108911. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108912. "use strict";
  108913. __webpack_require__.r(__webpack_exports__);
  108914. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return ParticleHelper; });
  108915. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  108916. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  108917. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  108918. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  108919. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  108920. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  108921. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  108922. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  108923. /**
  108924. * This class is made for on one-liner static method to help creating particle system set.
  108925. */
  108926. var ParticleHelper = /** @class */ (function () {
  108927. function ParticleHelper() {
  108928. }
  108929. /**
  108930. * Create a default particle system that you can tweak
  108931. * @param emitter defines the emitter to use
  108932. * @param capacity defines the system capacity (default is 500 particles)
  108933. * @param scene defines the hosting scene
  108934. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  108935. * @returns the new Particle system
  108936. */
  108937. ParticleHelper.CreateDefault = function (emitter, capacity, scene, useGPU) {
  108938. if (capacity === void 0) { capacity = 500; }
  108939. if (useGPU === void 0) { useGPU = false; }
  108940. var system;
  108941. if (useGPU) {
  108942. system = new _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"]("default system", { capacity: capacity }, scene);
  108943. }
  108944. else {
  108945. system = new _particleSystem__WEBPACK_IMPORTED_MODULE_6__["ParticleSystem"]("default system", capacity, scene);
  108946. }
  108947. system.emitter = emitter;
  108948. system.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]("https://www.babylonjs.com/assets/Flare.png", system.getScene());
  108949. system.createConeEmitter(0.1, Math.PI / 4);
  108950. // Particle color
  108951. system.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  108952. system.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  108953. system.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 0.0);
  108954. // Particle Size
  108955. system.minSize = 0.1;
  108956. system.maxSize = 0.1;
  108957. // Emission speed
  108958. system.minEmitPower = 2;
  108959. system.maxEmitPower = 2;
  108960. // Update speed
  108961. system.updateSpeed = 1 / 60;
  108962. system.emitRate = 30;
  108963. return system;
  108964. };
  108965. /**
  108966. * This is the main static method (one-liner) of this helper to create different particle systems
  108967. * @param type This string represents the type to the particle system to create
  108968. * @param scene The scene where the particle system should live
  108969. * @param gpu If the system will use gpu
  108970. * @returns the ParticleSystemSet created
  108971. */
  108972. ParticleHelper.CreateAsync = function (type, scene, gpu) {
  108973. if (gpu === void 0) { gpu = false; }
  108974. if (!scene) {
  108975. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  108976. }
  108977. var token = {};
  108978. scene._addPendingData(token);
  108979. return new Promise(function (resolve, reject) {
  108980. if (gpu && !_gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"].IsSupported) {
  108981. scene._removePendingData(token);
  108982. return reject("Particle system with GPU is not supported.");
  108983. }
  108984. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(ParticleHelper.BaseAssetsUrl + "/systems/" + type + ".json", function (data) {
  108985. scene._removePendingData(token);
  108986. var newData = JSON.parse(data.toString());
  108987. return resolve(_particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"].Parse(newData, scene, gpu));
  108988. }, undefined, undefined, undefined, function () {
  108989. scene._removePendingData(token);
  108990. return reject("An error occured while the creation of your particle system. Check if your type '" + type + "' exists.");
  108991. });
  108992. });
  108993. };
  108994. /**
  108995. * Static function used to export a particle system to a ParticleSystemSet variable.
  108996. * Please note that the emitter shape is not exported
  108997. * @param systems defines the particle systems to export
  108998. * @returns the created particle system set
  108999. */
  109000. ParticleHelper.ExportSet = function (systems) {
  109001. var set = new _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"]();
  109002. for (var _i = 0, systems_1 = systems; _i < systems_1.length; _i++) {
  109003. var system = systems_1[_i];
  109004. set.systems.push(system);
  109005. }
  109006. return set;
  109007. };
  109008. /**
  109009. * Gets or sets base Assets URL
  109010. */
  109011. ParticleHelper.BaseAssetsUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].PARTICLES_BaseAssetsUrl;
  109012. return ParticleHelper;
  109013. }());
  109014. /***/ }),
  109015. /***/ "./Particles/particleSystem.ts":
  109016. /*!*************************************!*\
  109017. !*** ./Particles/particleSystem.ts ***!
  109018. \*************************************/
  109019. /*! exports provided: ParticleSystem */
  109020. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109021. "use strict";
  109022. __webpack_require__.r(__webpack_exports__);
  109023. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return ParticleSystem; });
  109024. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  109025. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  109026. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  109027. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  109028. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  109029. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  109030. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  109031. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  109032. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  109033. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  109034. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  109035. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  109036. /* harmony import */ var _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/Textures/Procedurals/proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  109037. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  109038. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  109039. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  109040. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  109041. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  109042. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  109043. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  109044. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  109045. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  109046. /* harmony import */ var _Shaders_particles_fragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Shaders/particles.fragment */ "./Shaders/particles.fragment.ts");
  109047. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  109048. /**
  109049. * This represents a particle system in Babylon.
  109050. * 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.
  109051. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  109052. * @example https://doc.babylonjs.com/babylon101/particles
  109053. */
  109054. var ParticleSystem = /** @class */ (function (_super) {
  109055. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticleSystem, _super);
  109056. /**
  109057. * Instantiates a particle system.
  109058. * 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.
  109059. * @param name The name of the particle system
  109060. * @param capacity The max number of particles alive at the same time
  109061. * @param scene The scene the particle system belongs to
  109062. * @param customEffect a custom effect used to change the way particles are rendered by default
  109063. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  109064. * @param epsilon Offset used to render the particles
  109065. */
  109066. function ParticleSystem(name, capacity, scene, customEffect, isAnimationSheetEnabled, epsilon) {
  109067. if (customEffect === void 0) { customEffect = null; }
  109068. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  109069. if (epsilon === void 0) { epsilon = 0.01; }
  109070. var _this = _super.call(this, name) || this;
  109071. /**
  109072. * @hidden
  109073. */
  109074. _this._inheritedVelocityOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  109075. /**
  109076. * An event triggered when the system is disposed
  109077. */
  109078. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  109079. _this._particles = new Array();
  109080. _this._stockParticles = new Array();
  109081. _this._newPartsExcess = 0;
  109082. _this._vertexBuffers = {};
  109083. _this._scaledColorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  109084. _this._colorDiff = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  109085. _this._scaledDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  109086. _this._scaledGravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  109087. _this._currentRenderId = -1;
  109088. _this._useInstancing = false;
  109089. _this._started = false;
  109090. _this._stopped = false;
  109091. _this._actualFrame = 0;
  109092. /** @hidden */
  109093. _this._currentEmitRate1 = 0;
  109094. /** @hidden */
  109095. _this._currentEmitRate2 = 0;
  109096. /** @hidden */
  109097. _this._currentStartSize1 = 0;
  109098. /** @hidden */
  109099. _this._currentStartSize2 = 0;
  109100. _this._rawTextureWidth = 256;
  109101. _this._useRampGradients = false;
  109102. /**
  109103. * @hidden
  109104. * If the particle systems emitter should be disposed when the particle system is disposed
  109105. */
  109106. _this._disposeEmitterOnDispose = false;
  109107. // start of sub system methods
  109108. /**
  109109. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  109110. * Its lifetime will start back at 0.
  109111. */
  109112. _this.recycleParticle = function (particle) {
  109113. // move particle from activeParticle list to stock particles
  109114. var lastParticle = _this._particles.pop();
  109115. if (lastParticle !== particle) {
  109116. lastParticle.copyTo(particle);
  109117. }
  109118. _this._stockParticles.push(lastParticle);
  109119. };
  109120. _this._createParticle = function () {
  109121. var particle;
  109122. if (_this._stockParticles.length !== 0) {
  109123. particle = _this._stockParticles.pop();
  109124. particle._reset();
  109125. }
  109126. else {
  109127. particle = new _particle__WEBPACK_IMPORTED_MODULE_16__["Particle"](_this);
  109128. }
  109129. // Attach emitters
  109130. if (_this._subEmitters && _this._subEmitters.length > 0) {
  109131. var subEmitters = _this._subEmitters[Math.floor(Math.random() * _this._subEmitters.length)];
  109132. particle._attachedSubEmitters = [];
  109133. subEmitters.forEach(function (subEmitter) {
  109134. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].ATTACHED) {
  109135. var newEmitter = subEmitter.clone();
  109136. particle._attachedSubEmitters.push(newEmitter);
  109137. newEmitter.particleSystem.start();
  109138. }
  109139. });
  109140. }
  109141. return particle;
  109142. };
  109143. _this._emitFromParticle = function (particle) {
  109144. if (!_this._subEmitters || _this._subEmitters.length === 0) {
  109145. return;
  109146. }
  109147. var templateIndex = Math.floor(Math.random() * _this._subEmitters.length);
  109148. _this._subEmitters[templateIndex].forEach(function (subEmitter) {
  109149. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].END) {
  109150. var subSystem = subEmitter.clone();
  109151. particle._inheritParticleInfoToSubEmitter(subSystem);
  109152. subSystem.particleSystem._rootParticleSystem = _this;
  109153. _this.activeSubSystems.push(subSystem.particleSystem);
  109154. subSystem.particleSystem.start();
  109155. }
  109156. });
  109157. };
  109158. _this._capacity = capacity;
  109159. _this._epsilon = epsilon;
  109160. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  109161. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__["EngineStore"].LastCreatedScene;
  109162. // Setup the default processing configuration to the scene.
  109163. _this._attachImageProcessingConfiguration(null);
  109164. _this._customEffect = customEffect;
  109165. _this._scene.particleSystems.push(_this);
  109166. _this._useInstancing = _this._scene.getEngine().getCaps().instancedArrays;
  109167. _this._createIndexBuffer();
  109168. _this._createVertexBuffers();
  109169. // Default emitter type
  109170. _this.particleEmitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  109171. // Update
  109172. _this.updateFunction = function (particles) {
  109173. var noiseTextureSize = null;
  109174. var noiseTextureData = null;
  109175. if (_this.noiseTexture) { // We need to get texture data back to CPU
  109176. noiseTextureSize = _this.noiseTexture.getSize();
  109177. noiseTextureData = (_this.noiseTexture.getContent());
  109178. }
  109179. var _loop_1 = function () {
  109180. particle = particles[index];
  109181. var scaledUpdateSpeed = _this._scaledUpdateSpeed;
  109182. var previousAge = particle.age;
  109183. particle.age += scaledUpdateSpeed;
  109184. // Evaluate step to death
  109185. if (particle.age > particle.lifeTime) {
  109186. var diff = particle.age - previousAge;
  109187. var oldDiff = particle.lifeTime - previousAge;
  109188. scaledUpdateSpeed = (oldDiff * scaledUpdateSpeed) / diff;
  109189. particle.age = particle.lifeTime;
  109190. }
  109191. var ratio = particle.age / particle.lifeTime;
  109192. // Color
  109193. if (_this._colorGradients && _this._colorGradients.length > 0) {
  109194. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorGradients, function (currentGradient, nextGradient, scale) {
  109195. if (currentGradient !== particle._currentColorGradient) {
  109196. particle._currentColor1.copyFrom(particle._currentColor2);
  109197. nextGradient.getColorToRef(particle._currentColor2);
  109198. particle._currentColorGradient = currentGradient;
  109199. }
  109200. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(particle._currentColor1, particle._currentColor2, scale, particle.color);
  109201. });
  109202. }
  109203. else {
  109204. particle.colorStep.scaleToRef(scaledUpdateSpeed, _this._scaledColorStep);
  109205. particle.color.addInPlace(_this._scaledColorStep);
  109206. if (particle.color.a < 0) {
  109207. particle.color.a = 0;
  109208. }
  109209. }
  109210. // Angular speed
  109211. if (_this._angularSpeedGradients && _this._angularSpeedGradients.length > 0) {
  109212. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._angularSpeedGradients, function (currentGradient, nextGradient, scale) {
  109213. if (currentGradient !== particle._currentAngularSpeedGradient) {
  109214. particle._currentAngularSpeed1 = particle._currentAngularSpeed2;
  109215. particle._currentAngularSpeed2 = nextGradient.getFactor();
  109216. particle._currentAngularSpeedGradient = currentGradient;
  109217. }
  109218. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentAngularSpeed1, particle._currentAngularSpeed2, scale);
  109219. });
  109220. }
  109221. particle.angle += particle.angularSpeed * scaledUpdateSpeed;
  109222. // Direction
  109223. var directionScale = scaledUpdateSpeed;
  109224. /// Velocity
  109225. if (_this._velocityGradients && _this._velocityGradients.length > 0) {
  109226. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._velocityGradients, function (currentGradient, nextGradient, scale) {
  109227. if (currentGradient !== particle._currentVelocityGradient) {
  109228. particle._currentVelocity1 = particle._currentVelocity2;
  109229. particle._currentVelocity2 = nextGradient.getFactor();
  109230. particle._currentVelocityGradient = currentGradient;
  109231. }
  109232. directionScale *= _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
  109233. });
  109234. }
  109235. particle.direction.scaleToRef(directionScale, _this._scaledDirection);
  109236. /// Limit velocity
  109237. if (_this._limitVelocityGradients && _this._limitVelocityGradients.length > 0) {
  109238. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._limitVelocityGradients, function (currentGradient, nextGradient, scale) {
  109239. if (currentGradient !== particle._currentLimitVelocityGradient) {
  109240. particle._currentLimitVelocity1 = particle._currentLimitVelocity2;
  109241. particle._currentLimitVelocity2 = nextGradient.getFactor();
  109242. particle._currentLimitVelocityGradient = currentGradient;
  109243. }
  109244. var limitVelocity = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
  109245. var currentVelocity = particle.direction.length();
  109246. if (currentVelocity > limitVelocity) {
  109247. particle.direction.scaleInPlace(_this.limitVelocityDamping);
  109248. }
  109249. });
  109250. }
  109251. /// Drag
  109252. if (_this._dragGradients && _this._dragGradients.length > 0) {
  109253. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._dragGradients, function (currentGradient, nextGradient, scale) {
  109254. if (currentGradient !== particle._currentDragGradient) {
  109255. particle._currentDrag1 = particle._currentDrag2;
  109256. particle._currentDrag2 = nextGradient.getFactor();
  109257. particle._currentDragGradient = currentGradient;
  109258. }
  109259. var drag = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentDrag1, particle._currentDrag2, scale);
  109260. _this._scaledDirection.scaleInPlace(1.0 - drag);
  109261. });
  109262. }
  109263. particle.position.addInPlace(_this._scaledDirection);
  109264. // Noise
  109265. if (noiseTextureData && noiseTextureSize && particle._randomNoiseCoordinates1) {
  109266. var fetchedColorR = _this._fetchR(particle._randomNoiseCoordinates1.x, particle._randomNoiseCoordinates1.y, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  109267. var fetchedColorG = _this._fetchR(particle._randomNoiseCoordinates1.z, particle._randomNoiseCoordinates2.x, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  109268. var fetchedColorB = _this._fetchR(particle._randomNoiseCoordinates2.y, particle._randomNoiseCoordinates2.z, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  109269. var force = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  109270. var scaledForce = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  109271. force.copyFromFloats((2 * fetchedColorR - 1) * _this.noiseStrength.x, (2 * fetchedColorG - 1) * _this.noiseStrength.y, (2 * fetchedColorB - 1) * _this.noiseStrength.z);
  109272. force.scaleToRef(scaledUpdateSpeed, scaledForce);
  109273. particle.direction.addInPlace(scaledForce);
  109274. }
  109275. // Gravity
  109276. _this.gravity.scaleToRef(scaledUpdateSpeed, _this._scaledGravity);
  109277. particle.direction.addInPlace(_this._scaledGravity);
  109278. // Size
  109279. if (_this._sizeGradients && _this._sizeGradients.length > 0) {
  109280. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._sizeGradients, function (currentGradient, nextGradient, scale) {
  109281. if (currentGradient !== particle._currentSizeGradient) {
  109282. particle._currentSize1 = particle._currentSize2;
  109283. particle._currentSize2 = nextGradient.getFactor();
  109284. particle._currentSizeGradient = currentGradient;
  109285. }
  109286. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentSize1, particle._currentSize2, scale);
  109287. });
  109288. }
  109289. // Remap data
  109290. if (_this._useRampGradients) {
  109291. if (_this._colorRemapGradients && _this._colorRemapGradients.length > 0) {
  109292. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorRemapGradients, function (currentGradient, nextGradient, scale) {
  109293. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  109294. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  109295. particle.remapData.x = min;
  109296. particle.remapData.y = max - min;
  109297. });
  109298. }
  109299. if (_this._alphaRemapGradients && _this._alphaRemapGradients.length > 0) {
  109300. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._alphaRemapGradients, function (currentGradient, nextGradient, scale) {
  109301. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  109302. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  109303. particle.remapData.z = min;
  109304. particle.remapData.w = max - min;
  109305. });
  109306. }
  109307. }
  109308. if (_this._isAnimationSheetEnabled) {
  109309. particle.updateCellIndex();
  109310. }
  109311. // Update the position of the attached sub-emitters to match their attached particle
  109312. particle._inheritParticleInfoToSubEmitters();
  109313. if (particle.age >= particle.lifeTime) { // Recycle by swapping with last particle
  109314. _this._emitFromParticle(particle);
  109315. if (particle._attachedSubEmitters) {
  109316. particle._attachedSubEmitters.forEach(function (subEmitter) {
  109317. subEmitter.particleSystem.disposeOnStop = true;
  109318. subEmitter.particleSystem.stop();
  109319. });
  109320. particle._attachedSubEmitters = null;
  109321. }
  109322. _this.recycleParticle(particle);
  109323. index--;
  109324. return "continue";
  109325. }
  109326. };
  109327. var particle;
  109328. for (var index = 0; index < particles.length; index++) {
  109329. _loop_1();
  109330. }
  109331. };
  109332. return _this;
  109333. }
  109334. Object.defineProperty(ParticleSystem.prototype, "onDispose", {
  109335. /**
  109336. * Sets a callback that will be triggered when the system is disposed
  109337. */
  109338. set: function (callback) {
  109339. if (this._onDisposeObserver) {
  109340. this.onDisposeObservable.remove(this._onDisposeObserver);
  109341. }
  109342. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  109343. },
  109344. enumerable: true,
  109345. configurable: true
  109346. });
  109347. Object.defineProperty(ParticleSystem.prototype, "useRampGradients", {
  109348. /** Gets or sets a boolean indicating that ramp gradients must be used
  109349. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  109350. */
  109351. get: function () {
  109352. return this._useRampGradients;
  109353. },
  109354. set: function (value) {
  109355. if (this._useRampGradients === value) {
  109356. return;
  109357. }
  109358. this._useRampGradients = value;
  109359. this._resetEffect();
  109360. },
  109361. enumerable: true,
  109362. configurable: true
  109363. });
  109364. Object.defineProperty(ParticleSystem.prototype, "particles", {
  109365. //end of Sub-emitter
  109366. /**
  109367. * Gets the current list of active particles
  109368. */
  109369. get: function () {
  109370. return this._particles;
  109371. },
  109372. enumerable: true,
  109373. configurable: true
  109374. });
  109375. /**
  109376. * Returns the string "ParticleSystem"
  109377. * @returns a string containing the class name
  109378. */
  109379. ParticleSystem.prototype.getClassName = function () {
  109380. return "ParticleSystem";
  109381. };
  109382. ParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor, factor2) {
  109383. var newGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  109384. newGradient.gradient = gradient;
  109385. newGradient.factor1 = factor;
  109386. newGradient.factor2 = factor2;
  109387. factorGradients.push(newGradient);
  109388. factorGradients.sort(function (a, b) {
  109389. if (a.gradient < b.gradient) {
  109390. return -1;
  109391. }
  109392. else if (a.gradient > b.gradient) {
  109393. return 1;
  109394. }
  109395. return 0;
  109396. });
  109397. };
  109398. ParticleSystem.prototype._removeFactorGradient = function (factorGradients, gradient) {
  109399. if (!factorGradients) {
  109400. return;
  109401. }
  109402. var index = 0;
  109403. for (var _i = 0, factorGradients_1 = factorGradients; _i < factorGradients_1.length; _i++) {
  109404. var factorGradient = factorGradients_1[_i];
  109405. if (factorGradient.gradient === gradient) {
  109406. factorGradients.splice(index, 1);
  109407. break;
  109408. }
  109409. index++;
  109410. }
  109411. };
  109412. /**
  109413. * Adds a new life time gradient
  109414. * @param gradient defines the gradient to use (between 0 and 1)
  109415. * @param factor defines the life time factor to affect to the specified gradient
  109416. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  109417. * @returns the current particle system
  109418. */
  109419. ParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  109420. if (!this._lifeTimeGradients) {
  109421. this._lifeTimeGradients = [];
  109422. }
  109423. this._addFactorGradient(this._lifeTimeGradients, gradient, factor, factor2);
  109424. return this;
  109425. };
  109426. /**
  109427. * Remove a specific life time gradient
  109428. * @param gradient defines the gradient to remove
  109429. * @returns the current particle system
  109430. */
  109431. ParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  109432. this._removeFactorGradient(this._lifeTimeGradients, gradient);
  109433. return this;
  109434. };
  109435. /**
  109436. * Adds a new size gradient
  109437. * @param gradient defines the gradient to use (between 0 and 1)
  109438. * @param factor defines the size factor to affect to the specified gradient
  109439. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  109440. * @returns the current particle system
  109441. */
  109442. ParticleSystem.prototype.addSizeGradient = function (gradient, factor, factor2) {
  109443. if (!this._sizeGradients) {
  109444. this._sizeGradients = [];
  109445. }
  109446. this._addFactorGradient(this._sizeGradients, gradient, factor, factor2);
  109447. return this;
  109448. };
  109449. /**
  109450. * Remove a specific size gradient
  109451. * @param gradient defines the gradient to remove
  109452. * @returns the current particle system
  109453. */
  109454. ParticleSystem.prototype.removeSizeGradient = function (gradient) {
  109455. this._removeFactorGradient(this._sizeGradients, gradient);
  109456. return this;
  109457. };
  109458. /**
  109459. * Adds a new color remap gradient
  109460. * @param gradient defines the gradient to use (between 0 and 1)
  109461. * @param min defines the color remap minimal range
  109462. * @param max defines the color remap maximal range
  109463. * @returns the current particle system
  109464. */
  109465. ParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  109466. if (!this._colorRemapGradients) {
  109467. this._colorRemapGradients = [];
  109468. }
  109469. this._addFactorGradient(this._colorRemapGradients, gradient, min, max);
  109470. return this;
  109471. };
  109472. /**
  109473. * Remove a specific color remap gradient
  109474. * @param gradient defines the gradient to remove
  109475. * @returns the current particle system
  109476. */
  109477. ParticleSystem.prototype.removeColorRemapGradient = function (gradient) {
  109478. this._removeFactorGradient(this._colorRemapGradients, gradient);
  109479. return this;
  109480. };
  109481. /**
  109482. * Adds a new alpha remap gradient
  109483. * @param gradient defines the gradient to use (between 0 and 1)
  109484. * @param min defines the alpha remap minimal range
  109485. * @param max defines the alpha remap maximal range
  109486. * @returns the current particle system
  109487. */
  109488. ParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  109489. if (!this._alphaRemapGradients) {
  109490. this._alphaRemapGradients = [];
  109491. }
  109492. this._addFactorGradient(this._alphaRemapGradients, gradient, min, max);
  109493. return this;
  109494. };
  109495. /**
  109496. * Remove a specific alpha remap gradient
  109497. * @param gradient defines the gradient to remove
  109498. * @returns the current particle system
  109499. */
  109500. ParticleSystem.prototype.removeAlphaRemapGradient = function (gradient) {
  109501. this._removeFactorGradient(this._alphaRemapGradients, gradient);
  109502. return this;
  109503. };
  109504. /**
  109505. * Adds a new angular speed gradient
  109506. * @param gradient defines the gradient to use (between 0 and 1)
  109507. * @param factor defines the angular speed to affect to the specified gradient
  109508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  109509. * @returns the current particle system
  109510. */
  109511. ParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor, factor2) {
  109512. if (!this._angularSpeedGradients) {
  109513. this._angularSpeedGradients = [];
  109514. }
  109515. this._addFactorGradient(this._angularSpeedGradients, gradient, factor, factor2);
  109516. return this;
  109517. };
  109518. /**
  109519. * Remove a specific angular speed gradient
  109520. * @param gradient defines the gradient to remove
  109521. * @returns the current particle system
  109522. */
  109523. ParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  109524. this._removeFactorGradient(this._angularSpeedGradients, gradient);
  109525. return this;
  109526. };
  109527. /**
  109528. * Adds a new velocity gradient
  109529. * @param gradient defines the gradient to use (between 0 and 1)
  109530. * @param factor defines the velocity to affect to the specified gradient
  109531. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  109532. * @returns the current particle system
  109533. */
  109534. ParticleSystem.prototype.addVelocityGradient = function (gradient, factor, factor2) {
  109535. if (!this._velocityGradients) {
  109536. this._velocityGradients = [];
  109537. }
  109538. this._addFactorGradient(this._velocityGradients, gradient, factor, factor2);
  109539. return this;
  109540. };
  109541. /**
  109542. * Remove a specific velocity gradient
  109543. * @param gradient defines the gradient to remove
  109544. * @returns the current particle system
  109545. */
  109546. ParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  109547. this._removeFactorGradient(this._velocityGradients, gradient);
  109548. return this;
  109549. };
  109550. /**
  109551. * Adds a new limit velocity gradient
  109552. * @param gradient defines the gradient to use (between 0 and 1)
  109553. * @param factor defines the limit velocity value to affect to the specified gradient
  109554. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  109555. * @returns the current particle system
  109556. */
  109557. ParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor, factor2) {
  109558. if (!this._limitVelocityGradients) {
  109559. this._limitVelocityGradients = [];
  109560. }
  109561. this._addFactorGradient(this._limitVelocityGradients, gradient, factor, factor2);
  109562. return this;
  109563. };
  109564. /**
  109565. * Remove a specific limit velocity gradient
  109566. * @param gradient defines the gradient to remove
  109567. * @returns the current particle system
  109568. */
  109569. ParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  109570. this._removeFactorGradient(this._limitVelocityGradients, gradient);
  109571. return this;
  109572. };
  109573. /**
  109574. * Adds a new drag gradient
  109575. * @param gradient defines the gradient to use (between 0 and 1)
  109576. * @param factor defines the drag value to affect to the specified gradient
  109577. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  109578. * @returns the current particle system
  109579. */
  109580. ParticleSystem.prototype.addDragGradient = function (gradient, factor, factor2) {
  109581. if (!this._dragGradients) {
  109582. this._dragGradients = [];
  109583. }
  109584. this._addFactorGradient(this._dragGradients, gradient, factor, factor2);
  109585. return this;
  109586. };
  109587. /**
  109588. * Remove a specific drag gradient
  109589. * @param gradient defines the gradient to remove
  109590. * @returns the current particle system
  109591. */
  109592. ParticleSystem.prototype.removeDragGradient = function (gradient) {
  109593. this._removeFactorGradient(this._dragGradients, gradient);
  109594. return this;
  109595. };
  109596. /**
  109597. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  109598. * @param gradient defines the gradient to use (between 0 and 1)
  109599. * @param factor defines the emit rate value to affect to the specified gradient
  109600. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  109601. * @returns the current particle system
  109602. */
  109603. ParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  109604. if (!this._emitRateGradients) {
  109605. this._emitRateGradients = [];
  109606. }
  109607. this._addFactorGradient(this._emitRateGradients, gradient, factor, factor2);
  109608. return this;
  109609. };
  109610. /**
  109611. * Remove a specific emit rate gradient
  109612. * @param gradient defines the gradient to remove
  109613. * @returns the current particle system
  109614. */
  109615. ParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  109616. this._removeFactorGradient(this._emitRateGradients, gradient);
  109617. return this;
  109618. };
  109619. /**
  109620. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  109621. * @param gradient defines the gradient to use (between 0 and 1)
  109622. * @param factor defines the start size value to affect to the specified gradient
  109623. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  109624. * @returns the current particle system
  109625. */
  109626. ParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  109627. if (!this._startSizeGradients) {
  109628. this._startSizeGradients = [];
  109629. }
  109630. this._addFactorGradient(this._startSizeGradients, gradient, factor, factor2);
  109631. return this;
  109632. };
  109633. /**
  109634. * Remove a specific start size gradient
  109635. * @param gradient defines the gradient to remove
  109636. * @returns the current particle system
  109637. */
  109638. ParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  109639. this._removeFactorGradient(this._emitRateGradients, gradient);
  109640. return this;
  109641. };
  109642. ParticleSystem.prototype._createRampGradientTexture = function () {
  109643. if (!this._rampGradients || !this._rampGradients.length || this._rampGradientsTexture) {
  109644. return;
  109645. }
  109646. var data = new Uint8Array(this._rawTextureWidth * 4);
  109647. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color3[0];
  109648. for (var x = 0; x < this._rawTextureWidth; x++) {
  109649. var ratio = x / this._rawTextureWidth;
  109650. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._rampGradients, function (currentGradient, nextGradient, scale) {
  109651. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].LerpToRef(currentGradient.color, nextGradient.color, scale, tmpColor);
  109652. data[x * 4] = tmpColor.r * 255;
  109653. data[x * 4 + 1] = tmpColor.g * 255;
  109654. data[x * 4 + 2] = tmpColor.b * 255;
  109655. data[x * 4 + 3] = 255;
  109656. });
  109657. }
  109658. 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);
  109659. };
  109660. /**
  109661. * Gets the current list of ramp gradients.
  109662. * You must use addRampGradient and removeRampGradient to udpate this list
  109663. * @returns the list of ramp gradients
  109664. */
  109665. ParticleSystem.prototype.getRampGradients = function () {
  109666. return this._rampGradients;
  109667. };
  109668. /**
  109669. * Adds a new ramp gradient used to remap particle colors
  109670. * @param gradient defines the gradient to use (between 0 and 1)
  109671. * @param color defines the color to affect to the specified gradient
  109672. * @returns the current particle system
  109673. */
  109674. ParticleSystem.prototype.addRampGradient = function (gradient, color) {
  109675. if (!this._rampGradients) {
  109676. this._rampGradients = [];
  109677. }
  109678. var rampGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Color3Gradient"]();
  109679. rampGradient.gradient = gradient;
  109680. rampGradient.color = color;
  109681. this._rampGradients.push(rampGradient);
  109682. this._rampGradients.sort(function (a, b) {
  109683. if (a.gradient < b.gradient) {
  109684. return -1;
  109685. }
  109686. else if (a.gradient > b.gradient) {
  109687. return 1;
  109688. }
  109689. return 0;
  109690. });
  109691. if (this._rampGradientsTexture) {
  109692. this._rampGradientsTexture.dispose();
  109693. this._rampGradientsTexture = null;
  109694. }
  109695. this._createRampGradientTexture();
  109696. return this;
  109697. };
  109698. /**
  109699. * Remove a specific ramp gradient
  109700. * @param gradient defines the gradient to remove
  109701. * @returns the current particle system
  109702. */
  109703. ParticleSystem.prototype.removeRampGradient = function (gradient) {
  109704. this._removeGradientAndTexture(gradient, this._rampGradients, this._rampGradientsTexture);
  109705. this._rampGradientsTexture = null;
  109706. if (this._rampGradients && this._rampGradients.length > 0) {
  109707. this._createRampGradientTexture();
  109708. }
  109709. return this;
  109710. };
  109711. /**
  109712. * Adds a new color gradient
  109713. * @param gradient defines the gradient to use (between 0 and 1)
  109714. * @param color1 defines the color to affect to the specified gradient
  109715. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  109716. * @returns this particle system
  109717. */
  109718. ParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  109719. if (!this._colorGradients) {
  109720. this._colorGradients = [];
  109721. }
  109722. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  109723. colorGradient.gradient = gradient;
  109724. colorGradient.color1 = color1;
  109725. colorGradient.color2 = color2;
  109726. this._colorGradients.push(colorGradient);
  109727. this._colorGradients.sort(function (a, b) {
  109728. if (a.gradient < b.gradient) {
  109729. return -1;
  109730. }
  109731. else if (a.gradient > b.gradient) {
  109732. return 1;
  109733. }
  109734. return 0;
  109735. });
  109736. return this;
  109737. };
  109738. /**
  109739. * Remove a specific color gradient
  109740. * @param gradient defines the gradient to remove
  109741. * @returns this particle system
  109742. */
  109743. ParticleSystem.prototype.removeColorGradient = function (gradient) {
  109744. if (!this._colorGradients) {
  109745. return this;
  109746. }
  109747. var index = 0;
  109748. for (var _i = 0, _a = this._colorGradients; _i < _a.length; _i++) {
  109749. var colorGradient = _a[_i];
  109750. if (colorGradient.gradient === gradient) {
  109751. this._colorGradients.splice(index, 1);
  109752. break;
  109753. }
  109754. index++;
  109755. }
  109756. return this;
  109757. };
  109758. ParticleSystem.prototype._fetchR = function (u, v, width, height, pixels) {
  109759. u = Math.abs(u) * 0.5 + 0.5;
  109760. v = Math.abs(v) * 0.5 + 0.5;
  109761. var wrappedU = ((u * width) % width) | 0;
  109762. var wrappedV = ((v * height) % height) | 0;
  109763. var position = (wrappedU + wrappedV * width) * 4;
  109764. return pixels[position] / 255;
  109765. };
  109766. ParticleSystem.prototype._reset = function () {
  109767. this._resetEffect();
  109768. };
  109769. ParticleSystem.prototype._resetEffect = function () {
  109770. if (this._vertexBuffer) {
  109771. this._vertexBuffer.dispose();
  109772. this._vertexBuffer = null;
  109773. }
  109774. if (this._spriteBuffer) {
  109775. this._spriteBuffer.dispose();
  109776. this._spriteBuffer = null;
  109777. }
  109778. this._createVertexBuffers();
  109779. };
  109780. ParticleSystem.prototype._createVertexBuffers = function () {
  109781. this._vertexBufferSize = this._useInstancing ? 10 : 12;
  109782. if (this._isAnimationSheetEnabled) {
  109783. this._vertexBufferSize += 1;
  109784. }
  109785. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  109786. this._vertexBufferSize += 3;
  109787. }
  109788. if (this._useRampGradients) {
  109789. this._vertexBufferSize += 4;
  109790. }
  109791. var engine = this._scene.getEngine();
  109792. this._vertexData = new Float32Array(this._capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4));
  109793. this._vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, this._vertexData, true, this._vertexBufferSize);
  109794. var dataOffset = 0;
  109795. var positions = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  109796. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind] = positions;
  109797. dataOffset += 3;
  109798. var colors = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  109799. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind] = colors;
  109800. dataOffset += 4;
  109801. var options = this._vertexBuffer.createVertexBuffer("angle", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  109802. this._vertexBuffers["angle"] = options;
  109803. dataOffset += 1;
  109804. var size = this._vertexBuffer.createVertexBuffer("size", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  109805. this._vertexBuffers["size"] = size;
  109806. dataOffset += 2;
  109807. if (this._isAnimationSheetEnabled) {
  109808. var cellIndexBuffer = this._vertexBuffer.createVertexBuffer("cellIndex", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  109809. this._vertexBuffers["cellIndex"] = cellIndexBuffer;
  109810. dataOffset += 1;
  109811. }
  109812. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  109813. var directionBuffer = this._vertexBuffer.createVertexBuffer("direction", dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  109814. this._vertexBuffers["direction"] = directionBuffer;
  109815. dataOffset += 3;
  109816. }
  109817. if (this._useRampGradients) {
  109818. var rampDataBuffer = this._vertexBuffer.createVertexBuffer("remapData", dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  109819. this._vertexBuffers["remapData"] = rampDataBuffer;
  109820. dataOffset += 4;
  109821. }
  109822. var offsets;
  109823. if (this._useInstancing) {
  109824. var spriteData = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
  109825. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 2);
  109826. offsets = this._spriteBuffer.createVertexBuffer("offset", 0, 2);
  109827. }
  109828. else {
  109829. offsets = this._vertexBuffer.createVertexBuffer("offset", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  109830. dataOffset += 2;
  109831. }
  109832. this._vertexBuffers["offset"] = offsets;
  109833. };
  109834. ParticleSystem.prototype._createIndexBuffer = function () {
  109835. if (this._useInstancing) {
  109836. return;
  109837. }
  109838. var indices = [];
  109839. var index = 0;
  109840. for (var count = 0; count < this._capacity; count++) {
  109841. indices.push(index);
  109842. indices.push(index + 1);
  109843. indices.push(index + 2);
  109844. indices.push(index);
  109845. indices.push(index + 2);
  109846. indices.push(index + 3);
  109847. index += 4;
  109848. }
  109849. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  109850. };
  109851. /**
  109852. * Gets the maximum number of particles active at the same time.
  109853. * @returns The max number of active particles.
  109854. */
  109855. ParticleSystem.prototype.getCapacity = function () {
  109856. return this._capacity;
  109857. };
  109858. /**
  109859. * Gets whether there are still active particles in the system.
  109860. * @returns True if it is alive, otherwise false.
  109861. */
  109862. ParticleSystem.prototype.isAlive = function () {
  109863. return this._alive;
  109864. };
  109865. /**
  109866. * Gets if the system has been started. (Note: this will still be true after stop is called)
  109867. * @returns True if it has been started, otherwise false.
  109868. */
  109869. ParticleSystem.prototype.isStarted = function () {
  109870. return this._started;
  109871. };
  109872. ParticleSystem.prototype._prepareSubEmitterInternalArray = function () {
  109873. var _this = this;
  109874. this._subEmitters = new Array();
  109875. if (this.subEmitters) {
  109876. this.subEmitters.forEach(function (subEmitter) {
  109877. if (subEmitter instanceof ParticleSystem) {
  109878. _this._subEmitters.push([new _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"](subEmitter)]);
  109879. }
  109880. else if (subEmitter instanceof _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]) {
  109881. _this._subEmitters.push([subEmitter]);
  109882. }
  109883. else if (subEmitter instanceof Array) {
  109884. _this._subEmitters.push(subEmitter);
  109885. }
  109886. });
  109887. }
  109888. };
  109889. /**
  109890. * Starts the particle system and begins to emit
  109891. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  109892. */
  109893. ParticleSystem.prototype.start = function (delay) {
  109894. var _this = this;
  109895. if (delay === void 0) { delay = this.startDelay; }
  109896. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  109897. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  109898. }
  109899. if (delay) {
  109900. setTimeout(function () {
  109901. _this.start(0);
  109902. }, delay);
  109903. return;
  109904. }
  109905. // Convert the subEmitters field to the constant type field _subEmitters
  109906. this._prepareSubEmitterInternalArray();
  109907. this._started = true;
  109908. this._stopped = false;
  109909. this._actualFrame = 0;
  109910. if (this._subEmitters && this._subEmitters.length != 0) {
  109911. this.activeSubSystems = new Array();
  109912. }
  109913. // Reset emit gradient so it acts the same on every start
  109914. if (this._emitRateGradients) {
  109915. if (this._emitRateGradients.length > 0) {
  109916. this._currentEmitRateGradient = this._emitRateGradients[0];
  109917. this._currentEmitRate1 = this._currentEmitRateGradient.getFactor();
  109918. this._currentEmitRate2 = this._currentEmitRate1;
  109919. }
  109920. if (this._emitRateGradients.length > 1) {
  109921. this._currentEmitRate2 = this._emitRateGradients[1].getFactor();
  109922. }
  109923. }
  109924. // Reset start size gradient so it acts the same on every start
  109925. if (this._startSizeGradients) {
  109926. if (this._startSizeGradients.length > 0) {
  109927. this._currentStartSizeGradient = this._startSizeGradients[0];
  109928. this._currentStartSize1 = this._currentStartSizeGradient.getFactor();
  109929. this._currentStartSize2 = this._currentStartSize1;
  109930. }
  109931. if (this._startSizeGradients.length > 1) {
  109932. this._currentStartSize2 = this._startSizeGradients[1].getFactor();
  109933. }
  109934. }
  109935. if (this.preWarmCycles) {
  109936. if (this.emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__["AbstractMesh"]) {
  109937. this.emitter.computeWorldMatrix(true);
  109938. }
  109939. var noiseTextureAsProcedural_1 = this.noiseTexture;
  109940. if (noiseTextureAsProcedural_1 && noiseTextureAsProcedural_1.onGeneratedObservable) {
  109941. noiseTextureAsProcedural_1.onGeneratedObservable.addOnce(function () {
  109942. setTimeout(function () {
  109943. for (var index = 0; index < _this.preWarmCycles; index++) {
  109944. _this.animate(true);
  109945. noiseTextureAsProcedural_1.render();
  109946. }
  109947. });
  109948. });
  109949. }
  109950. else {
  109951. for (var index = 0; index < this.preWarmCycles; index++) {
  109952. this.animate(true);
  109953. }
  109954. }
  109955. }
  109956. // Animations
  109957. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  109958. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  109959. }
  109960. };
  109961. /**
  109962. * Stops the particle system.
  109963. * @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.
  109964. */
  109965. ParticleSystem.prototype.stop = function (stopSubEmitters) {
  109966. if (stopSubEmitters === void 0) { stopSubEmitters = true; }
  109967. this._stopped = true;
  109968. if (stopSubEmitters) {
  109969. this._stopSubEmitters();
  109970. }
  109971. };
  109972. // animation sheet
  109973. /**
  109974. * Remove all active particles
  109975. */
  109976. ParticleSystem.prototype.reset = function () {
  109977. this._stockParticles = [];
  109978. this._particles = [];
  109979. };
  109980. /**
  109981. * @hidden (for internal use only)
  109982. */
  109983. ParticleSystem.prototype._appendParticleVertex = function (index, particle, offsetX, offsetY) {
  109984. var offset = index * this._vertexBufferSize;
  109985. this._vertexData[offset++] = particle.position.x + this.worldOffset.x;
  109986. this._vertexData[offset++] = particle.position.y + this.worldOffset.y;
  109987. this._vertexData[offset++] = particle.position.z + this.worldOffset.z;
  109988. this._vertexData[offset++] = particle.color.r;
  109989. this._vertexData[offset++] = particle.color.g;
  109990. this._vertexData[offset++] = particle.color.b;
  109991. this._vertexData[offset++] = particle.color.a;
  109992. this._vertexData[offset++] = particle.angle;
  109993. this._vertexData[offset++] = particle.scale.x * particle.size;
  109994. this._vertexData[offset++] = particle.scale.y * particle.size;
  109995. if (this._isAnimationSheetEnabled) {
  109996. this._vertexData[offset++] = particle.cellIndex;
  109997. }
  109998. if (!this._isBillboardBased) {
  109999. if (particle._initialDirection) {
  110000. this._vertexData[offset++] = particle._initialDirection.x;
  110001. this._vertexData[offset++] = particle._initialDirection.y;
  110002. this._vertexData[offset++] = particle._initialDirection.z;
  110003. }
  110004. else {
  110005. this._vertexData[offset++] = particle.direction.x;
  110006. this._vertexData[offset++] = particle.direction.y;
  110007. this._vertexData[offset++] = particle.direction.z;
  110008. }
  110009. }
  110010. else if (this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  110011. this._vertexData[offset++] = particle.direction.x;
  110012. this._vertexData[offset++] = particle.direction.y;
  110013. this._vertexData[offset++] = particle.direction.z;
  110014. }
  110015. if (this._useRampGradients) {
  110016. this._vertexData[offset++] = particle.remapData.x;
  110017. this._vertexData[offset++] = particle.remapData.y;
  110018. this._vertexData[offset++] = particle.remapData.z;
  110019. this._vertexData[offset++] = particle.remapData.w;
  110020. }
  110021. if (!this._useInstancing) {
  110022. if (this._isAnimationSheetEnabled) {
  110023. if (offsetX === 0) {
  110024. offsetX = this._epsilon;
  110025. }
  110026. else if (offsetX === 1) {
  110027. offsetX = 1 - this._epsilon;
  110028. }
  110029. if (offsetY === 0) {
  110030. offsetY = this._epsilon;
  110031. }
  110032. else if (offsetY === 1) {
  110033. offsetY = 1 - this._epsilon;
  110034. }
  110035. }
  110036. this._vertexData[offset++] = offsetX;
  110037. this._vertexData[offset++] = offsetY;
  110038. }
  110039. };
  110040. ParticleSystem.prototype._stopSubEmitters = function () {
  110041. if (!this.activeSubSystems) {
  110042. return;
  110043. }
  110044. this.activeSubSystems.forEach(function (subSystem) {
  110045. subSystem.stop(true);
  110046. });
  110047. this.activeSubSystems = new Array();
  110048. };
  110049. ParticleSystem.prototype._removeFromRoot = function () {
  110050. if (!this._rootParticleSystem) {
  110051. return;
  110052. }
  110053. var index = this._rootParticleSystem.activeSubSystems.indexOf(this);
  110054. if (index !== -1) {
  110055. this._rootParticleSystem.activeSubSystems.splice(index, 1);
  110056. }
  110057. this._rootParticleSystem = null;
  110058. };
  110059. // End of sub system methods
  110060. ParticleSystem.prototype._update = function (newParticles) {
  110061. var _this = this;
  110062. // Update current
  110063. this._alive = this._particles.length > 0;
  110064. if (this.emitter.position) {
  110065. var emitterMesh = this.emitter;
  110066. this._emitterWorldMatrix = emitterMesh.getWorldMatrix();
  110067. }
  110068. else {
  110069. var emitterPosition = this.emitter;
  110070. this._emitterWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  110071. }
  110072. this.updateFunction(this._particles);
  110073. // Add new ones
  110074. var particle;
  110075. var _loop_2 = function () {
  110076. if (this_1._particles.length === this_1._capacity) {
  110077. return "break";
  110078. }
  110079. particle = this_1._createParticle();
  110080. this_1._particles.push(particle);
  110081. // Emitter
  110082. var emitPower = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minEmitPower, this_1.maxEmitPower);
  110083. if (this_1.startPositionFunction) {
  110084. this_1.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  110085. }
  110086. else {
  110087. this_1.particleEmitterType.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  110088. }
  110089. if (this_1.startDirectionFunction) {
  110090. this_1.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  110091. }
  110092. else {
  110093. this_1.particleEmitterType.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  110094. }
  110095. if (emitPower === 0) {
  110096. if (!particle._initialDirection) {
  110097. particle._initialDirection = particle.direction.clone();
  110098. }
  110099. else {
  110100. particle._initialDirection.copyFrom(particle.direction);
  110101. }
  110102. }
  110103. else {
  110104. particle._initialDirection = null;
  110105. }
  110106. particle.direction.scaleInPlace(emitPower);
  110107. // Life time
  110108. if (this_1.targetStopDuration && this_1._lifeTimeGradients && this_1._lifeTimeGradients.length > 0) {
  110109. var ratio_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(this_1._actualFrame / this_1.targetStopDuration);
  110110. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio_1, this_1._lifeTimeGradients, function (currentGradient, nextGradient) {
  110111. var factorGradient1 = currentGradient;
  110112. var factorGradient2 = nextGradient;
  110113. var lifeTime1 = factorGradient1.getFactor();
  110114. var lifeTime2 = factorGradient2.getFactor();
  110115. var gradient = (ratio_1 - factorGradient1.gradient) / (factorGradient2.gradient - factorGradient1.gradient);
  110116. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(lifeTime1, lifeTime2, gradient);
  110117. });
  110118. }
  110119. else {
  110120. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minLifeTime, this_1.maxLifeTime);
  110121. }
  110122. // Size
  110123. if (!this_1._sizeGradients || this_1._sizeGradients.length === 0) {
  110124. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minSize, this_1.maxSize);
  110125. }
  110126. else {
  110127. particle._currentSizeGradient = this_1._sizeGradients[0];
  110128. particle._currentSize1 = particle._currentSizeGradient.getFactor();
  110129. particle.size = particle._currentSize1;
  110130. if (this_1._sizeGradients.length > 1) {
  110131. particle._currentSize2 = this_1._sizeGradients[1].getFactor();
  110132. }
  110133. else {
  110134. particle._currentSize2 = particle._currentSize1;
  110135. }
  110136. }
  110137. // Size and scale
  110138. 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));
  110139. // Adjust scale by start size
  110140. if (this_1._startSizeGradients && this_1._startSizeGradients[0] && this_1.targetStopDuration) {
  110141. var ratio = this_1._actualFrame / this_1.targetStopDuration;
  110142. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this_1._startSizeGradients, function (currentGradient, nextGradient, scale) {
  110143. if (currentGradient !== _this._currentStartSizeGradient) {
  110144. _this._currentStartSize1 = _this._currentStartSize2;
  110145. _this._currentStartSize2 = nextGradient.getFactor();
  110146. _this._currentStartSizeGradient = currentGradient;
  110147. }
  110148. var value = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentStartSize1, _this._currentStartSize2, scale);
  110149. particle.scale.scaleInPlace(value);
  110150. });
  110151. }
  110152. // Angle
  110153. if (!this_1._angularSpeedGradients || this_1._angularSpeedGradients.length === 0) {
  110154. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minAngularSpeed, this_1.maxAngularSpeed);
  110155. }
  110156. else {
  110157. particle._currentAngularSpeedGradient = this_1._angularSpeedGradients[0];
  110158. particle.angularSpeed = particle._currentAngularSpeedGradient.getFactor();
  110159. particle._currentAngularSpeed1 = particle.angularSpeed;
  110160. if (this_1._angularSpeedGradients.length > 1) {
  110161. particle._currentAngularSpeed2 = this_1._angularSpeedGradients[1].getFactor();
  110162. }
  110163. else {
  110164. particle._currentAngularSpeed2 = particle._currentAngularSpeed1;
  110165. }
  110166. }
  110167. particle.angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minInitialRotation, this_1.maxInitialRotation);
  110168. // Velocity
  110169. if (this_1._velocityGradients && this_1._velocityGradients.length > 0) {
  110170. particle._currentVelocityGradient = this_1._velocityGradients[0];
  110171. particle._currentVelocity1 = particle._currentVelocityGradient.getFactor();
  110172. if (this_1._velocityGradients.length > 1) {
  110173. particle._currentVelocity2 = this_1._velocityGradients[1].getFactor();
  110174. }
  110175. else {
  110176. particle._currentVelocity2 = particle._currentVelocity1;
  110177. }
  110178. }
  110179. // Limit velocity
  110180. if (this_1._limitVelocityGradients && this_1._limitVelocityGradients.length > 0) {
  110181. particle._currentLimitVelocityGradient = this_1._limitVelocityGradients[0];
  110182. particle._currentLimitVelocity1 = particle._currentLimitVelocityGradient.getFactor();
  110183. if (this_1._limitVelocityGradients.length > 1) {
  110184. particle._currentLimitVelocity2 = this_1._limitVelocityGradients[1].getFactor();
  110185. }
  110186. else {
  110187. particle._currentLimitVelocity2 = particle._currentLimitVelocity1;
  110188. }
  110189. }
  110190. // Drag
  110191. if (this_1._dragGradients && this_1._dragGradients.length > 0) {
  110192. particle._currentDragGradient = this_1._dragGradients[0];
  110193. particle._currentDrag1 = particle._currentDragGradient.getFactor();
  110194. if (this_1._dragGradients.length > 1) {
  110195. particle._currentDrag2 = this_1._dragGradients[1].getFactor();
  110196. }
  110197. else {
  110198. particle._currentDrag2 = particle._currentDrag1;
  110199. }
  110200. }
  110201. // Color
  110202. if (!this_1._colorGradients || this_1._colorGradients.length === 0) {
  110203. step = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(0, 1.0);
  110204. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(this_1.color1, this_1.color2, step, particle.color);
  110205. this_1.colorDead.subtractToRef(particle.color, this_1._colorDiff);
  110206. this_1._colorDiff.scaleToRef(1.0 / particle.lifeTime, particle.colorStep);
  110207. }
  110208. else {
  110209. particle._currentColorGradient = this_1._colorGradients[0];
  110210. particle._currentColorGradient.getColorToRef(particle.color);
  110211. particle._currentColor1.copyFrom(particle.color);
  110212. if (this_1._colorGradients.length > 1) {
  110213. this_1._colorGradients[1].getColorToRef(particle._currentColor2);
  110214. }
  110215. else {
  110216. particle._currentColor2.copyFrom(particle.color);
  110217. }
  110218. }
  110219. // Sheet
  110220. if (this_1._isAnimationSheetEnabled) {
  110221. particle._initialStartSpriteCellID = this_1.startSpriteCellID;
  110222. particle._initialEndSpriteCellID = this_1.endSpriteCellID;
  110223. }
  110224. // Inherited Velocity
  110225. particle.direction.addInPlace(this_1._inheritedVelocityOffset);
  110226. // Ramp
  110227. if (this_1._useRampGradients) {
  110228. particle.remapData = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector4"](0, 1, 0, 1);
  110229. }
  110230. // Noise texture coordinates
  110231. if (this_1.noiseTexture) {
  110232. if (particle._randomNoiseCoordinates1) {
  110233. particle._randomNoiseCoordinates1.copyFromFloats(Math.random(), Math.random(), Math.random());
  110234. particle._randomNoiseCoordinates2.copyFromFloats(Math.random(), Math.random(), Math.random());
  110235. }
  110236. else {
  110237. particle._randomNoiseCoordinates1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  110238. particle._randomNoiseCoordinates2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  110239. }
  110240. }
  110241. // Update the position of the attached sub-emitters to match their attached particle
  110242. particle._inheritParticleInfoToSubEmitters();
  110243. };
  110244. var this_1 = this, step;
  110245. for (var index = 0; index < newParticles; index++) {
  110246. var state_1 = _loop_2();
  110247. if (state_1 === "break")
  110248. break;
  110249. }
  110250. };
  110251. /** @hidden */
  110252. ParticleSystem._GetAttributeNamesOrOptions = function (isAnimationSheetEnabled, isBillboardBased, useRampGradients) {
  110253. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  110254. if (isBillboardBased === void 0) { isBillboardBased = false; }
  110255. if (useRampGradients === void 0) { useRampGradients = false; }
  110256. var attributeNamesOrOptions = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, "angle", "offset", "size"];
  110257. if (isAnimationSheetEnabled) {
  110258. attributeNamesOrOptions.push("cellIndex");
  110259. }
  110260. if (!isBillboardBased) {
  110261. attributeNamesOrOptions.push("direction");
  110262. }
  110263. if (useRampGradients) {
  110264. attributeNamesOrOptions.push("remapData");
  110265. }
  110266. return attributeNamesOrOptions;
  110267. };
  110268. /** @hidden */
  110269. ParticleSystem._GetEffectCreationOptions = function (isAnimationSheetEnabled) {
  110270. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  110271. var effectCreationOption = ["invView", "view", "projection", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "textureMask", "translationPivot", "eyePosition"];
  110272. if (isAnimationSheetEnabled) {
  110273. effectCreationOption.push("particlesInfos");
  110274. }
  110275. return effectCreationOption;
  110276. };
  110277. /** @hidden */
  110278. ParticleSystem.prototype._getEffect = function (blendMode) {
  110279. if (this._customEffect) {
  110280. return this._customEffect;
  110281. }
  110282. var defines = [];
  110283. if (this._scene.clipPlane) {
  110284. defines.push("#define CLIPPLANE");
  110285. }
  110286. if (this._scene.clipPlane2) {
  110287. defines.push("#define CLIPPLANE2");
  110288. }
  110289. if (this._scene.clipPlane3) {
  110290. defines.push("#define CLIPPLANE3");
  110291. }
  110292. if (this._scene.clipPlane4) {
  110293. defines.push("#define CLIPPLANE4");
  110294. }
  110295. if (this._isAnimationSheetEnabled) {
  110296. defines.push("#define ANIMATESHEET");
  110297. }
  110298. if (blendMode === ParticleSystem.BLENDMODE_MULTIPLY) {
  110299. defines.push("#define BLENDMULTIPLYMODE");
  110300. }
  110301. if (this._useRampGradients) {
  110302. defines.push("#define RAMPGRADIENT");
  110303. }
  110304. if (this._isBillboardBased) {
  110305. defines.push("#define BILLBOARD");
  110306. switch (this.billboardMode) {
  110307. case ParticleSystem.BILLBOARDMODE_Y:
  110308. defines.push("#define BILLBOARDY");
  110309. break;
  110310. case ParticleSystem.BILLBOARDMODE_STRETCHED:
  110311. defines.push("#define BILLBOARDSTRETCHED");
  110312. break;
  110313. case ParticleSystem.BILLBOARDMODE_ALL:
  110314. default:
  110315. break;
  110316. }
  110317. }
  110318. if (this._imageProcessingConfiguration) {
  110319. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  110320. defines.push(this._imageProcessingConfigurationDefines.toString());
  110321. }
  110322. // Effect
  110323. var join = defines.join("\n");
  110324. if (this._cachedDefines !== join) {
  110325. this._cachedDefines = join;
  110326. var attributesNamesOrOptions = ParticleSystem._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled, this._isBillboardBased && this.billboardMode !== ParticleSystem.BILLBOARDMODE_STRETCHED, this._useRampGradients);
  110327. var effectCreationOption = ParticleSystem._GetEffectCreationOptions(this._isAnimationSheetEnabled);
  110328. var samplers = ["diffuseSampler", "rampSampler"];
  110329. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"]) {
  110330. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareUniforms(effectCreationOption, this._imageProcessingConfigurationDefines);
  110331. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  110332. }
  110333. this._effect = this._scene.getEngine().createEffect("particles", attributesNamesOrOptions, effectCreationOption, samplers, join);
  110334. }
  110335. return this._effect;
  110336. };
  110337. /**
  110338. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  110339. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  110340. */
  110341. ParticleSystem.prototype.animate = function (preWarmOnly) {
  110342. var _this = this;
  110343. if (preWarmOnly === void 0) { preWarmOnly = false; }
  110344. if (!this._started) {
  110345. return;
  110346. }
  110347. if (!preWarmOnly) {
  110348. // Check
  110349. if (!this.isReady()) {
  110350. return;
  110351. }
  110352. if (this._currentRenderId === this._scene.getFrameId()) {
  110353. return;
  110354. }
  110355. this._currentRenderId = this._scene.getFrameId();
  110356. }
  110357. this._scaledUpdateSpeed = this.updateSpeed * (preWarmOnly ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  110358. // Determine the number of particles we need to create
  110359. var newParticles;
  110360. if (this.manualEmitCount > -1) {
  110361. newParticles = this.manualEmitCount;
  110362. this._newPartsExcess = 0;
  110363. this.manualEmitCount = 0;
  110364. }
  110365. else {
  110366. var rate_1 = this.emitRate;
  110367. if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
  110368. var ratio = this._actualFrame / this.targetStopDuration;
  110369. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._emitRateGradients, function (currentGradient, nextGradient, scale) {
  110370. if (currentGradient !== _this._currentEmitRateGradient) {
  110371. _this._currentEmitRate1 = _this._currentEmitRate2;
  110372. _this._currentEmitRate2 = nextGradient.getFactor();
  110373. _this._currentEmitRateGradient = currentGradient;
  110374. }
  110375. rate_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentEmitRate1, _this._currentEmitRate2, scale);
  110376. });
  110377. }
  110378. newParticles = ((rate_1 * this._scaledUpdateSpeed) >> 0);
  110379. this._newPartsExcess += rate_1 * this._scaledUpdateSpeed - newParticles;
  110380. }
  110381. if (this._newPartsExcess > 1.0) {
  110382. newParticles += this._newPartsExcess >> 0;
  110383. this._newPartsExcess -= this._newPartsExcess >> 0;
  110384. }
  110385. this._alive = false;
  110386. if (!this._stopped) {
  110387. this._actualFrame += this._scaledUpdateSpeed;
  110388. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  110389. this.stop();
  110390. }
  110391. }
  110392. else {
  110393. newParticles = 0;
  110394. }
  110395. this._update(newParticles);
  110396. // Stopped?
  110397. if (this._stopped) {
  110398. if (!this._alive) {
  110399. this._started = false;
  110400. if (this.onAnimationEnd) {
  110401. this.onAnimationEnd();
  110402. }
  110403. if (this.disposeOnStop) {
  110404. this._scene._toBeDisposed.push(this);
  110405. }
  110406. }
  110407. }
  110408. if (!preWarmOnly) {
  110409. // Update VBO
  110410. var offset = 0;
  110411. for (var index = 0; index < this._particles.length; index++) {
  110412. var particle = this._particles[index];
  110413. this._appendParticleVertices(offset, particle);
  110414. offset += this._useInstancing ? 1 : 4;
  110415. }
  110416. if (this._vertexBuffer) {
  110417. this._vertexBuffer.update(this._vertexData);
  110418. }
  110419. }
  110420. if (this.manualEmitCount === 0 && this.disposeOnStop) {
  110421. this.stop();
  110422. }
  110423. };
  110424. ParticleSystem.prototype._appendParticleVertices = function (offset, particle) {
  110425. this._appendParticleVertex(offset++, particle, 0, 0);
  110426. if (!this._useInstancing) {
  110427. this._appendParticleVertex(offset++, particle, 1, 0);
  110428. this._appendParticleVertex(offset++, particle, 1, 1);
  110429. this._appendParticleVertex(offset++, particle, 0, 1);
  110430. }
  110431. };
  110432. /**
  110433. * Rebuilds the particle system.
  110434. */
  110435. ParticleSystem.prototype.rebuild = function () {
  110436. this._createIndexBuffer();
  110437. if (this._vertexBuffer) {
  110438. this._vertexBuffer._rebuild();
  110439. }
  110440. };
  110441. /**
  110442. * Is this system ready to be used/rendered
  110443. * @return true if the system is ready
  110444. */
  110445. ParticleSystem.prototype.isReady = function () {
  110446. if (!this.emitter || !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  110447. return false;
  110448. }
  110449. if (this.blendMode !== ParticleSystem.BLENDMODE_MULTIPLYADD) {
  110450. if (!this._getEffect(this.blendMode).isReady()) {
  110451. return false;
  110452. }
  110453. }
  110454. else {
  110455. if (!this._getEffect(ParticleSystem.BLENDMODE_MULTIPLY).isReady()) {
  110456. return false;
  110457. }
  110458. if (!this._getEffect(ParticleSystem.BLENDMODE_ADD).isReady()) {
  110459. return false;
  110460. }
  110461. }
  110462. return true;
  110463. };
  110464. ParticleSystem.prototype._render = function (blendMode) {
  110465. var effect = this._getEffect(blendMode);
  110466. var engine = this._scene.getEngine();
  110467. // Render
  110468. engine.enableEffect(effect);
  110469. var viewMatrix = this._scene.getViewMatrix();
  110470. effect.setTexture("diffuseSampler", this.particleTexture);
  110471. effect.setMatrix("view", viewMatrix);
  110472. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  110473. if (this._isAnimationSheetEnabled && this.particleTexture) {
  110474. var baseSize = this.particleTexture.getBaseSize();
  110475. effect.setFloat3("particlesInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  110476. }
  110477. effect.setVector2("translationPivot", this.translationPivot);
  110478. effect.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a);
  110479. if (this._isBillboardBased) {
  110480. var camera = this._scene.activeCamera;
  110481. effect.setVector3("eyePosition", camera.globalPosition);
  110482. }
  110483. if (this._rampGradientsTexture) {
  110484. effect.setTexture("rampSampler", this._rampGradientsTexture);
  110485. }
  110486. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  110487. var invView = viewMatrix.clone();
  110488. invView.invert();
  110489. effect.setMatrix("invView", invView);
  110490. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__["MaterialHelper"].BindClipPlane(effect, this._scene);
  110491. }
  110492. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  110493. // image processing
  110494. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  110495. this._imageProcessingConfiguration.bind(effect);
  110496. }
  110497. // Draw order
  110498. switch (blendMode) {
  110499. case ParticleSystem.BLENDMODE_ADD:
  110500. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ADD);
  110501. break;
  110502. case ParticleSystem.BLENDMODE_ONEONE:
  110503. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ONEONE);
  110504. break;
  110505. case ParticleSystem.BLENDMODE_STANDARD:
  110506. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_COMBINE);
  110507. break;
  110508. case ParticleSystem.BLENDMODE_MULTIPLY:
  110509. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_MULTIPLY);
  110510. break;
  110511. }
  110512. if (this._useInstancing) {
  110513. engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFanDrawMode, 0, 4, this._particles.length);
  110514. }
  110515. else {
  110516. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, this._particles.length * 6);
  110517. }
  110518. return this._particles.length;
  110519. };
  110520. /**
  110521. * Renders the particle system in its current state.
  110522. * @returns the current number of particles
  110523. */
  110524. ParticleSystem.prototype.render = function () {
  110525. // Check
  110526. if (!this.isReady() || !this._particles.length) {
  110527. return 0;
  110528. }
  110529. var engine = this._scene.getEngine();
  110530. engine.setState(false);
  110531. if (this.forceDepthWrite) {
  110532. engine.setDepthWrite(true);
  110533. }
  110534. var outparticles = 0;
  110535. if (this.blendMode === ParticleSystem.BLENDMODE_MULTIPLYADD) {
  110536. outparticles = this._render(ParticleSystem.BLENDMODE_MULTIPLY) + this._render(ParticleSystem.BLENDMODE_ADD);
  110537. }
  110538. outparticles = this._render(this.blendMode);
  110539. engine.unbindInstanceAttributes();
  110540. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_DISABLE);
  110541. return outparticles;
  110542. };
  110543. /**
  110544. * Disposes the particle system and free the associated resources
  110545. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  110546. */
  110547. ParticleSystem.prototype.dispose = function (disposeTexture) {
  110548. if (disposeTexture === void 0) { disposeTexture = true; }
  110549. if (this._vertexBuffer) {
  110550. this._vertexBuffer.dispose();
  110551. this._vertexBuffer = null;
  110552. }
  110553. if (this._spriteBuffer) {
  110554. this._spriteBuffer.dispose();
  110555. this._spriteBuffer = null;
  110556. }
  110557. if (this._indexBuffer) {
  110558. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  110559. this._indexBuffer = null;
  110560. }
  110561. if (disposeTexture && this.particleTexture) {
  110562. this.particleTexture.dispose();
  110563. this.particleTexture = null;
  110564. }
  110565. if (disposeTexture && this.noiseTexture) {
  110566. this.noiseTexture.dispose();
  110567. this.noiseTexture = null;
  110568. }
  110569. if (this._rampGradientsTexture) {
  110570. this._rampGradientsTexture.dispose();
  110571. this._rampGradientsTexture = null;
  110572. }
  110573. this._removeFromRoot();
  110574. if (this._subEmitters && this._subEmitters.length) {
  110575. for (var index = 0; index < this._subEmitters.length; index++) {
  110576. for (var _i = 0, _a = this._subEmitters[index]; _i < _a.length; _i++) {
  110577. var subEmitter = _a[_i];
  110578. subEmitter.dispose();
  110579. }
  110580. }
  110581. this._subEmitters = [];
  110582. this.subEmitters = [];
  110583. }
  110584. if (this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose) {
  110585. this.emitter.dispose(true);
  110586. }
  110587. // Remove from scene
  110588. var index = this._scene.particleSystems.indexOf(this);
  110589. if (index > -1) {
  110590. this._scene.particleSystems.splice(index, 1);
  110591. }
  110592. this._scene._activeParticleSystems.dispose();
  110593. // Callback
  110594. this.onDisposeObservable.notifyObservers(this);
  110595. this.onDisposeObservable.clear();
  110596. this.reset();
  110597. };
  110598. // Clone
  110599. /**
  110600. * Clones the particle system.
  110601. * @param name The name of the cloned object
  110602. * @param newEmitter The new emitter to use
  110603. * @returns the cloned particle system
  110604. */
  110605. ParticleSystem.prototype.clone = function (name, newEmitter) {
  110606. var custom = null;
  110607. var program = null;
  110608. if (this.customShader != null) {
  110609. program = this.customShader;
  110610. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  110611. custom = this._scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  110612. }
  110613. else if (this._customEffect) {
  110614. custom = this._customEffect;
  110615. }
  110616. var result = new ParticleSystem(name, this._capacity, this._scene, custom);
  110617. result.customShader = program;
  110618. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__["DeepCopier"].DeepCopy(this, result, ["particles", "customShader", "noiseTexture"]);
  110619. if (newEmitter === undefined) {
  110620. newEmitter = this.emitter;
  110621. }
  110622. result.noiseTexture = this.noiseTexture;
  110623. result.emitter = newEmitter;
  110624. if (this.particleTexture) {
  110625. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](this.particleTexture.url, this._scene);
  110626. }
  110627. // Clone gradients
  110628. if (this._colorGradients) {
  110629. this._colorGradients.forEach(function (v) {
  110630. result.addColorGradient(v.gradient, v.color1, v.color2);
  110631. });
  110632. }
  110633. if (this._dragGradients) {
  110634. this._dragGradients.forEach(function (v) {
  110635. result.addDragGradient(v.gradient, v.factor1, v.factor2);
  110636. });
  110637. }
  110638. if (this._angularSpeedGradients) {
  110639. this._angularSpeedGradients.forEach(function (v) {
  110640. result.addAngularSpeedGradient(v.gradient, v.factor1, v.factor2);
  110641. });
  110642. }
  110643. if (this._emitRateGradients) {
  110644. this._emitRateGradients.forEach(function (v) {
  110645. result.addEmitRateGradient(v.gradient, v.factor1, v.factor2);
  110646. });
  110647. }
  110648. if (this._lifeTimeGradients) {
  110649. this._lifeTimeGradients.forEach(function (v) {
  110650. result.addLifeTimeGradient(v.gradient, v.factor1, v.factor2);
  110651. });
  110652. }
  110653. if (this._limitVelocityGradients) {
  110654. this._limitVelocityGradients.forEach(function (v) {
  110655. result.addLimitVelocityGradient(v.gradient, v.factor1, v.factor2);
  110656. });
  110657. }
  110658. if (this._sizeGradients) {
  110659. this._sizeGradients.forEach(function (v) {
  110660. result.addSizeGradient(v.gradient, v.factor1, v.factor2);
  110661. });
  110662. }
  110663. if (this._startSizeGradients) {
  110664. this._startSizeGradients.forEach(function (v) {
  110665. result.addStartSizeGradient(v.gradient, v.factor1, v.factor2);
  110666. });
  110667. }
  110668. if (this._velocityGradients) {
  110669. this._velocityGradients.forEach(function (v) {
  110670. result.addVelocityGradient(v.gradient, v.factor1, v.factor2);
  110671. });
  110672. }
  110673. if (this._rampGradients) {
  110674. this._rampGradients.forEach(function (v) {
  110675. result.addRampGradient(v.gradient, v.color);
  110676. });
  110677. }
  110678. if (this._colorRemapGradients) {
  110679. this._colorRemapGradients.forEach(function (v) {
  110680. result.addColorRemapGradient(v.gradient, v.factor1, v.factor2);
  110681. });
  110682. }
  110683. if (this._alphaRemapGradients) {
  110684. this._alphaRemapGradients.forEach(function (v) {
  110685. result.addAlphaRemapGradient(v.gradient, v.factor1, v.factor2);
  110686. });
  110687. }
  110688. if (!this.preventAutoStart) {
  110689. result.start();
  110690. }
  110691. return result;
  110692. };
  110693. /**
  110694. * Serializes the particle system to a JSON object.
  110695. * @returns the JSON object
  110696. */
  110697. ParticleSystem.prototype.serialize = function () {
  110698. var serializationObject = {};
  110699. ParticleSystem._Serialize(serializationObject, this);
  110700. serializationObject.textureMask = this.textureMask.asArray();
  110701. serializationObject.customShader = this.customShader;
  110702. serializationObject.preventAutoStart = this.preventAutoStart;
  110703. // SubEmitters
  110704. if (this.subEmitters) {
  110705. serializationObject.subEmitters = [];
  110706. if (!this._subEmitters) {
  110707. this._prepareSubEmitterInternalArray();
  110708. }
  110709. for (var _i = 0, _a = this._subEmitters; _i < _a.length; _i++) {
  110710. var subs = _a[_i];
  110711. var cell = [];
  110712. for (var _b = 0, subs_1 = subs; _b < subs_1.length; _b++) {
  110713. var sub = subs_1[_b];
  110714. cell.push(sub.serialize());
  110715. }
  110716. serializationObject.subEmitters.push(cell);
  110717. }
  110718. }
  110719. return serializationObject;
  110720. };
  110721. /** @hidden */
  110722. ParticleSystem._Serialize = function (serializationObject, particleSystem) {
  110723. serializationObject.name = particleSystem.name;
  110724. serializationObject.id = particleSystem.id;
  110725. serializationObject.capacity = particleSystem.getCapacity();
  110726. // Emitter
  110727. if (particleSystem.emitter.position) {
  110728. var emitterMesh = particleSystem.emitter;
  110729. serializationObject.emitterId = emitterMesh.id;
  110730. }
  110731. else {
  110732. var emitterPosition = particleSystem.emitter;
  110733. serializationObject.emitter = emitterPosition.asArray();
  110734. }
  110735. // Emitter
  110736. if (particleSystem.particleEmitterType) {
  110737. serializationObject.particleEmitterType = particleSystem.particleEmitterType.serialize();
  110738. }
  110739. if (particleSystem.particleTexture) {
  110740. serializationObject.textureName = particleSystem.particleTexture.name;
  110741. serializationObject.invertY = particleSystem.particleTexture._invertY;
  110742. }
  110743. // Animations
  110744. _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__["SerializationHelper"].AppendSerializedAnimations(particleSystem, serializationObject);
  110745. serializationObject.beginAnimationOnStart = particleSystem.beginAnimationOnStart;
  110746. serializationObject.beginAnimationFrom = particleSystem.beginAnimationFrom;
  110747. serializationObject.beginAnimationTo = particleSystem.beginAnimationTo;
  110748. serializationObject.beginAnimationLoop = particleSystem.beginAnimationLoop;
  110749. // Particle system
  110750. serializationObject.startDelay = particleSystem.startDelay;
  110751. serializationObject.renderingGroupId = particleSystem.renderingGroupId;
  110752. serializationObject.isBillboardBased = particleSystem.isBillboardBased;
  110753. serializationObject.billboardMode = particleSystem.billboardMode;
  110754. serializationObject.minAngularSpeed = particleSystem.minAngularSpeed;
  110755. serializationObject.maxAngularSpeed = particleSystem.maxAngularSpeed;
  110756. serializationObject.minSize = particleSystem.minSize;
  110757. serializationObject.maxSize = particleSystem.maxSize;
  110758. serializationObject.minScaleX = particleSystem.minScaleX;
  110759. serializationObject.maxScaleX = particleSystem.maxScaleX;
  110760. serializationObject.minScaleY = particleSystem.minScaleY;
  110761. serializationObject.maxScaleY = particleSystem.maxScaleY;
  110762. serializationObject.minEmitPower = particleSystem.minEmitPower;
  110763. serializationObject.maxEmitPower = particleSystem.maxEmitPower;
  110764. serializationObject.minLifeTime = particleSystem.minLifeTime;
  110765. serializationObject.maxLifeTime = particleSystem.maxLifeTime;
  110766. serializationObject.emitRate = particleSystem.emitRate;
  110767. serializationObject.gravity = particleSystem.gravity.asArray();
  110768. serializationObject.noiseStrength = particleSystem.noiseStrength.asArray();
  110769. serializationObject.color1 = particleSystem.color1.asArray();
  110770. serializationObject.color2 = particleSystem.color2.asArray();
  110771. serializationObject.colorDead = particleSystem.colorDead.asArray();
  110772. serializationObject.updateSpeed = particleSystem.updateSpeed;
  110773. serializationObject.targetStopDuration = particleSystem.targetStopDuration;
  110774. serializationObject.blendMode = particleSystem.blendMode;
  110775. serializationObject.preWarmCycles = particleSystem.preWarmCycles;
  110776. serializationObject.preWarmStepOffset = particleSystem.preWarmStepOffset;
  110777. serializationObject.minInitialRotation = particleSystem.minInitialRotation;
  110778. serializationObject.maxInitialRotation = particleSystem.maxInitialRotation;
  110779. serializationObject.startSpriteCellID = particleSystem.startSpriteCellID;
  110780. serializationObject.endSpriteCellID = particleSystem.endSpriteCellID;
  110781. serializationObject.spriteCellChangeSpeed = particleSystem.spriteCellChangeSpeed;
  110782. serializationObject.spriteCellWidth = particleSystem.spriteCellWidth;
  110783. serializationObject.spriteCellHeight = particleSystem.spriteCellHeight;
  110784. serializationObject.spriteRandomStartCell = particleSystem.spriteRandomStartCell;
  110785. serializationObject.isAnimationSheetEnabled = particleSystem.isAnimationSheetEnabled;
  110786. var colorGradients = particleSystem.getColorGradients();
  110787. if (colorGradients) {
  110788. serializationObject.colorGradients = [];
  110789. for (var _i = 0, colorGradients_1 = colorGradients; _i < colorGradients_1.length; _i++) {
  110790. var colorGradient = colorGradients_1[_i];
  110791. var serializedGradient = {
  110792. gradient: colorGradient.gradient,
  110793. color1: colorGradient.color1.asArray()
  110794. };
  110795. if (colorGradient.color2) {
  110796. serializedGradient.color2 = colorGradient.color2.asArray();
  110797. }
  110798. serializationObject.colorGradients.push(serializedGradient);
  110799. }
  110800. }
  110801. var rampGradients = particleSystem.getRampGradients();
  110802. if (rampGradients) {
  110803. serializationObject.rampGradients = [];
  110804. for (var _a = 0, rampGradients_1 = rampGradients; _a < rampGradients_1.length; _a++) {
  110805. var rampGradient = rampGradients_1[_a];
  110806. var serializedGradient = {
  110807. gradient: rampGradient.gradient,
  110808. color: rampGradient.color.asArray()
  110809. };
  110810. serializationObject.rampGradients.push(serializedGradient);
  110811. }
  110812. serializationObject.useRampGradients = particleSystem.useRampGradients;
  110813. }
  110814. var colorRemapGradients = particleSystem.getColorRemapGradients();
  110815. if (colorRemapGradients) {
  110816. serializationObject.colorRemapGradients = [];
  110817. for (var _b = 0, colorRemapGradients_1 = colorRemapGradients; _b < colorRemapGradients_1.length; _b++) {
  110818. var colorRemapGradient = colorRemapGradients_1[_b];
  110819. var serializedGradient = {
  110820. gradient: colorRemapGradient.gradient,
  110821. factor1: colorRemapGradient.factor1
  110822. };
  110823. if (colorRemapGradient.factor2 !== undefined) {
  110824. serializedGradient.factor2 = colorRemapGradient.factor2;
  110825. }
  110826. serializationObject.colorRemapGradients.push(serializedGradient);
  110827. }
  110828. }
  110829. var alphaRemapGradients = particleSystem.getAlphaRemapGradients();
  110830. if (alphaRemapGradients) {
  110831. serializationObject.alphaRemapGradients = [];
  110832. for (var _c = 0, alphaRemapGradients_1 = alphaRemapGradients; _c < alphaRemapGradients_1.length; _c++) {
  110833. var alphaRemapGradient = alphaRemapGradients_1[_c];
  110834. var serializedGradient = {
  110835. gradient: alphaRemapGradient.gradient,
  110836. factor1: alphaRemapGradient.factor1
  110837. };
  110838. if (alphaRemapGradient.factor2 !== undefined) {
  110839. serializedGradient.factor2 = alphaRemapGradient.factor2;
  110840. }
  110841. serializationObject.alphaRemapGradients.push(serializedGradient);
  110842. }
  110843. }
  110844. var sizeGradients = particleSystem.getSizeGradients();
  110845. if (sizeGradients) {
  110846. serializationObject.sizeGradients = [];
  110847. for (var _d = 0, sizeGradients_1 = sizeGradients; _d < sizeGradients_1.length; _d++) {
  110848. var sizeGradient = sizeGradients_1[_d];
  110849. var serializedGradient = {
  110850. gradient: sizeGradient.gradient,
  110851. factor1: sizeGradient.factor1
  110852. };
  110853. if (sizeGradient.factor2 !== undefined) {
  110854. serializedGradient.factor2 = sizeGradient.factor2;
  110855. }
  110856. serializationObject.sizeGradients.push(serializedGradient);
  110857. }
  110858. }
  110859. var angularSpeedGradients = particleSystem.getAngularSpeedGradients();
  110860. if (angularSpeedGradients) {
  110861. serializationObject.angularSpeedGradients = [];
  110862. for (var _e = 0, angularSpeedGradients_1 = angularSpeedGradients; _e < angularSpeedGradients_1.length; _e++) {
  110863. var angularSpeedGradient = angularSpeedGradients_1[_e];
  110864. var serializedGradient = {
  110865. gradient: angularSpeedGradient.gradient,
  110866. factor1: angularSpeedGradient.factor1
  110867. };
  110868. if (angularSpeedGradient.factor2 !== undefined) {
  110869. serializedGradient.factor2 = angularSpeedGradient.factor2;
  110870. }
  110871. serializationObject.angularSpeedGradients.push(serializedGradient);
  110872. }
  110873. }
  110874. var velocityGradients = particleSystem.getVelocityGradients();
  110875. if (velocityGradients) {
  110876. serializationObject.velocityGradients = [];
  110877. for (var _f = 0, velocityGradients_1 = velocityGradients; _f < velocityGradients_1.length; _f++) {
  110878. var velocityGradient = velocityGradients_1[_f];
  110879. var serializedGradient = {
  110880. gradient: velocityGradient.gradient,
  110881. factor1: velocityGradient.factor1
  110882. };
  110883. if (velocityGradient.factor2 !== undefined) {
  110884. serializedGradient.factor2 = velocityGradient.factor2;
  110885. }
  110886. serializationObject.velocityGradients.push(serializedGradient);
  110887. }
  110888. }
  110889. var dragGradients = particleSystem.getDragGradients();
  110890. if (dragGradients) {
  110891. serializationObject.dragyGradients = [];
  110892. for (var _g = 0, dragGradients_1 = dragGradients; _g < dragGradients_1.length; _g++) {
  110893. var dragGradient = dragGradients_1[_g];
  110894. var serializedGradient = {
  110895. gradient: dragGradient.gradient,
  110896. factor1: dragGradient.factor1
  110897. };
  110898. if (dragGradient.factor2 !== undefined) {
  110899. serializedGradient.factor2 = dragGradient.factor2;
  110900. }
  110901. serializationObject.dragGradients.push(serializedGradient);
  110902. }
  110903. }
  110904. var emitRateGradients = particleSystem.getEmitRateGradients();
  110905. if (emitRateGradients) {
  110906. serializationObject.emitRateGradients = [];
  110907. for (var _h = 0, emitRateGradients_1 = emitRateGradients; _h < emitRateGradients_1.length; _h++) {
  110908. var emitRateGradient = emitRateGradients_1[_h];
  110909. var serializedGradient = {
  110910. gradient: emitRateGradient.gradient,
  110911. factor1: emitRateGradient.factor1
  110912. };
  110913. if (emitRateGradient.factor2 !== undefined) {
  110914. serializedGradient.factor2 = emitRateGradient.factor2;
  110915. }
  110916. serializationObject.emitRateGradients.push(serializedGradient);
  110917. }
  110918. }
  110919. var startSizeGradients = particleSystem.getStartSizeGradients();
  110920. if (startSizeGradients) {
  110921. serializationObject.startSizeGradients = [];
  110922. for (var _j = 0, startSizeGradients_1 = startSizeGradients; _j < startSizeGradients_1.length; _j++) {
  110923. var startSizeGradient = startSizeGradients_1[_j];
  110924. var serializedGradient = {
  110925. gradient: startSizeGradient.gradient,
  110926. factor1: startSizeGradient.factor1
  110927. };
  110928. if (startSizeGradient.factor2 !== undefined) {
  110929. serializedGradient.factor2 = startSizeGradient.factor2;
  110930. }
  110931. serializationObject.startSizeGradients.push(serializedGradient);
  110932. }
  110933. }
  110934. var lifeTimeGradients = particleSystem.getLifeTimeGradients();
  110935. if (lifeTimeGradients) {
  110936. serializationObject.lifeTimeGradients = [];
  110937. for (var _k = 0, lifeTimeGradients_1 = lifeTimeGradients; _k < lifeTimeGradients_1.length; _k++) {
  110938. var lifeTimeGradient = lifeTimeGradients_1[_k];
  110939. var serializedGradient = {
  110940. gradient: lifeTimeGradient.gradient,
  110941. factor1: lifeTimeGradient.factor1
  110942. };
  110943. if (lifeTimeGradient.factor2 !== undefined) {
  110944. serializedGradient.factor2 = lifeTimeGradient.factor2;
  110945. }
  110946. serializationObject.lifeTimeGradients.push(serializedGradient);
  110947. }
  110948. }
  110949. var limitVelocityGradients = particleSystem.getLimitVelocityGradients();
  110950. if (limitVelocityGradients) {
  110951. serializationObject.limitVelocityGradients = [];
  110952. for (var _l = 0, limitVelocityGradients_1 = limitVelocityGradients; _l < limitVelocityGradients_1.length; _l++) {
  110953. var limitVelocityGradient = limitVelocityGradients_1[_l];
  110954. var serializedGradient = {
  110955. gradient: limitVelocityGradient.gradient,
  110956. factor1: limitVelocityGradient.factor1
  110957. };
  110958. if (limitVelocityGradient.factor2 !== undefined) {
  110959. serializedGradient.factor2 = limitVelocityGradient.factor2;
  110960. }
  110961. serializationObject.limitVelocityGradients.push(serializedGradient);
  110962. }
  110963. serializationObject.limitVelocityDamping = particleSystem.limitVelocityDamping;
  110964. }
  110965. if (particleSystem.noiseTexture) {
  110966. serializationObject.noiseTexture = particleSystem.noiseTexture.serialize();
  110967. }
  110968. };
  110969. /** @hidden */
  110970. ParticleSystem._Parse = function (parsedParticleSystem, particleSystem, scene, rootUrl) {
  110971. // Texture
  110972. if (parsedParticleSystem.textureName) {
  110973. particleSystem.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](rootUrl + parsedParticleSystem.textureName, scene, false, parsedParticleSystem.invertY !== undefined ? parsedParticleSystem.invertY : true);
  110974. particleSystem.particleTexture.name = parsedParticleSystem.textureName;
  110975. }
  110976. // Emitter
  110977. if (!parsedParticleSystem.emitterId && parsedParticleSystem.emitterId !== 0 && parsedParticleSystem.emitter === undefined) {
  110978. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  110979. }
  110980. else if (parsedParticleSystem.emitterId) {
  110981. particleSystem.emitter = scene.getLastMeshByID(parsedParticleSystem.emitterId);
  110982. }
  110983. else {
  110984. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.emitter);
  110985. }
  110986. // Misc.
  110987. if (parsedParticleSystem.renderingGroupId !== undefined) {
  110988. particleSystem.renderingGroupId = parsedParticleSystem.renderingGroupId;
  110989. }
  110990. if (parsedParticleSystem.isBillboardBased !== undefined) {
  110991. particleSystem.isBillboardBased = parsedParticleSystem.isBillboardBased;
  110992. }
  110993. if (parsedParticleSystem.billboardMode !== undefined) {
  110994. particleSystem.billboardMode = parsedParticleSystem.billboardMode;
  110995. }
  110996. // Animations
  110997. if (parsedParticleSystem.animations) {
  110998. for (var animationIndex = 0; animationIndex < parsedParticleSystem.animations.length; animationIndex++) {
  110999. var parsedAnimation = parsedParticleSystem.animations[animationIndex];
  111000. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__["_TypeStore"].GetClass("BABYLON.Animation");
  111001. if (internalClass) {
  111002. particleSystem.animations.push(internalClass.Parse(parsedAnimation));
  111003. }
  111004. }
  111005. particleSystem.beginAnimationOnStart = parsedParticleSystem.beginAnimationOnStart;
  111006. particleSystem.beginAnimationFrom = parsedParticleSystem.beginAnimationFrom;
  111007. particleSystem.beginAnimationTo = parsedParticleSystem.beginAnimationTo;
  111008. particleSystem.beginAnimationLoop = parsedParticleSystem.beginAnimationLoop;
  111009. }
  111010. if (parsedParticleSystem.autoAnimate) {
  111011. scene.beginAnimation(particleSystem, parsedParticleSystem.autoAnimateFrom, parsedParticleSystem.autoAnimateTo, parsedParticleSystem.autoAnimateLoop, parsedParticleSystem.autoAnimateSpeed || 1.0);
  111012. }
  111013. // Particle system
  111014. particleSystem.startDelay = parsedParticleSystem.startDelay | 0;
  111015. particleSystem.minAngularSpeed = parsedParticleSystem.minAngularSpeed;
  111016. particleSystem.maxAngularSpeed = parsedParticleSystem.maxAngularSpeed;
  111017. particleSystem.minSize = parsedParticleSystem.minSize;
  111018. particleSystem.maxSize = parsedParticleSystem.maxSize;
  111019. if (parsedParticleSystem.minScaleX) {
  111020. particleSystem.minScaleX = parsedParticleSystem.minScaleX;
  111021. particleSystem.maxScaleX = parsedParticleSystem.maxScaleX;
  111022. particleSystem.minScaleY = parsedParticleSystem.minScaleY;
  111023. particleSystem.maxScaleY = parsedParticleSystem.maxScaleY;
  111024. }
  111025. if (parsedParticleSystem.preWarmCycles !== undefined) {
  111026. particleSystem.preWarmCycles = parsedParticleSystem.preWarmCycles;
  111027. particleSystem.preWarmStepOffset = parsedParticleSystem.preWarmStepOffset;
  111028. }
  111029. if (parsedParticleSystem.minInitialRotation !== undefined) {
  111030. particleSystem.minInitialRotation = parsedParticleSystem.minInitialRotation;
  111031. particleSystem.maxInitialRotation = parsedParticleSystem.maxInitialRotation;
  111032. }
  111033. particleSystem.minLifeTime = parsedParticleSystem.minLifeTime;
  111034. particleSystem.maxLifeTime = parsedParticleSystem.maxLifeTime;
  111035. particleSystem.minEmitPower = parsedParticleSystem.minEmitPower;
  111036. particleSystem.maxEmitPower = parsedParticleSystem.maxEmitPower;
  111037. particleSystem.emitRate = parsedParticleSystem.emitRate;
  111038. particleSystem.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.gravity);
  111039. if (parsedParticleSystem.noiseStrength) {
  111040. particleSystem.noiseStrength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.noiseStrength);
  111041. }
  111042. particleSystem.color1 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color1);
  111043. particleSystem.color2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color2);
  111044. particleSystem.colorDead = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.colorDead);
  111045. particleSystem.updateSpeed = parsedParticleSystem.updateSpeed;
  111046. particleSystem.targetStopDuration = parsedParticleSystem.targetStopDuration;
  111047. particleSystem.blendMode = parsedParticleSystem.blendMode;
  111048. if (parsedParticleSystem.colorGradients) {
  111049. for (var _i = 0, _a = parsedParticleSystem.colorGradients; _i < _a.length; _i++) {
  111050. var colorGradient = _a[_i];
  111051. 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);
  111052. }
  111053. }
  111054. if (parsedParticleSystem.rampGradients) {
  111055. for (var _b = 0, _c = parsedParticleSystem.rampGradients; _b < _c.length; _b++) {
  111056. var rampGradient = _c[_b];
  111057. particleSystem.addRampGradient(rampGradient.gradient, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].FromArray(rampGradient.color));
  111058. }
  111059. particleSystem.useRampGradients = parsedParticleSystem.useRampGradients;
  111060. }
  111061. if (parsedParticleSystem.colorRemapGradients) {
  111062. for (var _d = 0, _e = parsedParticleSystem.colorRemapGradients; _d < _e.length; _d++) {
  111063. var colorRemapGradient = _e[_d];
  111064. particleSystem.addColorRemapGradient(colorRemapGradient.gradient, colorRemapGradient.factor1 !== undefined ? colorRemapGradient.factor1 : colorRemapGradient.factor, colorRemapGradient.factor2);
  111065. }
  111066. }
  111067. if (parsedParticleSystem.alphaRemapGradients) {
  111068. for (var _f = 0, _g = parsedParticleSystem.alphaRemapGradients; _f < _g.length; _f++) {
  111069. var alphaRemapGradient = _g[_f];
  111070. particleSystem.addAlphaRemapGradient(alphaRemapGradient.gradient, alphaRemapGradient.factor1 !== undefined ? alphaRemapGradient.factor1 : alphaRemapGradient.factor, alphaRemapGradient.factor2);
  111071. }
  111072. }
  111073. if (parsedParticleSystem.sizeGradients) {
  111074. for (var _h = 0, _j = parsedParticleSystem.sizeGradients; _h < _j.length; _h++) {
  111075. var sizeGradient = _j[_h];
  111076. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  111077. }
  111078. }
  111079. if (parsedParticleSystem.sizeGradients) {
  111080. for (var _k = 0, _l = parsedParticleSystem.sizeGradients; _k < _l.length; _k++) {
  111081. var sizeGradient = _l[_k];
  111082. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  111083. }
  111084. }
  111085. if (parsedParticleSystem.angularSpeedGradients) {
  111086. for (var _m = 0, _o = parsedParticleSystem.angularSpeedGradients; _m < _o.length; _m++) {
  111087. var angularSpeedGradient = _o[_m];
  111088. particleSystem.addAngularSpeedGradient(angularSpeedGradient.gradient, angularSpeedGradient.factor1 !== undefined ? angularSpeedGradient.factor1 : angularSpeedGradient.factor, angularSpeedGradient.factor2);
  111089. }
  111090. }
  111091. if (parsedParticleSystem.velocityGradients) {
  111092. for (var _p = 0, _q = parsedParticleSystem.velocityGradients; _p < _q.length; _p++) {
  111093. var velocityGradient = _q[_p];
  111094. particleSystem.addVelocityGradient(velocityGradient.gradient, velocityGradient.factor1 !== undefined ? velocityGradient.factor1 : velocityGradient.factor, velocityGradient.factor2);
  111095. }
  111096. }
  111097. if (parsedParticleSystem.dragGradients) {
  111098. for (var _r = 0, _s = parsedParticleSystem.dragGradients; _r < _s.length; _r++) {
  111099. var dragGradient = _s[_r];
  111100. particleSystem.addDragGradient(dragGradient.gradient, dragGradient.factor1 !== undefined ? dragGradient.factor1 : dragGradient.factor, dragGradient.factor2);
  111101. }
  111102. }
  111103. if (parsedParticleSystem.emitRateGradients) {
  111104. for (var _t = 0, _u = parsedParticleSystem.emitRateGradients; _t < _u.length; _t++) {
  111105. var emitRateGradient = _u[_t];
  111106. particleSystem.addEmitRateGradient(emitRateGradient.gradient, emitRateGradient.factor1 !== undefined ? emitRateGradient.factor1 : emitRateGradient.factor, emitRateGradient.factor2);
  111107. }
  111108. }
  111109. if (parsedParticleSystem.startSizeGradients) {
  111110. for (var _v = 0, _w = parsedParticleSystem.startSizeGradients; _v < _w.length; _v++) {
  111111. var startSizeGradient = _w[_v];
  111112. particleSystem.addStartSizeGradient(startSizeGradient.gradient, startSizeGradient.factor1 !== undefined ? startSizeGradient.factor1 : startSizeGradient.factor, startSizeGradient.factor2);
  111113. }
  111114. }
  111115. if (parsedParticleSystem.lifeTimeGradients) {
  111116. for (var _x = 0, _y = parsedParticleSystem.lifeTimeGradients; _x < _y.length; _x++) {
  111117. var lifeTimeGradient = _y[_x];
  111118. particleSystem.addLifeTimeGradient(lifeTimeGradient.gradient, lifeTimeGradient.factor1 !== undefined ? lifeTimeGradient.factor1 : lifeTimeGradient.factor, lifeTimeGradient.factor2);
  111119. }
  111120. }
  111121. if (parsedParticleSystem.limitVelocityGradients) {
  111122. for (var _z = 0, _0 = parsedParticleSystem.limitVelocityGradients; _z < _0.length; _z++) {
  111123. var limitVelocityGradient = _0[_z];
  111124. particleSystem.addLimitVelocityGradient(limitVelocityGradient.gradient, limitVelocityGradient.factor1 !== undefined ? limitVelocityGradient.factor1 : limitVelocityGradient.factor, limitVelocityGradient.factor2);
  111125. }
  111126. particleSystem.limitVelocityDamping = parsedParticleSystem.limitVelocityDamping;
  111127. }
  111128. if (parsedParticleSystem.noiseTexture) {
  111129. particleSystem.noiseTexture = _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__["ProceduralTexture"].Parse(parsedParticleSystem.noiseTexture, scene, rootUrl);
  111130. }
  111131. // Emitter
  111132. var emitterType;
  111133. if (parsedParticleSystem.particleEmitterType) {
  111134. switch (parsedParticleSystem.particleEmitterType.type) {
  111135. case "SphereParticleEmitter":
  111136. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereParticleEmitter"]();
  111137. break;
  111138. case "SphereDirectedParticleEmitter":
  111139. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereDirectedParticleEmitter"]();
  111140. break;
  111141. case "ConeEmitter":
  111142. case "ConeParticleEmitter":
  111143. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["ConeParticleEmitter"]();
  111144. break;
  111145. case "CylinderParticleEmitter":
  111146. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["CylinderParticleEmitter"]();
  111147. break;
  111148. case "HemisphericParticleEmitter":
  111149. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["HemisphericParticleEmitter"]();
  111150. break;
  111151. case "BoxEmitter":
  111152. case "BoxParticleEmitter":
  111153. default:
  111154. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  111155. break;
  111156. }
  111157. emitterType.parse(parsedParticleSystem.particleEmitterType);
  111158. }
  111159. else {
  111160. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  111161. emitterType.parse(parsedParticleSystem);
  111162. }
  111163. particleSystem.particleEmitterType = emitterType;
  111164. // Animation sheet
  111165. particleSystem.startSpriteCellID = parsedParticleSystem.startSpriteCellID;
  111166. particleSystem.endSpriteCellID = parsedParticleSystem.endSpriteCellID;
  111167. particleSystem.spriteCellWidth = parsedParticleSystem.spriteCellWidth;
  111168. particleSystem.spriteCellHeight = parsedParticleSystem.spriteCellHeight;
  111169. particleSystem.spriteCellChangeSpeed = parsedParticleSystem.spriteCellChangeSpeed;
  111170. particleSystem.spriteRandomStartCell = parsedParticleSystem.spriteRandomStartCell;
  111171. };
  111172. /**
  111173. * Parses a JSON object to create a particle system.
  111174. * @param parsedParticleSystem The JSON object to parse
  111175. * @param scene The scene to create the particle system in
  111176. * @param rootUrl The root url to use to load external dependencies like texture
  111177. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  111178. * @returns the Parsed particle system
  111179. */
  111180. ParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  111181. if (doNotStart === void 0) { doNotStart = false; }
  111182. var name = parsedParticleSystem.name;
  111183. var custom = null;
  111184. var program = null;
  111185. if (parsedParticleSystem.customShader) {
  111186. program = parsedParticleSystem.customShader;
  111187. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  111188. custom = scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  111189. }
  111190. var particleSystem = new ParticleSystem(name, parsedParticleSystem.capacity, scene, custom, parsedParticleSystem.isAnimationSheetEnabled);
  111191. particleSystem.customShader = program;
  111192. if (parsedParticleSystem.id) {
  111193. particleSystem.id = parsedParticleSystem.id;
  111194. }
  111195. // SubEmitters
  111196. if (parsedParticleSystem.subEmitters) {
  111197. particleSystem.subEmitters = [];
  111198. for (var _i = 0, _a = parsedParticleSystem.subEmitters; _i < _a.length; _i++) {
  111199. var cell = _a[_i];
  111200. var cellArray = [];
  111201. for (var _b = 0, cell_1 = cell; _b < cell_1.length; _b++) {
  111202. var sub = cell_1[_b];
  111203. cellArray.push(_subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"].Parse(sub, scene, rootUrl));
  111204. }
  111205. particleSystem.subEmitters.push(cellArray);
  111206. }
  111207. }
  111208. ParticleSystem._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  111209. particleSystem.textureMask = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.textureMask);
  111210. // Auto start
  111211. if (parsedParticleSystem.preventAutoStart) {
  111212. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  111213. }
  111214. if (!doNotStart && !particleSystem.preventAutoStart) {
  111215. particleSystem.start();
  111216. }
  111217. return particleSystem;
  111218. };
  111219. /**
  111220. * Billboard mode will only apply to Y axis
  111221. */
  111222. ParticleSystem.BILLBOARDMODE_Y = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_Y;
  111223. /**
  111224. * Billboard mode will apply to all axes
  111225. */
  111226. ParticleSystem.BILLBOARDMODE_ALL = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  111227. /**
  111228. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  111229. */
  111230. ParticleSystem.BILLBOARDMODE_STRETCHED = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_STRETCHED;
  111231. return ParticleSystem;
  111232. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__["BaseParticleSystem"]));
  111233. _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]._ParseParticleSystem = ParticleSystem.Parse;
  111234. /***/ }),
  111235. /***/ "./Particles/particleSystemComponent.ts":
  111236. /*!**********************************************!*\
  111237. !*** ./Particles/particleSystemComponent.ts ***!
  111238. \**********************************************/
  111239. /*! exports provided: _IDoNeedToBeInTheBuild */
  111240. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111241. "use strict";
  111242. __webpack_require__.r(__webpack_exports__);
  111243. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _IDoNeedToBeInTheBuild; });
  111244. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  111245. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  111246. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  111247. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  111248. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  111249. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  111250. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  111251. // Adds the parsers to the scene parsers.
  111252. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedData, scene, container, rootUrl) {
  111253. var individualParser = _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  111254. if (!individualParser) {
  111255. return;
  111256. }
  111257. // Particles Systems
  111258. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  111259. for (var index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  111260. var parsedParticleSystem = parsedData.particleSystems[index];
  111261. container.particleSystems.push(individualParser(parsedParticleSystem, scene, rootUrl));
  111262. }
  111263. }
  111264. });
  111265. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedParticleSystem, scene, rootUrl) {
  111266. if (parsedParticleSystem.activeParticleCount) {
  111267. var ps = _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__["GPUParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  111268. return ps;
  111269. }
  111270. else {
  111271. var ps = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  111272. return ps;
  111273. }
  111274. });
  111275. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createEffectForParticles = function (fragmentName, uniformsNames, samplers, defines, fallbacks, onCompiled, onError) {
  111276. if (uniformsNames === void 0) { uniformsNames = []; }
  111277. if (samplers === void 0) { samplers = []; }
  111278. if (defines === void 0) { defines = ""; }
  111279. var attributesNamesOrOptions = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetAttributeNamesOrOptions();
  111280. var effectCreationOption = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetEffectCreationOptions();
  111281. if (defines.indexOf(" BILLBOARD") === -1) {
  111282. defines += "\n#define BILLBOARD\n";
  111283. }
  111284. if (samplers.indexOf("diffuseSampler") === -1) {
  111285. samplers.push("diffuseSampler");
  111286. }
  111287. return this.createEffect({
  111288. vertex: "particles",
  111289. fragmentElement: fragmentName
  111290. }, attributesNamesOrOptions, effectCreationOption.concat(uniformsNames), samplers, defines, fallbacks, onCompiled, onError);
  111291. };
  111292. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getEmittedParticleSystems = function () {
  111293. var results = new Array();
  111294. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  111295. var particleSystem = this.getScene().particleSystems[index];
  111296. if (particleSystem.emitter === this) {
  111297. results.push(particleSystem);
  111298. }
  111299. }
  111300. return results;
  111301. };
  111302. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getHierarchyEmittedParticleSystems = function () {
  111303. var results = new Array();
  111304. var descendants = this.getDescendants();
  111305. descendants.push(this);
  111306. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  111307. var particleSystem = this.getScene().particleSystems[index];
  111308. var emitter = particleSystem.emitter;
  111309. if (emitter.position && descendants.indexOf(emitter) !== -1) {
  111310. results.push(particleSystem);
  111311. }
  111312. }
  111313. return results;
  111314. };
  111315. /**
  111316. * @hidden
  111317. */
  111318. var _IDoNeedToBeInTheBuild = 42;
  111319. /***/ }),
  111320. /***/ "./Particles/particleSystemSet.ts":
  111321. /*!****************************************!*\
  111322. !*** ./Particles/particleSystemSet.ts ***!
  111323. \****************************************/
  111324. /*! exports provided: ParticleSystemSet */
  111325. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111326. "use strict";
  111327. __webpack_require__.r(__webpack_exports__);
  111328. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return ParticleSystemSet; });
  111329. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  111330. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  111331. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  111332. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  111333. /* harmony import */ var _Particles_particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Particles/particleSystem */ "./Particles/particleSystem.ts");
  111334. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  111335. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  111336. /** Internal class used to store shapes for emitters */
  111337. var ParticleSystemSetEmitterCreationOptions = /** @class */ (function () {
  111338. function ParticleSystemSetEmitterCreationOptions() {
  111339. }
  111340. return ParticleSystemSetEmitterCreationOptions;
  111341. }());
  111342. /**
  111343. * Represents a set of particle systems working together to create a specific effect
  111344. */
  111345. var ParticleSystemSet = /** @class */ (function () {
  111346. function ParticleSystemSet() {
  111347. /**
  111348. * Gets the particle system list
  111349. */
  111350. this.systems = new Array();
  111351. }
  111352. Object.defineProperty(ParticleSystemSet.prototype, "emitterNode", {
  111353. /**
  111354. * Gets the emitter node used with this set
  111355. */
  111356. get: function () {
  111357. return this._emitterNode;
  111358. },
  111359. enumerable: true,
  111360. configurable: true
  111361. });
  111362. /**
  111363. * Creates a new emitter mesh as a sphere
  111364. * @param options defines the options used to create the sphere
  111365. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  111366. * @param scene defines the hosting scene
  111367. */
  111368. ParticleSystemSet.prototype.setEmitterAsSphere = function (options, renderingGroupId, scene) {
  111369. if (this._emitterNode) {
  111370. this._emitterNode.dispose();
  111371. }
  111372. this._emitterCreationOptions = {
  111373. kind: "Sphere",
  111374. options: options,
  111375. renderingGroupId: renderingGroupId
  111376. };
  111377. var emitterMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere("emitterSphere", { diameter: options.diameter, segments: options.segments }, scene);
  111378. emitterMesh.renderingGroupId = renderingGroupId;
  111379. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("emitterSphereMaterial", scene);
  111380. material.emissiveColor = options.color;
  111381. emitterMesh.material = material;
  111382. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  111383. var system = _a[_i];
  111384. system.emitter = emitterMesh;
  111385. }
  111386. this._emitterNode = emitterMesh;
  111387. };
  111388. /**
  111389. * Starts all particle systems of the set
  111390. * @param emitter defines an optional mesh to use as emitter for the particle systems
  111391. */
  111392. ParticleSystemSet.prototype.start = function (emitter) {
  111393. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  111394. var system = _a[_i];
  111395. if (emitter) {
  111396. system.emitter = emitter;
  111397. }
  111398. system.start();
  111399. }
  111400. };
  111401. /**
  111402. * Release all associated resources
  111403. */
  111404. ParticleSystemSet.prototype.dispose = function () {
  111405. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  111406. var system = _a[_i];
  111407. system.dispose();
  111408. }
  111409. this.systems = [];
  111410. if (this._emitterNode) {
  111411. this._emitterNode.dispose();
  111412. this._emitterNode = null;
  111413. }
  111414. };
  111415. /**
  111416. * Serialize the set into a JSON compatible object
  111417. * @returns a JSON compatible representation of the set
  111418. */
  111419. ParticleSystemSet.prototype.serialize = function () {
  111420. var result = {};
  111421. result.systems = [];
  111422. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  111423. var system = _a[_i];
  111424. result.systems.push(system.serialize());
  111425. }
  111426. if (this._emitterNode) {
  111427. result.emitter = this._emitterCreationOptions;
  111428. }
  111429. return result;
  111430. };
  111431. /**
  111432. * Parse a new ParticleSystemSet from a serialized source
  111433. * @param data defines a JSON compatible representation of the set
  111434. * @param scene defines the hosting scene
  111435. * @param gpu defines if we want GPU particles or CPU particles
  111436. * @returns a new ParticleSystemSet
  111437. */
  111438. ParticleSystemSet.Parse = function (data, scene, gpu) {
  111439. if (gpu === void 0) { gpu = false; }
  111440. var result = new ParticleSystemSet();
  111441. var rootUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].PARTICLES_BaseAssetsUrl + "/textures/";
  111442. scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  111443. for (var _i = 0, _a = data.systems; _i < _a.length; _i++) {
  111444. var system = _a[_i];
  111445. 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));
  111446. }
  111447. if (data.emitter) {
  111448. var options = data.emitter.options;
  111449. switch (data.emitter.kind) {
  111450. case "Sphere":
  111451. result.setEmitterAsSphere({
  111452. diameter: options.diameter,
  111453. segments: options.segments,
  111454. color: _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(options.color)
  111455. }, data.emitter.renderingGroupId, scene);
  111456. break;
  111457. }
  111458. }
  111459. return result;
  111460. };
  111461. return ParticleSystemSet;
  111462. }());
  111463. /***/ }),
  111464. /***/ "./Particles/solidParticle.ts":
  111465. /*!************************************!*\
  111466. !*** ./Particles/solidParticle.ts ***!
  111467. \************************************/
  111468. /*! exports provided: SolidParticle, ModelShape, DepthSortedParticle */
  111469. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111470. "use strict";
  111471. __webpack_require__.r(__webpack_exports__);
  111472. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return SolidParticle; });
  111473. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return ModelShape; });
  111474. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return DepthSortedParticle; });
  111475. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  111476. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  111477. /* harmony import */ var _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/boundingSphere */ "./Culling/boundingSphere.ts");
  111478. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  111479. /**
  111480. * Represents one particle of a solid particle system.
  111481. */
  111482. var SolidParticle = /** @class */ (function () {
  111483. /**
  111484. * Creates a Solid Particle object.
  111485. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  111486. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  111487. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  111488. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  111489. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  111490. * @param shapeId (integer) is the model shape identifier in the SPS.
  111491. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  111492. * @param sps defines the sps it is associated to
  111493. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  111494. */
  111495. function SolidParticle(particleIndex, positionIndex, indiceIndex, model, shapeId, idxInShape, sps, modelBoundingInfo) {
  111496. if (modelBoundingInfo === void 0) { modelBoundingInfo = null; }
  111497. /**
  111498. * particle global index
  111499. */
  111500. this.idx = 0;
  111501. /**
  111502. * The color of the particle
  111503. */
  111504. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  111505. /**
  111506. * The world space position of the particle.
  111507. */
  111508. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  111509. /**
  111510. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  111511. */
  111512. this.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  111513. /**
  111514. * The scaling of the particle.
  111515. */
  111516. this.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  111517. /**
  111518. * The uvs of the particle.
  111519. */
  111520. this.uvs = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  111521. /**
  111522. * The current speed of the particle.
  111523. */
  111524. this.velocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  111525. /**
  111526. * The pivot point in the particle local space.
  111527. */
  111528. this.pivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  111529. /**
  111530. * Must the particle be translated from its pivot point in its local space ?
  111531. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  111532. * Default : false
  111533. */
  111534. this.translateFromPivot = false;
  111535. /**
  111536. * Is the particle active or not ?
  111537. */
  111538. this.alive = true;
  111539. /**
  111540. * Is the particle visible or not ?
  111541. */
  111542. this.isVisible = true;
  111543. /**
  111544. * Index of this particle in the global "positions" array (Internal use)
  111545. * @hidden
  111546. */
  111547. this._pos = 0;
  111548. /**
  111549. * @hidden Index of this particle in the global "indices" array (Internal use)
  111550. */
  111551. this._ind = 0;
  111552. /**
  111553. * ModelShape id of this particle
  111554. */
  111555. this.shapeId = 0;
  111556. /**
  111557. * Index of the particle in its shape id (Internal use)
  111558. */
  111559. this.idxInShape = 0;
  111560. /**
  111561. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  111562. */
  111563. this._stillInvisible = false;
  111564. /**
  111565. * @hidden Last computed particle rotation matrix
  111566. */
  111567. this._rotationMatrix = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0];
  111568. /**
  111569. * Parent particle Id, if any.
  111570. * Default null.
  111571. */
  111572. this.parentId = null;
  111573. /**
  111574. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  111575. * The possible values are :
  111576. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  111577. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  111578. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  111579. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  111580. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  111581. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  111582. * */
  111583. this.cullingStrategy = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"].CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  111584. /**
  111585. * @hidden Internal global position in the SPS.
  111586. */
  111587. this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  111588. this.idx = particleIndex;
  111589. this._pos = positionIndex;
  111590. this._ind = indiceIndex;
  111591. this._model = model;
  111592. this.shapeId = shapeId;
  111593. this.idxInShape = idxInShape;
  111594. this._sps = sps;
  111595. if (modelBoundingInfo) {
  111596. this._modelBoundingInfo = modelBoundingInfo;
  111597. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"](modelBoundingInfo.minimum, modelBoundingInfo.maximum);
  111598. }
  111599. }
  111600. Object.defineProperty(SolidParticle.prototype, "scale", {
  111601. /**
  111602. * Legacy support, changed scale to scaling
  111603. */
  111604. get: function () {
  111605. return this.scaling;
  111606. },
  111607. /**
  111608. * Legacy support, changed scale to scaling
  111609. */
  111610. set: function (scale) {
  111611. this.scaling = scale;
  111612. },
  111613. enumerable: true,
  111614. configurable: true
  111615. });
  111616. Object.defineProperty(SolidParticle.prototype, "quaternion", {
  111617. /**
  111618. * Legacy support, changed quaternion to rotationQuaternion
  111619. */
  111620. get: function () {
  111621. return this.rotationQuaternion;
  111622. },
  111623. /**
  111624. * Legacy support, changed quaternion to rotationQuaternion
  111625. */
  111626. set: function (q) {
  111627. this.rotationQuaternion = q;
  111628. },
  111629. enumerable: true,
  111630. configurable: true
  111631. });
  111632. /**
  111633. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  111634. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  111635. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  111636. * @returns true if it intersects
  111637. */
  111638. SolidParticle.prototype.intersectsMesh = function (target) {
  111639. if (!this._boundingInfo || !target._boundingInfo) {
  111640. return false;
  111641. }
  111642. if (this._sps._bSphereOnly) {
  111643. return _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"].Intersects(this._boundingInfo.boundingSphere, target._boundingInfo.boundingSphere);
  111644. }
  111645. return this._boundingInfo.intersects(target._boundingInfo, false);
  111646. };
  111647. /**
  111648. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  111649. * A particle is in the frustum if its bounding box intersects the frustum
  111650. * @param frustumPlanes defines the frustum to test
  111651. * @returns true if the particle is in the frustum planes
  111652. */
  111653. SolidParticle.prototype.isInFrustum = function (frustumPlanes) {
  111654. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  111655. };
  111656. /**
  111657. * get the rotation matrix of the particle
  111658. * @hidden
  111659. */
  111660. SolidParticle.prototype.getRotationMatrix = function (m) {
  111661. var quaternion;
  111662. if (this.rotationQuaternion) {
  111663. quaternion = this.rotationQuaternion;
  111664. }
  111665. else {
  111666. quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  111667. var rotation = this.rotation;
  111668. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  111669. }
  111670. quaternion.toRotationMatrix(m);
  111671. };
  111672. return SolidParticle;
  111673. }());
  111674. /**
  111675. * Represents the shape of the model used by one particle of a solid particle system.
  111676. * SPS internal tool, don't use it manually.
  111677. */
  111678. var ModelShape = /** @class */ (function () {
  111679. /**
  111680. * 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.
  111681. * SPS internal tool, don't use it manually.
  111682. * @hidden
  111683. */
  111684. function ModelShape(id, shape, indicesLength, shapeUV, posFunction, vtxFunction) {
  111685. /**
  111686. * length of the shape in the model indices array (internal use)
  111687. * @hidden
  111688. */
  111689. this._indicesLength = 0;
  111690. this.shapeID = id;
  111691. this._shape = shape;
  111692. this._indicesLength = indicesLength;
  111693. this._shapeUV = shapeUV;
  111694. this._positionFunction = posFunction;
  111695. this._vertexFunction = vtxFunction;
  111696. }
  111697. return ModelShape;
  111698. }());
  111699. /**
  111700. * Represents a Depth Sorted Particle in the solid particle system.
  111701. */
  111702. var DepthSortedParticle = /** @class */ (function () {
  111703. function DepthSortedParticle() {
  111704. /**
  111705. * Index of the particle in the "indices" array
  111706. */
  111707. this.ind = 0;
  111708. /**
  111709. * Length of the particle shape in the "indices" array
  111710. */
  111711. this.indicesLength = 0;
  111712. /**
  111713. * Squared distance from the particle to the camera
  111714. */
  111715. this.sqDistance = 0.0;
  111716. }
  111717. return DepthSortedParticle;
  111718. }());
  111719. /***/ }),
  111720. /***/ "./Particles/solidParticleSystem.ts":
  111721. /*!******************************************!*\
  111722. !*** ./Particles/solidParticleSystem.ts ***!
  111723. \******************************************/
  111724. /*! exports provided: SolidParticleSystem */
  111725. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111726. "use strict";
  111727. __webpack_require__.r(__webpack_exports__);
  111728. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return SolidParticleSystem; });
  111729. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  111730. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  111731. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  111732. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  111733. /* harmony import */ var _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  111734. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  111735. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  111736. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  111737. var depthSortFunction = function (p1, p2) { return p2.sqDistance - p1.sqDistance; };
  111738. /**
  111739. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  111740. *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.
  111741. * The SPS is also a particle system. It provides some methods to manage the particles.
  111742. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  111743. *
  111744. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  111745. */
  111746. var SolidParticleSystem = /** @class */ (function () {
  111747. /**
  111748. * Creates a SPS (Solid Particle System) object.
  111749. * @param name (String) is the SPS name, this will be the underlying mesh name.
  111750. * @param scene (Scene) is the scene in which the SPS is added.
  111751. * @param options defines the options of the sps e.g.
  111752. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  111753. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  111754. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  111755. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  111756. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  111757. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  111758. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  111759. */
  111760. function SolidParticleSystem(name, scene, options) {
  111761. /**
  111762. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  111763. * Example : var p = SPS.particles[i];
  111764. */
  111765. this.particles = new Array();
  111766. /**
  111767. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  111768. */
  111769. this.nbParticles = 0;
  111770. /**
  111771. * If the particles must ever face the camera (default false). Useful for planar particles.
  111772. */
  111773. this.billboard = false;
  111774. /**
  111775. * Recompute normals when adding a shape
  111776. */
  111777. this.recomputeNormals = true;
  111778. /**
  111779. * This a counter ofr your own usage. It's not set by any SPS functions.
  111780. */
  111781. this.counter = 0;
  111782. /**
  111783. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  111784. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  111785. */
  111786. this.vars = {};
  111787. /**
  111788. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  111789. * @hidden
  111790. */
  111791. this._bSphereOnly = false;
  111792. /**
  111793. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  111794. * @hidden
  111795. */
  111796. this._bSphereRadiusFactor = 1.0;
  111797. this._positions = new Array();
  111798. this._indices = new Array();
  111799. this._normals = new Array();
  111800. this._colors = new Array();
  111801. this._uvs = new Array();
  111802. this._index = 0; // indices index
  111803. this._updatable = true;
  111804. this._pickable = false;
  111805. this._isVisibilityBoxLocked = false;
  111806. this._alwaysVisible = false;
  111807. this._depthSort = false;
  111808. this._shapeCounter = 0;
  111809. this._copy = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](0, 0, 0, null, 0, 0, this);
  111810. this._color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  111811. this._computeParticleColor = true;
  111812. this._computeParticleTexture = true;
  111813. this._computeParticleRotation = true;
  111814. this._computeParticleVertex = false;
  111815. this._computeBoundingBox = false;
  111816. this._depthSortParticles = true;
  111817. this._mustUnrotateFixedNormals = false;
  111818. this._particlesIntersect = false;
  111819. this._needs32Bits = false;
  111820. this.name = name;
  111821. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  111822. this._camera = scene.activeCamera;
  111823. this._pickable = options ? options.isPickable : false;
  111824. this._depthSort = options ? options.enableDepthSort : false;
  111825. this._particlesIntersect = options ? options.particleIntersection : false;
  111826. this._bSphereOnly = options ? options.boundingSphereOnly : false;
  111827. this._bSphereRadiusFactor = (options && options.bSphereRadiusFactor) ? options.bSphereRadiusFactor : 1.0;
  111828. if (options && options.updatable !== undefined) {
  111829. this._updatable = options.updatable;
  111830. }
  111831. else {
  111832. this._updatable = true;
  111833. }
  111834. if (this._pickable) {
  111835. this.pickedParticles = [];
  111836. }
  111837. if (this._depthSort) {
  111838. this.depthSortedParticles = [];
  111839. }
  111840. }
  111841. /**
  111842. * Builds the SPS underlying mesh. Returns a standard Mesh.
  111843. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  111844. * @returns the created mesh
  111845. */
  111846. SolidParticleSystem.prototype.buildMesh = function () {
  111847. if (this.nbParticles === 0) {
  111848. var triangle = _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__["DiscBuilder"].CreateDisc("", { radius: 1, tessellation: 3 }, this._scene);
  111849. this.addShape(triangle, 1);
  111850. triangle.dispose();
  111851. }
  111852. this._indices32 = (this._needs32Bits) ? new Uint32Array(this._indices) : new Uint16Array(this._indices);
  111853. this._positions32 = new Float32Array(this._positions);
  111854. this._uvs32 = new Float32Array(this._uvs);
  111855. this._colors32 = new Float32Array(this._colors);
  111856. if (this.recomputeNormals) {
  111857. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(this._positions32, this._indices32, this._normals);
  111858. }
  111859. this._normals32 = new Float32Array(this._normals);
  111860. this._fixedNormal32 = new Float32Array(this._normals);
  111861. if (this._mustUnrotateFixedNormals) { // the particles could be created already rotated in the mesh with a positionFunction
  111862. this._unrotateFixedNormals();
  111863. }
  111864. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  111865. vertexData.indices = (this._depthSort) ? this._indices : this._indices32;
  111866. vertexData.set(this._positions32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  111867. vertexData.set(this._normals32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  111868. if (this._uvs32.length > 0) {
  111869. vertexData.set(this._uvs32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  111870. }
  111871. if (this._colors32.length > 0) {
  111872. vertexData.set(this._colors32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  111873. }
  111874. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this.name, this._scene);
  111875. vertexData.applyToMesh(mesh, this._updatable);
  111876. this.mesh = mesh;
  111877. this.mesh.isPickable = this._pickable;
  111878. // free memory
  111879. if (!this._depthSort) {
  111880. this._indices = null;
  111881. }
  111882. this._positions = null;
  111883. this._normals = null;
  111884. this._uvs = null;
  111885. this._colors = null;
  111886. if (!this._updatable) {
  111887. this.particles.length = 0;
  111888. }
  111889. return mesh;
  111890. };
  111891. /**
  111892. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  111893. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  111894. * Thus the particles generated from `digest()` have their property `position` set yet.
  111895. * @param mesh ( Mesh ) is the mesh to be digested
  111896. * @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
  111897. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  111898. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  111899. * @returns the current SPS
  111900. */
  111901. SolidParticleSystem.prototype.digest = function (mesh, options) {
  111902. var size = (options && options.facetNb) || 1;
  111903. var number = (options && options.number) || 0;
  111904. var delta = (options && options.delta) || 0;
  111905. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  111906. var meshInd = mesh.getIndices();
  111907. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  111908. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  111909. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  111910. var f = 0; // facet counter
  111911. var totalFacets = meshInd.length / 3; // a facet is a triangle, so 3 indices
  111912. // compute size from number
  111913. if (number) {
  111914. number = (number > totalFacets) ? totalFacets : number;
  111915. size = Math.round(totalFacets / number);
  111916. delta = 0;
  111917. }
  111918. else {
  111919. size = (size > totalFacets) ? totalFacets : size;
  111920. }
  111921. var facetPos = []; // submesh positions
  111922. var facetInd = []; // submesh indices
  111923. var facetUV = []; // submesh UV
  111924. var facetCol = []; // submesh colors
  111925. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  111926. var sizeO = size;
  111927. while (f < totalFacets) {
  111928. size = sizeO + Math.floor((1 + delta) * Math.random());
  111929. if (f > totalFacets - size) {
  111930. size = totalFacets - f;
  111931. }
  111932. // reset temp arrays
  111933. facetPos.length = 0;
  111934. facetInd.length = 0;
  111935. facetUV.length = 0;
  111936. facetCol.length = 0;
  111937. // iterate over "size" facets
  111938. var fi = 0;
  111939. for (var j = f * 3; j < (f + size) * 3; j++) {
  111940. facetInd.push(fi);
  111941. var i = meshInd[j];
  111942. facetPos.push(meshPos[i * 3], meshPos[i * 3 + 1], meshPos[i * 3 + 2]);
  111943. if (meshUV) {
  111944. facetUV.push(meshUV[i * 2], meshUV[i * 2 + 1]);
  111945. }
  111946. if (meshCol) {
  111947. facetCol.push(meshCol[i * 4], meshCol[i * 4 + 1], meshCol[i * 4 + 2], meshCol[i * 4 + 3]);
  111948. }
  111949. fi++;
  111950. }
  111951. // create a model shape for each single particle
  111952. var idx = this.nbParticles;
  111953. var shape = this._posToShape(facetPos);
  111954. var shapeUV = this._uvsToShapeUV(facetUV);
  111955. // compute the barycenter of the shape
  111956. var v;
  111957. for (v = 0; v < shape.length; v++) {
  111958. barycenter.addInPlace(shape[v]);
  111959. }
  111960. barycenter.scaleInPlace(1 / shape.length);
  111961. // shift the shape from its barycenter to the origin
  111962. for (v = 0; v < shape.length; v++) {
  111963. shape[v].subtractInPlace(barycenter);
  111964. }
  111965. var bInfo;
  111966. if (this._particlesIntersect) {
  111967. bInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](barycenter, barycenter);
  111968. }
  111969. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, size * 3, shapeUV, null, null);
  111970. // add the particle in the SPS
  111971. var currentPos = this._positions.length;
  111972. var currentInd = this._indices.length;
  111973. this._meshBuilder(this._index, shape, this._positions, facetInd, this._indices, facetUV, this._uvs, facetCol, this._colors, meshNor, this._normals, idx, 0, null);
  111974. this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, 0, bInfo);
  111975. // initialize the particle position
  111976. this.particles[this.nbParticles].position.addInPlace(barycenter);
  111977. this._index += shape.length;
  111978. idx++;
  111979. this.nbParticles++;
  111980. this._shapeCounter++;
  111981. f += size;
  111982. }
  111983. return this;
  111984. };
  111985. // unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  111986. SolidParticleSystem.prototype._unrotateFixedNormals = function () {
  111987. var index = 0;
  111988. var idx = 0;
  111989. var tmpNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  111990. var quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  111991. var invertedRotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  111992. for (var p = 0; p < this.particles.length; p++) {
  111993. var particle = this.particles[p];
  111994. var shape = particle._model._shape;
  111995. // computing the inverse of the rotation matrix from the quaternion
  111996. // is equivalent to computing the matrix of the inverse quaternion, i.e of the conjugate quaternion
  111997. if (particle.rotationQuaternion) {
  111998. particle.rotationQuaternion.conjugateToRef(quaternion);
  111999. }
  112000. else {
  112001. var rotation = particle.rotation;
  112002. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  112003. quaternion.conjugateInPlace();
  112004. }
  112005. quaternion.toRotationMatrix(invertedRotMatrix);
  112006. for (var pt = 0; pt < shape.length; pt++) {
  112007. idx = index + pt * 3;
  112008. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(this._normals32[idx], this._normals32[idx + 1], this._normals32[idx + 2], invertedRotMatrix, tmpNormal);
  112009. tmpNormal.toArray(this._fixedNormal32, idx);
  112010. }
  112011. index = idx + 3;
  112012. }
  112013. };
  112014. //reset copy
  112015. SolidParticleSystem.prototype._resetCopy = function () {
  112016. var copy = this._copy;
  112017. copy.position.setAll(0);
  112018. copy.rotation.setAll(0);
  112019. copy.rotationQuaternion = null;
  112020. copy.scaling.setAll(1);
  112021. copy.uvs.copyFromFloats(0.0, 0.0, 1.0, 1.0);
  112022. copy.color = null;
  112023. copy.translateFromPivot = false;
  112024. };
  112025. // _meshBuilder : inserts the shape model in the global SPS mesh
  112026. SolidParticleSystem.prototype._meshBuilder = function (p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options) {
  112027. var i;
  112028. var u = 0;
  112029. var c = 0;
  112030. var n = 0;
  112031. this._resetCopy();
  112032. var copy = this._copy;
  112033. if (options && options.positionFunction) { // call to custom positionFunction
  112034. options.positionFunction(copy, idx, idxInShape);
  112035. this._mustUnrotateFixedNormals = true;
  112036. }
  112037. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  112038. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  112039. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  112040. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  112041. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  112042. copy.getRotationMatrix(rotMatrix);
  112043. copy.pivot.multiplyToRef(copy.scaling, scaledPivot);
  112044. if (copy.translateFromPivot) {
  112045. pivotBackTranslation.setAll(0.0);
  112046. }
  112047. else {
  112048. pivotBackTranslation.copyFrom(scaledPivot);
  112049. }
  112050. for (i = 0; i < shape.length; i++) {
  112051. tmpVertex.copyFrom(shape[i]);
  112052. if (options && options.vertexFunction) {
  112053. options.vertexFunction(copy, tmpVertex, i);
  112054. }
  112055. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  112056. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  112057. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position);
  112058. positions.push(tmpRotated.x, tmpRotated.y, tmpRotated.z);
  112059. if (meshUV) {
  112060. var copyUvs = copy.uvs;
  112061. uvs.push((copyUvs.z - copyUvs.x) * meshUV[u] + copyUvs.x, (copyUvs.w - copyUvs.y) * meshUV[u + 1] + copyUvs.y);
  112062. u += 2;
  112063. }
  112064. if (copy.color) {
  112065. this._color = copy.color;
  112066. }
  112067. else {
  112068. var color = this._color;
  112069. if (meshCol && meshCol[c] !== undefined) {
  112070. color.r = meshCol[c];
  112071. color.g = meshCol[c + 1];
  112072. color.b = meshCol[c + 2];
  112073. color.a = meshCol[c + 3];
  112074. }
  112075. else {
  112076. color.r = 1.0;
  112077. color.g = 1.0;
  112078. color.b = 1.0;
  112079. color.a = 1.0;
  112080. }
  112081. }
  112082. colors.push(this._color.r, this._color.g, this._color.b, this._color.a);
  112083. c += 4;
  112084. if (!this.recomputeNormals && meshNor) {
  112085. tmpVertex.x = meshNor[n];
  112086. tmpVertex.y = meshNor[n + 1];
  112087. tmpVertex.z = meshNor[n + 2];
  112088. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, rotMatrix, tmpVertex);
  112089. normals.push(tmpVertex.x, tmpVertex.y, tmpVertex.z);
  112090. n += 3;
  112091. }
  112092. }
  112093. for (i = 0; i < meshInd.length; i++) {
  112094. var current_ind = p + meshInd[i];
  112095. indices.push(current_ind);
  112096. if (current_ind > 65535) {
  112097. this._needs32Bits = true;
  112098. }
  112099. }
  112100. if (this._pickable) {
  112101. var nbfaces = meshInd.length / 3;
  112102. for (i = 0; i < nbfaces; i++) {
  112103. this.pickedParticles.push({ idx: idx, faceId: i });
  112104. }
  112105. }
  112106. if (this._depthSort) {
  112107. this.depthSortedParticles.push(new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["DepthSortedParticle"]());
  112108. }
  112109. return copy;
  112110. };
  112111. // returns a shape array from positions array
  112112. SolidParticleSystem.prototype._posToShape = function (positions) {
  112113. var shape = [];
  112114. for (var i = 0; i < positions.length; i += 3) {
  112115. shape.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, i));
  112116. }
  112117. return shape;
  112118. };
  112119. // returns a shapeUV array from a Vector4 uvs
  112120. SolidParticleSystem.prototype._uvsToShapeUV = function (uvs) {
  112121. var shapeUV = [];
  112122. if (uvs) {
  112123. for (var i = 0; i < uvs.length; i++) {
  112124. shapeUV.push(uvs[i]);
  112125. }
  112126. }
  112127. return shapeUV;
  112128. };
  112129. // adds a new particle object in the particles array
  112130. SolidParticleSystem.prototype._addParticle = function (idx, idxpos, idxind, model, shapeId, idxInShape, bInfo) {
  112131. if (bInfo === void 0) { bInfo = null; }
  112132. var sp = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](idx, idxpos, idxind, model, shapeId, idxInShape, this, bInfo);
  112133. this.particles.push(sp);
  112134. return sp;
  112135. };
  112136. /**
  112137. * Adds some particles to the SPS from the model shape. Returns the shape id.
  112138. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  112139. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  112140. * @param nb (positive integer) the number of particles to be created from this model
  112141. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  112142. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  112143. * @returns the number of shapes in the system
  112144. */
  112145. SolidParticleSystem.prototype.addShape = function (mesh, nb, options) {
  112146. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  112147. var meshInd = mesh.getIndices();
  112148. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  112149. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  112150. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  112151. var bbInfo;
  112152. if (this._particlesIntersect) {
  112153. bbInfo = mesh.getBoundingInfo();
  112154. }
  112155. var shape = this._posToShape(meshPos);
  112156. var shapeUV = this._uvsToShapeUV(meshUV);
  112157. var posfunc = options ? options.positionFunction : null;
  112158. var vtxfunc = options ? options.vertexFunction : null;
  112159. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, meshInd.length, shapeUV, posfunc, vtxfunc);
  112160. // particles
  112161. var sp;
  112162. var currentCopy;
  112163. var idx = this.nbParticles;
  112164. for (var i = 0; i < nb; i++) {
  112165. var currentPos = this._positions.length;
  112166. var currentInd = this._indices.length;
  112167. currentCopy = this._meshBuilder(this._index, shape, this._positions, meshInd, this._indices, meshUV, this._uvs, meshCol, this._colors, meshNor, this._normals, idx, i, options);
  112168. if (this._updatable) {
  112169. sp = this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, i, bbInfo);
  112170. sp.position.copyFrom(currentCopy.position);
  112171. sp.rotation.copyFrom(currentCopy.rotation);
  112172. if (currentCopy.rotationQuaternion && sp.rotationQuaternion) {
  112173. sp.rotationQuaternion.copyFrom(currentCopy.rotationQuaternion);
  112174. }
  112175. if (currentCopy.color && sp.color) {
  112176. sp.color.copyFrom(currentCopy.color);
  112177. }
  112178. sp.scaling.copyFrom(currentCopy.scaling);
  112179. sp.uvs.copyFrom(currentCopy.uvs);
  112180. }
  112181. this._index += shape.length;
  112182. idx++;
  112183. }
  112184. this.nbParticles += nb;
  112185. this._shapeCounter++;
  112186. return this._shapeCounter - 1;
  112187. };
  112188. // rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  112189. SolidParticleSystem.prototype._rebuildParticle = function (particle) {
  112190. this._resetCopy();
  112191. var copy = this._copy;
  112192. if (particle._model._positionFunction) { // recall to stored custom positionFunction
  112193. particle._model._positionFunction(copy, particle.idx, particle.idxInShape);
  112194. }
  112195. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  112196. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  112197. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  112198. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  112199. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  112200. copy.getRotationMatrix(rotMatrix);
  112201. particle.pivot.multiplyToRef(particle.scaling, scaledPivot);
  112202. if (copy.translateFromPivot) {
  112203. pivotBackTranslation.copyFromFloats(0.0, 0.0, 0.0);
  112204. }
  112205. else {
  112206. pivotBackTranslation.copyFrom(scaledPivot);
  112207. }
  112208. var shape = particle._model._shape;
  112209. for (var pt = 0; pt < shape.length; pt++) {
  112210. tmpVertex.copyFrom(shape[pt]);
  112211. if (particle._model._vertexFunction) {
  112212. particle._model._vertexFunction(copy, tmpVertex, pt); // recall to stored vertexFunction
  112213. }
  112214. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  112215. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  112216. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position).toArray(this._positions32, particle._pos + pt * 3);
  112217. }
  112218. particle.position.setAll(0.0);
  112219. particle.rotation.setAll(0.0);
  112220. particle.rotationQuaternion = null;
  112221. particle.scaling.setAll(1.0);
  112222. particle.uvs.setAll(0.0);
  112223. particle.pivot.setAll(0.0);
  112224. particle.translateFromPivot = false;
  112225. particle.parentId = null;
  112226. };
  112227. /**
  112228. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  112229. * @returns the SPS.
  112230. */
  112231. SolidParticleSystem.prototype.rebuildMesh = function () {
  112232. for (var p = 0; p < this.particles.length; p++) {
  112233. this._rebuildParticle(this.particles[p]);
  112234. }
  112235. this.mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this._positions32, false, false);
  112236. return this;
  112237. };
  112238. /**
  112239. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  112240. * This method calls `updateParticle()` for each particle of the SPS.
  112241. * For an animated SPS, it is usually called within the render loop.
  112242. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  112243. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  112244. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  112245. * @returns the SPS.
  112246. */
  112247. SolidParticleSystem.prototype.setParticles = function (start, end, update) {
  112248. if (start === void 0) { start = 0; }
  112249. if (end === void 0) { end = this.nbParticles - 1; }
  112250. if (update === void 0) { update = true; }
  112251. if (!this._updatable) {
  112252. return this;
  112253. }
  112254. // custom beforeUpdate
  112255. this.beforeUpdateParticles(start, end, update);
  112256. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  112257. var invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  112258. var mesh = this.mesh;
  112259. var colors32 = this._colors32;
  112260. var positions32 = this._positions32;
  112261. var normals32 = this._normals32;
  112262. var uvs32 = this._uvs32;
  112263. var indices32 = this._indices32;
  112264. var indices = this._indices;
  112265. var fixedNormal32 = this._fixedNormal32;
  112266. var tempVectors = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3;
  112267. var camAxisX = tempVectors[5].copyFromFloats(1.0, 0.0, 0.0);
  112268. var camAxisY = tempVectors[6].copyFromFloats(0.0, 1.0, 0.0);
  112269. var camAxisZ = tempVectors[7].copyFromFloats(0.0, 0.0, 1.0);
  112270. var minimum = tempVectors[8].setAll(Number.MAX_VALUE);
  112271. var maximum = tempVectors[9].setAll(-Number.MAX_VALUE);
  112272. var camInvertedPosition = tempVectors[10].setAll(0);
  112273. // cases when the World Matrix is to be computed first
  112274. if (this.billboard || this._depthSort) {
  112275. this.mesh.computeWorldMatrix(true);
  112276. this.mesh._worldMatrix.invertToRef(invertedMatrix);
  112277. }
  112278. // if the particles will always face the camera
  112279. if (this.billboard) {
  112280. // compute the camera position and un-rotate it by the current mesh rotation
  112281. var tmpVertex = tempVectors[0];
  112282. this._camera.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Z, tmpVertex);
  112283. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, invertedMatrix, camAxisZ);
  112284. camAxisZ.normalize();
  112285. // same for camera up vector extracted from the cam view matrix
  112286. var view = this._camera.getViewMatrix(true);
  112287. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(view.m[1], view.m[5], view.m[9], invertedMatrix, camAxisY);
  112288. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(camAxisY, camAxisZ, camAxisX);
  112289. camAxisY.normalize();
  112290. camAxisX.normalize();
  112291. }
  112292. // if depthSort, compute the camera global position in the mesh local system
  112293. if (this._depthSort) {
  112294. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._camera.globalPosition, invertedMatrix, camInvertedPosition); // then un-rotate the camera
  112295. }
  112296. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(rotMatrix);
  112297. var idx = 0; // current position index in the global array positions32
  112298. var index = 0; // position start index in the global array positions32 of the current particle
  112299. var colidx = 0; // current color index in the global array colors32
  112300. var colorIndex = 0; // color start index in the global array colors32 of the current particle
  112301. var uvidx = 0; // current uv index in the global array uvs32
  112302. var uvIndex = 0; // uv start index in the global array uvs32 of the current particle
  112303. var pt = 0; // current index in the particle model shape
  112304. if (this.mesh.isFacetDataEnabled) {
  112305. this._computeBoundingBox = true;
  112306. }
  112307. end = (end >= this.nbParticles) ? this.nbParticles - 1 : end;
  112308. if (this._computeBoundingBox) {
  112309. if (start != 0 || end != this.nbParticles - 1) { // only some particles are updated, then use the current existing BBox basis. Note : it can only increase.
  112310. var boundingInfo = this.mesh._boundingInfo;
  112311. if (boundingInfo) {
  112312. minimum.copyFrom(boundingInfo.minimum);
  112313. maximum.copyFrom(boundingInfo.maximum);
  112314. }
  112315. }
  112316. }
  112317. // particle loop
  112318. index = this.particles[start]._pos;
  112319. var vpos = (index / 3) | 0;
  112320. colorIndex = vpos * 4;
  112321. uvIndex = vpos * 2;
  112322. for (var p = start; p <= end; p++) {
  112323. var particle = this.particles[p];
  112324. // call to custom user function to update the particle properties
  112325. this.updateParticle(particle);
  112326. var shape = particle._model._shape;
  112327. var shapeUV = particle._model._shapeUV;
  112328. var particleRotationMatrix = particle._rotationMatrix;
  112329. var particlePosition = particle.position;
  112330. var particleRotation = particle.rotation;
  112331. var particleScaling = particle.scaling;
  112332. var particleGlobalPosition = particle._globalPosition;
  112333. // camera-particle distance for depth sorting
  112334. if (this._depthSort && this._depthSortParticles) {
  112335. var dsp = this.depthSortedParticles[p];
  112336. dsp.ind = particle._ind;
  112337. dsp.indicesLength = particle._model._indicesLength;
  112338. dsp.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(particle.position, camInvertedPosition);
  112339. }
  112340. // skip the computations for inactive or already invisible particles
  112341. if (!particle.alive || (particle._stillInvisible && !particle.isVisible)) {
  112342. // increment indexes for the next particle
  112343. pt = shape.length;
  112344. index += pt * 3;
  112345. colorIndex += pt * 4;
  112346. uvIndex += pt * 2;
  112347. continue;
  112348. }
  112349. if (particle.isVisible) {
  112350. particle._stillInvisible = false; // un-mark permanent invisibility
  112351. var scaledPivot = tempVectors[12];
  112352. particle.pivot.multiplyToRef(particleScaling, scaledPivot);
  112353. // particle rotation matrix
  112354. if (this.billboard) {
  112355. particleRotation.x = 0.0;
  112356. particleRotation.y = 0.0;
  112357. }
  112358. if (this._computeParticleRotation || this.billboard) {
  112359. particle.getRotationMatrix(rotMatrix);
  112360. }
  112361. var particleHasParent = (particle.parentId !== null);
  112362. if (particleHasParent) {
  112363. var parent_1 = this.particles[particle.parentId];
  112364. var parentRotationMatrix = parent_1._rotationMatrix;
  112365. var parentGlobalPosition = parent_1._globalPosition;
  112366. var rotatedY = particlePosition.x * parentRotationMatrix[1] + particlePosition.y * parentRotationMatrix[4] + particlePosition.z * parentRotationMatrix[7];
  112367. var rotatedX = particlePosition.x * parentRotationMatrix[0] + particlePosition.y * parentRotationMatrix[3] + particlePosition.z * parentRotationMatrix[6];
  112368. var rotatedZ = particlePosition.x * parentRotationMatrix[2] + particlePosition.y * parentRotationMatrix[5] + particlePosition.z * parentRotationMatrix[8];
  112369. particleGlobalPosition.x = parentGlobalPosition.x + rotatedX;
  112370. particleGlobalPosition.y = parentGlobalPosition.y + rotatedY;
  112371. particleGlobalPosition.z = parentGlobalPosition.z + rotatedZ;
  112372. if (this._computeParticleRotation || this.billboard) {
  112373. var rotMatrixValues = rotMatrix.m;
  112374. particleRotationMatrix[0] = rotMatrixValues[0] * parentRotationMatrix[0] + rotMatrixValues[1] * parentRotationMatrix[3] + rotMatrixValues[2] * parentRotationMatrix[6];
  112375. particleRotationMatrix[1] = rotMatrixValues[0] * parentRotationMatrix[1] + rotMatrixValues[1] * parentRotationMatrix[4] + rotMatrixValues[2] * parentRotationMatrix[7];
  112376. particleRotationMatrix[2] = rotMatrixValues[0] * parentRotationMatrix[2] + rotMatrixValues[1] * parentRotationMatrix[5] + rotMatrixValues[2] * parentRotationMatrix[8];
  112377. particleRotationMatrix[3] = rotMatrixValues[4] * parentRotationMatrix[0] + rotMatrixValues[5] * parentRotationMatrix[3] + rotMatrixValues[6] * parentRotationMatrix[6];
  112378. particleRotationMatrix[4] = rotMatrixValues[4] * parentRotationMatrix[1] + rotMatrixValues[5] * parentRotationMatrix[4] + rotMatrixValues[6] * parentRotationMatrix[7];
  112379. particleRotationMatrix[5] = rotMatrixValues[4] * parentRotationMatrix[2] + rotMatrixValues[5] * parentRotationMatrix[5] + rotMatrixValues[6] * parentRotationMatrix[8];
  112380. particleRotationMatrix[6] = rotMatrixValues[8] * parentRotationMatrix[0] + rotMatrixValues[9] * parentRotationMatrix[3] + rotMatrixValues[10] * parentRotationMatrix[6];
  112381. particleRotationMatrix[7] = rotMatrixValues[8] * parentRotationMatrix[1] + rotMatrixValues[9] * parentRotationMatrix[4] + rotMatrixValues[10] * parentRotationMatrix[7];
  112382. particleRotationMatrix[8] = rotMatrixValues[8] * parentRotationMatrix[2] + rotMatrixValues[9] * parentRotationMatrix[5] + rotMatrixValues[10] * parentRotationMatrix[8];
  112383. }
  112384. }
  112385. else {
  112386. particleGlobalPosition.x = particlePosition.x;
  112387. particleGlobalPosition.y = particlePosition.y;
  112388. particleGlobalPosition.z = particlePosition.z;
  112389. if (this._computeParticleRotation || this.billboard) {
  112390. var rotMatrixValues = rotMatrix.m;
  112391. particleRotationMatrix[0] = rotMatrixValues[0];
  112392. particleRotationMatrix[1] = rotMatrixValues[1];
  112393. particleRotationMatrix[2] = rotMatrixValues[2];
  112394. particleRotationMatrix[3] = rotMatrixValues[4];
  112395. particleRotationMatrix[4] = rotMatrixValues[5];
  112396. particleRotationMatrix[5] = rotMatrixValues[6];
  112397. particleRotationMatrix[6] = rotMatrixValues[8];
  112398. particleRotationMatrix[7] = rotMatrixValues[9];
  112399. particleRotationMatrix[8] = rotMatrixValues[10];
  112400. }
  112401. }
  112402. var pivotBackTranslation = tempVectors[11];
  112403. if (particle.translateFromPivot) {
  112404. pivotBackTranslation.setAll(0.0);
  112405. }
  112406. else {
  112407. pivotBackTranslation.copyFrom(scaledPivot);
  112408. }
  112409. // particle vertex loop
  112410. for (pt = 0; pt < shape.length; pt++) {
  112411. idx = index + pt * 3;
  112412. colidx = colorIndex + pt * 4;
  112413. uvidx = uvIndex + pt * 2;
  112414. var tmpVertex = tempVectors[0];
  112415. tmpVertex.copyFrom(shape[pt]);
  112416. if (this._computeParticleVertex) {
  112417. this.updateParticleVertex(particle, tmpVertex, pt);
  112418. }
  112419. // positions
  112420. var vertexX = tmpVertex.x * particleScaling.x - scaledPivot.x;
  112421. var vertexY = tmpVertex.y * particleScaling.y - scaledPivot.y;
  112422. var vertexZ = tmpVertex.z * particleScaling.z - scaledPivot.z;
  112423. var rotatedX = vertexX * particleRotationMatrix[0] + vertexY * particleRotationMatrix[3] + vertexZ * particleRotationMatrix[6];
  112424. var rotatedY = vertexX * particleRotationMatrix[1] + vertexY * particleRotationMatrix[4] + vertexZ * particleRotationMatrix[7];
  112425. var rotatedZ = vertexX * particleRotationMatrix[2] + vertexY * particleRotationMatrix[5] + vertexZ * particleRotationMatrix[8];
  112426. rotatedX += pivotBackTranslation.x;
  112427. rotatedY += pivotBackTranslation.y;
  112428. rotatedZ += pivotBackTranslation.z;
  112429. var px = positions32[idx] = particleGlobalPosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  112430. var py = positions32[idx + 1] = particleGlobalPosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  112431. var pz = positions32[idx + 2] = particleGlobalPosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  112432. if (this._computeBoundingBox) {
  112433. minimum.minimizeInPlaceFromFloats(px, py, pz);
  112434. maximum.maximizeInPlaceFromFloats(px, py, pz);
  112435. }
  112436. // normals : if the particles can't be morphed then just rotate the normals, what is much more faster than ComputeNormals()
  112437. if (!this._computeParticleVertex) {
  112438. var normalx = fixedNormal32[idx];
  112439. var normaly = fixedNormal32[idx + 1];
  112440. var normalz = fixedNormal32[idx + 2];
  112441. var rotatedx = normalx * particleRotationMatrix[0] + normaly * particleRotationMatrix[3] + normalz * particleRotationMatrix[6];
  112442. var rotatedy = normalx * particleRotationMatrix[1] + normaly * particleRotationMatrix[4] + normalz * particleRotationMatrix[7];
  112443. var rotatedz = normalx * particleRotationMatrix[2] + normaly * particleRotationMatrix[5] + normalz * particleRotationMatrix[8];
  112444. normals32[idx] = camAxisX.x * rotatedx + camAxisY.x * rotatedy + camAxisZ.x * rotatedz;
  112445. normals32[idx + 1] = camAxisX.y * rotatedx + camAxisY.y * rotatedy + camAxisZ.y * rotatedz;
  112446. normals32[idx + 2] = camAxisX.z * rotatedx + camAxisY.z * rotatedy + camAxisZ.z * rotatedz;
  112447. }
  112448. if (this._computeParticleColor && particle.color) {
  112449. var color = particle.color;
  112450. var colors32_1 = this._colors32;
  112451. colors32_1[colidx] = color.r;
  112452. colors32_1[colidx + 1] = color.g;
  112453. colors32_1[colidx + 2] = color.b;
  112454. colors32_1[colidx + 3] = color.a;
  112455. }
  112456. if (this._computeParticleTexture) {
  112457. var uvs = particle.uvs;
  112458. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  112459. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  112460. }
  112461. }
  112462. }
  112463. // particle just set invisible : scaled to zero and positioned at the origin
  112464. else {
  112465. particle._stillInvisible = true; // mark the particle as invisible
  112466. for (pt = 0; pt < shape.length; pt++) {
  112467. idx = index + pt * 3;
  112468. colidx = colorIndex + pt * 4;
  112469. uvidx = uvIndex + pt * 2;
  112470. positions32[idx] = positions32[idx + 1] = positions32[idx + 2] = 0;
  112471. normals32[idx] = normals32[idx + 1] = normals32[idx + 2] = 0;
  112472. if (this._computeParticleColor && particle.color) {
  112473. var color = particle.color;
  112474. colors32[colidx] = color.r;
  112475. colors32[colidx + 1] = color.g;
  112476. colors32[colidx + 2] = color.b;
  112477. colors32[colidx + 3] = color.a;
  112478. }
  112479. if (this._computeParticleTexture) {
  112480. var uvs = particle.uvs;
  112481. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  112482. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  112483. }
  112484. }
  112485. }
  112486. // if the particle intersections must be computed : update the bbInfo
  112487. if (this._particlesIntersect) {
  112488. var bInfo = particle._boundingInfo;
  112489. var bBox = bInfo.boundingBox;
  112490. var bSphere = bInfo.boundingSphere;
  112491. var modelBoundingInfo = particle._modelBoundingInfo;
  112492. if (!this._bSphereOnly) {
  112493. // place, scale and rotate the particle bbox within the SPS local system, then update it
  112494. var modelBoundingInfoVectors = modelBoundingInfo.boundingBox.vectors;
  112495. var tempMin = tempVectors[1];
  112496. var tempMax = tempVectors[2];
  112497. tempMin.setAll(Number.MAX_VALUE);
  112498. tempMax.setAll(-Number.MAX_VALUE);
  112499. for (var b = 0; b < 8; b++) {
  112500. var scaledX = modelBoundingInfoVectors[b].x * particleScaling.x;
  112501. var scaledY = modelBoundingInfoVectors[b].y * particleScaling.y;
  112502. var scaledZ = modelBoundingInfoVectors[b].z * particleScaling.z;
  112503. var rotatedX = scaledX * particleRotationMatrix[0] + scaledY * particleRotationMatrix[3] + scaledZ * particleRotationMatrix[6];
  112504. var rotatedY = scaledX * particleRotationMatrix[1] + scaledY * particleRotationMatrix[4] + scaledZ * particleRotationMatrix[7];
  112505. var rotatedZ = scaledX * particleRotationMatrix[2] + scaledY * particleRotationMatrix[5] + scaledZ * particleRotationMatrix[8];
  112506. var x = particlePosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  112507. var y = particlePosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  112508. var z = particlePosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  112509. tempMin.minimizeInPlaceFromFloats(x, y, z);
  112510. tempMax.maximizeInPlaceFromFloats(x, y, z);
  112511. }
  112512. bBox.reConstruct(tempMin, tempMax, mesh._worldMatrix);
  112513. }
  112514. // place and scale the particle bouding sphere in the SPS local system, then update it
  112515. var minBbox = modelBoundingInfo.minimum.multiplyToRef(particleScaling, tempVectors[1]);
  112516. var maxBbox = modelBoundingInfo.maximum.multiplyToRef(particleScaling, tempVectors[2]);
  112517. var bSphereCenter = maxBbox.addToRef(minBbox, tempVectors[3]).scaleInPlace(0.5).addInPlace(particleGlobalPosition);
  112518. var halfDiag = maxBbox.subtractToRef(minBbox, tempVectors[4]).scaleInPlace(0.5 * this._bSphereRadiusFactor);
  112519. var bSphereMinBbox = bSphereCenter.subtractToRef(halfDiag, tempVectors[1]);
  112520. var bSphereMaxBbox = bSphereCenter.addToRef(halfDiag, tempVectors[2]);
  112521. bSphere.reConstruct(bSphereMinBbox, bSphereMaxBbox, mesh._worldMatrix);
  112522. }
  112523. // increment indexes for the next particle
  112524. index = idx + 3;
  112525. colorIndex = colidx + 4;
  112526. uvIndex = uvidx + 2;
  112527. }
  112528. // if the VBO must be updated
  112529. if (update) {
  112530. if (this._computeParticleColor) {
  112531. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, colors32, false, false);
  112532. }
  112533. if (this._computeParticleTexture) {
  112534. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs32, false, false);
  112535. }
  112536. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, positions32, false, false);
  112537. if (!mesh.areNormalsFrozen || mesh.isFacetDataEnabled) {
  112538. if (this._computeParticleVertex || mesh.isFacetDataEnabled) {
  112539. // recompute the normals only if the particles can be morphed, update then also the normal reference array _fixedNormal32[]
  112540. var params = mesh.isFacetDataEnabled ? mesh.getFacetDataParameters() : null;
  112541. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions32, indices32, normals32, params);
  112542. for (var i = 0; i < normals32.length; i++) {
  112543. fixedNormal32[i] = normals32[i];
  112544. }
  112545. }
  112546. if (!mesh.areNormalsFrozen) {
  112547. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals32, false, false);
  112548. }
  112549. }
  112550. if (this._depthSort && this._depthSortParticles) {
  112551. var depthSortedParticles = this.depthSortedParticles;
  112552. depthSortedParticles.sort(depthSortFunction);
  112553. var dspl = depthSortedParticles.length;
  112554. var sid = 0;
  112555. for (var sorted = 0; sorted < dspl; sorted++) {
  112556. var lind = depthSortedParticles[sorted].indicesLength;
  112557. var sind = depthSortedParticles[sorted].ind;
  112558. for (var i = 0; i < lind; i++) {
  112559. indices32[sid] = indices[sind + i];
  112560. sid++;
  112561. }
  112562. }
  112563. mesh.updateIndices(indices32);
  112564. }
  112565. }
  112566. if (this._computeBoundingBox) {
  112567. if (mesh._boundingInfo) {
  112568. mesh._boundingInfo.reConstruct(minimum, maximum, mesh._worldMatrix);
  112569. }
  112570. else {
  112571. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](minimum, maximum, mesh._worldMatrix);
  112572. }
  112573. }
  112574. this.afterUpdateParticles(start, end, update);
  112575. return this;
  112576. };
  112577. /**
  112578. * Disposes the SPS.
  112579. */
  112580. SolidParticleSystem.prototype.dispose = function () {
  112581. this.mesh.dispose();
  112582. this.vars = null;
  112583. // drop references to internal big arrays for the GC
  112584. this._positions = null;
  112585. this._indices = null;
  112586. this._normals = null;
  112587. this._uvs = null;
  112588. this._colors = null;
  112589. this._indices32 = null;
  112590. this._positions32 = null;
  112591. this._normals32 = null;
  112592. this._fixedNormal32 = null;
  112593. this._uvs32 = null;
  112594. this._colors32 = null;
  112595. this.pickedParticles = null;
  112596. };
  112597. /**
  112598. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  112599. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  112600. * @returns the SPS.
  112601. */
  112602. SolidParticleSystem.prototype.refreshVisibleSize = function () {
  112603. if (!this._isVisibilityBoxLocked) {
  112604. this.mesh.refreshBoundingInfo();
  112605. }
  112606. return this;
  112607. };
  112608. /**
  112609. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  112610. * @param size the size (float) of the visibility box
  112611. * note : this doesn't lock the SPS mesh bounding box.
  112612. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  112613. */
  112614. SolidParticleSystem.prototype.setVisibilityBox = function (size) {
  112615. var vis = size / 2;
  112616. 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));
  112617. };
  112618. Object.defineProperty(SolidParticleSystem.prototype, "isAlwaysVisible", {
  112619. /**
  112620. * Gets whether the SPS as always visible or not
  112621. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  112622. */
  112623. get: function () {
  112624. return this._alwaysVisible;
  112625. },
  112626. /**
  112627. * Sets the SPS as always visible or not
  112628. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  112629. */
  112630. set: function (val) {
  112631. this._alwaysVisible = val;
  112632. this.mesh.alwaysSelectAsActiveMesh = val;
  112633. },
  112634. enumerable: true,
  112635. configurable: true
  112636. });
  112637. Object.defineProperty(SolidParticleSystem.prototype, "isVisibilityBoxLocked", {
  112638. /**
  112639. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  112640. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  112641. */
  112642. get: function () {
  112643. return this._isVisibilityBoxLocked;
  112644. },
  112645. /**
  112646. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  112647. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  112648. */
  112649. set: function (val) {
  112650. this._isVisibilityBoxLocked = val;
  112651. var boundingInfo = this.mesh.getBoundingInfo();
  112652. boundingInfo.isLocked = val;
  112653. },
  112654. enumerable: true,
  112655. configurable: true
  112656. });
  112657. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleRotation", {
  112658. /**
  112659. * Gets if `setParticles()` computes the particle rotations or not.
  112660. * Default value : true. The SPS is faster when it's set to false.
  112661. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  112662. */
  112663. get: function () {
  112664. return this._computeParticleRotation;
  112665. },
  112666. /**
  112667. * Tells to `setParticles()` to compute the particle rotations or not.
  112668. * Default value : true. The SPS is faster when it's set to false.
  112669. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  112670. */
  112671. set: function (val) {
  112672. this._computeParticleRotation = val;
  112673. },
  112674. enumerable: true,
  112675. configurable: true
  112676. });
  112677. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleColor", {
  112678. /**
  112679. * Gets if `setParticles()` computes the particle colors or not.
  112680. * Default value : true. The SPS is faster when it's set to false.
  112681. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  112682. */
  112683. get: function () {
  112684. return this._computeParticleColor;
  112685. },
  112686. /**
  112687. * Tells to `setParticles()` to compute the particle colors or not.
  112688. * Default value : true. The SPS is faster when it's set to false.
  112689. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  112690. */
  112691. set: function (val) {
  112692. this._computeParticleColor = val;
  112693. },
  112694. enumerable: true,
  112695. configurable: true
  112696. });
  112697. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleTexture", {
  112698. /**
  112699. * Gets if `setParticles()` computes the particle textures or not.
  112700. * Default value : true. The SPS is faster when it's set to false.
  112701. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  112702. */
  112703. get: function () {
  112704. return this._computeParticleTexture;
  112705. },
  112706. set: function (val) {
  112707. this._computeParticleTexture = val;
  112708. },
  112709. enumerable: true,
  112710. configurable: true
  112711. });
  112712. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleVertex", {
  112713. /**
  112714. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  112715. * Default value : false. The SPS is faster when it's set to false.
  112716. * Note : the particle custom vertex positions aren't stored values.
  112717. */
  112718. get: function () {
  112719. return this._computeParticleVertex;
  112720. },
  112721. /**
  112722. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  112723. * Default value : false. The SPS is faster when it's set to false.
  112724. * Note : the particle custom vertex positions aren't stored values.
  112725. */
  112726. set: function (val) {
  112727. this._computeParticleVertex = val;
  112728. },
  112729. enumerable: true,
  112730. configurable: true
  112731. });
  112732. Object.defineProperty(SolidParticleSystem.prototype, "computeBoundingBox", {
  112733. /**
  112734. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  112735. */
  112736. get: function () {
  112737. return this._computeBoundingBox;
  112738. },
  112739. /**
  112740. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  112741. */
  112742. set: function (val) {
  112743. this._computeBoundingBox = val;
  112744. },
  112745. enumerable: true,
  112746. configurable: true
  112747. });
  112748. Object.defineProperty(SolidParticleSystem.prototype, "depthSortParticles", {
  112749. /**
  112750. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  112751. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  112752. * Default : `true`
  112753. */
  112754. get: function () {
  112755. return this._depthSortParticles;
  112756. },
  112757. /**
  112758. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  112759. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  112760. * Default : `true`
  112761. */
  112762. set: function (val) {
  112763. this._depthSortParticles = val;
  112764. },
  112765. enumerable: true,
  112766. configurable: true
  112767. });
  112768. // =======================================================================
  112769. // Particle behavior logic
  112770. // these following methods may be overwritten by the user to fit his needs
  112771. /**
  112772. * This function does nothing. It may be overwritten to set all the particle first values.
  112773. * The SPS doesn't call this function, you may have to call it by your own.
  112774. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  112775. */
  112776. SolidParticleSystem.prototype.initParticles = function () {
  112777. };
  112778. /**
  112779. * This function does nothing. It may be overwritten to recycle a particle.
  112780. * The SPS doesn't call this function, you may have to call it by your own.
  112781. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  112782. * @param particle The particle to recycle
  112783. * @returns the recycled particle
  112784. */
  112785. SolidParticleSystem.prototype.recycleParticle = function (particle) {
  112786. return particle;
  112787. };
  112788. /**
  112789. * Updates a particle : this function should be overwritten by the user.
  112790. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  112791. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  112792. * @example : just set a particle position or velocity and recycle conditions
  112793. * @param particle The particle to update
  112794. * @returns the updated particle
  112795. */
  112796. SolidParticleSystem.prototype.updateParticle = function (particle) {
  112797. return particle;
  112798. };
  112799. /**
  112800. * Updates a vertex of a particle : it can be overwritten by the user.
  112801. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  112802. * @param particle the current particle
  112803. * @param vertex the current index of the current particle
  112804. * @param pt the index of the current vertex in the particle shape
  112805. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  112806. * @example : just set a vertex particle position
  112807. * @returns the updated vertex
  112808. */
  112809. SolidParticleSystem.prototype.updateParticleVertex = function (particle, vertex, pt) {
  112810. return vertex;
  112811. };
  112812. /**
  112813. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  112814. * This does nothing and may be overwritten by the user.
  112815. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  112816. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  112817. * @param update the boolean update value actually passed to setParticles()
  112818. */
  112819. SolidParticleSystem.prototype.beforeUpdateParticles = function (start, stop, update) {
  112820. };
  112821. /**
  112822. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  112823. * This will be passed three parameters.
  112824. * This does nothing and may be overwritten by the user.
  112825. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  112826. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  112827. * @param update the boolean update value actually passed to setParticles()
  112828. */
  112829. SolidParticleSystem.prototype.afterUpdateParticles = function (start, stop, update) {
  112830. };
  112831. return SolidParticleSystem;
  112832. }());
  112833. /***/ }),
  112834. /***/ "./Particles/subEmitter.ts":
  112835. /*!*********************************!*\
  112836. !*** ./Particles/subEmitter.ts ***!
  112837. \*********************************/
  112838. /*! exports provided: SubEmitterType, SubEmitter */
  112839. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112840. "use strict";
  112841. __webpack_require__.r(__webpack_exports__);
  112842. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return SubEmitterType; });
  112843. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return SubEmitter; });
  112844. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  112845. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  112846. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  112847. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  112848. /**
  112849. * Type of sub emitter
  112850. */
  112851. var SubEmitterType;
  112852. (function (SubEmitterType) {
  112853. /**
  112854. * Attached to the particle over it's lifetime
  112855. */
  112856. SubEmitterType[SubEmitterType["ATTACHED"] = 0] = "ATTACHED";
  112857. /**
  112858. * Created when the particle dies
  112859. */
  112860. SubEmitterType[SubEmitterType["END"] = 1] = "END";
  112861. })(SubEmitterType || (SubEmitterType = {}));
  112862. /**
  112863. * Sub emitter class used to emit particles from an existing particle
  112864. */
  112865. var SubEmitter = /** @class */ (function () {
  112866. /**
  112867. * Creates a sub emitter
  112868. * @param particleSystem the particle system to be used by the sub emitter
  112869. */
  112870. function SubEmitter(
  112871. /**
  112872. * the particle system to be used by the sub emitter
  112873. */
  112874. particleSystem) {
  112875. this.particleSystem = particleSystem;
  112876. /**
  112877. * Type of the submitter (Default: END)
  112878. */
  112879. this.type = SubEmitterType.END;
  112880. /**
  112881. * 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)
  112882. * Note: This only is supported when using an emitter of type Mesh
  112883. */
  112884. this.inheritDirection = false;
  112885. /**
  112886. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  112887. */
  112888. this.inheritedVelocityAmount = 0;
  112889. // Create mesh as emitter to support rotation
  112890. if (!particleSystem.emitter || !particleSystem.emitter.dispose) {
  112891. particleSystem.emitter = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("SubemitterSystemEmitter", particleSystem.getScene());
  112892. }
  112893. // Automatically dispose of subemitter when system is disposed
  112894. particleSystem.onDisposeObservable.add(function () {
  112895. if (particleSystem.emitter && particleSystem.emitter.dispose) {
  112896. particleSystem.emitter.dispose();
  112897. }
  112898. });
  112899. }
  112900. /**
  112901. * Clones the sub emitter
  112902. * @returns the cloned sub emitter
  112903. */
  112904. SubEmitter.prototype.clone = function () {
  112905. // Clone particle system
  112906. var emitter = this.particleSystem.emitter;
  112907. if (!emitter) {
  112908. emitter = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  112909. }
  112910. else if (emitter instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  112911. emitter = emitter.clone();
  112912. }
  112913. else if (emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  112914. emitter = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", emitter.getScene());
  112915. emitter.isVisible = false;
  112916. }
  112917. var clone = new SubEmitter(this.particleSystem.clone("", emitter));
  112918. // Clone properties
  112919. clone.type = this.type;
  112920. clone.inheritDirection = this.inheritDirection;
  112921. clone.inheritedVelocityAmount = this.inheritedVelocityAmount;
  112922. clone.particleSystem._disposeEmitterOnDispose = true;
  112923. clone.particleSystem.disposeOnStop = true;
  112924. return clone;
  112925. };
  112926. /**
  112927. * Serialize current object to a JSON object
  112928. * @returns the serialized object
  112929. */
  112930. SubEmitter.prototype.serialize = function () {
  112931. var serializationObject = {};
  112932. serializationObject.type = this.type;
  112933. serializationObject.inheritDirection = this.inheritDirection;
  112934. serializationObject.inheritedVelocityAmount = this.inheritedVelocityAmount;
  112935. serializationObject.particleSystem = this.particleSystem.serialize();
  112936. return serializationObject;
  112937. };
  112938. /** @hidden */
  112939. SubEmitter._ParseParticleSystem = function (system, scene, rootUrl) {
  112940. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("ParseParticle");
  112941. };
  112942. /**
  112943. * Creates a new SubEmitter from a serialized JSON version
  112944. * @param serializationObject defines the JSON object to read from
  112945. * @param scene defines the hosting scene
  112946. * @param rootUrl defines the rootUrl for data loading
  112947. * @returns a new SubEmitter
  112948. */
  112949. SubEmitter.Parse = function (serializationObject, scene, rootUrl) {
  112950. var system = serializationObject.particleSystem;
  112951. var subEmitter = new SubEmitter(SubEmitter._ParseParticleSystem(system, scene, rootUrl));
  112952. subEmitter.type = serializationObject.type;
  112953. subEmitter.inheritDirection = serializationObject.inheritDirection;
  112954. subEmitter.inheritedVelocityAmount = serializationObject.inheritedVelocityAmount;
  112955. subEmitter.particleSystem._isSubEmitter = true;
  112956. return subEmitter;
  112957. };
  112958. /** Release associated resources */
  112959. SubEmitter.prototype.dispose = function () {
  112960. this.particleSystem.dispose();
  112961. };
  112962. return SubEmitter;
  112963. }());
  112964. /***/ }),
  112965. /***/ "./Physics/Plugins/ammoJSPlugin.ts":
  112966. /*!*****************************************!*\
  112967. !*** ./Physics/Plugins/ammoJSPlugin.ts ***!
  112968. \*****************************************/
  112969. /*! exports provided: AmmoJSPlugin */
  112970. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112971. "use strict";
  112972. __webpack_require__.r(__webpack_exports__);
  112973. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return AmmoJSPlugin; });
  112974. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  112975. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  112976. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  112977. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  112978. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  112979. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  112980. /* harmony import */ var _Meshes_Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Meshes/Builders/shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  112981. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  112982. /**
  112983. * AmmoJS Physics plugin
  112984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112985. * @see https://github.com/kripken/ammo.js/
  112986. */
  112987. var AmmoJSPlugin = /** @class */ (function () {
  112988. /**
  112989. * Initializes the ammoJS plugin
  112990. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  112991. * @param ammoInjection can be used to inject your own ammo reference
  112992. */
  112993. function AmmoJSPlugin(_useDeltaForWorldStep, ammoInjection) {
  112994. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  112995. if (ammoInjection === void 0) { ammoInjection = Ammo; }
  112996. var _this = this;
  112997. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  112998. /**
  112999. * Reference to the Ammo library
  113000. */
  113001. this.bjsAMMO = {};
  113002. /**
  113003. * Name of the plugin
  113004. */
  113005. this.name = "AmmoJSPlugin";
  113006. this._timeStep = 1 / 60;
  113007. this._fixedTimeStep = 1 / 60;
  113008. this._maxSteps = 5;
  113009. this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  113010. this._tmpContactCallbackResult = false;
  113011. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  113012. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  113013. if (typeof ammoInjection === "function") {
  113014. ammoInjection(this.bjsAMMO);
  113015. }
  113016. else {
  113017. this.bjsAMMO = ammoInjection;
  113018. }
  113019. if (!this.isSupported()) {
  113020. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("AmmoJS is not available. Please make sure you included the js file.");
  113021. return;
  113022. }
  113023. // Initialize the physics world
  113024. this._collisionConfiguration = new this.bjsAMMO.btSoftBodyRigidBodyCollisionConfiguration();
  113025. this._dispatcher = new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration);
  113026. this._overlappingPairCache = new this.bjsAMMO.btDbvtBroadphase();
  113027. this._solver = new this.bjsAMMO.btSequentialImpulseConstraintSolver();
  113028. this._softBodySolver = new this.bjsAMMO.btDefaultSoftBodySolver();
  113029. this.world = new this.bjsAMMO.btSoftRigidDynamicsWorld(this._dispatcher, this._overlappingPairCache, this._solver, this._collisionConfiguration, this._softBodySolver);
  113030. this._tmpAmmoConcreteContactResultCallback = new this.bjsAMMO.ConcreteContactResultCallback();
  113031. this._tmpAmmoConcreteContactResultCallback.addSingleResult = function () { _this._tmpContactCallbackResult = true; };
  113032. // Create temp ammo variables
  113033. this._tmpAmmoTransform = new this.bjsAMMO.btTransform();
  113034. this._tmpAmmoTransform.setIdentity();
  113035. this._tmpAmmoQuaternion = new this.bjsAMMO.btQuaternion(0, 0, 0, 1);
  113036. this._tmpAmmoVectorA = new this.bjsAMMO.btVector3(0, 0, 0);
  113037. this._tmpAmmoVectorB = new this.bjsAMMO.btVector3(0, 0, 0);
  113038. this._tmpAmmoVectorC = new this.bjsAMMO.btVector3(0, 0, 0);
  113039. this._tmpAmmoVectorD = new this.bjsAMMO.btVector3(0, 0, 0);
  113040. }
  113041. /**
  113042. * Sets the gravity of the physics world (m/(s^2))
  113043. * @param gravity Gravity to set
  113044. */
  113045. AmmoJSPlugin.prototype.setGravity = function (gravity) {
  113046. this._tmpAmmoVectorA.setValue(gravity.x, gravity.y, gravity.z);
  113047. this.world.setGravity(this._tmpAmmoVectorA);
  113048. this.world.getWorldInfo().set_m_gravity(this._tmpAmmoVectorA);
  113049. };
  113050. /**
  113051. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  113052. * @param timeStep timestep to use in seconds
  113053. */
  113054. AmmoJSPlugin.prototype.setTimeStep = function (timeStep) {
  113055. this._timeStep = timeStep;
  113056. };
  113057. /**
  113058. * 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)
  113059. * @param fixedTimeStep fixedTimeStep to use in seconds
  113060. */
  113061. AmmoJSPlugin.prototype.setFixedTimeStep = function (fixedTimeStep) {
  113062. this._fixedTimeStep = fixedTimeStep;
  113063. };
  113064. /**
  113065. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  113066. * @param maxSteps the maximum number of steps by the physics engine per frame
  113067. */
  113068. AmmoJSPlugin.prototype.setMaxSteps = function (maxSteps) {
  113069. this._maxSteps = maxSteps;
  113070. };
  113071. /**
  113072. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  113073. * @returns the current timestep in seconds
  113074. */
  113075. AmmoJSPlugin.prototype.getTimeStep = function () {
  113076. return this._timeStep;
  113077. };
  113078. // Ammo's contactTest and contactPairTest take a callback that runs synchronously, wrap them so that they are easier to consume
  113079. AmmoJSPlugin.prototype._isImpostorInContact = function (impostor) {
  113080. this._tmpContactCallbackResult = false;
  113081. this.world.contactTest(impostor.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  113082. return this._tmpContactCallbackResult;
  113083. };
  113084. // Ammo's collision events have some weird quirks
  113085. // contactPairTest fires too many events as it fires events even when objects are close together but contactTest does not
  113086. // so only fire event if both contactTest and contactPairTest have a hit
  113087. AmmoJSPlugin.prototype._isImpostorPairInContact = function (impostorA, impostorB) {
  113088. this._tmpContactCallbackResult = false;
  113089. this.world.contactPairTest(impostorA.physicsBody, impostorB.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  113090. return this._tmpContactCallbackResult;
  113091. };
  113092. // Ammo's behavior when maxSteps > 0 does not behave as described in docs
  113093. // @see http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Stepping_The_World
  113094. //
  113095. // When maxSteps is 0 do the entire simulation in one step
  113096. // 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)
  113097. // Note: To get deterministic physics, timeStep would always need to be divisible by fixedTimeStep
  113098. AmmoJSPlugin.prototype._stepSimulation = function (timeStep, maxSteps, fixedTimeStep) {
  113099. if (timeStep === void 0) { timeStep = 1 / 60; }
  113100. if (maxSteps === void 0) { maxSteps = 10; }
  113101. if (fixedTimeStep === void 0) { fixedTimeStep = 1 / 60; }
  113102. if (maxSteps == 0) {
  113103. this.world.stepSimulation(timeStep, 0);
  113104. }
  113105. else {
  113106. while (maxSteps > 0 && timeStep > 0) {
  113107. if (timeStep - fixedTimeStep < fixedTimeStep) {
  113108. this.world.stepSimulation(timeStep, 0);
  113109. timeStep = 0;
  113110. }
  113111. else {
  113112. timeStep -= fixedTimeStep;
  113113. this.world.stepSimulation(fixedTimeStep, 0);
  113114. }
  113115. maxSteps--;
  113116. }
  113117. }
  113118. };
  113119. /**
  113120. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  113121. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  113122. * After the step the babylon meshes are set to the position of the physics imposters
  113123. * @param delta amount of time to step forward
  113124. * @param impostors array of imposters to update before/after the step
  113125. */
  113126. AmmoJSPlugin.prototype.executeStep = function (delta, impostors) {
  113127. for (var _i = 0, impostors_1 = impostors; _i < impostors_1.length; _i++) {
  113128. var impostor = impostors_1[_i];
  113129. // Update physics world objects to match babylon world
  113130. if (!impostor.soft) {
  113131. impostor.beforeStep();
  113132. }
  113133. }
  113134. this._stepSimulation(this._useDeltaForWorldStep ? delta : this._timeStep, this._maxSteps, this._fixedTimeStep);
  113135. for (var _a = 0, impostors_2 = impostors; _a < impostors_2.length; _a++) {
  113136. var mainImpostor = impostors_2[_a];
  113137. // After physics update make babylon world objects match physics world objects
  113138. if (mainImpostor.soft) {
  113139. this._afterSoftStep(mainImpostor);
  113140. }
  113141. else {
  113142. mainImpostor.afterStep();
  113143. }
  113144. // Handle collision event
  113145. if (mainImpostor._onPhysicsCollideCallbacks.length > 0) {
  113146. if (this._isImpostorInContact(mainImpostor)) {
  113147. for (var _b = 0, _c = mainImpostor._onPhysicsCollideCallbacks; _b < _c.length; _b++) {
  113148. var collideCallback = _c[_b];
  113149. for (var _d = 0, _e = collideCallback.otherImpostors; _d < _e.length; _d++) {
  113150. var otherImpostor = _e[_d];
  113151. if (mainImpostor.physicsBody.isActive() || otherImpostor.physicsBody.isActive()) {
  113152. if (this._isImpostorPairInContact(mainImpostor, otherImpostor)) {
  113153. mainImpostor.onCollide({ body: otherImpostor.physicsBody });
  113154. otherImpostor.onCollide({ body: mainImpostor.physicsBody });
  113155. }
  113156. }
  113157. }
  113158. }
  113159. }
  113160. }
  113161. }
  113162. };
  113163. /**
  113164. * Update babylon mesh to match physics world object
  113165. * @param impostor imposter to match
  113166. */
  113167. AmmoJSPlugin.prototype._afterSoftStep = function (impostor) {
  113168. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].RopeImpostor) {
  113169. this._ropeStep(impostor);
  113170. }
  113171. else {
  113172. this._softbodyOrClothStep(impostor);
  113173. }
  113174. };
  113175. /**
  113176. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  113177. * @param impostor imposter to match
  113178. */
  113179. AmmoJSPlugin.prototype._ropeStep = function (impostor) {
  113180. var bodyVertices = impostor.physicsBody.get_m_nodes();
  113181. var nbVertices = bodyVertices.size();
  113182. var node;
  113183. var nodePositions;
  113184. var x, y, z;
  113185. var path = new Array();
  113186. for (var n = 0; n < nbVertices; n++) {
  113187. node = bodyVertices.at(n);
  113188. nodePositions = node.get_m_x();
  113189. x = nodePositions.x();
  113190. y = nodePositions.y();
  113191. z = nodePositions.z();
  113192. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](x, y, z));
  113193. }
  113194. var object = impostor.object;
  113195. var shape = impostor.getParam("shape");
  113196. if (impostor._isFromLine) {
  113197. impostor.object = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLines("lines", { points: path, instance: object });
  113198. }
  113199. else {
  113200. impostor.object = _Meshes_Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_6__["ShapeBuilder"].ExtrudeShape("ext", { shape: shape, path: path, instance: object });
  113201. }
  113202. };
  113203. /**
  113204. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  113205. * @param impostor imposter to match
  113206. */
  113207. AmmoJSPlugin.prototype._softbodyOrClothStep = function (impostor) {
  113208. var normalDirection = (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].ClothImpostor) ? 1 : -1;
  113209. var object = impostor.object;
  113210. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  113211. if (!vertexPositions) {
  113212. vertexPositions = [];
  113213. }
  113214. var vertexNormals = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  113215. if (!vertexNormals) {
  113216. vertexNormals = [];
  113217. }
  113218. var nbVertices = vertexPositions.length / 3;
  113219. var bodyVertices = impostor.physicsBody.get_m_nodes();
  113220. var node;
  113221. var nodePositions;
  113222. var nodeNormals;
  113223. var x, y, z;
  113224. var nx, ny, nz;
  113225. for (var n = 0; n < nbVertices; n++) {
  113226. node = bodyVertices.at(n);
  113227. nodePositions = node.get_m_x();
  113228. x = nodePositions.x();
  113229. y = nodePositions.y();
  113230. z = nodePositions.z() * normalDirection;
  113231. var nodeNormals = node.get_m_n();
  113232. nx = nodeNormals.x();
  113233. ny = nodeNormals.y();
  113234. nz = nodeNormals.z() * normalDirection;
  113235. vertexPositions[3 * n] = x;
  113236. vertexPositions[3 * n + 1] = y;
  113237. vertexPositions[3 * n + 2] = z;
  113238. vertexNormals[3 * n] = nx;
  113239. vertexNormals[3 * n + 1] = ny;
  113240. vertexNormals[3 * n + 2] = nz;
  113241. }
  113242. var vertex_data = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"]();
  113243. vertex_data.positions = vertexPositions;
  113244. vertex_data.normals = vertexNormals;
  113245. vertex_data.uvs = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  113246. vertex_data.colors = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  113247. if (object && object.getIndices) {
  113248. vertex_data.indices = object.getIndices();
  113249. }
  113250. vertex_data.applyToMesh(object);
  113251. };
  113252. /**
  113253. * Applies an impulse on the imposter
  113254. * @param impostor imposter to apply impulse to
  113255. * @param force amount of force to be applied to the imposter
  113256. * @param contactPoint the location to apply the impulse on the imposter
  113257. */
  113258. AmmoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  113259. if (!impostor.soft) {
  113260. impostor.physicsBody.activate();
  113261. var worldPoint = this._tmpAmmoVectorA;
  113262. var impulse = this._tmpAmmoVectorB;
  113263. // Convert contactPoint into world space
  113264. if (impostor.object && impostor.object.getWorldMatrix) {
  113265. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  113266. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  113267. contactPoint = this._tmpVector;
  113268. }
  113269. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  113270. impulse.setValue(force.x, force.y, force.z);
  113271. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  113272. }
  113273. else {
  113274. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Cannot be applied to a soft body");
  113275. }
  113276. };
  113277. /**
  113278. * Applies a force on the imposter
  113279. * @param impostor imposter to apply force
  113280. * @param force amount of force to be applied to the imposter
  113281. * @param contactPoint the location to apply the force on the imposter
  113282. */
  113283. AmmoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  113284. if (!impostor.soft) {
  113285. impostor.physicsBody.activate();
  113286. var worldPoint = this._tmpAmmoVectorA;
  113287. var impulse = this._tmpAmmoVectorB;
  113288. // Convert contactPoint into world space
  113289. if (impostor.object && impostor.object.getWorldMatrix) {
  113290. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  113291. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  113292. contactPoint = this._tmpVector;
  113293. }
  113294. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  113295. impulse.setValue(force.x, force.y, force.z);
  113296. impostor.physicsBody.applyForce(impulse, worldPoint);
  113297. }
  113298. else {
  113299. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Cannot be applied to a soft body");
  113300. }
  113301. };
  113302. /**
  113303. * Creates a physics body using the plugin
  113304. * @param impostor the imposter to create the physics body on
  113305. */
  113306. AmmoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  113307. impostor._pluginData = { toDispose: [] };
  113308. //parent-child relationship
  113309. if (impostor.parent) {
  113310. if (impostor.physicsBody) {
  113311. this.removePhysicsBody(impostor);
  113312. impostor.forceUpdate();
  113313. }
  113314. return;
  113315. }
  113316. if (impostor.isBodyInitRequired()) {
  113317. var colShape = this._createShape(impostor);
  113318. var mass = impostor.getParam("mass");
  113319. impostor._pluginData.mass = mass;
  113320. if (impostor.soft) {
  113321. colShape.get_m_cfg().set_collisions(0x11);
  113322. colShape.get_m_cfg().set_kDP(impostor.getParam("damping"));
  113323. Ammo.castObject(colShape, Ammo.btCollisionObject).getCollisionShape().setMargin(impostor.getParam("margin"));
  113324. colShape.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
  113325. this.world.addSoftBody(colShape, 1, -1);
  113326. impostor.physicsBody = colShape;
  113327. impostor._pluginData.toDispose.concat([colShape]);
  113328. this.setBodyPressure(impostor, 0);
  113329. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SoftbodyImpostor) {
  113330. this.setBodyPressure(impostor, impostor.getParam("pressure"));
  113331. }
  113332. this.setBodyStiffness(impostor, impostor.getParam("stiffness"));
  113333. this.setBodyVelocityIterations(impostor, impostor.getParam("velocityIterations"));
  113334. this.setBodyPositionIterations(impostor, impostor.getParam("positionIterations"));
  113335. }
  113336. else {
  113337. var localInertia = new Ammo.btVector3(0, 0, 0);
  113338. var startTransform = new Ammo.btTransform();
  113339. startTransform.setIdentity();
  113340. if (mass !== 0) {
  113341. colShape.calculateLocalInertia(mass, localInertia);
  113342. }
  113343. this._tmpAmmoVectorA.setValue(impostor.object.position.x, impostor.object.position.y, impostor.object.position.z);
  113344. this._tmpAmmoQuaternion.setValue(impostor.object.rotationQuaternion.x, impostor.object.rotationQuaternion.y, impostor.object.rotationQuaternion.z, impostor.object.rotationQuaternion.w);
  113345. startTransform.setOrigin(this._tmpAmmoVectorA);
  113346. startTransform.setRotation(this._tmpAmmoQuaternion);
  113347. var myMotionState = new Ammo.btDefaultMotionState(startTransform);
  113348. var rbInfo = new Ammo.btRigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia);
  113349. var body = new Ammo.btRigidBody(rbInfo);
  113350. // Make objects kinematic if it's mass is 0
  113351. if (mass === 0) {
  113352. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.KINEMATIC_FLAG);
  113353. body.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
  113354. }
  113355. // Disable collision if NoImpostor, but keep collision if shape is btCompoundShape
  113356. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor && !colShape.getChildShape) {
  113357. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.DISABLE_COLLISION_FLAG);
  113358. }
  113359. this.world.addRigidBody(body);
  113360. impostor.physicsBody = body;
  113361. impostor._pluginData.toDispose.concat([body, rbInfo, myMotionState, startTransform, localInertia, colShape]);
  113362. }
  113363. this.setBodyRestitution(impostor, impostor.getParam("restitution"));
  113364. this.setBodyFriction(impostor, impostor.getParam("friction"));
  113365. }
  113366. };
  113367. /**
  113368. * Removes the physics body from the imposter and disposes of the body's memory
  113369. * @param impostor imposter to remove the physics body from
  113370. */
  113371. AmmoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  113372. var _this = this;
  113373. if (this.world) {
  113374. this.world.removeRigidBody(impostor.physicsBody);
  113375. impostor._pluginData.toDispose.forEach(function (d) {
  113376. _this.bjsAMMO.destroy(d);
  113377. });
  113378. }
  113379. };
  113380. /**
  113381. * Generates a joint
  113382. * @param impostorJoint the imposter joint to create the joint with
  113383. */
  113384. AmmoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  113385. var mainBody = impostorJoint.mainImpostor.physicsBody;
  113386. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  113387. if (!mainBody || !connectedBody) {
  113388. return;
  113389. }
  113390. var jointData = impostorJoint.joint.jointData;
  113391. if (!jointData.mainPivot) {
  113392. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  113393. }
  113394. if (!jointData.connectedPivot) {
  113395. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  113396. }
  113397. var joint;
  113398. switch (impostorJoint.joint.type) {
  113399. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].DistanceJoint:
  113400. var distance = jointData.maxDistance;
  113401. if (distance) {
  113402. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -distance / 2, 0);
  113403. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, distance / 2, 0);
  113404. }
  113405. 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));
  113406. break;
  113407. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].HingeJoint:
  113408. if (!jointData.mainAxis) {
  113409. jointData.mainAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  113410. }
  113411. if (!jointData.connectedAxis) {
  113412. jointData.connectedAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  113413. }
  113414. var mainAxis = new Ammo.btVector3(jointData.mainAxis.x, jointData.mainAxis.y, jointData.mainAxis.z);
  113415. var connectedAxis = new Ammo.btVector3(jointData.connectedAxis.x, jointData.connectedAxis.y, jointData.connectedAxis.z);
  113416. 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);
  113417. break;
  113418. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].BallAndSocketJoint:
  113419. 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));
  113420. break;
  113421. default:
  113422. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint");
  113423. 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));
  113424. break;
  113425. }
  113426. this.world.addConstraint(joint, !impostorJoint.joint.jointData.collision);
  113427. impostorJoint.joint.physicsJoint = joint;
  113428. };
  113429. /**
  113430. * Removes a joint
  113431. * @param impostorJoint the imposter joint to remove the joint from
  113432. */
  113433. AmmoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  113434. if (this.world) {
  113435. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  113436. }
  113437. };
  113438. // adds all verticies (including child verticies) to the triangle mesh
  113439. AmmoJSPlugin.prototype._addMeshVerts = function (btTriangleMesh, topLevelObject, object) {
  113440. var _this = this;
  113441. var triangleCount = 0;
  113442. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  113443. var indices = object.getIndices();
  113444. if (!indices) {
  113445. indices = [];
  113446. }
  113447. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  113448. if (!vertexPositions) {
  113449. vertexPositions = [];
  113450. }
  113451. object.computeWorldMatrix(false);
  113452. var faceCount = indices.length / 3;
  113453. for (var i = 0; i < faceCount; i++) {
  113454. var triPoints = [];
  113455. for (var point = 0; point < 3; point++) {
  113456. 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]);
  113457. // Adjust for initial scaling
  113458. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].ScalingToRef(object.scaling.x, object.scaling.y, object.scaling.z, this._tmpMatrix);
  113459. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, this._tmpMatrix);
  113460. var vec;
  113461. if (point == 0) {
  113462. vec = this._tmpAmmoVectorA;
  113463. }
  113464. else if (point == 1) {
  113465. vec = this._tmpAmmoVectorB;
  113466. }
  113467. else {
  113468. vec = this._tmpAmmoVectorC;
  113469. }
  113470. vec.setValue(v.x, v.y, v.z);
  113471. triPoints.push(vec);
  113472. }
  113473. btTriangleMesh.addTriangle(triPoints[0], triPoints[1], triPoints[2]);
  113474. triangleCount++;
  113475. }
  113476. object.getChildMeshes().forEach(function (m) {
  113477. triangleCount += _this._addMeshVerts(btTriangleMesh, topLevelObject, m);
  113478. });
  113479. }
  113480. return triangleCount;
  113481. };
  113482. /**
  113483. * Initialise the soft body vertices to match its object's (mesh) vertices
  113484. * Softbody vertices (nodes) are in world space and to match this
  113485. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  113486. * @param impostor to create the softbody for
  113487. */
  113488. AmmoJSPlugin.prototype._softVertexData = function (impostor) {
  113489. var object = impostor.object;
  113490. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  113491. var indices = object.getIndices();
  113492. if (!indices) {
  113493. indices = [];
  113494. }
  113495. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  113496. if (!vertexPositions) {
  113497. vertexPositions = [];
  113498. }
  113499. var vertexNormals = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  113500. if (!vertexNormals) {
  113501. vertexNormals = [];
  113502. }
  113503. object.computeWorldMatrix(false);
  113504. var newPoints = [];
  113505. var newNorms = [];
  113506. for (var i = 0; i < vertexPositions.length; i += 3) {
  113507. var v = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexPositions[i], vertexPositions[i + 1], vertexPositions[i + 2]);
  113508. var n = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexNormals[i], vertexNormals[i + 1], vertexNormals[i + 2]);
  113509. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, object.getWorldMatrix());
  113510. n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(n, object.getWorldMatrix());
  113511. newPoints.push(v.x, v.y, v.z);
  113512. newNorms.push(n.x, n.y, n.z);
  113513. }
  113514. var vertex_data = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"]();
  113515. vertex_data.positions = newPoints;
  113516. vertex_data.normals = newNorms;
  113517. vertex_data.uvs = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  113518. vertex_data.colors = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  113519. if (object && object.getIndices) {
  113520. vertex_data.indices = object.getIndices();
  113521. }
  113522. vertex_data.applyToMesh(object);
  113523. object.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  113524. object.rotationQuaternion = null;
  113525. object.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  113526. object.computeWorldMatrix(true);
  113527. return vertex_data;
  113528. }
  113529. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"].ExtractFromMesh(object);
  113530. };
  113531. /**
  113532. * Create an impostor's soft body
  113533. * @param impostor to create the softbody for
  113534. */
  113535. AmmoJSPlugin.prototype._createSoftbody = function (impostor) {
  113536. var object = impostor.object;
  113537. if (object && object.getIndices) {
  113538. var indices = object.getIndices();
  113539. if (!indices) {
  113540. indices = [];
  113541. }
  113542. var vertex_data = this._softVertexData(impostor);
  113543. var vertexPositions = vertex_data.positions;
  113544. var vertexNormals = vertex_data.normals;
  113545. if (vertexPositions === null || vertexNormals === null) {
  113546. return new Ammo.btCompoundShape();
  113547. }
  113548. else {
  113549. var triPoints = [];
  113550. var triNorms = [];
  113551. for (var i = 0; i < vertexPositions.length; i += 3) {
  113552. var v = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexPositions[i], vertexPositions[i + 1], vertexPositions[i + 2]);
  113553. var n = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexNormals[i], vertexNormals[i + 1], vertexNormals[i + 2]);
  113554. triPoints.push(v.x, v.y, -v.z);
  113555. triNorms.push(n.x, n.y, -n.z);
  113556. }
  113557. var softBody = new Ammo.btSoftBodyHelpers().CreateFromTriMesh(this.world.getWorldInfo(), triPoints, object.getIndices(), indices.length / 3, true);
  113558. var nbVertices = vertexPositions.length / 3;
  113559. var bodyVertices = softBody.get_m_nodes();
  113560. var node;
  113561. var nodeNormals;
  113562. for (var i = 0; i < nbVertices; i++) {
  113563. node = bodyVertices.at(i);
  113564. var nodeNormals = node.get_m_n();
  113565. nodeNormals.setX(triNorms[3 * i]);
  113566. nodeNormals.setY(triNorms[3 * i + 1]);
  113567. nodeNormals.setZ(triNorms[3 * i + 2]);
  113568. }
  113569. return softBody;
  113570. }
  113571. }
  113572. };
  113573. /**
  113574. * Create cloth for an impostor
  113575. * @param impostor to create the softbody for
  113576. */
  113577. AmmoJSPlugin.prototype._createCloth = function (impostor) {
  113578. var object = impostor.object;
  113579. if (object && object.getIndices) {
  113580. var indices = object.getIndices();
  113581. if (!indices) {
  113582. indices = [];
  113583. }
  113584. var vertex_data = this._softVertexData(impostor);
  113585. var vertexPositions = vertex_data.positions;
  113586. var vertexNormals = vertex_data.normals;
  113587. if (vertexPositions === null || vertexNormals === null) {
  113588. return new Ammo.btCompoundShape();
  113589. }
  113590. else {
  113591. var len = vertexPositions.length;
  113592. var segments = Math.sqrt(len / 3);
  113593. impostor.segments = segments;
  113594. var segs = segments - 1;
  113595. this._tmpAmmoVectorA.setValue(vertexPositions[0], vertexPositions[1], vertexPositions[2]);
  113596. this._tmpAmmoVectorB.setValue(vertexPositions[3 * segs], vertexPositions[3 * segs + 1], vertexPositions[3 * segs + 2]);
  113597. this._tmpAmmoVectorD.setValue(vertexPositions[len - 3], vertexPositions[len - 2], vertexPositions[len - 1]);
  113598. this._tmpAmmoVectorC.setValue(vertexPositions[len - 3 - 3 * segs], vertexPositions[len - 2 - 3 * segs], vertexPositions[len - 1 - 3 * segs]);
  113599. var clothBody = new Ammo.btSoftBodyHelpers().CreatePatch(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, this._tmpAmmoVectorC, this._tmpAmmoVectorD, segments, segments, impostor.getParam("fixedPoints"), true);
  113600. return clothBody;
  113601. }
  113602. }
  113603. };
  113604. /**
  113605. * Create rope for an impostor
  113606. * @param impostor to create the softbody for
  113607. */
  113608. AmmoJSPlugin.prototype._createRope = function (impostor) {
  113609. var len;
  113610. var segments;
  113611. var vertex_data = this._softVertexData(impostor);
  113612. var vertexPositions = vertex_data.positions;
  113613. var vertexNormals = vertex_data.normals;
  113614. if (vertexPositions === null || vertexNormals === null) {
  113615. return new Ammo.btCompoundShape();
  113616. }
  113617. //force the mesh to be updatable
  113618. vertex_data.applyToMesh(impostor.object, true);
  113619. impostor._isFromLine = true;
  113620. // If in lines mesh all normals will be zero
  113621. var vertexSquared = vertexNormals.map(function (x) { return x * x; });
  113622. var reducer = function (accumulator, currentValue) { return accumulator + currentValue; };
  113623. var reduced = vertexSquared.reduce(reducer);
  113624. if (reduced === 0) { // line mesh
  113625. len = vertexPositions.length;
  113626. segments = len / 3 - 1;
  113627. this._tmpAmmoVectorA.setValue(vertexPositions[0], vertexPositions[1], vertexPositions[2]);
  113628. this._tmpAmmoVectorB.setValue(vertexPositions[len - 3], vertexPositions[len - 2], vertexPositions[len - 1]);
  113629. }
  113630. else { //extruded mesh
  113631. impostor._isFromLine = false;
  113632. var pathVectors = impostor.getParam("path");
  113633. var shape = impostor.getParam("shape");
  113634. if (shape === null) {
  113635. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("No shape available for extruded mesh");
  113636. return new Ammo.btCompoundShape();
  113637. }
  113638. if ((vertexPositions.length % (3 * pathVectors.length)) !== 0) {
  113639. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Path does not match extrusion");
  113640. return new Ammo.btCompoundShape();
  113641. }
  113642. len = pathVectors.length;
  113643. segments = len - 1;
  113644. this._tmpAmmoVectorA.setValue(pathVectors[0].x, pathVectors[0].y, pathVectors[0].z);
  113645. this._tmpAmmoVectorB.setValue(pathVectors[len - 1].x, pathVectors[len - 1].y, pathVectors[len - 1].z);
  113646. }
  113647. impostor.segments = segments;
  113648. var fixedPoints = impostor.getParam("fixedPoints");
  113649. fixedPoints = (fixedPoints > 3) ? 3 : fixedPoints;
  113650. var ropeBody = new Ammo.btSoftBodyHelpers().CreateRope(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, segments - 1, fixedPoints);
  113651. ropeBody.get_m_cfg().set_collisions(0x11);
  113652. return ropeBody;
  113653. };
  113654. // adds all verticies (including child verticies) to the convex hull shape
  113655. AmmoJSPlugin.prototype._addHullVerts = function (btConvexHullShape, topLevelObject, object) {
  113656. var _this = this;
  113657. var triangleCount = 0;
  113658. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  113659. var indices = object.getIndices();
  113660. if (!indices) {
  113661. indices = [];
  113662. }
  113663. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  113664. if (!vertexPositions) {
  113665. vertexPositions = [];
  113666. }
  113667. object.computeWorldMatrix(false);
  113668. var faceCount = indices.length / 3;
  113669. for (var i = 0; i < faceCount; i++) {
  113670. var triPoints = [];
  113671. for (var point = 0; point < 3; point++) {
  113672. 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]);
  113673. // Adjust for initial scaling
  113674. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].ScalingToRef(object.scaling.x, object.scaling.y, object.scaling.z, this._tmpMatrix);
  113675. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, this._tmpMatrix);
  113676. var vec;
  113677. if (point == 0) {
  113678. vec = this._tmpAmmoVectorA;
  113679. }
  113680. else if (point == 1) {
  113681. vec = this._tmpAmmoVectorB;
  113682. }
  113683. else {
  113684. vec = this._tmpAmmoVectorC;
  113685. }
  113686. vec.setValue(v.x, v.y, v.z);
  113687. triPoints.push(vec);
  113688. }
  113689. btConvexHullShape.addPoint(triPoints[0], true);
  113690. btConvexHullShape.addPoint(triPoints[1], true);
  113691. btConvexHullShape.addPoint(triPoints[2], true);
  113692. triangleCount++;
  113693. }
  113694. object.getChildMeshes().forEach(function (m) {
  113695. triangleCount += _this._addHullVerts(btConvexHullShape, topLevelObject, m);
  113696. });
  113697. }
  113698. return triangleCount;
  113699. };
  113700. AmmoJSPlugin.prototype._createShape = function (impostor, ignoreChildren) {
  113701. var _this = this;
  113702. if (ignoreChildren === void 0) { ignoreChildren = false; }
  113703. var object = impostor.object;
  113704. var returnValue;
  113705. var extendSize = impostor.getObjectExtendSize();
  113706. if (!ignoreChildren) {
  113707. var meshChildren = impostor.object.getChildMeshes ? impostor.object.getChildMeshes(true) : [];
  113708. returnValue = new Ammo.btCompoundShape();
  113709. // Add shape of all children to the compound shape
  113710. var childrenAdded = 0;
  113711. meshChildren.forEach(function (childMesh) {
  113712. var childImpostor = childMesh.getPhysicsImpostor();
  113713. if (childImpostor) {
  113714. var shape = _this._createShape(childImpostor);
  113715. // Position needs to be scaled based on parent's scaling
  113716. var parentMat = childMesh.parent.getWorldMatrix().clone();
  113717. var s = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  113718. parentMat.decompose(s);
  113719. _this._tmpAmmoTransform.getOrigin().setValue(childMesh.position.x * s.x, childMesh.position.y * s.y, childMesh.position.z * s.z);
  113720. _this._tmpAmmoQuaternion.setValue(childMesh.rotationQuaternion.x, childMesh.rotationQuaternion.y, childMesh.rotationQuaternion.z, childMesh.rotationQuaternion.w);
  113721. _this._tmpAmmoTransform.setRotation(_this._tmpAmmoQuaternion);
  113722. returnValue.addChildShape(_this._tmpAmmoTransform, shape);
  113723. childImpostor.dispose();
  113724. childrenAdded++;
  113725. }
  113726. });
  113727. if (childrenAdded > 0) {
  113728. // Add parents shape as a child if present
  113729. if (impostor.type != _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor) {
  113730. var shape = this._createShape(impostor, true);
  113731. if (shape) {
  113732. this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0);
  113733. this._tmpAmmoQuaternion.setValue(0, 0, 0, 1);
  113734. this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion);
  113735. returnValue.addChildShape(this._tmpAmmoTransform, shape);
  113736. }
  113737. }
  113738. return returnValue;
  113739. }
  113740. else {
  113741. // If no children with impostors create the actual shape below instead
  113742. Ammo.destroy(returnValue);
  113743. returnValue = null;
  113744. }
  113745. }
  113746. switch (impostor.type) {
  113747. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SphereImpostor:
  113748. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  113749. break;
  113750. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].CylinderImpostor:
  113751. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  113752. returnValue = new Ammo.btCylinderShape(this._tmpAmmoVectorA);
  113753. break;
  113754. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].PlaneImpostor:
  113755. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].BoxImpostor:
  113756. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  113757. returnValue = new Ammo.btBoxShape(this._tmpAmmoVectorA);
  113758. break;
  113759. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].MeshImpostor:
  113760. if (impostor.getParam("mass") == 0) {
  113761. // Only create btBvhTriangleMeshShape impostor is static
  113762. // See https://pybullet.org/Bullet/phpBB3/viewtopic.php?t=7283
  113763. var tetraMesh = new Ammo.btTriangleMesh();
  113764. impostor._pluginData.toDispose.concat([tetraMesh]);
  113765. var triangeCount = this._addMeshVerts(tetraMesh, object, object);
  113766. if (triangeCount == 0) {
  113767. returnValue = new Ammo.btCompoundShape();
  113768. }
  113769. else {
  113770. returnValue = new Ammo.btBvhTriangleMeshShape(tetraMesh);
  113771. }
  113772. break;
  113773. }
  113774. // Otherwise create convexHullImpostor
  113775. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].ConvexHullImpostor:
  113776. var convexMesh = new Ammo.btConvexHullShape();
  113777. var triangeCount = this._addHullVerts(convexMesh, object, object);
  113778. if (triangeCount == 0) {
  113779. // Cleanup Unused Convex Hull Shape
  113780. impostor._pluginData.toDispose.concat([convexMesh]);
  113781. returnValue = new Ammo.btCompoundShape();
  113782. }
  113783. else {
  113784. returnValue = convexMesh;
  113785. }
  113786. break;
  113787. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor:
  113788. // Fill with sphere but collision is disabled on the rigid body in generatePhysicsBody, using an empty shape caused unexpected movement with joints
  113789. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  113790. break;
  113791. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SoftbodyImpostor:
  113792. // Only usable with a mesh that has sufficient and shared vertices
  113793. returnValue = this._createSoftbody(impostor);
  113794. break;
  113795. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].ClothImpostor:
  113796. // Only usable with a ground mesh that has sufficient and shared vertices
  113797. returnValue = this._createCloth(impostor);
  113798. break;
  113799. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].RopeImpostor:
  113800. // Only usable with a line mesh or an extruded mesh that is updatable
  113801. returnValue = this._createRope(impostor);
  113802. break;
  113803. default:
  113804. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The impostor type is not currently supported by the ammo plugin.");
  113805. break;
  113806. }
  113807. return returnValue;
  113808. };
  113809. /**
  113810. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  113811. * @param impostor imposter containing the physics body and babylon object
  113812. */
  113813. AmmoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  113814. impostor.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  113815. impostor.object.position.set(this._tmpAmmoTransform.getOrigin().x(), this._tmpAmmoTransform.getOrigin().y(), this._tmpAmmoTransform.getOrigin().z());
  113816. if (!impostor.object.rotationQuaternion) {
  113817. if (impostor.object.rotation) {
  113818. this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  113819. this._tmpQuaternion.toEulerAnglesToRef(impostor.object.rotation);
  113820. }
  113821. }
  113822. else {
  113823. impostor.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  113824. }
  113825. };
  113826. /**
  113827. * Sets the babylon object's position/rotation from the physics body's position/rotation
  113828. * @param impostor imposter containing the physics body and babylon object
  113829. * @param newPosition new position
  113830. * @param newRotation new rotation
  113831. */
  113832. AmmoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  113833. var trans = impostor.physicsBody.getWorldTransform();
  113834. // If rotation/position has changed update and activate riged body
  113835. if (trans.getOrigin().x() != newPosition.x ||
  113836. trans.getOrigin().y() != newPosition.y ||
  113837. trans.getOrigin().z() != newPosition.z ||
  113838. trans.getRotation().x() != newRotation.x ||
  113839. trans.getRotation().y() != newRotation.y ||
  113840. trans.getRotation().z() != newRotation.z ||
  113841. trans.getRotation().w() != newRotation.w) {
  113842. this._tmpAmmoVectorA.setValue(newPosition.x, newPosition.y, newPosition.z);
  113843. trans.setOrigin(this._tmpAmmoVectorA);
  113844. this._tmpAmmoQuaternion.setValue(newRotation.x, newRotation.y, newRotation.z, newRotation.w);
  113845. trans.setRotation(this._tmpAmmoQuaternion);
  113846. impostor.physicsBody.setWorldTransform(trans);
  113847. if (impostor.mass == 0) {
  113848. // Kinematic objects must be updated using motion state
  113849. var motionState = impostor.physicsBody.getMotionState();
  113850. if (motionState) {
  113851. motionState.setWorldTransform(trans);
  113852. }
  113853. }
  113854. else {
  113855. impostor.physicsBody.activate();
  113856. }
  113857. }
  113858. };
  113859. /**
  113860. * If this plugin is supported
  113861. * @returns true if its supported
  113862. */
  113863. AmmoJSPlugin.prototype.isSupported = function () {
  113864. return this.bjsAMMO !== undefined;
  113865. };
  113866. /**
  113867. * Sets the linear velocity of the physics body
  113868. * @param impostor imposter to set the velocity on
  113869. * @param velocity velocity to set
  113870. */
  113871. AmmoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  113872. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  113873. if (impostor.soft) {
  113874. impostor.physicsBody.linearVelocity(this._tmpAmmoVectorA);
  113875. }
  113876. else {
  113877. impostor.physicsBody.setLinearVelocity(this._tmpAmmoVectorA);
  113878. }
  113879. };
  113880. /**
  113881. * Sets the angular velocity of the physics body
  113882. * @param impostor imposter to set the velocity on
  113883. * @param velocity velocity to set
  113884. */
  113885. AmmoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  113886. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  113887. if (impostor.soft) {
  113888. impostor.physicsBody.angularVelocity(this._tmpAmmoVectorA);
  113889. }
  113890. else {
  113891. impostor.physicsBody.setAngularVelocity(this._tmpAmmoVectorA);
  113892. }
  113893. };
  113894. /**
  113895. * gets the linear velocity
  113896. * @param impostor imposter to get linear velocity from
  113897. * @returns linear velocity
  113898. */
  113899. AmmoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  113900. if (impostor.soft) {
  113901. var v = impostor.physicsBody.linearVelocity();
  113902. }
  113903. else {
  113904. var v = impostor.physicsBody.getLinearVelocity();
  113905. }
  113906. if (!v) {
  113907. return null;
  113908. }
  113909. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  113910. };
  113911. /**
  113912. * gets the angular velocity
  113913. * @param impostor imposter to get angular velocity from
  113914. * @returns angular velocity
  113915. */
  113916. AmmoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  113917. if (impostor.soft) {
  113918. var v = impostor.physicsBody.angularVelocity();
  113919. }
  113920. else {
  113921. var v = impostor.physicsBody.getAngularVelocity();
  113922. }
  113923. if (!v) {
  113924. return null;
  113925. }
  113926. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  113927. };
  113928. /**
  113929. * Sets the mass of physics body
  113930. * @param impostor imposter to set the mass on
  113931. * @param mass mass to set
  113932. */
  113933. AmmoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  113934. if (impostor.soft) {
  113935. impostor.physicsBody.setTotalMass(mass, false);
  113936. }
  113937. else {
  113938. impostor.physicsBody.setMassProps(mass);
  113939. }
  113940. impostor._pluginData.mass = mass;
  113941. };
  113942. /**
  113943. * Gets the mass of the physics body
  113944. * @param impostor imposter to get the mass from
  113945. * @returns mass
  113946. */
  113947. AmmoJSPlugin.prototype.getBodyMass = function (impostor) {
  113948. return impostor._pluginData.mass;
  113949. };
  113950. /**
  113951. * Gets friction of the impostor
  113952. * @param impostor impostor to get friction from
  113953. * @returns friction value
  113954. */
  113955. AmmoJSPlugin.prototype.getBodyFriction = function (impostor) {
  113956. return impostor._pluginData.friction;
  113957. };
  113958. /**
  113959. * Sets friction of the impostor
  113960. * @param impostor impostor to set friction on
  113961. * @param friction friction value
  113962. */
  113963. AmmoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  113964. if (impostor.soft) {
  113965. impostor.physicsBody.get_m_cfg().set_kDF(friction);
  113966. }
  113967. else {
  113968. impostor.physicsBody.setFriction(friction);
  113969. }
  113970. impostor._pluginData.friction = friction;
  113971. };
  113972. /**
  113973. * Gets restitution of the impostor
  113974. * @param impostor impostor to get restitution from
  113975. * @returns restitution value
  113976. */
  113977. AmmoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  113978. return impostor._pluginData.restitution;
  113979. };
  113980. /**
  113981. * Sets resitution of the impostor
  113982. * @param impostor impostor to set resitution on
  113983. * @param restitution resitution value
  113984. */
  113985. AmmoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  113986. impostor.physicsBody.setRestitution(restitution);
  113987. impostor._pluginData.restitution = restitution;
  113988. };
  113989. /**
  113990. * Gets pressure inside the impostor
  113991. * @param impostor impostor to get pressure from
  113992. * @returns pressure value
  113993. */
  113994. AmmoJSPlugin.prototype.getBodyPressure = function (impostor) {
  113995. if (!impostor.soft) {
  113996. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Pressure is not a property of a rigid body");
  113997. return 0;
  113998. }
  113999. return impostor._pluginData.pressure;
  114000. };
  114001. /**
  114002. * Sets pressure inside a soft body impostor
  114003. * Cloth and rope must remain 0 pressure
  114004. * @param impostor impostor to set pressure on
  114005. * @param pressure pressure value
  114006. */
  114007. AmmoJSPlugin.prototype.setBodyPressure = function (impostor, pressure) {
  114008. if (impostor.soft) {
  114009. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SoftbodyImpostor) {
  114010. impostor.physicsBody.get_m_cfg().set_kPR(pressure);
  114011. impostor._pluginData.pressure = pressure;
  114012. }
  114013. else {
  114014. impostor.physicsBody.get_m_cfg().set_kPR(0);
  114015. impostor._pluginData.pressure = 0;
  114016. }
  114017. }
  114018. else {
  114019. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Pressure can only be applied to a softbody");
  114020. }
  114021. };
  114022. /**
  114023. * Gets stiffness of the impostor
  114024. * @param impostor impostor to get stiffness from
  114025. * @returns pressure value
  114026. */
  114027. AmmoJSPlugin.prototype.getBodyStiffness = function (impostor) {
  114028. if (!impostor.soft) {
  114029. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Stiffness is not a property of a rigid body");
  114030. return 0;
  114031. }
  114032. return impostor._pluginData.stiffness;
  114033. };
  114034. /**
  114035. * Sets stiffness of the impostor
  114036. * @param impostor impostor to set stiffness on
  114037. * @param stiffness stiffness value from 0 to 1
  114038. */
  114039. AmmoJSPlugin.prototype.setBodyStiffness = function (impostor, stiffness) {
  114040. if (impostor.soft) {
  114041. stiffness = stiffness < 0 ? 0 : stiffness;
  114042. stiffness = stiffness > 1 ? 1 : stiffness;
  114043. impostor.physicsBody.get_m_materials().at(0).set_m_kLST(stiffness);
  114044. impostor._pluginData.stiffness = stiffness;
  114045. }
  114046. else {
  114047. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Stiffness cannot be applied to a rigid body");
  114048. }
  114049. };
  114050. /**
  114051. * Gets velocityIterations of the impostor
  114052. * @param impostor impostor to get velocity iterations from
  114053. * @returns velocityIterations value
  114054. */
  114055. AmmoJSPlugin.prototype.getBodyVelocityIterations = function (impostor) {
  114056. if (!impostor.soft) {
  114057. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Velocity iterations is not a property of a rigid body");
  114058. return 0;
  114059. }
  114060. return impostor._pluginData.velocityIterations;
  114061. };
  114062. /**
  114063. * Sets velocityIterations of the impostor
  114064. * @param impostor impostor to set velocity iterations on
  114065. * @param velocityIterations velocityIterations value
  114066. */
  114067. AmmoJSPlugin.prototype.setBodyVelocityIterations = function (impostor, velocityIterations) {
  114068. if (impostor.soft) {
  114069. velocityIterations = velocityIterations < 0 ? 0 : velocityIterations;
  114070. impostor.physicsBody.get_m_cfg().set_viterations(velocityIterations);
  114071. impostor._pluginData.velocityIterations = velocityIterations;
  114072. }
  114073. else {
  114074. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Velocity iterations cannot be applied to a rigid body");
  114075. }
  114076. };
  114077. /**
  114078. * Gets positionIterations of the impostor
  114079. * @param impostor impostor to get position iterations from
  114080. * @returns positionIterations value
  114081. */
  114082. AmmoJSPlugin.prototype.getBodyPositionIterations = function (impostor) {
  114083. if (!impostor.soft) {
  114084. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Position iterations is not a property of a rigid body");
  114085. return 0;
  114086. }
  114087. return impostor._pluginData.positionIterations;
  114088. };
  114089. /**
  114090. * Sets positionIterations of the impostor
  114091. * @param impostor impostor to set position on
  114092. * @param positionIterations positionIterations value
  114093. */
  114094. AmmoJSPlugin.prototype.setBodyPositionIterations = function (impostor, positionIterations) {
  114095. if (impostor.soft) {
  114096. positionIterations = positionIterations < 0 ? 0 : positionIterations;
  114097. impostor.physicsBody.get_m_cfg().set_piterations(positionIterations);
  114098. impostor._pluginData.positionIterations = positionIterations;
  114099. }
  114100. else {
  114101. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Position iterations cannot be applied to a rigid body");
  114102. }
  114103. };
  114104. /**
  114105. * Append an anchor to a cloth object
  114106. * @param impostor is the cloth impostor to add anchor to
  114107. * @param otherImpostor is the rigid impostor to anchor to
  114108. * @param width ratio across width from 0 to 1
  114109. * @param height ratio up height from 0 to 1
  114110. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  114111. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  114112. */
  114113. AmmoJSPlugin.prototype.appendAnchor = function (impostor, otherImpostor, width, height, influence, noCollisionBetweenLinkedBodies) {
  114114. if (influence === void 0) { influence = 1; }
  114115. if (noCollisionBetweenLinkedBodies === void 0) { noCollisionBetweenLinkedBodies = false; }
  114116. var segs = impostor.segments;
  114117. var nbAcross = Math.round((segs - 1) * width);
  114118. var nbUp = Math.round((segs - 1) * height);
  114119. var nbDown = segs - 1 - nbUp;
  114120. var node = nbAcross + segs * nbDown;
  114121. impostor.physicsBody.appendAnchor(node, otherImpostor.physicsBody, noCollisionBetweenLinkedBodies, influence);
  114122. };
  114123. /**
  114124. * Append an hook to a rope object
  114125. * @param impostor is the rope impostor to add hook to
  114126. * @param otherImpostor is the rigid impostor to hook to
  114127. * @param length ratio along the rope from 0 to 1
  114128. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  114129. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  114130. */
  114131. AmmoJSPlugin.prototype.appendHook = function (impostor, otherImpostor, length, influence, noCollisionBetweenLinkedBodies) {
  114132. if (influence === void 0) { influence = 1; }
  114133. if (noCollisionBetweenLinkedBodies === void 0) { noCollisionBetweenLinkedBodies = false; }
  114134. var node = Math.round(impostor.segments * length);
  114135. impostor.physicsBody.appendAnchor(node, otherImpostor.physicsBody, noCollisionBetweenLinkedBodies, influence);
  114136. };
  114137. /**
  114138. * Sleeps the physics body and stops it from being active
  114139. * @param impostor impostor to sleep
  114140. */
  114141. AmmoJSPlugin.prototype.sleepBody = function (impostor) {
  114142. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("sleepBody is not currently supported by the Ammo physics plugin");
  114143. };
  114144. /**
  114145. * Activates the physics body
  114146. * @param impostor impostor to activate
  114147. */
  114148. AmmoJSPlugin.prototype.wakeUpBody = function (impostor) {
  114149. impostor.physicsBody.activate();
  114150. };
  114151. /**
  114152. * Updates the distance parameters of the joint
  114153. * @param joint joint to update
  114154. * @param maxDistance maximum distance of the joint
  114155. * @param minDistance minimum distance of the joint
  114156. */
  114157. AmmoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  114158. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin");
  114159. };
  114160. /**
  114161. * Sets a motor on the joint
  114162. * @param joint joint to set motor on
  114163. * @param speed speed of the motor
  114164. * @param maxForce maximum force of the motor
  114165. * @param motorIndex index of the motor
  114166. */
  114167. AmmoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  114168. joint.physicsJoint.enableAngularMotor(true, speed, maxForce);
  114169. };
  114170. /**
  114171. * Sets the motors limit
  114172. * @param joint joint to set limit on
  114173. * @param upperLimit upper limit
  114174. * @param lowerLimit lower limit
  114175. */
  114176. AmmoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  114177. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("setLimit is not currently supported by the Ammo physics plugin");
  114178. };
  114179. /**
  114180. * Syncs the position and rotation of a mesh with the impostor
  114181. * @param mesh mesh to sync
  114182. * @param impostor impostor to update the mesh with
  114183. */
  114184. AmmoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  114185. var body = impostor.physicsBody;
  114186. body.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  114187. mesh.position.x = this._tmpAmmoTransform.getOrigin().x();
  114188. mesh.position.y = this._tmpAmmoTransform.getOrigin().y();
  114189. mesh.position.z = this._tmpAmmoTransform.getOrigin().z();
  114190. if (mesh.rotationQuaternion) {
  114191. mesh.rotationQuaternion.x = this._tmpAmmoTransform.getRotation().x();
  114192. mesh.rotationQuaternion.y = this._tmpAmmoTransform.getRotation().y();
  114193. mesh.rotationQuaternion.z = this._tmpAmmoTransform.getRotation().z();
  114194. mesh.rotationQuaternion.w = this._tmpAmmoTransform.getRotation().w();
  114195. }
  114196. };
  114197. /**
  114198. * Gets the radius of the impostor
  114199. * @param impostor impostor to get radius from
  114200. * @returns the radius
  114201. */
  114202. AmmoJSPlugin.prototype.getRadius = function (impostor) {
  114203. var exntend = impostor.getObjectExtendSize();
  114204. return exntend.x / 2;
  114205. };
  114206. /**
  114207. * Gets the box size of the impostor
  114208. * @param impostor impostor to get box size from
  114209. * @param result the resulting box size
  114210. */
  114211. AmmoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  114212. var exntend = impostor.getObjectExtendSize();
  114213. result.x = exntend.x;
  114214. result.y = exntend.y;
  114215. result.z = exntend.z;
  114216. };
  114217. /**
  114218. * Disposes of the impostor
  114219. */
  114220. AmmoJSPlugin.prototype.dispose = function () {
  114221. // Dispose of world
  114222. Ammo.destroy(this.world);
  114223. Ammo.destroy(this._solver);
  114224. Ammo.destroy(this._overlappingPairCache);
  114225. Ammo.destroy(this._dispatcher);
  114226. Ammo.destroy(this._collisionConfiguration);
  114227. // Dispose of tmp variables
  114228. Ammo.destroy(this._tmpAmmoVectorA);
  114229. Ammo.destroy(this._tmpAmmoVectorB);
  114230. Ammo.destroy(this._tmpAmmoVectorC);
  114231. Ammo.destroy(this._tmpAmmoTransform);
  114232. Ammo.destroy(this._tmpAmmoQuaternion);
  114233. Ammo.destroy(this._tmpAmmoConcreteContactResultCallback);
  114234. this.world = null;
  114235. };
  114236. /**
  114237. * Does a raycast in the physics world
  114238. * @param from when should the ray start?
  114239. * @param to when should the ray end?
  114240. * @returns PhysicsRaycastResult
  114241. */
  114242. AmmoJSPlugin.prototype.raycast = function (from, to) {
  114243. this._tmpAmmoVectorRCA = new this.bjsAMMO.btVector3(from.x, from.y, from.z);
  114244. this._tmpAmmoVectorRCB = new this.bjsAMMO.btVector3(to.x, to.y, to.z);
  114245. var rayCallback = new this.bjsAMMO.ClosestRayResultCallback(this._tmpAmmoVectorRCA, this._tmpAmmoVectorRCB);
  114246. this.world.rayTest(this._tmpAmmoVectorRCA, this._tmpAmmoVectorRCB, rayCallback);
  114247. this._raycastResult.reset(from, to);
  114248. if (rayCallback.hasHit()) {
  114249. // TODO: do we want/need the body? If so, set all the data
  114250. /*
  114251. var rigidBody = this.bjsAMMO.btRigidBody.prototype.upcast(
  114252. rayCallback.get_m_collisionObject()
  114253. );
  114254. var body = {};
  114255. */
  114256. this._raycastResult.setHitData({
  114257. x: rayCallback.get_m_hitNormalWorld().x(),
  114258. y: rayCallback.get_m_hitNormalWorld().y(),
  114259. z: rayCallback.get_m_hitNormalWorld().z(),
  114260. }, {
  114261. x: rayCallback.get_m_hitPointWorld().x(),
  114262. y: rayCallback.get_m_hitPointWorld().y(),
  114263. z: rayCallback.get_m_hitPointWorld().z(),
  114264. });
  114265. this._raycastResult.calculateHitDistance();
  114266. }
  114267. return this._raycastResult;
  114268. };
  114269. AmmoJSPlugin.DISABLE_COLLISION_FLAG = 4;
  114270. AmmoJSPlugin.KINEMATIC_FLAG = 2;
  114271. AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG = 4;
  114272. return AmmoJSPlugin;
  114273. }());
  114274. /***/ }),
  114275. /***/ "./Physics/Plugins/cannonJSPlugin.ts":
  114276. /*!*******************************************!*\
  114277. !*** ./Physics/Plugins/cannonJSPlugin.ts ***!
  114278. \*******************************************/
  114279. /*! exports provided: CannonJSPlugin */
  114280. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114281. "use strict";
  114282. __webpack_require__.r(__webpack_exports__);
  114283. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return CannonJSPlugin; });
  114284. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  114285. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  114286. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  114287. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  114288. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  114289. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  114290. /* harmony import */ var _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../physicsRaycastResult */ "./Physics/physicsRaycastResult.ts");
  114291. /** @hidden */
  114292. var CannonJSPlugin = /** @class */ (function () {
  114293. function CannonJSPlugin(_useDeltaForWorldStep, iterations, cannonInjection) {
  114294. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  114295. if (iterations === void 0) { iterations = 10; }
  114296. if (cannonInjection === void 0) { cannonInjection = CANNON; }
  114297. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  114298. this.name = "CannonJSPlugin";
  114299. this._physicsMaterials = new Array();
  114300. this._fixedTimeStep = 1 / 60;
  114301. this._removeAfterStep = new Array();
  114302. this._minus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-0.7071067811865475, 0, 0, 0.7071067811865475);
  114303. this._plus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](0.7071067811865475, 0, 0, 0.7071067811865475);
  114304. this._tmpPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  114305. this._tmpDeltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  114306. this._tmpUnityRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  114307. this.BJSCANNON = cannonInjection;
  114308. if (!this.isSupported()) {
  114309. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("CannonJS is not available. Please make sure you included the js file.");
  114310. return;
  114311. }
  114312. this._extendNamespace();
  114313. this.world = new this.BJSCANNON.World();
  114314. this.world.broadphase = new this.BJSCANNON.NaiveBroadphase();
  114315. this.world.solver.iterations = iterations;
  114316. this._cannonRaycastResult = new this.BJSCANNON.RaycastResult();
  114317. this._raycastResult = new _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_6__["PhysicsRaycastResult"]();
  114318. }
  114319. CannonJSPlugin.prototype.setGravity = function (gravity) {
  114320. this.world.gravity.copy(gravity);
  114321. };
  114322. CannonJSPlugin.prototype.setTimeStep = function (timeStep) {
  114323. this._fixedTimeStep = timeStep;
  114324. };
  114325. CannonJSPlugin.prototype.getTimeStep = function () {
  114326. return this._fixedTimeStep;
  114327. };
  114328. CannonJSPlugin.prototype.executeStep = function (delta) {
  114329. var _this = this;
  114330. this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta : 0, 3);
  114331. if (this._removeAfterStep.length > 0) {
  114332. this._removeAfterStep.forEach(function (impostor) {
  114333. _this.world.remove(impostor.physicsBody);
  114334. });
  114335. this._removeAfterStep = [];
  114336. }
  114337. };
  114338. CannonJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  114339. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  114340. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  114341. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  114342. };
  114343. CannonJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  114344. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  114345. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  114346. impostor.physicsBody.applyForce(impulse, worldPoint);
  114347. };
  114348. CannonJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  114349. //parent-child relationship. Does this impostor has a parent impostor?
  114350. if (impostor.parent) {
  114351. if (impostor.physicsBody) {
  114352. this.removePhysicsBody(impostor);
  114353. //TODO is that needed?
  114354. impostor.forceUpdate();
  114355. }
  114356. return;
  114357. }
  114358. //should a new body be created for this impostor?
  114359. if (impostor.isBodyInitRequired()) {
  114360. var shape = this._createShape(impostor);
  114361. //unregister events, if body is being changed
  114362. var oldBody = impostor.physicsBody;
  114363. if (oldBody) {
  114364. this.removePhysicsBody(impostor);
  114365. }
  114366. //create the body and material
  114367. var material = this._addMaterial("mat-" + impostor.uniqueId, impostor.getParam("friction"), impostor.getParam("restitution"));
  114368. var bodyCreationObject = {
  114369. mass: impostor.getParam("mass"),
  114370. material: material
  114371. };
  114372. // A simple extend, in case native options were used.
  114373. var nativeOptions = impostor.getParam("nativeOptions");
  114374. for (var key in nativeOptions) {
  114375. if (nativeOptions.hasOwnProperty(key)) {
  114376. bodyCreationObject[key] = nativeOptions[key];
  114377. }
  114378. }
  114379. impostor.physicsBody = new this.BJSCANNON.Body(bodyCreationObject);
  114380. impostor.physicsBody.addEventListener("collide", impostor.onCollide);
  114381. this.world.addEventListener("preStep", impostor.beforeStep);
  114382. this.world.addEventListener("postStep", impostor.afterStep);
  114383. impostor.physicsBody.addShape(shape);
  114384. this.world.add(impostor.physicsBody);
  114385. //try to keep the body moving in the right direction by taking old properties.
  114386. //Should be tested!
  114387. if (oldBody) {
  114388. ['force', 'torque', 'velocity', 'angularVelocity'].forEach(function (param) {
  114389. impostor.physicsBody[param].copy(oldBody[param]);
  114390. });
  114391. }
  114392. this._processChildMeshes(impostor);
  114393. }
  114394. //now update the body's transformation
  114395. this._updatePhysicsBodyTransformation(impostor);
  114396. };
  114397. CannonJSPlugin.prototype._processChildMeshes = function (mainImpostor) {
  114398. var _this = this;
  114399. var meshChildren = mainImpostor.object.getChildMeshes ? mainImpostor.object.getChildMeshes(true) : [];
  114400. var currentRotation = mainImpostor.object.rotationQuaternion;
  114401. if (meshChildren.length) {
  114402. var processMesh = function (localPosition, mesh) {
  114403. if (!currentRotation || !mesh.rotationQuaternion) {
  114404. return;
  114405. }
  114406. var childImpostor = mesh.getPhysicsImpostor();
  114407. if (childImpostor) {
  114408. var parent = childImpostor.parent;
  114409. if (parent !== mainImpostor) {
  114410. var pPosition = mesh.getAbsolutePosition().subtract(mainImpostor.object.getAbsolutePosition());
  114411. var localRotation = mesh.rotationQuaternion.multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Inverse(currentRotation));
  114412. if (childImpostor.physicsBody) {
  114413. _this.removePhysicsBody(childImpostor);
  114414. childImpostor.physicsBody = null;
  114415. }
  114416. childImpostor.parent = mainImpostor;
  114417. childImpostor.resetUpdateFlags();
  114418. 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));
  114419. //Add the mass of the children.
  114420. mainImpostor.physicsBody.mass += childImpostor.getParam("mass");
  114421. }
  114422. }
  114423. currentRotation.multiplyInPlace(mesh.rotationQuaternion);
  114424. mesh.getChildMeshes(true).filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(_this, mesh.getAbsolutePosition()));
  114425. };
  114426. meshChildren.filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(this, mainImpostor.object.getAbsolutePosition()));
  114427. }
  114428. };
  114429. CannonJSPlugin.prototype.removePhysicsBody = function (impostor) {
  114430. impostor.physicsBody.removeEventListener("collide", impostor.onCollide);
  114431. this.world.removeEventListener("preStep", impostor.beforeStep);
  114432. this.world.removeEventListener("postStep", impostor.afterStep);
  114433. // Only remove the physics body after the physics step to avoid disrupting cannon's internal state
  114434. this._removeAfterStep.push(impostor);
  114435. };
  114436. CannonJSPlugin.prototype.generateJoint = function (impostorJoint) {
  114437. var mainBody = impostorJoint.mainImpostor.physicsBody;
  114438. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  114439. if (!mainBody || !connectedBody) {
  114440. return;
  114441. }
  114442. var constraint;
  114443. var jointData = impostorJoint.joint.jointData;
  114444. //TODO - https://github.com/schteppe/this.BJSCANNON.js/blob/gh-pages/demos/collisionFilter.html
  114445. var constraintData = {
  114446. pivotA: jointData.mainPivot ? new this.BJSCANNON.Vec3().copy(jointData.mainPivot) : null,
  114447. pivotB: jointData.connectedPivot ? new this.BJSCANNON.Vec3().copy(jointData.connectedPivot) : null,
  114448. axisA: jointData.mainAxis ? new this.BJSCANNON.Vec3().copy(jointData.mainAxis) : null,
  114449. axisB: jointData.connectedAxis ? new this.BJSCANNON.Vec3().copy(jointData.connectedAxis) : null,
  114450. maxForce: jointData.nativeParams.maxForce,
  114451. collideConnected: !!jointData.collision
  114452. };
  114453. switch (impostorJoint.joint.type) {
  114454. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].HingeJoint:
  114455. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].Hinge2Joint:
  114456. constraint = new this.BJSCANNON.HingeConstraint(mainBody, connectedBody, constraintData);
  114457. break;
  114458. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].DistanceJoint:
  114459. constraint = new this.BJSCANNON.DistanceConstraint(mainBody, connectedBody, jointData.maxDistance || 2);
  114460. break;
  114461. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint:
  114462. var springData = jointData;
  114463. constraint = new this.BJSCANNON.Spring(mainBody, connectedBody, {
  114464. restLength: springData.length,
  114465. stiffness: springData.stiffness,
  114466. damping: springData.damping,
  114467. localAnchorA: constraintData.pivotA,
  114468. localAnchorB: constraintData.pivotB
  114469. });
  114470. break;
  114471. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].LockJoint:
  114472. constraint = new this.BJSCANNON.LockConstraint(mainBody, connectedBody, constraintData);
  114473. break;
  114474. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].PointToPointJoint:
  114475. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].BallAndSocketJoint:
  114476. default:
  114477. constraint = new this.BJSCANNON.PointToPointConstraint(mainBody, constraintData.pivotA, connectedBody, constraintData.pivotB, constraintData.maxForce);
  114478. break;
  114479. }
  114480. //set the collideConnected flag after the creation, since DistanceJoint ignores it.
  114481. constraint.collideConnected = !!jointData.collision;
  114482. impostorJoint.joint.physicsJoint = constraint;
  114483. //don't add spring as constraint, as it is not one.
  114484. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  114485. this.world.addConstraint(constraint);
  114486. }
  114487. else {
  114488. impostorJoint.joint.jointData.forceApplicationCallback = impostorJoint.joint.jointData.forceApplicationCallback || function () {
  114489. constraint.applyForce();
  114490. };
  114491. impostorJoint.mainImpostor.registerAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  114492. }
  114493. };
  114494. CannonJSPlugin.prototype.removeJoint = function (impostorJoint) {
  114495. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  114496. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  114497. }
  114498. else {
  114499. impostorJoint.mainImpostor.unregisterAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  114500. }
  114501. };
  114502. CannonJSPlugin.prototype._addMaterial = function (name, friction, restitution) {
  114503. var index;
  114504. var mat;
  114505. for (index = 0; index < this._physicsMaterials.length; index++) {
  114506. mat = this._physicsMaterials[index];
  114507. if (mat.friction === friction && mat.restitution === restitution) {
  114508. return mat;
  114509. }
  114510. }
  114511. var currentMat = new this.BJSCANNON.Material(name);
  114512. currentMat.friction = friction;
  114513. currentMat.restitution = restitution;
  114514. this._physicsMaterials.push(currentMat);
  114515. return currentMat;
  114516. };
  114517. CannonJSPlugin.prototype._checkWithEpsilon = function (value) {
  114518. return value < _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon ? _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon : value;
  114519. };
  114520. CannonJSPlugin.prototype._createShape = function (impostor) {
  114521. var object = impostor.object;
  114522. var returnValue;
  114523. var extendSize = impostor.getObjectExtendSize();
  114524. switch (impostor.type) {
  114525. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].SphereImpostor:
  114526. var radiusX = extendSize.x;
  114527. var radiusY = extendSize.y;
  114528. var radiusZ = extendSize.z;
  114529. returnValue = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(radiusX), this._checkWithEpsilon(radiusY), this._checkWithEpsilon(radiusZ)) / 2);
  114530. break;
  114531. //TMP also for cylinder - TODO Cannon supports cylinder natively.
  114532. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].CylinderImpostor:
  114533. var nativeParams = impostor.getParam("nativeOptions");
  114534. if (!nativeParams) {
  114535. nativeParams = {};
  114536. }
  114537. var radiusTop = nativeParams.radiusTop !== undefined ? nativeParams.radiusTop : this._checkWithEpsilon(extendSize.x) / 2;
  114538. var radiusBottom = nativeParams.radiusBottom !== undefined ? nativeParams.radiusBottom : this._checkWithEpsilon(extendSize.x) / 2;
  114539. var height = nativeParams.height !== undefined ? nativeParams.height : this._checkWithEpsilon(extendSize.y);
  114540. var numSegments = nativeParams.numSegments !== undefined ? nativeParams.numSegments : 16;
  114541. returnValue = new this.BJSCANNON.Cylinder(radiusTop, radiusBottom, height, numSegments);
  114542. // Rotate 90 degrees as this shape is horizontal in cannon
  114543. var quat = new this.BJSCANNON.Quaternion();
  114544. quat.setFromAxisAngle(new this.BJSCANNON.Vec3(1, 0, 0), -Math.PI / 2);
  114545. var translation = new this.BJSCANNON.Vec3(0, 0, 0);
  114546. returnValue.transformAllPoints(translation, quat);
  114547. break;
  114548. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].BoxImpostor:
  114549. var box = extendSize.scale(0.5);
  114550. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z)));
  114551. break;
  114552. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor:
  114553. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead");
  114554. returnValue = new this.BJSCANNON.Plane();
  114555. break;
  114556. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor:
  114557. // should transform the vertex data to world coordinates!!
  114558. var rawVerts = object.getVerticesData ? object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) : [];
  114559. var rawFaces = object.getIndices ? object.getIndices() : [];
  114560. if (!rawVerts) {
  114561. return;
  114562. }
  114563. // get only scale! so the object could transform correctly.
  114564. var oldPosition = object.position.clone();
  114565. var oldRotation = object.rotation && object.rotation.clone();
  114566. var oldQuaternion = object.rotationQuaternion && object.rotationQuaternion.clone();
  114567. object.position.copyFromFloats(0, 0, 0);
  114568. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  114569. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  114570. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  114571. var transform = object.computeWorldMatrix(true);
  114572. // convert rawVerts to object space
  114573. var temp = new Array();
  114574. var index;
  114575. for (index = 0; index < rawVerts.length; index += 3) {
  114576. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(rawVerts, index), transform).toArray(temp, index);
  114577. }
  114578. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("MeshImpostor only collides against spheres.");
  114579. returnValue = new this.BJSCANNON.Trimesh(temp, rawFaces);
  114580. //now set back the transformation!
  114581. object.position.copyFrom(oldPosition);
  114582. oldRotation && object.rotation && object.rotation.copyFrom(oldRotation);
  114583. oldQuaternion && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion);
  114584. break;
  114585. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor:
  114586. var oldPosition2 = object.position.clone();
  114587. var oldRotation2 = object.rotation && object.rotation.clone();
  114588. var oldQuaternion2 = object.rotationQuaternion && object.rotationQuaternion.clone();
  114589. object.position.copyFromFloats(0, 0, 0);
  114590. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  114591. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  114592. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  114593. object.rotationQuaternion && object.rotationQuaternion.multiplyInPlace(this._minus90X);
  114594. returnValue = this._createHeightmap(object);
  114595. object.position.copyFrom(oldPosition2);
  114596. oldRotation2 && object.rotation && object.rotation.copyFrom(oldRotation2);
  114597. oldQuaternion2 && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion2);
  114598. object.computeWorldMatrix(true);
  114599. break;
  114600. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].ParticleImpostor:
  114601. returnValue = new this.BJSCANNON.Particle();
  114602. break;
  114603. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].NoImpostor:
  114604. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0, 0, 0));
  114605. break;
  114606. }
  114607. return returnValue;
  114608. };
  114609. CannonJSPlugin.prototype._createHeightmap = function (object, pointDepth) {
  114610. var pos = (object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  114611. var transform = object.computeWorldMatrix(true);
  114612. // convert rawVerts to object space
  114613. var temp = new Array();
  114614. var index;
  114615. for (index = 0; index < pos.length; index += 3) {
  114616. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(pos, index), transform).toArray(temp, index);
  114617. }
  114618. pos = temp;
  114619. var matrix = new Array();
  114620. //For now pointDepth will not be used and will be automatically calculated.
  114621. //Future reference - try and find the best place to add a reference to the pointDepth variable.
  114622. var arraySize = pointDepth || ~~(Math.sqrt(pos.length / 3) - 1);
  114623. var boundingInfo = object.getBoundingInfo();
  114624. var dim = Math.min(boundingInfo.boundingBox.extendSizeWorld.x, boundingInfo.boundingBox.extendSizeWorld.y);
  114625. var minY = boundingInfo.boundingBox.extendSizeWorld.z;
  114626. var elementSize = dim * 2 / arraySize;
  114627. for (var i = 0; i < pos.length; i = i + 3) {
  114628. var x = Math.round((pos[i + 0]) / elementSize + arraySize / 2);
  114629. var z = Math.round(((pos[i + 1]) / elementSize - arraySize / 2) * -1);
  114630. var y = -pos[i + 2] + minY;
  114631. if (!matrix[x]) {
  114632. matrix[x] = [];
  114633. }
  114634. if (!matrix[x][z]) {
  114635. matrix[x][z] = y;
  114636. }
  114637. matrix[x][z] = Math.max(y, matrix[x][z]);
  114638. }
  114639. for (var x = 0; x <= arraySize; ++x) {
  114640. if (!matrix[x]) {
  114641. var loc = 1;
  114642. while (!matrix[(x + loc) % arraySize]) {
  114643. loc++;
  114644. }
  114645. matrix[x] = matrix[(x + loc) % arraySize].slice();
  114646. //console.log("missing x", x);
  114647. }
  114648. for (var z = 0; z <= arraySize; ++z) {
  114649. if (!matrix[x][z]) {
  114650. var loc = 1;
  114651. var newValue;
  114652. while (newValue === undefined) {
  114653. newValue = matrix[x][(z + loc++) % arraySize];
  114654. }
  114655. matrix[x][z] = newValue;
  114656. }
  114657. }
  114658. }
  114659. var shape = new this.BJSCANNON.Heightfield(matrix, {
  114660. elementSize: elementSize
  114661. });
  114662. //For future reference, needed for body transformation
  114663. shape.minY = minY;
  114664. return shape;
  114665. };
  114666. CannonJSPlugin.prototype._updatePhysicsBodyTransformation = function (impostor) {
  114667. var object = impostor.object;
  114668. //make sure it is updated...
  114669. object.computeWorldMatrix && object.computeWorldMatrix(true);
  114670. // The delta between the mesh position and the mesh bounding box center
  114671. var bInfo = object.getBoundingInfo();
  114672. if (!bInfo) {
  114673. return;
  114674. }
  114675. var center = impostor.getObjectCenter();
  114676. //m.getAbsolutePosition().subtract(m.getBoundingInfo().boundingBox.centerWorld)
  114677. this._tmpDeltaPosition.copyFrom(object.getAbsolutePivotPoint().subtract(center));
  114678. this._tmpDeltaPosition.divideInPlace(impostor.object.scaling);
  114679. this._tmpPosition.copyFrom(center);
  114680. var quaternion = object.rotationQuaternion;
  114681. if (!quaternion) {
  114682. return;
  114683. }
  114684. //is shape is a plane or a heightmap, it must be rotated 90 degs in the X axis.
  114685. //ideally these would be rotated at time of creation like cylinder but they dont extend ConvexPolyhedron
  114686. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor || impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  114687. //-90 DEG in X, precalculated
  114688. quaternion = quaternion.multiply(this._minus90X);
  114689. //Invert! (Precalculated, 90 deg in X)
  114690. //No need to clone. this will never change.
  114691. impostor.setDeltaRotation(this._plus90X);
  114692. }
  114693. //If it is a heightfield, if should be centered.
  114694. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  114695. var mesh = object;
  114696. var boundingInfo = mesh.getBoundingInfo();
  114697. //calculate the correct body position:
  114698. var rotationQuaternion = mesh.rotationQuaternion;
  114699. mesh.rotationQuaternion = this._tmpUnityRotation;
  114700. mesh.computeWorldMatrix(true);
  114701. //get original center with no rotation
  114702. var c = center.clone();
  114703. var oldPivot = mesh.getPivotMatrix();
  114704. if (oldPivot) {
  114705. // create a copy the pivot Matrix as it is modified in place
  114706. oldPivot = oldPivot.clone();
  114707. }
  114708. else {
  114709. oldPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  114710. }
  114711. //calculate the new center using a pivot (since this.BJSCANNON.js doesn't center height maps)
  114712. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Translation(boundingInfo.boundingBox.extendSizeWorld.x, 0, -boundingInfo.boundingBox.extendSizeWorld.z);
  114713. mesh.setPreTransformMatrix(p);
  114714. mesh.computeWorldMatrix(true);
  114715. //calculate the translation
  114716. var translation = boundingInfo.boundingBox.centerWorld.subtract(center).subtract(mesh.position).negate();
  114717. this._tmpPosition.copyFromFloats(translation.x, translation.y - boundingInfo.boundingBox.extendSizeWorld.y, translation.z);
  114718. //add it inverted to the delta
  114719. this._tmpDeltaPosition.copyFrom(boundingInfo.boundingBox.centerWorld.subtract(c));
  114720. this._tmpDeltaPosition.y += boundingInfo.boundingBox.extendSizeWorld.y;
  114721. //rotation is back
  114722. mesh.rotationQuaternion = rotationQuaternion;
  114723. mesh.setPreTransformMatrix(oldPivot);
  114724. mesh.computeWorldMatrix(true);
  114725. }
  114726. else if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor) {
  114727. this._tmpDeltaPosition.copyFromFloats(0, 0, 0);
  114728. //this._tmpPosition.copyFrom(object.position);
  114729. }
  114730. impostor.setDeltaPosition(this._tmpDeltaPosition);
  114731. //Now update the impostor object
  114732. impostor.physicsBody.position.copy(this._tmpPosition);
  114733. impostor.physicsBody.quaternion.copy(quaternion);
  114734. };
  114735. CannonJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  114736. impostor.object.position.copyFrom(impostor.physicsBody.position);
  114737. if (impostor.object.rotationQuaternion) {
  114738. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.quaternion);
  114739. }
  114740. };
  114741. CannonJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  114742. impostor.physicsBody.position.copy(newPosition);
  114743. impostor.physicsBody.quaternion.copy(newRotation);
  114744. };
  114745. CannonJSPlugin.prototype.isSupported = function () {
  114746. return this.BJSCANNON !== undefined;
  114747. };
  114748. CannonJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  114749. impostor.physicsBody.velocity.copy(velocity);
  114750. };
  114751. CannonJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  114752. impostor.physicsBody.angularVelocity.copy(velocity);
  114753. };
  114754. CannonJSPlugin.prototype.getLinearVelocity = function (impostor) {
  114755. var v = impostor.physicsBody.velocity;
  114756. if (!v) {
  114757. return null;
  114758. }
  114759. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  114760. };
  114761. CannonJSPlugin.prototype.getAngularVelocity = function (impostor) {
  114762. var v = impostor.physicsBody.angularVelocity;
  114763. if (!v) {
  114764. return null;
  114765. }
  114766. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  114767. };
  114768. CannonJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  114769. impostor.physicsBody.mass = mass;
  114770. impostor.physicsBody.updateMassProperties();
  114771. };
  114772. CannonJSPlugin.prototype.getBodyMass = function (impostor) {
  114773. return impostor.physicsBody.mass;
  114774. };
  114775. CannonJSPlugin.prototype.getBodyFriction = function (impostor) {
  114776. return impostor.physicsBody.material.friction;
  114777. };
  114778. CannonJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  114779. impostor.physicsBody.material.friction = friction;
  114780. };
  114781. CannonJSPlugin.prototype.getBodyRestitution = function (impostor) {
  114782. return impostor.physicsBody.material.restitution;
  114783. };
  114784. CannonJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  114785. impostor.physicsBody.material.restitution = restitution;
  114786. };
  114787. CannonJSPlugin.prototype.sleepBody = function (impostor) {
  114788. impostor.physicsBody.sleep();
  114789. };
  114790. CannonJSPlugin.prototype.wakeUpBody = function (impostor) {
  114791. impostor.physicsBody.wakeUp();
  114792. };
  114793. CannonJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance) {
  114794. joint.physicsJoint.distance = maxDistance;
  114795. };
  114796. // private enableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  114797. // if (!motorIndex) {
  114798. // joint.physicsJoint.enableMotor();
  114799. // }
  114800. // }
  114801. // private disableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  114802. // if (!motorIndex) {
  114803. // joint.physicsJoint.disableMotor();
  114804. // }
  114805. // }
  114806. CannonJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  114807. if (!motorIndex) {
  114808. joint.physicsJoint.enableMotor();
  114809. joint.physicsJoint.setMotorSpeed(speed);
  114810. if (maxForce) {
  114811. this.setLimit(joint, maxForce);
  114812. }
  114813. }
  114814. };
  114815. CannonJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  114816. joint.physicsJoint.motorEquation.maxForce = upperLimit;
  114817. joint.physicsJoint.motorEquation.minForce = lowerLimit === void 0 ? -upperLimit : lowerLimit;
  114818. };
  114819. CannonJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  114820. var body = impostor.physicsBody;
  114821. mesh.position.x = body.position.x;
  114822. mesh.position.y = body.position.y;
  114823. mesh.position.z = body.position.z;
  114824. if (mesh.rotationQuaternion) {
  114825. mesh.rotationQuaternion.x = body.quaternion.x;
  114826. mesh.rotationQuaternion.y = body.quaternion.y;
  114827. mesh.rotationQuaternion.z = body.quaternion.z;
  114828. mesh.rotationQuaternion.w = body.quaternion.w;
  114829. }
  114830. };
  114831. CannonJSPlugin.prototype.getRadius = function (impostor) {
  114832. var shape = impostor.physicsBody.shapes[0];
  114833. return shape.boundingSphereRadius;
  114834. };
  114835. CannonJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  114836. var shape = impostor.physicsBody.shapes[0];
  114837. result.x = shape.halfExtents.x * 2;
  114838. result.y = shape.halfExtents.y * 2;
  114839. result.z = shape.halfExtents.z * 2;
  114840. };
  114841. CannonJSPlugin.prototype.dispose = function () {
  114842. };
  114843. CannonJSPlugin.prototype._extendNamespace = function () {
  114844. //this will force cannon to execute at least one step when using interpolation
  114845. var step_tmp1 = new this.BJSCANNON.Vec3();
  114846. var Engine = this.BJSCANNON;
  114847. this.BJSCANNON.World.prototype.step = function (dt, timeSinceLastCalled, maxSubSteps) {
  114848. maxSubSteps = maxSubSteps || 10;
  114849. timeSinceLastCalled = timeSinceLastCalled || 0;
  114850. if (timeSinceLastCalled === 0) {
  114851. this.internalStep(dt);
  114852. this.time += dt;
  114853. }
  114854. else {
  114855. var internalSteps = Math.floor((this.time + timeSinceLastCalled) / dt) - Math.floor(this.time / dt);
  114856. internalSteps = Math.min(internalSteps, maxSubSteps) || 1;
  114857. var t0 = performance.now();
  114858. for (var i = 0; i !== internalSteps; i++) {
  114859. this.internalStep(dt);
  114860. if (performance.now() - t0 > dt * 1000) {
  114861. break;
  114862. }
  114863. }
  114864. this.time += timeSinceLastCalled;
  114865. var h = this.time % dt;
  114866. var h_div_dt = h / dt;
  114867. var interpvelo = step_tmp1;
  114868. var bodies = this.bodies;
  114869. for (var j = 0; j !== bodies.length; j++) {
  114870. var b = bodies[j];
  114871. if (b.type !== Engine.Body.STATIC && b.sleepState !== Engine.Body.SLEEPING) {
  114872. b.position.vsub(b.previousPosition, interpvelo);
  114873. interpvelo.scale(h_div_dt, interpvelo);
  114874. b.position.vadd(interpvelo, b.interpolatedPosition);
  114875. }
  114876. else {
  114877. b.interpolatedPosition.copy(b.position);
  114878. b.interpolatedQuaternion.copy(b.quaternion);
  114879. }
  114880. }
  114881. }
  114882. };
  114883. };
  114884. /**
  114885. * Does a raycast in the physics world
  114886. * @param from when should the ray start?
  114887. * @param to when should the ray end?
  114888. * @returns PhysicsRaycastResult
  114889. */
  114890. CannonJSPlugin.prototype.raycast = function (from, to) {
  114891. this._cannonRaycastResult.reset();
  114892. this.world.raycastClosest(from, to, {}, this._cannonRaycastResult);
  114893. this._raycastResult.reset(from, to);
  114894. if (this._cannonRaycastResult.hasHit) {
  114895. // TODO: do we also want to get the body it hit?
  114896. this._raycastResult.setHitData({
  114897. x: this._cannonRaycastResult.hitNormalWorld.x,
  114898. y: this._cannonRaycastResult.hitNormalWorld.y,
  114899. z: this._cannonRaycastResult.hitNormalWorld.z,
  114900. }, {
  114901. x: this._cannonRaycastResult.hitPointWorld.x,
  114902. y: this._cannonRaycastResult.hitPointWorld.y,
  114903. z: this._cannonRaycastResult.hitPointWorld.z,
  114904. });
  114905. this._raycastResult.setHitDistance(this._cannonRaycastResult.distance);
  114906. }
  114907. return this._raycastResult;
  114908. };
  114909. return CannonJSPlugin;
  114910. }());
  114911. _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].DefaultPluginFactory = function () { return new CannonJSPlugin(); };
  114912. /***/ }),
  114913. /***/ "./Physics/Plugins/index.ts":
  114914. /*!**********************************!*\
  114915. !*** ./Physics/Plugins/index.ts ***!
  114916. \**********************************/
  114917. /*! exports provided: CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  114918. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114919. "use strict";
  114920. __webpack_require__.r(__webpack_exports__);
  114921. /* harmony import */ var _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  114922. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  114923. /* harmony import */ var _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ammoJSPlugin */ "./Physics/Plugins/ammoJSPlugin.ts");
  114924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__["AmmoJSPlugin"]; });
  114925. /* harmony import */ var _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  114926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__["OimoJSPlugin"]; });
  114927. /***/ }),
  114928. /***/ "./Physics/Plugins/oimoJSPlugin.ts":
  114929. /*!*****************************************!*\
  114930. !*** ./Physics/Plugins/oimoJSPlugin.ts ***!
  114931. \*****************************************/
  114932. /*! exports provided: OimoJSPlugin */
  114933. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114934. "use strict";
  114935. __webpack_require__.r(__webpack_exports__);
  114936. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return OimoJSPlugin; });
  114937. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  114938. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  114939. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  114940. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  114941. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  114942. /* harmony import */ var _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../physicsRaycastResult */ "./Physics/physicsRaycastResult.ts");
  114943. /** @hidden */
  114944. var OimoJSPlugin = /** @class */ (function () {
  114945. function OimoJSPlugin(iterations, oimoInjection) {
  114946. if (oimoInjection === void 0) { oimoInjection = OIMO; }
  114947. this.name = "OimoJSPlugin";
  114948. this._tmpImpostorsArray = [];
  114949. this._tmpPositionVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  114950. this.BJSOIMO = oimoInjection;
  114951. this.world = new this.BJSOIMO.World({
  114952. iterations: iterations
  114953. });
  114954. this.world.clear();
  114955. this._raycastResult = new _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_5__["PhysicsRaycastResult"]();
  114956. }
  114957. OimoJSPlugin.prototype.setGravity = function (gravity) {
  114958. this.world.gravity.copy(gravity);
  114959. };
  114960. OimoJSPlugin.prototype.setTimeStep = function (timeStep) {
  114961. this.world.timeStep = timeStep;
  114962. };
  114963. OimoJSPlugin.prototype.getTimeStep = function () {
  114964. return this.world.timeStep;
  114965. };
  114966. OimoJSPlugin.prototype.executeStep = function (delta, impostors) {
  114967. var _this = this;
  114968. impostors.forEach(function (impostor) {
  114969. impostor.beforeStep();
  114970. });
  114971. this.world.step();
  114972. impostors.forEach(function (impostor) {
  114973. impostor.afterStep();
  114974. //update the ordered impostors array
  114975. _this._tmpImpostorsArray[impostor.uniqueId] = impostor;
  114976. });
  114977. //check for collisions
  114978. var contact = this.world.contacts;
  114979. while (contact !== null) {
  114980. if (contact.touching && !contact.body1.sleeping && !contact.body2.sleeping) {
  114981. contact = contact.next;
  114982. continue;
  114983. }
  114984. //is this body colliding with any other? get the impostor
  114985. var mainImpostor = this._tmpImpostorsArray[+contact.body1.name];
  114986. var collidingImpostor = this._tmpImpostorsArray[+contact.body2.name];
  114987. if (!mainImpostor || !collidingImpostor) {
  114988. contact = contact.next;
  114989. continue;
  114990. }
  114991. mainImpostor.onCollide({ body: collidingImpostor.physicsBody });
  114992. collidingImpostor.onCollide({ body: mainImpostor.physicsBody });
  114993. contact = contact.next;
  114994. }
  114995. };
  114996. OimoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  114997. var mass = impostor.physicsBody.mass;
  114998. impostor.physicsBody.applyImpulse(contactPoint.scale(this.world.invScale), force.scale(this.world.invScale * mass));
  114999. };
  115000. OimoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  115001. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("Oimo doesn't support applying force. Using impule instead.");
  115002. this.applyImpulse(impostor, force, contactPoint);
  115003. };
  115004. OimoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  115005. var _this = this;
  115006. //parent-child relationship. Does this impostor has a parent impostor?
  115007. if (impostor.parent) {
  115008. if (impostor.physicsBody) {
  115009. this.removePhysicsBody(impostor);
  115010. //TODO is that needed?
  115011. impostor.forceUpdate();
  115012. }
  115013. return;
  115014. }
  115015. if (impostor.isBodyInitRequired()) {
  115016. var bodyConfig = {
  115017. name: impostor.uniqueId,
  115018. //Oimo must have mass, also for static objects.
  115019. config: [impostor.getParam("mass") || 1, impostor.getParam("friction"), impostor.getParam("restitution")],
  115020. size: [],
  115021. type: [],
  115022. pos: [],
  115023. posShape: [],
  115024. rot: [],
  115025. rotShape: [],
  115026. move: impostor.getParam("mass") !== 0,
  115027. density: impostor.getParam("mass"),
  115028. friction: impostor.getParam("friction"),
  115029. restitution: impostor.getParam("restitution"),
  115030. //Supporting older versions of Oimo
  115031. world: this.world
  115032. };
  115033. var impostors = [impostor];
  115034. var addToArray = function (parent) {
  115035. if (!parent.getChildMeshes) {
  115036. return;
  115037. }
  115038. parent.getChildMeshes().forEach(function (m) {
  115039. if (m.physicsImpostor) {
  115040. impostors.push(m.physicsImpostor);
  115041. //m.physicsImpostor._init();
  115042. }
  115043. });
  115044. };
  115045. addToArray(impostor.object);
  115046. var checkWithEpsilon_1 = function (value) {
  115047. return Math.max(value, _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__["PhysicsEngine"].Epsilon);
  115048. };
  115049. var globalQuaternion_1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  115050. impostors.forEach(function (i) {
  115051. if (!i.object.rotationQuaternion) {
  115052. return;
  115053. }
  115054. //get the correct bounding box
  115055. var oldQuaternion = i.object.rotationQuaternion;
  115056. globalQuaternion_1 = oldQuaternion.clone();
  115057. var rot = oldQuaternion.toEulerAngles();
  115058. var extendSize = i.getObjectExtendSize();
  115059. var radToDeg = 57.295779513082320876;
  115060. if (i === impostor) {
  115061. var center = impostor.getObjectCenter();
  115062. impostor.object.getAbsolutePivotPoint().subtractToRef(center, _this._tmpPositionVector);
  115063. _this._tmpPositionVector.divideInPlace(impostor.object.scaling);
  115064. //Can also use Array.prototype.push.apply
  115065. bodyConfig.pos.push(center.x);
  115066. bodyConfig.pos.push(center.y);
  115067. bodyConfig.pos.push(center.z);
  115068. bodyConfig.posShape.push(0, 0, 0);
  115069. bodyConfig.rotShape.push(0, 0, 0);
  115070. }
  115071. else {
  115072. var localPosition = i.object.getAbsolutePosition().subtract(impostor.object.getAbsolutePosition());
  115073. bodyConfig.posShape.push(localPosition.x);
  115074. bodyConfig.posShape.push(localPosition.y);
  115075. bodyConfig.posShape.push(localPosition.z);
  115076. bodyConfig.pos.push(0, 0, 0);
  115077. bodyConfig.rotShape.push(rot.x * radToDeg);
  115078. bodyConfig.rotShape.push(rot.y * radToDeg);
  115079. bodyConfig.rotShape.push(rot.z * radToDeg);
  115080. }
  115081. // register mesh
  115082. switch (i.type) {
  115083. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].ParticleImpostor:
  115084. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("No Particle support in OIMO.js. using SphereImpostor instead");
  115085. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].SphereImpostor:
  115086. var radiusX = extendSize.x;
  115087. var radiusY = extendSize.y;
  115088. var radiusZ = extendSize.z;
  115089. var size = Math.max(checkWithEpsilon_1(radiusX), checkWithEpsilon_1(radiusY), checkWithEpsilon_1(radiusZ)) / 2;
  115090. bodyConfig.type.push('sphere');
  115091. //due to the way oimo works with compounds, add 3 times
  115092. bodyConfig.size.push(size);
  115093. bodyConfig.size.push(size);
  115094. bodyConfig.size.push(size);
  115095. break;
  115096. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].CylinderImpostor:
  115097. var sizeX = checkWithEpsilon_1(extendSize.x) / 2;
  115098. var sizeY = checkWithEpsilon_1(extendSize.y);
  115099. bodyConfig.type.push('cylinder');
  115100. bodyConfig.size.push(sizeX);
  115101. bodyConfig.size.push(sizeY);
  115102. //due to the way oimo works with compounds, add one more value.
  115103. bodyConfig.size.push(sizeY);
  115104. break;
  115105. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].PlaneImpostor:
  115106. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].BoxImpostor:
  115107. default:
  115108. var sizeX = checkWithEpsilon_1(extendSize.x);
  115109. var sizeY = checkWithEpsilon_1(extendSize.y);
  115110. var sizeZ = checkWithEpsilon_1(extendSize.z);
  115111. bodyConfig.type.push('box');
  115112. //if (i === impostor) {
  115113. bodyConfig.size.push(sizeX);
  115114. bodyConfig.size.push(sizeY);
  115115. bodyConfig.size.push(sizeZ);
  115116. //} else {
  115117. // bodyConfig.size.push(0,0,0);
  115118. //}
  115119. break;
  115120. }
  115121. //actually not needed, but hey...
  115122. i.object.rotationQuaternion = oldQuaternion;
  115123. });
  115124. impostor.physicsBody = this.world.add(bodyConfig);
  115125. // set the quaternion, ignoring the previously defined (euler) rotation
  115126. impostor.physicsBody.resetQuaternion(globalQuaternion_1);
  115127. // update with delta 0, so the body will reveive the new rotation.
  115128. impostor.physicsBody.updatePosition(0);
  115129. }
  115130. else {
  115131. this._tmpPositionVector.copyFromFloats(0, 0, 0);
  115132. }
  115133. impostor.setDeltaPosition(this._tmpPositionVector);
  115134. //this._tmpPositionVector.addInPlace(impostor.mesh.getBoundingInfo().boundingBox.center);
  115135. //this.setPhysicsBodyTransformation(impostor, this._tmpPositionVector, impostor.mesh.rotationQuaternion);
  115136. };
  115137. OimoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  115138. //impostor.physicsBody.dispose();
  115139. //Same as : (older oimo versions)
  115140. this.world.removeRigidBody(impostor.physicsBody);
  115141. };
  115142. OimoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  115143. var mainBody = impostorJoint.mainImpostor.physicsBody;
  115144. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  115145. if (!mainBody || !connectedBody) {
  115146. return;
  115147. }
  115148. var jointData = impostorJoint.joint.jointData;
  115149. var options = jointData.nativeParams || {};
  115150. var type;
  115151. var nativeJointData = {
  115152. body1: mainBody,
  115153. body2: connectedBody,
  115154. axe1: options.axe1 || (jointData.mainAxis ? jointData.mainAxis.asArray() : null),
  115155. axe2: options.axe2 || (jointData.connectedAxis ? jointData.connectedAxis.asArray() : null),
  115156. pos1: options.pos1 || (jointData.mainPivot ? jointData.mainPivot.asArray() : null),
  115157. pos2: options.pos2 || (jointData.connectedPivot ? jointData.connectedPivot.asArray() : null),
  115158. min: options.min,
  115159. max: options.max,
  115160. collision: options.collision || jointData.collision,
  115161. spring: options.spring,
  115162. //supporting older version of Oimo
  115163. world: this.world
  115164. };
  115165. switch (impostorJoint.joint.type) {
  115166. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].BallAndSocketJoint:
  115167. type = "jointBall";
  115168. break;
  115169. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SpringJoint:
  115170. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
  115171. var springData = jointData;
  115172. nativeJointData.min = springData.length || nativeJointData.min;
  115173. //Max should also be set, just make sure it is at least min
  115174. nativeJointData.max = Math.max(nativeJointData.min, nativeJointData.max);
  115175. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].DistanceJoint:
  115176. type = "jointDistance";
  115177. nativeJointData.max = jointData.maxDistance;
  115178. break;
  115179. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].PrismaticJoint:
  115180. type = "jointPrisme";
  115181. break;
  115182. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SliderJoint:
  115183. type = "jointSlide";
  115184. break;
  115185. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].WheelJoint:
  115186. type = "jointWheel";
  115187. break;
  115188. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].HingeJoint:
  115189. default:
  115190. type = "jointHinge";
  115191. break;
  115192. }
  115193. nativeJointData.type = type;
  115194. impostorJoint.joint.physicsJoint = this.world.add(nativeJointData);
  115195. };
  115196. OimoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  115197. //Bug in Oimo prevents us from disposing a joint in the playground
  115198. //joint.joint.physicsJoint.dispose();
  115199. //So we will bruteforce it!
  115200. try {
  115201. this.world.removeJoint(impostorJoint.joint.physicsJoint);
  115202. }
  115203. catch (e) {
  115204. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn(e);
  115205. }
  115206. };
  115207. OimoJSPlugin.prototype.isSupported = function () {
  115208. return this.BJSOIMO !== undefined;
  115209. };
  115210. OimoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  115211. if (!impostor.physicsBody.sleeping) {
  115212. //TODO check that
  115213. /*if (impostor.physicsBody.shapes.next) {
  115214. var parentShape = this._getLastShape(impostor.physicsBody);
  115215. impostor.object.position.copyFrom(parentShape.position);
  115216. console.log(parentShape.position);
  115217. } else {*/
  115218. impostor.object.position.copyFrom(impostor.physicsBody.getPosition());
  115219. //}
  115220. if (impostor.object.rotationQuaternion) {
  115221. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.getQuaternion());
  115222. }
  115223. }
  115224. };
  115225. OimoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  115226. var body = impostor.physicsBody;
  115227. body.position.copy(newPosition);
  115228. body.orientation.copy(newRotation);
  115229. body.syncShapes();
  115230. body.awake();
  115231. };
  115232. /*private _getLastShape(body: any): any {
  115233. var lastShape = body.shapes;
  115234. while (lastShape.next) {
  115235. lastShape = lastShape.next;
  115236. }
  115237. return lastShape;
  115238. }*/
  115239. OimoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  115240. impostor.physicsBody.linearVelocity.copy(velocity);
  115241. };
  115242. OimoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  115243. impostor.physicsBody.angularVelocity.copy(velocity);
  115244. };
  115245. OimoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  115246. var v = impostor.physicsBody.linearVelocity;
  115247. if (!v) {
  115248. return null;
  115249. }
  115250. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  115251. };
  115252. OimoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  115253. var v = impostor.physicsBody.angularVelocity;
  115254. if (!v) {
  115255. return null;
  115256. }
  115257. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  115258. };
  115259. OimoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  115260. var staticBody = mass === 0;
  115261. //this will actually set the body's density and not its mass.
  115262. //But this is how oimo treats the mass variable.
  115263. impostor.physicsBody.shapes.density = staticBody ? 1 : mass;
  115264. impostor.physicsBody.setupMass(staticBody ? 0x2 : 0x1);
  115265. };
  115266. OimoJSPlugin.prototype.getBodyMass = function (impostor) {
  115267. return impostor.physicsBody.shapes.density;
  115268. };
  115269. OimoJSPlugin.prototype.getBodyFriction = function (impostor) {
  115270. return impostor.physicsBody.shapes.friction;
  115271. };
  115272. OimoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  115273. impostor.physicsBody.shapes.friction = friction;
  115274. };
  115275. OimoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  115276. return impostor.physicsBody.shapes.restitution;
  115277. };
  115278. OimoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  115279. impostor.physicsBody.shapes.restitution = restitution;
  115280. };
  115281. OimoJSPlugin.prototype.sleepBody = function (impostor) {
  115282. impostor.physicsBody.sleep();
  115283. };
  115284. OimoJSPlugin.prototype.wakeUpBody = function (impostor) {
  115285. impostor.physicsBody.awake();
  115286. };
  115287. OimoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  115288. joint.physicsJoint.limitMotor.upperLimit = maxDistance;
  115289. if (minDistance !== void 0) {
  115290. joint.physicsJoint.limitMotor.lowerLimit = minDistance;
  115291. }
  115292. };
  115293. OimoJSPlugin.prototype.setMotor = function (joint, speed, force, motorIndex) {
  115294. if (force !== undefined) {
  115295. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OimoJS plugin currently has unexpected behavior when using setMotor with force parameter");
  115296. }
  115297. else {
  115298. force = 1e6;
  115299. }
  115300. speed *= -1;
  115301. //TODO separate rotational and transational motors.
  115302. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  115303. if (motor) {
  115304. motor.setMotor(speed, force);
  115305. }
  115306. };
  115307. OimoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit, motorIndex) {
  115308. //TODO separate rotational and transational motors.
  115309. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  115310. if (motor) {
  115311. motor.setLimit(upperLimit, lowerLimit === void 0 ? -upperLimit : lowerLimit);
  115312. }
  115313. };
  115314. OimoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  115315. var body = impostor.physicsBody;
  115316. mesh.position.x = body.position.x;
  115317. mesh.position.y = body.position.y;
  115318. mesh.position.z = body.position.z;
  115319. if (mesh.rotationQuaternion) {
  115320. mesh.rotationQuaternion.x = body.orientation.x;
  115321. mesh.rotationQuaternion.y = body.orientation.y;
  115322. mesh.rotationQuaternion.z = body.orientation.z;
  115323. mesh.rotationQuaternion.w = body.orientation.s;
  115324. }
  115325. };
  115326. OimoJSPlugin.prototype.getRadius = function (impostor) {
  115327. return impostor.physicsBody.shapes.radius;
  115328. };
  115329. OimoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  115330. var shape = impostor.physicsBody.shapes;
  115331. result.x = shape.halfWidth * 2;
  115332. result.y = shape.halfHeight * 2;
  115333. result.z = shape.halfDepth * 2;
  115334. };
  115335. OimoJSPlugin.prototype.dispose = function () {
  115336. this.world.clear();
  115337. };
  115338. /**
  115339. * Does a raycast in the physics world
  115340. * @param from when should the ray start?
  115341. * @param to when should the ray end?
  115342. * @returns PhysicsRaycastResult
  115343. */
  115344. OimoJSPlugin.prototype.raycast = function (from, to) {
  115345. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("raycast is not currently supported by the Oimo physics plugin");
  115346. this._raycastResult.reset(from, to);
  115347. return this._raycastResult;
  115348. };
  115349. return OimoJSPlugin;
  115350. }());
  115351. /***/ }),
  115352. /***/ "./Physics/index.ts":
  115353. /*!**************************!*\
  115354. !*** ./Physics/index.ts ***!
  115355. \**************************/
  115356. /*! exports provided: PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEventOptions, PhysicsUpdraftEventOptions, PhysicsVortexEventOptions, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  115357. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115358. "use strict";
  115359. __webpack_require__.r(__webpack_exports__);
  115360. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  115361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _physicsEngine__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  115362. /* harmony import */ var _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./physicsEngineComponent */ "./Physics/physicsEngineComponent.ts");
  115363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__["PhysicsEngineSceneComponent"]; });
  115364. /* harmony import */ var _physicsHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./physicsHelper */ "./Physics/physicsHelper.ts");
  115365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsHelper"]; });
  115366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialExplosionEventOptions"]; });
  115367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftEventOptions"]; });
  115368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsVortexEventOptions"]; });
  115369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialImpulseFalloff"]; });
  115370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftMode"]; });
  115371. /* harmony import */ var _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsImpostor */ "./Physics/physicsImpostor.ts");
  115372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"]; });
  115373. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  115374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"]; });
  115375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["DistanceJoint"]; });
  115376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["MotorEnabledJoint"]; });
  115377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["HingeJoint"]; });
  115378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["Hinge2Joint"]; });
  115379. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Plugins/index */ "./Physics/Plugins/index.ts");
  115380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["CannonJSPlugin"]; });
  115381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["AmmoJSPlugin"]; });
  115382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["OimoJSPlugin"]; });
  115383. /***/ }),
  115384. /***/ "./Physics/physicsEngine.ts":
  115385. /*!**********************************!*\
  115386. !*** ./Physics/physicsEngine.ts ***!
  115387. \**********************************/
  115388. /*! exports provided: PhysicsEngine */
  115389. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115390. "use strict";
  115391. __webpack_require__.r(__webpack_exports__);
  115392. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return PhysicsEngine; });
  115393. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  115394. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  115395. /**
  115396. * Class used to control physics engine
  115397. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  115398. */
  115399. var PhysicsEngine = /** @class */ (function () {
  115400. /**
  115401. * Creates a new Physics Engine
  115402. * @param gravity defines the gravity vector used by the simulation
  115403. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  115404. */
  115405. function PhysicsEngine(gravity, _physicsPlugin) {
  115406. if (_physicsPlugin === void 0) { _physicsPlugin = PhysicsEngine.DefaultPluginFactory(); }
  115407. this._physicsPlugin = _physicsPlugin;
  115408. this._impostors = [];
  115409. this._joints = [];
  115410. if (!this._physicsPlugin.isSupported()) {
  115411. throw new Error("Physics Engine " + this._physicsPlugin.name + " cannot be found. "
  115412. + "Please make sure it is included.");
  115413. }
  115414. gravity = gravity || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -9.807, 0);
  115415. this.setGravity(gravity);
  115416. this.setTimeStep();
  115417. }
  115418. /**
  115419. * Factory used to create the default physics plugin.
  115420. * @returns The default physics plugin
  115421. */
  115422. PhysicsEngine.DefaultPluginFactory = function () {
  115423. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__["_DevTools"].WarnImport("CannonJSPlugin");
  115424. };
  115425. /**
  115426. * Sets the gravity vector used by the simulation
  115427. * @param gravity defines the gravity vector to use
  115428. */
  115429. PhysicsEngine.prototype.setGravity = function (gravity) {
  115430. this.gravity = gravity;
  115431. this._physicsPlugin.setGravity(this.gravity);
  115432. };
  115433. /**
  115434. * Set the time step of the physics engine.
  115435. * Default is 1/60.
  115436. * To slow it down, enter 1/600 for example.
  115437. * To speed it up, 1/30
  115438. * @param newTimeStep defines the new timestep to apply to this world.
  115439. */
  115440. PhysicsEngine.prototype.setTimeStep = function (newTimeStep) {
  115441. if (newTimeStep === void 0) { newTimeStep = 1 / 60; }
  115442. this._physicsPlugin.setTimeStep(newTimeStep);
  115443. };
  115444. /**
  115445. * Get the time step of the physics engine.
  115446. * @returns the current time step
  115447. */
  115448. PhysicsEngine.prototype.getTimeStep = function () {
  115449. return this._physicsPlugin.getTimeStep();
  115450. };
  115451. /**
  115452. * Release all resources
  115453. */
  115454. PhysicsEngine.prototype.dispose = function () {
  115455. this._impostors.forEach(function (impostor) {
  115456. impostor.dispose();
  115457. });
  115458. this._physicsPlugin.dispose();
  115459. };
  115460. /**
  115461. * Gets the name of the current physics plugin
  115462. * @returns the name of the plugin
  115463. */
  115464. PhysicsEngine.prototype.getPhysicsPluginName = function () {
  115465. return this._physicsPlugin.name;
  115466. };
  115467. /**
  115468. * Adding a new impostor for the impostor tracking.
  115469. * This will be done by the impostor itself.
  115470. * @param impostor the impostor to add
  115471. */
  115472. PhysicsEngine.prototype.addImpostor = function (impostor) {
  115473. impostor.uniqueId = this._impostors.push(impostor);
  115474. //if no parent, generate the body
  115475. if (!impostor.parent) {
  115476. this._physicsPlugin.generatePhysicsBody(impostor);
  115477. }
  115478. };
  115479. /**
  115480. * Remove an impostor from the engine.
  115481. * This impostor and its mesh will not longer be updated by the physics engine.
  115482. * @param impostor the impostor to remove
  115483. */
  115484. PhysicsEngine.prototype.removeImpostor = function (impostor) {
  115485. var index = this._impostors.indexOf(impostor);
  115486. if (index > -1) {
  115487. var removed = this._impostors.splice(index, 1);
  115488. //Is it needed?
  115489. if (removed.length) {
  115490. this.getPhysicsPlugin().removePhysicsBody(impostor);
  115491. }
  115492. }
  115493. };
  115494. /**
  115495. * Add a joint to the physics engine
  115496. * @param mainImpostor defines the main impostor to which the joint is added.
  115497. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  115498. * @param joint defines the joint that will connect both impostors.
  115499. */
  115500. PhysicsEngine.prototype.addJoint = function (mainImpostor, connectedImpostor, joint) {
  115501. var impostorJoint = {
  115502. mainImpostor: mainImpostor,
  115503. connectedImpostor: connectedImpostor,
  115504. joint: joint
  115505. };
  115506. joint.physicsPlugin = this._physicsPlugin;
  115507. this._joints.push(impostorJoint);
  115508. this._physicsPlugin.generateJoint(impostorJoint);
  115509. };
  115510. /**
  115511. * Removes a joint from the simulation
  115512. * @param mainImpostor defines the impostor used with the joint
  115513. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  115514. * @param joint defines the joint to remove
  115515. */
  115516. PhysicsEngine.prototype.removeJoint = function (mainImpostor, connectedImpostor, joint) {
  115517. var matchingJoints = this._joints.filter(function (impostorJoint) {
  115518. return (impostorJoint.connectedImpostor === connectedImpostor
  115519. && impostorJoint.joint === joint
  115520. && impostorJoint.mainImpostor === mainImpostor);
  115521. });
  115522. if (matchingJoints.length) {
  115523. this._physicsPlugin.removeJoint(matchingJoints[0]);
  115524. //TODO remove it from the list as well
  115525. }
  115526. };
  115527. /**
  115528. * Called by the scene. No need to call it.
  115529. * @param delta defines the timespam between frames
  115530. */
  115531. PhysicsEngine.prototype._step = function (delta) {
  115532. var _this = this;
  115533. //check if any mesh has no body / requires an update
  115534. this._impostors.forEach(function (impostor) {
  115535. if (impostor.isBodyInitRequired()) {
  115536. _this._physicsPlugin.generatePhysicsBody(impostor);
  115537. }
  115538. });
  115539. if (delta > 0.1) {
  115540. delta = 0.1;
  115541. }
  115542. else if (delta <= 0) {
  115543. delta = 1.0 / 60.0;
  115544. }
  115545. this._physicsPlugin.executeStep(delta, this._impostors);
  115546. };
  115547. /**
  115548. * Gets the current plugin used to run the simulation
  115549. * @returns current plugin
  115550. */
  115551. PhysicsEngine.prototype.getPhysicsPlugin = function () {
  115552. return this._physicsPlugin;
  115553. };
  115554. /**
  115555. * Gets the list of physic impostors
  115556. * @returns an array of PhysicsImpostor
  115557. */
  115558. PhysicsEngine.prototype.getImpostors = function () {
  115559. return this._impostors;
  115560. };
  115561. /**
  115562. * Gets the impostor for a physics enabled object
  115563. * @param object defines the object impersonated by the impostor
  115564. * @returns the PhysicsImpostor or null if not found
  115565. */
  115566. PhysicsEngine.prototype.getImpostorForPhysicsObject = function (object) {
  115567. for (var i = 0; i < this._impostors.length; ++i) {
  115568. if (this._impostors[i].object === object) {
  115569. return this._impostors[i];
  115570. }
  115571. }
  115572. return null;
  115573. };
  115574. /**
  115575. * Gets the impostor for a physics body object
  115576. * @param body defines physics body used by the impostor
  115577. * @returns the PhysicsImpostor or null if not found
  115578. */
  115579. PhysicsEngine.prototype.getImpostorWithPhysicsBody = function (body) {
  115580. for (var i = 0; i < this._impostors.length; ++i) {
  115581. if (this._impostors[i].physicsBody === body) {
  115582. return this._impostors[i];
  115583. }
  115584. }
  115585. return null;
  115586. };
  115587. /**
  115588. * Does a raycast in the physics world
  115589. * @param from when should the ray start?
  115590. * @param to when should the ray end?
  115591. * @returns PhysicsRaycastResult
  115592. */
  115593. PhysicsEngine.prototype.raycast = function (from, to) {
  115594. return this._physicsPlugin.raycast(from, to);
  115595. };
  115596. /**
  115597. * Global value used to control the smallest number supported by the simulation
  115598. */
  115599. PhysicsEngine.Epsilon = 0.001;
  115600. return PhysicsEngine;
  115601. }());
  115602. /***/ }),
  115603. /***/ "./Physics/physicsEngineComponent.ts":
  115604. /*!*******************************************!*\
  115605. !*** ./Physics/physicsEngineComponent.ts ***!
  115606. \*******************************************/
  115607. /*! exports provided: PhysicsEngineSceneComponent */
  115608. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115609. "use strict";
  115610. __webpack_require__.r(__webpack_exports__);
  115611. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return PhysicsEngineSceneComponent; });
  115612. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  115613. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  115614. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  115615. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  115616. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  115617. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  115618. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  115619. /**
  115620. * Gets the current physics engine
  115621. * @returns a IPhysicsEngine or null if none attached
  115622. */
  115623. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.getPhysicsEngine = function () {
  115624. return this._physicsEngine;
  115625. };
  115626. /**
  115627. * Enables physics to the current scene
  115628. * @param gravity defines the scene's gravity for the physics engine
  115629. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  115630. * @return a boolean indicating if the physics engine was initialized
  115631. */
  115632. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.enablePhysics = function (gravity, plugin) {
  115633. if (gravity === void 0) { gravity = null; }
  115634. if (this._physicsEngine) {
  115635. return true;
  115636. }
  115637. // Register the component to the scene
  115638. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE);
  115639. if (!component) {
  115640. component = new PhysicsEngineSceneComponent(this);
  115641. this._addComponent(component);
  115642. }
  115643. try {
  115644. this._physicsEngine = new _physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"](gravity, plugin);
  115645. return true;
  115646. }
  115647. catch (e) {
  115648. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error(e.message);
  115649. return false;
  115650. }
  115651. };
  115652. /**
  115653. * Disables and disposes the physics engine associated with the scene
  115654. */
  115655. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.disablePhysicsEngine = function () {
  115656. if (!this._physicsEngine) {
  115657. return;
  115658. }
  115659. this._physicsEngine.dispose();
  115660. this._physicsEngine = null;
  115661. };
  115662. /**
  115663. * Gets a boolean indicating if there is an active physics engine
  115664. * @returns a boolean indicating if there is an active physics engine
  115665. */
  115666. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.isPhysicsEnabled = function () {
  115667. return this._physicsEngine !== undefined;
  115668. };
  115669. /**
  115670. * Deletes a physics compound impostor
  115671. * @param compound defines the compound to delete
  115672. */
  115673. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.deleteCompoundImpostor = function (compound) {
  115674. var mesh = compound.parts[0].mesh;
  115675. if (mesh.physicsImpostor) {
  115676. mesh.physicsImpostor.dispose( /*true*/);
  115677. mesh.physicsImpostor = null;
  115678. }
  115679. };
  115680. /** @hidden */
  115681. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._advancePhysicsEngineStep = function (step) {
  115682. if (this._physicsEngine) {
  115683. this.onBeforePhysicsObservable.notifyObservers(this);
  115684. this._physicsEngine._step(step / 1000);
  115685. this.onAfterPhysicsObservable.notifyObservers(this);
  115686. }
  115687. };
  115688. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "physicsImpostor", {
  115689. get: function () {
  115690. return this._physicsImpostor;
  115691. },
  115692. set: function (value) {
  115693. var _this = this;
  115694. if (this._physicsImpostor === value) {
  115695. return;
  115696. }
  115697. if (this._disposePhysicsObserver) {
  115698. this.onDisposeObservable.remove(this._disposePhysicsObserver);
  115699. }
  115700. this._physicsImpostor = value;
  115701. if (value) {
  115702. this._disposePhysicsObserver = this.onDisposeObservable.add(function () {
  115703. // Physics
  115704. if (_this.physicsImpostor) {
  115705. _this.physicsImpostor.dispose( /*!doNotRecurse*/);
  115706. _this.physicsImpostor = null;
  115707. }
  115708. });
  115709. }
  115710. },
  115711. enumerable: true,
  115712. configurable: true
  115713. });
  115714. /**
  115715. * Gets the current physics impostor
  115716. * @see http://doc.babylonjs.com/features/physics_engine
  115717. * @returns a physics impostor or null
  115718. */
  115719. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.getPhysicsImpostor = function () {
  115720. return this.physicsImpostor;
  115721. };
  115722. /**
  115723. * Apply a physic impulse to the mesh
  115724. * @param force defines the force to apply
  115725. * @param contactPoint defines where to apply the force
  115726. * @returns the current mesh
  115727. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  115728. */
  115729. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.applyImpulse = function (force, contactPoint) {
  115730. if (!this.physicsImpostor) {
  115731. return this;
  115732. }
  115733. this.physicsImpostor.applyImpulse(force, contactPoint);
  115734. return this;
  115735. };
  115736. /**
  115737. * Creates a physic joint between two meshes
  115738. * @param otherMesh defines the other mesh to use
  115739. * @param pivot1 defines the pivot to use on this mesh
  115740. * @param pivot2 defines the pivot to use on the other mesh
  115741. * @param options defines additional options (can be plugin dependent)
  115742. * @returns the current mesh
  115743. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  115744. */
  115745. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.setPhysicsLinkWith = function (otherMesh, pivot1, pivot2, options) {
  115746. if (!this.physicsImpostor || !otherMesh.physicsImpostor) {
  115747. return this;
  115748. }
  115749. this.physicsImpostor.createJoint(otherMesh.physicsImpostor, _physicsJoint__WEBPACK_IMPORTED_MODULE_6__["PhysicsJoint"].HingeJoint, {
  115750. mainPivot: pivot1,
  115751. connectedPivot: pivot2,
  115752. nativeParams: options
  115753. });
  115754. return this;
  115755. };
  115756. /**
  115757. * Defines the physics engine scene component responsible to manage a physics engine
  115758. */
  115759. var PhysicsEngineSceneComponent = /** @class */ (function () {
  115760. /**
  115761. * Creates a new instance of the component for the given scene
  115762. * @param scene Defines the scene to register the component in
  115763. */
  115764. function PhysicsEngineSceneComponent(scene) {
  115765. var _this = this;
  115766. /**
  115767. * The component name helpful to identify the component in the list of scene components.
  115768. */
  115769. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE;
  115770. this.scene = scene;
  115771. this.scene.onBeforePhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  115772. this.scene.onAfterPhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  115773. // Replace the function used to get the deterministic frame time
  115774. this.scene.getDeterministicFrameTime = function () {
  115775. if (_this.scene._physicsEngine) {
  115776. return _this.scene._physicsEngine.getTimeStep() * 1000;
  115777. }
  115778. return 1000.0 / 60.0;
  115779. };
  115780. }
  115781. /**
  115782. * Registers the component in a given scene
  115783. */
  115784. PhysicsEngineSceneComponent.prototype.register = function () {
  115785. };
  115786. /**
  115787. * Rebuilds the elements related to this component in case of
  115788. * context lost for instance.
  115789. */
  115790. PhysicsEngineSceneComponent.prototype.rebuild = function () {
  115791. // Nothing to do for this component
  115792. };
  115793. /**
  115794. * Disposes the component and the associated ressources
  115795. */
  115796. PhysicsEngineSceneComponent.prototype.dispose = function () {
  115797. this.scene.onBeforePhysicsObservable.clear();
  115798. this.scene.onAfterPhysicsObservable.clear();
  115799. if (this.scene._physicsEngine) {
  115800. this.scene.disablePhysicsEngine();
  115801. }
  115802. };
  115803. return PhysicsEngineSceneComponent;
  115804. }());
  115805. /***/ }),
  115806. /***/ "./Physics/physicsHelper.ts":
  115807. /*!**********************************!*\
  115808. !*** ./Physics/physicsHelper.ts ***!
  115809. \**********************************/
  115810. /*! exports provided: PhysicsHelper, PhysicsRadialExplosionEventOptions, PhysicsUpdraftEventOptions, PhysicsVortexEventOptions, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode */
  115811. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115812. "use strict";
  115813. __webpack_require__.r(__webpack_exports__);
  115814. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return PhysicsHelper; });
  115815. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return PhysicsRadialExplosionEventOptions; });
  115816. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return PhysicsUpdraftEventOptions; });
  115817. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return PhysicsVortexEventOptions; });
  115818. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return PhysicsRadialImpulseFalloff; });
  115819. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return PhysicsUpdraftMode; });
  115820. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115821. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  115822. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  115823. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  115824. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  115825. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  115826. /**
  115827. * A helper for physics simulations
  115828. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  115829. */
  115830. var PhysicsHelper = /** @class */ (function () {
  115831. /**
  115832. * Initializes the Physics helper
  115833. * @param scene Babylon.js scene
  115834. */
  115835. function PhysicsHelper(scene) {
  115836. this._scene = scene;
  115837. this._physicsEngine = this._scene.getPhysicsEngine();
  115838. if (!this._physicsEngine) {
  115839. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you can use the methods.');
  115840. return;
  115841. }
  115842. }
  115843. /**
  115844. * Applies a radial explosion impulse
  115845. * @param origin the origin of the explosion
  115846. * @param radiusOrEventOptions the radius or the options of radial explosion
  115847. * @param strength the explosion strength
  115848. * @param falloff possible options: Constant & Linear. Defaults to Constant
  115849. * @returns A physics radial explosion event, or null
  115850. */
  115851. PhysicsHelper.prototype.applyRadialExplosionImpulse = function (origin, radiusOrEventOptions, strength, falloff) {
  115852. if (!this._physicsEngine) {
  115853. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call this method.');
  115854. return null;
  115855. }
  115856. var impostors = this._physicsEngine.getImpostors();
  115857. if (impostors.length === 0) {
  115858. return null;
  115859. }
  115860. if (typeof radiusOrEventOptions === 'number') {
  115861. radiusOrEventOptions = new PhysicsRadialExplosionEventOptions();
  115862. radiusOrEventOptions.radius = radiusOrEventOptions;
  115863. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  115864. radiusOrEventOptions.falloff = falloff || radiusOrEventOptions.falloff;
  115865. }
  115866. var event = new PhysicsRadialExplosionEvent(this._scene, radiusOrEventOptions);
  115867. var affectedImpostorsWithData = Array();
  115868. impostors.forEach(function (impostor) {
  115869. var impostorHitData = event.getImpostorHitData(impostor, origin);
  115870. if (!impostorHitData) {
  115871. return;
  115872. }
  115873. impostor.applyImpulse(impostorHitData.force, impostorHitData.contactPoint);
  115874. affectedImpostorsWithData.push({
  115875. impostor: impostor,
  115876. hitData: impostorHitData,
  115877. });
  115878. });
  115879. event.triggerAffectedImpostorsCallback(affectedImpostorsWithData);
  115880. event.dispose(false);
  115881. return event;
  115882. };
  115883. /**
  115884. * Applies a radial explosion force
  115885. * @param origin the origin of the explosion
  115886. * @param radiusOrEventOptions the radius or the options of radial explosion
  115887. * @param strength the explosion strength
  115888. * @param falloff possible options: Constant & Linear. Defaults to Constant
  115889. * @returns A physics radial explosion event, or null
  115890. */
  115891. PhysicsHelper.prototype.applyRadialExplosionForce = function (origin, radiusOrEventOptions, strength, falloff) {
  115892. if (!this._physicsEngine) {
  115893. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  115894. return null;
  115895. }
  115896. var impostors = this._physicsEngine.getImpostors();
  115897. if (impostors.length === 0) {
  115898. return null;
  115899. }
  115900. if (typeof radiusOrEventOptions === 'number') {
  115901. radiusOrEventOptions = new PhysicsRadialExplosionEventOptions();
  115902. radiusOrEventOptions.radius = radiusOrEventOptions;
  115903. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  115904. radiusOrEventOptions.falloff = falloff || radiusOrEventOptions.falloff;
  115905. }
  115906. var event = new PhysicsRadialExplosionEvent(this._scene, radiusOrEventOptions);
  115907. var affectedImpostorsWithData = Array();
  115908. impostors.forEach(function (impostor) {
  115909. var impostorHitData = event.getImpostorHitData(impostor, origin);
  115910. if (!impostorHitData) {
  115911. return;
  115912. }
  115913. impostor.applyForce(impostorHitData.force, impostorHitData.contactPoint);
  115914. affectedImpostorsWithData.push({
  115915. impostor: impostor,
  115916. hitData: impostorHitData,
  115917. });
  115918. });
  115919. event.triggerAffectedImpostorsCallback(affectedImpostorsWithData);
  115920. event.dispose(false);
  115921. return event;
  115922. };
  115923. /**
  115924. * Creates a gravitational field
  115925. * @param origin the origin of the explosion
  115926. * @param radiusOrEventOptions the radius or the options of radial explosion
  115927. * @param strength the explosion strength
  115928. * @param falloff possible options: Constant & Linear. Defaults to Constant
  115929. * @returns A physics gravitational field event, or null
  115930. */
  115931. PhysicsHelper.prototype.gravitationalField = function (origin, radiusOrEventOptions, strength, falloff) {
  115932. if (!this._physicsEngine) {
  115933. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  115934. return null;
  115935. }
  115936. var impostors = this._physicsEngine.getImpostors();
  115937. if (impostors.length === 0) {
  115938. return null;
  115939. }
  115940. if (typeof radiusOrEventOptions === 'number') {
  115941. radiusOrEventOptions = new PhysicsRadialExplosionEventOptions();
  115942. radiusOrEventOptions.radius = radiusOrEventOptions;
  115943. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  115944. radiusOrEventOptions.falloff = falloff || radiusOrEventOptions.falloff;
  115945. }
  115946. var event = new PhysicsGravitationalFieldEvent(this, this._scene, origin, radiusOrEventOptions);
  115947. event.dispose(false);
  115948. return event;
  115949. };
  115950. /**
  115951. * Creates a physics updraft event
  115952. * @param origin the origin of the updraft
  115953. * @param radiusOrEventOptions the radius or the options of the updraft
  115954. * @param strength the strength of the updraft
  115955. * @param height the height of the updraft
  115956. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  115957. * @returns A physics updraft event, or null
  115958. */
  115959. PhysicsHelper.prototype.updraft = function (origin, radiusOrEventOptions, strength, height, updraftMode) {
  115960. if (!this._physicsEngine) {
  115961. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  115962. return null;
  115963. }
  115964. if (this._physicsEngine.getImpostors().length === 0) {
  115965. return null;
  115966. }
  115967. if (typeof radiusOrEventOptions === 'number') {
  115968. radiusOrEventOptions = new PhysicsUpdraftEventOptions();
  115969. radiusOrEventOptions.radius = radiusOrEventOptions;
  115970. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  115971. radiusOrEventOptions.height = height || radiusOrEventOptions.height;
  115972. radiusOrEventOptions.updraftMode = updraftMode || radiusOrEventOptions.updraftMode;
  115973. }
  115974. var event = new PhysicsUpdraftEvent(this._scene, origin, radiusOrEventOptions);
  115975. event.dispose(false);
  115976. return event;
  115977. };
  115978. /**
  115979. * Creates a physics vortex event
  115980. * @param origin the of the vortex
  115981. * @param radiusOrEventOptions the radius or the options of the vortex
  115982. * @param strength the strength of the vortex
  115983. * @param height the height of the vortex
  115984. * @returns a Physics vortex event, or null
  115985. * A physics vortex event or null
  115986. */
  115987. PhysicsHelper.prototype.vortex = function (origin, radiusOrEventOptions, strength, height) {
  115988. if (!this._physicsEngine) {
  115989. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  115990. return null;
  115991. }
  115992. if (this._physicsEngine.getImpostors().length === 0) {
  115993. return null;
  115994. }
  115995. if (typeof radiusOrEventOptions === 'number') {
  115996. radiusOrEventOptions = new PhysicsVortexEventOptions();
  115997. radiusOrEventOptions.radius = radiusOrEventOptions;
  115998. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  115999. radiusOrEventOptions.height = height || radiusOrEventOptions.height;
  116000. }
  116001. var event = new PhysicsVortexEvent(this._scene, origin, radiusOrEventOptions);
  116002. event.dispose(false);
  116003. return event;
  116004. };
  116005. return PhysicsHelper;
  116006. }());
  116007. /**
  116008. * Represents a physics radial explosion event
  116009. */
  116010. var PhysicsRadialExplosionEvent = /** @class */ (function () {
  116011. /**
  116012. * Initializes a radial explosioin event
  116013. * @param _scene BabylonJS scene
  116014. * @param _options The options for the vortex event
  116015. */
  116016. function PhysicsRadialExplosionEvent(_scene, _options) {
  116017. this._scene = _scene;
  116018. this._options = _options;
  116019. this._dataFetched = false; // check if the data has been fetched. If not, do cleanup
  116020. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsRadialExplosionEventOptions()), this._options);
  116021. }
  116022. /**
  116023. * Returns the data related to the radial explosion event (sphere).
  116024. * @returns The radial explosion event data
  116025. */
  116026. PhysicsRadialExplosionEvent.prototype.getData = function () {
  116027. this._dataFetched = true;
  116028. return {
  116029. sphere: this._sphere,
  116030. };
  116031. };
  116032. /**
  116033. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  116034. * @param impostor A physics imposter
  116035. * @param origin the origin of the explosion
  116036. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  116037. */
  116038. PhysicsRadialExplosionEvent.prototype.getImpostorHitData = function (impostor, origin) {
  116039. if (impostor.mass === 0) {
  116040. return null;
  116041. }
  116042. if (!this._intersectsWithSphere(impostor, origin, this._options.radius)) {
  116043. return null;
  116044. }
  116045. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  116046. return null;
  116047. }
  116048. var impostorObjectCenter = impostor.getObjectCenter();
  116049. var direction = impostorObjectCenter.subtract(origin);
  116050. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](origin, direction, this._options.radius);
  116051. var hit = ray.intersectsMesh(impostor.object);
  116052. var contactPoint = hit.pickedPoint;
  116053. if (!contactPoint) {
  116054. return null;
  116055. }
  116056. var distanceFromOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Distance(origin, contactPoint);
  116057. if (distanceFromOrigin > this._options.radius) {
  116058. return null;
  116059. }
  116060. var multiplier = this._options.falloff === PhysicsRadialImpulseFalloff.Constant
  116061. ? this._options.strength
  116062. : this._options.strength * (1 - (distanceFromOrigin / this._options.radius));
  116063. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  116064. return { force: force, contactPoint: contactPoint, distanceFromOrigin: distanceFromOrigin };
  116065. };
  116066. /**
  116067. * Triggers affecterd impostors callbacks
  116068. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  116069. */
  116070. PhysicsRadialExplosionEvent.prototype.triggerAffectedImpostorsCallback = function (affectedImpostorsWithData) {
  116071. if (this._options.affectedImpostorsCallback) {
  116072. this._options.affectedImpostorsCallback(affectedImpostorsWithData);
  116073. }
  116074. };
  116075. /**
  116076. * Disposes the sphere.
  116077. * @param force Specifies if the sphere should be disposed by force
  116078. */
  116079. PhysicsRadialExplosionEvent.prototype.dispose = function (force) {
  116080. var _this = this;
  116081. if (force === void 0) { force = true; }
  116082. if (force) {
  116083. this._sphere.dispose();
  116084. }
  116085. else {
  116086. setTimeout(function () {
  116087. if (!_this._dataFetched) {
  116088. _this._sphere.dispose();
  116089. }
  116090. }, 0);
  116091. }
  116092. };
  116093. /*** Helpers ***/
  116094. PhysicsRadialExplosionEvent.prototype._prepareSphere = function () {
  116095. if (!this._sphere) {
  116096. this._sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"].CreateSphere("radialExplosionEventSphere", this._options.sphere, this._scene);
  116097. this._sphere.isVisible = false;
  116098. }
  116099. };
  116100. PhysicsRadialExplosionEvent.prototype._intersectsWithSphere = function (impostor, origin, radius) {
  116101. var impostorObject = impostor.object;
  116102. this._prepareSphere();
  116103. this._sphere.position = origin;
  116104. this._sphere.scaling = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](radius * 2, radius * 2, radius * 2);
  116105. this._sphere._updateBoundingInfo();
  116106. this._sphere.computeWorldMatrix(true);
  116107. return this._sphere.intersectsMesh(impostorObject, true);
  116108. };
  116109. return PhysicsRadialExplosionEvent;
  116110. }());
  116111. /**
  116112. * Represents a gravitational field event
  116113. */
  116114. var PhysicsGravitationalFieldEvent = /** @class */ (function () {
  116115. /**
  116116. * Initializes the physics gravitational field event
  116117. * @param _physicsHelper A physics helper
  116118. * @param _scene BabylonJS scene
  116119. * @param _origin The origin position of the gravitational field event
  116120. * @param _options The options for the vortex event
  116121. */
  116122. function PhysicsGravitationalFieldEvent(_physicsHelper, _scene, _origin, _options) {
  116123. this._physicsHelper = _physicsHelper;
  116124. this._scene = _scene;
  116125. this._origin = _origin;
  116126. this._options = _options;
  116127. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  116128. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsRadialExplosionEventOptions()), this._options);
  116129. this._tickCallback = this._tick.bind(this);
  116130. this._options.strength = this._options.strength * -1;
  116131. }
  116132. /**
  116133. * Returns the data related to the gravitational field event (sphere).
  116134. * @returns A gravitational field event
  116135. */
  116136. PhysicsGravitationalFieldEvent.prototype.getData = function () {
  116137. this._dataFetched = true;
  116138. return {
  116139. sphere: this._sphere,
  116140. };
  116141. };
  116142. /**
  116143. * Enables the gravitational field.
  116144. */
  116145. PhysicsGravitationalFieldEvent.prototype.enable = function () {
  116146. this._tickCallback.call(this);
  116147. this._scene.registerBeforeRender(this._tickCallback);
  116148. };
  116149. /**
  116150. * Disables the gravitational field.
  116151. */
  116152. PhysicsGravitationalFieldEvent.prototype.disable = function () {
  116153. this._scene.unregisterBeforeRender(this._tickCallback);
  116154. };
  116155. /**
  116156. * Disposes the sphere.
  116157. * @param force The force to dispose from the gravitational field event
  116158. */
  116159. PhysicsGravitationalFieldEvent.prototype.dispose = function (force) {
  116160. var _this = this;
  116161. if (force === void 0) { force = true; }
  116162. if (force) {
  116163. this._sphere.dispose();
  116164. }
  116165. else {
  116166. setTimeout(function () {
  116167. if (!_this._dataFetched) {
  116168. _this._sphere.dispose();
  116169. }
  116170. }, 0);
  116171. }
  116172. };
  116173. PhysicsGravitationalFieldEvent.prototype._tick = function () {
  116174. // Since the params won't change, we fetch the event only once
  116175. if (this._sphere) {
  116176. this._physicsHelper.applyRadialExplosionForce(this._origin, this._options);
  116177. }
  116178. else {
  116179. var radialExplosionEvent = this._physicsHelper.applyRadialExplosionForce(this._origin, this._options);
  116180. if (radialExplosionEvent) {
  116181. this._sphere = radialExplosionEvent.getData().sphere.clone('radialExplosionEventSphereClone');
  116182. }
  116183. }
  116184. };
  116185. return PhysicsGravitationalFieldEvent;
  116186. }());
  116187. /**
  116188. * Represents a physics updraft event
  116189. */
  116190. var PhysicsUpdraftEvent = /** @class */ (function () {
  116191. /**
  116192. * Initializes the physics updraft event
  116193. * @param _scene BabylonJS scene
  116194. * @param _origin The origin position of the updraft
  116195. * @param _options The options for the updraft event
  116196. */
  116197. function PhysicsUpdraftEvent(_scene, _origin, _options) {
  116198. this._scene = _scene;
  116199. this._origin = _origin;
  116200. this._options = _options;
  116201. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // the most upper part of the cylinder
  116202. this._originDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // used if the updraftMode is perpendicular
  116203. this._cylinderPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // to keep the cylinders position, because normally the origin is in the center and not on the bottom
  116204. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  116205. this._physicsEngine = this._scene.getPhysicsEngine();
  116206. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsUpdraftEventOptions()), this._options);
  116207. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height / 2, 0), this._cylinderPosition);
  116208. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height, 0), this._originTop);
  116209. if (this._options.updraftMode === PhysicsUpdraftMode.Perpendicular) {
  116210. this._originDirection = this._origin.subtract(this._originTop).normalize();
  116211. }
  116212. this._tickCallback = this._tick.bind(this);
  116213. this._prepareCylinder();
  116214. }
  116215. /**
  116216. * Returns the data related to the updraft event (cylinder).
  116217. * @returns A physics updraft event
  116218. */
  116219. PhysicsUpdraftEvent.prototype.getData = function () {
  116220. this._dataFetched = true;
  116221. return {
  116222. cylinder: this._cylinder,
  116223. };
  116224. };
  116225. /**
  116226. * Enables the updraft.
  116227. */
  116228. PhysicsUpdraftEvent.prototype.enable = function () {
  116229. this._tickCallback.call(this);
  116230. this._scene.registerBeforeRender(this._tickCallback);
  116231. };
  116232. /**
  116233. * Disables the updraft.
  116234. */
  116235. PhysicsUpdraftEvent.prototype.disable = function () {
  116236. this._scene.unregisterBeforeRender(this._tickCallback);
  116237. };
  116238. /**
  116239. * Disposes the cylinder.
  116240. * @param force Specifies if the updraft should be disposed by force
  116241. */
  116242. PhysicsUpdraftEvent.prototype.dispose = function (force) {
  116243. var _this = this;
  116244. if (force === void 0) { force = true; }
  116245. if (!this._cylinder) {
  116246. return;
  116247. }
  116248. if (force) {
  116249. this._cylinder.dispose();
  116250. }
  116251. else {
  116252. setTimeout(function () {
  116253. if (!_this._dataFetched) {
  116254. _this._cylinder.dispose();
  116255. }
  116256. }, 0);
  116257. }
  116258. };
  116259. PhysicsUpdraftEvent.prototype.getImpostorHitData = function (impostor) {
  116260. if (impostor.mass === 0) {
  116261. return null;
  116262. }
  116263. if (!this._intersectsWithCylinder(impostor)) {
  116264. return null;
  116265. }
  116266. var impostorObjectCenter = impostor.getObjectCenter();
  116267. if (this._options.updraftMode === PhysicsUpdraftMode.Perpendicular) {
  116268. var direction = this._originDirection;
  116269. }
  116270. else {
  116271. var direction = impostorObjectCenter.subtract(this._originTop);
  116272. }
  116273. var distanceFromOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Distance(this._origin, impostorObjectCenter);
  116274. var multiplier = this._options.strength * -1;
  116275. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  116276. return { force: force, contactPoint: impostorObjectCenter, distanceFromOrigin: distanceFromOrigin };
  116277. };
  116278. PhysicsUpdraftEvent.prototype._tick = function () {
  116279. var _this = this;
  116280. this._physicsEngine.getImpostors().forEach(function (impostor) {
  116281. var impostorHitData = _this.getImpostorHitData(impostor);
  116282. if (!impostorHitData) {
  116283. return;
  116284. }
  116285. impostor.applyForce(impostorHitData.force, impostorHitData.contactPoint);
  116286. });
  116287. };
  116288. /*** Helpers ***/
  116289. PhysicsUpdraftEvent.prototype._prepareCylinder = function () {
  116290. if (!this._cylinder) {
  116291. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("updraftEventCylinder", {
  116292. height: this._options.height,
  116293. diameter: this._options.radius * 2,
  116294. }, this._scene);
  116295. this._cylinder.isVisible = false;
  116296. }
  116297. };
  116298. PhysicsUpdraftEvent.prototype._intersectsWithCylinder = function (impostor) {
  116299. var impostorObject = impostor.object;
  116300. this._cylinder.position = this._cylinderPosition;
  116301. return this._cylinder.intersectsMesh(impostorObject, true);
  116302. };
  116303. return PhysicsUpdraftEvent;
  116304. }());
  116305. /**
  116306. * Represents a physics vortex event
  116307. */
  116308. var PhysicsVortexEvent = /** @class */ (function () {
  116309. /**
  116310. * Initializes the physics vortex event
  116311. * @param _scene The BabylonJS scene
  116312. * @param _origin The origin position of the vortex
  116313. * @param _options The options for the vortex event
  116314. */
  116315. function PhysicsVortexEvent(_scene, _origin, _options) {
  116316. this._scene = _scene;
  116317. this._origin = _origin;
  116318. this._options = _options;
  116319. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // the most upper part of the cylinder
  116320. this._cylinderPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // to keep the cylinders position, because normally the origin is in the center and not on the bottom
  116321. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  116322. this._physicsEngine = this._scene.getPhysicsEngine();
  116323. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsVortexEventOptions()), this._options);
  116324. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height / 2, 0), this._cylinderPosition);
  116325. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height, 0), this._originTop);
  116326. this._tickCallback = this._tick.bind(this);
  116327. this._prepareCylinder();
  116328. }
  116329. /**
  116330. * Returns the data related to the vortex event (cylinder).
  116331. * @returns The physics vortex event data
  116332. */
  116333. PhysicsVortexEvent.prototype.getData = function () {
  116334. this._dataFetched = true;
  116335. return {
  116336. cylinder: this._cylinder,
  116337. };
  116338. };
  116339. /**
  116340. * Enables the vortex.
  116341. */
  116342. PhysicsVortexEvent.prototype.enable = function () {
  116343. this._tickCallback.call(this);
  116344. this._scene.registerBeforeRender(this._tickCallback);
  116345. };
  116346. /**
  116347. * Disables the cortex.
  116348. */
  116349. PhysicsVortexEvent.prototype.disable = function () {
  116350. this._scene.unregisterBeforeRender(this._tickCallback);
  116351. };
  116352. /**
  116353. * Disposes the sphere.
  116354. * @param force
  116355. */
  116356. PhysicsVortexEvent.prototype.dispose = function (force) {
  116357. var _this = this;
  116358. if (force === void 0) { force = true; }
  116359. if (force) {
  116360. this._cylinder.dispose();
  116361. }
  116362. else {
  116363. setTimeout(function () {
  116364. if (!_this._dataFetched) {
  116365. _this._cylinder.dispose();
  116366. }
  116367. }, 0);
  116368. }
  116369. };
  116370. PhysicsVortexEvent.prototype.getImpostorHitData = function (impostor) {
  116371. if (impostor.mass === 0) {
  116372. return null;
  116373. }
  116374. if (!this._intersectsWithCylinder(impostor)) {
  116375. return null;
  116376. }
  116377. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  116378. return null;
  116379. }
  116380. var impostorObjectCenter = impostor.getObjectCenter();
  116381. var originOnPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](this._origin.x, impostorObjectCenter.y, this._origin.z); // the distance to the origin as if both objects were on a plane (Y-axis)
  116382. var originToImpostorDirection = impostorObjectCenter.subtract(originOnPlane);
  116383. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](originOnPlane, originToImpostorDirection, this._options.radius);
  116384. var hit = ray.intersectsMesh(impostor.object);
  116385. var contactPoint = hit.pickedPoint;
  116386. if (!contactPoint) {
  116387. return null;
  116388. }
  116389. var absoluteDistanceFromOrigin = hit.distance / this._options.radius;
  116390. var directionToOrigin = contactPoint.normalize();
  116391. if (absoluteDistanceFromOrigin > this._options.centripetalForceThreshold) {
  116392. directionToOrigin = directionToOrigin.negate();
  116393. }
  116394. if (absoluteDistanceFromOrigin > this._options.centripetalForceThreshold) {
  116395. var forceX = directionToOrigin.x * this._options.centripetalForceMultiplier;
  116396. var forceY = directionToOrigin.y * this._options.updraftForceMultiplier;
  116397. var forceZ = directionToOrigin.z * this._options.centripetalForceMultiplier;
  116398. }
  116399. else {
  116400. var perpendicularDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(originOnPlane, impostorObjectCenter).normalize();
  116401. var forceX = (perpendicularDirection.x + directionToOrigin.x) * this._options.centrifugalForceMultiplier;
  116402. var forceY = this._originTop.y * this._options.updraftForceMultiplier;
  116403. var forceZ = (perpendicularDirection.z + directionToOrigin.z) * this._options.centrifugalForceMultiplier;
  116404. }
  116405. var force = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](forceX, forceY, forceZ);
  116406. force = force.multiplyByFloats(this._options.strength, this._options.strength, this._options.strength);
  116407. return { force: force, contactPoint: impostorObjectCenter, distanceFromOrigin: absoluteDistanceFromOrigin };
  116408. };
  116409. PhysicsVortexEvent.prototype._tick = function () {
  116410. var _this = this;
  116411. this._physicsEngine.getImpostors().forEach(function (impostor) {
  116412. var impostorHitData = _this.getImpostorHitData(impostor);
  116413. if (!impostorHitData) {
  116414. return;
  116415. }
  116416. impostor.applyForce(impostorHitData.force, impostorHitData.contactPoint);
  116417. });
  116418. };
  116419. /*** Helpers ***/
  116420. PhysicsVortexEvent.prototype._prepareCylinder = function () {
  116421. if (!this._cylinder) {
  116422. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("vortexEventCylinder", {
  116423. height: this._options.height,
  116424. diameter: this._options.radius * 2,
  116425. }, this._scene);
  116426. this._cylinder.isVisible = false;
  116427. }
  116428. };
  116429. PhysicsVortexEvent.prototype._intersectsWithCylinder = function (impostor) {
  116430. var impostorObject = impostor.object;
  116431. this._cylinder.position = this._cylinderPosition;
  116432. return this._cylinder.intersectsMesh(impostorObject, true);
  116433. };
  116434. return PhysicsVortexEvent;
  116435. }());
  116436. /**
  116437. * Options fot the radial explosion event
  116438. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116439. */
  116440. var PhysicsRadialExplosionEventOptions = /** @class */ (function () {
  116441. function PhysicsRadialExplosionEventOptions() {
  116442. /**
  116443. * The radius of the sphere for the radial explosion.
  116444. */
  116445. this.radius = 5;
  116446. /**
  116447. * The strenth of the explosion.
  116448. */
  116449. this.strength = 10;
  116450. /**
  116451. * The strenght of the force in correspondence to the distance of the affected object
  116452. */
  116453. this.falloff = PhysicsRadialImpulseFalloff.Constant;
  116454. /**
  116455. * Sphere options for the radial explosion.
  116456. */
  116457. this.sphere = { segments: 32, diameter: 1 };
  116458. }
  116459. return PhysicsRadialExplosionEventOptions;
  116460. }());
  116461. /**
  116462. * Options fot the updraft event
  116463. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116464. */
  116465. var PhysicsUpdraftEventOptions = /** @class */ (function () {
  116466. function PhysicsUpdraftEventOptions() {
  116467. /**
  116468. * The radius of the cylinder for the vortex
  116469. */
  116470. this.radius = 5;
  116471. /**
  116472. * The strenth of the updraft.
  116473. */
  116474. this.strength = 10;
  116475. /**
  116476. * The height of the cylinder for the updraft.
  116477. */
  116478. this.height = 10;
  116479. /**
  116480. * The mode for the the updraft.
  116481. */
  116482. this.updraftMode = PhysicsUpdraftMode.Center;
  116483. }
  116484. return PhysicsUpdraftEventOptions;
  116485. }());
  116486. /**
  116487. * Options fot the vortex event
  116488. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116489. */
  116490. var PhysicsVortexEventOptions = /** @class */ (function () {
  116491. function PhysicsVortexEventOptions() {
  116492. /**
  116493. * The radius of the cylinder for the vortex
  116494. */
  116495. this.radius = 5;
  116496. /**
  116497. * The strenth of the vortex.
  116498. */
  116499. this.strength = 10;
  116500. /**
  116501. * The height of the cylinder for the vortex.
  116502. */
  116503. this.height = 10;
  116504. /**
  116505. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  116506. */
  116507. this.centripetalForceThreshold = 0.7;
  116508. /**
  116509. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  116510. */
  116511. this.centripetalForceMultiplier = 5;
  116512. /**
  116513. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  116514. */
  116515. this.centrifugalForceMultiplier = 0.5;
  116516. /**
  116517. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  116518. */
  116519. this.updraftForceMultiplier = 0.02;
  116520. }
  116521. return PhysicsVortexEventOptions;
  116522. }());
  116523. /**
  116524. * The strenght of the force in correspondence to the distance of the affected object
  116525. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116526. */
  116527. var PhysicsRadialImpulseFalloff;
  116528. (function (PhysicsRadialImpulseFalloff) {
  116529. /** Defines that impulse is constant in strength across it's whole radius */
  116530. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Constant"] = 0] = "Constant";
  116531. /** Defines that impulse gets weaker if it's further from the origin */
  116532. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Linear"] = 1] = "Linear";
  116533. })(PhysicsRadialImpulseFalloff || (PhysicsRadialImpulseFalloff = {}));
  116534. /**
  116535. * The strength of the force in correspondence to the distance of the affected object
  116536. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116537. */
  116538. var PhysicsUpdraftMode;
  116539. (function (PhysicsUpdraftMode) {
  116540. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  116541. PhysicsUpdraftMode[PhysicsUpdraftMode["Center"] = 0] = "Center";
  116542. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  116543. PhysicsUpdraftMode[PhysicsUpdraftMode["Perpendicular"] = 1] = "Perpendicular";
  116544. })(PhysicsUpdraftMode || (PhysicsUpdraftMode = {}));
  116545. /***/ }),
  116546. /***/ "./Physics/physicsImpostor.ts":
  116547. /*!************************************!*\
  116548. !*** ./Physics/physicsImpostor.ts ***!
  116549. \************************************/
  116550. /*! exports provided: PhysicsImpostor */
  116551. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116552. "use strict";
  116553. __webpack_require__.r(__webpack_exports__);
  116554. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return PhysicsImpostor; });
  116555. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  116556. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  116557. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  116558. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  116559. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  116560. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  116561. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  116562. return new PhysicsImpostor(physicObject, jsonObject.physicsImpostor, {
  116563. mass: jsonObject.physicsMass,
  116564. friction: jsonObject.physicsFriction,
  116565. restitution: jsonObject.physicsRestitution
  116566. }, scene);
  116567. };
  116568. /**
  116569. * Represents a physics imposter
  116570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116571. */
  116572. var PhysicsImpostor = /** @class */ (function () {
  116573. /**
  116574. * Initializes the physics imposter
  116575. * @param object The physics-enabled object used as the physics imposter
  116576. * @param type The type of the physics imposter
  116577. * @param _options The options for the physics imposter
  116578. * @param _scene The Babylon scene
  116579. */
  116580. function PhysicsImpostor(
  116581. /**
  116582. * The physics-enabled object used as the physics imposter
  116583. */
  116584. object,
  116585. /**
  116586. * The type of the physics imposter
  116587. */
  116588. type, _options, _scene) {
  116589. if (_options === void 0) { _options = { mass: 0 }; }
  116590. var _this = this;
  116591. this.object = object;
  116592. this.type = type;
  116593. this._options = _options;
  116594. this._scene = _scene;
  116595. this._bodyUpdateRequired = false;
  116596. this._onBeforePhysicsStepCallbacks = new Array();
  116597. this._onAfterPhysicsStepCallbacks = new Array();
  116598. /** @hidden */
  116599. this._onPhysicsCollideCallbacks = [];
  116600. this._deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  116601. this._isDisposed = false;
  116602. /**
  116603. * @hidden
  116604. */
  116605. this.soft = false;
  116606. /**
  116607. * @hidden
  116608. */
  116609. this.segments = 0;
  116610. //temp variables for parent rotation calculations
  116611. //private _mats: Array<Matrix> = [new Matrix(), new Matrix()];
  116612. this._tmpQuat = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  116613. this._tmpQuat2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  116614. /**
  116615. * this function is executed by the physics engine.
  116616. */
  116617. this.beforeStep = function () {
  116618. if (!_this._physicsEngine) {
  116619. return;
  116620. }
  116621. _this.object.translate(_this._deltaPosition, -1);
  116622. _this._deltaRotationConjugated && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotationConjugated, _this.object.rotationQuaternion);
  116623. _this.object.computeWorldMatrix(false);
  116624. if (_this.object.parent && _this.object.rotationQuaternion) {
  116625. _this.getParentsRotation();
  116626. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this._tmpQuat);
  116627. }
  116628. else {
  116629. _this._tmpQuat.copyFrom(_this.object.rotationQuaternion || new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]());
  116630. }
  116631. if (!_this._options.disableBidirectionalTransformation) {
  116632. _this.object.rotationQuaternion && _this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(_this, /*bInfo.boundingBox.centerWorld*/ _this.object.getAbsolutePosition(), _this._tmpQuat);
  116633. }
  116634. _this._onBeforePhysicsStepCallbacks.forEach(function (func) {
  116635. func(_this);
  116636. });
  116637. };
  116638. /**
  116639. * this function is executed by the physics engine
  116640. */
  116641. this.afterStep = function () {
  116642. if (!_this._physicsEngine) {
  116643. return;
  116644. }
  116645. _this._onAfterPhysicsStepCallbacks.forEach(function (func) {
  116646. func(_this);
  116647. });
  116648. _this._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(_this);
  116649. // object has now its world rotation. needs to be converted to local.
  116650. if (_this.object.parent && _this.object.rotationQuaternion) {
  116651. _this.getParentsRotation();
  116652. _this._tmpQuat.conjugateInPlace();
  116653. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this.object.rotationQuaternion);
  116654. }
  116655. // take the position set and make it the absolute position of this object.
  116656. _this.object.setAbsolutePosition(_this.object.position);
  116657. _this._deltaRotation && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotation, _this.object.rotationQuaternion);
  116658. _this.object.translate(_this._deltaPosition, 1);
  116659. };
  116660. /**
  116661. * Legacy collision detection event support
  116662. */
  116663. this.onCollideEvent = null;
  116664. /**
  116665. * event and body object due to cannon's event-based architecture.
  116666. */
  116667. this.onCollide = function (e) {
  116668. if (!_this._onPhysicsCollideCallbacks.length && !_this.onCollideEvent) {
  116669. return;
  116670. }
  116671. if (!_this._physicsEngine) {
  116672. return;
  116673. }
  116674. var otherImpostor = _this._physicsEngine.getImpostorWithPhysicsBody(e.body);
  116675. if (otherImpostor) {
  116676. // Legacy collision detection event support
  116677. if (_this.onCollideEvent) {
  116678. _this.onCollideEvent(_this, otherImpostor);
  116679. }
  116680. _this._onPhysicsCollideCallbacks.filter(function (obj) {
  116681. return obj.otherImpostors.indexOf(otherImpostor) !== -1;
  116682. }).forEach(function (obj) {
  116683. obj.callback(_this, otherImpostor);
  116684. });
  116685. }
  116686. };
  116687. //sanity check!
  116688. if (!this.object) {
  116689. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("No object was provided. A physics object is obligatory");
  116690. return;
  116691. }
  116692. // Legacy support for old syntax.
  116693. if (!this._scene && object.getScene) {
  116694. this._scene = object.getScene();
  116695. }
  116696. if (!this._scene) {
  116697. return;
  116698. }
  116699. if (this.type > 100) {
  116700. this.soft = true;
  116701. }
  116702. this._physicsEngine = this._scene.getPhysicsEngine();
  116703. if (!this._physicsEngine) {
  116704. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors.");
  116705. }
  116706. else {
  116707. //set the object's quaternion, if not set
  116708. if (!this.object.rotationQuaternion) {
  116709. if (this.object.rotation) {
  116710. this.object.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(this.object.rotation.y, this.object.rotation.x, this.object.rotation.z);
  116711. }
  116712. else {
  116713. this.object.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  116714. }
  116715. }
  116716. //default options params
  116717. this._options.mass = (_options.mass === void 0) ? 0 : _options.mass;
  116718. this._options.friction = (_options.friction === void 0) ? 0.2 : _options.friction;
  116719. this._options.restitution = (_options.restitution === void 0) ? 0.2 : _options.restitution;
  116720. if (this.soft) {
  116721. //softbody mass must be above 0;
  116722. this._options.mass = this._options.mass > 0 ? this._options.mass : 1;
  116723. this._options.pressure = (_options.pressure === void 0) ? 200 : _options.pressure;
  116724. this._options.stiffness = (_options.stiffness === void 0) ? 1 : _options.stiffness;
  116725. this._options.velocityIterations = (_options.velocityIterations === void 0) ? 20 : _options.velocityIterations;
  116726. this._options.positionIterations = (_options.positionIterations === void 0) ? 20 : _options.positionIterations;
  116727. this._options.fixedPoints = (_options.fixedPoints === void 0) ? 0 : _options.fixedPoints;
  116728. this._options.margin = (_options.margin === void 0) ? 0 : _options.margin;
  116729. this._options.damping = (_options.damping === void 0) ? 0 : _options.damping;
  116730. this._options.path = (_options.path === void 0) ? null : _options.path;
  116731. this._options.shape = (_options.shape === void 0) ? null : _options.shape;
  116732. }
  116733. this._joints = [];
  116734. //If the mesh has a parent, don't initialize the physicsBody. Instead wait for the parent to do that.
  116735. if (!this.object.parent || this._options.ignoreParent) {
  116736. this._init();
  116737. }
  116738. else if (this.object.parent.physicsImpostor) {
  116739. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("You must affect impostors to children before affecting impostor to parent.");
  116740. }
  116741. }
  116742. }
  116743. Object.defineProperty(PhysicsImpostor.prototype, "isDisposed", {
  116744. /**
  116745. * Specifies if the physics imposter is disposed
  116746. */
  116747. get: function () {
  116748. return this._isDisposed;
  116749. },
  116750. enumerable: true,
  116751. configurable: true
  116752. });
  116753. Object.defineProperty(PhysicsImpostor.prototype, "mass", {
  116754. /**
  116755. * Gets the mass of the physics imposter
  116756. */
  116757. get: function () {
  116758. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyMass(this) : 0;
  116759. },
  116760. set: function (value) {
  116761. this.setMass(value);
  116762. },
  116763. enumerable: true,
  116764. configurable: true
  116765. });
  116766. Object.defineProperty(PhysicsImpostor.prototype, "friction", {
  116767. /**
  116768. * Gets the coefficient of friction
  116769. */
  116770. get: function () {
  116771. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyFriction(this) : 0;
  116772. },
  116773. /**
  116774. * Sets the coefficient of friction
  116775. */
  116776. set: function (value) {
  116777. if (!this._physicsEngine) {
  116778. return;
  116779. }
  116780. this._physicsEngine.getPhysicsPlugin().setBodyFriction(this, value);
  116781. },
  116782. enumerable: true,
  116783. configurable: true
  116784. });
  116785. Object.defineProperty(PhysicsImpostor.prototype, "restitution", {
  116786. /**
  116787. * Gets the coefficient of restitution
  116788. */
  116789. get: function () {
  116790. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this) : 0;
  116791. },
  116792. /**
  116793. * Sets the coefficient of restitution
  116794. */
  116795. set: function (value) {
  116796. if (!this._physicsEngine) {
  116797. return;
  116798. }
  116799. this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this, value);
  116800. },
  116801. enumerable: true,
  116802. configurable: true
  116803. });
  116804. Object.defineProperty(PhysicsImpostor.prototype, "pressure", {
  116805. /**
  116806. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  116807. */
  116808. get: function () {
  116809. if (!this._physicsEngine) {
  116810. return 0;
  116811. }
  116812. var plugin = this._physicsEngine.getPhysicsPlugin();
  116813. if (!plugin.setBodyPressure) {
  116814. return 0;
  116815. }
  116816. return plugin.getBodyPressure(this);
  116817. },
  116818. /**
  116819. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  116820. */
  116821. set: function (value) {
  116822. if (!this._physicsEngine) {
  116823. return;
  116824. }
  116825. var plugin = this._physicsEngine.getPhysicsPlugin();
  116826. if (!plugin.setBodyPressure) {
  116827. return;
  116828. }
  116829. plugin.setBodyPressure(this, value);
  116830. },
  116831. enumerable: true,
  116832. configurable: true
  116833. });
  116834. Object.defineProperty(PhysicsImpostor.prototype, "stiffness", {
  116835. /**
  116836. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  116837. */
  116838. get: function () {
  116839. if (!this._physicsEngine) {
  116840. return 0;
  116841. }
  116842. var plugin = this._physicsEngine.getPhysicsPlugin();
  116843. if (!plugin.getBodyStiffness) {
  116844. return 0;
  116845. }
  116846. return plugin.getBodyStiffness(this);
  116847. },
  116848. /**
  116849. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  116850. */
  116851. set: function (value) {
  116852. if (!this._physicsEngine) {
  116853. return;
  116854. }
  116855. var plugin = this._physicsEngine.getPhysicsPlugin();
  116856. if (!plugin.setBodyStiffness) {
  116857. return;
  116858. }
  116859. plugin.setBodyStiffness(this, value);
  116860. },
  116861. enumerable: true,
  116862. configurable: true
  116863. });
  116864. Object.defineProperty(PhysicsImpostor.prototype, "velocityIterations", {
  116865. /**
  116866. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  116867. */
  116868. get: function () {
  116869. if (!this._physicsEngine) {
  116870. return 0;
  116871. }
  116872. var plugin = this._physicsEngine.getPhysicsPlugin();
  116873. if (!plugin.getBodyVelocityIterations) {
  116874. return 0;
  116875. }
  116876. return plugin.getBodyVelocityIterations(this);
  116877. },
  116878. /**
  116879. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  116880. */
  116881. set: function (value) {
  116882. if (!this._physicsEngine) {
  116883. return;
  116884. }
  116885. var plugin = this._physicsEngine.getPhysicsPlugin();
  116886. if (!plugin.setBodyVelocityIterations) {
  116887. return;
  116888. }
  116889. plugin.setBodyVelocityIterations(this, value);
  116890. },
  116891. enumerable: true,
  116892. configurable: true
  116893. });
  116894. Object.defineProperty(PhysicsImpostor.prototype, "positionIterations", {
  116895. /**
  116896. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  116897. */
  116898. get: function () {
  116899. if (!this._physicsEngine) {
  116900. return 0;
  116901. }
  116902. var plugin = this._physicsEngine.getPhysicsPlugin();
  116903. if (!plugin.getBodyPositionIterations) {
  116904. return 0;
  116905. }
  116906. return plugin.getBodyPositionIterations(this);
  116907. },
  116908. /**
  116909. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  116910. */
  116911. set: function (value) {
  116912. if (!this._physicsEngine) {
  116913. return;
  116914. }
  116915. var plugin = this._physicsEngine.getPhysicsPlugin();
  116916. if (!plugin.setBodyPositionIterations) {
  116917. return;
  116918. }
  116919. plugin.setBodyPositionIterations(this, value);
  116920. },
  116921. enumerable: true,
  116922. configurable: true
  116923. });
  116924. /**
  116925. * This function will completly initialize this impostor.
  116926. * It will create a new body - but only if this mesh has no parent.
  116927. * If it has, this impostor will not be used other than to define the impostor
  116928. * of the child mesh.
  116929. * @hidden
  116930. */
  116931. PhysicsImpostor.prototype._init = function () {
  116932. if (!this._physicsEngine) {
  116933. return;
  116934. }
  116935. this._physicsEngine.removeImpostor(this);
  116936. this.physicsBody = null;
  116937. this._parent = this._parent || this._getPhysicsParent();
  116938. if (!this._isDisposed && (!this.parent || this._options.ignoreParent)) {
  116939. this._physicsEngine.addImpostor(this);
  116940. }
  116941. };
  116942. PhysicsImpostor.prototype._getPhysicsParent = function () {
  116943. if (this.object.parent instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]) {
  116944. var parentMesh = this.object.parent;
  116945. return parentMesh.physicsImpostor;
  116946. }
  116947. return null;
  116948. };
  116949. /**
  116950. * Should a new body be generated.
  116951. * @returns boolean specifying if body initialization is required
  116952. */
  116953. PhysicsImpostor.prototype.isBodyInitRequired = function () {
  116954. return this._bodyUpdateRequired || (!this._physicsBody && !this._parent);
  116955. };
  116956. /**
  116957. * Sets the updated scaling
  116958. * @param updated Specifies if the scaling is updated
  116959. */
  116960. PhysicsImpostor.prototype.setScalingUpdated = function () {
  116961. this.forceUpdate();
  116962. };
  116963. /**
  116964. * Force a regeneration of this or the parent's impostor's body.
  116965. * Use under cautious - This will remove all joints already implemented.
  116966. */
  116967. PhysicsImpostor.prototype.forceUpdate = function () {
  116968. this._init();
  116969. if (this.parent && !this._options.ignoreParent) {
  116970. this.parent.forceUpdate();
  116971. }
  116972. };
  116973. Object.defineProperty(PhysicsImpostor.prototype, "physicsBody", {
  116974. /*public get mesh(): AbstractMesh {
  116975. return this._mesh;
  116976. }*/
  116977. /**
  116978. * Gets the body that holds this impostor. Either its own, or its parent.
  116979. */
  116980. get: function () {
  116981. return (this._parent && !this._options.ignoreParent) ? this._parent.physicsBody : this._physicsBody;
  116982. },
  116983. /**
  116984. * Set the physics body. Used mainly by the physics engine/plugin
  116985. */
  116986. set: function (physicsBody) {
  116987. if (this._physicsBody && this._physicsEngine) {
  116988. this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this);
  116989. }
  116990. this._physicsBody = physicsBody;
  116991. this.resetUpdateFlags();
  116992. },
  116993. enumerable: true,
  116994. configurable: true
  116995. });
  116996. Object.defineProperty(PhysicsImpostor.prototype, "parent", {
  116997. /**
  116998. * Get the parent of the physics imposter
  116999. * @returns Physics imposter or null
  117000. */
  117001. get: function () {
  117002. return !this._options.ignoreParent && this._parent ? this._parent : null;
  117003. },
  117004. /**
  117005. * Sets the parent of the physics imposter
  117006. */
  117007. set: function (value) {
  117008. this._parent = value;
  117009. },
  117010. enumerable: true,
  117011. configurable: true
  117012. });
  117013. /**
  117014. * Resets the update flags
  117015. */
  117016. PhysicsImpostor.prototype.resetUpdateFlags = function () {
  117017. this._bodyUpdateRequired = false;
  117018. };
  117019. /**
  117020. * Gets the object extend size
  117021. * @returns the object extend size
  117022. */
  117023. PhysicsImpostor.prototype.getObjectExtendSize = function () {
  117024. if (this.object.getBoundingInfo) {
  117025. var q = this.object.rotationQuaternion;
  117026. //reset rotation
  117027. this.object.rotationQuaternion = PhysicsImpostor.IDENTITY_QUATERNION;
  117028. //calculate the world matrix with no rotation
  117029. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  117030. var boundingInfo = this.object.getBoundingInfo();
  117031. var size = boundingInfo.boundingBox.extendSizeWorld.scale(2);
  117032. //bring back the rotation
  117033. this.object.rotationQuaternion = q;
  117034. //calculate the world matrix with the new rotation
  117035. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  117036. return size;
  117037. }
  117038. else {
  117039. return PhysicsImpostor.DEFAULT_OBJECT_SIZE;
  117040. }
  117041. };
  117042. /**
  117043. * Gets the object center
  117044. * @returns The object center
  117045. */
  117046. PhysicsImpostor.prototype.getObjectCenter = function () {
  117047. if (this.object.getBoundingInfo) {
  117048. var boundingInfo = this.object.getBoundingInfo();
  117049. return boundingInfo.boundingBox.centerWorld;
  117050. }
  117051. else {
  117052. return this.object.position;
  117053. }
  117054. };
  117055. /**
  117056. * Get a specific parametes from the options parameter
  117057. * @param paramName The object parameter name
  117058. * @returns The object parameter
  117059. */
  117060. PhysicsImpostor.prototype.getParam = function (paramName) {
  117061. return this._options[paramName];
  117062. };
  117063. /**
  117064. * Sets a specific parameter in the options given to the physics plugin
  117065. * @param paramName The parameter name
  117066. * @param value The value of the parameter
  117067. */
  117068. PhysicsImpostor.prototype.setParam = function (paramName, value) {
  117069. this._options[paramName] = value;
  117070. this._bodyUpdateRequired = true;
  117071. };
  117072. /**
  117073. * Specifically change the body's mass option. Won't recreate the physics body object
  117074. * @param mass The mass of the physics imposter
  117075. */
  117076. PhysicsImpostor.prototype.setMass = function (mass) {
  117077. if (this.getParam("mass") !== mass) {
  117078. this.setParam("mass", mass);
  117079. }
  117080. if (this._physicsEngine) {
  117081. this._physicsEngine.getPhysicsPlugin().setBodyMass(this, mass);
  117082. }
  117083. };
  117084. /**
  117085. * Gets the linear velocity
  117086. * @returns linear velocity or null
  117087. */
  117088. PhysicsImpostor.prototype.getLinearVelocity = function () {
  117089. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  117090. };
  117091. /**
  117092. * Sets the linear velocity
  117093. * @param velocity linear velocity or null
  117094. */
  117095. PhysicsImpostor.prototype.setLinearVelocity = function (velocity) {
  117096. if (this._physicsEngine) {
  117097. this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, velocity);
  117098. }
  117099. };
  117100. /**
  117101. * Gets the angular velocity
  117102. * @returns angular velocity or null
  117103. */
  117104. PhysicsImpostor.prototype.getAngularVelocity = function () {
  117105. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  117106. };
  117107. /**
  117108. * Sets the angular velocity
  117109. * @param velocity The velocity or null
  117110. */
  117111. PhysicsImpostor.prototype.setAngularVelocity = function (velocity) {
  117112. if (this._physicsEngine) {
  117113. this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this, velocity);
  117114. }
  117115. };
  117116. /**
  117117. * Execute a function with the physics plugin native code
  117118. * Provide a function the will have two variables - the world object and the physics body object
  117119. * @param func The function to execute with the physics plugin native code
  117120. */
  117121. PhysicsImpostor.prototype.executeNativeFunction = function (func) {
  117122. if (this._physicsEngine) {
  117123. func(this._physicsEngine.getPhysicsPlugin().world, this.physicsBody);
  117124. }
  117125. };
  117126. /**
  117127. * Register a function that will be executed before the physics world is stepping forward
  117128. * @param func The function to execute before the physics world is stepped forward
  117129. */
  117130. PhysicsImpostor.prototype.registerBeforePhysicsStep = function (func) {
  117131. this._onBeforePhysicsStepCallbacks.push(func);
  117132. };
  117133. /**
  117134. * Unregister a function that will be executed before the physics world is stepping forward
  117135. * @param func The function to execute before the physics world is stepped forward
  117136. */
  117137. PhysicsImpostor.prototype.unregisterBeforePhysicsStep = function (func) {
  117138. var index = this._onBeforePhysicsStepCallbacks.indexOf(func);
  117139. if (index > -1) {
  117140. this._onBeforePhysicsStepCallbacks.splice(index, 1);
  117141. }
  117142. else {
  117143. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  117144. }
  117145. };
  117146. /**
  117147. * Register a function that will be executed after the physics step
  117148. * @param func The function to execute after physics step
  117149. */
  117150. PhysicsImpostor.prototype.registerAfterPhysicsStep = function (func) {
  117151. this._onAfterPhysicsStepCallbacks.push(func);
  117152. };
  117153. /**
  117154. * Unregisters a function that will be executed after the physics step
  117155. * @param func The function to execute after physics step
  117156. */
  117157. PhysicsImpostor.prototype.unregisterAfterPhysicsStep = function (func) {
  117158. var index = this._onAfterPhysicsStepCallbacks.indexOf(func);
  117159. if (index > -1) {
  117160. this._onAfterPhysicsStepCallbacks.splice(index, 1);
  117161. }
  117162. else {
  117163. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  117164. }
  117165. };
  117166. /**
  117167. * register a function that will be executed when this impostor collides against a different body
  117168. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  117169. * @param func Callback that is executed on collision
  117170. */
  117171. PhysicsImpostor.prototype.registerOnPhysicsCollide = function (collideAgainst, func) {
  117172. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  117173. this._onPhysicsCollideCallbacks.push({ callback: func, otherImpostors: collidedAgainstList });
  117174. };
  117175. /**
  117176. * Unregisters the physics imposter on contact
  117177. * @param collideAgainst The physics object to collide against
  117178. * @param func Callback to execute on collision
  117179. */
  117180. PhysicsImpostor.prototype.unregisterOnPhysicsCollide = function (collideAgainst, func) {
  117181. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  117182. var index = -1;
  117183. var found = this._onPhysicsCollideCallbacks.some(function (cbDef, idx) {
  117184. if (cbDef.callback === func && cbDef.otherImpostors.length === collidedAgainstList.length) {
  117185. // chcek the arrays match
  117186. var sameList = cbDef.otherImpostors.every(function (impostor) {
  117187. return collidedAgainstList.indexOf(impostor) > -1;
  117188. });
  117189. if (sameList) {
  117190. index = idx;
  117191. }
  117192. return sameList;
  117193. }
  117194. return false;
  117195. });
  117196. if (found) {
  117197. this._onPhysicsCollideCallbacks.splice(index, 1);
  117198. }
  117199. else {
  117200. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  117201. }
  117202. };
  117203. /**
  117204. * Get the parent rotation
  117205. * @returns The parent rotation
  117206. */
  117207. PhysicsImpostor.prototype.getParentsRotation = function () {
  117208. var parent = this.object.parent;
  117209. this._tmpQuat.copyFromFloats(0, 0, 0, 1);
  117210. while (parent) {
  117211. if (parent.rotationQuaternion) {
  117212. this._tmpQuat2.copyFrom(parent.rotationQuaternion);
  117213. }
  117214. else {
  117215. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(parent.rotation.y, parent.rotation.x, parent.rotation.z, this._tmpQuat2);
  117216. }
  117217. this._tmpQuat.multiplyToRef(this._tmpQuat2, this._tmpQuat);
  117218. parent = parent.parent;
  117219. }
  117220. return this._tmpQuat;
  117221. };
  117222. /**
  117223. * Apply a force
  117224. * @param force The force to apply
  117225. * @param contactPoint The contact point for the force
  117226. * @returns The physics imposter
  117227. */
  117228. PhysicsImpostor.prototype.applyForce = function (force, contactPoint) {
  117229. if (this._physicsEngine) {
  117230. this._physicsEngine.getPhysicsPlugin().applyForce(this, force, contactPoint);
  117231. }
  117232. return this;
  117233. };
  117234. /**
  117235. * Apply an impulse
  117236. * @param force The impulse force
  117237. * @param contactPoint The contact point for the impulse force
  117238. * @returns The physics imposter
  117239. */
  117240. PhysicsImpostor.prototype.applyImpulse = function (force, contactPoint) {
  117241. if (this._physicsEngine) {
  117242. this._physicsEngine.getPhysicsPlugin().applyImpulse(this, force, contactPoint);
  117243. }
  117244. return this;
  117245. };
  117246. /**
  117247. * A help function to create a joint
  117248. * @param otherImpostor A physics imposter used to create a joint
  117249. * @param jointType The type of joint
  117250. * @param jointData The data for the joint
  117251. * @returns The physics imposter
  117252. */
  117253. PhysicsImpostor.prototype.createJoint = function (otherImpostor, jointType, jointData) {
  117254. var joint = new _physicsJoint__WEBPACK_IMPORTED_MODULE_5__["PhysicsJoint"](jointType, jointData);
  117255. this.addJoint(otherImpostor, joint);
  117256. return this;
  117257. };
  117258. /**
  117259. * Add a joint to this impostor with a different impostor
  117260. * @param otherImpostor A physics imposter used to add a joint
  117261. * @param joint The joint to add
  117262. * @returns The physics imposter
  117263. */
  117264. PhysicsImpostor.prototype.addJoint = function (otherImpostor, joint) {
  117265. this._joints.push({
  117266. otherImpostor: otherImpostor,
  117267. joint: joint
  117268. });
  117269. if (this._physicsEngine) {
  117270. this._physicsEngine.addJoint(this, otherImpostor, joint);
  117271. }
  117272. return this;
  117273. };
  117274. /**
  117275. * Add an anchor to a cloth impostor
  117276. * @param otherImpostor rigid impostor to anchor to
  117277. * @param width ratio across width from 0 to 1
  117278. * @param height ratio up height from 0 to 1
  117279. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  117280. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  117281. * @returns impostor the soft imposter
  117282. */
  117283. PhysicsImpostor.prototype.addAnchor = function (otherImpostor, width, height, influence, noCollisionBetweenLinkedBodies) {
  117284. if (!this._physicsEngine) {
  117285. return this;
  117286. }
  117287. var plugin = this._physicsEngine.getPhysicsPlugin();
  117288. if (!plugin.appendAnchor) {
  117289. return this;
  117290. }
  117291. if (this._physicsEngine) {
  117292. plugin.appendAnchor(this, otherImpostor, width, height, influence, noCollisionBetweenLinkedBodies);
  117293. }
  117294. return this;
  117295. };
  117296. /**
  117297. * Add a hook to a rope impostor
  117298. * @param otherImpostor rigid impostor to anchor to
  117299. * @param length ratio across rope from 0 to 1
  117300. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  117301. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  117302. * @returns impostor the rope imposter
  117303. */
  117304. PhysicsImpostor.prototype.addHook = function (otherImpostor, length, influence, noCollisionBetweenLinkedBodies) {
  117305. if (!this._physicsEngine) {
  117306. return this;
  117307. }
  117308. var plugin = this._physicsEngine.getPhysicsPlugin();
  117309. if (!plugin.appendAnchor) {
  117310. return this;
  117311. }
  117312. if (this._physicsEngine) {
  117313. plugin.appendHook(this, otherImpostor, length, influence, noCollisionBetweenLinkedBodies);
  117314. }
  117315. return this;
  117316. };
  117317. /**
  117318. * Will keep this body still, in a sleep mode.
  117319. * @returns the physics imposter
  117320. */
  117321. PhysicsImpostor.prototype.sleep = function () {
  117322. if (this._physicsEngine) {
  117323. this._physicsEngine.getPhysicsPlugin().sleepBody(this);
  117324. }
  117325. return this;
  117326. };
  117327. /**
  117328. * Wake the body up.
  117329. * @returns The physics imposter
  117330. */
  117331. PhysicsImpostor.prototype.wakeUp = function () {
  117332. if (this._physicsEngine) {
  117333. this._physicsEngine.getPhysicsPlugin().wakeUpBody(this);
  117334. }
  117335. return this;
  117336. };
  117337. /**
  117338. * Clones the physics imposter
  117339. * @param newObject The physics imposter clones to this physics-enabled object
  117340. * @returns A nullable physics imposter
  117341. */
  117342. PhysicsImpostor.prototype.clone = function (newObject) {
  117343. if (!newObject) {
  117344. return null;
  117345. }
  117346. return new PhysicsImpostor(newObject, this.type, this._options, this._scene);
  117347. };
  117348. /**
  117349. * Disposes the physics imposter
  117350. */
  117351. PhysicsImpostor.prototype.dispose = function ( /*disposeChildren: boolean = true*/) {
  117352. var _this = this;
  117353. //no dispose if no physics engine is available.
  117354. if (!this._physicsEngine) {
  117355. return;
  117356. }
  117357. this._joints.forEach(function (j) {
  117358. if (_this._physicsEngine) {
  117359. _this._physicsEngine.removeJoint(_this, j.otherImpostor, j.joint);
  117360. }
  117361. });
  117362. //dispose the physics body
  117363. this._physicsEngine.removeImpostor(this);
  117364. if (this.parent) {
  117365. this.parent.forceUpdate();
  117366. }
  117367. else {
  117368. /*this._object.getChildMeshes().forEach(function(mesh) {
  117369. if (mesh.physicsImpostor) {
  117370. if (disposeChildren) {
  117371. mesh.physicsImpostor.dispose();
  117372. mesh.physicsImpostor = null;
  117373. }
  117374. }
  117375. })*/
  117376. }
  117377. this._isDisposed = true;
  117378. };
  117379. /**
  117380. * Sets the delta position
  117381. * @param position The delta position amount
  117382. */
  117383. PhysicsImpostor.prototype.setDeltaPosition = function (position) {
  117384. this._deltaPosition.copyFrom(position);
  117385. };
  117386. /**
  117387. * Sets the delta rotation
  117388. * @param rotation The delta rotation amount
  117389. */
  117390. PhysicsImpostor.prototype.setDeltaRotation = function (rotation) {
  117391. if (!this._deltaRotation) {
  117392. this._deltaRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  117393. }
  117394. this._deltaRotation.copyFrom(rotation);
  117395. this._deltaRotationConjugated = this._deltaRotation.conjugate();
  117396. };
  117397. /**
  117398. * Gets the box size of the physics imposter and stores the result in the input parameter
  117399. * @param result Stores the box size
  117400. * @returns The physics imposter
  117401. */
  117402. PhysicsImpostor.prototype.getBoxSizeToRef = function (result) {
  117403. if (this._physicsEngine) {
  117404. this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this, result);
  117405. }
  117406. return this;
  117407. };
  117408. /**
  117409. * Gets the radius of the physics imposter
  117410. * @returns Radius of the physics imposter
  117411. */
  117412. PhysicsImpostor.prototype.getRadius = function () {
  117413. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getRadius(this) : 0;
  117414. };
  117415. /**
  117416. * Sync a bone with this impostor
  117417. * @param bone The bone to sync to the impostor.
  117418. * @param boneMesh The mesh that the bone is influencing.
  117419. * @param jointPivot The pivot of the joint / bone in local space.
  117420. * @param distToJoint Optional distance from the impostor to the joint.
  117421. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  117422. */
  117423. PhysicsImpostor.prototype.syncBoneWithImpostor = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation) {
  117424. var tempVec = PhysicsImpostor._tmpVecs[0];
  117425. var mesh = this.object;
  117426. if (mesh.rotationQuaternion) {
  117427. if (adjustRotation) {
  117428. var tempQuat = PhysicsImpostor._tmpQuat;
  117429. mesh.rotationQuaternion.multiplyToRef(adjustRotation, tempQuat);
  117430. bone.setRotationQuaternion(tempQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  117431. }
  117432. else {
  117433. bone.setRotationQuaternion(mesh.rotationQuaternion, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  117434. }
  117435. }
  117436. tempVec.x = 0;
  117437. tempVec.y = 0;
  117438. tempVec.z = 0;
  117439. if (jointPivot) {
  117440. tempVec.x = jointPivot.x;
  117441. tempVec.y = jointPivot.y;
  117442. tempVec.z = jointPivot.z;
  117443. bone.getDirectionToRef(tempVec, boneMesh, tempVec);
  117444. if (distToJoint === undefined || distToJoint === null) {
  117445. distToJoint = jointPivot.length();
  117446. }
  117447. tempVec.x *= distToJoint;
  117448. tempVec.y *= distToJoint;
  117449. tempVec.z *= distToJoint;
  117450. }
  117451. if (bone.getParent()) {
  117452. tempVec.addInPlace(mesh.getAbsolutePosition());
  117453. bone.setAbsolutePosition(tempVec, boneMesh);
  117454. }
  117455. else {
  117456. boneMesh.setAbsolutePosition(mesh.getAbsolutePosition());
  117457. boneMesh.position.x -= tempVec.x;
  117458. boneMesh.position.y -= tempVec.y;
  117459. boneMesh.position.z -= tempVec.z;
  117460. }
  117461. };
  117462. /**
  117463. * Sync impostor to a bone
  117464. * @param bone The bone that the impostor will be synced to.
  117465. * @param boneMesh The mesh that the bone is influencing.
  117466. * @param jointPivot The pivot of the joint / bone in local space.
  117467. * @param distToJoint Optional distance from the impostor to the joint.
  117468. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  117469. * @param boneAxis Optional vector3 axis the bone is aligned with
  117470. */
  117471. PhysicsImpostor.prototype.syncImpostorWithBone = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation, boneAxis) {
  117472. var mesh = this.object;
  117473. if (mesh.rotationQuaternion) {
  117474. if (adjustRotation) {
  117475. var tempQuat = PhysicsImpostor._tmpQuat;
  117476. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, tempQuat);
  117477. tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);
  117478. }
  117479. else {
  117480. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, mesh.rotationQuaternion);
  117481. }
  117482. }
  117483. var pos = PhysicsImpostor._tmpVecs[0];
  117484. var boneDir = PhysicsImpostor._tmpVecs[1];
  117485. if (!boneAxis) {
  117486. boneAxis = PhysicsImpostor._tmpVecs[2];
  117487. boneAxis.x = 0;
  117488. boneAxis.y = 1;
  117489. boneAxis.z = 0;
  117490. }
  117491. bone.getDirectionToRef(boneAxis, boneMesh, boneDir);
  117492. bone.getAbsolutePositionToRef(boneMesh, pos);
  117493. if ((distToJoint === undefined || distToJoint === null) && jointPivot) {
  117494. distToJoint = jointPivot.length();
  117495. }
  117496. if (distToJoint !== undefined && distToJoint !== null) {
  117497. pos.x += boneDir.x * distToJoint;
  117498. pos.y += boneDir.y * distToJoint;
  117499. pos.z += boneDir.z * distToJoint;
  117500. }
  117501. mesh.setAbsolutePosition(pos);
  117502. };
  117503. /**
  117504. * The default object size of the imposter
  117505. */
  117506. PhysicsImpostor.DEFAULT_OBJECT_SIZE = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  117507. /**
  117508. * The identity quaternion of the imposter
  117509. */
  117510. PhysicsImpostor.IDENTITY_QUATERNION = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  117511. PhysicsImpostor._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero);
  117512. PhysicsImpostor._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  117513. //Impostor types
  117514. /**
  117515. * No-Imposter type
  117516. */
  117517. PhysicsImpostor.NoImpostor = 0;
  117518. /**
  117519. * Sphere-Imposter type
  117520. */
  117521. PhysicsImpostor.SphereImpostor = 1;
  117522. /**
  117523. * Box-Imposter type
  117524. */
  117525. PhysicsImpostor.BoxImpostor = 2;
  117526. /**
  117527. * Plane-Imposter type
  117528. */
  117529. PhysicsImpostor.PlaneImpostor = 3;
  117530. /**
  117531. * Mesh-imposter type
  117532. */
  117533. PhysicsImpostor.MeshImpostor = 4;
  117534. /**
  117535. * Cylinder-Imposter type
  117536. */
  117537. PhysicsImpostor.CylinderImpostor = 7;
  117538. /**
  117539. * Particle-Imposter type
  117540. */
  117541. PhysicsImpostor.ParticleImpostor = 8;
  117542. /**
  117543. * Heightmap-Imposter type
  117544. */
  117545. PhysicsImpostor.HeightmapImpostor = 9;
  117546. /**
  117547. * ConvexHull-Impostor type (Ammo.js plugin only)
  117548. */
  117549. PhysicsImpostor.ConvexHullImpostor = 10;
  117550. /**
  117551. * Rope-Imposter type
  117552. */
  117553. PhysicsImpostor.RopeImpostor = 101;
  117554. /**
  117555. * Cloth-Imposter type
  117556. */
  117557. PhysicsImpostor.ClothImpostor = 102;
  117558. /**
  117559. * Softbody-Imposter type
  117560. */
  117561. PhysicsImpostor.SoftbodyImpostor = 103;
  117562. return PhysicsImpostor;
  117563. }());
  117564. /***/ }),
  117565. /***/ "./Physics/physicsJoint.ts":
  117566. /*!*********************************!*\
  117567. !*** ./Physics/physicsJoint.ts ***!
  117568. \*********************************/
  117569. /*! exports provided: PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint */
  117570. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117571. "use strict";
  117572. __webpack_require__.r(__webpack_exports__);
  117573. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return PhysicsJoint; });
  117574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return DistanceJoint; });
  117575. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return MotorEnabledJoint; });
  117576. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return HingeJoint; });
  117577. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return Hinge2Joint; });
  117578. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117579. /**
  117580. * This is a holder class for the physics joint created by the physics plugin
  117581. * It holds a set of functions to control the underlying joint
  117582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117583. */
  117584. var PhysicsJoint = /** @class */ (function () {
  117585. /**
  117586. * Initializes the physics joint
  117587. * @param type The type of the physics joint
  117588. * @param jointData The data for the physics joint
  117589. */
  117590. function PhysicsJoint(
  117591. /**
  117592. * The type of the physics joint
  117593. */
  117594. type,
  117595. /**
  117596. * The data for the physics joint
  117597. */
  117598. jointData) {
  117599. this.type = type;
  117600. this.jointData = jointData;
  117601. jointData.nativeParams = jointData.nativeParams || {};
  117602. }
  117603. Object.defineProperty(PhysicsJoint.prototype, "physicsJoint", {
  117604. /**
  117605. * Gets the physics joint
  117606. */
  117607. get: function () {
  117608. return this._physicsJoint;
  117609. },
  117610. /**
  117611. * Sets the physics joint
  117612. */
  117613. set: function (newJoint) {
  117614. if (this._physicsJoint) {
  117615. //remove from the wolrd
  117616. }
  117617. this._physicsJoint = newJoint;
  117618. },
  117619. enumerable: true,
  117620. configurable: true
  117621. });
  117622. Object.defineProperty(PhysicsJoint.prototype, "physicsPlugin", {
  117623. /**
  117624. * Sets the physics plugin
  117625. */
  117626. set: function (physicsPlugin) {
  117627. this._physicsPlugin = physicsPlugin;
  117628. },
  117629. enumerable: true,
  117630. configurable: true
  117631. });
  117632. /**
  117633. * Execute a function that is physics-plugin specific.
  117634. * @param {Function} func the function that will be executed.
  117635. * It accepts two parameters: the physics world and the physics joint
  117636. */
  117637. PhysicsJoint.prototype.executeNativeFunction = function (func) {
  117638. func(this._physicsPlugin.world, this._physicsJoint);
  117639. };
  117640. //TODO check if the native joints are the same
  117641. //Joint Types
  117642. /**
  117643. * Distance-Joint type
  117644. */
  117645. PhysicsJoint.DistanceJoint = 0;
  117646. /**
  117647. * Hinge-Joint type
  117648. */
  117649. PhysicsJoint.HingeJoint = 1;
  117650. /**
  117651. * Ball-and-Socket joint type
  117652. */
  117653. PhysicsJoint.BallAndSocketJoint = 2;
  117654. /**
  117655. * Wheel-Joint type
  117656. */
  117657. PhysicsJoint.WheelJoint = 3;
  117658. /**
  117659. * Slider-Joint type
  117660. */
  117661. PhysicsJoint.SliderJoint = 4;
  117662. //OIMO
  117663. /**
  117664. * Prismatic-Joint type
  117665. */
  117666. PhysicsJoint.PrismaticJoint = 5;
  117667. //
  117668. /**
  117669. * Universal-Joint type
  117670. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  117671. */
  117672. PhysicsJoint.UniversalJoint = 6;
  117673. /**
  117674. * Hinge-Joint 2 type
  117675. */
  117676. PhysicsJoint.Hinge2Joint = PhysicsJoint.WheelJoint;
  117677. //Cannon
  117678. /**
  117679. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  117680. */
  117681. PhysicsJoint.PointToPointJoint = 8;
  117682. //Cannon only at the moment
  117683. /**
  117684. * Spring-Joint type
  117685. */
  117686. PhysicsJoint.SpringJoint = 9;
  117687. /**
  117688. * Lock-Joint type
  117689. */
  117690. PhysicsJoint.LockJoint = 10;
  117691. return PhysicsJoint;
  117692. }());
  117693. /**
  117694. * A class representing a physics distance joint
  117695. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117696. */
  117697. var DistanceJoint = /** @class */ (function (_super) {
  117698. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DistanceJoint, _super);
  117699. /**
  117700. *
  117701. * @param jointData The data for the Distance-Joint
  117702. */
  117703. function DistanceJoint(jointData) {
  117704. return _super.call(this, PhysicsJoint.DistanceJoint, jointData) || this;
  117705. }
  117706. /**
  117707. * Update the predefined distance.
  117708. * @param maxDistance The maximum preferred distance
  117709. * @param minDistance The minimum preferred distance
  117710. */
  117711. DistanceJoint.prototype.updateDistance = function (maxDistance, minDistance) {
  117712. this._physicsPlugin.updateDistanceJoint(this, maxDistance, minDistance);
  117713. };
  117714. return DistanceJoint;
  117715. }(PhysicsJoint));
  117716. /**
  117717. * Represents a Motor-Enabled Joint
  117718. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117719. */
  117720. var MotorEnabledJoint = /** @class */ (function (_super) {
  117721. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotorEnabledJoint, _super);
  117722. /**
  117723. * Initializes the Motor-Enabled Joint
  117724. * @param type The type of the joint
  117725. * @param jointData The physica joint data for the joint
  117726. */
  117727. function MotorEnabledJoint(type, jointData) {
  117728. return _super.call(this, type, jointData) || this;
  117729. }
  117730. /**
  117731. * Set the motor values.
  117732. * Attention, this function is plugin specific. Engines won't react 100% the same.
  117733. * @param force the force to apply
  117734. * @param maxForce max force for this motor.
  117735. */
  117736. MotorEnabledJoint.prototype.setMotor = function (force, maxForce) {
  117737. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  117738. };
  117739. /**
  117740. * Set the motor's limits.
  117741. * Attention, this function is plugin specific. Engines won't react 100% the same.
  117742. * @param upperLimit The upper limit of the motor
  117743. * @param lowerLimit The lower limit of the motor
  117744. */
  117745. MotorEnabledJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  117746. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  117747. };
  117748. return MotorEnabledJoint;
  117749. }(PhysicsJoint));
  117750. /**
  117751. * This class represents a single physics Hinge-Joint
  117752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117753. */
  117754. var HingeJoint = /** @class */ (function (_super) {
  117755. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HingeJoint, _super);
  117756. /**
  117757. * Initializes the Hinge-Joint
  117758. * @param jointData The joint data for the Hinge-Joint
  117759. */
  117760. function HingeJoint(jointData) {
  117761. return _super.call(this, PhysicsJoint.HingeJoint, jointData) || this;
  117762. }
  117763. /**
  117764. * Set the motor values.
  117765. * Attention, this function is plugin specific. Engines won't react 100% the same.
  117766. * @param {number} force the force to apply
  117767. * @param {number} maxForce max force for this motor.
  117768. */
  117769. HingeJoint.prototype.setMotor = function (force, maxForce) {
  117770. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  117771. };
  117772. /**
  117773. * Set the motor's limits.
  117774. * Attention, this function is plugin specific. Engines won't react 100% the same.
  117775. * @param upperLimit The upper limit of the motor
  117776. * @param lowerLimit The lower limit of the motor
  117777. */
  117778. HingeJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  117779. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  117780. };
  117781. return HingeJoint;
  117782. }(MotorEnabledJoint));
  117783. /**
  117784. * This class represents a dual hinge physics joint (same as wheel joint)
  117785. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117786. */
  117787. var Hinge2Joint = /** @class */ (function (_super) {
  117788. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Hinge2Joint, _super);
  117789. /**
  117790. * Initializes the Hinge2-Joint
  117791. * @param jointData The joint data for the Hinge2-Joint
  117792. */
  117793. function Hinge2Joint(jointData) {
  117794. return _super.call(this, PhysicsJoint.Hinge2Joint, jointData) || this;
  117795. }
  117796. /**
  117797. * Set the motor values.
  117798. * Attention, this function is plugin specific. Engines won't react 100% the same.
  117799. * @param {number} targetSpeed the speed the motor is to reach
  117800. * @param {number} maxForce max force for this motor.
  117801. * @param {motorIndex} the motor's index, 0 or 1.
  117802. */
  117803. Hinge2Joint.prototype.setMotor = function (targetSpeed, maxForce, motorIndex) {
  117804. if (motorIndex === void 0) { motorIndex = 0; }
  117805. this._physicsPlugin.setMotor(this, targetSpeed || 0, maxForce, motorIndex);
  117806. };
  117807. /**
  117808. * Set the motor limits.
  117809. * Attention, this function is plugin specific. Engines won't react 100% the same.
  117810. * @param {number} upperLimit the upper limit
  117811. * @param {number} lowerLimit lower limit
  117812. * @param {motorIndex} the motor's index, 0 or 1.
  117813. */
  117814. Hinge2Joint.prototype.setLimit = function (upperLimit, lowerLimit, motorIndex) {
  117815. if (motorIndex === void 0) { motorIndex = 0; }
  117816. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit, motorIndex);
  117817. };
  117818. return Hinge2Joint;
  117819. }(MotorEnabledJoint));
  117820. /***/ }),
  117821. /***/ "./Physics/physicsRaycastResult.ts":
  117822. /*!*****************************************!*\
  117823. !*** ./Physics/physicsRaycastResult.ts ***!
  117824. \*****************************************/
  117825. /*! exports provided: PhysicsRaycastResult */
  117826. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117827. "use strict";
  117828. __webpack_require__.r(__webpack_exports__);
  117829. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRaycastResult", function() { return PhysicsRaycastResult; });
  117830. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  117831. /**
  117832. * Holds the data for the raycast result
  117833. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117834. */
  117835. var PhysicsRaycastResult = /** @class */ (function () {
  117836. function PhysicsRaycastResult() {
  117837. this._hasHit = false;
  117838. this._hitDistance = 0;
  117839. this._hitNormalWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  117840. this._hitPointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  117841. this._rayFromWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  117842. this._rayToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  117843. }
  117844. Object.defineProperty(PhysicsRaycastResult.prototype, "hasHit", {
  117845. /**
  117846. * Gets if there was a hit
  117847. */
  117848. get: function () {
  117849. return this._hasHit;
  117850. },
  117851. enumerable: true,
  117852. configurable: true
  117853. });
  117854. Object.defineProperty(PhysicsRaycastResult.prototype, "hitDistance", {
  117855. /**
  117856. * Gets the distance from the hit
  117857. */
  117858. get: function () {
  117859. return this._hitDistance;
  117860. },
  117861. enumerable: true,
  117862. configurable: true
  117863. });
  117864. Object.defineProperty(PhysicsRaycastResult.prototype, "hitNormalWorld", {
  117865. /**
  117866. * Gets the hit normal/direction in the world
  117867. */
  117868. get: function () {
  117869. return this._hitNormalWorld;
  117870. },
  117871. enumerable: true,
  117872. configurable: true
  117873. });
  117874. Object.defineProperty(PhysicsRaycastResult.prototype, "hitPointWorld", {
  117875. /**
  117876. * Gets the hit point in the world
  117877. */
  117878. get: function () {
  117879. return this._hitPointWorld;
  117880. },
  117881. enumerable: true,
  117882. configurable: true
  117883. });
  117884. Object.defineProperty(PhysicsRaycastResult.prototype, "rayFromWorld", {
  117885. /**
  117886. * Gets the ray "start point" of the ray in the world
  117887. */
  117888. get: function () {
  117889. return this._rayFromWorld;
  117890. },
  117891. enumerable: true,
  117892. configurable: true
  117893. });
  117894. Object.defineProperty(PhysicsRaycastResult.prototype, "rayToWorld", {
  117895. /**
  117896. * Gets the ray "end point" of the ray in the world
  117897. */
  117898. get: function () {
  117899. return this._rayToWorld;
  117900. },
  117901. enumerable: true,
  117902. configurable: true
  117903. });
  117904. /**
  117905. * Sets the hit data (normal & point in world space)
  117906. * @param hitNormalWorld defines the normal in world space
  117907. * @param hitPointWorld defines the point in world space
  117908. */
  117909. PhysicsRaycastResult.prototype.setHitData = function (hitNormalWorld, hitPointWorld) {
  117910. this._hasHit = true;
  117911. this._hitNormalWorld = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](hitNormalWorld.x, hitNormalWorld.y, hitNormalWorld.z);
  117912. this._hitPointWorld = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](hitPointWorld.x, hitPointWorld.y, hitPointWorld.z);
  117913. };
  117914. /**
  117915. * Sets the distance from the start point to the hit point
  117916. * @param distance
  117917. */
  117918. PhysicsRaycastResult.prototype.setHitDistance = function (distance) {
  117919. this._hitDistance = distance;
  117920. };
  117921. /**
  117922. * Calculates the distance manually
  117923. */
  117924. PhysicsRaycastResult.prototype.calculateHitDistance = function () {
  117925. this._hitDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(this._rayFromWorld, this._hitPointWorld);
  117926. };
  117927. /**
  117928. * Resets all the values to default
  117929. * @param from The from point on world space
  117930. * @param to The to point on world space
  117931. */
  117932. PhysicsRaycastResult.prototype.reset = function (from, to) {
  117933. if (from === void 0) { from = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(); }
  117934. if (to === void 0) { to = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(); }
  117935. this._rayFromWorld = from;
  117936. this._rayToWorld = to;
  117937. this._hasHit = false;
  117938. this._hitDistance = 0;
  117939. this._hitNormalWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  117940. this._hitPointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  117941. };
  117942. return PhysicsRaycastResult;
  117943. }());
  117944. /***/ }),
  117945. /***/ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts":
  117946. /*!****************************************************************************!*\
  117947. !*** ./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts ***!
  117948. \****************************************************************************/
  117949. /*! exports provided: DefaultRenderingPipeline */
  117950. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117951. "use strict";
  117952. __webpack_require__.r(__webpack_exports__);
  117953. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return DefaultRenderingPipeline; });
  117954. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117955. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  117956. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  117957. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  117958. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  117959. /* harmony import */ var _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Layers/glowLayer */ "./Layers/glowLayer.ts");
  117960. /* harmony import */ var _PostProcesses_sharpenPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  117961. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  117962. /* harmony import */ var _PostProcesses_chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  117963. /* harmony import */ var _PostProcesses_grainPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  117964. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  117965. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  117966. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  117967. /* harmony import */ var _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../PostProcesses/depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  117968. /* harmony import */ var _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../../PostProcesses/bloomEffect */ "./PostProcesses/bloomEffect.ts");
  117969. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  117970. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  117971. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  117972. /**
  117973. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  117974. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  117975. */
  117976. var DefaultRenderingPipeline = /** @class */ (function (_super) {
  117977. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DefaultRenderingPipeline, _super);
  117978. /**
  117979. * @constructor
  117980. * @param name - The rendering pipeline name (default: "")
  117981. * @param hdr - If high dynamic range textures should be used (default: true)
  117982. * @param scene - The scene linked to this pipeline (default: the last created scene)
  117983. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  117984. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  117985. */
  117986. function DefaultRenderingPipeline(name, hdr, scene, cameras, automaticBuild) {
  117987. if (name === void 0) { name = ""; }
  117988. if (hdr === void 0) { hdr = true; }
  117989. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene; }
  117990. if (automaticBuild === void 0) { automaticBuild = true; }
  117991. var _this = _super.call(this, scene.getEngine(), name) || this;
  117992. _this._camerasToBeAttached = [];
  117993. /**
  117994. * ID of the sharpen post process,
  117995. */
  117996. _this.SharpenPostProcessId = "SharpenPostProcessEffect";
  117997. /**
  117998. * @ignore
  117999. * ID of the image processing post process;
  118000. */
  118001. _this.ImageProcessingPostProcessId = "ImageProcessingPostProcessEffect";
  118002. /**
  118003. * @ignore
  118004. * ID of the Fast Approximate Anti-Aliasing post process;
  118005. */
  118006. _this.FxaaPostProcessId = "FxaaPostProcessEffect";
  118007. /**
  118008. * ID of the chromatic aberration post process,
  118009. */
  118010. _this.ChromaticAberrationPostProcessId = "ChromaticAberrationPostProcessEffect";
  118011. /**
  118012. * ID of the grain post process
  118013. */
  118014. _this.GrainPostProcessId = "GrainPostProcessEffect";
  118015. /**
  118016. * Glow post process which adds a glow to emissive areas of the image
  118017. */
  118018. _this._glowLayer = null;
  118019. /**
  118020. * Animations which can be used to tweak settings over a period of time
  118021. */
  118022. _this.animations = [];
  118023. _this._imageProcessingConfigurationObserver = null;
  118024. // Values
  118025. _this._sharpenEnabled = false;
  118026. _this._bloomEnabled = false;
  118027. _this._depthOfFieldEnabled = false;
  118028. _this._depthOfFieldBlurLevel = _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffectBlurLevel"].Low;
  118029. _this._fxaaEnabled = false;
  118030. _this._imageProcessingEnabled = true;
  118031. _this._bloomScale = 0.5;
  118032. _this._chromaticAberrationEnabled = false;
  118033. _this._grainEnabled = false;
  118034. _this._buildAllowed = true;
  118035. _this._resizeObserver = null;
  118036. _this._hardwareScaleLevel = 1.0;
  118037. _this._bloomKernel = 64;
  118038. /**
  118039. * Specifies the weight of the bloom in the final rendering
  118040. */
  118041. _this._bloomWeight = 0.15;
  118042. /**
  118043. * Specifies the luma threshold for the area that will be blurred by the bloom
  118044. */
  118045. _this._bloomThreshold = 0.9;
  118046. _this._samples = 1;
  118047. _this._hasCleared = false;
  118048. _this._prevPostProcess = null;
  118049. _this._prevPrevPostProcess = null;
  118050. _this._depthOfFieldSceneObserver = null;
  118051. _this._cameras = cameras || scene.cameras;
  118052. _this._cameras = _this._cameras.slice();
  118053. _this._camerasToBeAttached = _this._cameras.slice();
  118054. _this._buildAllowed = automaticBuild;
  118055. // Initialize
  118056. _this._scene = scene;
  118057. var caps = _this._scene.getEngine().getCaps();
  118058. _this._hdr = hdr && (caps.textureHalfFloatRender || caps.textureFloatRender);
  118059. // Misc
  118060. if (_this._hdr) {
  118061. if (caps.textureHalfFloatRender) {
  118062. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_HALF_FLOAT;
  118063. }
  118064. else if (caps.textureFloatRender) {
  118065. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_FLOAT;
  118066. }
  118067. }
  118068. else {
  118069. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  118070. }
  118071. // Attach
  118072. scene.postProcessRenderPipelineManager.addPipeline(_this);
  118073. var engine = _this._scene.getEngine();
  118074. // Create post processes before hand so they can be modified before enabled.
  118075. // Block compilation flag is set to true to avoid compilation prior to use, these will be updated on first use in build pipeline.
  118076. _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);
  118077. _this._sharpenEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.SharpenPostProcessId, function () { return _this.sharpen; }, true);
  118078. _this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](_this._scene, null, _this._depthOfFieldBlurLevel, _this._defaultPipelineTextureType, true);
  118079. _this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](_this._scene, _this._bloomScale, _this._bloomWeight, _this.bloomKernel, _this._defaultPipelineTextureType, true);
  118080. _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);
  118081. _this._chromaticAberrationEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.ChromaticAberrationPostProcessId, function () { return _this.chromaticAberration; }, true);
  118082. _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);
  118083. _this._grainEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.GrainPostProcessId, function () { return _this.grain; }, true);
  118084. _this._resizeObserver = engine.onResizeObservable.add(function () {
  118085. _this._hardwareScaleLevel = engine.getHardwareScalingLevel();
  118086. _this.bloomKernel = _this.bloomKernel;
  118087. });
  118088. _this._imageProcessingConfigurationObserver = _this._scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  118089. _this.bloom._downscale._exposure = _this._scene.imageProcessingConfiguration.exposure;
  118090. });
  118091. _this._buildPipeline();
  118092. return _this;
  118093. }
  118094. Object.defineProperty(DefaultRenderingPipeline.prototype, "scene", {
  118095. /**
  118096. * Gets active scene
  118097. */
  118098. get: function () {
  118099. return this._scene;
  118100. },
  118101. enumerable: true,
  118102. configurable: true
  118103. });
  118104. Object.defineProperty(DefaultRenderingPipeline.prototype, "sharpenEnabled", {
  118105. get: function () {
  118106. return this._sharpenEnabled;
  118107. },
  118108. /**
  118109. * Enable or disable the sharpen process from the pipeline
  118110. */
  118111. set: function (enabled) {
  118112. if (this._sharpenEnabled === enabled) {
  118113. return;
  118114. }
  118115. this._sharpenEnabled = enabled;
  118116. this._buildPipeline();
  118117. },
  118118. enumerable: true,
  118119. configurable: true
  118120. });
  118121. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomKernel", {
  118122. /**
  118123. * Specifies the size of the bloom blur kernel, relative to the final output size
  118124. */
  118125. get: function () {
  118126. return this._bloomKernel;
  118127. },
  118128. set: function (value) {
  118129. this._bloomKernel = value;
  118130. this.bloom.kernel = value / this._hardwareScaleLevel;
  118131. },
  118132. enumerable: true,
  118133. configurable: true
  118134. });
  118135. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomWeight", {
  118136. get: function () {
  118137. return this._bloomWeight;
  118138. },
  118139. /**
  118140. * The strength of the bloom.
  118141. */
  118142. set: function (value) {
  118143. if (this._bloomWeight === value) {
  118144. return;
  118145. }
  118146. this.bloom.weight = value;
  118147. this._bloomWeight = value;
  118148. },
  118149. enumerable: true,
  118150. configurable: true
  118151. });
  118152. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomThreshold", {
  118153. get: function () {
  118154. return this._bloomThreshold;
  118155. },
  118156. /**
  118157. * The strength of the bloom.
  118158. */
  118159. set: function (value) {
  118160. if (this._bloomThreshold === value) {
  118161. return;
  118162. }
  118163. this.bloom.threshold = value;
  118164. this._bloomThreshold = value;
  118165. },
  118166. enumerable: true,
  118167. configurable: true
  118168. });
  118169. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomScale", {
  118170. get: function () {
  118171. return this._bloomScale;
  118172. },
  118173. /**
  118174. * The scale of the bloom, lower value will provide better performance.
  118175. */
  118176. set: function (value) {
  118177. if (this._bloomScale === value) {
  118178. return;
  118179. }
  118180. this._bloomScale = value;
  118181. // recreate bloom and dispose old as this setting is not dynamic
  118182. this._rebuildBloom();
  118183. this._buildPipeline();
  118184. },
  118185. enumerable: true,
  118186. configurable: true
  118187. });
  118188. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomEnabled", {
  118189. get: function () {
  118190. return this._bloomEnabled;
  118191. },
  118192. /**
  118193. * Enable or disable the bloom from the pipeline
  118194. */
  118195. set: function (enabled) {
  118196. if (this._bloomEnabled === enabled) {
  118197. return;
  118198. }
  118199. this._bloomEnabled = enabled;
  118200. this._buildPipeline();
  118201. },
  118202. enumerable: true,
  118203. configurable: true
  118204. });
  118205. DefaultRenderingPipeline.prototype._rebuildBloom = function () {
  118206. // recreate bloom and dispose old as this setting is not dynamic
  118207. var oldBloom = this.bloom;
  118208. this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](this._scene, this.bloomScale, this._bloomWeight, this.bloomKernel, this._defaultPipelineTextureType, false);
  118209. this.bloom.threshold = oldBloom.threshold;
  118210. for (var i = 0; i < this._cameras.length; i++) {
  118211. oldBloom.disposeEffects(this._cameras[i]);
  118212. }
  118213. };
  118214. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", {
  118215. /**
  118216. * If the depth of field is enabled.
  118217. */
  118218. get: function () {
  118219. return this._depthOfFieldEnabled;
  118220. },
  118221. set: function (enabled) {
  118222. if (this._depthOfFieldEnabled === enabled) {
  118223. return;
  118224. }
  118225. this._depthOfFieldEnabled = enabled;
  118226. this._buildPipeline();
  118227. },
  118228. enumerable: true,
  118229. configurable: true
  118230. });
  118231. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", {
  118232. /**
  118233. * Blur level of the depth of field effect. (Higher blur will effect performance)
  118234. */
  118235. get: function () {
  118236. return this._depthOfFieldBlurLevel;
  118237. },
  118238. set: function (value) {
  118239. if (this._depthOfFieldBlurLevel === value) {
  118240. return;
  118241. }
  118242. this._depthOfFieldBlurLevel = value;
  118243. // recreate dof and dispose old as this setting is not dynamic
  118244. var oldDof = this.depthOfField;
  118245. this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](this._scene, null, this._depthOfFieldBlurLevel, this._defaultPipelineTextureType, false);
  118246. this.depthOfField.focalLength = oldDof.focalLength;
  118247. this.depthOfField.focusDistance = oldDof.focusDistance;
  118248. this.depthOfField.fStop = oldDof.fStop;
  118249. this.depthOfField.lensSize = oldDof.lensSize;
  118250. for (var i = 0; i < this._cameras.length; i++) {
  118251. oldDof.disposeEffects(this._cameras[i]);
  118252. }
  118253. this._buildPipeline();
  118254. },
  118255. enumerable: true,
  118256. configurable: true
  118257. });
  118258. Object.defineProperty(DefaultRenderingPipeline.prototype, "fxaaEnabled", {
  118259. get: function () {
  118260. return this._fxaaEnabled;
  118261. },
  118262. /**
  118263. * If the anti aliasing is enabled.
  118264. */
  118265. set: function (enabled) {
  118266. if (this._fxaaEnabled === enabled) {
  118267. return;
  118268. }
  118269. this._fxaaEnabled = enabled;
  118270. this._buildPipeline();
  118271. },
  118272. enumerable: true,
  118273. configurable: true
  118274. });
  118275. Object.defineProperty(DefaultRenderingPipeline.prototype, "samples", {
  118276. get: function () {
  118277. return this._samples;
  118278. },
  118279. /**
  118280. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  118281. */
  118282. set: function (sampleCount) {
  118283. if (this._samples === sampleCount) {
  118284. return;
  118285. }
  118286. this._samples = sampleCount;
  118287. this._buildPipeline();
  118288. },
  118289. enumerable: true,
  118290. configurable: true
  118291. });
  118292. Object.defineProperty(DefaultRenderingPipeline.prototype, "imageProcessingEnabled", {
  118293. get: function () {
  118294. return this._imageProcessingEnabled;
  118295. },
  118296. /**
  118297. * If image processing is enabled.
  118298. */
  118299. set: function (enabled) {
  118300. if (this._imageProcessingEnabled === enabled) {
  118301. return;
  118302. }
  118303. this._imageProcessingEnabled = enabled;
  118304. this._buildPipeline();
  118305. },
  118306. enumerable: true,
  118307. configurable: true
  118308. });
  118309. Object.defineProperty(DefaultRenderingPipeline.prototype, "glowLayerEnabled", {
  118310. get: function () {
  118311. return this._glowLayer != null;
  118312. },
  118313. /**
  118314. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  118315. */
  118316. set: function (enabled) {
  118317. if (enabled && !this._glowLayer) {
  118318. this._glowLayer = new _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__["GlowLayer"]("", this._scene);
  118319. }
  118320. else if (!enabled && this._glowLayer) {
  118321. this._glowLayer.dispose();
  118322. this._glowLayer = null;
  118323. }
  118324. },
  118325. enumerable: true,
  118326. configurable: true
  118327. });
  118328. Object.defineProperty(DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", {
  118329. get: function () {
  118330. return this._chromaticAberrationEnabled;
  118331. },
  118332. /**
  118333. * Enable or disable the chromaticAberration process from the pipeline
  118334. */
  118335. set: function (enabled) {
  118336. if (this._chromaticAberrationEnabled === enabled) {
  118337. return;
  118338. }
  118339. this._chromaticAberrationEnabled = enabled;
  118340. this._buildPipeline();
  118341. },
  118342. enumerable: true,
  118343. configurable: true
  118344. });
  118345. Object.defineProperty(DefaultRenderingPipeline.prototype, "grainEnabled", {
  118346. get: function () {
  118347. return this._grainEnabled;
  118348. },
  118349. /**
  118350. * Enable or disable the grain process from the pipeline
  118351. */
  118352. set: function (enabled) {
  118353. if (this._grainEnabled === enabled) {
  118354. return;
  118355. }
  118356. this._grainEnabled = enabled;
  118357. this._buildPipeline();
  118358. },
  118359. enumerable: true,
  118360. configurable: true
  118361. });
  118362. /**
  118363. * Get the class name
  118364. * @returns "DefaultRenderingPipeline"
  118365. */
  118366. DefaultRenderingPipeline.prototype.getClassName = function () {
  118367. return "DefaultRenderingPipeline";
  118368. };
  118369. /**
  118370. * Force the compilation of the entire pipeline.
  118371. */
  118372. DefaultRenderingPipeline.prototype.prepare = function () {
  118373. var previousState = this._buildAllowed;
  118374. this._buildAllowed = true;
  118375. this._buildPipeline();
  118376. this._buildAllowed = previousState;
  118377. };
  118378. DefaultRenderingPipeline.prototype._setAutoClearAndTextureSharing = function (postProcess, skipTextureSharing) {
  118379. if (skipTextureSharing === void 0) { skipTextureSharing = false; }
  118380. if (this._hasCleared) {
  118381. postProcess.autoClear = false;
  118382. }
  118383. else {
  118384. postProcess.autoClear = true;
  118385. this._scene.autoClear = false;
  118386. this._hasCleared = true;
  118387. }
  118388. if (!skipTextureSharing) {
  118389. if (this._prevPrevPostProcess) {
  118390. postProcess.shareOutputWith(this._prevPrevPostProcess);
  118391. }
  118392. else {
  118393. postProcess.useOwnOutput();
  118394. }
  118395. if (this._prevPostProcess) {
  118396. this._prevPrevPostProcess = this._prevPostProcess;
  118397. }
  118398. this._prevPostProcess = postProcess;
  118399. }
  118400. };
  118401. DefaultRenderingPipeline.prototype._buildPipeline = function () {
  118402. var _this = this;
  118403. if (!this._buildAllowed) {
  118404. return;
  118405. }
  118406. this._scene.autoClear = true;
  118407. var engine = this._scene.getEngine();
  118408. this._disposePostProcesses();
  118409. if (this._cameras !== null) {
  118410. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  118411. // get back cameras to be used to reattach pipeline
  118412. this._cameras = this._camerasToBeAttached.slice();
  118413. }
  118414. this._reset();
  118415. this._prevPostProcess = null;
  118416. this._prevPrevPostProcess = null;
  118417. this._hasCleared = false;
  118418. if (this.depthOfFieldEnabled) {
  118419. // Multi camera suport
  118420. if (this._cameras.length > 1) {
  118421. for (var _i = 0, _a = this._cameras; _i < _a.length; _i++) {
  118422. var camera = _a[_i];
  118423. var depthRenderer = this._scene.enableDepthRenderer(camera);
  118424. depthRenderer.useOnlyInActiveCamera = true;
  118425. }
  118426. this._depthOfFieldSceneObserver = this._scene.onAfterRenderTargetsRenderObservable.add(function (scene) {
  118427. if (_this._cameras.indexOf(scene.activeCamera) > -1) {
  118428. _this.depthOfField.depthTexture = scene.enableDepthRenderer(scene.activeCamera).getDepthMap();
  118429. }
  118430. });
  118431. }
  118432. else {
  118433. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  118434. var depthRenderer = this._scene.enableDepthRenderer(this._cameras[0]);
  118435. this.depthOfField.depthTexture = depthRenderer.getDepthMap();
  118436. }
  118437. if (!this.depthOfField._isReady()) {
  118438. this.depthOfField._updateEffects();
  118439. }
  118440. this.addEffect(this.depthOfField);
  118441. this._setAutoClearAndTextureSharing(this.depthOfField._effects[0], true);
  118442. }
  118443. else {
  118444. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  118445. }
  118446. if (this.bloomEnabled) {
  118447. if (!this.bloom._isReady()) {
  118448. this.bloom._updateEffects();
  118449. }
  118450. this.addEffect(this.bloom);
  118451. this._setAutoClearAndTextureSharing(this.bloom._effects[0], true);
  118452. }
  118453. if (this._imageProcessingEnabled) {
  118454. 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);
  118455. if (this._hdr) {
  118456. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.ImageProcessingPostProcessId, function () { return _this.imageProcessing; }, true));
  118457. this._setAutoClearAndTextureSharing(this.imageProcessing);
  118458. }
  118459. else {
  118460. this._scene.imageProcessingConfiguration.applyByPostProcess = false;
  118461. }
  118462. }
  118463. if (this.sharpenEnabled) {
  118464. if (!this.sharpen.isReady()) {
  118465. this.sharpen.updateEffect();
  118466. }
  118467. this.addEffect(this._sharpenEffect);
  118468. this._setAutoClearAndTextureSharing(this.sharpen);
  118469. }
  118470. if (this.grainEnabled) {
  118471. if (!this.grain.isReady()) {
  118472. this.grain.updateEffect();
  118473. }
  118474. this.addEffect(this._grainEffect);
  118475. this._setAutoClearAndTextureSharing(this.grain);
  118476. }
  118477. if (this.chromaticAberrationEnabled) {
  118478. if (!this.chromaticAberration.isReady()) {
  118479. this.chromaticAberration.updateEffect();
  118480. }
  118481. this.addEffect(this._chromaticAberrationEffect);
  118482. this._setAutoClearAndTextureSharing(this.chromaticAberration);
  118483. }
  118484. if (this.fxaaEnabled) {
  118485. 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);
  118486. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.FxaaPostProcessId, function () { return _this.fxaa; }, true));
  118487. this._setAutoClearAndTextureSharing(this.fxaa, true);
  118488. }
  118489. if (this._cameras !== null) {
  118490. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  118491. }
  118492. if (!this._enableMSAAOnFirstPostProcess(this.samples) && this.samples > 1) {
  118493. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  118494. }
  118495. };
  118496. DefaultRenderingPipeline.prototype._disposePostProcesses = function (disposeNonRecreated) {
  118497. if (disposeNonRecreated === void 0) { disposeNonRecreated = false; }
  118498. for (var i = 0; i < this._cameras.length; i++) {
  118499. var camera = this._cameras[i];
  118500. if (this.imageProcessing) {
  118501. this.imageProcessing.dispose(camera);
  118502. }
  118503. if (this.fxaa) {
  118504. this.fxaa.dispose(camera);
  118505. }
  118506. // These are created in the constructor and should not be disposed on every pipeline change
  118507. if (disposeNonRecreated) {
  118508. if (this.sharpen) {
  118509. this.sharpen.dispose(camera);
  118510. }
  118511. if (this.depthOfField) {
  118512. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  118513. this.depthOfField.disposeEffects(camera);
  118514. }
  118515. if (this.bloom) {
  118516. this.bloom.disposeEffects(camera);
  118517. }
  118518. if (this.chromaticAberration) {
  118519. this.chromaticAberration.dispose(camera);
  118520. }
  118521. if (this.grain) {
  118522. this.grain.dispose(camera);
  118523. }
  118524. if (this._glowLayer) {
  118525. this._glowLayer.dispose();
  118526. }
  118527. }
  118528. }
  118529. this.imageProcessing = null;
  118530. this.fxaa = null;
  118531. if (disposeNonRecreated) {
  118532. this.sharpen = null;
  118533. this._sharpenEffect = null;
  118534. this.depthOfField = null;
  118535. this.bloom = null;
  118536. this.chromaticAberration = null;
  118537. this._chromaticAberrationEffect = null;
  118538. this.grain = null;
  118539. this._grainEffect = null;
  118540. this._glowLayer = null;
  118541. }
  118542. };
  118543. /**
  118544. * Adds a camera to the pipeline
  118545. * @param camera the camera to be added
  118546. */
  118547. DefaultRenderingPipeline.prototype.addCamera = function (camera) {
  118548. this._camerasToBeAttached.push(camera);
  118549. this._buildPipeline();
  118550. };
  118551. /**
  118552. * Removes a camera from the pipeline
  118553. * @param camera the camera to remove
  118554. */
  118555. DefaultRenderingPipeline.prototype.removeCamera = function (camera) {
  118556. var index = this._camerasToBeAttached.indexOf(camera);
  118557. this._camerasToBeAttached.splice(index, 1);
  118558. this._buildPipeline();
  118559. };
  118560. /**
  118561. * Dispose of the pipeline and stop all post processes
  118562. */
  118563. DefaultRenderingPipeline.prototype.dispose = function () {
  118564. this._disposePostProcesses(true);
  118565. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  118566. this._scene.autoClear = true;
  118567. if (this._resizeObserver) {
  118568. this._scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  118569. this._resizeObserver = null;
  118570. }
  118571. this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver);
  118572. _super.prototype.dispose.call(this);
  118573. };
  118574. /**
  118575. * Serialize the rendering pipeline (Used when exporting)
  118576. * @returns the serialized object
  118577. */
  118578. DefaultRenderingPipeline.prototype.serialize = function () {
  118579. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  118580. serializationObject.customType = "DefaultRenderingPipeline";
  118581. return serializationObject;
  118582. };
  118583. /**
  118584. * Parse the serialized pipeline
  118585. * @param source Source pipeline.
  118586. * @param scene The scene to load the pipeline to.
  118587. * @param rootUrl The URL of the serialized pipeline.
  118588. * @returns An instantiated pipeline from the serialized object.
  118589. */
  118590. DefaultRenderingPipeline.Parse = function (source, scene, rootUrl) {
  118591. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new DefaultRenderingPipeline(source._name, source._name._hdr, scene); }, source, scene, rootUrl);
  118592. };
  118593. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118594. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118595. ], DefaultRenderingPipeline.prototype, "sharpenEnabled", null);
  118596. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118597. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118598. ], DefaultRenderingPipeline.prototype, "bloomKernel", null);
  118599. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118600. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118601. ], DefaultRenderingPipeline.prototype, "_bloomWeight", void 0);
  118602. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118603. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118604. ], DefaultRenderingPipeline.prototype, "_bloomThreshold", void 0);
  118605. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118606. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118607. ], DefaultRenderingPipeline.prototype, "_hdr", void 0);
  118608. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118609. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118610. ], DefaultRenderingPipeline.prototype, "bloomWeight", null);
  118611. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118612. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118613. ], DefaultRenderingPipeline.prototype, "bloomThreshold", null);
  118614. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118615. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118616. ], DefaultRenderingPipeline.prototype, "bloomScale", null);
  118617. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118618. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118619. ], DefaultRenderingPipeline.prototype, "bloomEnabled", null);
  118620. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118621. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118622. ], DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", null);
  118623. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118624. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118625. ], DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", null);
  118626. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118627. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118628. ], DefaultRenderingPipeline.prototype, "fxaaEnabled", null);
  118629. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118630. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118631. ], DefaultRenderingPipeline.prototype, "samples", null);
  118632. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118633. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118634. ], DefaultRenderingPipeline.prototype, "imageProcessingEnabled", null);
  118635. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118636. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118637. ], DefaultRenderingPipeline.prototype, "glowLayerEnabled", null);
  118638. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118639. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118640. ], DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", null);
  118641. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118642. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118643. ], DefaultRenderingPipeline.prototype, "grainEnabled", null);
  118644. return DefaultRenderingPipeline;
  118645. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__["PostProcessRenderPipeline"]));
  118646. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__["_TypeStore"].RegisteredTypes["BABYLON.DefaultRenderingPipeline"] = DefaultRenderingPipeline;
  118647. /***/ }),
  118648. /***/ "./PostProcesses/RenderPipeline/Pipelines/index.ts":
  118649. /*!*********************************************************!*\
  118650. !*** ./PostProcesses/RenderPipeline/Pipelines/index.ts ***!
  118651. \*********************************************************/
  118652. /*! exports provided: DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  118653. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118654. "use strict";
  118655. __webpack_require__.r(__webpack_exports__);
  118656. /* harmony import */ var _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts");
  118657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  118658. /* harmony import */ var _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts");
  118659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__["LensRenderingPipeline"]; });
  118660. /* harmony import */ var _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ssao2RenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts");
  118661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__["SSAO2RenderingPipeline"]; });
  118662. /* harmony import */ var _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ssaoRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts");
  118663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__["SSAORenderingPipeline"]; });
  118664. /* harmony import */ var _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./standardRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts");
  118665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__["StandardRenderingPipeline"]; });
  118666. /***/ }),
  118667. /***/ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts":
  118668. /*!*************************************************************************!*\
  118669. !*** ./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts ***!
  118670. \*************************************************************************/
  118671. /*! exports provided: LensRenderingPipeline */
  118672. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118673. "use strict";
  118674. __webpack_require__.r(__webpack_exports__);
  118675. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return LensRenderingPipeline; });
  118676. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118677. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  118678. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  118679. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  118680. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  118681. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  118682. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  118683. /* harmony import */ var _Shaders_lensHighlights_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Shaders/lensHighlights.fragment */ "./Shaders/lensHighlights.fragment.ts");
  118684. /* harmony import */ var _Shaders_depthOfField_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../Shaders/depthOfField.fragment */ "./Shaders/depthOfField.fragment.ts");
  118685. /**
  118686. * BABYLON.JS Chromatic Aberration GLSL Shader
  118687. * Author: Olivier Guyot
  118688. * Separates very slightly R, G and B colors on the edges of the screen
  118689. * Inspired by Francois Tarlier & Martins Upitis
  118690. */
  118691. var LensRenderingPipeline = /** @class */ (function (_super) {
  118692. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensRenderingPipeline, _super);
  118693. /**
  118694. * @constructor
  118695. *
  118696. * Effect parameters are as follow:
  118697. * {
  118698. * chromatic_aberration: number; // from 0 to x (1 for realism)
  118699. * edge_blur: number; // from 0 to x (1 for realism)
  118700. * distortion: number; // from 0 to x (1 for realism)
  118701. * grain_amount: number; // from 0 to 1
  118702. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  118703. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  118704. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  118705. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  118706. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  118707. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  118708. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  118709. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  118710. * }
  118711. * Note: if an effect parameter is unset, effect is disabled
  118712. *
  118713. * @param name The rendering pipeline name
  118714. * @param parameters - An object containing all parameters (see above)
  118715. * @param scene The scene linked to this pipeline
  118716. * @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)
  118717. * @param cameras The array of cameras that the rendering pipeline will be attached to
  118718. */
  118719. function LensRenderingPipeline(name, parameters, scene, ratio, cameras) {
  118720. if (ratio === void 0) { ratio = 1.0; }
  118721. var _this = _super.call(this, scene.getEngine(), name) || this;
  118722. // Lens effects can be of the following:
  118723. // - chromatic aberration (slight shift of RGB colors)
  118724. // - blur on the edge of the lens
  118725. // - lens distortion
  118726. // - depth-of-field blur & highlights enhancing
  118727. // - depth-of-field 'bokeh' effect (shapes appearing in blurred areas)
  118728. // - grain effect (noise or custom texture)
  118729. // Two additional texture samplers are needed:
  118730. // - depth map (for depth-of-field)
  118731. // - grain texture
  118732. /**
  118733. * @ignore
  118734. * The chromatic aberration PostProcess id in the pipeline
  118735. */
  118736. _this.LensChromaticAberrationEffect = "LensChromaticAberrationEffect";
  118737. /**
  118738. * @ignore
  118739. * The highlights enhancing PostProcess id in the pipeline
  118740. */
  118741. _this.HighlightsEnhancingEffect = "HighlightsEnhancingEffect";
  118742. /**
  118743. * @ignore
  118744. * The depth-of-field PostProcess id in the pipeline
  118745. */
  118746. _this.LensDepthOfFieldEffect = "LensDepthOfFieldEffect";
  118747. _this._pentagonBokehIsEnabled = false;
  118748. _this._scene = scene;
  118749. // Fetch texture samplers
  118750. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  118751. if (parameters.grain_texture) {
  118752. _this._grainTexture = parameters.grain_texture;
  118753. }
  118754. else {
  118755. _this._createGrainTexture();
  118756. }
  118757. // save parameters
  118758. _this._edgeBlur = parameters.edge_blur ? parameters.edge_blur : 0;
  118759. _this._grainAmount = parameters.grain_amount ? parameters.grain_amount : 0;
  118760. _this._chromaticAberration = parameters.chromatic_aberration ? parameters.chromatic_aberration : 0;
  118761. _this._distortion = parameters.distortion ? parameters.distortion : 0;
  118762. _this._highlightsGain = parameters.dof_gain !== undefined ? parameters.dof_gain : -1;
  118763. _this._highlightsThreshold = parameters.dof_threshold ? parameters.dof_threshold : 1;
  118764. _this._dofDistance = parameters.dof_focus_distance !== undefined ? parameters.dof_focus_distance : -1;
  118765. _this._dofAperture = parameters.dof_aperture ? parameters.dof_aperture : 1;
  118766. _this._dofDarken = parameters.dof_darken ? parameters.dof_darken : 0;
  118767. _this._dofPentagon = parameters.dof_pentagon !== undefined ? parameters.dof_pentagon : true;
  118768. _this._blurNoise = parameters.blur_noise !== undefined ? parameters.blur_noise : true;
  118769. // Create effects
  118770. _this._createChromaticAberrationPostProcess(ratio);
  118771. _this._createHighlightsPostProcess(ratio);
  118772. _this._createDepthOfFieldPostProcess(ratio / 4);
  118773. // Set up pipeline
  118774. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensChromaticAberrationEffect, function () { return _this._chromaticAberrationPostProcess; }, true));
  118775. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.HighlightsEnhancingEffect, function () { return _this._highlightsPostProcess; }, true));
  118776. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensDepthOfFieldEffect, function () { return _this._depthOfFieldPostProcess; }, true));
  118777. if (_this._highlightsGain === -1) {
  118778. _this._disableEffect(_this.HighlightsEnhancingEffect, null);
  118779. }
  118780. // Finish
  118781. scene.postProcessRenderPipelineManager.addPipeline(_this);
  118782. if (cameras) {
  118783. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  118784. }
  118785. return _this;
  118786. }
  118787. /**
  118788. * Get the class name
  118789. * @returns "LensRenderingPipeline"
  118790. */
  118791. LensRenderingPipeline.prototype.getClassName = function () {
  118792. return "LensRenderingPipeline";
  118793. };
  118794. Object.defineProperty(LensRenderingPipeline.prototype, "scene", {
  118795. // Properties
  118796. /**
  118797. * Gets associated scene
  118798. */
  118799. get: function () {
  118800. return this._scene;
  118801. },
  118802. enumerable: true,
  118803. configurable: true
  118804. });
  118805. Object.defineProperty(LensRenderingPipeline.prototype, "edgeBlur", {
  118806. /**
  118807. * Gets or sets the edge blur
  118808. */
  118809. get: function () {
  118810. return this._edgeBlur;
  118811. },
  118812. set: function (value) {
  118813. this.setEdgeBlur(value);
  118814. },
  118815. enumerable: true,
  118816. configurable: true
  118817. });
  118818. Object.defineProperty(LensRenderingPipeline.prototype, "grainAmount", {
  118819. /**
  118820. * Gets or sets the grain amount
  118821. */
  118822. get: function () {
  118823. return this._grainAmount;
  118824. },
  118825. set: function (value) {
  118826. this.setGrainAmount(value);
  118827. },
  118828. enumerable: true,
  118829. configurable: true
  118830. });
  118831. Object.defineProperty(LensRenderingPipeline.prototype, "chromaticAberration", {
  118832. /**
  118833. * Gets or sets the chromatic aberration amount
  118834. */
  118835. get: function () {
  118836. return this._chromaticAberration;
  118837. },
  118838. set: function (value) {
  118839. this.setChromaticAberration(value);
  118840. },
  118841. enumerable: true,
  118842. configurable: true
  118843. });
  118844. Object.defineProperty(LensRenderingPipeline.prototype, "dofAperture", {
  118845. /**
  118846. * Gets or sets the depth of field aperture
  118847. */
  118848. get: function () {
  118849. return this._dofAperture;
  118850. },
  118851. set: function (value) {
  118852. this.setAperture(value);
  118853. },
  118854. enumerable: true,
  118855. configurable: true
  118856. });
  118857. Object.defineProperty(LensRenderingPipeline.prototype, "edgeDistortion", {
  118858. /**
  118859. * Gets or sets the edge distortion
  118860. */
  118861. get: function () {
  118862. return this._distortion;
  118863. },
  118864. set: function (value) {
  118865. this.setEdgeDistortion(value);
  118866. },
  118867. enumerable: true,
  118868. configurable: true
  118869. });
  118870. Object.defineProperty(LensRenderingPipeline.prototype, "dofDistortion", {
  118871. /**
  118872. * Gets or sets the depth of field distortion
  118873. */
  118874. get: function () {
  118875. return this._dofDistance;
  118876. },
  118877. set: function (value) {
  118878. this.setFocusDistance(value);
  118879. },
  118880. enumerable: true,
  118881. configurable: true
  118882. });
  118883. Object.defineProperty(LensRenderingPipeline.prototype, "darkenOutOfFocus", {
  118884. /**
  118885. * Gets or sets the darken out of focus amount
  118886. */
  118887. get: function () {
  118888. return this._dofDarken;
  118889. },
  118890. set: function (value) {
  118891. this.setDarkenOutOfFocus(value);
  118892. },
  118893. enumerable: true,
  118894. configurable: true
  118895. });
  118896. Object.defineProperty(LensRenderingPipeline.prototype, "blurNoise", {
  118897. /**
  118898. * Gets or sets a boolean indicating if blur noise is enabled
  118899. */
  118900. get: function () {
  118901. return this._blurNoise;
  118902. },
  118903. set: function (value) {
  118904. this._blurNoise = value;
  118905. },
  118906. enumerable: true,
  118907. configurable: true
  118908. });
  118909. Object.defineProperty(LensRenderingPipeline.prototype, "pentagonBokeh", {
  118910. /**
  118911. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  118912. */
  118913. get: function () {
  118914. return this._pentagonBokehIsEnabled;
  118915. },
  118916. set: function (value) {
  118917. if (value) {
  118918. this.enablePentagonBokeh();
  118919. }
  118920. else {
  118921. this.disablePentagonBokeh();
  118922. }
  118923. },
  118924. enumerable: true,
  118925. configurable: true
  118926. });
  118927. Object.defineProperty(LensRenderingPipeline.prototype, "highlightsGain", {
  118928. /**
  118929. * Gets or sets the highlight grain amount
  118930. */
  118931. get: function () {
  118932. return this._highlightsGain;
  118933. },
  118934. set: function (value) {
  118935. this.setHighlightsGain(value);
  118936. },
  118937. enumerable: true,
  118938. configurable: true
  118939. });
  118940. Object.defineProperty(LensRenderingPipeline.prototype, "highlightsThreshold", {
  118941. /**
  118942. * Gets or sets the highlight threshold
  118943. */
  118944. get: function () {
  118945. return this._highlightsThreshold;
  118946. },
  118947. set: function (value) {
  118948. this.setHighlightsThreshold(value);
  118949. },
  118950. enumerable: true,
  118951. configurable: true
  118952. });
  118953. // public methods (self explanatory)
  118954. /**
  118955. * Sets the amount of blur at the edges
  118956. * @param amount blur amount
  118957. */
  118958. LensRenderingPipeline.prototype.setEdgeBlur = function (amount) { this._edgeBlur = amount; };
  118959. /**
  118960. * Sets edge blur to 0
  118961. */
  118962. LensRenderingPipeline.prototype.disableEdgeBlur = function () { this._edgeBlur = 0; };
  118963. /**
  118964. * Sets the amout of grain
  118965. * @param amount Amount of grain
  118966. */
  118967. LensRenderingPipeline.prototype.setGrainAmount = function (amount) { this._grainAmount = amount; };
  118968. /**
  118969. * Set grain amount to 0
  118970. */
  118971. LensRenderingPipeline.prototype.disableGrain = function () { this._grainAmount = 0; };
  118972. /**
  118973. * Sets the chromatic aberration amount
  118974. * @param amount amount of chromatic aberration
  118975. */
  118976. LensRenderingPipeline.prototype.setChromaticAberration = function (amount) { this._chromaticAberration = amount; };
  118977. /**
  118978. * Sets chromatic aberration amount to 0
  118979. */
  118980. LensRenderingPipeline.prototype.disableChromaticAberration = function () { this._chromaticAberration = 0; };
  118981. /**
  118982. * Sets the EdgeDistortion amount
  118983. * @param amount amount of EdgeDistortion
  118984. */
  118985. LensRenderingPipeline.prototype.setEdgeDistortion = function (amount) { this._distortion = amount; };
  118986. /**
  118987. * Sets edge distortion to 0
  118988. */
  118989. LensRenderingPipeline.prototype.disableEdgeDistortion = function () { this._distortion = 0; };
  118990. /**
  118991. * Sets the FocusDistance amount
  118992. * @param amount amount of FocusDistance
  118993. */
  118994. LensRenderingPipeline.prototype.setFocusDistance = function (amount) { this._dofDistance = amount; };
  118995. /**
  118996. * Disables depth of field
  118997. */
  118998. LensRenderingPipeline.prototype.disableDepthOfField = function () { this._dofDistance = -1; };
  118999. /**
  119000. * Sets the Aperture amount
  119001. * @param amount amount of Aperture
  119002. */
  119003. LensRenderingPipeline.prototype.setAperture = function (amount) { this._dofAperture = amount; };
  119004. /**
  119005. * Sets the DarkenOutOfFocus amount
  119006. * @param amount amount of DarkenOutOfFocus
  119007. */
  119008. LensRenderingPipeline.prototype.setDarkenOutOfFocus = function (amount) { this._dofDarken = amount; };
  119009. /**
  119010. * Creates a pentagon bokeh effect
  119011. */
  119012. LensRenderingPipeline.prototype.enablePentagonBokeh = function () {
  119013. this._highlightsPostProcess.updateEffect("#define PENTAGON\n");
  119014. this._pentagonBokehIsEnabled = true;
  119015. };
  119016. /**
  119017. * Disables the pentagon bokeh effect
  119018. */
  119019. LensRenderingPipeline.prototype.disablePentagonBokeh = function () {
  119020. this._pentagonBokehIsEnabled = false;
  119021. this._highlightsPostProcess.updateEffect();
  119022. };
  119023. /**
  119024. * Enables noise blur
  119025. */
  119026. LensRenderingPipeline.prototype.enableNoiseBlur = function () { this._blurNoise = true; };
  119027. /**
  119028. * Disables noise blur
  119029. */
  119030. LensRenderingPipeline.prototype.disableNoiseBlur = function () { this._blurNoise = false; };
  119031. /**
  119032. * Sets the HighlightsGain amount
  119033. * @param amount amount of HighlightsGain
  119034. */
  119035. LensRenderingPipeline.prototype.setHighlightsGain = function (amount) {
  119036. this._highlightsGain = amount;
  119037. };
  119038. /**
  119039. * Sets the HighlightsThreshold amount
  119040. * @param amount amount of HighlightsThreshold
  119041. */
  119042. LensRenderingPipeline.prototype.setHighlightsThreshold = function (amount) {
  119043. if (this._highlightsGain === -1) {
  119044. this._highlightsGain = 1.0;
  119045. }
  119046. this._highlightsThreshold = amount;
  119047. };
  119048. /**
  119049. * Disables highlights
  119050. */
  119051. LensRenderingPipeline.prototype.disableHighlights = function () {
  119052. this._highlightsGain = -1;
  119053. };
  119054. /**
  119055. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  119056. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  119057. */
  119058. LensRenderingPipeline.prototype.dispose = function (disableDepthRender) {
  119059. if (disableDepthRender === void 0) { disableDepthRender = false; }
  119060. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  119061. this._chromaticAberrationPostProcess = null;
  119062. this._highlightsPostProcess = null;
  119063. this._depthOfFieldPostProcess = null;
  119064. this._grainTexture.dispose();
  119065. if (disableDepthRender) {
  119066. this._scene.disableDepthRenderer();
  119067. }
  119068. };
  119069. // colors shifting and distortion
  119070. LensRenderingPipeline.prototype._createChromaticAberrationPostProcess = function (ratio) {
  119071. var _this = this;
  119072. this._chromaticAberrationPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensChromaticAberration", "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], // uniforms
  119073. [], // samplers
  119074. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  119075. this._chromaticAberrationPostProcess.onApply = function (effect) {
  119076. effect.setFloat('chromatic_aberration', _this._chromaticAberration);
  119077. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  119078. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  119079. effect.setFloat('radialIntensity', 1);
  119080. effect.setFloat2('direction', 17, 17);
  119081. effect.setFloat2('centerPosition', 0.5, 0.5);
  119082. };
  119083. };
  119084. // highlights enhancing
  119085. LensRenderingPipeline.prototype._createHighlightsPostProcess = function (ratio) {
  119086. var _this = this;
  119087. this._highlightsPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensHighlights", "lensHighlights", ["gain", "threshold", "screen_width", "screen_height"], // uniforms
  119088. [], // samplers
  119089. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, this._dofPentagon ? "#define PENTAGON\n" : "");
  119090. this._highlightsPostProcess.onApply = function (effect) {
  119091. effect.setFloat('gain', _this._highlightsGain);
  119092. effect.setFloat('threshold', _this._highlightsThreshold);
  119093. effect.setTextureFromPostProcess("textureSampler", _this._chromaticAberrationPostProcess);
  119094. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  119095. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  119096. };
  119097. };
  119098. // colors shifting and distortion
  119099. LensRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (ratio) {
  119100. var _this = this;
  119101. this._depthOfFieldPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensDepthOfField", "depthOfField", [
  119102. "grain_amount", "blur_noise", "screen_width", "screen_height", "distortion", "dof_enabled",
  119103. "screen_distance", "aperture", "darken", "edge_blur", "highlights", "near", "far"
  119104. ], ["depthSampler", "grainSampler", "highlightsSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  119105. this._depthOfFieldPostProcess.onApply = function (effect) {
  119106. effect.setTexture("depthSampler", _this._depthTexture);
  119107. effect.setTexture("grainSampler", _this._grainTexture);
  119108. effect.setTextureFromPostProcess("textureSampler", _this._highlightsPostProcess);
  119109. effect.setTextureFromPostProcess("highlightsSampler", _this._depthOfFieldPostProcess);
  119110. effect.setFloat('grain_amount', _this._grainAmount);
  119111. effect.setBool('blur_noise', _this._blurNoise);
  119112. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  119113. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  119114. effect.setFloat('distortion', _this._distortion);
  119115. effect.setBool('dof_enabled', (_this._dofDistance !== -1));
  119116. effect.setFloat('screen_distance', 1.0 / (0.1 - 1.0 / _this._dofDistance));
  119117. effect.setFloat('aperture', _this._dofAperture);
  119118. effect.setFloat('darken', _this._dofDarken);
  119119. effect.setFloat('edge_blur', _this._edgeBlur);
  119120. effect.setBool('highlights', (_this._highlightsGain !== -1));
  119121. if (_this._scene.activeCamera) {
  119122. effect.setFloat('near', _this._scene.activeCamera.minZ);
  119123. effect.setFloat('far', _this._scene.activeCamera.maxZ);
  119124. }
  119125. };
  119126. };
  119127. // creates a black and white random noise texture, 512x512
  119128. LensRenderingPipeline.prototype._createGrainTexture = function () {
  119129. var size = 512;
  119130. 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);
  119131. this._grainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  119132. this._grainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  119133. var context = this._grainTexture.getContext();
  119134. var rand = function (min, max) {
  119135. return Math.random() * (max - min) + min;
  119136. };
  119137. var value;
  119138. for (var x = 0; x < size; x++) {
  119139. for (var y = 0; y < size; y++) {
  119140. value = Math.floor(rand(0.42, 0.58) * 255);
  119141. context.fillStyle = 'rgb(' + value + ', ' + value + ', ' + value + ')';
  119142. context.fillRect(x, y, 1, 1);
  119143. }
  119144. }
  119145. this._grainTexture.update(false);
  119146. };
  119147. return LensRenderingPipeline;
  119148. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipeline"]));
  119149. /***/ }),
  119150. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts":
  119151. /*!**************************************************************************!*\
  119152. !*** ./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts ***!
  119153. \**************************************************************************/
  119154. /*! exports provided: SSAO2RenderingPipeline */
  119155. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119156. "use strict";
  119157. __webpack_require__.r(__webpack_exports__);
  119158. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return SSAO2RenderingPipeline; });
  119159. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119160. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  119161. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  119162. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  119163. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119164. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  119165. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  119166. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  119167. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  119168. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  119169. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  119170. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  119171. /* harmony import */ var _Shaders_ssao2_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssao2.fragment */ "./Shaders/ssao2.fragment.ts");
  119172. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  119173. /**
  119174. * Render pipeline to produce ssao effect
  119175. */
  119176. var SSAO2RenderingPipeline = /** @class */ (function (_super) {
  119177. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAO2RenderingPipeline, _super);
  119178. /**
  119179. * @constructor
  119180. * @param name The rendering pipeline name
  119181. * @param scene The scene linked to this pipeline
  119182. * @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 }
  119183. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119184. */
  119185. function SSAO2RenderingPipeline(name, scene, ratio, cameras) {
  119186. var _this = _super.call(this, scene.getEngine(), name) || this;
  119187. // Members
  119188. /**
  119189. * @ignore
  119190. * The PassPostProcess id in the pipeline that contains the original scene color
  119191. */
  119192. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  119193. /**
  119194. * @ignore
  119195. * The SSAO PostProcess id in the pipeline
  119196. */
  119197. _this.SSAORenderEffect = "SSAORenderEffect";
  119198. /**
  119199. * @ignore
  119200. * The horizontal blur PostProcess id in the pipeline
  119201. */
  119202. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  119203. /**
  119204. * @ignore
  119205. * The vertical blur PostProcess id in the pipeline
  119206. */
  119207. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  119208. /**
  119209. * @ignore
  119210. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119211. */
  119212. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  119213. /**
  119214. * The output strength of the SSAO post-process. Default value is 1.0.
  119215. */
  119216. _this.totalStrength = 1.0;
  119217. /**
  119218. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  119219. */
  119220. _this.maxZ = 100.0;
  119221. /**
  119222. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  119223. */
  119224. _this.minZAspect = 0.2;
  119225. _this._samples = 8;
  119226. _this._textureSamples = 1;
  119227. _this._expensiveBlur = true;
  119228. /**
  119229. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  119230. */
  119231. _this.radius = 2.0;
  119232. /**
  119233. * The base color of the SSAO post-process
  119234. * The final result is "base + ssao" between [0, 1]
  119235. */
  119236. _this.base = 0;
  119237. _this._firstUpdate = true;
  119238. _this._bits = new Uint32Array(1);
  119239. _this._scene = scene;
  119240. _this._ratio = ratio;
  119241. if (!_this.isSupported) {
  119242. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("SSAO 2 needs WebGL 2 support.");
  119243. return _this;
  119244. }
  119245. var ssaoRatio = _this._ratio.ssaoRatio || ratio;
  119246. var blurRatio = _this._ratio.blurRatio || ratio;
  119247. // Set up assets
  119248. var geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  119249. _this._createRandomTexture();
  119250. _this._depthTexture = geometryBufferRenderer.getGBuffer().textures[0];
  119251. _this._normalTexture = geometryBufferRenderer.getGBuffer().textures[1];
  119252. _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);
  119253. _this._originalColorPostProcess.samples = _this.textureSamples;
  119254. _this._createSSAOPostProcess(1.0);
  119255. _this._createBlurPostProcess(ssaoRatio, blurRatio);
  119256. _this._createSSAOCombinePostProcess(blurRatio);
  119257. // Set up pipeline
  119258. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  119259. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  119260. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  119261. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  119262. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  119263. // Finish
  119264. scene.postProcessRenderPipelineManager.addPipeline(_this);
  119265. if (cameras) {
  119266. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  119267. }
  119268. return _this;
  119269. }
  119270. Object.defineProperty(SSAO2RenderingPipeline.prototype, "samples", {
  119271. get: function () {
  119272. return this._samples;
  119273. },
  119274. /**
  119275. * Number of samples used for the SSAO calculations. Default value is 8
  119276. */
  119277. set: function (n) {
  119278. this._ssaoPostProcess.updateEffect("#define SAMPLES " + n + "\n#define SSAO");
  119279. this._samples = n;
  119280. this._sampleSphere = this._generateHemisphere();
  119281. this._firstUpdate = true;
  119282. },
  119283. enumerable: true,
  119284. configurable: true
  119285. });
  119286. Object.defineProperty(SSAO2RenderingPipeline.prototype, "textureSamples", {
  119287. get: function () {
  119288. return this._textureSamples;
  119289. },
  119290. /**
  119291. * Number of samples to use for antialiasing
  119292. */
  119293. set: function (n) {
  119294. this._textureSamples = n;
  119295. this._originalColorPostProcess.samples = n;
  119296. this._blurHPostProcess.samples = n;
  119297. this._blurVPostProcess.samples = n;
  119298. this._ssaoPostProcess.samples = n;
  119299. this._ssaoCombinePostProcess.samples = n;
  119300. },
  119301. enumerable: true,
  119302. configurable: true
  119303. });
  119304. Object.defineProperty(SSAO2RenderingPipeline.prototype, "expensiveBlur", {
  119305. get: function () {
  119306. return this._expensiveBlur;
  119307. },
  119308. /**
  119309. * If bilateral blur should be used
  119310. */
  119311. set: function (b) {
  119312. 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"]);
  119313. this._blurVPostProcess.updateEffect("#define BILATERAL_BLUR\n#define SAMPLES 16\n#define EXPENSIVE " + (b ? "1" : "0") + "\n", null, ["textureSampler", "depthSampler"]);
  119314. this._expensiveBlur = b;
  119315. this._firstUpdate = true;
  119316. },
  119317. enumerable: true,
  119318. configurable: true
  119319. });
  119320. Object.defineProperty(SSAO2RenderingPipeline, "IsSupported", {
  119321. /**
  119322. * Support test.
  119323. */
  119324. get: function () {
  119325. var engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__["EngineStore"].LastCreatedEngine;
  119326. if (!engine) {
  119327. return false;
  119328. }
  119329. return engine.getCaps().drawBuffersExtension;
  119330. },
  119331. enumerable: true,
  119332. configurable: true
  119333. });
  119334. Object.defineProperty(SSAO2RenderingPipeline.prototype, "scene", {
  119335. /**
  119336. * Gets active scene
  119337. */
  119338. get: function () {
  119339. return this._scene;
  119340. },
  119341. enumerable: true,
  119342. configurable: true
  119343. });
  119344. // Public Methods
  119345. /**
  119346. * Get the class name
  119347. * @returns "SSAO2RenderingPipeline"
  119348. */
  119349. SSAO2RenderingPipeline.prototype.getClassName = function () {
  119350. return "SSAO2RenderingPipeline";
  119351. };
  119352. /**
  119353. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119354. */
  119355. SSAO2RenderingPipeline.prototype.dispose = function (disableGeometryBufferRenderer) {
  119356. if (disableGeometryBufferRenderer === void 0) { disableGeometryBufferRenderer = false; }
  119357. for (var i = 0; i < this._scene.cameras.length; i++) {
  119358. var camera = this._scene.cameras[i];
  119359. this._originalColorPostProcess.dispose(camera);
  119360. this._ssaoPostProcess.dispose(camera);
  119361. this._blurHPostProcess.dispose(camera);
  119362. this._blurVPostProcess.dispose(camera);
  119363. this._ssaoCombinePostProcess.dispose(camera);
  119364. }
  119365. this._randomTexture.dispose();
  119366. if (disableGeometryBufferRenderer) {
  119367. this._scene.disableGeometryBufferRenderer();
  119368. }
  119369. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  119370. _super.prototype.dispose.call(this);
  119371. };
  119372. // Private Methods
  119373. SSAO2RenderingPipeline.prototype._createBlurPostProcess = function (ssaoRatio, blurRatio) {
  119374. var _this = this;
  119375. this._samplerOffsets = [];
  119376. var expensive = this.expensiveBlur;
  119377. for (var i = -8; i < 8; i++) {
  119378. this._samplerOffsets.push(i * 2 + 0.5);
  119379. }
  119380. 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");
  119381. this._blurHPostProcess.onApply = function (effect) {
  119382. if (!_this._scene.activeCamera) {
  119383. return;
  119384. }
  119385. effect.setFloat("outSize", _this._ssaoCombinePostProcess.width > 0 ? _this._ssaoCombinePostProcess.width : _this._originalColorPostProcess.width);
  119386. effect.setFloat("near", _this._scene.activeCamera.minZ);
  119387. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  119388. effect.setFloat("radius", _this.radius);
  119389. effect.setTexture("depthSampler", _this._depthTexture);
  119390. if (_this._firstUpdate) {
  119391. effect.setArray("samplerOffsets", _this._samplerOffsets);
  119392. }
  119393. };
  119394. 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");
  119395. this._blurVPostProcess.onApply = function (effect) {
  119396. if (!_this._scene.activeCamera) {
  119397. return;
  119398. }
  119399. effect.setFloat("outSize", _this._ssaoCombinePostProcess.height > 0 ? _this._ssaoCombinePostProcess.height : _this._originalColorPostProcess.height);
  119400. effect.setFloat("near", _this._scene.activeCamera.minZ);
  119401. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  119402. effect.setFloat("radius", _this.radius);
  119403. effect.setTexture("depthSampler", _this._depthTexture);
  119404. if (_this._firstUpdate) {
  119405. effect.setArray("samplerOffsets", _this._samplerOffsets);
  119406. _this._firstUpdate = false;
  119407. }
  119408. };
  119409. this._blurHPostProcess.samples = this.textureSamples;
  119410. this._blurVPostProcess.samples = this.textureSamples;
  119411. };
  119412. /** @hidden */
  119413. SSAO2RenderingPipeline.prototype._rebuild = function () {
  119414. this._firstUpdate = true;
  119415. _super.prototype._rebuild.call(this);
  119416. };
  119417. //Van der Corput radical inverse
  119418. SSAO2RenderingPipeline.prototype._radicalInverse_VdC = function (i) {
  119419. this._bits[0] = i;
  119420. this._bits[0] = ((this._bits[0] << 16) | (this._bits[0] >> 16)) >>> 0;
  119421. this._bits[0] = ((this._bits[0] & 0x55555555) << 1) | ((this._bits[0] & 0xAAAAAAAA) >>> 1) >>> 0;
  119422. this._bits[0] = ((this._bits[0] & 0x33333333) << 2) | ((this._bits[0] & 0xCCCCCCCC) >>> 2) >>> 0;
  119423. this._bits[0] = ((this._bits[0] & 0x0F0F0F0F) << 4) | ((this._bits[0] & 0xF0F0F0F0) >>> 4) >>> 0;
  119424. this._bits[0] = ((this._bits[0] & 0x00FF00FF) << 8) | ((this._bits[0] & 0xFF00FF00) >>> 8) >>> 0;
  119425. return this._bits[0] * 2.3283064365386963e-10; // / 0x100000000 or / 4294967296
  119426. };
  119427. SSAO2RenderingPipeline.prototype._hammersley = function (i, n) {
  119428. return [i / n, this._radicalInverse_VdC(i)];
  119429. };
  119430. SSAO2RenderingPipeline.prototype._hemisphereSample_uniform = function (u, v) {
  119431. var phi = v * 2.0 * Math.PI;
  119432. // rejecting samples that are close to tangent plane to avoid z-fighting artifacts
  119433. var cosTheta = 1.0 - (u * 0.85 + 0.15);
  119434. var sinTheta = Math.sqrt(1.0 - cosTheta * cosTheta);
  119435. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.cos(phi) * sinTheta, Math.sin(phi) * sinTheta, cosTheta);
  119436. };
  119437. SSAO2RenderingPipeline.prototype._generateHemisphere = function () {
  119438. var numSamples = this.samples;
  119439. var result = [];
  119440. var vector;
  119441. var i = 0;
  119442. while (i < numSamples) {
  119443. if (numSamples < 16) {
  119444. vector = this._hemisphereSample_uniform(Math.random(), Math.random());
  119445. }
  119446. else {
  119447. var rand = this._hammersley(i, numSamples);
  119448. vector = this._hemisphereSample_uniform(rand[0], rand[1]);
  119449. }
  119450. result.push(vector.x, vector.y, vector.z);
  119451. i++;
  119452. }
  119453. return result;
  119454. };
  119455. SSAO2RenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  119456. var _this = this;
  119457. var numSamples = this.samples;
  119458. this._sampleSphere = this._generateHemisphere();
  119459. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("ssao2", "ssao2", [
  119460. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  119461. "base", "range", "projection", "near", "far", "texelSize",
  119462. "xViewport", "yViewport", "maxZ", "minZAspect"
  119463. ], ["randomSampler", "normalSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  119464. this._ssaoPostProcess.onApply = function (effect) {
  119465. if (_this._firstUpdate) {
  119466. effect.setArray3("sampleSphere", _this._sampleSphere);
  119467. effect.setFloat("randTextureTiles", 32.0);
  119468. }
  119469. if (!_this._scene.activeCamera) {
  119470. return;
  119471. }
  119472. effect.setFloat("samplesFactor", 1 / _this.samples);
  119473. effect.setFloat("totalStrength", _this.totalStrength);
  119474. effect.setFloat2("texelSize", 1 / _this._ssaoPostProcess.width, 1 / _this._ssaoPostProcess.height);
  119475. effect.setFloat("radius", _this.radius);
  119476. effect.setFloat("maxZ", _this.maxZ);
  119477. effect.setFloat("minZAspect", _this.minZAspect);
  119478. effect.setFloat("base", _this.base);
  119479. effect.setFloat("near", _this._scene.activeCamera.minZ);
  119480. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  119481. effect.setFloat("xViewport", Math.tan(_this._scene.activeCamera.fov / 2) * _this._scene.getEngine().getAspectRatio(_this._scene.activeCamera, true));
  119482. effect.setFloat("yViewport", Math.tan(_this._scene.activeCamera.fov / 2));
  119483. effect.setMatrix("projection", _this._scene.getProjectionMatrix());
  119484. effect.setTexture("textureSampler", _this._depthTexture);
  119485. effect.setTexture("normalSampler", _this._normalTexture);
  119486. effect.setTexture("randomSampler", _this._randomTexture);
  119487. };
  119488. this._ssaoPostProcess.samples = this.textureSamples;
  119489. };
  119490. SSAO2RenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  119491. var _this = this;
  119492. 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);
  119493. this._ssaoCombinePostProcess.onApply = function (effect) {
  119494. var viewport = _this._scene.activeCamera.viewport;
  119495. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector4[0].copyFromFloats(viewport.x, viewport.y, viewport.width, viewport.height));
  119496. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  119497. };
  119498. this._ssaoCombinePostProcess.samples = this.textureSamples;
  119499. };
  119500. SSAO2RenderingPipeline.prototype._createRandomTexture = function () {
  119501. var size = 128;
  119502. 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);
  119503. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  119504. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  119505. var context = this._randomTexture.getContext();
  119506. var rand = function (min, max) {
  119507. return Math.random() * (max - min) + min;
  119508. };
  119509. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  119510. for (var x = 0; x < size; x++) {
  119511. for (var y = 0; y < size; y++) {
  119512. randVector.x = rand(0.0, 1.0);
  119513. randVector.y = rand(0.0, 1.0);
  119514. randVector.z = 0.0;
  119515. randVector.normalize();
  119516. randVector.scaleInPlace(255);
  119517. randVector.x = Math.floor(randVector.x);
  119518. randVector.y = Math.floor(randVector.y);
  119519. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  119520. context.fillRect(x, y, 1, 1);
  119521. }
  119522. }
  119523. this._randomTexture.update(false);
  119524. };
  119525. /**
  119526. * Serialize the rendering pipeline (Used when exporting)
  119527. * @returns the serialized object
  119528. */
  119529. SSAO2RenderingPipeline.prototype.serialize = function () {
  119530. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Serialize(this);
  119531. serializationObject.customType = "SSAO2RenderingPipeline";
  119532. return serializationObject;
  119533. };
  119534. /**
  119535. * Parse the serialized pipeline
  119536. * @param source Source pipeline.
  119537. * @param scene The scene to load the pipeline to.
  119538. * @param rootUrl The URL of the serialized pipeline.
  119539. * @returns An instantiated pipeline from the serialized object.
  119540. */
  119541. SSAO2RenderingPipeline.Parse = function (source, scene, rootUrl) {
  119542. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Parse(function () { return new SSAO2RenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  119543. };
  119544. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119545. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  119546. ], SSAO2RenderingPipeline.prototype, "totalStrength", void 0);
  119547. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119548. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  119549. ], SSAO2RenderingPipeline.prototype, "maxZ", void 0);
  119550. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119551. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  119552. ], SSAO2RenderingPipeline.prototype, "minZAspect", void 0);
  119553. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119554. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("samples")
  119555. ], SSAO2RenderingPipeline.prototype, "_samples", void 0);
  119556. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119557. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("textureSamples")
  119558. ], SSAO2RenderingPipeline.prototype, "_textureSamples", void 0);
  119559. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119560. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  119561. ], SSAO2RenderingPipeline.prototype, "_ratio", void 0);
  119562. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119563. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("expensiveBlur")
  119564. ], SSAO2RenderingPipeline.prototype, "_expensiveBlur", void 0);
  119565. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119566. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  119567. ], SSAO2RenderingPipeline.prototype, "radius", void 0);
  119568. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119569. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  119570. ], SSAO2RenderingPipeline.prototype, "base", void 0);
  119571. return SSAO2RenderingPipeline;
  119572. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  119573. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__["_TypeStore"].RegisteredTypes["BABYLON.SSAO2RenderingPipeline"] = SSAO2RenderingPipeline;
  119574. /***/ }),
  119575. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts":
  119576. /*!*************************************************************************!*\
  119577. !*** ./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts ***!
  119578. \*************************************************************************/
  119579. /*! exports provided: SSAORenderingPipeline */
  119580. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119581. "use strict";
  119582. __webpack_require__.r(__webpack_exports__);
  119583. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return SSAORenderingPipeline; });
  119584. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119585. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  119586. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119587. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  119588. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  119589. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  119590. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  119591. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  119592. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  119593. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  119594. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  119595. /* harmony import */ var _Shaders_ssao_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Shaders/ssao.fragment */ "./Shaders/ssao.fragment.ts");
  119596. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  119597. /**
  119598. * Render pipeline to produce ssao effect
  119599. */
  119600. var SSAORenderingPipeline = /** @class */ (function (_super) {
  119601. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAORenderingPipeline, _super);
  119602. /**
  119603. * @constructor
  119604. * @param name - The rendering pipeline name
  119605. * @param scene - The scene linked to this pipeline
  119606. * @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 }
  119607. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  119608. */
  119609. function SSAORenderingPipeline(name, scene, ratio, cameras) {
  119610. var _this = _super.call(this, scene.getEngine(), name) || this;
  119611. // Members
  119612. /**
  119613. * @ignore
  119614. * The PassPostProcess id in the pipeline that contains the original scene color
  119615. */
  119616. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  119617. /**
  119618. * @ignore
  119619. * The SSAO PostProcess id in the pipeline
  119620. */
  119621. _this.SSAORenderEffect = "SSAORenderEffect";
  119622. /**
  119623. * @ignore
  119624. * The horizontal blur PostProcess id in the pipeline
  119625. */
  119626. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  119627. /**
  119628. * @ignore
  119629. * The vertical blur PostProcess id in the pipeline
  119630. */
  119631. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  119632. /**
  119633. * @ignore
  119634. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119635. */
  119636. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  119637. /**
  119638. * The output strength of the SSAO post-process. Default value is 1.0.
  119639. */
  119640. _this.totalStrength = 1.0;
  119641. /**
  119642. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  119643. */
  119644. _this.radius = 0.0001;
  119645. /**
  119646. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  119647. * Must not be equal to fallOff and superior to fallOff.
  119648. * Default value is 0.0075
  119649. */
  119650. _this.area = 0.0075;
  119651. /**
  119652. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  119653. * Must not be equal to area and inferior to area.
  119654. * Default value is 0.000001
  119655. */
  119656. _this.fallOff = 0.000001;
  119657. /**
  119658. * The base color of the SSAO post-process
  119659. * The final result is "base + ssao" between [0, 1]
  119660. */
  119661. _this.base = 0.5;
  119662. _this._firstUpdate = true;
  119663. _this._scene = scene;
  119664. // Set up assets
  119665. _this._createRandomTexture();
  119666. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  119667. var ssaoRatio = ratio.ssaoRatio || ratio;
  119668. var combineRatio = ratio.combineRatio || ratio;
  119669. _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);
  119670. _this._createSSAOPostProcess(ssaoRatio);
  119671. _this._createBlurPostProcess(ssaoRatio);
  119672. _this._createSSAOCombinePostProcess(combineRatio);
  119673. // Set up pipeline
  119674. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  119675. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  119676. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  119677. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  119678. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  119679. // Finish
  119680. scene.postProcessRenderPipelineManager.addPipeline(_this);
  119681. if (cameras) {
  119682. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  119683. }
  119684. return _this;
  119685. }
  119686. Object.defineProperty(SSAORenderingPipeline.prototype, "scene", {
  119687. /**
  119688. * Gets active scene
  119689. */
  119690. get: function () {
  119691. return this._scene;
  119692. },
  119693. enumerable: true,
  119694. configurable: true
  119695. });
  119696. // Public Methods
  119697. /**
  119698. * Get the class name
  119699. * @returns "SSAORenderingPipeline"
  119700. */
  119701. SSAORenderingPipeline.prototype.getClassName = function () {
  119702. return "SSAORenderingPipeline";
  119703. };
  119704. /**
  119705. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119706. */
  119707. SSAORenderingPipeline.prototype.dispose = function (disableDepthRender) {
  119708. if (disableDepthRender === void 0) { disableDepthRender = false; }
  119709. for (var i = 0; i < this._scene.cameras.length; i++) {
  119710. var camera = this._scene.cameras[i];
  119711. this._originalColorPostProcess.dispose(camera);
  119712. this._ssaoPostProcess.dispose(camera);
  119713. this._blurHPostProcess.dispose(camera);
  119714. this._blurVPostProcess.dispose(camera);
  119715. this._ssaoCombinePostProcess.dispose(camera);
  119716. }
  119717. this._randomTexture.dispose();
  119718. if (disableDepthRender) {
  119719. this._scene.disableDepthRenderer();
  119720. }
  119721. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  119722. _super.prototype.dispose.call(this);
  119723. };
  119724. // Private Methods
  119725. SSAORenderingPipeline.prototype._createBlurPostProcess = function (ratio) {
  119726. var _this = this;
  119727. var size = 16;
  119728. 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);
  119729. 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);
  119730. this._blurHPostProcess.onActivateObservable.add(function () {
  119731. var dw = _this._blurHPostProcess.width / _this._scene.getEngine().getRenderWidth();
  119732. _this._blurHPostProcess.kernel = size * dw;
  119733. });
  119734. this._blurVPostProcess.onActivateObservable.add(function () {
  119735. var dw = _this._blurVPostProcess.height / _this._scene.getEngine().getRenderHeight();
  119736. _this._blurVPostProcess.kernel = size * dw;
  119737. });
  119738. };
  119739. /** @hidden */
  119740. SSAORenderingPipeline.prototype._rebuild = function () {
  119741. this._firstUpdate = true;
  119742. _super.prototype._rebuild.call(this);
  119743. };
  119744. SSAORenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  119745. var _this = this;
  119746. var numSamples = 16;
  119747. var sampleSphere = [
  119748. 0.5381, 0.1856, -0.4319,
  119749. 0.1379, 0.2486, 0.4430,
  119750. 0.3371, 0.5679, -0.0057,
  119751. -0.6999, -0.0451, -0.0019,
  119752. 0.0689, -0.1598, -0.8547,
  119753. 0.0560, 0.0069, -0.1843,
  119754. -0.0146, 0.1402, 0.0762,
  119755. 0.0100, -0.1924, -0.0344,
  119756. -0.3577, -0.5301, -0.4358,
  119757. -0.3169, 0.1063, 0.0158,
  119758. 0.0103, -0.5869, 0.0046,
  119759. -0.0897, -0.4940, 0.3287,
  119760. 0.7119, -0.0154, -0.0918,
  119761. -0.0533, 0.0596, -0.5411,
  119762. 0.0352, -0.0631, 0.5460,
  119763. -0.4776, 0.2847, -0.0271
  119764. ];
  119765. var samplesFactor = 1.0 / numSamples;
  119766. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__["PostProcess"]("ssao", "ssao", [
  119767. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  119768. "area", "fallOff", "base", "range", "viewport"
  119769. ], ["randomSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  119770. this._ssaoPostProcess.onApply = function (effect) {
  119771. if (_this._firstUpdate) {
  119772. effect.setArray3("sampleSphere", sampleSphere);
  119773. effect.setFloat("samplesFactor", samplesFactor);
  119774. effect.setFloat("randTextureTiles", 4.0);
  119775. }
  119776. effect.setFloat("totalStrength", _this.totalStrength);
  119777. effect.setFloat("radius", _this.radius);
  119778. effect.setFloat("area", _this.area);
  119779. effect.setFloat("fallOff", _this.fallOff);
  119780. effect.setFloat("base", _this.base);
  119781. effect.setTexture("textureSampler", _this._depthTexture);
  119782. effect.setTexture("randomSampler", _this._randomTexture);
  119783. };
  119784. };
  119785. SSAORenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  119786. var _this = this;
  119787. 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);
  119788. this._ssaoCombinePostProcess.onApply = function (effect) {
  119789. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector4[0].copyFromFloats(0, 0, 1.0, 1.0));
  119790. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  119791. };
  119792. };
  119793. SSAORenderingPipeline.prototype._createRandomTexture = function () {
  119794. var size = 512;
  119795. 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);
  119796. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  119797. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  119798. var context = this._randomTexture.getContext();
  119799. var rand = function (min, max) {
  119800. return Math.random() * (max - min) + min;
  119801. };
  119802. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  119803. for (var x = 0; x < size; x++) {
  119804. for (var y = 0; y < size; y++) {
  119805. randVector.x = Math.floor(rand(-1.0, 1.0) * 255);
  119806. randVector.y = Math.floor(rand(-1.0, 1.0) * 255);
  119807. randVector.z = Math.floor(rand(-1.0, 1.0) * 255);
  119808. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  119809. context.fillRect(x, y, 1, 1);
  119810. }
  119811. }
  119812. this._randomTexture.update(false);
  119813. };
  119814. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119815. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  119816. ], SSAORenderingPipeline.prototype, "totalStrength", void 0);
  119817. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119818. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  119819. ], SSAORenderingPipeline.prototype, "radius", void 0);
  119820. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119821. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  119822. ], SSAORenderingPipeline.prototype, "area", void 0);
  119823. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119824. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  119825. ], SSAORenderingPipeline.prototype, "fallOff", void 0);
  119826. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119827. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  119828. ], SSAORenderingPipeline.prototype, "base", void 0);
  119829. return SSAORenderingPipeline;
  119830. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderPipeline"]));
  119831. /***/ }),
  119832. /***/ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts":
  119833. /*!*****************************************************************************!*\
  119834. !*** ./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts ***!
  119835. \*****************************************************************************/
  119836. /*! exports provided: StandardRenderingPipeline */
  119837. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119838. "use strict";
  119839. __webpack_require__.r(__webpack_exports__);
  119840. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return StandardRenderingPipeline; });
  119841. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119842. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  119843. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  119844. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  119845. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  119846. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119847. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  119848. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  119849. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  119850. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  119851. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  119852. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  119853. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  119854. /* harmony import */ var _Shaders_standard_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/standard.fragment */ "./Shaders/standard.fragment.ts");
  119855. /**
  119856. * Standard rendering pipeline
  119857. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  119858. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  119859. */
  119860. var StandardRenderingPipeline = /** @class */ (function (_super) {
  119861. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardRenderingPipeline, _super);
  119862. /**
  119863. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  119864. * @constructor
  119865. * @param name The rendering pipeline name
  119866. * @param scene The scene linked to this pipeline
  119867. * @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)
  119868. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  119869. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119870. */
  119871. function StandardRenderingPipeline(name, scene, ratio, originalPostProcess, cameras) {
  119872. if (originalPostProcess === void 0) { originalPostProcess = null; }
  119873. var _this = _super.call(this, scene.getEngine(), name) || this;
  119874. /**
  119875. * Post-process used to down scale an image x4
  119876. */
  119877. _this.downSampleX4PostProcess = null;
  119878. /**
  119879. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  119880. */
  119881. _this.brightPassPostProcess = null;
  119882. /**
  119883. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  119884. */
  119885. _this.blurHPostProcesses = [];
  119886. /**
  119887. * Post-process array storing all the vertical blur post-processes used by the pipeline
  119888. */
  119889. _this.blurVPostProcesses = [];
  119890. /**
  119891. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  119892. */
  119893. _this.textureAdderPostProcess = null;
  119894. /**
  119895. * Post-process used to create volumetric lighting effect
  119896. */
  119897. _this.volumetricLightPostProcess = null;
  119898. /**
  119899. * Post-process used to smooth the previous volumetric light post-process on the X axis
  119900. */
  119901. _this.volumetricLightSmoothXPostProcess = null;
  119902. /**
  119903. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  119904. */
  119905. _this.volumetricLightSmoothYPostProcess = null;
  119906. /**
  119907. * Post-process used to merge the volumetric light effect and the real scene color
  119908. */
  119909. _this.volumetricLightMergePostProces = null;
  119910. /**
  119911. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  119912. */
  119913. _this.volumetricLightFinalPostProcess = null;
  119914. /**
  119915. * Base post-process used to calculate the average luminance of the final image for HDR
  119916. */
  119917. _this.luminancePostProcess = null;
  119918. /**
  119919. * Post-processes used to create down sample post-processes in order to get
  119920. * the average luminance of the final image for HDR
  119921. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  119922. */
  119923. _this.luminanceDownSamplePostProcesses = [];
  119924. /**
  119925. * Post-process used to create a HDR effect (light adaptation)
  119926. */
  119927. _this.hdrPostProcess = null;
  119928. /**
  119929. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  119930. */
  119931. _this.textureAdderFinalPostProcess = null;
  119932. /**
  119933. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  119934. */
  119935. _this.lensFlareFinalPostProcess = null;
  119936. /**
  119937. * Post-process used to merge the final HDR post-process and the real scene color
  119938. */
  119939. _this.hdrFinalPostProcess = null;
  119940. /**
  119941. * Post-process used to create a lens flare effect
  119942. */
  119943. _this.lensFlarePostProcess = null;
  119944. /**
  119945. * Post-process that merges the result of the lens flare post-process and the real scene color
  119946. */
  119947. _this.lensFlareComposePostProcess = null;
  119948. /**
  119949. * Post-process used to create a motion blur effect
  119950. */
  119951. _this.motionBlurPostProcess = null;
  119952. /**
  119953. * Post-process used to create a depth of field effect
  119954. */
  119955. _this.depthOfFieldPostProcess = null;
  119956. /**
  119957. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  119958. */
  119959. _this.fxaaPostProcess = null;
  119960. // Values
  119961. /**
  119962. * Represents the brightness threshold in order to configure the illuminated surfaces
  119963. */
  119964. _this.brightThreshold = 1.0;
  119965. /**
  119966. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  119967. */
  119968. _this.blurWidth = 512.0;
  119969. /**
  119970. * Sets if the blur for highlighted surfaces must be only horizontal
  119971. */
  119972. _this.horizontalBlur = false;
  119973. /**
  119974. * Texture used typically to simulate "dirty" on camera lens
  119975. */
  119976. _this.lensTexture = null;
  119977. /**
  119978. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  119979. */
  119980. _this.volumetricLightCoefficient = 0.2;
  119981. /**
  119982. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  119983. */
  119984. _this.volumetricLightPower = 4.0;
  119985. /**
  119986. * Used the set the blur intensity to smooth the volumetric lights
  119987. */
  119988. _this.volumetricLightBlurScale = 64.0;
  119989. /**
  119990. * Light (spot or directional) used to generate the volumetric lights rays
  119991. * The source light must have a shadow generate so the pipeline can get its
  119992. * depth map
  119993. */
  119994. _this.sourceLight = null;
  119995. /**
  119996. * For eye adaptation, represents the minimum luminance the eye can see
  119997. */
  119998. _this.hdrMinimumLuminance = 1.0;
  119999. /**
  120000. * For eye adaptation, represents the decrease luminance speed
  120001. */
  120002. _this.hdrDecreaseRate = 0.5;
  120003. /**
  120004. * For eye adaptation, represents the increase luminance speed
  120005. */
  120006. _this.hdrIncreaseRate = 0.5;
  120007. /**
  120008. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  120009. */
  120010. _this.lensColorTexture = null;
  120011. /**
  120012. * The overall strengh for the lens flare effect
  120013. */
  120014. _this.lensFlareStrength = 20.0;
  120015. /**
  120016. * Dispersion coefficient for lens flare ghosts
  120017. */
  120018. _this.lensFlareGhostDispersal = 1.4;
  120019. /**
  120020. * Main lens flare halo width
  120021. */
  120022. _this.lensFlareHaloWidth = 0.7;
  120023. /**
  120024. * Based on the lens distortion effect, defines how much the lens flare result
  120025. * is distorted
  120026. */
  120027. _this.lensFlareDistortionStrength = 16.0;
  120028. /**
  120029. * Lens star texture must be used to simulate rays on the flares and is available
  120030. * in the documentation
  120031. */
  120032. _this.lensStarTexture = null;
  120033. /**
  120034. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  120035. * flare effect by taking account of the dirt texture
  120036. */
  120037. _this.lensFlareDirtTexture = null;
  120038. /**
  120039. * Represents the focal length for the depth of field effect
  120040. */
  120041. _this.depthOfFieldDistance = 10.0;
  120042. /**
  120043. * Represents the blur intensity for the blurred part of the depth of field effect
  120044. */
  120045. _this.depthOfFieldBlurWidth = 64.0;
  120046. /**
  120047. * For motion blur, defines how much the image is blurred by the movement
  120048. */
  120049. _this.motionStrength = 1.0;
  120050. /**
  120051. * List of animations for the pipeline (IAnimatable implementation)
  120052. */
  120053. _this.animations = [];
  120054. _this._currentDepthOfFieldSource = null;
  120055. _this._fixedExposure = 1.0;
  120056. _this._currentExposure = 1.0;
  120057. _this._hdrAutoExposure = false;
  120058. _this._hdrCurrentLuminance = 1.0;
  120059. // Getters and setters
  120060. _this._bloomEnabled = false;
  120061. _this._depthOfFieldEnabled = false;
  120062. _this._vlsEnabled = false;
  120063. _this._lensFlareEnabled = false;
  120064. _this._hdrEnabled = false;
  120065. _this._motionBlurEnabled = false;
  120066. _this._fxaaEnabled = false;
  120067. _this._motionBlurSamples = 64.0;
  120068. _this._volumetricLightStepsCount = 50.0;
  120069. _this._samples = 1;
  120070. _this._cameras = cameras || [];
  120071. // Initialize
  120072. _this._scene = scene;
  120073. _this._basePostProcess = originalPostProcess;
  120074. _this._ratio = ratio;
  120075. // Misc
  120076. _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;
  120077. // Finish
  120078. scene.postProcessRenderPipelineManager.addPipeline(_this);
  120079. _this._buildPipeline();
  120080. return _this;
  120081. }
  120082. Object.defineProperty(StandardRenderingPipeline.prototype, "exposure", {
  120083. /**
  120084. * Gets the overall exposure used by the pipeline
  120085. */
  120086. get: function () {
  120087. return this._fixedExposure;
  120088. },
  120089. /**
  120090. * Sets the overall exposure used by the pipeline
  120091. */
  120092. set: function (value) {
  120093. this._fixedExposure = value;
  120094. this._currentExposure = value;
  120095. },
  120096. enumerable: true,
  120097. configurable: true
  120098. });
  120099. Object.defineProperty(StandardRenderingPipeline.prototype, "hdrAutoExposure", {
  120100. /**
  120101. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  120102. */
  120103. get: function () {
  120104. return this._hdrAutoExposure;
  120105. },
  120106. /**
  120107. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  120108. */
  120109. set: function (value) {
  120110. this._hdrAutoExposure = value;
  120111. if (this.hdrPostProcess) {
  120112. var defines = ["#define HDR"];
  120113. if (value) {
  120114. defines.push("#define AUTO_EXPOSURE");
  120115. }
  120116. this.hdrPostProcess.updateEffect(defines.join("\n"));
  120117. }
  120118. },
  120119. enumerable: true,
  120120. configurable: true
  120121. });
  120122. Object.defineProperty(StandardRenderingPipeline.prototype, "BloomEnabled", {
  120123. /**
  120124. * @ignore
  120125. * Specifies if the bloom pipeline is enabled
  120126. */
  120127. get: function () {
  120128. return this._bloomEnabled;
  120129. },
  120130. set: function (enabled) {
  120131. if (this._bloomEnabled === enabled) {
  120132. return;
  120133. }
  120134. this._bloomEnabled = enabled;
  120135. this._buildPipeline();
  120136. },
  120137. enumerable: true,
  120138. configurable: true
  120139. });
  120140. Object.defineProperty(StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", {
  120141. /**
  120142. * @ignore
  120143. * Specifies if the depth of field pipeline is enabed
  120144. */
  120145. get: function () {
  120146. return this._depthOfFieldEnabled;
  120147. },
  120148. set: function (enabled) {
  120149. if (this._depthOfFieldEnabled === enabled) {
  120150. return;
  120151. }
  120152. this._depthOfFieldEnabled = enabled;
  120153. this._buildPipeline();
  120154. },
  120155. enumerable: true,
  120156. configurable: true
  120157. });
  120158. Object.defineProperty(StandardRenderingPipeline.prototype, "LensFlareEnabled", {
  120159. /**
  120160. * @ignore
  120161. * Specifies if the lens flare pipeline is enabed
  120162. */
  120163. get: function () {
  120164. return this._lensFlareEnabled;
  120165. },
  120166. set: function (enabled) {
  120167. if (this._lensFlareEnabled === enabled) {
  120168. return;
  120169. }
  120170. this._lensFlareEnabled = enabled;
  120171. this._buildPipeline();
  120172. },
  120173. enumerable: true,
  120174. configurable: true
  120175. });
  120176. Object.defineProperty(StandardRenderingPipeline.prototype, "HDREnabled", {
  120177. /**
  120178. * @ignore
  120179. * Specifies if the HDR pipeline is enabled
  120180. */
  120181. get: function () {
  120182. return this._hdrEnabled;
  120183. },
  120184. set: function (enabled) {
  120185. if (this._hdrEnabled === enabled) {
  120186. return;
  120187. }
  120188. this._hdrEnabled = enabled;
  120189. this._buildPipeline();
  120190. },
  120191. enumerable: true,
  120192. configurable: true
  120193. });
  120194. Object.defineProperty(StandardRenderingPipeline.prototype, "VLSEnabled", {
  120195. /**
  120196. * @ignore
  120197. * Specifies if the volumetric lights scattering effect is enabled
  120198. */
  120199. get: function () {
  120200. return this._vlsEnabled;
  120201. },
  120202. set: function (enabled) {
  120203. if (this._vlsEnabled === enabled) {
  120204. return;
  120205. }
  120206. if (enabled) {
  120207. var geometry = this._scene.enableGeometryBufferRenderer();
  120208. if (!geometry) {
  120209. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");
  120210. return;
  120211. }
  120212. }
  120213. this._vlsEnabled = enabled;
  120214. this._buildPipeline();
  120215. },
  120216. enumerable: true,
  120217. configurable: true
  120218. });
  120219. Object.defineProperty(StandardRenderingPipeline.prototype, "MotionBlurEnabled", {
  120220. /**
  120221. * @ignore
  120222. * Specifies if the motion blur effect is enabled
  120223. */
  120224. get: function () {
  120225. return this._motionBlurEnabled;
  120226. },
  120227. set: function (enabled) {
  120228. if (this._motionBlurEnabled === enabled) {
  120229. return;
  120230. }
  120231. this._motionBlurEnabled = enabled;
  120232. this._buildPipeline();
  120233. },
  120234. enumerable: true,
  120235. configurable: true
  120236. });
  120237. Object.defineProperty(StandardRenderingPipeline.prototype, "fxaaEnabled", {
  120238. /**
  120239. * Specifies if anti-aliasing is enabled
  120240. */
  120241. get: function () {
  120242. return this._fxaaEnabled;
  120243. },
  120244. set: function (enabled) {
  120245. if (this._fxaaEnabled === enabled) {
  120246. return;
  120247. }
  120248. this._fxaaEnabled = enabled;
  120249. this._buildPipeline();
  120250. },
  120251. enumerable: true,
  120252. configurable: true
  120253. });
  120254. Object.defineProperty(StandardRenderingPipeline.prototype, "volumetricLightStepsCount", {
  120255. /**
  120256. * Specifies the number of steps used to calculate the volumetric lights
  120257. * Typically in interval [50, 200]
  120258. */
  120259. get: function () {
  120260. return this._volumetricLightStepsCount;
  120261. },
  120262. set: function (count) {
  120263. if (this.volumetricLightPostProcess) {
  120264. this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS " + count.toFixed(1));
  120265. }
  120266. this._volumetricLightStepsCount = count;
  120267. },
  120268. enumerable: true,
  120269. configurable: true
  120270. });
  120271. Object.defineProperty(StandardRenderingPipeline.prototype, "motionBlurSamples", {
  120272. /**
  120273. * Specifies the number of samples used for the motion blur effect
  120274. * Typically in interval [16, 64]
  120275. */
  120276. get: function () {
  120277. return this._motionBlurSamples;
  120278. },
  120279. set: function (samples) {
  120280. if (this.motionBlurPostProcess) {
  120281. this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES " + samples.toFixed(1));
  120282. }
  120283. this._motionBlurSamples = samples;
  120284. },
  120285. enumerable: true,
  120286. configurable: true
  120287. });
  120288. Object.defineProperty(StandardRenderingPipeline.prototype, "samples", {
  120289. /**
  120290. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  120291. */
  120292. get: function () {
  120293. return this._samples;
  120294. },
  120295. set: function (sampleCount) {
  120296. if (this._samples === sampleCount) {
  120297. return;
  120298. }
  120299. this._samples = sampleCount;
  120300. this._buildPipeline();
  120301. },
  120302. enumerable: true,
  120303. configurable: true
  120304. });
  120305. StandardRenderingPipeline.prototype._buildPipeline = function () {
  120306. var _this = this;
  120307. var ratio = this._ratio;
  120308. var scene = this._scene;
  120309. this._disposePostProcesses();
  120310. this._reset();
  120311. // Create pass post-process
  120312. if (!this._basePostProcess) {
  120313. 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);
  120314. this.originalPostProcess.onApply = function () {
  120315. _this._currentDepthOfFieldSource = _this.originalPostProcess;
  120316. };
  120317. }
  120318. else {
  120319. this.originalPostProcess = this._basePostProcess;
  120320. }
  120321. if (this._bloomEnabled || this._vlsEnabled || this._lensFlareEnabled || this._depthOfFieldEnabled || this._motionBlurEnabled) {
  120322. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPassPostProcess", function () { return _this.originalPostProcess; }, true));
  120323. }
  120324. this._currentDepthOfFieldSource = this.originalPostProcess;
  120325. if (this._bloomEnabled) {
  120326. // Create down sample X4 post-process
  120327. this._createDownSampleX4PostProcess(scene, ratio / 2);
  120328. // Create bright pass post-process
  120329. this._createBrightPassPostProcess(scene, ratio / 2);
  120330. // Create gaussian blur post-processes (down sampling blurs)
  120331. this._createBlurPostProcesses(scene, ratio / 4, 1);
  120332. // Create texture adder post-process
  120333. this._createTextureAdderPostProcess(scene, ratio);
  120334. // Create depth-of-field source post-process
  120335. 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);
  120336. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBaseDepthOfFieldSource", function () { return _this.textureAdderFinalPostProcess; }, true));
  120337. }
  120338. if (this._vlsEnabled) {
  120339. // Create volumetric light
  120340. this._createVolumetricLightPostProcess(scene, ratio);
  120341. // Create volumetric light final post-process
  120342. 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);
  120343. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSFinal", function () { return _this.volumetricLightFinalPostProcess; }, true));
  120344. }
  120345. if (this._lensFlareEnabled) {
  120346. // Create lens flare post-process
  120347. this._createLensFlarePostProcess(scene, ratio);
  120348. // Create depth-of-field source post-process post lens-flare and disable it now
  120349. 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);
  120350. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostLensFlareDepthOfFieldSource", function () { return _this.lensFlareFinalPostProcess; }, true));
  120351. }
  120352. if (this._hdrEnabled) {
  120353. // Create luminance
  120354. this._createLuminancePostProcesses(scene, this._floatTextureType);
  120355. // Create HDR
  120356. this._createHdrPostProcess(scene, ratio);
  120357. // Create depth-of-field source post-process post hdr and disable it now
  120358. 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);
  120359. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostHDReDepthOfFieldSource", function () { return _this.hdrFinalPostProcess; }, true));
  120360. }
  120361. if (this._depthOfFieldEnabled) {
  120362. // Create gaussian blur used by depth-of-field
  120363. this._createBlurPostProcesses(scene, ratio / 2, 3, "depthOfFieldBlurWidth");
  120364. // Create depth-of-field post-process
  120365. this._createDepthOfFieldPostProcess(scene, ratio);
  120366. }
  120367. if (this._motionBlurEnabled) {
  120368. // Create motion blur post-process
  120369. this._createMotionBlurPostProcess(scene, ratio);
  120370. }
  120371. if (this._fxaaEnabled) {
  120372. // Create fxaa post-process
  120373. 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);
  120374. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRFxaa", function () { return _this.fxaaPostProcess; }, true));
  120375. }
  120376. if (this._cameras !== null) {
  120377. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  120378. }
  120379. if (!this._enableMSAAOnFirstPostProcess(this._samples) && this._samples > 1) {
  120380. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  120381. }
  120382. };
  120383. // Down Sample X4 Post-Processs
  120384. StandardRenderingPipeline.prototype._createDownSampleX4PostProcess = function (scene, ratio) {
  120385. var _this = this;
  120386. var downSampleX4Offsets = new Array(32);
  120387. 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);
  120388. this.downSampleX4PostProcess.onApply = function (effect) {
  120389. var id = 0;
  120390. var width = _this.downSampleX4PostProcess.width;
  120391. var height = _this.downSampleX4PostProcess.height;
  120392. for (var i = -2; i < 2; i++) {
  120393. for (var j = -2; j < 2; j++) {
  120394. downSampleX4Offsets[id] = (i + 0.5) * (1.0 / width);
  120395. downSampleX4Offsets[id + 1] = (j + 0.5) * (1.0 / height);
  120396. id += 2;
  120397. }
  120398. }
  120399. effect.setArray2("dsOffsets", downSampleX4Offsets);
  120400. };
  120401. // Add to pipeline
  120402. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDownSampleX4", function () { return _this.downSampleX4PostProcess; }, true));
  120403. };
  120404. // Brightpass Post-Process
  120405. StandardRenderingPipeline.prototype._createBrightPassPostProcess = function (scene, ratio) {
  120406. var _this = this;
  120407. var brightOffsets = new Array(8);
  120408. 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);
  120409. this.brightPassPostProcess.onApply = function (effect) {
  120410. var sU = (1.0 / _this.brightPassPostProcess.width);
  120411. var sV = (1.0 / _this.brightPassPostProcess.height);
  120412. brightOffsets[0] = -0.5 * sU;
  120413. brightOffsets[1] = 0.5 * sV;
  120414. brightOffsets[2] = 0.5 * sU;
  120415. brightOffsets[3] = 0.5 * sV;
  120416. brightOffsets[4] = -0.5 * sU;
  120417. brightOffsets[5] = -0.5 * sV;
  120418. brightOffsets[6] = 0.5 * sU;
  120419. brightOffsets[7] = -0.5 * sV;
  120420. effect.setArray2("dsOffsets", brightOffsets);
  120421. effect.setFloat("brightThreshold", _this.brightThreshold);
  120422. };
  120423. // Add to pipeline
  120424. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBrightPass", function () { return _this.brightPassPostProcess; }, true));
  120425. };
  120426. // Create blur H&V post-processes
  120427. StandardRenderingPipeline.prototype._createBlurPostProcesses = function (scene, ratio, indice, blurWidthKey) {
  120428. var _this = this;
  120429. if (blurWidthKey === void 0) { blurWidthKey = "blurWidth"; }
  120430. var engine = scene.getEngine();
  120431. 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);
  120432. 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);
  120433. blurX.onActivateObservable.add(function () {
  120434. var dw = blurX.width / engine.getRenderWidth();
  120435. blurX.kernel = _this[blurWidthKey] * dw;
  120436. });
  120437. blurY.onActivateObservable.add(function () {
  120438. var dw = blurY.height / engine.getRenderHeight();
  120439. blurY.kernel = _this.horizontalBlur ? 64 * dw : _this[blurWidthKey] * dw;
  120440. });
  120441. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurH" + indice, function () { return blurX; }, true));
  120442. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurV" + indice, function () { return blurY; }, true));
  120443. this.blurHPostProcesses.push(blurX);
  120444. this.blurVPostProcesses.push(blurY);
  120445. };
  120446. // Create texture adder post-process
  120447. StandardRenderingPipeline.prototype._createTextureAdderPostProcess = function (scene, ratio) {
  120448. var _this = this;
  120449. 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);
  120450. this.textureAdderPostProcess.onApply = function (effect) {
  120451. effect.setTextureFromPostProcess("otherSampler", _this._vlsEnabled ? _this._currentDepthOfFieldSource : _this.originalPostProcess);
  120452. effect.setTexture("lensSampler", _this.lensTexture);
  120453. effect.setFloat("exposure", _this._currentExposure);
  120454. _this._currentDepthOfFieldSource = _this.textureAdderFinalPostProcess;
  120455. };
  120456. // Add to pipeline
  120457. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRTextureAdder", function () { return _this.textureAdderPostProcess; }, true));
  120458. };
  120459. StandardRenderingPipeline.prototype._createVolumetricLightPostProcess = function (scene, ratio) {
  120460. var _this = this;
  120461. var geometryRenderer = scene.enableGeometryBufferRenderer();
  120462. geometryRenderer.enablePosition = true;
  120463. var geometry = geometryRenderer.getGBuffer();
  120464. // Base post-process
  120465. 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));
  120466. var depthValues = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  120467. this.volumetricLightPostProcess.onApply = function (effect) {
  120468. if (_this.sourceLight && _this.sourceLight.getShadowGenerator() && _this._scene.activeCamera) {
  120469. var generator = _this.sourceLight.getShadowGenerator();
  120470. effect.setTexture("shadowMapSampler", generator.getShadowMap());
  120471. effect.setTexture("positionSampler", geometry.textures[2]);
  120472. effect.setColor3("sunColor", _this.sourceLight.diffuse);
  120473. effect.setVector3("sunDirection", _this.sourceLight.getShadowDirection());
  120474. effect.setVector3("cameraPosition", _this._scene.activeCamera.globalPosition);
  120475. effect.setMatrix("shadowViewProjection", generator.getTransformMatrix());
  120476. effect.setFloat("scatteringCoefficient", _this.volumetricLightCoefficient);
  120477. effect.setFloat("scatteringPower", _this.volumetricLightPower);
  120478. depthValues.x = _this.sourceLight.getDepthMinZ(_this._scene.activeCamera);
  120479. depthValues.y = _this.sourceLight.getDepthMaxZ(_this._scene.activeCamera);
  120480. effect.setVector2("depthValues", depthValues);
  120481. }
  120482. };
  120483. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLS", function () { return _this.volumetricLightPostProcess; }, true));
  120484. // Smooth
  120485. this._createBlurPostProcesses(scene, ratio / 4, 0, "volumetricLightBlurScale");
  120486. // Merge
  120487. 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");
  120488. this.volumetricLightMergePostProces.onApply = function (effect) {
  120489. effect.setTextureFromPostProcess("originalSampler", _this._bloomEnabled ? _this.textureAdderFinalPostProcess : _this.originalPostProcess);
  120490. _this._currentDepthOfFieldSource = _this.volumetricLightFinalPostProcess;
  120491. };
  120492. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSMerge", function () { return _this.volumetricLightMergePostProces; }, true));
  120493. };
  120494. // Create luminance
  120495. StandardRenderingPipeline.prototype._createLuminancePostProcesses = function (scene, textureType) {
  120496. var _this = this;
  120497. // Create luminance
  120498. var size = Math.pow(3, StandardRenderingPipeline.LuminanceSteps);
  120499. 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);
  120500. var offsets = [];
  120501. this.luminancePostProcess.onApply = function (effect) {
  120502. var sU = (1.0 / _this.luminancePostProcess.width);
  120503. var sV = (1.0 / _this.luminancePostProcess.height);
  120504. offsets[0] = -0.5 * sU;
  120505. offsets[1] = 0.5 * sV;
  120506. offsets[2] = 0.5 * sU;
  120507. offsets[3] = 0.5 * sV;
  120508. offsets[4] = -0.5 * sU;
  120509. offsets[5] = -0.5 * sV;
  120510. offsets[6] = 0.5 * sU;
  120511. offsets[7] = -0.5 * sV;
  120512. effect.setArray2("lumOffsets", offsets);
  120513. };
  120514. // Add to pipeline
  120515. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminance", function () { return _this.luminancePostProcess; }, true));
  120516. // Create down sample luminance
  120517. for (var i = StandardRenderingPipeline.LuminanceSteps - 1; i >= 0; i--) {
  120518. var size = Math.pow(3, i);
  120519. var defines = "#define LUMINANCE_DOWN_SAMPLE\n";
  120520. if (i === 0) {
  120521. defines += "#define FINAL_DOWN_SAMPLER";
  120522. }
  120523. 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);
  120524. this.luminanceDownSamplePostProcesses.push(postProcess);
  120525. }
  120526. // Create callbacks and add effects
  120527. var lastLuminance = this.luminancePostProcess;
  120528. this.luminanceDownSamplePostProcesses.forEach(function (pp, index) {
  120529. var downSampleOffsets = new Array(18);
  120530. pp.onApply = function (effect) {
  120531. if (!lastLuminance) {
  120532. return;
  120533. }
  120534. var id = 0;
  120535. for (var x = -1; x < 2; x++) {
  120536. for (var y = -1; y < 2; y++) {
  120537. downSampleOffsets[id] = x / lastLuminance.width;
  120538. downSampleOffsets[id + 1] = y / lastLuminance.height;
  120539. id += 2;
  120540. }
  120541. }
  120542. effect.setArray2("dsOffsets", downSampleOffsets);
  120543. effect.setFloat("halfDestPixelSize", 0.5 / lastLuminance.width);
  120544. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  120545. lastLuminance = _this.luminancePostProcess;
  120546. }
  120547. else {
  120548. lastLuminance = pp;
  120549. }
  120550. };
  120551. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  120552. pp.onAfterRender = function () {
  120553. var pixel = scene.getEngine().readPixels(0, 0, 1, 1);
  120554. 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);
  120555. _this._hdrCurrentLuminance = (pixel[0] * bit_shift.x + pixel[1] * bit_shift.y + pixel[2] * bit_shift.z + pixel[3] * bit_shift.w) / 100.0;
  120556. };
  120557. }
  120558. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminanceDownSample" + index, function () { return pp; }, true));
  120559. });
  120560. };
  120561. // Create HDR post-process
  120562. StandardRenderingPipeline.prototype._createHdrPostProcess = function (scene, ratio) {
  120563. var _this = this;
  120564. var defines = ["#define HDR"];
  120565. if (this._hdrAutoExposure) {
  120566. defines.push("#define AUTO_EXPOSURE");
  120567. }
  120568. this.hdrPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("HDR", "standard", ["averageLuminance"], ["textureAdderSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, defines.join("\n"), _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  120569. var outputLiminance = 1;
  120570. var time = 0;
  120571. var lastTime = 0;
  120572. this.hdrPostProcess.onApply = function (effect) {
  120573. effect.setTextureFromPostProcess("textureAdderSampler", _this._currentDepthOfFieldSource);
  120574. time += scene.getEngine().getDeltaTime();
  120575. if (outputLiminance < 0) {
  120576. outputLiminance = _this._hdrCurrentLuminance;
  120577. }
  120578. else {
  120579. var dt = (lastTime - time) / 1000.0;
  120580. if (_this._hdrCurrentLuminance < outputLiminance + _this.hdrDecreaseRate * dt) {
  120581. outputLiminance += _this.hdrDecreaseRate * dt;
  120582. }
  120583. else if (_this._hdrCurrentLuminance > outputLiminance - _this.hdrIncreaseRate * dt) {
  120584. outputLiminance -= _this.hdrIncreaseRate * dt;
  120585. }
  120586. else {
  120587. outputLiminance = _this._hdrCurrentLuminance;
  120588. }
  120589. }
  120590. if (_this.hdrAutoExposure) {
  120591. _this._currentExposure = _this._fixedExposure / outputLiminance;
  120592. }
  120593. else {
  120594. outputLiminance = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(outputLiminance, _this.hdrMinimumLuminance, 1e20);
  120595. effect.setFloat("averageLuminance", outputLiminance);
  120596. }
  120597. lastTime = time;
  120598. _this._currentDepthOfFieldSource = _this.hdrFinalPostProcess;
  120599. };
  120600. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDR", function () { return _this.hdrPostProcess; }, true));
  120601. };
  120602. // Create lens flare post-process
  120603. StandardRenderingPipeline.prototype._createLensFlarePostProcess = function (scene, ratio) {
  120604. var _this = this;
  120605. 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);
  120606. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlare", function () { return _this.lensFlarePostProcess; }, true));
  120607. this._createBlurPostProcesses(scene, ratio / 4, 2);
  120608. 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);
  120609. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlareCompose", function () { return _this.lensFlareComposePostProcess; }, true));
  120610. var resolution = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  120611. // Lens flare
  120612. this.lensFlarePostProcess.onApply = function (effect) {
  120613. effect.setTextureFromPostProcess("textureSampler", _this._bloomEnabled ? _this.blurHPostProcesses[0] : _this.originalPostProcess);
  120614. effect.setTexture("lensColorSampler", _this.lensColorTexture);
  120615. effect.setFloat("strength", _this.lensFlareStrength);
  120616. effect.setFloat("ghostDispersal", _this.lensFlareGhostDispersal);
  120617. effect.setFloat("haloWidth", _this.lensFlareHaloWidth);
  120618. // Shift
  120619. resolution.x = _this.lensFlarePostProcess.width;
  120620. resolution.y = _this.lensFlarePostProcess.height;
  120621. effect.setVector2("resolution", resolution);
  120622. effect.setFloat("distortionStrength", _this.lensFlareDistortionStrength);
  120623. };
  120624. // Compose
  120625. 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);
  120626. 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);
  120627. this.lensFlareComposePostProcess.onApply = function (effect) {
  120628. if (!_this._scene.activeCamera) {
  120629. return;
  120630. }
  120631. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  120632. effect.setTexture("lensDirtSampler", _this.lensFlareDirtTexture);
  120633. effect.setTexture("lensStarSampler", _this.lensStarTexture);
  120634. // Lens start rotation matrix
  120635. var camerax = _this._scene.activeCamera.getViewMatrix().getRow(0);
  120636. var cameraz = _this._scene.activeCamera.getViewMatrix().getRow(2);
  120637. 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));
  120638. camRot *= 4.0;
  120639. 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);
  120640. var lensStarMatrix = scaleBias2.multiply(starRotation).multiply(scaleBias1);
  120641. effect.setMatrix("lensStarMatrix", lensStarMatrix);
  120642. _this._currentDepthOfFieldSource = _this.lensFlareFinalPostProcess;
  120643. };
  120644. };
  120645. // Create depth-of-field post-process
  120646. StandardRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (scene, ratio) {
  120647. var _this = this;
  120648. 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);
  120649. this.depthOfFieldPostProcess.onApply = function (effect) {
  120650. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  120651. effect.setTexture("depthSampler", _this._getDepthTexture());
  120652. effect.setFloat("distance", _this.depthOfFieldDistance);
  120653. };
  120654. // Add to pipeline
  120655. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDepthOfField", function () { return _this.depthOfFieldPostProcess; }, true));
  120656. };
  120657. // Create motion blur post-process
  120658. StandardRenderingPipeline.prototype._createMotionBlurPostProcess = function (scene, ratio) {
  120659. var _this = this;
  120660. 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);
  120661. var motionScale = 0;
  120662. var prevViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  120663. var invViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  120664. var viewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  120665. var screenSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  120666. this.motionBlurPostProcess.onApply = function (effect) {
  120667. viewProjection = scene.getProjectionMatrix().multiply(scene.getViewMatrix());
  120668. viewProjection.invertToRef(invViewProjection);
  120669. effect.setMatrix("inverseViewProjection", invViewProjection);
  120670. effect.setMatrix("prevViewProjection", prevViewProjection);
  120671. prevViewProjection = viewProjection;
  120672. screenSize.x = _this.motionBlurPostProcess.width;
  120673. screenSize.y = _this.motionBlurPostProcess.height;
  120674. effect.setVector2("screenSize", screenSize);
  120675. motionScale = scene.getEngine().getFps() / 60.0;
  120676. effect.setFloat("motionScale", motionScale);
  120677. effect.setFloat("motionStrength", _this.motionStrength);
  120678. effect.setTexture("depthSampler", _this._getDepthTexture());
  120679. };
  120680. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRMotionBlur", function () { return _this.motionBlurPostProcess; }, true));
  120681. };
  120682. StandardRenderingPipeline.prototype._getDepthTexture = function () {
  120683. if (this._scene.getEngine().getCaps().drawBuffersExtension) {
  120684. var renderer = this._scene.enableGeometryBufferRenderer();
  120685. return renderer.getGBuffer().textures[0];
  120686. }
  120687. return this._scene.enableDepthRenderer().getDepthMap();
  120688. };
  120689. StandardRenderingPipeline.prototype._disposePostProcesses = function () {
  120690. for (var i = 0; i < this._cameras.length; i++) {
  120691. var camera = this._cameras[i];
  120692. if (this.originalPostProcess) {
  120693. this.originalPostProcess.dispose(camera);
  120694. }
  120695. if (this.downSampleX4PostProcess) {
  120696. this.downSampleX4PostProcess.dispose(camera);
  120697. }
  120698. if (this.brightPassPostProcess) {
  120699. this.brightPassPostProcess.dispose(camera);
  120700. }
  120701. if (this.textureAdderPostProcess) {
  120702. this.textureAdderPostProcess.dispose(camera);
  120703. }
  120704. if (this.textureAdderFinalPostProcess) {
  120705. this.textureAdderFinalPostProcess.dispose(camera);
  120706. }
  120707. if (this.volumetricLightPostProcess) {
  120708. this.volumetricLightPostProcess.dispose(camera);
  120709. }
  120710. if (this.volumetricLightSmoothXPostProcess) {
  120711. this.volumetricLightSmoothXPostProcess.dispose(camera);
  120712. }
  120713. if (this.volumetricLightSmoothYPostProcess) {
  120714. this.volumetricLightSmoothYPostProcess.dispose(camera);
  120715. }
  120716. if (this.volumetricLightMergePostProces) {
  120717. this.volumetricLightMergePostProces.dispose(camera);
  120718. }
  120719. if (this.volumetricLightFinalPostProcess) {
  120720. this.volumetricLightFinalPostProcess.dispose(camera);
  120721. }
  120722. if (this.lensFlarePostProcess) {
  120723. this.lensFlarePostProcess.dispose(camera);
  120724. }
  120725. if (this.lensFlareComposePostProcess) {
  120726. this.lensFlareComposePostProcess.dispose(camera);
  120727. }
  120728. for (var j = 0; j < this.luminanceDownSamplePostProcesses.length; j++) {
  120729. this.luminanceDownSamplePostProcesses[j].dispose(camera);
  120730. }
  120731. if (this.luminancePostProcess) {
  120732. this.luminancePostProcess.dispose(camera);
  120733. }
  120734. if (this.hdrPostProcess) {
  120735. this.hdrPostProcess.dispose(camera);
  120736. }
  120737. if (this.hdrFinalPostProcess) {
  120738. this.hdrFinalPostProcess.dispose(camera);
  120739. }
  120740. if (this.depthOfFieldPostProcess) {
  120741. this.depthOfFieldPostProcess.dispose(camera);
  120742. }
  120743. if (this.motionBlurPostProcess) {
  120744. this.motionBlurPostProcess.dispose(camera);
  120745. }
  120746. if (this.fxaaPostProcess) {
  120747. this.fxaaPostProcess.dispose(camera);
  120748. }
  120749. for (var j = 0; j < this.blurHPostProcesses.length; j++) {
  120750. this.blurHPostProcesses[j].dispose(camera);
  120751. }
  120752. for (var j = 0; j < this.blurVPostProcesses.length; j++) {
  120753. this.blurVPostProcesses[j].dispose(camera);
  120754. }
  120755. }
  120756. this.originalPostProcess = null;
  120757. this.downSampleX4PostProcess = null;
  120758. this.brightPassPostProcess = null;
  120759. this.textureAdderPostProcess = null;
  120760. this.textureAdderFinalPostProcess = null;
  120761. this.volumetricLightPostProcess = null;
  120762. this.volumetricLightSmoothXPostProcess = null;
  120763. this.volumetricLightSmoothYPostProcess = null;
  120764. this.volumetricLightMergePostProces = null;
  120765. this.volumetricLightFinalPostProcess = null;
  120766. this.lensFlarePostProcess = null;
  120767. this.lensFlareComposePostProcess = null;
  120768. this.luminancePostProcess = null;
  120769. this.hdrPostProcess = null;
  120770. this.hdrFinalPostProcess = null;
  120771. this.depthOfFieldPostProcess = null;
  120772. this.motionBlurPostProcess = null;
  120773. this.fxaaPostProcess = null;
  120774. this.luminanceDownSamplePostProcesses = [];
  120775. this.blurHPostProcesses = [];
  120776. this.blurVPostProcesses = [];
  120777. };
  120778. /**
  120779. * Dispose of the pipeline and stop all post processes
  120780. */
  120781. StandardRenderingPipeline.prototype.dispose = function () {
  120782. this._disposePostProcesses();
  120783. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  120784. _super.prototype.dispose.call(this);
  120785. };
  120786. /**
  120787. * Serialize the rendering pipeline (Used when exporting)
  120788. * @returns the serialized object
  120789. */
  120790. StandardRenderingPipeline.prototype.serialize = function () {
  120791. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  120792. if (this.sourceLight) {
  120793. serializationObject.sourceLightId = this.sourceLight.id;
  120794. }
  120795. serializationObject.customType = "StandardRenderingPipeline";
  120796. return serializationObject;
  120797. };
  120798. /**
  120799. * Parse the serialized pipeline
  120800. * @param source Source pipeline.
  120801. * @param scene The scene to load the pipeline to.
  120802. * @param rootUrl The URL of the serialized pipeline.
  120803. * @returns An instantiated pipeline from the serialized object.
  120804. */
  120805. StandardRenderingPipeline.Parse = function (source, scene, rootUrl) {
  120806. var p = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardRenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  120807. if (source.sourceLightId) {
  120808. p.sourceLight = scene.getLightByID(source.sourceLightId);
  120809. }
  120810. return p;
  120811. };
  120812. /**
  120813. * Luminance steps
  120814. */
  120815. StandardRenderingPipeline.LuminanceSteps = 6;
  120816. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120817. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120818. ], StandardRenderingPipeline.prototype, "brightThreshold", void 0);
  120819. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120820. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120821. ], StandardRenderingPipeline.prototype, "blurWidth", void 0);
  120822. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120823. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120824. ], StandardRenderingPipeline.prototype, "horizontalBlur", void 0);
  120825. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120826. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120827. ], StandardRenderingPipeline.prototype, "exposure", null);
  120828. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120829. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensTexture")
  120830. ], StandardRenderingPipeline.prototype, "lensTexture", void 0);
  120831. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120832. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120833. ], StandardRenderingPipeline.prototype, "volumetricLightCoefficient", void 0);
  120834. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120835. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120836. ], StandardRenderingPipeline.prototype, "volumetricLightPower", void 0);
  120837. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120838. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120839. ], StandardRenderingPipeline.prototype, "volumetricLightBlurScale", void 0);
  120840. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120841. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120842. ], StandardRenderingPipeline.prototype, "hdrMinimumLuminance", void 0);
  120843. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120844. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120845. ], StandardRenderingPipeline.prototype, "hdrDecreaseRate", void 0);
  120846. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120847. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120848. ], StandardRenderingPipeline.prototype, "hdrIncreaseRate", void 0);
  120849. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120850. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120851. ], StandardRenderingPipeline.prototype, "hdrAutoExposure", null);
  120852. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120853. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensColorTexture")
  120854. ], StandardRenderingPipeline.prototype, "lensColorTexture", void 0);
  120855. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120856. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120857. ], StandardRenderingPipeline.prototype, "lensFlareStrength", void 0);
  120858. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120859. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120860. ], StandardRenderingPipeline.prototype, "lensFlareGhostDispersal", void 0);
  120861. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120862. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120863. ], StandardRenderingPipeline.prototype, "lensFlareHaloWidth", void 0);
  120864. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120865. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120866. ], StandardRenderingPipeline.prototype, "lensFlareDistortionStrength", void 0);
  120867. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120868. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensStarTexture")
  120869. ], StandardRenderingPipeline.prototype, "lensStarTexture", void 0);
  120870. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120871. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensFlareDirtTexture")
  120872. ], StandardRenderingPipeline.prototype, "lensFlareDirtTexture", void 0);
  120873. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120874. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120875. ], StandardRenderingPipeline.prototype, "depthOfFieldDistance", void 0);
  120876. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120877. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120878. ], StandardRenderingPipeline.prototype, "depthOfFieldBlurWidth", void 0);
  120879. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120880. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120881. ], StandardRenderingPipeline.prototype, "motionStrength", void 0);
  120882. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120883. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120884. ], StandardRenderingPipeline.prototype, "_ratio", void 0);
  120885. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120886. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120887. ], StandardRenderingPipeline.prototype, "BloomEnabled", null);
  120888. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120889. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120890. ], StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", null);
  120891. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120892. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120893. ], StandardRenderingPipeline.prototype, "LensFlareEnabled", null);
  120894. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120895. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120896. ], StandardRenderingPipeline.prototype, "HDREnabled", null);
  120897. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120898. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120899. ], StandardRenderingPipeline.prototype, "VLSEnabled", null);
  120900. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120901. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120902. ], StandardRenderingPipeline.prototype, "MotionBlurEnabled", null);
  120903. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120904. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120905. ], StandardRenderingPipeline.prototype, "fxaaEnabled", null);
  120906. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120907. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120908. ], StandardRenderingPipeline.prototype, "volumetricLightStepsCount", null);
  120909. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120910. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120911. ], StandardRenderingPipeline.prototype, "motionBlurSamples", null);
  120912. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120913. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120914. ], StandardRenderingPipeline.prototype, "samples", null);
  120915. return StandardRenderingPipeline;
  120916. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  120917. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardRenderingPipeline"] = StandardRenderingPipeline;
  120918. /***/ }),
  120919. /***/ "./PostProcesses/RenderPipeline/index.ts":
  120920. /*!***********************************************!*\
  120921. !*** ./PostProcesses/RenderPipeline/index.ts ***!
  120922. \***********************************************/
  120923. /*! exports provided: PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  120924. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120925. "use strict";
  120926. __webpack_require__.r(__webpack_exports__);
  120927. /* harmony import */ var _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Pipelines/index */ "./PostProcesses/RenderPipeline/Pipelines/index.ts");
  120928. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  120929. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  120930. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  120931. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  120932. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  120933. /* harmony import */ var _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  120934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]; });
  120935. /* harmony import */ var _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  120936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__["PostProcessRenderPipeline"]; });
  120937. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  120938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderPipelineManager"]; });
  120939. /* harmony import */ var _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  120940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipelineManagerSceneComponent"]; });
  120941. /***/ }),
  120942. /***/ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts":
  120943. /*!*****************************************************************!*\
  120944. !*** ./PostProcesses/RenderPipeline/postProcessRenderEffect.ts ***!
  120945. \*****************************************************************/
  120946. /*! exports provided: PostProcessRenderEffect */
  120947. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120948. "use strict";
  120949. __webpack_require__.r(__webpack_exports__);
  120950. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return PostProcessRenderEffect; });
  120951. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  120952. /**
  120953. * This represents a set of one or more post processes in Babylon.
  120954. * A post process can be used to apply a shader to a texture after it is rendered.
  120955. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  120956. */
  120957. var PostProcessRenderEffect = /** @class */ (function () {
  120958. /**
  120959. * Instantiates a post process render effect.
  120960. * A post process can be used to apply a shader to a texture after it is rendered.
  120961. * @param engine The engine the effect is tied to
  120962. * @param name The name of the effect
  120963. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  120964. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  120965. */
  120966. function PostProcessRenderEffect(engine, name, getPostProcesses, singleInstance) {
  120967. this._name = name;
  120968. this._singleInstance = singleInstance || true;
  120969. this._getPostProcesses = getPostProcesses;
  120970. this._cameras = {};
  120971. this._indicesForCamera = {};
  120972. this._postProcesses = {};
  120973. }
  120974. Object.defineProperty(PostProcessRenderEffect.prototype, "isSupported", {
  120975. /**
  120976. * Checks if all the post processes in the effect are supported.
  120977. */
  120978. get: function () {
  120979. for (var index in this._postProcesses) {
  120980. if (this._postProcesses.hasOwnProperty(index)) {
  120981. var pps = this._postProcesses[index];
  120982. for (var ppIndex = 0; ppIndex < pps.length; ppIndex++) {
  120983. if (!pps[ppIndex].isSupported) {
  120984. return false;
  120985. }
  120986. }
  120987. }
  120988. }
  120989. return true;
  120990. },
  120991. enumerable: true,
  120992. configurable: true
  120993. });
  120994. /**
  120995. * Updates the current state of the effect
  120996. * @hidden
  120997. */
  120998. PostProcessRenderEffect.prototype._update = function () {
  120999. };
  121000. /**
  121001. * Attaches the effect on cameras
  121002. * @param cameras The camera to attach to.
  121003. * @hidden
  121004. */
  121005. PostProcessRenderEffect.prototype._attachCameras = function (cameras) {
  121006. var _this = this;
  121007. var cameraKey;
  121008. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  121009. if (!cams) {
  121010. return;
  121011. }
  121012. for (var i = 0; i < cams.length; i++) {
  121013. var camera = cams[i];
  121014. var cameraName = camera.name;
  121015. if (this._singleInstance) {
  121016. cameraKey = 0;
  121017. }
  121018. else {
  121019. cameraKey = cameraName;
  121020. }
  121021. if (!this._postProcesses[cameraKey]) {
  121022. var postProcess = this._getPostProcesses();
  121023. if (postProcess) {
  121024. this._postProcesses[cameraKey] = Array.isArray(postProcess) ? postProcess : [postProcess];
  121025. }
  121026. }
  121027. if (!this._indicesForCamera[cameraName]) {
  121028. this._indicesForCamera[cameraName] = [];
  121029. }
  121030. this._postProcesses[cameraKey].forEach(function (postProcess) {
  121031. var index = camera.attachPostProcess(postProcess);
  121032. _this._indicesForCamera[cameraName].push(index);
  121033. });
  121034. if (!this._cameras[cameraName]) {
  121035. this._cameras[cameraName] = camera;
  121036. }
  121037. }
  121038. };
  121039. /**
  121040. * Detatches the effect on cameras
  121041. * @param cameras The camera to detatch from.
  121042. * @hidden
  121043. */
  121044. PostProcessRenderEffect.prototype._detachCameras = function (cameras) {
  121045. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  121046. if (!cams) {
  121047. return;
  121048. }
  121049. for (var i = 0; i < cams.length; i++) {
  121050. var camera = cams[i];
  121051. var cameraName = camera.name;
  121052. var postProcesses = this._postProcesses[this._singleInstance ? 0 : cameraName];
  121053. if (postProcesses) {
  121054. postProcesses.forEach(function (postProcess) {
  121055. camera.detachPostProcess(postProcess);
  121056. });
  121057. }
  121058. if (this._cameras[cameraName]) {
  121059. this._cameras[cameraName] = null;
  121060. }
  121061. }
  121062. };
  121063. /**
  121064. * Enables the effect on given cameras
  121065. * @param cameras The camera to enable.
  121066. * @hidden
  121067. */
  121068. PostProcessRenderEffect.prototype._enable = function (cameras) {
  121069. var _this = this;
  121070. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  121071. if (!cams) {
  121072. return;
  121073. }
  121074. for (var i = 0; i < cams.length; i++) {
  121075. var camera = cams[i];
  121076. var cameraName = camera.name;
  121077. for (var j = 0; j < this._indicesForCamera[cameraName].length; j++) {
  121078. if (camera._postProcesses[this._indicesForCamera[cameraName][j]] === undefined || camera._postProcesses[this._indicesForCamera[cameraName][j]] === null) {
  121079. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  121080. cams[i].attachPostProcess(postProcess, _this._indicesForCamera[cameraName][j]);
  121081. });
  121082. }
  121083. }
  121084. }
  121085. };
  121086. /**
  121087. * Disables the effect on the given cameras
  121088. * @param cameras The camera to disable.
  121089. * @hidden
  121090. */
  121091. PostProcessRenderEffect.prototype._disable = function (cameras) {
  121092. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  121093. if (!cams) {
  121094. return;
  121095. }
  121096. for (var i = 0; i < cams.length; i++) {
  121097. var camera = cams[i];
  121098. var cameraName = camera.name;
  121099. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  121100. camera.detachPostProcess(postProcess);
  121101. });
  121102. }
  121103. };
  121104. /**
  121105. * Gets a list of the post processes contained in the effect.
  121106. * @param camera The camera to get the post processes on.
  121107. * @returns The list of the post processes in the effect.
  121108. */
  121109. PostProcessRenderEffect.prototype.getPostProcesses = function (camera) {
  121110. if (this._singleInstance) {
  121111. return this._postProcesses[0];
  121112. }
  121113. else {
  121114. if (!camera) {
  121115. return null;
  121116. }
  121117. return this._postProcesses[camera.name];
  121118. }
  121119. };
  121120. return PostProcessRenderEffect;
  121121. }());
  121122. /***/ }),
  121123. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts":
  121124. /*!*******************************************************************!*\
  121125. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts ***!
  121126. \*******************************************************************/
  121127. /*! exports provided: PostProcessRenderPipeline */
  121128. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121129. "use strict";
  121130. __webpack_require__.r(__webpack_exports__);
  121131. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return PostProcessRenderPipeline; });
  121132. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121133. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  121134. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  121135. /**
  121136. * PostProcessRenderPipeline
  121137. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121138. */
  121139. var PostProcessRenderPipeline = /** @class */ (function () {
  121140. /**
  121141. * Initializes a PostProcessRenderPipeline
  121142. * @param engine engine to add the pipeline to
  121143. * @param name name of the pipeline
  121144. */
  121145. function PostProcessRenderPipeline(engine, name) {
  121146. this.engine = engine;
  121147. this._name = name;
  121148. this._renderEffects = {};
  121149. this._renderEffectsForIsolatedPass = new Array();
  121150. this._cameras = [];
  121151. }
  121152. Object.defineProperty(PostProcessRenderPipeline.prototype, "name", {
  121153. /**
  121154. * Gets pipeline name
  121155. */
  121156. get: function () {
  121157. return this._name;
  121158. },
  121159. enumerable: true,
  121160. configurable: true
  121161. });
  121162. /**
  121163. * Gets the class name
  121164. * @returns "PostProcessRenderPipeline"
  121165. */
  121166. PostProcessRenderPipeline.prototype.getClassName = function () {
  121167. return "PostProcessRenderPipeline";
  121168. };
  121169. Object.defineProperty(PostProcessRenderPipeline.prototype, "isSupported", {
  121170. /**
  121171. * If all the render effects in the pipeline are supported
  121172. */
  121173. get: function () {
  121174. for (var renderEffectName in this._renderEffects) {
  121175. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  121176. if (!this._renderEffects[renderEffectName].isSupported) {
  121177. return false;
  121178. }
  121179. }
  121180. }
  121181. return true;
  121182. },
  121183. enumerable: true,
  121184. configurable: true
  121185. });
  121186. /**
  121187. * Adds an effect to the pipeline
  121188. * @param renderEffect the effect to add
  121189. */
  121190. PostProcessRenderPipeline.prototype.addEffect = function (renderEffect) {
  121191. this._renderEffects[renderEffect._name] = renderEffect;
  121192. };
  121193. // private
  121194. /** @hidden */
  121195. PostProcessRenderPipeline.prototype._rebuild = function () {
  121196. };
  121197. /** @hidden */
  121198. PostProcessRenderPipeline.prototype._enableEffect = function (renderEffectName, cameras) {
  121199. var renderEffects = this._renderEffects[renderEffectName];
  121200. if (!renderEffects) {
  121201. return;
  121202. }
  121203. renderEffects._enable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  121204. };
  121205. /** @hidden */
  121206. PostProcessRenderPipeline.prototype._disableEffect = function (renderEffectName, cameras) {
  121207. var renderEffects = this._renderEffects[renderEffectName];
  121208. if (!renderEffects) {
  121209. return;
  121210. }
  121211. renderEffects._disable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  121212. };
  121213. /** @hidden */
  121214. PostProcessRenderPipeline.prototype._attachCameras = function (cameras, unique) {
  121215. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  121216. if (!cams) {
  121217. return;
  121218. }
  121219. var indicesToDelete = [];
  121220. var i;
  121221. for (i = 0; i < cams.length; i++) {
  121222. var camera = cams[i];
  121223. var cameraName = camera.name;
  121224. if (this._cameras.indexOf(camera) === -1) {
  121225. this._cameras[cameraName] = camera;
  121226. }
  121227. else if (unique) {
  121228. indicesToDelete.push(i);
  121229. }
  121230. }
  121231. for (i = 0; i < indicesToDelete.length; i++) {
  121232. cameras.splice(indicesToDelete[i], 1);
  121233. }
  121234. for (var renderEffectName in this._renderEffects) {
  121235. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  121236. this._renderEffects[renderEffectName]._attachCameras(cams);
  121237. }
  121238. }
  121239. };
  121240. /** @hidden */
  121241. PostProcessRenderPipeline.prototype._detachCameras = function (cameras) {
  121242. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  121243. if (!cams) {
  121244. return;
  121245. }
  121246. for (var renderEffectName in this._renderEffects) {
  121247. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  121248. this._renderEffects[renderEffectName]._detachCameras(cams);
  121249. }
  121250. }
  121251. for (var i = 0; i < cams.length; i++) {
  121252. this._cameras.splice(this._cameras.indexOf(cams[i]), 1);
  121253. }
  121254. };
  121255. /** @hidden */
  121256. PostProcessRenderPipeline.prototype._update = function () {
  121257. for (var renderEffectName in this._renderEffects) {
  121258. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  121259. this._renderEffects[renderEffectName]._update();
  121260. }
  121261. }
  121262. for (var i = 0; i < this._cameras.length; i++) {
  121263. var cameraName = this._cameras[i].name;
  121264. if (this._renderEffectsForIsolatedPass[cameraName]) {
  121265. this._renderEffectsForIsolatedPass[cameraName]._update();
  121266. }
  121267. }
  121268. };
  121269. /** @hidden */
  121270. PostProcessRenderPipeline.prototype._reset = function () {
  121271. this._renderEffects = {};
  121272. this._renderEffectsForIsolatedPass = new Array();
  121273. };
  121274. PostProcessRenderPipeline.prototype._enableMSAAOnFirstPostProcess = function (sampleCount) {
  121275. // 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)
  121276. var effectKeys = Object.keys(this._renderEffects);
  121277. if (this.engine.webGLVersion === 1) {
  121278. return false;
  121279. }
  121280. if (effectKeys.length > 0) {
  121281. var postProcesses = this._renderEffects[effectKeys[0]].getPostProcesses();
  121282. if (postProcesses) {
  121283. postProcesses[0].samples = sampleCount;
  121284. }
  121285. }
  121286. return true;
  121287. };
  121288. /**
  121289. * Disposes of the pipeline
  121290. */
  121291. PostProcessRenderPipeline.prototype.dispose = function () {
  121292. // Must be implemented by children
  121293. };
  121294. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121295. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  121296. ], PostProcessRenderPipeline.prototype, "_name", void 0);
  121297. return PostProcessRenderPipeline;
  121298. }());
  121299. /***/ }),
  121300. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts":
  121301. /*!**************************************************************************!*\
  121302. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts ***!
  121303. \**************************************************************************/
  121304. /*! exports provided: PostProcessRenderPipelineManager */
  121305. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121306. "use strict";
  121307. __webpack_require__.r(__webpack_exports__);
  121308. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return PostProcessRenderPipelineManager; });
  121309. /**
  121310. * PostProcessRenderPipelineManager class
  121311. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121312. */
  121313. var PostProcessRenderPipelineManager = /** @class */ (function () {
  121314. /**
  121315. * Initializes a PostProcessRenderPipelineManager
  121316. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121317. */
  121318. function PostProcessRenderPipelineManager() {
  121319. this._renderPipelines = {};
  121320. }
  121321. Object.defineProperty(PostProcessRenderPipelineManager.prototype, "supportedPipelines", {
  121322. /**
  121323. * Gets the list of supported render pipelines
  121324. */
  121325. get: function () {
  121326. var result = [];
  121327. for (var renderPipelineName in this._renderPipelines) {
  121328. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  121329. var pipeline = this._renderPipelines[renderPipelineName];
  121330. if (pipeline.isSupported) {
  121331. result.push(pipeline);
  121332. }
  121333. }
  121334. }
  121335. return result;
  121336. },
  121337. enumerable: true,
  121338. configurable: true
  121339. });
  121340. /**
  121341. * Adds a pipeline to the manager
  121342. * @param renderPipeline The pipeline to add
  121343. */
  121344. PostProcessRenderPipelineManager.prototype.addPipeline = function (renderPipeline) {
  121345. this._renderPipelines[renderPipeline._name] = renderPipeline;
  121346. };
  121347. /**
  121348. * Attaches a camera to the pipeline
  121349. * @param renderPipelineName The name of the pipeline to attach to
  121350. * @param cameras the camera to attach
  121351. * @param unique if the camera can be attached multiple times to the pipeline
  121352. */
  121353. PostProcessRenderPipelineManager.prototype.attachCamerasToRenderPipeline = function (renderPipelineName, cameras, unique) {
  121354. if (unique === void 0) { unique = false; }
  121355. var renderPipeline = this._renderPipelines[renderPipelineName];
  121356. if (!renderPipeline) {
  121357. return;
  121358. }
  121359. renderPipeline._attachCameras(cameras, unique);
  121360. };
  121361. /**
  121362. * Detaches a camera from the pipeline
  121363. * @param renderPipelineName The name of the pipeline to detach from
  121364. * @param cameras the camera to detach
  121365. */
  121366. PostProcessRenderPipelineManager.prototype.detachCamerasFromRenderPipeline = function (renderPipelineName, cameras) {
  121367. var renderPipeline = this._renderPipelines[renderPipelineName];
  121368. if (!renderPipeline) {
  121369. return;
  121370. }
  121371. renderPipeline._detachCameras(cameras);
  121372. };
  121373. /**
  121374. * Enables an effect by name on a pipeline
  121375. * @param renderPipelineName the name of the pipeline to enable the effect in
  121376. * @param renderEffectName the name of the effect to enable
  121377. * @param cameras the cameras that the effect should be enabled on
  121378. */
  121379. PostProcessRenderPipelineManager.prototype.enableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  121380. var renderPipeline = this._renderPipelines[renderPipelineName];
  121381. if (!renderPipeline) {
  121382. return;
  121383. }
  121384. renderPipeline._enableEffect(renderEffectName, cameras);
  121385. };
  121386. /**
  121387. * Disables an effect by name on a pipeline
  121388. * @param renderPipelineName the name of the pipeline to disable the effect in
  121389. * @param renderEffectName the name of the effect to disable
  121390. * @param cameras the cameras that the effect should be disabled on
  121391. */
  121392. PostProcessRenderPipelineManager.prototype.disableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  121393. var renderPipeline = this._renderPipelines[renderPipelineName];
  121394. if (!renderPipeline) {
  121395. return;
  121396. }
  121397. renderPipeline._disableEffect(renderEffectName, cameras);
  121398. };
  121399. /**
  121400. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  121401. */
  121402. PostProcessRenderPipelineManager.prototype.update = function () {
  121403. for (var renderPipelineName in this._renderPipelines) {
  121404. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  121405. var pipeline = this._renderPipelines[renderPipelineName];
  121406. if (!pipeline.isSupported) {
  121407. pipeline.dispose();
  121408. delete this._renderPipelines[renderPipelineName];
  121409. }
  121410. else {
  121411. pipeline._update();
  121412. }
  121413. }
  121414. }
  121415. };
  121416. /** @hidden */
  121417. PostProcessRenderPipelineManager.prototype._rebuild = function () {
  121418. for (var renderPipelineName in this._renderPipelines) {
  121419. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  121420. var pipeline = this._renderPipelines[renderPipelineName];
  121421. pipeline._rebuild();
  121422. }
  121423. }
  121424. };
  121425. /**
  121426. * Disposes of the manager and pipelines
  121427. */
  121428. PostProcessRenderPipelineManager.prototype.dispose = function () {
  121429. for (var renderPipelineName in this._renderPipelines) {
  121430. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  121431. var pipeline = this._renderPipelines[renderPipelineName];
  121432. pipeline.dispose();
  121433. }
  121434. }
  121435. };
  121436. return PostProcessRenderPipelineManager;
  121437. }());
  121438. /***/ }),
  121439. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts":
  121440. /*!****************************************************************************************!*\
  121441. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts ***!
  121442. \****************************************************************************************/
  121443. /*! exports provided: PostProcessRenderPipelineManagerSceneComponent */
  121444. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121445. "use strict";
  121446. __webpack_require__.r(__webpack_exports__);
  121447. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return PostProcessRenderPipelineManagerSceneComponent; });
  121448. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  121449. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  121450. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  121451. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype, "postProcessRenderPipelineManager", {
  121452. get: function () {
  121453. if (!this._postProcessRenderPipelineManager) {
  121454. // Register the G Buffer component to the scene.
  121455. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER);
  121456. if (!component) {
  121457. component = new PostProcessRenderPipelineManagerSceneComponent(this);
  121458. this._addComponent(component);
  121459. }
  121460. this._postProcessRenderPipelineManager = new _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderPipelineManager"]();
  121461. }
  121462. return this._postProcessRenderPipelineManager;
  121463. },
  121464. enumerable: true,
  121465. configurable: true
  121466. });
  121467. /**
  121468. * Defines the Render Pipeline scene component responsible to rendering pipelines
  121469. */
  121470. var PostProcessRenderPipelineManagerSceneComponent = /** @class */ (function () {
  121471. /**
  121472. * Creates a new instance of the component for the given scene
  121473. * @param scene Defines the scene to register the component in
  121474. */
  121475. function PostProcessRenderPipelineManagerSceneComponent(scene) {
  121476. /**
  121477. * The component name helpfull to identify the component in the list of scene components.
  121478. */
  121479. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER;
  121480. this.scene = scene;
  121481. }
  121482. /**
  121483. * Registers the component in a given scene
  121484. */
  121485. PostProcessRenderPipelineManagerSceneComponent.prototype.register = function () {
  121486. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER, this, this._gatherRenderTargets);
  121487. };
  121488. /**
  121489. * Rebuilds the elements related to this component in case of
  121490. * context lost for instance.
  121491. */
  121492. PostProcessRenderPipelineManagerSceneComponent.prototype.rebuild = function () {
  121493. if (this.scene._postProcessRenderPipelineManager) {
  121494. this.scene._postProcessRenderPipelineManager._rebuild();
  121495. }
  121496. };
  121497. /**
  121498. * Disposes the component and the associated ressources
  121499. */
  121500. PostProcessRenderPipelineManagerSceneComponent.prototype.dispose = function () {
  121501. if (this.scene._postProcessRenderPipelineManager) {
  121502. this.scene._postProcessRenderPipelineManager.dispose();
  121503. }
  121504. };
  121505. PostProcessRenderPipelineManagerSceneComponent.prototype._gatherRenderTargets = function () {
  121506. if (this.scene._postProcessRenderPipelineManager) {
  121507. this.scene._postProcessRenderPipelineManager.update();
  121508. }
  121509. };
  121510. return PostProcessRenderPipelineManagerSceneComponent;
  121511. }());
  121512. /***/ }),
  121513. /***/ "./PostProcesses/anaglyphPostProcess.ts":
  121514. /*!**********************************************!*\
  121515. !*** ./PostProcesses/anaglyphPostProcess.ts ***!
  121516. \**********************************************/
  121517. /*! exports provided: AnaglyphPostProcess */
  121518. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121519. "use strict";
  121520. __webpack_require__.r(__webpack_exports__);
  121521. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return AnaglyphPostProcess; });
  121522. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121523. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121524. /* harmony import */ var _Shaders_anaglyph_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/anaglyph.fragment */ "./Shaders/anaglyph.fragment.ts");
  121525. /**
  121526. * Postprocess used to generate anaglyphic rendering
  121527. */
  121528. var AnaglyphPostProcess = /** @class */ (function (_super) {
  121529. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphPostProcess, _super);
  121530. /**
  121531. * Creates a new AnaglyphPostProcess
  121532. * @param name defines postprocess name
  121533. * @param options defines creation options or target ratio scale
  121534. * @param rigCameras defines cameras using this postprocess
  121535. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  121536. * @param engine defines hosting engine
  121537. * @param reusable defines if the postprocess will be reused multiple times per frame
  121538. */
  121539. function AnaglyphPostProcess(name, options, rigCameras, samplingMode, engine, reusable) {
  121540. var _this = _super.call(this, name, "anaglyph", null, ["leftSampler"], options, rigCameras[1], samplingMode, engine, reusable) || this;
  121541. _this._passedProcess = rigCameras[0]._rigPostProcess;
  121542. _this.onApplyObservable.add(function (effect) {
  121543. effect.setTextureFromPostProcess("leftSampler", _this._passedProcess);
  121544. });
  121545. return _this;
  121546. }
  121547. return AnaglyphPostProcess;
  121548. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  121549. /***/ }),
  121550. /***/ "./PostProcesses/blackAndWhitePostProcess.ts":
  121551. /*!***************************************************!*\
  121552. !*** ./PostProcesses/blackAndWhitePostProcess.ts ***!
  121553. \***************************************************/
  121554. /*! exports provided: BlackAndWhitePostProcess */
  121555. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121556. "use strict";
  121557. __webpack_require__.r(__webpack_exports__);
  121558. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return BlackAndWhitePostProcess; });
  121559. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121560. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121561. /* harmony import */ var _Shaders_blackAndWhite_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/blackAndWhite.fragment */ "./Shaders/blackAndWhite.fragment.ts");
  121562. /**
  121563. * Post process used to render in black and white
  121564. */
  121565. var BlackAndWhitePostProcess = /** @class */ (function (_super) {
  121566. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlackAndWhitePostProcess, _super);
  121567. /**
  121568. * Creates a black and white post process
  121569. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  121570. * @param name The name of the effect.
  121571. * @param options The required width/height ratio to downsize to before computing the render pass.
  121572. * @param camera The camera to apply the render pass to.
  121573. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121574. * @param engine The engine which the post process will be applied. (default: current engine)
  121575. * @param reusable If the post process can be reused on the same frame. (default: false)
  121576. */
  121577. function BlackAndWhitePostProcess(name, options, camera, samplingMode, engine, reusable) {
  121578. var _this = _super.call(this, name, "blackAndWhite", ["degree"], null, options, camera, samplingMode, engine, reusable) || this;
  121579. /**
  121580. * Linear about to convert he result to black and white (default: 1)
  121581. */
  121582. _this.degree = 1;
  121583. _this.onApplyObservable.add(function (effect) {
  121584. effect.setFloat("degree", _this.degree);
  121585. });
  121586. return _this;
  121587. }
  121588. return BlackAndWhitePostProcess;
  121589. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  121590. /***/ }),
  121591. /***/ "./PostProcesses/bloomEffect.ts":
  121592. /*!**************************************!*\
  121593. !*** ./PostProcesses/bloomEffect.ts ***!
  121594. \**************************************/
  121595. /*! exports provided: BloomEffect */
  121596. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121597. "use strict";
  121598. __webpack_require__.r(__webpack_exports__);
  121599. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return BloomEffect; });
  121600. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121601. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  121602. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  121603. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  121604. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  121605. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  121606. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  121607. /**
  121608. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  121609. */
  121610. var BloomEffect = /** @class */ (function (_super) {
  121611. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomEffect, _super);
  121612. /**
  121613. * Creates a new instance of @see BloomEffect
  121614. * @param scene The scene the effect belongs to.
  121615. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  121616. * @param bloomKernel The size of the kernel to be used when applying the blur.
  121617. * @param bloomWeight The the strength of bloom.
  121618. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  121619. * @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)
  121620. */
  121621. function BloomEffect(scene, bloomScale, bloomWeight, bloomKernel, pipelineTextureType, blockCompilation) {
  121622. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  121623. if (blockCompilation === void 0) { blockCompilation = false; }
  121624. var _this = _super.call(this, scene.getEngine(), "bloom", function () {
  121625. return _this._effects;
  121626. }, true) || this;
  121627. _this.bloomScale = bloomScale;
  121628. /**
  121629. * @hidden Internal
  121630. */
  121631. _this._effects = [];
  121632. _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);
  121633. _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);
  121634. _this._blurX.alwaysForcePOT = true;
  121635. _this._blurX.autoClear = false;
  121636. _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);
  121637. _this._blurY.alwaysForcePOT = true;
  121638. _this._blurY.autoClear = false;
  121639. _this.kernel = bloomKernel;
  121640. _this._effects = [_this._downscale, _this._blurX, _this._blurY];
  121641. _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);
  121642. _this._merge.autoClear = false;
  121643. _this._effects.push(_this._merge);
  121644. return _this;
  121645. }
  121646. Object.defineProperty(BloomEffect.prototype, "threshold", {
  121647. /**
  121648. * The luminance threshold to find bright areas of the image to bloom.
  121649. */
  121650. get: function () {
  121651. return this._downscale.threshold;
  121652. },
  121653. set: function (value) {
  121654. this._downscale.threshold = value;
  121655. },
  121656. enumerable: true,
  121657. configurable: true
  121658. });
  121659. Object.defineProperty(BloomEffect.prototype, "weight", {
  121660. /**
  121661. * The strength of the bloom.
  121662. */
  121663. get: function () {
  121664. return this._merge.weight;
  121665. },
  121666. set: function (value) {
  121667. this._merge.weight = value;
  121668. },
  121669. enumerable: true,
  121670. configurable: true
  121671. });
  121672. Object.defineProperty(BloomEffect.prototype, "kernel", {
  121673. /**
  121674. * Specifies the size of the bloom blur kernel, relative to the final output size
  121675. */
  121676. get: function () {
  121677. return this._blurX.kernel / this.bloomScale;
  121678. },
  121679. set: function (value) {
  121680. this._blurX.kernel = value * this.bloomScale;
  121681. this._blurY.kernel = value * this.bloomScale;
  121682. },
  121683. enumerable: true,
  121684. configurable: true
  121685. });
  121686. /**
  121687. * Disposes each of the internal effects for a given camera.
  121688. * @param camera The camera to dispose the effect on.
  121689. */
  121690. BloomEffect.prototype.disposeEffects = function (camera) {
  121691. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  121692. this._effects[effectIndex].dispose(camera);
  121693. }
  121694. };
  121695. /**
  121696. * @hidden Internal
  121697. */
  121698. BloomEffect.prototype._updateEffects = function () {
  121699. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  121700. this._effects[effectIndex].updateEffect();
  121701. }
  121702. };
  121703. /**
  121704. * Internal
  121705. * @returns if all the contained post processes are ready.
  121706. * @hidden
  121707. */
  121708. BloomEffect.prototype._isReady = function () {
  121709. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  121710. if (!this._effects[effectIndex].isReady()) {
  121711. return false;
  121712. }
  121713. }
  121714. return true;
  121715. };
  121716. return BloomEffect;
  121717. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]));
  121718. /***/ }),
  121719. /***/ "./PostProcesses/bloomMergePostProcess.ts":
  121720. /*!************************************************!*\
  121721. !*** ./PostProcesses/bloomMergePostProcess.ts ***!
  121722. \************************************************/
  121723. /*! exports provided: BloomMergePostProcess */
  121724. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121725. "use strict";
  121726. __webpack_require__.r(__webpack_exports__);
  121727. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return BloomMergePostProcess; });
  121728. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121729. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121730. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121731. /* harmony import */ var _Shaders_bloomMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/bloomMerge.fragment */ "./Shaders/bloomMerge.fragment.ts");
  121732. /**
  121733. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  121734. */
  121735. var BloomMergePostProcess = /** @class */ (function (_super) {
  121736. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomMergePostProcess, _super);
  121737. /**
  121738. * Creates a new instance of @see BloomMergePostProcess
  121739. * @param name The name of the effect.
  121740. * @param originalFromInput Post process which's input will be used for the merge.
  121741. * @param blurred Blurred highlights post process which's output will be used.
  121742. * @param weight Weight of the bloom to be added to the original input.
  121743. * @param options The required width/height ratio to downsize to before computing the render pass.
  121744. * @param camera The camera to apply the render pass to.
  121745. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121746. * @param engine The engine which the post process will be applied. (default: current engine)
  121747. * @param reusable If the post process can be reused on the same frame. (default: false)
  121748. * @param textureType Type of textures used when performing the post process. (default: 0)
  121749. * @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)
  121750. */
  121751. function BloomMergePostProcess(name, originalFromInput, blurred,
  121752. /** Weight of the bloom to be added to the original input. */
  121753. weight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  121754. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  121755. if (blockCompilation === void 0) { blockCompilation = false; }
  121756. var _this = _super.call(this, name, "bloomMerge", ["bloomWeight"], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2", "bloomBlur"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  121757. _this.weight = weight;
  121758. _this.onApplyObservable.add(function (effect) {
  121759. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  121760. effect.setTextureFromPostProcessOutput("bloomBlur", blurred);
  121761. effect.setFloat("bloomWeight", _this.weight);
  121762. });
  121763. if (!blockCompilation) {
  121764. _this.updateEffect();
  121765. }
  121766. return _this;
  121767. }
  121768. return BloomMergePostProcess;
  121769. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  121770. /***/ }),
  121771. /***/ "./PostProcesses/blurPostProcess.ts":
  121772. /*!******************************************!*\
  121773. !*** ./PostProcesses/blurPostProcess.ts ***!
  121774. \******************************************/
  121775. /*! exports provided: BlurPostProcess */
  121776. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121777. "use strict";
  121778. __webpack_require__.r(__webpack_exports__);
  121779. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return BlurPostProcess; });
  121780. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121781. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121782. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  121783. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121784. /* harmony import */ var _Shaders_kernelBlur_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/kernelBlur.fragment */ "./Shaders/kernelBlur.fragment.ts");
  121785. /* harmony import */ var _Shaders_kernelBlur_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/kernelBlur.vertex */ "./Shaders/kernelBlur.vertex.ts");
  121786. /**
  121787. * The Blur Post Process which blurs an image based on a kernel and direction.
  121788. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  121789. */
  121790. var BlurPostProcess = /** @class */ (function (_super) {
  121791. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlurPostProcess, _super);
  121792. /**
  121793. * Creates a new instance BlurPostProcess
  121794. * @param name The name of the effect.
  121795. * @param direction The direction in which to blur the image.
  121796. * @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.
  121797. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  121798. * @param camera The camera to apply the render pass to.
  121799. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121800. * @param engine The engine which the post process will be applied. (default: current engine)
  121801. * @param reusable If the post process can be reused on the same frame. (default: false)
  121802. * @param textureType Type of textures used when performing the post process. (default: 0)
  121803. * @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)
  121804. */
  121805. function BlurPostProcess(name,
  121806. /** The direction in which to blur the image. */
  121807. direction, kernel, options, camera, samplingMode, engine, reusable, textureType, defines, blockCompilation) {
  121808. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  121809. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  121810. if (defines === void 0) { defines = ""; }
  121811. if (blockCompilation === void 0) { blockCompilation = false; }
  121812. 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;
  121813. _this.direction = direction;
  121814. _this.blockCompilation = blockCompilation;
  121815. _this._packedFloat = false;
  121816. _this._staticDefines = "";
  121817. _this._staticDefines = defines;
  121818. _this.onApplyObservable.add(function (effect) {
  121819. if (_this._outputTexture) {
  121820. effect.setFloat2('delta', (1 / _this._outputTexture.width) * _this.direction.x, (1 / _this._outputTexture.height) * _this.direction.y);
  121821. }
  121822. else {
  121823. effect.setFloat2('delta', (1 / _this.width) * _this.direction.x, (1 / _this.height) * _this.direction.y);
  121824. }
  121825. });
  121826. _this.kernel = kernel;
  121827. return _this;
  121828. }
  121829. Object.defineProperty(BlurPostProcess.prototype, "kernel", {
  121830. /**
  121831. * Gets the length in pixels of the blur sample region
  121832. */
  121833. get: function () {
  121834. return this._idealKernel;
  121835. },
  121836. /**
  121837. * Sets the length in pixels of the blur sample region
  121838. */
  121839. set: function (v) {
  121840. if (this._idealKernel === v) {
  121841. return;
  121842. }
  121843. v = Math.max(v, 1);
  121844. this._idealKernel = v;
  121845. this._kernel = this._nearestBestKernel(v);
  121846. if (!this.blockCompilation) {
  121847. this._updateParameters();
  121848. }
  121849. },
  121850. enumerable: true,
  121851. configurable: true
  121852. });
  121853. Object.defineProperty(BlurPostProcess.prototype, "packedFloat", {
  121854. /**
  121855. * Gets wether or not the blur is unpacking/repacking floats
  121856. */
  121857. get: function () {
  121858. return this._packedFloat;
  121859. },
  121860. /**
  121861. * Sets wether or not the blur needs to unpack/repack floats
  121862. */
  121863. set: function (v) {
  121864. if (this._packedFloat === v) {
  121865. return;
  121866. }
  121867. this._packedFloat = v;
  121868. if (!this.blockCompilation) {
  121869. this._updateParameters();
  121870. }
  121871. },
  121872. enumerable: true,
  121873. configurable: true
  121874. });
  121875. /**
  121876. * Updates the effect with the current post process compile time values and recompiles the shader.
  121877. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  121878. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  121879. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  121880. * @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
  121881. * @param onCompiled Called when the shader has been compiled.
  121882. * @param onError Called if there is an error when compiling a shader.
  121883. */
  121884. BlurPostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  121885. if (defines === void 0) { defines = null; }
  121886. if (uniforms === void 0) { uniforms = null; }
  121887. if (samplers === void 0) { samplers = null; }
  121888. this._updateParameters(onCompiled, onError);
  121889. };
  121890. BlurPostProcess.prototype._updateParameters = function (onCompiled, onError) {
  121891. // Generate sampling offsets and weights
  121892. var N = this._kernel;
  121893. var centerIndex = (N - 1) / 2;
  121894. // Generate Gaussian sampling weights over kernel
  121895. var offsets = [];
  121896. var weights = [];
  121897. var totalWeight = 0;
  121898. for (var i = 0; i < N; i++) {
  121899. var u = i / (N - 1);
  121900. var w = this._gaussianWeight(u * 2.0 - 1);
  121901. offsets[i] = (i - centerIndex);
  121902. weights[i] = w;
  121903. totalWeight += w;
  121904. }
  121905. // Normalize weights
  121906. for (var i = 0; i < weights.length; i++) {
  121907. weights[i] /= totalWeight;
  121908. }
  121909. // Optimize: combine samples to take advantage of hardware linear sampling
  121910. // Walk from left to center, combining pairs (symmetrically)
  121911. var linearSamplingWeights = [];
  121912. var linearSamplingOffsets = [];
  121913. var linearSamplingMap = [];
  121914. for (var i = 0; i <= centerIndex; i += 2) {
  121915. var j = Math.min(i + 1, Math.floor(centerIndex));
  121916. var singleCenterSample = i === j;
  121917. if (singleCenterSample) {
  121918. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  121919. }
  121920. else {
  121921. var sharedCell = j === centerIndex;
  121922. var weightLinear = (weights[i] + weights[j] * (sharedCell ? .5 : 1.));
  121923. var offsetLinear = offsets[i] + 1 / (1 + weights[i] / weights[j]);
  121924. if (offsetLinear === 0) {
  121925. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  121926. linearSamplingMap.push({ o: offsets[i + 1], w: weights[i + 1] });
  121927. }
  121928. else {
  121929. linearSamplingMap.push({ o: offsetLinear, w: weightLinear });
  121930. linearSamplingMap.push({ o: -offsetLinear, w: weightLinear });
  121931. }
  121932. }
  121933. }
  121934. for (var i = 0; i < linearSamplingMap.length; i++) {
  121935. linearSamplingOffsets[i] = linearSamplingMap[i].o;
  121936. linearSamplingWeights[i] = linearSamplingMap[i].w;
  121937. }
  121938. // Replace with optimized
  121939. offsets = linearSamplingOffsets;
  121940. weights = linearSamplingWeights;
  121941. // Generate shaders
  121942. var maxVaryingRows = this.getEngine().getCaps().maxVaryingVectors;
  121943. var freeVaryingVec2 = Math.max(maxVaryingRows, 0.) - 1; // Because of sampleCenter
  121944. var varyingCount = Math.min(offsets.length, freeVaryingVec2);
  121945. var defines = "";
  121946. defines += this._staticDefines;
  121947. // The DOF fragment should ignore the center pixel when looping as it is handled manualy in the fragment shader.
  121948. if (this._staticDefines.indexOf("DOF") != -1) {
  121949. defines += "#define CENTER_WEIGHT " + this._glslFloat(weights[varyingCount - 1]) + "\r\n";
  121950. varyingCount--;
  121951. }
  121952. for (var i = 0; i < varyingCount; i++) {
  121953. defines += "#define KERNEL_OFFSET" + i + " " + this._glslFloat(offsets[i]) + "\r\n";
  121954. defines += "#define KERNEL_WEIGHT" + i + " " + this._glslFloat(weights[i]) + "\r\n";
  121955. }
  121956. var depCount = 0;
  121957. for (var i = freeVaryingVec2; i < offsets.length; i++) {
  121958. defines += "#define KERNEL_DEP_OFFSET" + depCount + " " + this._glslFloat(offsets[i]) + "\r\n";
  121959. defines += "#define KERNEL_DEP_WEIGHT" + depCount + " " + this._glslFloat(weights[i]) + "\r\n";
  121960. depCount++;
  121961. }
  121962. if (this.packedFloat) {
  121963. defines += "#define PACKEDFLOAT 1";
  121964. }
  121965. this.blockCompilation = false;
  121966. _super.prototype.updateEffect.call(this, defines, null, null, {
  121967. varyingCount: varyingCount,
  121968. depCount: depCount
  121969. }, onCompiled, onError);
  121970. };
  121971. /**
  121972. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  121973. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  121974. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  121975. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  121976. * The gaps between physical kernels are compensated for in the weighting of the samples
  121977. * @param idealKernel Ideal blur kernel.
  121978. * @return Nearest best kernel.
  121979. */
  121980. BlurPostProcess.prototype._nearestBestKernel = function (idealKernel) {
  121981. var v = Math.round(idealKernel);
  121982. for (var _i = 0, _a = [v, v - 1, v + 1, v - 2, v + 2]; _i < _a.length; _i++) {
  121983. var k = _a[_i];
  121984. if (((k % 2) !== 0) && ((Math.floor(k / 2) % 2) === 0) && k > 0) {
  121985. return Math.max(k, 3);
  121986. }
  121987. }
  121988. return Math.max(v, 3);
  121989. };
  121990. /**
  121991. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  121992. * @param x The point on the Gaussian distribution to sample.
  121993. * @return the value of the Gaussian function at x.
  121994. */
  121995. BlurPostProcess.prototype._gaussianWeight = function (x) {
  121996. //reference: Engines/ImageProcessingBlur.cpp #dcc760
  121997. // We are evaluating the Gaussian (normal) distribution over a kernel parameter space of [-1,1],
  121998. // so we truncate at three standard deviations by setting stddev (sigma) to 1/3.
  121999. // The choice of 3-sigma truncation is common but arbitrary, and means that the signal is
  122000. // truncated at around 1.3% of peak strength.
  122001. //the distribution is scaled to account for the difference between the actual kernel size and the requested kernel size
  122002. var sigma = (1 / 3);
  122003. var denominator = Math.sqrt(2.0 * Math.PI) * sigma;
  122004. var exponent = -((x * x) / (2.0 * sigma * sigma));
  122005. var weight = (1.0 / denominator) * Math.exp(exponent);
  122006. return weight;
  122007. };
  122008. /**
  122009. * Generates a string that can be used as a floating point number in GLSL.
  122010. * @param x Value to print.
  122011. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  122012. * @return GLSL float string.
  122013. */
  122014. BlurPostProcess.prototype._glslFloat = function (x, decimalFigures) {
  122015. if (decimalFigures === void 0) { decimalFigures = 8; }
  122016. return x.toFixed(decimalFigures).replace(/0+$/, '');
  122017. };
  122018. return BlurPostProcess;
  122019. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122020. /***/ }),
  122021. /***/ "./PostProcesses/chromaticAberrationPostProcess.ts":
  122022. /*!*********************************************************!*\
  122023. !*** ./PostProcesses/chromaticAberrationPostProcess.ts ***!
  122024. \*********************************************************/
  122025. /*! exports provided: ChromaticAberrationPostProcess */
  122026. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122027. "use strict";
  122028. __webpack_require__.r(__webpack_exports__);
  122029. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return ChromaticAberrationPostProcess; });
  122030. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122031. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  122032. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122033. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122034. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  122035. /**
  122036. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  122037. */
  122038. var ChromaticAberrationPostProcess = /** @class */ (function (_super) {
  122039. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ChromaticAberrationPostProcess, _super);
  122040. /**
  122041. * Creates a new instance ChromaticAberrationPostProcess
  122042. * @param name The name of the effect.
  122043. * @param screenWidth The width of the screen to apply the effect on.
  122044. * @param screenHeight The height of the screen to apply the effect on.
  122045. * @param options The required width/height ratio to downsize to before computing the render pass.
  122046. * @param camera The camera to apply the render pass to.
  122047. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122048. * @param engine The engine which the post process will be applied. (default: current engine)
  122049. * @param reusable If the post process can be reused on the same frame. (default: false)
  122050. * @param textureType Type of textures used when performing the post process. (default: 0)
  122051. * @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)
  122052. */
  122053. function ChromaticAberrationPostProcess(name, screenWidth, screenHeight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  122054. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122055. if (blockCompilation === void 0) { blockCompilation = false; }
  122056. 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;
  122057. /**
  122058. * The amount of seperation of rgb channels (default: 30)
  122059. */
  122060. _this.aberrationAmount = 30;
  122061. /**
  122062. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  122063. */
  122064. _this.radialIntensity = 0;
  122065. /**
  122066. * 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))
  122067. */
  122068. _this.direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.707, 0.707);
  122069. /**
  122070. * 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))
  122071. */
  122072. _this.centerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.5, 0.5);
  122073. _this.onApplyObservable.add(function (effect) {
  122074. effect.setFloat('chromatic_aberration', _this.aberrationAmount);
  122075. effect.setFloat('screen_width', screenWidth);
  122076. effect.setFloat('screen_height', screenHeight);
  122077. effect.setFloat('radialIntensity', _this.radialIntensity);
  122078. effect.setFloat2('direction', _this.direction.x, _this.direction.y);
  122079. effect.setFloat2('centerPosition', _this.centerPosition.x, _this.centerPosition.y);
  122080. });
  122081. return _this;
  122082. }
  122083. return ChromaticAberrationPostProcess;
  122084. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  122085. /***/ }),
  122086. /***/ "./PostProcesses/circleOfConfusionPostProcess.ts":
  122087. /*!*******************************************************!*\
  122088. !*** ./PostProcesses/circleOfConfusionPostProcess.ts ***!
  122089. \*******************************************************/
  122090. /*! exports provided: CircleOfConfusionPostProcess */
  122091. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122092. "use strict";
  122093. __webpack_require__.r(__webpack_exports__);
  122094. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return CircleOfConfusionPostProcess; });
  122095. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122096. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122097. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  122098. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122099. /* harmony import */ var _Shaders_circleOfConfusion_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/circleOfConfusion.fragment */ "./Shaders/circleOfConfusion.fragment.ts");
  122100. /**
  122101. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  122102. */
  122103. var CircleOfConfusionPostProcess = /** @class */ (function (_super) {
  122104. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleOfConfusionPostProcess, _super);
  122105. /**
  122106. * Creates a new instance CircleOfConfusionPostProcess
  122107. * @param name The name of the effect.
  122108. * @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.
  122109. * @param options The required width/height ratio to downsize to before computing the render pass.
  122110. * @param camera The camera to apply the render pass to.
  122111. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122112. * @param engine The engine which the post process will be applied. (default: current engine)
  122113. * @param reusable If the post process can be reused on the same frame. (default: false)
  122114. * @param textureType Type of textures used when performing the post process. (default: 0)
  122115. * @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)
  122116. */
  122117. function CircleOfConfusionPostProcess(name, depthTexture, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  122118. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122119. if (blockCompilation === void 0) { blockCompilation = false; }
  122120. var _this = _super.call(this, name, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  122121. /**
  122122. * 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.
  122123. */
  122124. _this.lensSize = 50;
  122125. /**
  122126. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  122127. */
  122128. _this.fStop = 1.4;
  122129. /**
  122130. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  122131. */
  122132. _this.focusDistance = 2000;
  122133. /**
  122134. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  122135. */
  122136. _this.focalLength = 50;
  122137. _this._depthTexture = null;
  122138. _this._depthTexture = depthTexture;
  122139. _this.onApplyObservable.add(function (effect) {
  122140. if (!_this._depthTexture) {
  122141. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("No depth texture set on CircleOfConfusionPostProcess");
  122142. return;
  122143. }
  122144. effect.setTexture("depthSampler", _this._depthTexture);
  122145. // Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html
  122146. var aperture = _this.lensSize / _this.fStop;
  122147. var cocPrecalculation = ((aperture * _this.focalLength) / ((_this.focusDistance - _this.focalLength))); // * ((this.focusDistance - pixelDistance)/pixelDistance) [This part is done in shader]
  122148. effect.setFloat('focusDistance', _this.focusDistance);
  122149. effect.setFloat('cocPrecalculation', cocPrecalculation);
  122150. effect.setFloat2('cameraMinMaxZ', _this._depthTexture.activeCamera.minZ, _this._depthTexture.activeCamera.maxZ);
  122151. });
  122152. return _this;
  122153. }
  122154. Object.defineProperty(CircleOfConfusionPostProcess.prototype, "depthTexture", {
  122155. /**
  122156. * 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.
  122157. */
  122158. set: function (value) {
  122159. this._depthTexture = value;
  122160. },
  122161. enumerable: true,
  122162. configurable: true
  122163. });
  122164. return CircleOfConfusionPostProcess;
  122165. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122166. /***/ }),
  122167. /***/ "./PostProcesses/colorCorrectionPostProcess.ts":
  122168. /*!*****************************************************!*\
  122169. !*** ./PostProcesses/colorCorrectionPostProcess.ts ***!
  122170. \*****************************************************/
  122171. /*! exports provided: ColorCorrectionPostProcess */
  122172. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122173. "use strict";
  122174. __webpack_require__.r(__webpack_exports__);
  122175. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return ColorCorrectionPostProcess; });
  122176. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122177. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122178. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  122179. /* harmony import */ var _Shaders_colorCorrection_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/colorCorrection.fragment */ "./Shaders/colorCorrection.fragment.ts");
  122180. /**
  122181. *
  122182. * This post-process allows the modification of rendered colors by using
  122183. * a 'look-up table' (LUT). This effect is also called Color Grading.
  122184. *
  122185. * The object needs to be provided an url to a texture containing the color
  122186. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  122187. * Use an image editing software to tweak the LUT to match your needs.
  122188. *
  122189. * For an example of a color LUT, see here:
  122190. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  122191. * For explanations on color grading, see here:
  122192. * @see http://udn.epicgames.com/Three/ColorGrading.html
  122193. *
  122194. */
  122195. var ColorCorrectionPostProcess = /** @class */ (function (_super) {
  122196. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorCorrectionPostProcess, _super);
  122197. function ColorCorrectionPostProcess(name, colorTableUrl, options, camera, samplingMode, engine, reusable) {
  122198. var _this = _super.call(this, name, 'colorCorrection', null, ['colorTable'], options, camera, samplingMode, engine, reusable) || this;
  122199. _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);
  122200. _this._colorTableTexture.anisotropicFilteringLevel = 1;
  122201. _this._colorTableTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  122202. _this._colorTableTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  122203. _this.onApply = function (effect) {
  122204. effect.setTexture("colorTable", _this._colorTableTexture);
  122205. };
  122206. return _this;
  122207. }
  122208. return ColorCorrectionPostProcess;
  122209. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122210. /***/ }),
  122211. /***/ "./PostProcesses/convolutionPostProcess.ts":
  122212. /*!*************************************************!*\
  122213. !*** ./PostProcesses/convolutionPostProcess.ts ***!
  122214. \*************************************************/
  122215. /*! exports provided: ConvolutionPostProcess */
  122216. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122217. "use strict";
  122218. __webpack_require__.r(__webpack_exports__);
  122219. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return ConvolutionPostProcess; });
  122220. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122221. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122222. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122223. /* harmony import */ var _Shaders_convolution_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/convolution.fragment */ "./Shaders/convolution.fragment.ts");
  122224. /**
  122225. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  122226. * input texture to perform effects such as edge detection or sharpening
  122227. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  122228. */
  122229. var ConvolutionPostProcess = /** @class */ (function (_super) {
  122230. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ConvolutionPostProcess, _super);
  122231. /**
  122232. * Creates a new instance ConvolutionPostProcess
  122233. * @param name The name of the effect.
  122234. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  122235. * @param options The required width/height ratio to downsize to before computing the render pass.
  122236. * @param camera The camera to apply the render pass to.
  122237. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122238. * @param engine The engine which the post process will be applied. (default: current engine)
  122239. * @param reusable If the post process can be reused on the same frame. (default: false)
  122240. * @param textureType Type of textures used when performing the post process. (default: 0)
  122241. */
  122242. function ConvolutionPostProcess(name,
  122243. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  122244. kernel, options, camera, samplingMode, engine, reusable, textureType) {
  122245. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122246. var _this = _super.call(this, name, "convolution", ["kernel", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  122247. _this.kernel = kernel;
  122248. _this.onApply = function (effect) {
  122249. effect.setFloat2("screenSize", _this.width, _this.height);
  122250. effect.setArray("kernel", _this.kernel);
  122251. };
  122252. return _this;
  122253. }
  122254. // Statics
  122255. /**
  122256. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122257. */
  122258. ConvolutionPostProcess.EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1];
  122259. /**
  122260. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122261. */
  122262. ConvolutionPostProcess.EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0];
  122263. /**
  122264. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122265. */
  122266. ConvolutionPostProcess.EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1];
  122267. /**
  122268. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122269. */
  122270. ConvolutionPostProcess.SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0];
  122271. /**
  122272. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122273. */
  122274. ConvolutionPostProcess.EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2];
  122275. /**
  122276. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122277. */
  122278. ConvolutionPostProcess.GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0];
  122279. return ConvolutionPostProcess;
  122280. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122281. /***/ }),
  122282. /***/ "./PostProcesses/depthOfFieldBlurPostProcess.ts":
  122283. /*!******************************************************!*\
  122284. !*** ./PostProcesses/depthOfFieldBlurPostProcess.ts ***!
  122285. \******************************************************/
  122286. /*! exports provided: DepthOfFieldBlurPostProcess */
  122287. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122288. "use strict";
  122289. __webpack_require__.r(__webpack_exports__);
  122290. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return DepthOfFieldBlurPostProcess; });
  122291. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122292. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  122293. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  122294. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122295. /**
  122296. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  122297. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  122298. * based on samples that have a large difference in distance than the center pixel.
  122299. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  122300. */
  122301. var DepthOfFieldBlurPostProcess = /** @class */ (function (_super) {
  122302. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldBlurPostProcess, _super);
  122303. /**
  122304. * Creates a new instance CircleOfConfusionPostProcess
  122305. * @param name The name of the effect.
  122306. * @param scene The scene the effect belongs to.
  122307. * @param direction The direction the blur should be applied.
  122308. * @param kernel The size of the kernel used to blur.
  122309. * @param options The required width/height ratio to downsize to before computing the render pass.
  122310. * @param camera The camera to apply the render pass to.
  122311. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  122312. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  122313. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122314. * @param engine The engine which the post process will be applied. (default: current engine)
  122315. * @param reusable If the post process can be reused on the same frame. (default: false)
  122316. * @param textureType Type of textures used when performing the post process. (default: 0)
  122317. * @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)
  122318. */
  122319. function DepthOfFieldBlurPostProcess(name, scene, direction, kernel, options, camera, circleOfConfusion, imageToBlur, samplingMode, engine, reusable, textureType, blockCompilation) {
  122320. if (imageToBlur === void 0) { imageToBlur = null; }
  122321. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  122322. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122323. if (blockCompilation === void 0) { blockCompilation = false; }
  122324. 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;
  122325. _this.direction = direction;
  122326. _this.onApplyObservable.add(function (effect) {
  122327. if (imageToBlur != null) {
  122328. effect.setTextureFromPostProcess("textureSampler", imageToBlur);
  122329. }
  122330. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  122331. if (scene.activeCamera) {
  122332. effect.setFloat2('cameraMinMaxZ', scene.activeCamera.minZ, scene.activeCamera.maxZ);
  122333. }
  122334. });
  122335. return _this;
  122336. }
  122337. return DepthOfFieldBlurPostProcess;
  122338. }(_blurPostProcess__WEBPACK_IMPORTED_MODULE_2__["BlurPostProcess"]));
  122339. /***/ }),
  122340. /***/ "./PostProcesses/depthOfFieldEffect.ts":
  122341. /*!*********************************************!*\
  122342. !*** ./PostProcesses/depthOfFieldEffect.ts ***!
  122343. \*********************************************/
  122344. /*! exports provided: DepthOfFieldEffectBlurLevel, DepthOfFieldEffect */
  122345. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122346. "use strict";
  122347. __webpack_require__.r(__webpack_exports__);
  122348. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return DepthOfFieldEffectBlurLevel; });
  122349. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return DepthOfFieldEffect; });
  122350. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122351. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  122352. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  122353. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  122354. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  122355. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  122356. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  122357. /**
  122358. * Specifies the level of max blur that should be applied when using the depth of field effect
  122359. */
  122360. var DepthOfFieldEffectBlurLevel;
  122361. (function (DepthOfFieldEffectBlurLevel) {
  122362. /**
  122363. * Subtle blur
  122364. */
  122365. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Low"] = 0] = "Low";
  122366. /**
  122367. * Medium blur
  122368. */
  122369. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Medium"] = 1] = "Medium";
  122370. /**
  122371. * Large blur
  122372. */
  122373. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["High"] = 2] = "High";
  122374. })(DepthOfFieldEffectBlurLevel || (DepthOfFieldEffectBlurLevel = {}));
  122375. /**
  122376. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  122377. */
  122378. var DepthOfFieldEffect = /** @class */ (function (_super) {
  122379. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldEffect, _super);
  122380. /**
  122381. * Creates a new instance DepthOfFieldEffect
  122382. * @param scene The scene the effect belongs to.
  122383. * @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.
  122384. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  122385. * @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)
  122386. */
  122387. function DepthOfFieldEffect(scene, depthTexture, blurLevel, pipelineTextureType, blockCompilation) {
  122388. if (blurLevel === void 0) { blurLevel = DepthOfFieldEffectBlurLevel.Low; }
  122389. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  122390. if (blockCompilation === void 0) { blockCompilation = false; }
  122391. var _this = _super.call(this, scene.getEngine(), "depth of field", function () {
  122392. return _this._effects;
  122393. }, true) || this;
  122394. /**
  122395. * @hidden Internal post processes in depth of field effect
  122396. */
  122397. _this._effects = [];
  122398. // Circle of confusion value for each pixel is used to determine how much to blur that pixel
  122399. _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);
  122400. // 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)
  122401. // Blur the image but do not blur on sharp far to near distance changes to avoid bleeding artifacts
  122402. // See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  122403. _this._depthOfFieldBlurY = [];
  122404. _this._depthOfFieldBlurX = [];
  122405. var blurCount = 1;
  122406. var kernelSize = 15;
  122407. switch (blurLevel) {
  122408. case DepthOfFieldEffectBlurLevel.High: {
  122409. blurCount = 3;
  122410. kernelSize = 51;
  122411. break;
  122412. }
  122413. case DepthOfFieldEffectBlurLevel.Medium: {
  122414. blurCount = 2;
  122415. kernelSize = 31;
  122416. break;
  122417. }
  122418. default: {
  122419. kernelSize = 15;
  122420. blurCount = 1;
  122421. break;
  122422. }
  122423. }
  122424. var adjustedKernelSize = kernelSize / Math.pow(2, blurCount - 1);
  122425. var ratio = 1.0;
  122426. for (var i = 0; i < blurCount; i++) {
  122427. 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);
  122428. blurY.autoClear = false;
  122429. ratio = 0.75 / Math.pow(2, i);
  122430. 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);
  122431. blurX.autoClear = false;
  122432. _this._depthOfFieldBlurY.push(blurY);
  122433. _this._depthOfFieldBlurX.push(blurX);
  122434. }
  122435. // Set all post processes on the effect.
  122436. _this._effects = [_this._circleOfConfusion];
  122437. for (var i = 0; i < _this._depthOfFieldBlurX.length; i++) {
  122438. _this._effects.push(_this._depthOfFieldBlurY[i]);
  122439. _this._effects.push(_this._depthOfFieldBlurX[i]);
  122440. }
  122441. // Merge blurred images with original image based on circleOfConfusion
  122442. _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);
  122443. _this._dofMerge.autoClear = false;
  122444. _this._effects.push(_this._dofMerge);
  122445. return _this;
  122446. }
  122447. Object.defineProperty(DepthOfFieldEffect.prototype, "focalLength", {
  122448. get: function () {
  122449. return this._circleOfConfusion.focalLength;
  122450. },
  122451. /**
  122452. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  122453. */
  122454. set: function (value) {
  122455. this._circleOfConfusion.focalLength = value;
  122456. },
  122457. enumerable: true,
  122458. configurable: true
  122459. });
  122460. Object.defineProperty(DepthOfFieldEffect.prototype, "fStop", {
  122461. get: function () {
  122462. return this._circleOfConfusion.fStop;
  122463. },
  122464. /**
  122465. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  122466. */
  122467. set: function (value) {
  122468. this._circleOfConfusion.fStop = value;
  122469. },
  122470. enumerable: true,
  122471. configurable: true
  122472. });
  122473. Object.defineProperty(DepthOfFieldEffect.prototype, "focusDistance", {
  122474. get: function () {
  122475. return this._circleOfConfusion.focusDistance;
  122476. },
  122477. /**
  122478. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  122479. */
  122480. set: function (value) {
  122481. this._circleOfConfusion.focusDistance = value;
  122482. },
  122483. enumerable: true,
  122484. configurable: true
  122485. });
  122486. Object.defineProperty(DepthOfFieldEffect.prototype, "lensSize", {
  122487. get: function () {
  122488. return this._circleOfConfusion.lensSize;
  122489. },
  122490. /**
  122491. * 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.
  122492. */
  122493. set: function (value) {
  122494. this._circleOfConfusion.lensSize = value;
  122495. },
  122496. enumerable: true,
  122497. configurable: true
  122498. });
  122499. Object.defineProperty(DepthOfFieldEffect.prototype, "depthTexture", {
  122500. /**
  122501. * 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.
  122502. */
  122503. set: function (value) {
  122504. this._circleOfConfusion.depthTexture = value;
  122505. },
  122506. enumerable: true,
  122507. configurable: true
  122508. });
  122509. /**
  122510. * Disposes each of the internal effects for a given camera.
  122511. * @param camera The camera to dispose the effect on.
  122512. */
  122513. DepthOfFieldEffect.prototype.disposeEffects = function (camera) {
  122514. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  122515. this._effects[effectIndex].dispose(camera);
  122516. }
  122517. };
  122518. /**
  122519. * @hidden Internal
  122520. */
  122521. DepthOfFieldEffect.prototype._updateEffects = function () {
  122522. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  122523. this._effects[effectIndex].updateEffect();
  122524. }
  122525. };
  122526. /**
  122527. * Internal
  122528. * @returns if all the contained post processes are ready.
  122529. * @hidden
  122530. */
  122531. DepthOfFieldEffect.prototype._isReady = function () {
  122532. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  122533. if (!this._effects[effectIndex].isReady()) {
  122534. return false;
  122535. }
  122536. }
  122537. return true;
  122538. };
  122539. return DepthOfFieldEffect;
  122540. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderEffect"]));
  122541. /***/ }),
  122542. /***/ "./PostProcesses/depthOfFieldMergePostProcess.ts":
  122543. /*!*******************************************************!*\
  122544. !*** ./PostProcesses/depthOfFieldMergePostProcess.ts ***!
  122545. \*******************************************************/
  122546. /*! exports provided: DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess */
  122547. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122548. "use strict";
  122549. __webpack_require__.r(__webpack_exports__);
  122550. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return DepthOfFieldMergePostProcessOptions; });
  122551. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return DepthOfFieldMergePostProcess; });
  122552. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122553. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122554. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122555. /* harmony import */ var _Shaders_depthOfFieldMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/depthOfFieldMerge.fragment */ "./Shaders/depthOfFieldMerge.fragment.ts");
  122556. /**
  122557. * Options to be set when merging outputs from the default pipeline.
  122558. */
  122559. var DepthOfFieldMergePostProcessOptions = /** @class */ (function () {
  122560. function DepthOfFieldMergePostProcessOptions() {
  122561. }
  122562. return DepthOfFieldMergePostProcessOptions;
  122563. }());
  122564. /**
  122565. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  122566. */
  122567. var DepthOfFieldMergePostProcess = /** @class */ (function (_super) {
  122568. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldMergePostProcess, _super);
  122569. /**
  122570. * Creates a new instance of DepthOfFieldMergePostProcess
  122571. * @param name The name of the effect.
  122572. * @param originalFromInput Post process which's input will be used for the merge.
  122573. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  122574. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  122575. * @param options The required width/height ratio to downsize to before computing the render pass.
  122576. * @param camera The camera to apply the render pass to.
  122577. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122578. * @param engine The engine which the post process will be applied. (default: current engine)
  122579. * @param reusable If the post process can be reused on the same frame. (default: false)
  122580. * @param textureType Type of textures used when performing the post process. (default: 0)
  122581. * @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)
  122582. */
  122583. function DepthOfFieldMergePostProcess(name, originalFromInput, circleOfConfusion, blurSteps, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  122584. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122585. if (blockCompilation === void 0) { blockCompilation = false; }
  122586. var _this = _super.call(this, name, "depthOfFieldMerge", [], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  122587. _this.blurSteps = blurSteps;
  122588. _this.onApplyObservable.add(function (effect) {
  122589. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  122590. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  122591. blurSteps.forEach(function (step, index) {
  122592. effect.setTextureFromPostProcessOutput("blurStep" + (blurSteps.length - index - 1), step);
  122593. });
  122594. });
  122595. if (!blockCompilation) {
  122596. _this.updateEffect();
  122597. }
  122598. return _this;
  122599. }
  122600. /**
  122601. * Updates the effect with the current post process compile time values and recompiles the shader.
  122602. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  122603. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  122604. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  122605. * @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
  122606. * @param onCompiled Called when the shader has been compiled.
  122607. * @param onError Called if there is an error when compiling a shader.
  122608. */
  122609. DepthOfFieldMergePostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  122610. if (defines === void 0) { defines = null; }
  122611. if (uniforms === void 0) { uniforms = null; }
  122612. if (samplers === void 0) { samplers = null; }
  122613. if (!defines) {
  122614. defines = "";
  122615. defines += "#define BLUR_LEVEL " + (this.blurSteps.length - 1) + "\n";
  122616. }
  122617. _super.prototype.updateEffect.call(this, defines, uniforms, samplers, indexParameters, onCompiled, onError);
  122618. };
  122619. return DepthOfFieldMergePostProcess;
  122620. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122621. /***/ }),
  122622. /***/ "./PostProcesses/displayPassPostProcess.ts":
  122623. /*!*************************************************!*\
  122624. !*** ./PostProcesses/displayPassPostProcess.ts ***!
  122625. \*************************************************/
  122626. /*! exports provided: DisplayPassPostProcess */
  122627. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122628. "use strict";
  122629. __webpack_require__.r(__webpack_exports__);
  122630. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return DisplayPassPostProcess; });
  122631. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122632. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122633. /* harmony import */ var _Shaders_displayPass_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/displayPass.fragment */ "./Shaders/displayPass.fragment.ts");
  122634. /**
  122635. * DisplayPassPostProcess which produces an output the same as it's input
  122636. */
  122637. var DisplayPassPostProcess = /** @class */ (function (_super) {
  122638. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayPassPostProcess, _super);
  122639. /**
  122640. * Creates the DisplayPassPostProcess
  122641. * @param name The name of the effect.
  122642. * @param options The required width/height ratio to downsize to before computing the render pass.
  122643. * @param camera The camera to apply the render pass to.
  122644. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122645. * @param engine The engine which the post process will be applied. (default: current engine)
  122646. * @param reusable If the post process can be reused on the same frame. (default: false)
  122647. */
  122648. function DisplayPassPostProcess(name, options, camera, samplingMode, engine, reusable) {
  122649. return _super.call(this, name, "displayPass", ["passSampler"], ["passSampler"], options, camera, samplingMode, engine, reusable) || this;
  122650. }
  122651. return DisplayPassPostProcess;
  122652. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122653. /***/ }),
  122654. /***/ "./PostProcesses/extractHighlightsPostProcess.ts":
  122655. /*!*******************************************************!*\
  122656. !*** ./PostProcesses/extractHighlightsPostProcess.ts ***!
  122657. \*******************************************************/
  122658. /*! exports provided: ExtractHighlightsPostProcess */
  122659. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122660. "use strict";
  122661. __webpack_require__.r(__webpack_exports__);
  122662. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return ExtractHighlightsPostProcess; });
  122663. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122664. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122665. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  122666. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122667. /* harmony import */ var _Shaders_extractHighlights_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/extractHighlights.fragment */ "./Shaders/extractHighlights.fragment.ts");
  122668. /**
  122669. * 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.
  122670. */
  122671. var ExtractHighlightsPostProcess = /** @class */ (function (_super) {
  122672. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExtractHighlightsPostProcess, _super);
  122673. function ExtractHighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  122674. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122675. if (blockCompilation === void 0) { blockCompilation = false; }
  122676. var _this = _super.call(this, name, "extractHighlights", ["threshold", "exposure"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  122677. /**
  122678. * The luminance threshold, pixels below this value will be set to black.
  122679. */
  122680. _this.threshold = 0.9;
  122681. /** @hidden */
  122682. _this._exposure = 1;
  122683. /**
  122684. * Post process which has the input texture to be used when performing highlight extraction
  122685. * @hidden
  122686. */
  122687. _this._inputPostProcess = null;
  122688. _this.onApplyObservable.add(function (effect) {
  122689. if (_this._inputPostProcess) {
  122690. effect.setTextureFromPostProcess("textureSampler", _this._inputPostProcess);
  122691. }
  122692. effect.setFloat('threshold', Math.pow(_this.threshold, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["ToGammaSpace"]));
  122693. effect.setFloat('exposure', _this._exposure);
  122694. });
  122695. return _this;
  122696. }
  122697. return ExtractHighlightsPostProcess;
  122698. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122699. /***/ }),
  122700. /***/ "./PostProcesses/filterPostProcess.ts":
  122701. /*!********************************************!*\
  122702. !*** ./PostProcesses/filterPostProcess.ts ***!
  122703. \********************************************/
  122704. /*! exports provided: FilterPostProcess */
  122705. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122706. "use strict";
  122707. __webpack_require__.r(__webpack_exports__);
  122708. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return FilterPostProcess; });
  122709. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122710. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122711. /* harmony import */ var _Shaders_filter_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/filter.fragment */ "./Shaders/filter.fragment.ts");
  122712. /**
  122713. * Applies a kernel filter to the image
  122714. */
  122715. var FilterPostProcess = /** @class */ (function (_super) {
  122716. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FilterPostProcess, _super);
  122717. /**
  122718. *
  122719. * @param name The name of the effect.
  122720. * @param kernelMatrix The matrix to be applied to the image
  122721. * @param options The required width/height ratio to downsize to before computing the render pass.
  122722. * @param camera The camera to apply the render pass to.
  122723. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122724. * @param engine The engine which the post process will be applied. (default: current engine)
  122725. * @param reusable If the post process can be reused on the same frame. (default: false)
  122726. */
  122727. function FilterPostProcess(name,
  122728. /** The matrix to be applied to the image */
  122729. kernelMatrix, options, camera, samplingMode, engine, reusable) {
  122730. var _this = _super.call(this, name, "filter", ["kernelMatrix"], null, options, camera, samplingMode, engine, reusable) || this;
  122731. _this.kernelMatrix = kernelMatrix;
  122732. _this.onApply = function (effect) {
  122733. effect.setMatrix("kernelMatrix", _this.kernelMatrix);
  122734. };
  122735. return _this;
  122736. }
  122737. return FilterPostProcess;
  122738. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122739. /***/ }),
  122740. /***/ "./PostProcesses/fxaaPostProcess.ts":
  122741. /*!******************************************!*\
  122742. !*** ./PostProcesses/fxaaPostProcess.ts ***!
  122743. \******************************************/
  122744. /*! exports provided: FxaaPostProcess */
  122745. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122746. "use strict";
  122747. __webpack_require__.r(__webpack_exports__);
  122748. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return FxaaPostProcess; });
  122749. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122750. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  122751. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122752. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122753. /* harmony import */ var _Shaders_fxaa_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/fxaa.fragment */ "./Shaders/fxaa.fragment.ts");
  122754. /* harmony import */ var _Shaders_fxaa_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/fxaa.vertex */ "./Shaders/fxaa.vertex.ts");
  122755. /**
  122756. * Fxaa post process
  122757. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  122758. */
  122759. var FxaaPostProcess = /** @class */ (function (_super) {
  122760. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FxaaPostProcess, _super);
  122761. function FxaaPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  122762. if (camera === void 0) { camera = null; }
  122763. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122764. 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;
  122765. var defines = _this._getDefines();
  122766. _this.updateEffect(defines);
  122767. _this.onApplyObservable.add(function (effect) {
  122768. var texelSize = _this.texelSize;
  122769. effect.setFloat2("texelSize", texelSize.x, texelSize.y);
  122770. });
  122771. return _this;
  122772. }
  122773. FxaaPostProcess.prototype._getDefines = function () {
  122774. var engine = this.getEngine();
  122775. if (!engine) {
  122776. return null;
  122777. }
  122778. var glInfo = engine.getGlInfo();
  122779. if (glInfo && glInfo.renderer && glInfo.renderer.toLowerCase().indexOf("mali") > -1) {
  122780. return "#define MALI 1\n";
  122781. }
  122782. return null;
  122783. };
  122784. return FxaaPostProcess;
  122785. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  122786. /***/ }),
  122787. /***/ "./PostProcesses/grainPostProcess.ts":
  122788. /*!*******************************************!*\
  122789. !*** ./PostProcesses/grainPostProcess.ts ***!
  122790. \*******************************************/
  122791. /*! exports provided: GrainPostProcess */
  122792. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122793. "use strict";
  122794. __webpack_require__.r(__webpack_exports__);
  122795. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return GrainPostProcess; });
  122796. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122797. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122798. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122799. /* harmony import */ var _Shaders_grain_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/grain.fragment */ "./Shaders/grain.fragment.ts");
  122800. /**
  122801. * The GrainPostProcess adds noise to the image at mid luminance levels
  122802. */
  122803. var GrainPostProcess = /** @class */ (function (_super) {
  122804. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GrainPostProcess, _super);
  122805. /**
  122806. * Creates a new instance of @see GrainPostProcess
  122807. * @param name The name of the effect.
  122808. * @param options The required width/height ratio to downsize to before computing the render pass.
  122809. * @param camera The camera to apply the render pass to.
  122810. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122811. * @param engine The engine which the post process will be applied. (default: current engine)
  122812. * @param reusable If the post process can be reused on the same frame. (default: false)
  122813. * @param textureType Type of textures used when performing the post process. (default: 0)
  122814. * @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)
  122815. */
  122816. function GrainPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  122817. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122818. if (blockCompilation === void 0) { blockCompilation = false; }
  122819. var _this = _super.call(this, name, "grain", ["intensity", "animatedSeed"], [], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  122820. /**
  122821. * The intensity of the grain added (default: 30)
  122822. */
  122823. _this.intensity = 30;
  122824. /**
  122825. * If the grain should be randomized on every frame
  122826. */
  122827. _this.animated = false;
  122828. _this.onApplyObservable.add(function (effect) {
  122829. effect.setFloat('intensity', _this.intensity);
  122830. effect.setFloat('animatedSeed', _this.animated ? Math.random() + 1 : 1);
  122831. });
  122832. return _this;
  122833. }
  122834. return GrainPostProcess;
  122835. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122836. /***/ }),
  122837. /***/ "./PostProcesses/highlightsPostProcess.ts":
  122838. /*!************************************************!*\
  122839. !*** ./PostProcesses/highlightsPostProcess.ts ***!
  122840. \************************************************/
  122841. /*! exports provided: HighlightsPostProcess */
  122842. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122843. "use strict";
  122844. __webpack_require__.r(__webpack_exports__);
  122845. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return HighlightsPostProcess; });
  122846. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122847. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122848. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122849. /* harmony import */ var _Shaders_highlights_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/highlights.fragment */ "./Shaders/highlights.fragment.ts");
  122850. /**
  122851. * Extracts highlights from the image
  122852. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  122853. */
  122854. var HighlightsPostProcess = /** @class */ (function (_super) {
  122855. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightsPostProcess, _super);
  122856. /**
  122857. * Extracts highlights from the image
  122858. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  122859. * @param name The name of the effect.
  122860. * @param options The required width/height ratio to downsize to before computing the render pass.
  122861. * @param camera The camera to apply the render pass to.
  122862. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122863. * @param engine The engine which the post process will be applied. (default: current engine)
  122864. * @param reusable If the post process can be reused on the same frame. (default: false)
  122865. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  122866. */
  122867. function HighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  122868. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122869. return _super.call(this, name, "highlights", null, null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  122870. }
  122871. return HighlightsPostProcess;
  122872. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122873. /***/ }),
  122874. /***/ "./PostProcesses/imageProcessingPostProcess.ts":
  122875. /*!*****************************************************!*\
  122876. !*** ./PostProcesses/imageProcessingPostProcess.ts ***!
  122877. \*****************************************************/
  122878. /*! exports provided: ImageProcessingPostProcess */
  122879. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122880. "use strict";
  122881. __webpack_require__.r(__webpack_exports__);
  122882. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return ImageProcessingPostProcess; });
  122883. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122884. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  122885. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  122886. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122887. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  122888. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122889. /* harmony import */ var _Shaders_imageProcessing_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/imageProcessing.fragment */ "./Shaders/imageProcessing.fragment.ts");
  122890. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  122891. /**
  122892. * ImageProcessingPostProcess
  122893. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  122894. */
  122895. var ImageProcessingPostProcess = /** @class */ (function (_super) {
  122896. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingPostProcess, _super);
  122897. function ImageProcessingPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, imageProcessingConfiguration) {
  122898. if (camera === void 0) { camera = null; }
  122899. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122900. var _this = _super.call(this, name, "imageProcessing", [], [], options, camera, samplingMode, engine, reusable, null, textureType, "postprocess", null, true) || this;
  122901. _this._fromLinearSpace = true;
  122902. /**
  122903. * Defines cache preventing GC.
  122904. */
  122905. _this._defines = {
  122906. IMAGEPROCESSING: false,
  122907. VIGNETTE: false,
  122908. VIGNETTEBLENDMODEMULTIPLY: false,
  122909. VIGNETTEBLENDMODEOPAQUE: false,
  122910. TONEMAPPING: false,
  122911. TONEMAPPING_ACES: false,
  122912. CONTRAST: false,
  122913. COLORCURVES: false,
  122914. COLORGRADING: false,
  122915. COLORGRADING3D: false,
  122916. FROMLINEARSPACE: false,
  122917. SAMPLER3DGREENDEPTH: false,
  122918. SAMPLER3DBGRMAP: false,
  122919. IMAGEPROCESSINGPOSTPROCESS: false,
  122920. EXPOSURE: false,
  122921. };
  122922. // Setup the configuration as forced by the constructor. This would then not force the
  122923. // scene materials output in linear space and let untouched the default forward pass.
  122924. if (imageProcessingConfiguration) {
  122925. imageProcessingConfiguration.applyByPostProcess = true;
  122926. _this._attachImageProcessingConfiguration(imageProcessingConfiguration, true);
  122927. // This will cause the shader to be compiled
  122928. _this.fromLinearSpace = false;
  122929. }
  122930. // Setup the default processing configuration to the scene.
  122931. else {
  122932. _this._attachImageProcessingConfiguration(null, true);
  122933. _this.imageProcessingConfiguration.applyByPostProcess = true;
  122934. }
  122935. _this.onApply = function (effect) {
  122936. _this.imageProcessingConfiguration.bind(effect, _this.aspectRatio);
  122937. };
  122938. return _this;
  122939. }
  122940. Object.defineProperty(ImageProcessingPostProcess.prototype, "imageProcessingConfiguration", {
  122941. /**
  122942. * Gets the image processing configuration used either in this material.
  122943. */
  122944. get: function () {
  122945. return this._imageProcessingConfiguration;
  122946. },
  122947. /**
  122948. * Sets the Default image processing configuration used either in the this material.
  122949. *
  122950. * If sets to null, the scene one is in use.
  122951. */
  122952. set: function (value) {
  122953. this._attachImageProcessingConfiguration(value);
  122954. },
  122955. enumerable: true,
  122956. configurable: true
  122957. });
  122958. /**
  122959. * Attaches a new image processing configuration to the PBR Material.
  122960. * @param configuration
  122961. */
  122962. ImageProcessingPostProcess.prototype._attachImageProcessingConfiguration = function (configuration, doNotBuild) {
  122963. var _this = this;
  122964. if (doNotBuild === void 0) { doNotBuild = false; }
  122965. if (configuration === this._imageProcessingConfiguration) {
  122966. return;
  122967. }
  122968. // Detaches observer.
  122969. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  122970. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  122971. }
  122972. // Pick the scene configuration if needed.
  122973. if (!configuration) {
  122974. var scene = null;
  122975. var engine = this.getEngine();
  122976. var camera = this.getCamera();
  122977. if (camera) {
  122978. scene = camera.getScene();
  122979. }
  122980. else if (engine && engine.scenes) {
  122981. var scenes = engine.scenes;
  122982. scene = scenes[scenes.length - 1];
  122983. }
  122984. else {
  122985. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene;
  122986. }
  122987. this._imageProcessingConfiguration = scene.imageProcessingConfiguration;
  122988. }
  122989. else {
  122990. this._imageProcessingConfiguration = configuration;
  122991. }
  122992. // Attaches observer.
  122993. if (this._imageProcessingConfiguration) {
  122994. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  122995. _this._updateParameters();
  122996. });
  122997. }
  122998. // Ensure the effect will be rebuilt.
  122999. if (!doNotBuild) {
  123000. this._updateParameters();
  123001. }
  123002. };
  123003. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurves", {
  123004. /**
  123005. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  123006. */
  123007. get: function () {
  123008. return this.imageProcessingConfiguration.colorCurves;
  123009. },
  123010. /**
  123011. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  123012. */
  123013. set: function (value) {
  123014. this.imageProcessingConfiguration.colorCurves = value;
  123015. },
  123016. enumerable: true,
  123017. configurable: true
  123018. });
  123019. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurvesEnabled", {
  123020. /**
  123021. * Gets wether the color curves effect is enabled.
  123022. */
  123023. get: function () {
  123024. return this.imageProcessingConfiguration.colorCurvesEnabled;
  123025. },
  123026. /**
  123027. * Sets wether the color curves effect is enabled.
  123028. */
  123029. set: function (value) {
  123030. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  123031. },
  123032. enumerable: true,
  123033. configurable: true
  123034. });
  123035. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingTexture", {
  123036. /**
  123037. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  123038. */
  123039. get: function () {
  123040. return this.imageProcessingConfiguration.colorGradingTexture;
  123041. },
  123042. /**
  123043. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  123044. */
  123045. set: function (value) {
  123046. this.imageProcessingConfiguration.colorGradingTexture = value;
  123047. },
  123048. enumerable: true,
  123049. configurable: true
  123050. });
  123051. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingEnabled", {
  123052. /**
  123053. * Gets wether the color grading effect is enabled.
  123054. */
  123055. get: function () {
  123056. return this.imageProcessingConfiguration.colorGradingEnabled;
  123057. },
  123058. /**
  123059. * Gets wether the color grading effect is enabled.
  123060. */
  123061. set: function (value) {
  123062. this.imageProcessingConfiguration.colorGradingEnabled = value;
  123063. },
  123064. enumerable: true,
  123065. configurable: true
  123066. });
  123067. Object.defineProperty(ImageProcessingPostProcess.prototype, "exposure", {
  123068. /**
  123069. * Gets exposure used in the effect.
  123070. */
  123071. get: function () {
  123072. return this.imageProcessingConfiguration.exposure;
  123073. },
  123074. /**
  123075. * Sets exposure used in the effect.
  123076. */
  123077. set: function (value) {
  123078. this.imageProcessingConfiguration.exposure = value;
  123079. },
  123080. enumerable: true,
  123081. configurable: true
  123082. });
  123083. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingEnabled", {
  123084. /**
  123085. * Gets wether tonemapping is enabled or not.
  123086. */
  123087. get: function () {
  123088. return this._imageProcessingConfiguration.toneMappingEnabled;
  123089. },
  123090. /**
  123091. * Sets wether tonemapping is enabled or not
  123092. */
  123093. set: function (value) {
  123094. this._imageProcessingConfiguration.toneMappingEnabled = value;
  123095. },
  123096. enumerable: true,
  123097. configurable: true
  123098. });
  123099. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingType", {
  123100. /**
  123101. * Gets the type of tone mapping effect.
  123102. */
  123103. get: function () {
  123104. return this._imageProcessingConfiguration.toneMappingType;
  123105. },
  123106. /**
  123107. * Sets the type of tone mapping effect.
  123108. */
  123109. set: function (value) {
  123110. this._imageProcessingConfiguration.toneMappingType = value;
  123111. },
  123112. enumerable: true,
  123113. configurable: true
  123114. });
  123115. Object.defineProperty(ImageProcessingPostProcess.prototype, "contrast", {
  123116. /**
  123117. * Gets contrast used in the effect.
  123118. */
  123119. get: function () {
  123120. return this.imageProcessingConfiguration.contrast;
  123121. },
  123122. /**
  123123. * Sets contrast used in the effect.
  123124. */
  123125. set: function (value) {
  123126. this.imageProcessingConfiguration.contrast = value;
  123127. },
  123128. enumerable: true,
  123129. configurable: true
  123130. });
  123131. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteStretch", {
  123132. /**
  123133. * Gets Vignette stretch size.
  123134. */
  123135. get: function () {
  123136. return this.imageProcessingConfiguration.vignetteStretch;
  123137. },
  123138. /**
  123139. * Sets Vignette stretch size.
  123140. */
  123141. set: function (value) {
  123142. this.imageProcessingConfiguration.vignetteStretch = value;
  123143. },
  123144. enumerable: true,
  123145. configurable: true
  123146. });
  123147. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreX", {
  123148. /**
  123149. * Gets Vignette centre X Offset.
  123150. */
  123151. get: function () {
  123152. return this.imageProcessingConfiguration.vignetteCentreX;
  123153. },
  123154. /**
  123155. * Sets Vignette centre X Offset.
  123156. */
  123157. set: function (value) {
  123158. this.imageProcessingConfiguration.vignetteCentreX = value;
  123159. },
  123160. enumerable: true,
  123161. configurable: true
  123162. });
  123163. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreY", {
  123164. /**
  123165. * Gets Vignette centre Y Offset.
  123166. */
  123167. get: function () {
  123168. return this.imageProcessingConfiguration.vignetteCentreY;
  123169. },
  123170. /**
  123171. * Sets Vignette centre Y Offset.
  123172. */
  123173. set: function (value) {
  123174. this.imageProcessingConfiguration.vignetteCentreY = value;
  123175. },
  123176. enumerable: true,
  123177. configurable: true
  123178. });
  123179. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteWeight", {
  123180. /**
  123181. * Gets Vignette weight or intensity of the vignette effect.
  123182. */
  123183. get: function () {
  123184. return this.imageProcessingConfiguration.vignetteWeight;
  123185. },
  123186. /**
  123187. * Sets Vignette weight or intensity of the vignette effect.
  123188. */
  123189. set: function (value) {
  123190. this.imageProcessingConfiguration.vignetteWeight = value;
  123191. },
  123192. enumerable: true,
  123193. configurable: true
  123194. });
  123195. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteColor", {
  123196. /**
  123197. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  123198. * if vignetteEnabled is set to true.
  123199. */
  123200. get: function () {
  123201. return this.imageProcessingConfiguration.vignetteColor;
  123202. },
  123203. /**
  123204. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  123205. * if vignetteEnabled is set to true.
  123206. */
  123207. set: function (value) {
  123208. this.imageProcessingConfiguration.vignetteColor = value;
  123209. },
  123210. enumerable: true,
  123211. configurable: true
  123212. });
  123213. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCameraFov", {
  123214. /**
  123215. * Gets Camera field of view used by the Vignette effect.
  123216. */
  123217. get: function () {
  123218. return this.imageProcessingConfiguration.vignetteCameraFov;
  123219. },
  123220. /**
  123221. * Sets Camera field of view used by the Vignette effect.
  123222. */
  123223. set: function (value) {
  123224. this.imageProcessingConfiguration.vignetteCameraFov = value;
  123225. },
  123226. enumerable: true,
  123227. configurable: true
  123228. });
  123229. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteBlendMode", {
  123230. /**
  123231. * Gets the vignette blend mode allowing different kind of effect.
  123232. */
  123233. get: function () {
  123234. return this.imageProcessingConfiguration.vignetteBlendMode;
  123235. },
  123236. /**
  123237. * Sets the vignette blend mode allowing different kind of effect.
  123238. */
  123239. set: function (value) {
  123240. this.imageProcessingConfiguration.vignetteBlendMode = value;
  123241. },
  123242. enumerable: true,
  123243. configurable: true
  123244. });
  123245. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteEnabled", {
  123246. /**
  123247. * Gets wether the vignette effect is enabled.
  123248. */
  123249. get: function () {
  123250. return this.imageProcessingConfiguration.vignetteEnabled;
  123251. },
  123252. /**
  123253. * Sets wether the vignette effect is enabled.
  123254. */
  123255. set: function (value) {
  123256. this.imageProcessingConfiguration.vignetteEnabled = value;
  123257. },
  123258. enumerable: true,
  123259. configurable: true
  123260. });
  123261. Object.defineProperty(ImageProcessingPostProcess.prototype, "fromLinearSpace", {
  123262. /**
  123263. * Gets wether the input of the processing is in Gamma or Linear Space.
  123264. */
  123265. get: function () {
  123266. return this._fromLinearSpace;
  123267. },
  123268. /**
  123269. * Sets wether the input of the processing is in Gamma or Linear Space.
  123270. */
  123271. set: function (value) {
  123272. if (this._fromLinearSpace === value) {
  123273. return;
  123274. }
  123275. this._fromLinearSpace = value;
  123276. this._updateParameters();
  123277. },
  123278. enumerable: true,
  123279. configurable: true
  123280. });
  123281. /**
  123282. * "ImageProcessingPostProcess"
  123283. * @returns "ImageProcessingPostProcess"
  123284. */
  123285. ImageProcessingPostProcess.prototype.getClassName = function () {
  123286. return "ImageProcessingPostProcess";
  123287. };
  123288. ImageProcessingPostProcess.prototype._updateParameters = function () {
  123289. this._defines.FROMLINEARSPACE = this._fromLinearSpace;
  123290. this.imageProcessingConfiguration.prepareDefines(this._defines, true);
  123291. var defines = "";
  123292. for (var define in this._defines) {
  123293. if (this._defines[define]) {
  123294. defines += "#define " + define + ";\r\n";
  123295. }
  123296. }
  123297. var samplers = ["textureSampler"];
  123298. var uniforms = ["scale"];
  123299. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"]) {
  123300. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._defines);
  123301. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._defines);
  123302. }
  123303. this.updateEffect(defines, uniforms, samplers);
  123304. };
  123305. ImageProcessingPostProcess.prototype.dispose = function (camera) {
  123306. _super.prototype.dispose.call(this, camera);
  123307. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  123308. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  123309. }
  123310. if (this._imageProcessingConfiguration) {
  123311. this.imageProcessingConfiguration.applyByPostProcess = false;
  123312. }
  123313. };
  123314. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  123315. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  123316. ], ImageProcessingPostProcess.prototype, "_fromLinearSpace", void 0);
  123317. return ImageProcessingPostProcess;
  123318. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  123319. /***/ }),
  123320. /***/ "./PostProcesses/index.ts":
  123321. /*!********************************!*\
  123322. !*** ./PostProcesses/index.ts ***!
  123323. \********************************/
  123324. /*! exports provided: AnaglyphPostProcess, BlackAndWhitePostProcess, BloomEffect, BloomMergePostProcess, BlurPostProcess, ChromaticAberrationPostProcess, CircleOfConfusionPostProcess, ColorCorrectionPostProcess, ConvolutionPostProcess, DepthOfFieldBlurPostProcess, DepthOfFieldEffectBlurLevel, DepthOfFieldEffect, DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess, DisplayPassPostProcess, ExtractHighlightsPostProcess, FilterPostProcess, FxaaPostProcess, GrainPostProcess, HighlightsPostProcess, ImageProcessingPostProcess, MotionBlurPostProcess, PassPostProcess, PassCubePostProcess, PostProcess, PostProcessManager, RefractionPostProcess, SharpenPostProcess, StereoscopicInterlacePostProcess, TonemappingOperator, TonemapPostProcess, VolumetricLightScatteringPostProcess, VRDistortionCorrectionPostProcess, VRMultiviewToSingleviewPostProcess, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  123325. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123326. "use strict";
  123327. __webpack_require__.r(__webpack_exports__);
  123328. /* harmony import */ var _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  123329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  123330. /* harmony import */ var _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./blackAndWhitePostProcess */ "./PostProcesses/blackAndWhitePostProcess.ts");
  123331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__["BlackAndWhitePostProcess"]; });
  123332. /* harmony import */ var _bloomEffect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bloomEffect */ "./PostProcesses/bloomEffect.ts");
  123333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _bloomEffect__WEBPACK_IMPORTED_MODULE_2__["BloomEffect"]; });
  123334. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  123335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__["BloomMergePostProcess"]; });
  123336. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  123337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__["BlurPostProcess"]; });
  123338. /* harmony import */ var _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  123339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__["ChromaticAberrationPostProcess"]; });
  123340. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  123341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__["CircleOfConfusionPostProcess"]; });
  123342. /* harmony import */ var _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./colorCorrectionPostProcess */ "./PostProcesses/colorCorrectionPostProcess.ts");
  123343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__["ColorCorrectionPostProcess"]; });
  123344. /* harmony import */ var _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./convolutionPostProcess */ "./PostProcesses/convolutionPostProcess.ts");
  123345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__["ConvolutionPostProcess"]; });
  123346. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  123347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__["DepthOfFieldBlurPostProcess"]; });
  123348. /* harmony import */ var _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  123349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffectBlurLevel"]; });
  123350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffect"]; });
  123351. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  123352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcessOptions"]; });
  123353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcess"]; });
  123354. /* harmony import */ var _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./displayPassPostProcess */ "./PostProcesses/displayPassPostProcess.ts");
  123355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__["DisplayPassPostProcess"]; });
  123356. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  123357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__["ExtractHighlightsPostProcess"]; });
  123358. /* harmony import */ var _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./filterPostProcess */ "./PostProcesses/filterPostProcess.ts");
  123359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__["FilterPostProcess"]; });
  123360. /* harmony import */ var _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  123361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__["FxaaPostProcess"]; });
  123362. /* harmony import */ var _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  123363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__["GrainPostProcess"]; });
  123364. /* harmony import */ var _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./highlightsPostProcess */ "./PostProcesses/highlightsPostProcess.ts");
  123365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__["HighlightsPostProcess"]; });
  123366. /* harmony import */ var _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  123367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__["ImageProcessingPostProcess"]; });
  123368. /* harmony import */ var _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./motionBlurPostProcess */ "./PostProcesses/motionBlurPostProcess.ts");
  123369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__["MotionBlurPostProcess"]; });
  123370. /* harmony import */ var _passPostProcess__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./passPostProcess */ "./PostProcesses/passPostProcess.ts");
  123371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassPostProcess"]; });
  123372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassCubePostProcess"]; });
  123373. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _postProcess__WEBPACK_IMPORTED_MODULE_21__["PostProcess"]; });
  123375. /* harmony import */ var _postProcessManager__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./postProcessManager */ "./PostProcesses/postProcessManager.ts");
  123376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _postProcessManager__WEBPACK_IMPORTED_MODULE_22__["PostProcessManager"]; });
  123377. /* harmony import */ var _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./refractionPostProcess */ "./PostProcesses/refractionPostProcess.ts");
  123378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__["RefractionPostProcess"]; });
  123379. /* harmony import */ var _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./RenderPipeline/index */ "./PostProcesses/RenderPipeline/index.ts");
  123380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderEffect"]; });
  123381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipeline"]; });
  123382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManager"]; });
  123383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManagerSceneComponent"]; });
  123384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["DefaultRenderingPipeline"]; });
  123385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["LensRenderingPipeline"]; });
  123386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAO2RenderingPipeline"]; });
  123387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAORenderingPipeline"]; });
  123388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["StandardRenderingPipeline"]; });
  123389. /* harmony import */ var _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  123390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__["SharpenPostProcess"]; });
  123391. /* harmony import */ var _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  123392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__["StereoscopicInterlacePostProcess"]; });
  123393. /* harmony import */ var _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./tonemapPostProcess */ "./PostProcesses/tonemapPostProcess.ts");
  123394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemappingOperator"]; });
  123395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemapPostProcess"]; });
  123396. /* harmony import */ var _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./volumetricLightScatteringPostProcess */ "./PostProcesses/volumetricLightScatteringPostProcess.ts");
  123397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__["VolumetricLightScatteringPostProcess"]; });
  123398. /* harmony import */ var _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  123399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  123400. /* harmony import */ var _vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./vrMultiviewToSingleviewPostProcess */ "./PostProcesses/vrMultiviewToSingleviewPostProcess.ts");
  123401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleviewPostProcess", function() { return _vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_30__["VRMultiviewToSingleviewPostProcess"]; });
  123402. /***/ }),
  123403. /***/ "./PostProcesses/motionBlurPostProcess.ts":
  123404. /*!************************************************!*\
  123405. !*** ./PostProcesses/motionBlurPostProcess.ts ***!
  123406. \************************************************/
  123407. /*! exports provided: MotionBlurPostProcess */
  123408. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123409. "use strict";
  123410. __webpack_require__.r(__webpack_exports__);
  123411. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return MotionBlurPostProcess; });
  123412. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123413. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  123414. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  123415. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123416. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123417. /* harmony import */ var _Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Rendering/geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  123418. /* harmony import */ var _Animations_animatable__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Animations/animatable */ "./Animations/animatable.ts");
  123419. /* harmony import */ var _Rendering_geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  123420. /* harmony import */ var _Shaders_motionBlur_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/motionBlur.fragment */ "./Shaders/motionBlur.fragment.ts");
  123421. /**
  123422. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  123423. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  123424. * As an example, all you have to do is to create the post-process:
  123425. * var mb = new BABYLON.MotionBlurPostProcess(
  123426. * 'mb', // The name of the effect.
  123427. * scene, // The scene containing the objects to blur according to their velocity.
  123428. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  123429. * camera // The camera to apply the render pass to.
  123430. * );
  123431. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  123432. */
  123433. var MotionBlurPostProcess = /** @class */ (function (_super) {
  123434. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotionBlurPostProcess, _super);
  123435. /**
  123436. * Creates a new instance MotionBlurPostProcess
  123437. * @param name The name of the effect.
  123438. * @param scene The scene containing the objects to blur according to their velocity.
  123439. * @param options The required width/height ratio to downsize to before computing the render pass.
  123440. * @param camera The camera to apply the render pass to.
  123441. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123442. * @param engine The engine which the post process will be applied. (default: current engine)
  123443. * @param reusable If the post process can be reused on the same frame. (default: false)
  123444. * @param textureType Type of textures used when performing the post process. (default: 0)
  123445. * @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)
  123446. */
  123447. function MotionBlurPostProcess(name, scene, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  123448. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123449. if (blockCompilation === void 0) { blockCompilation = false; }
  123450. 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;
  123451. /**
  123452. * Defines how much the image is blurred by the movement. Default value is equal to 1
  123453. */
  123454. _this.motionStrength = 1;
  123455. _this._motionBlurSamples = 32;
  123456. _this._geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  123457. if (!_this._geometryBufferRenderer) {
  123458. // Geometry buffer renderer is not supported. So, work as a passthrough.
  123459. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Multiple Render Target support needed to compute object based motion blur");
  123460. _this.updateEffect();
  123461. }
  123462. else {
  123463. // Geometry buffer renderer is supported.
  123464. _this._geometryBufferRenderer.enableVelocity = true;
  123465. _this.onApply = function (effect) {
  123466. effect.setVector2("screenSize", new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](_this.width, _this.height));
  123467. effect.setFloat("motionScale", scene.getAnimationRatio());
  123468. effect.setFloat("motionStrength", _this.motionStrength);
  123469. if (_this._geometryBufferRenderer) {
  123470. var velocityIndex = _this._geometryBufferRenderer.getTextureIndex(_Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRenderer"].VELOCITY_TEXTURE_TYPE);
  123471. effect.setTexture("velocitySampler", _this._geometryBufferRenderer.getGBuffer().textures[velocityIndex]);
  123472. }
  123473. };
  123474. }
  123475. return _this;
  123476. }
  123477. Object.defineProperty(MotionBlurPostProcess.prototype, "motionBlurSamples", {
  123478. /**
  123479. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  123480. */
  123481. get: function () {
  123482. return this._motionBlurSamples;
  123483. },
  123484. /**
  123485. * Sets the number of iterations to be used for motion blur quality
  123486. */
  123487. set: function (samples) {
  123488. this._motionBlurSamples = samples;
  123489. if (this._geometryBufferRenderer) {
  123490. this.updateEffect("#define GEOMETRY_SUPPORTED\n#define SAMPLES " + samples.toFixed(1));
  123491. }
  123492. },
  123493. enumerable: true,
  123494. configurable: true
  123495. });
  123496. /**
  123497. * Disposes the post process.
  123498. * @param camera The camera to dispose the post process on.
  123499. */
  123500. MotionBlurPostProcess.prototype.dispose = function (camera) {
  123501. if (this._geometryBufferRenderer) {
  123502. // Clear previous transformation matrices dictionary used to compute objects velocities
  123503. this._geometryBufferRenderer._previousTransformationMatrices = {};
  123504. }
  123505. _super.prototype.dispose.call(this, camera);
  123506. };
  123507. return MotionBlurPostProcess;
  123508. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  123509. /***/ }),
  123510. /***/ "./PostProcesses/passPostProcess.ts":
  123511. /*!******************************************!*\
  123512. !*** ./PostProcesses/passPostProcess.ts ***!
  123513. \******************************************/
  123514. /*! exports provided: PassPostProcess, PassCubePostProcess */
  123515. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123516. "use strict";
  123517. __webpack_require__.r(__webpack_exports__);
  123518. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return PassPostProcess; });
  123519. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return PassCubePostProcess; });
  123520. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123521. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123522. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123523. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  123524. /* harmony import */ var _Shaders_pass_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/pass.fragment */ "./Shaders/pass.fragment.ts");
  123525. /* harmony import */ var _Shaders_passCube_fragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/passCube.fragment */ "./Shaders/passCube.fragment.ts");
  123526. /**
  123527. * PassPostProcess which produces an output the same as it's input
  123528. */
  123529. var PassPostProcess = /** @class */ (function (_super) {
  123530. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassPostProcess, _super);
  123531. /**
  123532. * Creates the PassPostProcess
  123533. * @param name The name of the effect.
  123534. * @param options The required width/height ratio to downsize to before computing the render pass.
  123535. * @param camera The camera to apply the render pass to.
  123536. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123537. * @param engine The engine which the post process will be applied. (default: current engine)
  123538. * @param reusable If the post process can be reused on the same frame. (default: false)
  123539. * @param textureType The type of texture to be used when performing the post processing.
  123540. * @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)
  123541. */
  123542. function PassPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  123543. if (camera === void 0) { camera = null; }
  123544. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123545. if (blockCompilation === void 0) { blockCompilation = false; }
  123546. return _super.call(this, name, "pass", null, null, options, camera, samplingMode, engine, reusable, undefined, textureType, undefined, null, blockCompilation) || this;
  123547. }
  123548. return PassPostProcess;
  123549. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  123550. /**
  123551. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  123552. */
  123553. var PassCubePostProcess = /** @class */ (function (_super) {
  123554. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassCubePostProcess, _super);
  123555. /**
  123556. * Creates the PassCubePostProcess
  123557. * @param name The name of the effect.
  123558. * @param options The required width/height ratio to downsize to before computing the render pass.
  123559. * @param camera The camera to apply the render pass to.
  123560. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123561. * @param engine The engine which the post process will be applied. (default: current engine)
  123562. * @param reusable If the post process can be reused on the same frame. (default: false)
  123563. * @param textureType The type of texture to be used when performing the post processing.
  123564. * @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)
  123565. */
  123566. function PassCubePostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  123567. if (camera === void 0) { camera = null; }
  123568. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123569. if (blockCompilation === void 0) { blockCompilation = false; }
  123570. var _this = _super.call(this, name, "passCube", null, null, options, camera, samplingMode, engine, reusable, "#define POSITIVEX", textureType, undefined, null, blockCompilation) || this;
  123571. _this._face = 0;
  123572. return _this;
  123573. }
  123574. Object.defineProperty(PassCubePostProcess.prototype, "face", {
  123575. /**
  123576. * Gets or sets the cube face to display.
  123577. * * 0 is +X
  123578. * * 1 is -X
  123579. * * 2 is +Y
  123580. * * 3 is -Y
  123581. * * 4 is +Z
  123582. * * 5 is -Z
  123583. */
  123584. get: function () {
  123585. return this._face;
  123586. },
  123587. set: function (value) {
  123588. if (value < 0 || value > 5) {
  123589. return;
  123590. }
  123591. this._face = value;
  123592. switch (this._face) {
  123593. case 0:
  123594. this.updateEffect("#define POSITIVEX");
  123595. break;
  123596. case 1:
  123597. this.updateEffect("#define NEGATIVEX");
  123598. break;
  123599. case 2:
  123600. this.updateEffect("#define POSITIVEY");
  123601. break;
  123602. case 3:
  123603. this.updateEffect("#define NEGATIVEY");
  123604. break;
  123605. case 4:
  123606. this.updateEffect("#define POSITIVEZ");
  123607. break;
  123608. case 5:
  123609. this.updateEffect("#define NEGATIVEZ");
  123610. break;
  123611. }
  123612. },
  123613. enumerable: true,
  123614. configurable: true
  123615. });
  123616. return PassCubePostProcess;
  123617. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  123618. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"]._RescalePostProcessFactory = function (engine) {
  123619. 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);
  123620. };
  123621. /***/ }),
  123622. /***/ "./PostProcesses/postProcess.ts":
  123623. /*!**************************************!*\
  123624. !*** ./PostProcesses/postProcess.ts ***!
  123625. \**************************************/
  123626. /*! exports provided: PostProcess */
  123627. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123628. "use strict";
  123629. __webpack_require__.r(__webpack_exports__);
  123630. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return PostProcess; });
  123631. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  123632. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  123633. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  123634. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  123635. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123636. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  123637. /**
  123638. * PostProcess can be used to apply a shader to a texture after it has been rendered
  123639. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  123640. */
  123641. var PostProcess = /** @class */ (function () {
  123642. /**
  123643. * Creates a new instance PostProcess
  123644. * @param name The name of the PostProcess.
  123645. * @param fragmentUrl The url of the fragment shader to be used.
  123646. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  123647. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  123648. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  123649. * @param camera The camera to apply the render pass to.
  123650. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123651. * @param engine The engine which the post process will be applied. (default: current engine)
  123652. * @param reusable If the post process can be reused on the same frame. (default: false)
  123653. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  123654. * @param textureType Type of textures used when performing the post process. (default: 0)
  123655. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  123656. * @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
  123657. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  123658. */
  123659. function PostProcess(
  123660. /** Name of the PostProcess. */
  123661. name, fragmentUrl, parameters, samplers, options, camera, samplingMode, engine, reusable, defines, textureType, vertexUrl, indexParameters, blockCompilation) {
  123662. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE; }
  123663. if (defines === void 0) { defines = null; }
  123664. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123665. if (vertexUrl === void 0) { vertexUrl = "postprocess"; }
  123666. if (blockCompilation === void 0) { blockCompilation = false; }
  123667. this.name = name;
  123668. /**
  123669. * Width of the texture to apply the post process on
  123670. */
  123671. this.width = -1;
  123672. /**
  123673. * Height of the texture to apply the post process on
  123674. */
  123675. this.height = -1;
  123676. /**
  123677. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  123678. * @hidden
  123679. */
  123680. this._outputTexture = null;
  123681. /**
  123682. * If the buffer needs to be cleared before applying the post process. (default: true)
  123683. * Should be set to false if shader will overwrite all previous pixels.
  123684. */
  123685. this.autoClear = true;
  123686. /**
  123687. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  123688. */
  123689. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE;
  123690. /**
  123691. * Animations to be used for the post processing
  123692. */
  123693. this.animations = new Array();
  123694. /**
  123695. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  123696. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  123697. */
  123698. this.enablePixelPerfectMode = false;
  123699. /**
  123700. * Force the postprocess to be applied without taking in account viewport
  123701. */
  123702. this.forceFullscreenViewport = true;
  123703. /**
  123704. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  123705. *
  123706. * | Value | Type | Description |
  123707. * | ----- | ----------------------------------- | ----------- |
  123708. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  123709. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  123710. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  123711. *
  123712. */
  123713. this.scaleMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].SCALEMODE_FLOOR;
  123714. /**
  123715. * Force textures to be a power of two (default: false)
  123716. */
  123717. this.alwaysForcePOT = false;
  123718. this._samples = 1;
  123719. /**
  123720. * Modify the scale of the post process to be the same as the viewport (default: false)
  123721. */
  123722. this.adaptScaleToCurrentViewport = false;
  123723. this._reusable = false;
  123724. /**
  123725. * Smart array of input and output textures for the post process.
  123726. * @hidden
  123727. */
  123728. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  123729. /**
  123730. * The index in _textures that corresponds to the output texture.
  123731. * @hidden
  123732. */
  123733. this._currentRenderTextureInd = 0;
  123734. this._scaleRatio = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 1);
  123735. this._texelSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  123736. // Events
  123737. /**
  123738. * An event triggered when the postprocess is activated.
  123739. */
  123740. this.onActivateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  123741. /**
  123742. * An event triggered when the postprocess changes its size.
  123743. */
  123744. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  123745. /**
  123746. * An event triggered when the postprocess applies its effect.
  123747. */
  123748. this.onApplyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  123749. /**
  123750. * An event triggered before rendering the postprocess
  123751. */
  123752. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  123753. /**
  123754. * An event triggered after rendering the postprocess
  123755. */
  123756. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  123757. if (camera != null) {
  123758. this._camera = camera;
  123759. this._scene = camera.getScene();
  123760. camera.attachPostProcess(this);
  123761. this._engine = this._scene.getEngine();
  123762. this._scene.postProcesses.push(this);
  123763. this.uniqueId = this._scene.getUniqueId();
  123764. }
  123765. else if (engine) {
  123766. this._engine = engine;
  123767. this._engine.postProcesses.push(this);
  123768. }
  123769. this._options = options;
  123770. this.renderTargetSamplingMode = samplingMode ? samplingMode : _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  123771. this._reusable = reusable || false;
  123772. this._textureType = textureType;
  123773. this._samplers = samplers || [];
  123774. this._samplers.push("textureSampler");
  123775. this._fragmentUrl = fragmentUrl;
  123776. this._vertexUrl = vertexUrl;
  123777. this._parameters = parameters || [];
  123778. this._parameters.push("scale");
  123779. this._indexParameters = indexParameters;
  123780. if (!blockCompilation) {
  123781. this.updateEffect(defines);
  123782. }
  123783. }
  123784. Object.defineProperty(PostProcess.prototype, "samples", {
  123785. /**
  123786. * Number of sample textures (default: 1)
  123787. */
  123788. get: function () {
  123789. return this._samples;
  123790. },
  123791. set: function (n) {
  123792. var _this = this;
  123793. this._samples = n;
  123794. this._textures.forEach(function (texture) {
  123795. if (texture.samples !== _this._samples) {
  123796. _this._engine.updateRenderTargetTextureSampleCount(texture, _this._samples);
  123797. }
  123798. });
  123799. },
  123800. enumerable: true,
  123801. configurable: true
  123802. });
  123803. /**
  123804. * Returns the fragment url or shader name used in the post process.
  123805. * @returns the fragment url or name in the shader store.
  123806. */
  123807. PostProcess.prototype.getEffectName = function () {
  123808. return this._fragmentUrl;
  123809. };
  123810. Object.defineProperty(PostProcess.prototype, "onActivate", {
  123811. /**
  123812. * A function that is added to the onActivateObservable
  123813. */
  123814. set: function (callback) {
  123815. if (this._onActivateObserver) {
  123816. this.onActivateObservable.remove(this._onActivateObserver);
  123817. }
  123818. if (callback) {
  123819. this._onActivateObserver = this.onActivateObservable.add(callback);
  123820. }
  123821. },
  123822. enumerable: true,
  123823. configurable: true
  123824. });
  123825. Object.defineProperty(PostProcess.prototype, "onSizeChanged", {
  123826. /**
  123827. * A function that is added to the onSizeChangedObservable
  123828. */
  123829. set: function (callback) {
  123830. if (this._onSizeChangedObserver) {
  123831. this.onSizeChangedObservable.remove(this._onSizeChangedObserver);
  123832. }
  123833. this._onSizeChangedObserver = this.onSizeChangedObservable.add(callback);
  123834. },
  123835. enumerable: true,
  123836. configurable: true
  123837. });
  123838. Object.defineProperty(PostProcess.prototype, "onApply", {
  123839. /**
  123840. * A function that is added to the onApplyObservable
  123841. */
  123842. set: function (callback) {
  123843. if (this._onApplyObserver) {
  123844. this.onApplyObservable.remove(this._onApplyObserver);
  123845. }
  123846. this._onApplyObserver = this.onApplyObservable.add(callback);
  123847. },
  123848. enumerable: true,
  123849. configurable: true
  123850. });
  123851. Object.defineProperty(PostProcess.prototype, "onBeforeRender", {
  123852. /**
  123853. * A function that is added to the onBeforeRenderObservable
  123854. */
  123855. set: function (callback) {
  123856. if (this._onBeforeRenderObserver) {
  123857. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  123858. }
  123859. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  123860. },
  123861. enumerable: true,
  123862. configurable: true
  123863. });
  123864. Object.defineProperty(PostProcess.prototype, "onAfterRender", {
  123865. /**
  123866. * A function that is added to the onAfterRenderObservable
  123867. */
  123868. set: function (callback) {
  123869. if (this._onAfterRenderObserver) {
  123870. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  123871. }
  123872. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  123873. },
  123874. enumerable: true,
  123875. configurable: true
  123876. });
  123877. Object.defineProperty(PostProcess.prototype, "inputTexture", {
  123878. /**
  123879. * 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
  123880. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  123881. */
  123882. get: function () {
  123883. return this._textures.data[this._currentRenderTextureInd];
  123884. },
  123885. set: function (value) {
  123886. this._forcedOutputTexture = value;
  123887. },
  123888. enumerable: true,
  123889. configurable: true
  123890. });
  123891. /**
  123892. * Gets the camera which post process is applied to.
  123893. * @returns The camera the post process is applied to.
  123894. */
  123895. PostProcess.prototype.getCamera = function () {
  123896. return this._camera;
  123897. };
  123898. Object.defineProperty(PostProcess.prototype, "texelSize", {
  123899. /**
  123900. * Gets the texel size of the postprocess.
  123901. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  123902. */
  123903. get: function () {
  123904. if (this._shareOutputWithPostProcess) {
  123905. return this._shareOutputWithPostProcess.texelSize;
  123906. }
  123907. if (this._forcedOutputTexture) {
  123908. this._texelSize.copyFromFloats(1.0 / this._forcedOutputTexture.width, 1.0 / this._forcedOutputTexture.height);
  123909. }
  123910. return this._texelSize;
  123911. },
  123912. enumerable: true,
  123913. configurable: true
  123914. });
  123915. /**
  123916. * Gets a string idenfifying the name of the class
  123917. * @returns "PostProcess" string
  123918. */
  123919. PostProcess.prototype.getClassName = function () {
  123920. return "PostProcess";
  123921. };
  123922. /**
  123923. * Gets the engine which this post process belongs to.
  123924. * @returns The engine the post process was enabled with.
  123925. */
  123926. PostProcess.prototype.getEngine = function () {
  123927. return this._engine;
  123928. };
  123929. /**
  123930. * The effect that is created when initializing the post process.
  123931. * @returns The created effect corrisponding the the postprocess.
  123932. */
  123933. PostProcess.prototype.getEffect = function () {
  123934. return this._effect;
  123935. };
  123936. /**
  123937. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  123938. * @param postProcess The post process to share the output with.
  123939. * @returns This post process.
  123940. */
  123941. PostProcess.prototype.shareOutputWith = function (postProcess) {
  123942. this._disposeTextures();
  123943. this._shareOutputWithPostProcess = postProcess;
  123944. return this;
  123945. };
  123946. /**
  123947. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  123948. * This should be called if the post process that shares output with this post process is disabled/disposed.
  123949. */
  123950. PostProcess.prototype.useOwnOutput = function () {
  123951. if (this._textures.length == 0) {
  123952. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  123953. }
  123954. this._shareOutputWithPostProcess = null;
  123955. };
  123956. /**
  123957. * Updates the effect with the current post process compile time values and recompiles the shader.
  123958. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  123959. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  123960. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  123961. * @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
  123962. * @param onCompiled Called when the shader has been compiled.
  123963. * @param onError Called if there is an error when compiling a shader.
  123964. */
  123965. PostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  123966. if (defines === void 0) { defines = null; }
  123967. if (uniforms === void 0) { uniforms = null; }
  123968. if (samplers === void 0) { samplers = null; }
  123969. 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);
  123970. };
  123971. /**
  123972. * The post process is reusable if it can be used multiple times within one frame.
  123973. * @returns If the post process is reusable
  123974. */
  123975. PostProcess.prototype.isReusable = function () {
  123976. return this._reusable;
  123977. };
  123978. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  123979. PostProcess.prototype.markTextureDirty = function () {
  123980. this.width = -1;
  123981. };
  123982. /**
  123983. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  123984. * 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.
  123985. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  123986. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  123987. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  123988. * @returns The target texture that was bound to be written to.
  123989. */
  123990. PostProcess.prototype.activate = function (camera, sourceTexture, forceDepthStencil) {
  123991. var _this = this;
  123992. if (sourceTexture === void 0) { sourceTexture = null; }
  123993. camera = camera || this._camera;
  123994. var scene = camera.getScene();
  123995. var engine = scene.getEngine();
  123996. var maxSize = engine.getCaps().maxTextureSize;
  123997. var requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderWidth(true)) * this._options) | 0;
  123998. var requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderHeight(true)) * this._options) | 0;
  123999. // 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
  124000. var webVRCamera = camera.parent;
  124001. if (webVRCamera && (webVRCamera.leftCamera == camera || webVRCamera.rightCamera == camera)) {
  124002. requiredWidth /= 2;
  124003. }
  124004. var desiredWidth = (this._options.width || requiredWidth);
  124005. var desiredHeight = this._options.height || requiredHeight;
  124006. if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
  124007. if (this.adaptScaleToCurrentViewport) {
  124008. var currentViewport = engine.currentViewport;
  124009. if (currentViewport) {
  124010. desiredWidth *= currentViewport.width;
  124011. desiredHeight *= currentViewport.height;
  124012. }
  124013. }
  124014. if (this.renderTargetSamplingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE || this.alwaysForcePOT) {
  124015. if (!this._options.width) {
  124016. desiredWidth = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredWidth, maxSize, this.scaleMode) : desiredWidth;
  124017. }
  124018. if (!this._options.height) {
  124019. desiredHeight = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredHeight, maxSize, this.scaleMode) : desiredHeight;
  124020. }
  124021. }
  124022. if (this.width !== desiredWidth || this.height !== desiredHeight) {
  124023. if (this._textures.length > 0) {
  124024. for (var i = 0; i < this._textures.length; i++) {
  124025. this._engine._releaseTexture(this._textures.data[i]);
  124026. }
  124027. this._textures.reset();
  124028. }
  124029. this.width = desiredWidth;
  124030. this.height = desiredHeight;
  124031. var textureSize = { width: this.width, height: this.height };
  124032. var textureOptions = {
  124033. generateMipMaps: false,
  124034. generateDepthBuffer: forceDepthStencil || camera._postProcesses.indexOf(this) === 0,
  124035. generateStencilBuffer: (forceDepthStencil || camera._postProcesses.indexOf(this) === 0) && this._engine.isStencilEnable,
  124036. samplingMode: this.renderTargetSamplingMode,
  124037. type: this._textureType
  124038. };
  124039. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  124040. if (this._reusable) {
  124041. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  124042. }
  124043. this._texelSize.copyFromFloats(1.0 / this.width, 1.0 / this.height);
  124044. this.onSizeChangedObservable.notifyObservers(this);
  124045. }
  124046. this._textures.forEach(function (texture) {
  124047. if (texture.samples !== _this.samples) {
  124048. _this._engine.updateRenderTargetTextureSampleCount(texture, _this.samples);
  124049. }
  124050. });
  124051. }
  124052. var target;
  124053. if (this._shareOutputWithPostProcess) {
  124054. target = this._shareOutputWithPostProcess.inputTexture;
  124055. }
  124056. else if (this._forcedOutputTexture) {
  124057. target = this._forcedOutputTexture;
  124058. this.width = this._forcedOutputTexture.width;
  124059. this.height = this._forcedOutputTexture.height;
  124060. }
  124061. else {
  124062. target = this.inputTexture;
  124063. }
  124064. // Bind the input of this post process to be used as the output of the previous post process.
  124065. if (this.enablePixelPerfectMode) {
  124066. this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);
  124067. this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight, this.forceFullscreenViewport);
  124068. }
  124069. else {
  124070. this._scaleRatio.copyFromFloats(1, 1);
  124071. this._engine.bindFramebuffer(target, 0, undefined, undefined, this.forceFullscreenViewport);
  124072. }
  124073. this.onActivateObservable.notifyObservers(camera);
  124074. // Clear
  124075. if (this.autoClear && this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE) {
  124076. this._engine.clear(this.clearColor ? this.clearColor : scene.clearColor, scene._allowPostProcessClearColor, true, true);
  124077. }
  124078. if (this._reusable) {
  124079. this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
  124080. }
  124081. return target;
  124082. };
  124083. Object.defineProperty(PostProcess.prototype, "isSupported", {
  124084. /**
  124085. * If the post process is supported.
  124086. */
  124087. get: function () {
  124088. return this._effect.isSupported;
  124089. },
  124090. enumerable: true,
  124091. configurable: true
  124092. });
  124093. Object.defineProperty(PostProcess.prototype, "aspectRatio", {
  124094. /**
  124095. * The aspect ratio of the output texture.
  124096. */
  124097. get: function () {
  124098. if (this._shareOutputWithPostProcess) {
  124099. return this._shareOutputWithPostProcess.aspectRatio;
  124100. }
  124101. if (this._forcedOutputTexture) {
  124102. return this._forcedOutputTexture.width / this._forcedOutputTexture.height;
  124103. }
  124104. return this.width / this.height;
  124105. },
  124106. enumerable: true,
  124107. configurable: true
  124108. });
  124109. /**
  124110. * Get a value indicating if the post-process is ready to be used
  124111. * @returns true if the post-process is ready (shader is compiled)
  124112. */
  124113. PostProcess.prototype.isReady = function () {
  124114. return this._effect && this._effect.isReady();
  124115. };
  124116. /**
  124117. * Binds all textures and uniforms to the shader, this will be run on every pass.
  124118. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  124119. */
  124120. PostProcess.prototype.apply = function () {
  124121. // Check
  124122. if (!this._effect || !this._effect.isReady()) {
  124123. return null;
  124124. }
  124125. // States
  124126. this._engine.enableEffect(this._effect);
  124127. this._engine.setState(false);
  124128. this._engine.setDepthBuffer(false);
  124129. this._engine.setDepthWrite(false);
  124130. // Alpha
  124131. this._engine.setAlphaMode(this.alphaMode);
  124132. if (this.alphaConstants) {
  124133. this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
  124134. }
  124135. // Bind the output texture of the preivous post process as the input to this post process.
  124136. var source;
  124137. if (this._shareOutputWithPostProcess) {
  124138. source = this._shareOutputWithPostProcess.inputTexture;
  124139. }
  124140. else if (this._forcedOutputTexture) {
  124141. source = this._forcedOutputTexture;
  124142. }
  124143. else {
  124144. source = this.inputTexture;
  124145. }
  124146. this._effect._bindTexture("textureSampler", source);
  124147. // Parameters
  124148. this._effect.setVector2("scale", this._scaleRatio);
  124149. this.onApplyObservable.notifyObservers(this._effect);
  124150. return this._effect;
  124151. };
  124152. PostProcess.prototype._disposeTextures = function () {
  124153. if (this._shareOutputWithPostProcess || this._forcedOutputTexture) {
  124154. return;
  124155. }
  124156. if (this._textures.length > 0) {
  124157. for (var i = 0; i < this._textures.length; i++) {
  124158. this._engine._releaseTexture(this._textures.data[i]);
  124159. }
  124160. }
  124161. this._textures.dispose();
  124162. };
  124163. /**
  124164. * Disposes the post process.
  124165. * @param camera The camera to dispose the post process on.
  124166. */
  124167. PostProcess.prototype.dispose = function (camera) {
  124168. camera = camera || this._camera;
  124169. this._disposeTextures();
  124170. if (this._scene) {
  124171. var index_1 = this._scene.postProcesses.indexOf(this);
  124172. if (index_1 !== -1) {
  124173. this._scene.postProcesses.splice(index_1, 1);
  124174. }
  124175. }
  124176. else {
  124177. var index_2 = this._engine.postProcesses.indexOf(this);
  124178. if (index_2 !== -1) {
  124179. this._engine.postProcesses.splice(index_2, 1);
  124180. }
  124181. }
  124182. if (!camera) {
  124183. return;
  124184. }
  124185. camera.detachPostProcess(this);
  124186. var index = camera._postProcesses.indexOf(this);
  124187. if (index === 0 && camera._postProcesses.length > 0) {
  124188. var firstPostProcess = this._camera._getFirstPostProcess();
  124189. if (firstPostProcess) {
  124190. firstPostProcess.markTextureDirty();
  124191. }
  124192. }
  124193. this.onActivateObservable.clear();
  124194. this.onAfterRenderObservable.clear();
  124195. this.onApplyObservable.clear();
  124196. this.onBeforeRenderObservable.clear();
  124197. this.onSizeChangedObservable.clear();
  124198. };
  124199. return PostProcess;
  124200. }());
  124201. /***/ }),
  124202. /***/ "./PostProcesses/postProcessManager.ts":
  124203. /*!*********************************************!*\
  124204. !*** ./PostProcesses/postProcessManager.ts ***!
  124205. \*********************************************/
  124206. /*! exports provided: PostProcessManager */
  124207. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124208. "use strict";
  124209. __webpack_require__.r(__webpack_exports__);
  124210. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return PostProcessManager; });
  124211. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  124212. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  124213. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124214. /**
  124215. * PostProcessManager is used to manage one or more post processes or post process pipelines
  124216. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124217. */
  124218. var PostProcessManager = /** @class */ (function () {
  124219. /**
  124220. * Creates a new instance PostProcess
  124221. * @param scene The scene that the post process is associated with.
  124222. */
  124223. function PostProcessManager(scene) {
  124224. this._vertexBuffers = {};
  124225. this._scene = scene;
  124226. }
  124227. PostProcessManager.prototype._prepareBuffers = function () {
  124228. if (this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind]) {
  124229. return;
  124230. }
  124231. // VBO
  124232. var vertices = [];
  124233. vertices.push(1, 1);
  124234. vertices.push(-1, 1);
  124235. vertices.push(-1, -1);
  124236. vertices.push(1, -1);
  124237. 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);
  124238. this._buildIndexBuffer();
  124239. };
  124240. PostProcessManager.prototype._buildIndexBuffer = function () {
  124241. // Indices
  124242. var indices = [];
  124243. indices.push(0);
  124244. indices.push(1);
  124245. indices.push(2);
  124246. indices.push(0);
  124247. indices.push(2);
  124248. indices.push(3);
  124249. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  124250. };
  124251. /**
  124252. * Rebuilds the vertex buffers of the manager.
  124253. * @hidden
  124254. */
  124255. PostProcessManager.prototype._rebuild = function () {
  124256. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  124257. if (!vb) {
  124258. return;
  124259. }
  124260. vb._rebuild();
  124261. this._buildIndexBuffer();
  124262. };
  124263. // Methods
  124264. /**
  124265. * Prepares a frame to be run through a post process.
  124266. * @param sourceTexture The input texture to the post procesess. (default: null)
  124267. * @param postProcesses An array of post processes to be run. (default: null)
  124268. * @returns True if the post processes were able to be run.
  124269. * @hidden
  124270. */
  124271. PostProcessManager.prototype._prepareFrame = function (sourceTexture, postProcesses) {
  124272. if (sourceTexture === void 0) { sourceTexture = null; }
  124273. if (postProcesses === void 0) { postProcesses = null; }
  124274. var camera = this._scene.activeCamera;
  124275. if (!camera) {
  124276. return false;
  124277. }
  124278. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  124279. if (!postProcesses || postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  124280. return false;
  124281. }
  124282. postProcesses[0].activate(camera, sourceTexture, postProcesses !== null && postProcesses !== undefined);
  124283. return true;
  124284. };
  124285. /**
  124286. * Manually render a set of post processes to a texture.
  124287. * @param postProcesses An array of post processes to be run.
  124288. * @param targetTexture The target texture to render to.
  124289. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  124290. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  124291. * @param lodLevel defines which lod of the texture to render to
  124292. */
  124293. PostProcessManager.prototype.directRender = function (postProcesses, targetTexture, forceFullscreenViewport, faceIndex, lodLevel) {
  124294. if (targetTexture === void 0) { targetTexture = null; }
  124295. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  124296. if (faceIndex === void 0) { faceIndex = 0; }
  124297. if (lodLevel === void 0) { lodLevel = 0; }
  124298. var engine = this._scene.getEngine();
  124299. for (var index = 0; index < postProcesses.length; index++) {
  124300. if (index < postProcesses.length - 1) {
  124301. postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture);
  124302. }
  124303. else {
  124304. if (targetTexture) {
  124305. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport, undefined, lodLevel);
  124306. }
  124307. else {
  124308. engine.restoreDefaultFramebuffer();
  124309. }
  124310. }
  124311. var pp = postProcesses[index];
  124312. var effect = pp.apply();
  124313. if (effect) {
  124314. pp.onBeforeRenderObservable.notifyObservers(effect);
  124315. // VBOs
  124316. this._prepareBuffers();
  124317. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  124318. // Draw order
  124319. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  124320. pp.onAfterRenderObservable.notifyObservers(effect);
  124321. }
  124322. }
  124323. // Restore depth buffer
  124324. engine.setDepthBuffer(true);
  124325. engine.setDepthWrite(true);
  124326. };
  124327. /**
  124328. * Finalize the result of the output of the postprocesses.
  124329. * @param doNotPresent If true the result will not be displayed to the screen.
  124330. * @param targetTexture The target texture to render to.
  124331. * @param faceIndex The index of the face to bind the target texture to.
  124332. * @param postProcesses The array of post processes to render.
  124333. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  124334. * @hidden
  124335. */
  124336. PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, faceIndex, postProcesses, forceFullscreenViewport) {
  124337. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  124338. var camera = this._scene.activeCamera;
  124339. if (!camera) {
  124340. return;
  124341. }
  124342. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  124343. if (postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  124344. return;
  124345. }
  124346. var engine = this._scene.getEngine();
  124347. for (var index = 0, len = postProcesses.length; index < len; index++) {
  124348. var pp = postProcesses[index];
  124349. if (index < len - 1) {
  124350. pp._outputTexture = postProcesses[index + 1].activate(camera, targetTexture);
  124351. }
  124352. else {
  124353. if (targetTexture) {
  124354. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport);
  124355. pp._outputTexture = targetTexture;
  124356. }
  124357. else {
  124358. engine.restoreDefaultFramebuffer();
  124359. pp._outputTexture = null;
  124360. }
  124361. }
  124362. if (doNotPresent) {
  124363. break;
  124364. }
  124365. var effect = pp.apply();
  124366. if (effect) {
  124367. pp.onBeforeRenderObservable.notifyObservers(effect);
  124368. // VBOs
  124369. this._prepareBuffers();
  124370. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  124371. // Draw order
  124372. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  124373. pp.onAfterRenderObservable.notifyObservers(effect);
  124374. }
  124375. }
  124376. // Restore states
  124377. engine.setDepthBuffer(true);
  124378. engine.setDepthWrite(true);
  124379. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  124380. };
  124381. /**
  124382. * Disposes of the post process manager.
  124383. */
  124384. PostProcessManager.prototype.dispose = function () {
  124385. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  124386. if (buffer) {
  124387. buffer.dispose();
  124388. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  124389. }
  124390. if (this._indexBuffer) {
  124391. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  124392. this._indexBuffer = null;
  124393. }
  124394. };
  124395. return PostProcessManager;
  124396. }());
  124397. /***/ }),
  124398. /***/ "./PostProcesses/refractionPostProcess.ts":
  124399. /*!************************************************!*\
  124400. !*** ./PostProcesses/refractionPostProcess.ts ***!
  124401. \************************************************/
  124402. /*! exports provided: RefractionPostProcess */
  124403. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124404. "use strict";
  124405. __webpack_require__.r(__webpack_exports__);
  124406. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return RefractionPostProcess; });
  124407. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  124408. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  124409. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  124410. /* harmony import */ var _Shaders_refraction_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/refraction.fragment */ "./Shaders/refraction.fragment.ts");
  124411. /**
  124412. * Post process which applies a refractin texture
  124413. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124414. */
  124415. var RefractionPostProcess = /** @class */ (function (_super) {
  124416. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionPostProcess, _super);
  124417. /**
  124418. * Initializes the RefractionPostProcess
  124419. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124420. * @param name The name of the effect.
  124421. * @param refractionTextureUrl Url of the refraction texture to use
  124422. * @param color the base color of the refraction (used to taint the rendering)
  124423. * @param depth simulated refraction depth
  124424. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  124425. * @param camera The camera to apply the render pass to.
  124426. * @param options The required width/height ratio to downsize to before computing the render pass.
  124427. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124428. * @param engine The engine which the post process will be applied. (default: current engine)
  124429. * @param reusable If the post process can be reused on the same frame. (default: false)
  124430. */
  124431. function RefractionPostProcess(name, refractionTextureUrl,
  124432. /** the base color of the refraction (used to taint the rendering) */
  124433. color,
  124434. /** simulated refraction depth */
  124435. depth,
  124436. /** the coefficient of the base color (0 to remove base color tainting) */
  124437. colorLevel, options, camera, samplingMode, engine, reusable) {
  124438. var _this = _super.call(this, name, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], options, camera, samplingMode, engine, reusable) || this;
  124439. _this.color = color;
  124440. _this.depth = depth;
  124441. _this.colorLevel = colorLevel;
  124442. _this._ownRefractionTexture = true;
  124443. _this.onActivateObservable.add(function (cam) {
  124444. _this._refTexture = _this._refTexture || new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](refractionTextureUrl, cam.getScene());
  124445. });
  124446. _this.onApplyObservable.add(function (effect) {
  124447. effect.setColor3("baseColor", _this.color);
  124448. effect.setFloat("depth", _this.depth);
  124449. effect.setFloat("colorLevel", _this.colorLevel);
  124450. effect.setTexture("refractionSampler", _this._refTexture);
  124451. });
  124452. return _this;
  124453. }
  124454. Object.defineProperty(RefractionPostProcess.prototype, "refractionTexture", {
  124455. /**
  124456. * Gets or sets the refraction texture
  124457. * Please note that you are responsible for disposing the texture if you set it manually
  124458. */
  124459. get: function () {
  124460. return this._refTexture;
  124461. },
  124462. set: function (value) {
  124463. if (this._refTexture && this._ownRefractionTexture) {
  124464. this._refTexture.dispose();
  124465. }
  124466. this._refTexture = value;
  124467. this._ownRefractionTexture = false;
  124468. },
  124469. enumerable: true,
  124470. configurable: true
  124471. });
  124472. // Methods
  124473. /**
  124474. * Disposes of the post process
  124475. * @param camera Camera to dispose post process on
  124476. */
  124477. RefractionPostProcess.prototype.dispose = function (camera) {
  124478. if (this._refTexture && this._ownRefractionTexture) {
  124479. this._refTexture.dispose();
  124480. this._refTexture = null;
  124481. }
  124482. _super.prototype.dispose.call(this, camera);
  124483. };
  124484. return RefractionPostProcess;
  124485. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  124486. /***/ }),
  124487. /***/ "./PostProcesses/sharpenPostProcess.ts":
  124488. /*!*********************************************!*\
  124489. !*** ./PostProcesses/sharpenPostProcess.ts ***!
  124490. \*********************************************/
  124491. /*! exports provided: SharpenPostProcess */
  124492. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124493. "use strict";
  124494. __webpack_require__.r(__webpack_exports__);
  124495. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return SharpenPostProcess; });
  124496. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  124497. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  124498. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124499. /* harmony import */ var _Shaders_sharpen_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/sharpen.fragment */ "./Shaders/sharpen.fragment.ts");
  124500. /**
  124501. * The SharpenPostProcess applies a sharpen kernel to every pixel
  124502. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  124503. */
  124504. var SharpenPostProcess = /** @class */ (function (_super) {
  124505. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SharpenPostProcess, _super);
  124506. /**
  124507. * Creates a new instance ConvolutionPostProcess
  124508. * @param name The name of the effect.
  124509. * @param options The required width/height ratio to downsize to before computing the render pass.
  124510. * @param camera The camera to apply the render pass to.
  124511. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124512. * @param engine The engine which the post process will be applied. (default: current engine)
  124513. * @param reusable If the post process can be reused on the same frame. (default: false)
  124514. * @param textureType Type of textures used when performing the post process. (default: 0)
  124515. * @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)
  124516. */
  124517. function SharpenPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  124518. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  124519. if (blockCompilation === void 0) { blockCompilation = false; }
  124520. var _this = _super.call(this, name, "sharpen", ["sharpnessAmounts", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  124521. /**
  124522. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  124523. */
  124524. _this.colorAmount = 1.0;
  124525. /**
  124526. * How much sharpness should be applied (default: 0.3)
  124527. */
  124528. _this.edgeAmount = 0.3;
  124529. _this.onApply = function (effect) {
  124530. effect.setFloat2("screenSize", _this.width, _this.height);
  124531. effect.setFloat2("sharpnessAmounts", _this.edgeAmount, _this.colorAmount);
  124532. };
  124533. return _this;
  124534. }
  124535. return SharpenPostProcess;
  124536. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  124537. /***/ }),
  124538. /***/ "./PostProcesses/stereoscopicInterlacePostProcess.ts":
  124539. /*!***********************************************************!*\
  124540. !*** ./PostProcesses/stereoscopicInterlacePostProcess.ts ***!
  124541. \***********************************************************/
  124542. /*! exports provided: StereoscopicInterlacePostProcess */
  124543. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124544. "use strict";
  124545. __webpack_require__.r(__webpack_exports__);
  124546. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return StereoscopicInterlacePostProcess; });
  124547. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  124548. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  124549. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  124550. /* harmony import */ var _Shaders_stereoscopicInterlace_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/stereoscopicInterlace.fragment */ "./Shaders/stereoscopicInterlace.fragment.ts");
  124551. /**
  124552. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  124553. */
  124554. var StereoscopicInterlacePostProcess = /** @class */ (function (_super) {
  124555. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicInterlacePostProcess, _super);
  124556. /**
  124557. * Initializes a StereoscopicInterlacePostProcess
  124558. * @param name The name of the effect.
  124559. * @param rigCameras The rig cameras to be appled to the post process
  124560. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  124561. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124562. * @param engine The engine which the post process will be applied. (default: current engine)
  124563. * @param reusable If the post process can be reused on the same frame. (default: false)
  124564. */
  124565. function StereoscopicInterlacePostProcess(name, rigCameras, isStereoscopicHoriz, samplingMode, engine, reusable) {
  124566. var _this = _super.call(this, name, "stereoscopicInterlace", ['stepSize'], ['camASampler'], 1, rigCameras[1], samplingMode, engine, reusable, isStereoscopicHoriz ? "#define IS_STEREOSCOPIC_HORIZ 1" : undefined) || this;
  124567. _this._passedProcess = rigCameras[0]._rigPostProcess;
  124568. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  124569. _this.onSizeChangedObservable.add(function () {
  124570. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  124571. });
  124572. _this.onApplyObservable.add(function (effect) {
  124573. effect.setTextureFromPostProcess("camASampler", _this._passedProcess);
  124574. effect.setFloat2("stepSize", _this._stepSize.x, _this._stepSize.y);
  124575. });
  124576. return _this;
  124577. }
  124578. return StereoscopicInterlacePostProcess;
  124579. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  124580. /***/ }),
  124581. /***/ "./PostProcesses/tonemapPostProcess.ts":
  124582. /*!*********************************************!*\
  124583. !*** ./PostProcesses/tonemapPostProcess.ts ***!
  124584. \*********************************************/
  124585. /*! exports provided: TonemappingOperator, TonemapPostProcess */
  124586. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124587. "use strict";
  124588. __webpack_require__.r(__webpack_exports__);
  124589. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return TonemappingOperator; });
  124590. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return TonemapPostProcess; });
  124591. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  124592. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  124593. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124594. /* harmony import */ var _Shaders_tonemap_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/tonemap.fragment */ "./Shaders/tonemap.fragment.ts");
  124595. /** Defines operator used for tonemapping */
  124596. var TonemappingOperator;
  124597. (function (TonemappingOperator) {
  124598. /** Hable */
  124599. TonemappingOperator[TonemappingOperator["Hable"] = 0] = "Hable";
  124600. /** Reinhard */
  124601. TonemappingOperator[TonemappingOperator["Reinhard"] = 1] = "Reinhard";
  124602. /** HejiDawson */
  124603. TonemappingOperator[TonemappingOperator["HejiDawson"] = 2] = "HejiDawson";
  124604. /** Photographic */
  124605. TonemappingOperator[TonemappingOperator["Photographic"] = 3] = "Photographic";
  124606. })(TonemappingOperator || (TonemappingOperator = {}));
  124607. /**
  124608. * Defines a post process to apply tone mapping
  124609. */
  124610. var TonemapPostProcess = /** @class */ (function (_super) {
  124611. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TonemapPostProcess, _super);
  124612. /**
  124613. * Creates a new TonemapPostProcess
  124614. * @param name defines the name of the postprocess
  124615. * @param _operator defines the operator to use
  124616. * @param exposureAdjustment defines the required exposure adjustement
  124617. * @param camera defines the camera to use (can be null)
  124618. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  124619. * @param engine defines the hosting engine (can be ignore if camera is set)
  124620. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  124621. */
  124622. function TonemapPostProcess(name, _operator,
  124623. /** Defines the required exposure adjustement */
  124624. exposureAdjustment, camera, samplingMode, engine, textureFormat) {
  124625. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE; }
  124626. if (textureFormat === void 0) { textureFormat = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  124627. var _this = _super.call(this, name, "tonemap", ["_ExposureAdjustment"], null, 1.0, camera, samplingMode, engine, true, null, textureFormat) || this;
  124628. _this._operator = _operator;
  124629. _this.exposureAdjustment = exposureAdjustment;
  124630. var defines = "#define ";
  124631. if (_this._operator === TonemappingOperator.Hable) {
  124632. defines += "HABLE_TONEMAPPING";
  124633. }
  124634. else if (_this._operator === TonemappingOperator.Reinhard) {
  124635. defines += "REINHARD_TONEMAPPING";
  124636. }
  124637. else if (_this._operator === TonemappingOperator.HejiDawson) {
  124638. defines += "OPTIMIZED_HEJIDAWSON_TONEMAPPING";
  124639. }
  124640. else if (_this._operator === TonemappingOperator.Photographic) {
  124641. defines += "PHOTOGRAPHIC_TONEMAPPING";
  124642. }
  124643. //sadly a second call to create the effect.
  124644. _this.updateEffect(defines);
  124645. _this.onApply = function (effect) {
  124646. effect.setFloat("_ExposureAdjustment", _this.exposureAdjustment);
  124647. };
  124648. return _this;
  124649. }
  124650. return TonemapPostProcess;
  124651. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  124652. /***/ }),
  124653. /***/ "./PostProcesses/volumetricLightScatteringPostProcess.ts":
  124654. /*!***************************************************************!*\
  124655. !*** ./PostProcesses/volumetricLightScatteringPostProcess.ts ***!
  124656. \***************************************************************/
  124657. /*! exports provided: VolumetricLightScatteringPostProcess */
  124658. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124659. "use strict";
  124660. __webpack_require__.r(__webpack_exports__);
  124661. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return VolumetricLightScatteringPostProcess; });
  124662. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  124663. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  124664. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  124665. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  124666. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  124667. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  124668. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  124669. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  124670. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  124671. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  124672. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  124673. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  124674. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124675. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  124676. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  124677. /* harmony import */ var _Shaders_volumetricLightScattering_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/volumetricLightScattering.fragment */ "./Shaders/volumetricLightScattering.fragment.ts");
  124678. /* harmony import */ var _Shaders_volumetricLightScatteringPass_fragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Shaders/volumetricLightScatteringPass.fragment */ "./Shaders/volumetricLightScatteringPass.fragment.ts");
  124679. /**
  124680. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  124681. */
  124682. var VolumetricLightScatteringPostProcess = /** @class */ (function (_super) {
  124683. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumetricLightScatteringPostProcess, _super);
  124684. /**
  124685. * @constructor
  124686. * @param name The post-process name
  124687. * @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)
  124688. * @param camera The camera that the post-process will be attached to
  124689. * @param mesh The mesh used to create the light scattering
  124690. * @param samples The post-process quality, default 100
  124691. * @param samplingModeThe post-process filtering mode
  124692. * @param engine The babylon engine
  124693. * @param reusable If the post-process is reusable
  124694. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  124695. */
  124696. function VolumetricLightScatteringPostProcess(name, ratio, camera, mesh, samples, samplingMode, engine, reusable, scene) {
  124697. if (samples === void 0) { samples = 100; }
  124698. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].BILINEAR_SAMPLINGMODE; }
  124699. 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;
  124700. _this._screenCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  124701. /**
  124702. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  124703. */
  124704. _this.customMeshPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  124705. /**
  124706. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  124707. */
  124708. _this.useCustomMeshPosition = false;
  124709. /**
  124710. * If the post-process should inverse the light scattering direction
  124711. */
  124712. _this.invert = true;
  124713. /**
  124714. * Array containing the excluded meshes not rendered in the internal pass
  124715. */
  124716. _this.excludedMeshes = new Array();
  124717. /**
  124718. * Controls the overall intensity of the post-process
  124719. */
  124720. _this.exposure = 0.3;
  124721. /**
  124722. * Dissipates each sample's contribution in range [0, 1]
  124723. */
  124724. _this.decay = 0.96815;
  124725. /**
  124726. * Controls the overall intensity of each sample
  124727. */
  124728. _this.weight = 0.58767;
  124729. /**
  124730. * Controls the density of each sample
  124731. */
  124732. _this.density = 0.926;
  124733. scene = ((camera === null) ? scene : camera.getScene()); // parameter "scene" can be null.
  124734. engine = scene.getEngine();
  124735. _this._viewPort = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Viewport"](0, 0, 1, 1).toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  124736. // Configure mesh
  124737. _this.mesh = ((mesh !== null) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene));
  124738. // Configure
  124739. _this._createPass(scene, ratio.passRatio || ratio);
  124740. _this.onActivate = function (camera) {
  124741. if (!_this.isSupported) {
  124742. _this.dispose(camera);
  124743. }
  124744. _this.onActivate = null;
  124745. };
  124746. _this.onApplyObservable.add(function (effect) {
  124747. _this._updateMeshScreenCoordinates(scene);
  124748. effect.setTexture("lightScatteringSampler", _this._volumetricLightScatteringRTT);
  124749. effect.setFloat("exposure", _this.exposure);
  124750. effect.setFloat("decay", _this.decay);
  124751. effect.setFloat("weight", _this.weight);
  124752. effect.setFloat("density", _this.density);
  124753. effect.setVector2("meshPositionOnScreen", _this._screenCoordinates);
  124754. });
  124755. return _this;
  124756. }
  124757. Object.defineProperty(VolumetricLightScatteringPostProcess.prototype, "useDiffuseColor", {
  124758. /**
  124759. * @hidden
  124760. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  124761. */
  124762. get: function () {
  124763. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  124764. return false;
  124765. },
  124766. set: function (useDiffuseColor) {
  124767. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  124768. },
  124769. enumerable: true,
  124770. configurable: true
  124771. });
  124772. /**
  124773. * Returns the string "VolumetricLightScatteringPostProcess"
  124774. * @returns "VolumetricLightScatteringPostProcess"
  124775. */
  124776. VolumetricLightScatteringPostProcess.prototype.getClassName = function () {
  124777. return "VolumetricLightScatteringPostProcess";
  124778. };
  124779. VolumetricLightScatteringPostProcess.prototype._isReady = function (subMesh, useInstances) {
  124780. var mesh = subMesh.getMesh();
  124781. // Render this.mesh as default
  124782. if (mesh === this.mesh && mesh.material) {
  124783. return mesh.material.isReady(mesh);
  124784. }
  124785. var defines = [];
  124786. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  124787. var material = subMesh.getMaterial();
  124788. // Alpha test
  124789. if (material) {
  124790. if (material.needAlphaTesting()) {
  124791. defines.push("#define ALPHATEST");
  124792. }
  124793. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind)) {
  124794. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  124795. defines.push("#define UV1");
  124796. }
  124797. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind)) {
  124798. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  124799. defines.push("#define UV2");
  124800. }
  124801. }
  124802. // Bones
  124803. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  124804. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  124805. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  124806. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  124807. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  124808. }
  124809. else {
  124810. defines.push("#define NUM_BONE_INFLUENCERS 0");
  124811. }
  124812. // Instances
  124813. if (useInstances) {
  124814. defines.push("#define INSTANCES");
  124815. attribs.push("world0");
  124816. attribs.push("world1");
  124817. attribs.push("world2");
  124818. attribs.push("world3");
  124819. }
  124820. // Get correct effect
  124821. var join = defines.join("\n");
  124822. if (this._cachedDefines !== join) {
  124823. this._cachedDefines = join;
  124824. this._volumetricLightScatteringPass = mesh.getScene().getEngine().createEffect({ vertexElement: "depth", fragmentElement: "volumetricLightScatteringPass" }, attribs, ["world", "mBones", "viewProjection", "diffuseMatrix"], ["diffuseSampler"], join);
  124825. }
  124826. return this._volumetricLightScatteringPass.isReady();
  124827. };
  124828. /**
  124829. * Sets the new light position for light scattering effect
  124830. * @param position The new custom light position
  124831. */
  124832. VolumetricLightScatteringPostProcess.prototype.setCustomMeshPosition = function (position) {
  124833. this.customMeshPosition = position;
  124834. };
  124835. /**
  124836. * Returns the light position for light scattering effect
  124837. * @return Vector3 The custom light position
  124838. */
  124839. VolumetricLightScatteringPostProcess.prototype.getCustomMeshPosition = function () {
  124840. return this.customMeshPosition;
  124841. };
  124842. /**
  124843. * Disposes the internal assets and detaches the post-process from the camera
  124844. */
  124845. VolumetricLightScatteringPostProcess.prototype.dispose = function (camera) {
  124846. var rttIndex = camera.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);
  124847. if (rttIndex !== -1) {
  124848. camera.getScene().customRenderTargets.splice(rttIndex, 1);
  124849. }
  124850. this._volumetricLightScatteringRTT.dispose();
  124851. _super.prototype.dispose.call(this, camera);
  124852. };
  124853. /**
  124854. * Returns the render target texture used by the post-process
  124855. * @return the render target texture used by the post-process
  124856. */
  124857. VolumetricLightScatteringPostProcess.prototype.getPass = function () {
  124858. return this._volumetricLightScatteringRTT;
  124859. };
  124860. // Private methods
  124861. VolumetricLightScatteringPostProcess.prototype._meshExcluded = function (mesh) {
  124862. if (this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  124863. return true;
  124864. }
  124865. return false;
  124866. };
  124867. VolumetricLightScatteringPostProcess.prototype._createPass = function (scene, ratio) {
  124868. var _this = this;
  124869. var engine = scene.getEngine();
  124870. 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);
  124871. this._volumetricLightScatteringRTT.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  124872. this._volumetricLightScatteringRTT.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  124873. this._volumetricLightScatteringRTT.renderList = null;
  124874. this._volumetricLightScatteringRTT.renderParticles = false;
  124875. this._volumetricLightScatteringRTT.ignoreCameraViewport = true;
  124876. var camera = this.getCamera();
  124877. if (camera) {
  124878. camera.customRenderTargets.push(this._volumetricLightScatteringRTT);
  124879. }
  124880. else {
  124881. scene.customRenderTargets.push(this._volumetricLightScatteringRTT);
  124882. }
  124883. // Custom render function for submeshes
  124884. var renderSubMesh = function (subMesh) {
  124885. var mesh = subMesh.getRenderingMesh();
  124886. if (_this._meshExcluded(mesh)) {
  124887. return;
  124888. }
  124889. var material = subMesh.getMaterial();
  124890. if (!material) {
  124891. return;
  124892. }
  124893. var scene = mesh.getScene();
  124894. var engine = scene.getEngine();
  124895. // Culling
  124896. engine.setState(material.backFaceCulling);
  124897. // Managing instances
  124898. var batch = mesh._getInstancesRenderList(subMesh._id);
  124899. if (batch.mustReturn) {
  124900. return;
  124901. }
  124902. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  124903. if (_this._isReady(subMesh, hardwareInstancedRendering)) {
  124904. var effect = _this._volumetricLightScatteringPass;
  124905. if (mesh === _this.mesh) {
  124906. if (subMesh.effect) {
  124907. effect = subMesh.effect;
  124908. }
  124909. else {
  124910. effect = material.getEffect();
  124911. }
  124912. }
  124913. engine.enableEffect(effect);
  124914. mesh._bind(subMesh, effect, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode);
  124915. if (mesh === _this.mesh) {
  124916. material.bind(mesh.getWorldMatrix(), mesh);
  124917. }
  124918. else {
  124919. _this._volumetricLightScatteringPass.setMatrix("viewProjection", scene.getTransformMatrix());
  124920. // Alpha test
  124921. if (material && material.needAlphaTesting()) {
  124922. var alphaTexture = material.getAlphaTestTexture();
  124923. _this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
  124924. if (alphaTexture) {
  124925. _this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  124926. }
  124927. }
  124928. // Bones
  124929. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  124930. _this._volumetricLightScatteringPass.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  124931. }
  124932. }
  124933. // Draw
  124934. mesh._processRendering(subMesh, _this._volumetricLightScatteringPass, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return effect.setMatrix("world", world); });
  124935. }
  124936. };
  124937. // Render target texture callbacks
  124938. var savedSceneClearColor;
  124939. var sceneClearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0.0, 0.0, 0.0, 1.0);
  124940. this._volumetricLightScatteringRTT.onBeforeRenderObservable.add(function () {
  124941. savedSceneClearColor = scene.clearColor;
  124942. scene.clearColor = sceneClearColor;
  124943. });
  124944. this._volumetricLightScatteringRTT.onAfterRenderObservable.add(function () {
  124945. scene.clearColor = savedSceneClearColor;
  124946. });
  124947. this._volumetricLightScatteringRTT.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  124948. var engine = scene.getEngine();
  124949. var index;
  124950. if (depthOnlySubMeshes.length) {
  124951. engine.setColorWrite(false);
  124952. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  124953. renderSubMesh(depthOnlySubMeshes.data[index]);
  124954. }
  124955. engine.setColorWrite(true);
  124956. }
  124957. for (index = 0; index < opaqueSubMeshes.length; index++) {
  124958. renderSubMesh(opaqueSubMeshes.data[index]);
  124959. }
  124960. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  124961. renderSubMesh(alphaTestSubMeshes.data[index]);
  124962. }
  124963. if (transparentSubMeshes.length) {
  124964. // Sort sub meshes
  124965. for (index = 0; index < transparentSubMeshes.length; index++) {
  124966. var submesh = transparentSubMeshes.data[index];
  124967. var boundingInfo = submesh.getBoundingInfo();
  124968. if (boundingInfo && scene.activeCamera) {
  124969. submesh._alphaIndex = submesh.getMesh().alphaIndex;
  124970. submesh._distanceToCamera = boundingInfo.boundingSphere.centerWorld.subtract(scene.activeCamera.position).length();
  124971. }
  124972. }
  124973. var sortedArray = transparentSubMeshes.data.slice(0, transparentSubMeshes.length);
  124974. sortedArray.sort(function (a, b) {
  124975. // Alpha index first
  124976. if (a._alphaIndex > b._alphaIndex) {
  124977. return 1;
  124978. }
  124979. if (a._alphaIndex < b._alphaIndex) {
  124980. return -1;
  124981. }
  124982. // Then distance to camera
  124983. if (a._distanceToCamera < b._distanceToCamera) {
  124984. return 1;
  124985. }
  124986. if (a._distanceToCamera > b._distanceToCamera) {
  124987. return -1;
  124988. }
  124989. return 0;
  124990. });
  124991. // Render sub meshes
  124992. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_COMBINE);
  124993. for (index = 0; index < sortedArray.length; index++) {
  124994. renderSubMesh(sortedArray[index]);
  124995. }
  124996. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_DISABLE);
  124997. }
  124998. };
  124999. };
  125000. VolumetricLightScatteringPostProcess.prototype._updateMeshScreenCoordinates = function (scene) {
  125001. var transform = scene.getTransformMatrix();
  125002. var meshPosition;
  125003. if (this.useCustomMeshPosition) {
  125004. meshPosition = this.customMeshPosition;
  125005. }
  125006. else if (this.attachedNode) {
  125007. meshPosition = this.attachedNode.position;
  125008. }
  125009. else {
  125010. meshPosition = this.mesh.parent ? this.mesh.getAbsolutePosition() : this.mesh.position;
  125011. }
  125012. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Project(meshPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity(), transform, this._viewPort);
  125013. this._screenCoordinates.x = pos.x / this._viewPort.width;
  125014. this._screenCoordinates.y = pos.y / this._viewPort.height;
  125015. if (this.invert) {
  125016. this._screenCoordinates.y = 1.0 - this._screenCoordinates.y;
  125017. }
  125018. };
  125019. // Static methods
  125020. /**
  125021. * Creates a default mesh for the Volumeric Light Scattering post-process
  125022. * @param name The mesh name
  125023. * @param scene The scene where to create the mesh
  125024. * @return the default mesh
  125025. */
  125026. VolumetricLightScatteringPostProcess.CreateDefaultMesh = function (name, scene) {
  125027. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__["Mesh"].CreatePlane(name, 1, scene);
  125028. mesh.billboardMode = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__["AbstractMesh"].BILLBOARDMODE_ALL;
  125029. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"](name + "Material", scene);
  125030. material.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  125031. mesh.material = material;
  125032. return mesh;
  125033. };
  125034. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125035. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  125036. ], VolumetricLightScatteringPostProcess.prototype, "customMeshPosition", void 0);
  125037. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125038. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  125039. ], VolumetricLightScatteringPostProcess.prototype, "useCustomMeshPosition", void 0);
  125040. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125041. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  125042. ], VolumetricLightScatteringPostProcess.prototype, "invert", void 0);
  125043. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125044. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  125045. ], VolumetricLightScatteringPostProcess.prototype, "mesh", void 0);
  125046. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125047. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  125048. ], VolumetricLightScatteringPostProcess.prototype, "excludedMeshes", void 0);
  125049. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125050. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  125051. ], VolumetricLightScatteringPostProcess.prototype, "exposure", void 0);
  125052. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125053. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  125054. ], VolumetricLightScatteringPostProcess.prototype, "decay", void 0);
  125055. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125056. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  125057. ], VolumetricLightScatteringPostProcess.prototype, "weight", void 0);
  125058. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125059. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  125060. ], VolumetricLightScatteringPostProcess.prototype, "density", void 0);
  125061. return VolumetricLightScatteringPostProcess;
  125062. }(_postProcess__WEBPACK_IMPORTED_MODULE_11__["PostProcess"]));
  125063. /***/ }),
  125064. /***/ "./PostProcesses/vrDistortionCorrectionPostProcess.ts":
  125065. /*!************************************************************!*\
  125066. !*** ./PostProcesses/vrDistortionCorrectionPostProcess.ts ***!
  125067. \************************************************************/
  125068. /*! exports provided: VRDistortionCorrectionPostProcess */
  125069. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125070. "use strict";
  125071. __webpack_require__.r(__webpack_exports__);
  125072. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return VRDistortionCorrectionPostProcess; });
  125073. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125074. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  125075. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  125076. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125077. /* harmony import */ var _Shaders_vrDistortionCorrection_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/vrDistortionCorrection.fragment */ "./Shaders/vrDistortionCorrection.fragment.ts");
  125078. /**
  125079. * VRDistortionCorrectionPostProcess used for mobile VR
  125080. */
  125081. var VRDistortionCorrectionPostProcess = /** @class */ (function (_super) {
  125082. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDistortionCorrectionPostProcess, _super);
  125083. /**
  125084. * Initializes the VRDistortionCorrectionPostProcess
  125085. * @param name The name of the effect.
  125086. * @param camera The camera to apply the render pass to.
  125087. * @param isRightEye If this is for the right eye distortion
  125088. * @param vrMetrics All the required metrics for the VR camera
  125089. */
  125090. function VRDistortionCorrectionPostProcess(name, camera, isRightEye, vrMetrics) {
  125091. var _this = _super.call(this, name, "vrDistortionCorrection", [
  125092. 'LensCenter',
  125093. 'Scale',
  125094. 'ScaleIn',
  125095. 'HmdWarpParam'
  125096. ], null, vrMetrics.postProcessScaleFactor, camera, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE) || this;
  125097. _this._isRightEye = isRightEye;
  125098. _this._distortionFactors = vrMetrics.distortionK;
  125099. _this._postProcessScaleFactor = vrMetrics.postProcessScaleFactor;
  125100. _this._lensCenterOffset = vrMetrics.lensCenterOffset;
  125101. _this.adaptScaleToCurrentViewport = true;
  125102. _this.onSizeChangedObservable.add(function () {
  125103. _this._scaleIn = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](2, 2 / _this.aspectRatio);
  125104. _this._scaleFactor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](.5 * (1 / _this._postProcessScaleFactor), .5 * (1 / _this._postProcessScaleFactor) * _this.aspectRatio);
  125105. _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);
  125106. });
  125107. _this.onApplyObservable.add(function (effect) {
  125108. effect.setFloat2("LensCenter", _this._lensCenter.x, _this._lensCenter.y);
  125109. effect.setFloat2("Scale", _this._scaleFactor.x, _this._scaleFactor.y);
  125110. effect.setFloat2("ScaleIn", _this._scaleIn.x, _this._scaleIn.y);
  125111. effect.setFloat4("HmdWarpParam", _this._distortionFactors[0], _this._distortionFactors[1], _this._distortionFactors[2], _this._distortionFactors[3]);
  125112. });
  125113. return _this;
  125114. }
  125115. return VRDistortionCorrectionPostProcess;
  125116. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  125117. /***/ }),
  125118. /***/ "./PostProcesses/vrMultiviewToSingleviewPostProcess.ts":
  125119. /*!*************************************************************!*\
  125120. !*** ./PostProcesses/vrMultiviewToSingleviewPostProcess.ts ***!
  125121. \*************************************************************/
  125122. /*! exports provided: VRMultiviewToSingleviewPostProcess */
  125123. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125124. "use strict";
  125125. __webpack_require__.r(__webpack_exports__);
  125126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleviewPostProcess", function() { return VRMultiviewToSingleviewPostProcess; });
  125127. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125128. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  125129. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125130. /* harmony import */ var _Shaders_vrMultiviewToSingleview_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/vrMultiviewToSingleview.fragment */ "./Shaders/vrMultiviewToSingleview.fragment.ts");
  125131. /* harmony import */ var _Engines_Extensions_engine_multiview__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/Extensions/engine.multiview */ "./Engines/Extensions/engine.multiview.ts");
  125132. /**
  125133. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  125134. * This will not be used for webXR as it supports displaying texture arrays directly
  125135. */
  125136. var VRMultiviewToSingleviewPostProcess = /** @class */ (function (_super) {
  125137. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRMultiviewToSingleviewPostProcess, _super);
  125138. /**
  125139. * Initializes a VRMultiviewToSingleview
  125140. * @param name name of the post process
  125141. * @param camera camera to be applied to
  125142. * @param scaleFactor scaling factor to the size of the output texture
  125143. */
  125144. function VRMultiviewToSingleviewPostProcess(name, camera, scaleFactor) {
  125145. var _this = _super.call(this, name, "vrMultiviewToSingleview", ["imageIndex"], ["multiviewSampler"], scaleFactor, camera, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE) || this;
  125146. _this.onSizeChangedObservable.add(function () {
  125147. });
  125148. _this.onApplyObservable.add(function (effect) {
  125149. if (camera._scene.activeCamera && camera._scene.activeCamera.isLeftCamera) {
  125150. effect.setInt("imageIndex", 0);
  125151. }
  125152. else {
  125153. effect.setInt("imageIndex", 1);
  125154. }
  125155. effect.setTexture("multiviewSampler", camera._multiviewTexture);
  125156. });
  125157. return _this;
  125158. }
  125159. return VRMultiviewToSingleviewPostProcess;
  125160. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  125161. /***/ }),
  125162. /***/ "./Probes/index.ts":
  125163. /*!*************************!*\
  125164. !*** ./Probes/index.ts ***!
  125165. \*************************/
  125166. /*! exports provided: ReflectionProbe */
  125167. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125168. "use strict";
  125169. __webpack_require__.r(__webpack_exports__);
  125170. /* harmony import */ var _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./reflectionProbe */ "./Probes/reflectionProbe.ts");
  125171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  125172. /***/ }),
  125173. /***/ "./Probes/reflectionProbe.ts":
  125174. /*!***********************************!*\
  125175. !*** ./Probes/reflectionProbe.ts ***!
  125176. \***********************************/
  125177. /*! exports provided: ReflectionProbe */
  125178. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125179. "use strict";
  125180. __webpack_require__.r(__webpack_exports__);
  125181. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return ReflectionProbe; });
  125182. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125183. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  125184. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  125185. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  125186. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  125187. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125188. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.removeReflectionProbe = function (toRemove) {
  125189. if (!this.reflectionProbes) {
  125190. return -1;
  125191. }
  125192. var index = this.reflectionProbes.indexOf(toRemove);
  125193. if (index !== -1) {
  125194. this.reflectionProbes.splice(index, 1);
  125195. }
  125196. return index;
  125197. };
  125198. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.addReflectionProbe = function (newReflectionProbe) {
  125199. if (!this.reflectionProbes) {
  125200. this.reflectionProbes = [];
  125201. }
  125202. this.reflectionProbes.push(newReflectionProbe);
  125203. };
  125204. /**
  125205. * Class used to generate realtime reflection / refraction cube textures
  125206. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  125207. */
  125208. var ReflectionProbe = /** @class */ (function () {
  125209. /**
  125210. * Creates a new reflection probe
  125211. * @param name defines the name of the probe
  125212. * @param size defines the texture resolution (for each face)
  125213. * @param scene defines the hosting scene
  125214. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  125215. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  125216. */
  125217. function ReflectionProbe(
  125218. /** defines the name of the probe */
  125219. name, size, scene, generateMipMaps, useFloat) {
  125220. if (generateMipMaps === void 0) { generateMipMaps = true; }
  125221. if (useFloat === void 0) { useFloat = false; }
  125222. var _this = this;
  125223. this.name = name;
  125224. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  125225. this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  125226. this._add = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  125227. this._invertYAxis = false;
  125228. /** Gets or sets probe position (center of the cube map) */
  125229. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  125230. this._scene = scene;
  125231. // Create the scene field if not exist.
  125232. if (!this._scene.reflectionProbes) {
  125233. this._scene.reflectionProbes = new Array();
  125234. }
  125235. this._scene.reflectionProbes.push(this);
  125236. 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);
  125237. this._renderTargetTexture.onBeforeRenderObservable.add(function (faceIndex) {
  125238. switch (faceIndex) {
  125239. case 0:
  125240. _this._add.copyFromFloats(1, 0, 0);
  125241. break;
  125242. case 1:
  125243. _this._add.copyFromFloats(-1, 0, 0);
  125244. break;
  125245. case 2:
  125246. _this._add.copyFromFloats(0, _this._invertYAxis ? 1 : -1, 0);
  125247. break;
  125248. case 3:
  125249. _this._add.copyFromFloats(0, _this._invertYAxis ? -1 : 1, 0);
  125250. break;
  125251. case 4:
  125252. _this._add.copyFromFloats(0, 0, 1);
  125253. break;
  125254. case 5:
  125255. _this._add.copyFromFloats(0, 0, -1);
  125256. break;
  125257. }
  125258. if (_this._attachedMesh) {
  125259. _this.position.copyFrom(_this._attachedMesh.getAbsolutePosition());
  125260. }
  125261. _this.position.addToRef(_this._add, _this._target);
  125262. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(_this.position, _this._target, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), _this._viewMatrix);
  125263. if (scene.activeCamera) {
  125264. _this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].PerspectiveFovLH(Math.PI / 2, 1, scene.activeCamera.minZ, scene.activeCamera.maxZ);
  125265. scene.setTransformMatrix(_this._viewMatrix, _this._projectionMatrix);
  125266. }
  125267. scene._forcedViewPosition = _this.position;
  125268. });
  125269. this._renderTargetTexture.onAfterUnbindObservable.add(function () {
  125270. scene._forcedViewPosition = null;
  125271. scene.updateTransformMatrix(true);
  125272. });
  125273. }
  125274. Object.defineProperty(ReflectionProbe.prototype, "samples", {
  125275. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  125276. get: function () {
  125277. return this._renderTargetTexture.samples;
  125278. },
  125279. set: function (value) {
  125280. this._renderTargetTexture.samples = value;
  125281. },
  125282. enumerable: true,
  125283. configurable: true
  125284. });
  125285. Object.defineProperty(ReflectionProbe.prototype, "refreshRate", {
  125286. /** Gets or sets the refresh rate to use (on every frame by default) */
  125287. get: function () {
  125288. return this._renderTargetTexture.refreshRate;
  125289. },
  125290. set: function (value) {
  125291. this._renderTargetTexture.refreshRate = value;
  125292. },
  125293. enumerable: true,
  125294. configurable: true
  125295. });
  125296. /**
  125297. * Gets the hosting scene
  125298. * @returns a Scene
  125299. */
  125300. ReflectionProbe.prototype.getScene = function () {
  125301. return this._scene;
  125302. };
  125303. Object.defineProperty(ReflectionProbe.prototype, "cubeTexture", {
  125304. /** Gets the internal CubeTexture used to render to */
  125305. get: function () {
  125306. return this._renderTargetTexture;
  125307. },
  125308. enumerable: true,
  125309. configurable: true
  125310. });
  125311. Object.defineProperty(ReflectionProbe.prototype, "renderList", {
  125312. /** Gets the list of meshes to render */
  125313. get: function () {
  125314. return this._renderTargetTexture.renderList;
  125315. },
  125316. enumerable: true,
  125317. configurable: true
  125318. });
  125319. /**
  125320. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  125321. * @param mesh defines the mesh to attach to
  125322. */
  125323. ReflectionProbe.prototype.attachToMesh = function (mesh) {
  125324. this._attachedMesh = mesh;
  125325. };
  125326. /**
  125327. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  125328. * @param renderingGroupId The rendering group id corresponding to its index
  125329. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  125330. */
  125331. ReflectionProbe.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  125332. this._renderTargetTexture.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  125333. };
  125334. /**
  125335. * Clean all associated resources
  125336. */
  125337. ReflectionProbe.prototype.dispose = function () {
  125338. var index = this._scene.reflectionProbes.indexOf(this);
  125339. if (index !== -1) {
  125340. // Remove from the scene if found
  125341. this._scene.reflectionProbes.splice(index, 1);
  125342. }
  125343. if (this._renderTargetTexture) {
  125344. this._renderTargetTexture.dispose();
  125345. this._renderTargetTexture = null;
  125346. }
  125347. };
  125348. /**
  125349. * Converts the reflection probe information to a readable string for debug purpose.
  125350. * @param fullDetails Supports for multiple levels of logging within scene loading
  125351. * @returns the human readable reflection probe info
  125352. */
  125353. ReflectionProbe.prototype.toString = function (fullDetails) {
  125354. var ret = "Name: " + this.name;
  125355. if (fullDetails) {
  125356. ret += ", position: " + this.position.toString();
  125357. if (this._attachedMesh) {
  125358. ret += ", attached mesh: " + this._attachedMesh.name;
  125359. }
  125360. }
  125361. return ret;
  125362. };
  125363. /**
  125364. * Get the class name of the relfection probe.
  125365. * @returns "ReflectionProbe"
  125366. */
  125367. ReflectionProbe.prototype.getClassName = function () {
  125368. return "ReflectionProbe";
  125369. };
  125370. /**
  125371. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  125372. * @returns The JSON representation of the texture
  125373. */
  125374. ReflectionProbe.prototype.serialize = function () {
  125375. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, this._renderTargetTexture.serialize());
  125376. serializationObject.isReflectionProbe = true;
  125377. return serializationObject;
  125378. };
  125379. /**
  125380. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  125381. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  125382. * @param scene Define the scene the parsed reflection probe should be instantiated in
  125383. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  125384. * @returns The parsed reflection probe if successful
  125385. */
  125386. ReflectionProbe.Parse = function (parsedReflectionProbe, scene, rootUrl) {
  125387. var reflectionProbe = null;
  125388. if (scene.reflectionProbes) {
  125389. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  125390. var rp = scene.reflectionProbes[index];
  125391. if (rp.name === parsedReflectionProbe.name) {
  125392. reflectionProbe = rp;
  125393. break;
  125394. }
  125395. }
  125396. }
  125397. reflectionProbe = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return reflectionProbe || new ReflectionProbe(parsedReflectionProbe.name, parsedReflectionProbe.renderTargetSize, scene, parsedReflectionProbe._generateMipMaps); }, parsedReflectionProbe, scene, rootUrl);
  125398. reflectionProbe.cubeTexture._waitingRenderList = parsedReflectionProbe.renderList;
  125399. if (parsedReflectionProbe._attachedMesh) {
  125400. reflectionProbe.attachToMesh(scene.getMeshByID(parsedReflectionProbe._attachedMesh));
  125401. }
  125402. return reflectionProbe;
  125403. };
  125404. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125405. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  125406. ], ReflectionProbe.prototype, "_attachedMesh", void 0);
  125407. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125408. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  125409. ], ReflectionProbe.prototype, "position", void 0);
  125410. return ReflectionProbe;
  125411. }());
  125412. /***/ }),
  125413. /***/ "./Rendering/boundingBoxRenderer.ts":
  125414. /*!******************************************!*\
  125415. !*** ./Rendering/boundingBoxRenderer.ts ***!
  125416. \******************************************/
  125417. /*! exports provided: BoundingBoxRenderer */
  125418. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125419. "use strict";
  125420. __webpack_require__.r(__webpack_exports__);
  125421. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return BoundingBoxRenderer; });
  125422. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  125423. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  125424. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  125425. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  125426. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  125427. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  125428. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  125429. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  125430. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  125431. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  125432. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  125433. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  125434. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "forceShowBoundingBoxes", {
  125435. get: function () {
  125436. return this._forceShowBoundingBoxes || false;
  125437. },
  125438. set: function (value) {
  125439. this._forceShowBoundingBoxes = value;
  125440. // Lazyly creates a BB renderer if needed.
  125441. if (value) {
  125442. this.getBoundingBoxRenderer();
  125443. }
  125444. },
  125445. enumerable: true,
  125446. configurable: true
  125447. });
  125448. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.getBoundingBoxRenderer = function () {
  125449. if (!this._boundingBoxRenderer) {
  125450. this._boundingBoxRenderer = new BoundingBoxRenderer(this);
  125451. }
  125452. return this._boundingBoxRenderer;
  125453. };
  125454. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "showBoundingBox", {
  125455. get: function () {
  125456. return this._showBoundingBox || false;
  125457. },
  125458. set: function (value) {
  125459. this._showBoundingBox = value;
  125460. // Lazyly creates a BB renderer if needed.
  125461. if (value) {
  125462. this.getScene().getBoundingBoxRenderer();
  125463. }
  125464. },
  125465. enumerable: true,
  125466. configurable: true
  125467. });
  125468. /**
  125469. * Component responsible of rendering the bounding box of the meshes in a scene.
  125470. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  125471. */
  125472. var BoundingBoxRenderer = /** @class */ (function () {
  125473. /**
  125474. * Instantiates a new bounding box renderer in a scene.
  125475. * @param scene the scene the renderer renders in
  125476. */
  125477. function BoundingBoxRenderer(scene) {
  125478. /**
  125479. * The component name helpfull to identify the component in the list of scene components.
  125480. */
  125481. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_BOUNDINGBOXRENDERER;
  125482. /**
  125483. * Color of the bounding box lines placed in front of an object
  125484. */
  125485. this.frontColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  125486. /**
  125487. * Color of the bounding box lines placed behind an object
  125488. */
  125489. this.backColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0.1, 0.1, 0.1);
  125490. /**
  125491. * Defines if the renderer should show the back lines or not
  125492. */
  125493. this.showBackLines = true;
  125494. /**
  125495. * @hidden
  125496. */
  125497. this.renderList = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__["SmartArray"](32);
  125498. this._vertexBuffers = {};
  125499. this.scene = scene;
  125500. scene._addComponent(this);
  125501. }
  125502. /**
  125503. * Registers the component in a given scene
  125504. */
  125505. BoundingBoxRenderer.prototype.register = function () {
  125506. this.scene._beforeEvaluateActiveMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset);
  125507. this.scene._activeMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_ACTIVEMESH_BOUNDINGBOXRENDERER, this, this._activeMesh);
  125508. this.scene._evaluateSubMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh);
  125509. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render);
  125510. };
  125511. BoundingBoxRenderer.prototype._evaluateSubMesh = function (mesh, subMesh) {
  125512. if (mesh.showSubMeshesBoundingBox) {
  125513. var boundingInfo = subMesh.getBoundingInfo();
  125514. if (boundingInfo !== null && boundingInfo !== undefined) {
  125515. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  125516. this.renderList.push(boundingInfo.boundingBox);
  125517. }
  125518. }
  125519. };
  125520. BoundingBoxRenderer.prototype._activeMesh = function (sourceMesh, mesh) {
  125521. if (sourceMesh.showBoundingBox || this.scene.forceShowBoundingBoxes) {
  125522. var boundingInfo = sourceMesh.getBoundingInfo();
  125523. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  125524. this.renderList.push(boundingInfo.boundingBox);
  125525. }
  125526. };
  125527. BoundingBoxRenderer.prototype._prepareRessources = function () {
  125528. if (this._colorShader) {
  125529. return;
  125530. }
  125531. this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__["ShaderMaterial"]("colorShader", this.scene, "color", {
  125532. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind],
  125533. uniforms: ["world", "viewProjection", "color"]
  125534. });
  125535. var engine = this.scene.getEngine();
  125536. var boxdata = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateBox({ size: 1.0 });
  125537. 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);
  125538. this._createIndexBuffer();
  125539. };
  125540. BoundingBoxRenderer.prototype._createIndexBuffer = function () {
  125541. var engine = this.scene.getEngine();
  125542. 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]);
  125543. };
  125544. /**
  125545. * Rebuilds the elements related to this component in case of
  125546. * context lost for instance.
  125547. */
  125548. BoundingBoxRenderer.prototype.rebuild = function () {
  125549. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  125550. if (vb) {
  125551. vb._rebuild();
  125552. }
  125553. this._createIndexBuffer();
  125554. };
  125555. /**
  125556. * @hidden
  125557. */
  125558. BoundingBoxRenderer.prototype.reset = function () {
  125559. this.renderList.reset();
  125560. };
  125561. /**
  125562. * Render the bounding boxes of a specific rendering group
  125563. * @param renderingGroupId defines the rendering group to render
  125564. */
  125565. BoundingBoxRenderer.prototype.render = function (renderingGroupId) {
  125566. if (this.renderList.length === 0) {
  125567. return;
  125568. }
  125569. this._prepareRessources();
  125570. if (!this._colorShader.isReady()) {
  125571. return;
  125572. }
  125573. var engine = this.scene.getEngine();
  125574. engine.setDepthWrite(false);
  125575. this._colorShader._preBind();
  125576. for (var boundingBoxIndex = 0; boundingBoxIndex < this.renderList.length; boundingBoxIndex++) {
  125577. var boundingBox = this.renderList.data[boundingBoxIndex];
  125578. if (boundingBox._tag !== renderingGroupId) {
  125579. continue;
  125580. }
  125581. var min = boundingBox.minimum;
  125582. var max = boundingBox.maximum;
  125583. var diff = max.subtract(min);
  125584. var median = min.add(diff.scale(0.5));
  125585. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  125586. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  125587. .multiply(boundingBox.getWorldMatrix());
  125588. // VBOs
  125589. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  125590. if (this.showBackLines) {
  125591. // Back
  125592. engine.setDepthFunctionToGreaterOrEqual();
  125593. this.scene.resetCachedMaterial();
  125594. this._colorShader.setColor4("color", this.backColor.toColor4());
  125595. this._colorShader.bind(worldMatrix);
  125596. // Draw order
  125597. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  125598. }
  125599. // Front
  125600. engine.setDepthFunctionToLess();
  125601. this.scene.resetCachedMaterial();
  125602. this._colorShader.setColor4("color", this.frontColor.toColor4());
  125603. this._colorShader.bind(worldMatrix);
  125604. // Draw order
  125605. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  125606. }
  125607. this._colorShader.unbind();
  125608. engine.setDepthFunctionToLessOrEqual();
  125609. engine.setDepthWrite(true);
  125610. };
  125611. /**
  125612. * In case of occlusion queries, we can render the occlusion bounding box through this method
  125613. * @param mesh Define the mesh to render the occlusion bounding box for
  125614. */
  125615. BoundingBoxRenderer.prototype.renderOcclusionBoundingBox = function (mesh) {
  125616. this._prepareRessources();
  125617. if (!this._colorShader.isReady() || !mesh._boundingInfo) {
  125618. return;
  125619. }
  125620. var engine = this.scene.getEngine();
  125621. engine.setDepthWrite(false);
  125622. engine.setColorWrite(false);
  125623. this._colorShader._preBind();
  125624. var boundingBox = mesh._boundingInfo.boundingBox;
  125625. var min = boundingBox.minimum;
  125626. var max = boundingBox.maximum;
  125627. var diff = max.subtract(min);
  125628. var median = min.add(diff.scale(0.5));
  125629. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  125630. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  125631. .multiply(boundingBox.getWorldMatrix());
  125632. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  125633. engine.setDepthFunctionToLess();
  125634. this.scene.resetCachedMaterial();
  125635. this._colorShader.bind(worldMatrix);
  125636. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  125637. this._colorShader.unbind();
  125638. engine.setDepthFunctionToLessOrEqual();
  125639. engine.setDepthWrite(true);
  125640. engine.setColorWrite(true);
  125641. };
  125642. /**
  125643. * Dispose and release the resources attached to this renderer.
  125644. */
  125645. BoundingBoxRenderer.prototype.dispose = function () {
  125646. if (!this._colorShader) {
  125647. return;
  125648. }
  125649. this.renderList.dispose();
  125650. this._colorShader.dispose();
  125651. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  125652. if (buffer) {
  125653. buffer.dispose();
  125654. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  125655. }
  125656. this.scene.getEngine()._releaseBuffer(this._indexBuffer);
  125657. };
  125658. return BoundingBoxRenderer;
  125659. }());
  125660. /***/ }),
  125661. /***/ "./Rendering/depthRenderer.ts":
  125662. /*!************************************!*\
  125663. !*** ./Rendering/depthRenderer.ts ***!
  125664. \************************************/
  125665. /*! exports provided: DepthRenderer */
  125666. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125667. "use strict";
  125668. __webpack_require__.r(__webpack_exports__);
  125669. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return DepthRenderer; });
  125670. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  125671. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  125672. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  125673. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  125674. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  125675. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125676. /* harmony import */ var _Shaders_depth_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/depth.fragment */ "./Shaders/depth.fragment.ts");
  125677. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  125678. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  125679. /**
  125680. * This represents a depth renderer in Babylon.
  125681. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  125682. */
  125683. var DepthRenderer = /** @class */ (function () {
  125684. /**
  125685. * Instantiates a depth renderer
  125686. * @param scene The scene the renderer belongs to
  125687. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  125688. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  125689. */
  125690. function DepthRenderer(scene, type, camera) {
  125691. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT; }
  125692. if (camera === void 0) { camera = null; }
  125693. var _this = this;
  125694. /**
  125695. * Specifiess that the depth renderer will only be used within
  125696. * the camera it is created for.
  125697. * This can help forcing its rendering during the camera processing.
  125698. */
  125699. this.useOnlyInActiveCamera = false;
  125700. this._scene = scene;
  125701. DepthRenderer._SceneComponentInitialization(this._scene);
  125702. this._camera = camera;
  125703. var engine = scene.getEngine();
  125704. // Render target
  125705. this._depthMap = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]("depthMap", { width: engine.getRenderWidth(), height: engine.getRenderHeight() }, this._scene, false, true, type);
  125706. this._depthMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  125707. this._depthMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  125708. this._depthMap.refreshRate = 1;
  125709. this._depthMap.renderParticles = false;
  125710. this._depthMap.renderList = null;
  125711. // Camera to get depth map from to support multiple concurrent cameras
  125712. this._depthMap.activeCamera = this._camera;
  125713. this._depthMap.ignoreCameraViewport = true;
  125714. this._depthMap.useCameraPostProcesses = false;
  125715. // set default depth value to 1.0 (far away)
  125716. this._depthMap.onClearObservable.add(function (engine) {
  125717. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0), true, true, true);
  125718. });
  125719. // Custom render function
  125720. var renderSubMesh = function (subMesh) {
  125721. var mesh = subMesh.getRenderingMesh();
  125722. var scene = _this._scene;
  125723. var engine = scene.getEngine();
  125724. var material = subMesh.getMaterial();
  125725. if (!material) {
  125726. return;
  125727. }
  125728. // Culling and reverse (right handed system)
  125729. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  125730. // Managing instances
  125731. var batch = mesh._getInstancesRenderList(subMesh._id);
  125732. if (batch.mustReturn) {
  125733. return;
  125734. }
  125735. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  125736. var camera = _this._camera || scene.activeCamera;
  125737. if (_this.isReady(subMesh, hardwareInstancedRendering) && camera) {
  125738. engine.enableEffect(_this._effect);
  125739. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  125740. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  125741. _this._effect.setFloat2("depthValues", camera.minZ, camera.minZ + camera.maxZ);
  125742. // Alpha test
  125743. if (material && material.needAlphaTesting()) {
  125744. var alphaTexture = material.getAlphaTestTexture();
  125745. if (alphaTexture) {
  125746. _this._effect.setTexture("diffuseSampler", alphaTexture);
  125747. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  125748. }
  125749. }
  125750. // Bones
  125751. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  125752. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  125753. }
  125754. // Draw
  125755. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  125756. }
  125757. };
  125758. this._depthMap.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  125759. var index;
  125760. if (depthOnlySubMeshes.length) {
  125761. engine.setColorWrite(false);
  125762. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  125763. renderSubMesh(depthOnlySubMeshes.data[index]);
  125764. }
  125765. engine.setColorWrite(true);
  125766. }
  125767. for (index = 0; index < opaqueSubMeshes.length; index++) {
  125768. renderSubMesh(opaqueSubMeshes.data[index]);
  125769. }
  125770. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  125771. renderSubMesh(alphaTestSubMeshes.data[index]);
  125772. }
  125773. };
  125774. }
  125775. /**
  125776. * Creates the depth rendering effect and checks if the effect is ready.
  125777. * @param subMesh The submesh to be used to render the depth map of
  125778. * @param useInstances If multiple world instances should be used
  125779. * @returns if the depth renderer is ready to render the depth map
  125780. */
  125781. DepthRenderer.prototype.isReady = function (subMesh, useInstances) {
  125782. var material = subMesh.getMaterial();
  125783. if (material.disableDepthWrite) {
  125784. return false;
  125785. }
  125786. var defines = [];
  125787. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  125788. var mesh = subMesh.getMesh();
  125789. // Alpha test
  125790. if (material && material.needAlphaTesting() && material.getAlphaTestTexture()) {
  125791. defines.push("#define ALPHATEST");
  125792. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  125793. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  125794. defines.push("#define UV1");
  125795. }
  125796. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  125797. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  125798. defines.push("#define UV2");
  125799. }
  125800. }
  125801. // Bones
  125802. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  125803. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  125804. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  125805. if (mesh.numBoneInfluencers > 4) {
  125806. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  125807. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  125808. }
  125809. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  125810. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  125811. }
  125812. else {
  125813. defines.push("#define NUM_BONE_INFLUENCERS 0");
  125814. }
  125815. // Instances
  125816. if (useInstances) {
  125817. defines.push("#define INSTANCES");
  125818. attribs.push("world0");
  125819. attribs.push("world1");
  125820. attribs.push("world2");
  125821. attribs.push("world3");
  125822. }
  125823. // Get correct effect
  125824. var join = defines.join("\n");
  125825. if (this._cachedDefines !== join) {
  125826. this._cachedDefines = join;
  125827. this._effect = this._scene.getEngine().createEffect("depth", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "depthValues"], ["diffuseSampler"], join);
  125828. }
  125829. return this._effect.isReady();
  125830. };
  125831. /**
  125832. * Gets the texture which the depth map will be written to.
  125833. * @returns The depth map texture
  125834. */
  125835. DepthRenderer.prototype.getDepthMap = function () {
  125836. return this._depthMap;
  125837. };
  125838. /**
  125839. * Disposes of the depth renderer.
  125840. */
  125841. DepthRenderer.prototype.dispose = function () {
  125842. this._depthMap.dispose();
  125843. };
  125844. /** @hidden */
  125845. DepthRenderer._SceneComponentInitialization = function (_) {
  125846. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("DepthRendererSceneComponent");
  125847. };
  125848. return DepthRenderer;
  125849. }());
  125850. /***/ }),
  125851. /***/ "./Rendering/depthRendererSceneComponent.ts":
  125852. /*!**************************************************!*\
  125853. !*** ./Rendering/depthRendererSceneComponent.ts ***!
  125854. \**************************************************/
  125855. /*! exports provided: DepthRendererSceneComponent */
  125856. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125857. "use strict";
  125858. __webpack_require__.r(__webpack_exports__);
  125859. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return DepthRendererSceneComponent; });
  125860. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  125861. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  125862. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125863. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  125864. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableDepthRenderer = function (camera) {
  125865. camera = camera || this.activeCamera;
  125866. if (!camera) {
  125867. throw "No camera available to enable depth renderer";
  125868. }
  125869. if (!this._depthRenderer) {
  125870. this._depthRenderer = {};
  125871. }
  125872. if (!this._depthRenderer[camera.id]) {
  125873. var textureType = 0;
  125874. if (this.getEngine().getCaps().textureHalfFloatRender) {
  125875. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  125876. }
  125877. else if (this.getEngine().getCaps().textureFloatRender) {
  125878. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  125879. }
  125880. else {
  125881. throw "Depth renderer does not support int texture type";
  125882. }
  125883. this._depthRenderer[camera.id] = new _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"](this, textureType, camera);
  125884. }
  125885. return this._depthRenderer[camera.id];
  125886. };
  125887. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableDepthRenderer = function (camera) {
  125888. camera = camera || this.activeCamera;
  125889. if (!camera || !this._depthRenderer || !this._depthRenderer[camera.id]) {
  125890. return;
  125891. }
  125892. this._depthRenderer[camera.id].dispose();
  125893. delete this._depthRenderer[camera.id];
  125894. };
  125895. /**
  125896. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  125897. * in several rendering techniques.
  125898. */
  125899. var DepthRendererSceneComponent = /** @class */ (function () {
  125900. /**
  125901. * Creates a new instance of the component for the given scene
  125902. * @param scene Defines the scene to register the component in
  125903. */
  125904. function DepthRendererSceneComponent(scene) {
  125905. /**
  125906. * The component name helpfull to identify the component in the list of scene components.
  125907. */
  125908. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER;
  125909. this.scene = scene;
  125910. }
  125911. /**
  125912. * Registers the component in a given scene
  125913. */
  125914. DepthRendererSceneComponent.prototype.register = function () {
  125915. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_DEPTHRENDERER, this, this._gatherRenderTargets);
  125916. this.scene._gatherActiveCameraRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER, this, this._gatherActiveCameraRenderTargets);
  125917. };
  125918. /**
  125919. * Rebuilds the elements related to this component in case of
  125920. * context lost for instance.
  125921. */
  125922. DepthRendererSceneComponent.prototype.rebuild = function () {
  125923. // Nothing to do for this component
  125924. };
  125925. /**
  125926. * Disposes the component and the associated ressources
  125927. */
  125928. DepthRendererSceneComponent.prototype.dispose = function () {
  125929. for (var key in this.scene._depthRenderer) {
  125930. this.scene._depthRenderer[key].dispose();
  125931. }
  125932. };
  125933. DepthRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  125934. if (this.scene._depthRenderer) {
  125935. for (var key in this.scene._depthRenderer) {
  125936. var depthRenderer = this.scene._depthRenderer[key];
  125937. if (!depthRenderer.useOnlyInActiveCamera) {
  125938. renderTargets.push(depthRenderer.getDepthMap());
  125939. }
  125940. }
  125941. }
  125942. };
  125943. DepthRendererSceneComponent.prototype._gatherActiveCameraRenderTargets = function (renderTargets) {
  125944. if (this.scene._depthRenderer) {
  125945. for (var key in this.scene._depthRenderer) {
  125946. var depthRenderer = this.scene._depthRenderer[key];
  125947. if (depthRenderer.useOnlyInActiveCamera && this.scene.activeCamera.id === key) {
  125948. renderTargets.push(depthRenderer.getDepthMap());
  125949. }
  125950. }
  125951. }
  125952. };
  125953. return DepthRendererSceneComponent;
  125954. }());
  125955. _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]._SceneComponentInitialization = function (scene) {
  125956. // Register the G Buffer component to the scene.
  125957. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER);
  125958. if (!component) {
  125959. component = new DepthRendererSceneComponent(scene);
  125960. scene._addComponent(component);
  125961. }
  125962. };
  125963. /***/ }),
  125964. /***/ "./Rendering/edgesRenderer.ts":
  125965. /*!************************************!*\
  125966. !*** ./Rendering/edgesRenderer.ts ***!
  125967. \************************************/
  125968. /*! exports provided: EdgesRenderer, LineEdgesRenderer */
  125969. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125970. "use strict";
  125971. __webpack_require__.r(__webpack_exports__);
  125972. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return EdgesRenderer; });
  125973. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return LineEdgesRenderer; });
  125974. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125975. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  125976. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  125977. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  125978. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  125979. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  125980. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  125981. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  125982. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125983. /* harmony import */ var _Shaders_line_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/line.fragment */ "./Shaders/line.fragment.ts");
  125984. /* harmony import */ var _Shaders_line_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/line.vertex */ "./Shaders/line.vertex.ts");
  125985. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.disableEdgesRendering = function () {
  125986. if (this._edgesRenderer) {
  125987. this._edgesRenderer.dispose();
  125988. this._edgesRenderer = null;
  125989. }
  125990. return this;
  125991. };
  125992. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  125993. if (epsilon === void 0) { epsilon = 0.95; }
  125994. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  125995. this.disableEdgesRendering();
  125996. this._edgesRenderer = new EdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  125997. return this;
  125998. };
  125999. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "edgesRenderer", {
  126000. get: function () {
  126001. return this._edgesRenderer;
  126002. },
  126003. enumerable: true,
  126004. configurable: true
  126005. });
  126006. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  126007. if (epsilon === void 0) { epsilon = 0.95; }
  126008. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  126009. this.disableEdgesRendering();
  126010. this._edgesRenderer = new LineEdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  126011. return this;
  126012. };
  126013. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["InstancedLinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  126014. if (epsilon === void 0) { epsilon = 0.95; }
  126015. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  126016. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering.apply(this, arguments);
  126017. return this;
  126018. };
  126019. /**
  126020. * FaceAdjacencies Helper class to generate edges
  126021. */
  126022. var FaceAdjacencies = /** @class */ (function () {
  126023. function FaceAdjacencies() {
  126024. this.edges = new Array();
  126025. this.edgesConnectedCount = 0;
  126026. }
  126027. return FaceAdjacencies;
  126028. }());
  126029. /**
  126030. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  126031. */
  126032. var EdgesRenderer = /** @class */ (function () {
  126033. /**
  126034. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  126035. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  126036. * @param source Mesh used to create edges
  126037. * @param epsilon sum of angles in adjacency to check for edge
  126038. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  126039. * @param generateEdgesLines - should generate Lines or only prepare resources.
  126040. */
  126041. function EdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices, generateEdgesLines) {
  126042. if (epsilon === void 0) { epsilon = 0.95; }
  126043. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  126044. if (generateEdgesLines === void 0) { generateEdgesLines = true; }
  126045. var _this = this;
  126046. /**
  126047. * Define the size of the edges with an orthographic camera
  126048. */
  126049. this.edgesWidthScalerForOrthographic = 1000.0;
  126050. /**
  126051. * Define the size of the edges with a perspective camera
  126052. */
  126053. this.edgesWidthScalerForPerspective = 50.0;
  126054. this._linesPositions = new Array();
  126055. this._linesNormals = new Array();
  126056. this._linesIndices = new Array();
  126057. this._buffers = {};
  126058. this._checkVerticesInsteadOfIndices = false;
  126059. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  126060. this.isEnabled = true;
  126061. this._source = source;
  126062. this._checkVerticesInsteadOfIndices = checkVerticesInsteadOfIndices;
  126063. this._epsilon = epsilon;
  126064. this._prepareRessources();
  126065. if (generateEdgesLines) {
  126066. this._generateEdgesLines();
  126067. }
  126068. this._meshRebuildObserver = this._source.onRebuildObservable.add(function () {
  126069. _this._rebuild();
  126070. });
  126071. this._meshDisposeObserver = this._source.onDisposeObservable.add(function () {
  126072. _this.dispose();
  126073. });
  126074. }
  126075. EdgesRenderer.prototype._prepareRessources = function () {
  126076. if (this._lineShader) {
  126077. return;
  126078. }
  126079. this._lineShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("lineShader", this._source.getScene(), "line", {
  126080. attributes: ["position", "normal"],
  126081. uniforms: ["worldViewProjection", "color", "width", "aspectRatio"]
  126082. });
  126083. this._lineShader.disableDepthWrite = true;
  126084. this._lineShader.backFaceCulling = false;
  126085. };
  126086. /** @hidden */
  126087. EdgesRenderer.prototype._rebuild = function () {
  126088. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  126089. if (buffer) {
  126090. buffer._rebuild();
  126091. }
  126092. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  126093. if (buffer) {
  126094. buffer._rebuild();
  126095. }
  126096. var scene = this._source.getScene();
  126097. var engine = scene.getEngine();
  126098. this._ib = engine.createIndexBuffer(this._linesIndices);
  126099. };
  126100. /**
  126101. * Releases the required resources for the edges renderer
  126102. */
  126103. EdgesRenderer.prototype.dispose = function () {
  126104. this._source.onRebuildObservable.remove(this._meshRebuildObserver);
  126105. this._source.onDisposeObservable.remove(this._meshDisposeObserver);
  126106. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  126107. if (buffer) {
  126108. buffer.dispose();
  126109. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  126110. }
  126111. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  126112. if (buffer) {
  126113. buffer.dispose();
  126114. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind] = null;
  126115. }
  126116. this._source.getScene().getEngine()._releaseBuffer(this._ib);
  126117. this._lineShader.dispose();
  126118. };
  126119. EdgesRenderer.prototype._processEdgeForAdjacencies = function (pa, pb, p0, p1, p2) {
  126120. if (pa === p0 && pb === p1 || pa === p1 && pb === p0) {
  126121. return 0;
  126122. }
  126123. if (pa === p1 && pb === p2 || pa === p2 && pb === p1) {
  126124. return 1;
  126125. }
  126126. if (pa === p2 && pb === p0 || pa === p0 && pb === p2) {
  126127. return 2;
  126128. }
  126129. return -1;
  126130. };
  126131. EdgesRenderer.prototype._processEdgeForAdjacenciesWithVertices = function (pa, pb, p0, p1, p2) {
  126132. if (pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p1) || pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p0)) {
  126133. return 0;
  126134. }
  126135. if (pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p2) || pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p1)) {
  126136. return 1;
  126137. }
  126138. if (pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p0) || pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p2)) {
  126139. return 2;
  126140. }
  126141. return -1;
  126142. };
  126143. /**
  126144. * Checks if the pair of p0 and p1 is en edge
  126145. * @param faceIndex
  126146. * @param edge
  126147. * @param faceNormals
  126148. * @param p0
  126149. * @param p1
  126150. * @private
  126151. */
  126152. EdgesRenderer.prototype._checkEdge = function (faceIndex, edge, faceNormals, p0, p1) {
  126153. var needToCreateLine;
  126154. if (edge === undefined) {
  126155. needToCreateLine = true;
  126156. }
  126157. else {
  126158. var dotProduct = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Dot(faceNormals[faceIndex], faceNormals[edge]);
  126159. needToCreateLine = dotProduct < this._epsilon;
  126160. }
  126161. if (needToCreateLine) {
  126162. this.createLine(p0, p1, this._linesPositions.length / 3);
  126163. }
  126164. };
  126165. /**
  126166. * push line into the position, normal and index buffer
  126167. * @protected
  126168. */
  126169. EdgesRenderer.prototype.createLine = function (p0, p1, offset) {
  126170. // Positions
  126171. 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);
  126172. // Normals
  126173. 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);
  126174. // Indices
  126175. this._linesIndices.push(offset, offset + 1, offset + 2, offset, offset + 2, offset + 3);
  126176. };
  126177. /**
  126178. * Generates lines edges from adjacencjes
  126179. * @private
  126180. */
  126181. EdgesRenderer.prototype._generateEdgesLines = function () {
  126182. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  126183. var indices = this._source.getIndices();
  126184. if (!indices || !positions) {
  126185. return;
  126186. }
  126187. // First let's find adjacencies
  126188. var adjacencies = new Array();
  126189. var faceNormals = new Array();
  126190. var index;
  126191. var faceAdjacencies;
  126192. // Prepare faces
  126193. for (index = 0; index < indices.length; index += 3) {
  126194. faceAdjacencies = new FaceAdjacencies();
  126195. var p0Index = indices[index];
  126196. var p1Index = indices[index + 1];
  126197. var p2Index = indices[index + 2];
  126198. faceAdjacencies.p0 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p0Index * 3], positions[p0Index * 3 + 1], positions[p0Index * 3 + 2]);
  126199. faceAdjacencies.p1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p1Index * 3], positions[p1Index * 3 + 1], positions[p1Index * 3 + 2]);
  126200. faceAdjacencies.p2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p2Index * 3], positions[p2Index * 3 + 1], positions[p2Index * 3 + 2]);
  126201. var faceNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Cross(faceAdjacencies.p1.subtract(faceAdjacencies.p0), faceAdjacencies.p2.subtract(faceAdjacencies.p1));
  126202. faceNormal.normalize();
  126203. faceNormals.push(faceNormal);
  126204. adjacencies.push(faceAdjacencies);
  126205. }
  126206. // Scan
  126207. for (index = 0; index < adjacencies.length; index++) {
  126208. faceAdjacencies = adjacencies[index];
  126209. for (var otherIndex = index + 1; otherIndex < adjacencies.length; otherIndex++) {
  126210. var otherFaceAdjacencies = adjacencies[otherIndex];
  126211. if (faceAdjacencies.edgesConnectedCount === 3) { // Full
  126212. break;
  126213. }
  126214. if (otherFaceAdjacencies.edgesConnectedCount === 3) { // Full
  126215. continue;
  126216. }
  126217. var otherP0 = indices[otherIndex * 3];
  126218. var otherP1 = indices[otherIndex * 3 + 1];
  126219. var otherP2 = indices[otherIndex * 3 + 2];
  126220. for (var edgeIndex = 0; edgeIndex < 3; edgeIndex++) {
  126221. var otherEdgeIndex = 0;
  126222. if (faceAdjacencies.edges[edgeIndex] !== undefined) {
  126223. continue;
  126224. }
  126225. switch (edgeIndex) {
  126226. case 0:
  126227. if (this._checkVerticesInsteadOfIndices) {
  126228. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p0, faceAdjacencies.p1, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  126229. }
  126230. else {
  126231. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3], indices[index * 3 + 1], otherP0, otherP1, otherP2);
  126232. }
  126233. break;
  126234. case 1:
  126235. if (this._checkVerticesInsteadOfIndices) {
  126236. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p1, faceAdjacencies.p2, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  126237. }
  126238. else {
  126239. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 1], indices[index * 3 + 2], otherP0, otherP1, otherP2);
  126240. }
  126241. break;
  126242. case 2:
  126243. if (this._checkVerticesInsteadOfIndices) {
  126244. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p2, faceAdjacencies.p0, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  126245. }
  126246. else {
  126247. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 2], indices[index * 3], otherP0, otherP1, otherP2);
  126248. }
  126249. break;
  126250. }
  126251. if (otherEdgeIndex === -1) {
  126252. continue;
  126253. }
  126254. faceAdjacencies.edges[edgeIndex] = otherIndex;
  126255. otherFaceAdjacencies.edges[otherEdgeIndex] = index;
  126256. faceAdjacencies.edgesConnectedCount++;
  126257. otherFaceAdjacencies.edgesConnectedCount++;
  126258. if (faceAdjacencies.edgesConnectedCount === 3) {
  126259. break;
  126260. }
  126261. }
  126262. }
  126263. }
  126264. // Create lines
  126265. for (index = 0; index < adjacencies.length; index++) {
  126266. // 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
  126267. var current = adjacencies[index];
  126268. this._checkEdge(index, current.edges[0], faceNormals, current.p0, current.p1);
  126269. this._checkEdge(index, current.edges[1], faceNormals, current.p1, current.p2);
  126270. this._checkEdge(index, current.edges[2], faceNormals, current.p2, current.p0);
  126271. }
  126272. // Merge into a single mesh
  126273. var engine = this._source.getScene().getEngine();
  126274. 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);
  126275. 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);
  126276. this._ib = engine.createIndexBuffer(this._linesIndices);
  126277. this._indicesCount = this._linesIndices.length;
  126278. };
  126279. /**
  126280. * Checks wether or not the edges renderer is ready to render.
  126281. * @return true if ready, otherwise false.
  126282. */
  126283. EdgesRenderer.prototype.isReady = function () {
  126284. return this._lineShader.isReady();
  126285. };
  126286. /**
  126287. * Renders the edges of the attached mesh,
  126288. */
  126289. EdgesRenderer.prototype.render = function () {
  126290. var scene = this._source.getScene();
  126291. if (!this.isReady() || !scene.activeCamera) {
  126292. return;
  126293. }
  126294. var engine = scene.getEngine();
  126295. this._lineShader._preBind();
  126296. if (this._source.edgesColor.a !== 1) {
  126297. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE);
  126298. }
  126299. else {
  126300. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  126301. }
  126302. // VBOs
  126303. engine.bindBuffers(this._buffers, this._ib, this._lineShader.getEffect());
  126304. scene.resetCachedMaterial();
  126305. this._lineShader.setColor4("color", this._source.edgesColor);
  126306. if (scene.activeCamera.mode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__["Camera"].ORTHOGRAPHIC_CAMERA) {
  126307. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForOrthographic);
  126308. }
  126309. else {
  126310. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForPerspective);
  126311. }
  126312. this._lineShader.setFloat("aspectRatio", engine.getAspectRatio(scene.activeCamera));
  126313. this._lineShader.bind(this._source.getWorldMatrix());
  126314. // Draw order
  126315. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, this._indicesCount);
  126316. this._lineShader.unbind();
  126317. };
  126318. return EdgesRenderer;
  126319. }());
  126320. /**
  126321. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  126322. */
  126323. var LineEdgesRenderer = /** @class */ (function (_super) {
  126324. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LineEdgesRenderer, _super);
  126325. /**
  126326. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  126327. * @param source LineMesh used to generate edges
  126328. * @param epsilon not important (specified angle for edge detection)
  126329. * @param checkVerticesInsteadOfIndices not important for LineMesh
  126330. */
  126331. function LineEdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices) {
  126332. if (epsilon === void 0) { epsilon = 0.95; }
  126333. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  126334. var _this = _super.call(this, source, epsilon, checkVerticesInsteadOfIndices, false) || this;
  126335. _this._generateEdgesLines();
  126336. return _this;
  126337. }
  126338. /**
  126339. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  126340. */
  126341. LineEdgesRenderer.prototype._generateEdgesLines = function () {
  126342. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  126343. var indices = this._source.getIndices();
  126344. if (!indices || !positions) {
  126345. return;
  126346. }
  126347. var p0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  126348. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  126349. var len = indices.length - 1;
  126350. for (var i = 0, offset = 0; i < len; i += 2, offset += 4) {
  126351. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i], p0);
  126352. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i + 1], p1);
  126353. this.createLine(p0, p1, offset);
  126354. }
  126355. // Merge into a single mesh
  126356. var engine = this._source.getScene().getEngine();
  126357. 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);
  126358. 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);
  126359. this._ib = engine.createIndexBuffer(this._linesIndices);
  126360. this._indicesCount = this._linesIndices.length;
  126361. };
  126362. return LineEdgesRenderer;
  126363. }(EdgesRenderer));
  126364. /***/ }),
  126365. /***/ "./Rendering/geometryBufferRenderer.ts":
  126366. /*!*********************************************!*\
  126367. !*** ./Rendering/geometryBufferRenderer.ts ***!
  126368. \*********************************************/
  126369. /*! exports provided: GeometryBufferRenderer */
  126370. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126371. "use strict";
  126372. __webpack_require__.r(__webpack_exports__);
  126373. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return GeometryBufferRenderer; });
  126374. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  126375. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  126376. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  126377. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  126378. /* harmony import */ var _Materials_Textures_multiRenderTarget__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  126379. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  126380. /* harmony import */ var _Shaders_geometry_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/geometry.fragment */ "./Shaders/geometry.fragment.ts");
  126381. /* harmony import */ var _Shaders_geometry_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/geometry.vertex */ "./Shaders/geometry.vertex.ts");
  126382. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  126383. /**
  126384. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  126385. */
  126386. var GeometryBufferRenderer = /** @class */ (function () {
  126387. /**
  126388. * Creates a new G Buffer for the scene
  126389. * @param scene The scene the buffer belongs to
  126390. * @param ratio How big is the buffer related to the main canvas.
  126391. */
  126392. function GeometryBufferRenderer(scene, ratio) {
  126393. if (ratio === void 0) { ratio = 1; }
  126394. /**
  126395. * Dictionary used to store the previous transformation matrices of each rendered mesh
  126396. * in order to compute objects velocities when enableVelocity is set to "true"
  126397. * @hidden
  126398. */
  126399. this._previousTransformationMatrices = {};
  126400. this._enablePosition = false;
  126401. this._enableVelocity = false;
  126402. this._positionIndex = -1;
  126403. this._velocityIndex = -1;
  126404. this._scene = scene;
  126405. this._ratio = ratio;
  126406. GeometryBufferRenderer._SceneComponentInitialization(this._scene);
  126407. // Render target
  126408. this._createRenderTargets();
  126409. }
  126410. Object.defineProperty(GeometryBufferRenderer.prototype, "renderList", {
  126411. /**
  126412. * Set the render list (meshes to be rendered) used in the G buffer.
  126413. */
  126414. set: function (meshes) {
  126415. this._multiRenderTarget.renderList = meshes;
  126416. },
  126417. enumerable: true,
  126418. configurable: true
  126419. });
  126420. Object.defineProperty(GeometryBufferRenderer.prototype, "isSupported", {
  126421. /**
  126422. * Gets wether or not G buffer are supported by the running hardware.
  126423. * This requires draw buffer supports
  126424. */
  126425. get: function () {
  126426. return this._multiRenderTarget.isSupported;
  126427. },
  126428. enumerable: true,
  126429. configurable: true
  126430. });
  126431. /**
  126432. * Returns the index of the given texture type in the G-Buffer textures array
  126433. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  126434. * @returns the index of the given texture type in the G-Buffer textures array
  126435. */
  126436. GeometryBufferRenderer.prototype.getTextureIndex = function (textureType) {
  126437. switch (textureType) {
  126438. case GeometryBufferRenderer.POSITION_TEXTURE_TYPE: return this._positionIndex;
  126439. case GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE: return this._velocityIndex;
  126440. default: return -1;
  126441. }
  126442. };
  126443. Object.defineProperty(GeometryBufferRenderer.prototype, "enablePosition", {
  126444. /**
  126445. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  126446. */
  126447. get: function () {
  126448. return this._enablePosition;
  126449. },
  126450. /**
  126451. * Sets whether or not objects positions are enabled for the G buffer.
  126452. */
  126453. set: function (enable) {
  126454. this._enablePosition = enable;
  126455. this.dispose();
  126456. this._createRenderTargets();
  126457. },
  126458. enumerable: true,
  126459. configurable: true
  126460. });
  126461. Object.defineProperty(GeometryBufferRenderer.prototype, "enableVelocity", {
  126462. /**
  126463. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  126464. */
  126465. get: function () {
  126466. return this._enableVelocity;
  126467. },
  126468. /**
  126469. * Sets wether or not objects velocities are enabled for the G buffer.
  126470. */
  126471. set: function (enable) {
  126472. this._enableVelocity = enable;
  126473. this.dispose();
  126474. this._createRenderTargets();
  126475. },
  126476. enumerable: true,
  126477. configurable: true
  126478. });
  126479. Object.defineProperty(GeometryBufferRenderer.prototype, "scene", {
  126480. /**
  126481. * Gets the scene associated with the buffer.
  126482. */
  126483. get: function () {
  126484. return this._scene;
  126485. },
  126486. enumerable: true,
  126487. configurable: true
  126488. });
  126489. Object.defineProperty(GeometryBufferRenderer.prototype, "ratio", {
  126490. /**
  126491. * Gets the ratio used by the buffer during its creation.
  126492. * How big is the buffer related to the main canvas.
  126493. */
  126494. get: function () {
  126495. return this._ratio;
  126496. },
  126497. enumerable: true,
  126498. configurable: true
  126499. });
  126500. /**
  126501. * Checks wether everything is ready to render a submesh to the G buffer.
  126502. * @param subMesh the submesh to check readiness for
  126503. * @param useInstances is the mesh drawn using instance or not
  126504. * @returns true if ready otherwise false
  126505. */
  126506. GeometryBufferRenderer.prototype.isReady = function (subMesh, useInstances) {
  126507. var material = subMesh.getMaterial();
  126508. if (material && material.disableDepthWrite) {
  126509. return false;
  126510. }
  126511. var defines = [];
  126512. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  126513. var mesh = subMesh.getMesh();
  126514. // Alpha test
  126515. if (material && material.needAlphaTesting()) {
  126516. defines.push("#define ALPHATEST");
  126517. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  126518. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  126519. defines.push("#define UV1");
  126520. }
  126521. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  126522. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  126523. defines.push("#define UV2");
  126524. }
  126525. }
  126526. // Buffers
  126527. if (this._enablePosition) {
  126528. defines.push("#define POSITION");
  126529. defines.push("#define POSITION_INDEX " + this._positionIndex);
  126530. }
  126531. if (this._enableVelocity) {
  126532. defines.push("#define VELOCITY");
  126533. defines.push("#define VELOCITY_INDEX " + this._velocityIndex);
  126534. }
  126535. // Bones
  126536. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  126537. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  126538. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  126539. if (mesh.numBoneInfluencers > 4) {
  126540. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  126541. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  126542. }
  126543. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  126544. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  126545. }
  126546. else {
  126547. defines.push("#define NUM_BONE_INFLUENCERS 0");
  126548. }
  126549. // Instances
  126550. if (useInstances) {
  126551. defines.push("#define INSTANCES");
  126552. attribs.push("world0");
  126553. attribs.push("world1");
  126554. attribs.push("world2");
  126555. attribs.push("world3");
  126556. }
  126557. // Setup textures count
  126558. defines.push("#define RENDER_TARGET_COUNT " + this._multiRenderTarget.textures.length);
  126559. // Get correct effect
  126560. var join = defines.join("\n");
  126561. if (this._cachedDefines !== join) {
  126562. this._cachedDefines = join;
  126563. this._effect = this._scene.getEngine().createEffect("geometry", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "view", "previousWorldViewProjection"], ["diffuseSampler"], join, undefined, undefined, undefined, { buffersCount: this._enablePosition ? 3 : 2 });
  126564. }
  126565. return this._effect.isReady();
  126566. };
  126567. /**
  126568. * Gets the current underlying G Buffer.
  126569. * @returns the buffer
  126570. */
  126571. GeometryBufferRenderer.prototype.getGBuffer = function () {
  126572. return this._multiRenderTarget;
  126573. };
  126574. Object.defineProperty(GeometryBufferRenderer.prototype, "samples", {
  126575. /**
  126576. * Gets the number of samples used to render the buffer (anti aliasing).
  126577. */
  126578. get: function () {
  126579. return this._multiRenderTarget.samples;
  126580. },
  126581. /**
  126582. * Sets the number of samples used to render the buffer (anti aliasing).
  126583. */
  126584. set: function (value) {
  126585. this._multiRenderTarget.samples = value;
  126586. },
  126587. enumerable: true,
  126588. configurable: true
  126589. });
  126590. /**
  126591. * Disposes the renderer and frees up associated resources.
  126592. */
  126593. GeometryBufferRenderer.prototype.dispose = function () {
  126594. this.getGBuffer().dispose();
  126595. };
  126596. GeometryBufferRenderer.prototype._createRenderTargets = function () {
  126597. var _this = this;
  126598. var engine = this._scene.getEngine();
  126599. var count = 2;
  126600. if (this._enablePosition) {
  126601. this._positionIndex = count;
  126602. count++;
  126603. }
  126604. if (this._enableVelocity) {
  126605. this._velocityIndex = count;
  126606. count++;
  126607. }
  126608. 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 });
  126609. if (!this.isSupported) {
  126610. return;
  126611. }
  126612. this._multiRenderTarget.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  126613. this._multiRenderTarget.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  126614. this._multiRenderTarget.refreshRate = 1;
  126615. this._multiRenderTarget.renderParticles = false;
  126616. this._multiRenderTarget.renderList = null;
  126617. // set default depth value to 1.0 (far away)
  126618. this._multiRenderTarget.onClearObservable.add(function (engine) {
  126619. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0.0, 0.0, 0.0, 1.0), true, true, true);
  126620. });
  126621. // Custom render function
  126622. var renderSubMesh = function (subMesh) {
  126623. var mesh = subMesh.getRenderingMesh();
  126624. var scene = _this._scene;
  126625. var engine = scene.getEngine();
  126626. var material = subMesh.getMaterial();
  126627. if (!material) {
  126628. return;
  126629. }
  126630. // Velocity
  126631. if (!_this._previousTransformationMatrices[mesh.uniqueId]) {
  126632. _this._previousTransformationMatrices[mesh.uniqueId] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  126633. }
  126634. // Culling
  126635. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  126636. // Managing instances
  126637. var batch = mesh._getInstancesRenderList(subMesh._id);
  126638. if (batch.mustReturn) {
  126639. return;
  126640. }
  126641. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  126642. if (_this.isReady(subMesh, hardwareInstancedRendering)) {
  126643. engine.enableEffect(_this._effect);
  126644. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  126645. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  126646. _this._effect.setMatrix("view", scene.getViewMatrix());
  126647. // Alpha test
  126648. if (material && material.needAlphaTesting()) {
  126649. var alphaTexture = material.getAlphaTestTexture();
  126650. if (alphaTexture) {
  126651. _this._effect.setTexture("diffuseSampler", alphaTexture);
  126652. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  126653. }
  126654. }
  126655. // Bones
  126656. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  126657. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  126658. }
  126659. // Velocity
  126660. _this._effect.setMatrix("previousWorldViewProjection", _this._previousTransformationMatrices[mesh.uniqueId]);
  126661. // Draw
  126662. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  126663. }
  126664. // Velocity
  126665. _this._previousTransformationMatrices[mesh.uniqueId] = mesh.getWorldMatrix().multiply(_this._scene.getTransformMatrix());
  126666. };
  126667. this._multiRenderTarget.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  126668. var index;
  126669. if (depthOnlySubMeshes.length) {
  126670. engine.setColorWrite(false);
  126671. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  126672. renderSubMesh(depthOnlySubMeshes.data[index]);
  126673. }
  126674. engine.setColorWrite(true);
  126675. }
  126676. for (index = 0; index < opaqueSubMeshes.length; index++) {
  126677. renderSubMesh(opaqueSubMeshes.data[index]);
  126678. }
  126679. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  126680. renderSubMesh(alphaTestSubMeshes.data[index]);
  126681. }
  126682. };
  126683. };
  126684. /**
  126685. * Constant used to retrieve the position texture index in the G-Buffer textures array
  126686. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  126687. */
  126688. GeometryBufferRenderer.POSITION_TEXTURE_TYPE = 1;
  126689. /**
  126690. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  126691. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  126692. */
  126693. GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE = 2;
  126694. /** @hidden */
  126695. GeometryBufferRenderer._SceneComponentInitialization = function (_) {
  126696. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("GeometryBufferRendererSceneComponent");
  126697. };
  126698. return GeometryBufferRenderer;
  126699. }());
  126700. /***/ }),
  126701. /***/ "./Rendering/geometryBufferRendererSceneComponent.ts":
  126702. /*!***********************************************************!*\
  126703. !*** ./Rendering/geometryBufferRendererSceneComponent.ts ***!
  126704. \***********************************************************/
  126705. /*! exports provided: GeometryBufferRendererSceneComponent */
  126706. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126707. "use strict";
  126708. __webpack_require__.r(__webpack_exports__);
  126709. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return GeometryBufferRendererSceneComponent; });
  126710. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  126711. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  126712. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  126713. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "geometryBufferRenderer", {
  126714. get: function () {
  126715. this._geometryBufferRenderer;
  126716. },
  126717. set: function (value) {
  126718. if (value && value.isSupported) {
  126719. this._geometryBufferRenderer = value;
  126720. }
  126721. },
  126722. enumerable: true,
  126723. configurable: true
  126724. });
  126725. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableGeometryBufferRenderer = function (ratio) {
  126726. if (ratio === void 0) { ratio = 1; }
  126727. if (this._geometryBufferRenderer) {
  126728. return this._geometryBufferRenderer;
  126729. }
  126730. this._geometryBufferRenderer = new _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"](this, ratio);
  126731. if (!this._geometryBufferRenderer.isSupported) {
  126732. this._geometryBufferRenderer = null;
  126733. }
  126734. return this._geometryBufferRenderer;
  126735. };
  126736. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableGeometryBufferRenderer = function () {
  126737. if (!this._geometryBufferRenderer) {
  126738. return;
  126739. }
  126740. this._geometryBufferRenderer.dispose();
  126741. this._geometryBufferRenderer = null;
  126742. };
  126743. /**
  126744. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  126745. * in several rendering techniques.
  126746. */
  126747. var GeometryBufferRendererSceneComponent = /** @class */ (function () {
  126748. /**
  126749. * Creates a new instance of the component for the given scene
  126750. * @param scene Defines the scene to register the component in
  126751. */
  126752. function GeometryBufferRendererSceneComponent(scene) {
  126753. /**
  126754. * The component name helpful to identify the component in the list of scene components.
  126755. */
  126756. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER;
  126757. this.scene = scene;
  126758. }
  126759. /**
  126760. * Registers the component in a given scene
  126761. */
  126762. GeometryBufferRendererSceneComponent.prototype.register = function () {
  126763. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER, this, this._gatherRenderTargets);
  126764. };
  126765. /**
  126766. * Rebuilds the elements related to this component in case of
  126767. * context lost for instance.
  126768. */
  126769. GeometryBufferRendererSceneComponent.prototype.rebuild = function () {
  126770. // Nothing to do for this component
  126771. };
  126772. /**
  126773. * Disposes the component and the associated ressources
  126774. */
  126775. GeometryBufferRendererSceneComponent.prototype.dispose = function () {
  126776. // Nothing to do for this component
  126777. };
  126778. GeometryBufferRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  126779. if (this.scene._geometryBufferRenderer) {
  126780. renderTargets.push(this.scene._geometryBufferRenderer.getGBuffer());
  126781. }
  126782. };
  126783. return GeometryBufferRendererSceneComponent;
  126784. }());
  126785. _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"]._SceneComponentInitialization = function (scene) {
  126786. // Register the G Buffer component to the scene.
  126787. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER);
  126788. if (!component) {
  126789. component = new GeometryBufferRendererSceneComponent(scene);
  126790. scene._addComponent(component);
  126791. }
  126792. };
  126793. /***/ }),
  126794. /***/ "./Rendering/index.ts":
  126795. /*!****************************!*\
  126796. !*** ./Rendering/index.ts ***!
  126797. \****************************/
  126798. /*! exports provided: BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer */
  126799. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126800. "use strict";
  126801. __webpack_require__.r(__webpack_exports__);
  126802. /* harmony import */ var _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBoxRenderer */ "./Rendering/boundingBoxRenderer.ts");
  126803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  126804. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  126805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]; });
  126806. /* harmony import */ var _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./depthRendererSceneComponent */ "./Rendering/depthRendererSceneComponent.ts");
  126807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__["DepthRendererSceneComponent"]; });
  126808. /* harmony import */ var _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./edgesRenderer */ "./Rendering/edgesRenderer.ts");
  126809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["EdgesRenderer"]; });
  126810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["LineEdgesRenderer"]; });
  126811. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  126812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__["GeometryBufferRenderer"]; });
  126813. /* harmony import */ var _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  126814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRendererSceneComponent"]; });
  126815. /* harmony import */ var _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./outlineRenderer */ "./Rendering/outlineRenderer.ts");
  126816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__["OutlineRenderer"]; });
  126817. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  126818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _renderingGroup__WEBPACK_IMPORTED_MODULE_7__["RenderingGroup"]; });
  126819. /* harmony import */ var _renderingManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./renderingManager */ "./Rendering/renderingManager.ts");
  126820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingGroupInfo"]; });
  126821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingManager"]; });
  126822. /* harmony import */ var _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  126823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"]; });
  126824. /***/ }),
  126825. /***/ "./Rendering/outlineRenderer.ts":
  126826. /*!**************************************!*\
  126827. !*** ./Rendering/outlineRenderer.ts ***!
  126828. \**************************************/
  126829. /*! exports provided: OutlineRenderer */
  126830. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126831. "use strict";
  126832. __webpack_require__.r(__webpack_exports__);
  126833. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return OutlineRenderer; });
  126834. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  126835. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  126836. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  126837. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  126838. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  126839. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  126840. /* harmony import */ var _Shaders_outline_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/outline.fragment */ "./Shaders/outline.fragment.ts");
  126841. /* harmony import */ var _Shaders_outline_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/outline.vertex */ "./Shaders/outline.vertex.ts");
  126842. /**
  126843. * Gets the outline renderer associated with the scene
  126844. * @returns a OutlineRenderer
  126845. */
  126846. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype.getOutlineRenderer = function () {
  126847. if (!this._outlineRenderer) {
  126848. this._outlineRenderer = new OutlineRenderer(this);
  126849. }
  126850. return this._outlineRenderer;
  126851. };
  126852. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOutline", {
  126853. get: function () {
  126854. return this._renderOutline;
  126855. },
  126856. set: function (value) {
  126857. if (value) {
  126858. // Lazy Load the component.
  126859. this.getScene().getOutlineRenderer();
  126860. }
  126861. this._renderOutline = value;
  126862. },
  126863. enumerable: true,
  126864. configurable: true
  126865. });
  126866. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOverlay", {
  126867. get: function () {
  126868. return this._renderOverlay;
  126869. },
  126870. set: function (value) {
  126871. if (value) {
  126872. // Lazy Load the component.
  126873. this.getScene().getOutlineRenderer();
  126874. }
  126875. this._renderOverlay = value;
  126876. },
  126877. enumerable: true,
  126878. configurable: true
  126879. });
  126880. /**
  126881. * This class is responsible to draw bothe outline/overlay of meshes.
  126882. * It should not be used directly but through the available method on mesh.
  126883. */
  126884. var OutlineRenderer = /** @class */ (function () {
  126885. /**
  126886. * Instantiates a new outline renderer. (There could be only one per scene).
  126887. * @param scene Defines the scene it belongs to
  126888. */
  126889. function OutlineRenderer(scene) {
  126890. /**
  126891. * The name of the component. Each component must have a unique name.
  126892. */
  126893. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OUTLINERENDERER;
  126894. /**
  126895. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  126896. */
  126897. this.zOffset = 1;
  126898. this.scene = scene;
  126899. this._engine = scene.getEngine();
  126900. this.scene._addComponent(this);
  126901. }
  126902. /**
  126903. * Register the component to one instance of a scene.
  126904. */
  126905. OutlineRenderer.prototype.register = function () {
  126906. this.scene._beforeRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_BEFORERENDERINGMESH_OUTLINE, this, this._beforeRenderingMesh);
  126907. this.scene._afterRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDERINGMESH_OUTLINE, this, this._afterRenderingMesh);
  126908. };
  126909. /**
  126910. * Rebuilds the elements related to this component in case of
  126911. * context lost for instance.
  126912. */
  126913. OutlineRenderer.prototype.rebuild = function () {
  126914. // Nothing to do here.
  126915. };
  126916. /**
  126917. * Disposes the component and the associated ressources.
  126918. */
  126919. OutlineRenderer.prototype.dispose = function () {
  126920. // Nothing to do here.
  126921. };
  126922. /**
  126923. * Renders the outline in the canvas.
  126924. * @param subMesh Defines the sumesh to render
  126925. * @param batch Defines the batch of meshes in case of instances
  126926. * @param useOverlay Defines if the rendering is for the overlay or the outline
  126927. */
  126928. OutlineRenderer.prototype.render = function (subMesh, batch, useOverlay) {
  126929. var _this = this;
  126930. if (useOverlay === void 0) { useOverlay = false; }
  126931. var scene = this.scene;
  126932. var engine = scene.getEngine();
  126933. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  126934. if (!this.isReady(subMesh, hardwareInstancedRendering)) {
  126935. return;
  126936. }
  126937. var mesh = subMesh.getRenderingMesh();
  126938. var material = subMesh.getMaterial();
  126939. if (!material || !scene.activeCamera) {
  126940. return;
  126941. }
  126942. engine.enableEffect(this._effect);
  126943. // Logarithmic depth
  126944. if (material.useLogarithmicDepth) {
  126945. this._effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  126946. }
  126947. this._effect.setFloat("offset", useOverlay ? 0 : mesh.outlineWidth);
  126948. this._effect.setColor4("color", useOverlay ? mesh.overlayColor : mesh.outlineColor, useOverlay ? mesh.overlayAlpha : material.alpha);
  126949. this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  126950. // Bones
  126951. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  126952. this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  126953. }
  126954. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  126955. // Alpha test
  126956. if (material && material.needAlphaTesting()) {
  126957. var alphaTexture = material.getAlphaTestTexture();
  126958. if (alphaTexture) {
  126959. this._effect.setTexture("diffuseSampler", alphaTexture);
  126960. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  126961. }
  126962. }
  126963. engine.setZOffset(-this.zOffset);
  126964. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { _this._effect.setMatrix("world", world); });
  126965. engine.setZOffset(0);
  126966. };
  126967. /**
  126968. * Returns whether or not the outline renderer is ready for a given submesh.
  126969. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  126970. * @param subMesh Defines the submesh to check readyness for
  126971. * @param useInstances Defines wheter wee are trying to render instances or not
  126972. * @returns true if ready otherwise false
  126973. */
  126974. OutlineRenderer.prototype.isReady = function (subMesh, useInstances) {
  126975. var defines = [];
  126976. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].NormalKind];
  126977. var mesh = subMesh.getMesh();
  126978. var material = subMesh.getMaterial();
  126979. if (material) {
  126980. // Alpha test
  126981. if (material.needAlphaTesting()) {
  126982. defines.push("#define ALPHATEST");
  126983. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind)) {
  126984. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind);
  126985. defines.push("#define UV1");
  126986. }
  126987. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind)) {
  126988. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind);
  126989. defines.push("#define UV2");
  126990. }
  126991. }
  126992. //Logarithmic depth
  126993. if (material.useLogarithmicDepth) {
  126994. defines.push("#define LOGARITHMICDEPTH");
  126995. }
  126996. }
  126997. // Bones
  126998. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  126999. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesKind);
  127000. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsKind);
  127001. if (mesh.numBoneInfluencers > 4) {
  127002. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesExtraKind);
  127003. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsExtraKind);
  127004. }
  127005. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  127006. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  127007. }
  127008. else {
  127009. defines.push("#define NUM_BONE_INFLUENCERS 0");
  127010. }
  127011. // Instances
  127012. if (useInstances) {
  127013. defines.push("#define INSTANCES");
  127014. attribs.push("world0");
  127015. attribs.push("world1");
  127016. attribs.push("world2");
  127017. attribs.push("world3");
  127018. }
  127019. // Get correct effect
  127020. var join = defines.join("\n");
  127021. if (this._cachedDefines !== join) {
  127022. this._cachedDefines = join;
  127023. this._effect = this.scene.getEngine().createEffect("outline", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "offset", "color", "logarithmicDepthConstant"], ["diffuseSampler"], join);
  127024. }
  127025. return this._effect.isReady();
  127026. };
  127027. OutlineRenderer.prototype._beforeRenderingMesh = function (mesh, subMesh, batch) {
  127028. // Outline - step 1
  127029. this._savedDepthWrite = this._engine.getDepthWrite();
  127030. if (mesh.renderOutline) {
  127031. var material = subMesh.getMaterial();
  127032. if (material && material.needAlphaBlending) {
  127033. this._engine.cacheStencilState();
  127034. // Draw only to stencil buffer for the original mesh
  127035. // The resulting stencil buffer will be used so the outline is not visible inside the mesh when the mesh is transparent
  127036. this._engine.setDepthWrite(false);
  127037. this._engine.setColorWrite(false);
  127038. this._engine.setStencilBuffer(true);
  127039. this._engine.setStencilOperationPass(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].REPLACE);
  127040. this._engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALWAYS);
  127041. this._engine.setStencilMask(OutlineRenderer._StencilReference);
  127042. this._engine.setStencilFunctionReference(OutlineRenderer._StencilReference);
  127043. this.render(subMesh, batch, /* This sets offset to 0 */ true);
  127044. this._engine.setColorWrite(true);
  127045. this._engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].NOTEQUAL);
  127046. }
  127047. // Draw the outline using the above stencil if needed to avoid drawing within the mesh
  127048. this._engine.setDepthWrite(false);
  127049. this.render(subMesh, batch);
  127050. this._engine.setDepthWrite(this._savedDepthWrite);
  127051. if (material && material.needAlphaBlending) {
  127052. this._engine.restoreStencilState();
  127053. }
  127054. }
  127055. };
  127056. OutlineRenderer.prototype._afterRenderingMesh = function (mesh, subMesh, batch) {
  127057. // Outline - step 2
  127058. if (mesh.renderOutline && this._savedDepthWrite) {
  127059. this._engine.setDepthWrite(true);
  127060. this._engine.setColorWrite(false);
  127061. this.render(subMesh, batch);
  127062. this._engine.setColorWrite(true);
  127063. }
  127064. // Overlay
  127065. if (mesh.renderOverlay) {
  127066. var currentMode = this._engine.getAlphaMode();
  127067. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALPHA_COMBINE);
  127068. this.render(subMesh, batch, true);
  127069. this._engine.setAlphaMode(currentMode);
  127070. }
  127071. };
  127072. /**
  127073. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  127074. */
  127075. OutlineRenderer._StencilReference = 0x04;
  127076. return OutlineRenderer;
  127077. }());
  127078. /***/ }),
  127079. /***/ "./Rendering/renderingGroup.ts":
  127080. /*!*************************************!*\
  127081. !*** ./Rendering/renderingGroup.ts ***!
  127082. \*************************************/
  127083. /*! exports provided: RenderingGroup */
  127084. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127085. "use strict";
  127086. __webpack_require__.r(__webpack_exports__);
  127087. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return RenderingGroup; });
  127088. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  127089. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  127090. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  127091. /**
  127092. * This represents the object necessary to create a rendering group.
  127093. * This is exclusively used and created by the rendering manager.
  127094. * To modify the behavior, you use the available helpers in your scene or meshes.
  127095. * @hidden
  127096. */
  127097. var RenderingGroup = /** @class */ (function () {
  127098. /**
  127099. * Creates a new rendering group.
  127100. * @param index The rendering group index
  127101. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  127102. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  127103. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  127104. */
  127105. function RenderingGroup(index, scene, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  127106. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  127107. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  127108. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  127109. this.index = index;
  127110. this._opaqueSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  127111. this._transparentSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  127112. this._alphaTestSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  127113. this._depthOnlySubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  127114. this._particleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  127115. this._spriteManagers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  127116. this._edgesRenderers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  127117. this._scene = scene;
  127118. this.opaqueSortCompareFn = opaqueSortCompareFn;
  127119. this.alphaTestSortCompareFn = alphaTestSortCompareFn;
  127120. this.transparentSortCompareFn = transparentSortCompareFn;
  127121. }
  127122. Object.defineProperty(RenderingGroup.prototype, "opaqueSortCompareFn", {
  127123. /**
  127124. * Set the opaque sort comparison function.
  127125. * If null the sub meshes will be render in the order they were created
  127126. */
  127127. set: function (value) {
  127128. this._opaqueSortCompareFn = value;
  127129. if (value) {
  127130. this._renderOpaque = this.renderOpaqueSorted;
  127131. }
  127132. else {
  127133. this._renderOpaque = RenderingGroup.renderUnsorted;
  127134. }
  127135. },
  127136. enumerable: true,
  127137. configurable: true
  127138. });
  127139. Object.defineProperty(RenderingGroup.prototype, "alphaTestSortCompareFn", {
  127140. /**
  127141. * Set the alpha test sort comparison function.
  127142. * If null the sub meshes will be render in the order they were created
  127143. */
  127144. set: function (value) {
  127145. this._alphaTestSortCompareFn = value;
  127146. if (value) {
  127147. this._renderAlphaTest = this.renderAlphaTestSorted;
  127148. }
  127149. else {
  127150. this._renderAlphaTest = RenderingGroup.renderUnsorted;
  127151. }
  127152. },
  127153. enumerable: true,
  127154. configurable: true
  127155. });
  127156. Object.defineProperty(RenderingGroup.prototype, "transparentSortCompareFn", {
  127157. /**
  127158. * Set the transparent sort comparison function.
  127159. * If null the sub meshes will be render in the order they were created
  127160. */
  127161. set: function (value) {
  127162. if (value) {
  127163. this._transparentSortCompareFn = value;
  127164. }
  127165. else {
  127166. this._transparentSortCompareFn = RenderingGroup.defaultTransparentSortCompare;
  127167. }
  127168. this._renderTransparent = this.renderTransparentSorted;
  127169. },
  127170. enumerable: true,
  127171. configurable: true
  127172. });
  127173. /**
  127174. * Render all the sub meshes contained in the group.
  127175. * @param customRenderFunction Used to override the default render behaviour of the group.
  127176. * @returns true if rendered some submeshes.
  127177. */
  127178. RenderingGroup.prototype.render = function (customRenderFunction, renderSprites, renderParticles, activeMeshes) {
  127179. if (customRenderFunction) {
  127180. customRenderFunction(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, this._depthOnlySubMeshes);
  127181. return;
  127182. }
  127183. var engine = this._scene.getEngine();
  127184. // Depth only
  127185. if (this._depthOnlySubMeshes.length !== 0) {
  127186. engine.setColorWrite(false);
  127187. this._renderAlphaTest(this._depthOnlySubMeshes);
  127188. engine.setColorWrite(true);
  127189. }
  127190. // Opaque
  127191. if (this._opaqueSubMeshes.length !== 0) {
  127192. this._renderOpaque(this._opaqueSubMeshes);
  127193. }
  127194. // Alpha test
  127195. if (this._alphaTestSubMeshes.length !== 0) {
  127196. this._renderAlphaTest(this._alphaTestSubMeshes);
  127197. }
  127198. var stencilState = engine.getStencilBuffer();
  127199. engine.setStencilBuffer(false);
  127200. // Sprites
  127201. if (renderSprites) {
  127202. this._renderSprites();
  127203. }
  127204. // Particles
  127205. if (renderParticles) {
  127206. this._renderParticles(activeMeshes);
  127207. }
  127208. if (this.onBeforeTransparentRendering) {
  127209. this.onBeforeTransparentRendering();
  127210. }
  127211. // Transparent
  127212. if (this._transparentSubMeshes.length !== 0) {
  127213. this._renderTransparent(this._transparentSubMeshes);
  127214. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  127215. }
  127216. // Set back stencil to false in case it changes before the edge renderer.
  127217. engine.setStencilBuffer(false);
  127218. // Edges
  127219. if (this._edgesRenderers.length) {
  127220. for (var edgesRendererIndex = 0; edgesRendererIndex < this._edgesRenderers.length; edgesRendererIndex++) {
  127221. this._edgesRenderers.data[edgesRendererIndex].render();
  127222. }
  127223. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  127224. }
  127225. // Restore Stencil state.
  127226. engine.setStencilBuffer(stencilState);
  127227. };
  127228. /**
  127229. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  127230. * @param subMeshes The submeshes to render
  127231. */
  127232. RenderingGroup.prototype.renderOpaqueSorted = function (subMeshes) {
  127233. return RenderingGroup.renderSorted(subMeshes, this._opaqueSortCompareFn, this._scene.activeCamera, false);
  127234. };
  127235. /**
  127236. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  127237. * @param subMeshes The submeshes to render
  127238. */
  127239. RenderingGroup.prototype.renderAlphaTestSorted = function (subMeshes) {
  127240. return RenderingGroup.renderSorted(subMeshes, this._alphaTestSortCompareFn, this._scene.activeCamera, false);
  127241. };
  127242. /**
  127243. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  127244. * @param subMeshes The submeshes to render
  127245. */
  127246. RenderingGroup.prototype.renderTransparentSorted = function (subMeshes) {
  127247. return RenderingGroup.renderSorted(subMeshes, this._transparentSortCompareFn, this._scene.activeCamera, true);
  127248. };
  127249. /**
  127250. * Renders the submeshes in a specified order.
  127251. * @param subMeshes The submeshes to sort before render
  127252. * @param sortCompareFn The comparison function use to sort
  127253. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  127254. * @param transparent Specifies to activate blending if true
  127255. */
  127256. RenderingGroup.renderSorted = function (subMeshes, sortCompareFn, camera, transparent) {
  127257. var subIndex = 0;
  127258. var subMesh;
  127259. var cameraPosition = camera ? camera.globalPosition : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  127260. for (; subIndex < subMeshes.length; subIndex++) {
  127261. subMesh = subMeshes.data[subIndex];
  127262. subMesh._alphaIndex = subMesh.getMesh().alphaIndex;
  127263. subMesh._distanceToCamera = subMesh.getBoundingInfo().boundingSphere.centerWorld.subtract(cameraPosition).length();
  127264. }
  127265. var sortedArray = subMeshes.data.slice(0, subMeshes.length);
  127266. if (sortCompareFn) {
  127267. sortedArray.sort(sortCompareFn);
  127268. }
  127269. for (subIndex = 0; subIndex < sortedArray.length; subIndex++) {
  127270. subMesh = sortedArray[subIndex];
  127271. if (transparent) {
  127272. var material = subMesh.getMaterial();
  127273. if (material && material.needDepthPrePass) {
  127274. var engine = material.getScene().getEngine();
  127275. engine.setColorWrite(false);
  127276. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  127277. subMesh.render(false);
  127278. engine.setColorWrite(true);
  127279. }
  127280. }
  127281. subMesh.render(transparent);
  127282. }
  127283. };
  127284. /**
  127285. * Renders the submeshes in the order they were dispatched (no sort applied).
  127286. * @param subMeshes The submeshes to render
  127287. */
  127288. RenderingGroup.renderUnsorted = function (subMeshes) {
  127289. for (var subIndex = 0; subIndex < subMeshes.length; subIndex++) {
  127290. var submesh = subMeshes.data[subIndex];
  127291. submesh.render(false);
  127292. }
  127293. };
  127294. /**
  127295. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  127296. * are rendered back to front if in the same alpha index.
  127297. *
  127298. * @param a The first submesh
  127299. * @param b The second submesh
  127300. * @returns The result of the comparison
  127301. */
  127302. RenderingGroup.defaultTransparentSortCompare = function (a, b) {
  127303. // Alpha index first
  127304. if (a._alphaIndex > b._alphaIndex) {
  127305. return 1;
  127306. }
  127307. if (a._alphaIndex < b._alphaIndex) {
  127308. return -1;
  127309. }
  127310. // Then distance to camera
  127311. return RenderingGroup.backToFrontSortCompare(a, b);
  127312. };
  127313. /**
  127314. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  127315. * are rendered back to front.
  127316. *
  127317. * @param a The first submesh
  127318. * @param b The second submesh
  127319. * @returns The result of the comparison
  127320. */
  127321. RenderingGroup.backToFrontSortCompare = function (a, b) {
  127322. // Then distance to camera
  127323. if (a._distanceToCamera < b._distanceToCamera) {
  127324. return 1;
  127325. }
  127326. if (a._distanceToCamera > b._distanceToCamera) {
  127327. return -1;
  127328. }
  127329. return 0;
  127330. };
  127331. /**
  127332. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  127333. * are rendered front to back (prevent overdraw).
  127334. *
  127335. * @param a The first submesh
  127336. * @param b The second submesh
  127337. * @returns The result of the comparison
  127338. */
  127339. RenderingGroup.frontToBackSortCompare = function (a, b) {
  127340. // Then distance to camera
  127341. if (a._distanceToCamera < b._distanceToCamera) {
  127342. return -1;
  127343. }
  127344. if (a._distanceToCamera > b._distanceToCamera) {
  127345. return 1;
  127346. }
  127347. return 0;
  127348. };
  127349. /**
  127350. * Resets the different lists of submeshes to prepare a new frame.
  127351. */
  127352. RenderingGroup.prototype.prepare = function () {
  127353. this._opaqueSubMeshes.reset();
  127354. this._transparentSubMeshes.reset();
  127355. this._alphaTestSubMeshes.reset();
  127356. this._depthOnlySubMeshes.reset();
  127357. this._particleSystems.reset();
  127358. this._spriteManagers.reset();
  127359. this._edgesRenderers.reset();
  127360. };
  127361. RenderingGroup.prototype.dispose = function () {
  127362. this._opaqueSubMeshes.dispose();
  127363. this._transparentSubMeshes.dispose();
  127364. this._alphaTestSubMeshes.dispose();
  127365. this._depthOnlySubMeshes.dispose();
  127366. this._particleSystems.dispose();
  127367. this._spriteManagers.dispose();
  127368. this._edgesRenderers.dispose();
  127369. };
  127370. /**
  127371. * Inserts the submesh in its correct queue depending on its material.
  127372. * @param subMesh The submesh to dispatch
  127373. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  127374. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  127375. */
  127376. RenderingGroup.prototype.dispatch = function (subMesh, mesh, material) {
  127377. // Get mesh and materials if not provided
  127378. if (mesh === undefined) {
  127379. mesh = subMesh.getMesh();
  127380. }
  127381. if (material === undefined) {
  127382. material = subMesh.getMaterial();
  127383. }
  127384. if (material === null || material === undefined) {
  127385. return;
  127386. }
  127387. if (material.needAlphaBlendingForMesh(mesh)) { // Transparent
  127388. this._transparentSubMeshes.push(subMesh);
  127389. }
  127390. else if (material.needAlphaTesting()) { // Alpha test
  127391. if (material.needDepthPrePass) {
  127392. this._depthOnlySubMeshes.push(subMesh);
  127393. }
  127394. this._alphaTestSubMeshes.push(subMesh);
  127395. }
  127396. else {
  127397. if (material.needDepthPrePass) {
  127398. this._depthOnlySubMeshes.push(subMesh);
  127399. }
  127400. this._opaqueSubMeshes.push(subMesh); // Opaque
  127401. }
  127402. if (mesh._edgesRenderer && mesh._edgesRenderer.isEnabled) {
  127403. this._edgesRenderers.push(mesh._edgesRenderer);
  127404. }
  127405. };
  127406. RenderingGroup.prototype.dispatchSprites = function (spriteManager) {
  127407. this._spriteManagers.push(spriteManager);
  127408. };
  127409. RenderingGroup.prototype.dispatchParticles = function (particleSystem) {
  127410. this._particleSystems.push(particleSystem);
  127411. };
  127412. RenderingGroup.prototype._renderParticles = function (activeMeshes) {
  127413. if (this._particleSystems.length === 0) {
  127414. return;
  127415. }
  127416. // Particles
  127417. var activeCamera = this._scene.activeCamera;
  127418. this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);
  127419. for (var particleIndex = 0; particleIndex < this._particleSystems.length; particleIndex++) {
  127420. var particleSystem = this._particleSystems.data[particleIndex];
  127421. if ((activeCamera && activeCamera.layerMask & particleSystem.layerMask) === 0) {
  127422. continue;
  127423. }
  127424. var emitter = particleSystem.emitter;
  127425. if (!emitter.position || !activeMeshes || activeMeshes.indexOf(emitter) !== -1) {
  127426. this._scene._activeParticles.addCount(particleSystem.render(), false);
  127427. }
  127428. }
  127429. this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene);
  127430. };
  127431. RenderingGroup.prototype._renderSprites = function () {
  127432. if (!this._scene.spritesEnabled || this._spriteManagers.length === 0) {
  127433. return;
  127434. }
  127435. // Sprites
  127436. var activeCamera = this._scene.activeCamera;
  127437. this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);
  127438. for (var id = 0; id < this._spriteManagers.length; id++) {
  127439. var spriteManager = this._spriteManagers.data[id];
  127440. if (((activeCamera && activeCamera.layerMask & spriteManager.layerMask) !== 0)) {
  127441. spriteManager.render();
  127442. }
  127443. }
  127444. this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene);
  127445. };
  127446. return RenderingGroup;
  127447. }());
  127448. /***/ }),
  127449. /***/ "./Rendering/renderingManager.ts":
  127450. /*!***************************************!*\
  127451. !*** ./Rendering/renderingManager.ts ***!
  127452. \***************************************/
  127453. /*! exports provided: RenderingGroupInfo, RenderingManager */
  127454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127455. "use strict";
  127456. __webpack_require__.r(__webpack_exports__);
  127457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return RenderingGroupInfo; });
  127458. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return RenderingManager; });
  127459. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  127460. /**
  127461. * This class is used by the onRenderingGroupObservable
  127462. */
  127463. var RenderingGroupInfo = /** @class */ (function () {
  127464. function RenderingGroupInfo() {
  127465. }
  127466. return RenderingGroupInfo;
  127467. }());
  127468. /**
  127469. * This is the manager responsible of all the rendering for meshes sprites and particles.
  127470. * It is enable to manage the different groups as well as the different necessary sort functions.
  127471. * This should not be used directly aside of the few static configurations
  127472. */
  127473. var RenderingManager = /** @class */ (function () {
  127474. /**
  127475. * Instantiates a new rendering group for a particular scene
  127476. * @param scene Defines the scene the groups belongs to
  127477. */
  127478. function RenderingManager(scene) {
  127479. /**
  127480. * @hidden
  127481. */
  127482. this._useSceneAutoClearSetup = false;
  127483. this._renderingGroups = new Array();
  127484. this._autoClearDepthStencil = {};
  127485. this._customOpaqueSortCompareFn = {};
  127486. this._customAlphaTestSortCompareFn = {};
  127487. this._customTransparentSortCompareFn = {};
  127488. this._renderingGroupInfo = new RenderingGroupInfo();
  127489. this._scene = scene;
  127490. for (var i = RenderingManager.MIN_RENDERINGGROUPS; i < RenderingManager.MAX_RENDERINGGROUPS; i++) {
  127491. this._autoClearDepthStencil[i] = { autoClear: true, depth: true, stencil: true };
  127492. }
  127493. }
  127494. RenderingManager.prototype._clearDepthStencilBuffer = function (depth, stencil) {
  127495. if (depth === void 0) { depth = true; }
  127496. if (stencil === void 0) { stencil = true; }
  127497. if (this._depthStencilBufferAlreadyCleaned) {
  127498. return;
  127499. }
  127500. this._scene.getEngine().clear(null, false, depth, stencil);
  127501. this._depthStencilBufferAlreadyCleaned = true;
  127502. };
  127503. /**
  127504. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  127505. * @hidden
  127506. */
  127507. RenderingManager.prototype.render = function (customRenderFunction, activeMeshes, renderParticles, renderSprites) {
  127508. // Update the observable context (not null as it only goes away on dispose)
  127509. var info = this._renderingGroupInfo;
  127510. info.scene = this._scene;
  127511. info.camera = this._scene.activeCamera;
  127512. // Dispatch sprites
  127513. if (this._scene.spriteManagers && renderSprites) {
  127514. for (var index = 0; index < this._scene.spriteManagers.length; index++) {
  127515. var manager = this._scene.spriteManagers[index];
  127516. this.dispatchSprites(manager);
  127517. }
  127518. }
  127519. // Render
  127520. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  127521. this._depthStencilBufferAlreadyCleaned = index === RenderingManager.MIN_RENDERINGGROUPS;
  127522. var renderingGroup = this._renderingGroups[index];
  127523. if (!renderingGroup) {
  127524. continue;
  127525. }
  127526. var renderingGroupMask = Math.pow(2, index);
  127527. info.renderingGroupId = index;
  127528. // Before Observable
  127529. this._scene.onBeforeRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  127530. // Clear depth/stencil if needed
  127531. if (RenderingManager.AUTOCLEAR) {
  127532. var autoClear = this._useSceneAutoClearSetup ?
  127533. this._scene.getAutoClearDepthStencilSetup(index) :
  127534. this._autoClearDepthStencil[index];
  127535. if (autoClear && autoClear.autoClear) {
  127536. this._clearDepthStencilBuffer(autoClear.depth, autoClear.stencil);
  127537. }
  127538. }
  127539. // Render
  127540. for (var _i = 0, _a = this._scene._beforeRenderingGroupDrawStage; _i < _a.length; _i++) {
  127541. var step = _a[_i];
  127542. step.action(index);
  127543. }
  127544. renderingGroup.render(customRenderFunction, renderSprites, renderParticles, activeMeshes);
  127545. for (var _b = 0, _c = this._scene._afterRenderingGroupDrawStage; _b < _c.length; _b++) {
  127546. var step = _c[_b];
  127547. step.action(index);
  127548. }
  127549. // After Observable
  127550. this._scene.onAfterRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  127551. }
  127552. };
  127553. /**
  127554. * Resets the different information of the group to prepare a new frame
  127555. * @hidden
  127556. */
  127557. RenderingManager.prototype.reset = function () {
  127558. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  127559. var renderingGroup = this._renderingGroups[index];
  127560. if (renderingGroup) {
  127561. renderingGroup.prepare();
  127562. }
  127563. }
  127564. };
  127565. /**
  127566. * Dispose and release the group and its associated resources.
  127567. * @hidden
  127568. */
  127569. RenderingManager.prototype.dispose = function () {
  127570. this.freeRenderingGroups();
  127571. this._renderingGroups.length = 0;
  127572. this._renderingGroupInfo = null;
  127573. };
  127574. /**
  127575. * Clear the info related to rendering groups preventing retention points during dispose.
  127576. */
  127577. RenderingManager.prototype.freeRenderingGroups = function () {
  127578. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  127579. var renderingGroup = this._renderingGroups[index];
  127580. if (renderingGroup) {
  127581. renderingGroup.dispose();
  127582. }
  127583. }
  127584. };
  127585. RenderingManager.prototype._prepareRenderingGroup = function (renderingGroupId) {
  127586. if (this._renderingGroups[renderingGroupId] === undefined) {
  127587. this._renderingGroups[renderingGroupId] = new _renderingGroup__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"](renderingGroupId, this._scene, this._customOpaqueSortCompareFn[renderingGroupId], this._customAlphaTestSortCompareFn[renderingGroupId], this._customTransparentSortCompareFn[renderingGroupId]);
  127588. }
  127589. };
  127590. /**
  127591. * Add a sprite manager to the rendering manager in order to render it this frame.
  127592. * @param spriteManager Define the sprite manager to render
  127593. */
  127594. RenderingManager.prototype.dispatchSprites = function (spriteManager) {
  127595. var renderingGroupId = spriteManager.renderingGroupId || 0;
  127596. this._prepareRenderingGroup(renderingGroupId);
  127597. this._renderingGroups[renderingGroupId].dispatchSprites(spriteManager);
  127598. };
  127599. /**
  127600. * Add a particle system to the rendering manager in order to render it this frame.
  127601. * @param particleSystem Define the particle system to render
  127602. */
  127603. RenderingManager.prototype.dispatchParticles = function (particleSystem) {
  127604. var renderingGroupId = particleSystem.renderingGroupId || 0;
  127605. this._prepareRenderingGroup(renderingGroupId);
  127606. this._renderingGroups[renderingGroupId].dispatchParticles(particleSystem);
  127607. };
  127608. /**
  127609. * Add a submesh to the manager in order to render it this frame
  127610. * @param subMesh The submesh to dispatch
  127611. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  127612. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  127613. */
  127614. RenderingManager.prototype.dispatch = function (subMesh, mesh, material) {
  127615. if (mesh === undefined) {
  127616. mesh = subMesh.getMesh();
  127617. }
  127618. var renderingGroupId = mesh.renderingGroupId || 0;
  127619. this._prepareRenderingGroup(renderingGroupId);
  127620. this._renderingGroups[renderingGroupId].dispatch(subMesh, mesh, material);
  127621. };
  127622. /**
  127623. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  127624. * This allowed control for front to back rendering or reversly depending of the special needs.
  127625. *
  127626. * @param renderingGroupId The rendering group id corresponding to its index
  127627. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  127628. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  127629. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  127630. */
  127631. RenderingManager.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  127632. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  127633. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  127634. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  127635. this._customOpaqueSortCompareFn[renderingGroupId] = opaqueSortCompareFn;
  127636. this._customAlphaTestSortCompareFn[renderingGroupId] = alphaTestSortCompareFn;
  127637. this._customTransparentSortCompareFn[renderingGroupId] = transparentSortCompareFn;
  127638. if (this._renderingGroups[renderingGroupId]) {
  127639. var group = this._renderingGroups[renderingGroupId];
  127640. group.opaqueSortCompareFn = this._customOpaqueSortCompareFn[renderingGroupId];
  127641. group.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[renderingGroupId];
  127642. group.transparentSortCompareFn = this._customTransparentSortCompareFn[renderingGroupId];
  127643. }
  127644. };
  127645. /**
  127646. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  127647. *
  127648. * @param renderingGroupId The rendering group id corresponding to its index
  127649. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  127650. * @param depth Automatically clears depth between groups if true and autoClear is true.
  127651. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  127652. */
  127653. RenderingManager.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  127654. if (depth === void 0) { depth = true; }
  127655. if (stencil === void 0) { stencil = true; }
  127656. this._autoClearDepthStencil[renderingGroupId] = {
  127657. autoClear: autoClearDepthStencil,
  127658. depth: depth,
  127659. stencil: stencil
  127660. };
  127661. };
  127662. /**
  127663. * Gets the current auto clear configuration for one rendering group of the rendering
  127664. * manager.
  127665. * @param index the rendering group index to get the information for
  127666. * @returns The auto clear setup for the requested rendering group
  127667. */
  127668. RenderingManager.prototype.getAutoClearDepthStencilSetup = function (index) {
  127669. return this._autoClearDepthStencil[index];
  127670. };
  127671. /**
  127672. * The max id used for rendering groups (not included)
  127673. */
  127674. RenderingManager.MAX_RENDERINGGROUPS = 4;
  127675. /**
  127676. * The min id used for rendering groups (included)
  127677. */
  127678. RenderingManager.MIN_RENDERINGGROUPS = 0;
  127679. /**
  127680. * Used to globally prevent autoclearing scenes.
  127681. */
  127682. RenderingManager.AUTOCLEAR = true;
  127683. return RenderingManager;
  127684. }());
  127685. /***/ }),
  127686. /***/ "./Rendering/utilityLayerRenderer.ts":
  127687. /*!*******************************************!*\
  127688. !*** ./Rendering/utilityLayerRenderer.ts ***!
  127689. \*******************************************/
  127690. /*! exports provided: UtilityLayerRenderer */
  127691. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127692. "use strict";
  127693. __webpack_require__.r(__webpack_exports__);
  127694. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return UtilityLayerRenderer; });
  127695. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  127696. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  127697. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  127698. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  127699. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  127700. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  127701. /**
  127702. * Renders a layer on top of an existing scene
  127703. */
  127704. var UtilityLayerRenderer = /** @class */ (function () {
  127705. /**
  127706. * Instantiates a UtilityLayerRenderer
  127707. * @param originalScene the original scene that will be rendered on top of
  127708. * @param handleEvents boolean indicating if the utility layer should handle events
  127709. */
  127710. function UtilityLayerRenderer(
  127711. /** the original scene that will be rendered on top of */
  127712. originalScene, handleEvents) {
  127713. if (handleEvents === void 0) { handleEvents = true; }
  127714. var _this = this;
  127715. this.originalScene = originalScene;
  127716. this._pointerCaptures = {};
  127717. this._lastPointerEvents = {};
  127718. this._sharedGizmoLight = null;
  127719. /**
  127720. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  127721. */
  127722. this.pickUtilitySceneFirst = true;
  127723. /**
  127724. * If the utility layer should automatically be rendered on top of existing scene
  127725. */
  127726. this.shouldRender = true;
  127727. /**
  127728. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  127729. */
  127730. this.onlyCheckPointerDownEvents = true;
  127731. /**
  127732. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  127733. */
  127734. this.processAllEvents = false;
  127735. /**
  127736. * Observable raised when the pointer move from the utility layer scene to the main scene
  127737. */
  127738. this.onPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  127739. // Create scene which will be rendered in the foreground and remove it from being referenced by engine to avoid interfering with existing app
  127740. this.utilityLayerScene = new _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"](originalScene.getEngine());
  127741. this.utilityLayerScene.useRightHandedSystem = originalScene.useRightHandedSystem;
  127742. this.utilityLayerScene._allowPostProcessClearColor = false;
  127743. originalScene.getEngine().scenes.pop();
  127744. // Detach controls on utility scene, events will be fired by logic below to handle picking priority
  127745. this.utilityLayerScene.detachControl();
  127746. if (handleEvents) {
  127747. this._originalPointerObserver = originalScene.onPrePointerObservable.add(function (prePointerInfo, eventState) {
  127748. if (!_this.utilityLayerScene.activeCamera) {
  127749. return;
  127750. }
  127751. if (!_this.processAllEvents) {
  127752. if (prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE
  127753. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP
  127754. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  127755. return;
  127756. }
  127757. }
  127758. _this.utilityLayerScene.pointerX = originalScene.pointerX;
  127759. _this.utilityLayerScene.pointerY = originalScene.pointerY;
  127760. var pointerEvent = (prePointerInfo.event);
  127761. if (originalScene.isPointerCaptured(pointerEvent.pointerId)) {
  127762. _this._pointerCaptures[pointerEvent.pointerId] = false;
  127763. return;
  127764. }
  127765. var utilityScenePick = prePointerInfo.ray ? _this.utilityLayerScene.pickWithRay(prePointerInfo.ray) : _this.utilityLayerScene.pick(originalScene.pointerX, originalScene.pointerY);
  127766. if (!prePointerInfo.ray && utilityScenePick) {
  127767. prePointerInfo.ray = utilityScenePick.ray;
  127768. }
  127769. // always fire the prepointer oversvable
  127770. _this.utilityLayerScene.onPrePointerObservable.notifyObservers(prePointerInfo);
  127771. // allow every non pointer down event to flow to the utility layer
  127772. if (_this.onlyCheckPointerDownEvents && prePointerInfo.type != _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  127773. if (!prePointerInfo.skipOnPointerObservable) {
  127774. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  127775. }
  127776. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent.pointerId]) {
  127777. _this._pointerCaptures[pointerEvent.pointerId] = false;
  127778. }
  127779. return;
  127780. }
  127781. if (_this.utilityLayerScene.autoClearDepthAndStencil || _this.pickUtilitySceneFirst) {
  127782. // If this layer is an overlay, check if this layer was hit and if so, skip pointer events for the main scene
  127783. if (utilityScenePick && utilityScenePick.hit) {
  127784. if (!prePointerInfo.skipOnPointerObservable) {
  127785. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  127786. }
  127787. prePointerInfo.skipOnPointerObservable = true;
  127788. }
  127789. }
  127790. else {
  127791. var originalScenePick = prePointerInfo.ray ? originalScene.pickWithRay(prePointerInfo.ray) : originalScene.pick(originalScene.pointerX, originalScene.pointerY);
  127792. var pointerEvent_1 = (prePointerInfo.event);
  127793. // If the layer can be occluded by the original scene, only fire pointer events to the first layer that hit they ray
  127794. if (originalScenePick && utilityScenePick) {
  127795. // No pick in utility scene
  127796. if (utilityScenePick.distance === 0 && originalScenePick.pickedMesh) {
  127797. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  127798. // We touched an utility mesh present in the main scene
  127799. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  127800. prePointerInfo.skipOnPointerObservable = true;
  127801. }
  127802. else if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  127803. _this._pointerCaptures[pointerEvent_1.pointerId] = true;
  127804. }
  127805. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  127806. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  127807. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  127808. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  127809. }
  127810. }
  127811. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance < originalScenePick.distance || originalScenePick.distance === 0)) {
  127812. // We pick something in utility scene or the pick in utility is closer than the one in main scene
  127813. _this._notifyObservers(prePointerInfo, utilityScenePick, pointerEvent_1);
  127814. // If a previous utility layer set this, do not unset this
  127815. if (!prePointerInfo.skipOnPointerObservable) {
  127816. prePointerInfo.skipOnPointerObservable = utilityScenePick.distance > 0;
  127817. }
  127818. }
  127819. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance > originalScenePick.distance)) {
  127820. // We have a pick in both scenes but main is closer than utility
  127821. // We touched an utility mesh present in the main scene
  127822. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  127823. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  127824. prePointerInfo.skipOnPointerObservable = true;
  127825. }
  127826. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  127827. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  127828. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  127829. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  127830. }
  127831. }
  127832. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent_1.pointerId]) {
  127833. _this._pointerCaptures[pointerEvent_1.pointerId] = false;
  127834. }
  127835. }
  127836. }
  127837. });
  127838. // As a newly added utility layer will be rendered over the screen last, it's pointer events should be processed first
  127839. if (this._originalPointerObserver) {
  127840. originalScene.onPrePointerObservable.makeObserverTopPriority(this._originalPointerObserver);
  127841. }
  127842. }
  127843. // Render directly on top of existing scene without clearing
  127844. this.utilityLayerScene.autoClear = false;
  127845. this._afterRenderObserver = this.originalScene.onAfterRenderObservable.add(function () {
  127846. if (_this.shouldRender) {
  127847. _this.render();
  127848. }
  127849. });
  127850. this._sceneDisposeObserver = this.originalScene.onDisposeObservable.add(function () {
  127851. _this.dispose();
  127852. });
  127853. this._updateCamera();
  127854. }
  127855. /**
  127856. * @hidden
  127857. * Light which used by gizmos to get light shading
  127858. */
  127859. UtilityLayerRenderer.prototype._getSharedGizmoLight = function () {
  127860. if (!this._sharedGizmoLight) {
  127861. this._sharedGizmoLight = new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_4__["HemisphericLight"]("shared gizmo light", new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](0, 1, 0), this.utilityLayerScene);
  127862. this._sharedGizmoLight.intensity = 2;
  127863. this._sharedGizmoLight.groundColor = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Color3"].Gray();
  127864. }
  127865. return this._sharedGizmoLight;
  127866. };
  127867. Object.defineProperty(UtilityLayerRenderer, "DefaultUtilityLayer", {
  127868. /**
  127869. * 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)
  127870. */
  127871. get: function () {
  127872. if (UtilityLayerRenderer._DefaultUtilityLayer == null) {
  127873. UtilityLayerRenderer._DefaultUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  127874. UtilityLayerRenderer._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  127875. UtilityLayerRenderer._DefaultUtilityLayer = null;
  127876. });
  127877. }
  127878. return UtilityLayerRenderer._DefaultUtilityLayer;
  127879. },
  127880. enumerable: true,
  127881. configurable: true
  127882. });
  127883. Object.defineProperty(UtilityLayerRenderer, "DefaultKeepDepthUtilityLayer", {
  127884. /**
  127885. * 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)
  127886. */
  127887. get: function () {
  127888. if (UtilityLayerRenderer._DefaultKeepDepthUtilityLayer == null) {
  127889. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  127890. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  127891. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  127892. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  127893. });
  127894. }
  127895. return UtilityLayerRenderer._DefaultKeepDepthUtilityLayer;
  127896. },
  127897. enumerable: true,
  127898. configurable: true
  127899. });
  127900. UtilityLayerRenderer.prototype._notifyObservers = function (prePointerInfo, pickInfo, pointerEvent) {
  127901. if (!prePointerInfo.skipOnPointerObservable) {
  127902. this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, pickInfo));
  127903. this._lastPointerEvents[pointerEvent.pointerId] = true;
  127904. }
  127905. };
  127906. /**
  127907. * Renders the utility layers scene on top of the original scene
  127908. */
  127909. UtilityLayerRenderer.prototype.render = function () {
  127910. this._updateCamera();
  127911. if (this.utilityLayerScene.activeCamera) {
  127912. // Set the camera's scene to utility layers scene
  127913. var oldScene = this.utilityLayerScene.activeCamera.getScene();
  127914. var camera = this.utilityLayerScene.activeCamera;
  127915. camera._scene = this.utilityLayerScene;
  127916. if (camera.leftCamera) {
  127917. camera.leftCamera._scene = this.utilityLayerScene;
  127918. }
  127919. if (camera.rightCamera) {
  127920. camera.rightCamera._scene = this.utilityLayerScene;
  127921. }
  127922. this.utilityLayerScene.render(false);
  127923. // Reset camera's scene back to original
  127924. camera._scene = oldScene;
  127925. if (camera.leftCamera) {
  127926. camera.leftCamera._scene = oldScene;
  127927. }
  127928. if (camera.rightCamera) {
  127929. camera.rightCamera._scene = oldScene;
  127930. }
  127931. }
  127932. };
  127933. /**
  127934. * Disposes of the renderer
  127935. */
  127936. UtilityLayerRenderer.prototype.dispose = function () {
  127937. this.onPointerOutObservable.clear();
  127938. if (this._afterRenderObserver) {
  127939. this.originalScene.onAfterRenderObservable.remove(this._afterRenderObserver);
  127940. }
  127941. if (this._sceneDisposeObserver) {
  127942. this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver);
  127943. }
  127944. if (this._originalPointerObserver) {
  127945. this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver);
  127946. }
  127947. this.utilityLayerScene.dispose();
  127948. };
  127949. UtilityLayerRenderer.prototype._updateCamera = function () {
  127950. if (this.originalScene.activeCameras.length > 1) {
  127951. this.utilityLayerScene.activeCamera = this.originalScene.activeCameras[this.originalScene.activeCameras.length - 1];
  127952. }
  127953. else {
  127954. this.utilityLayerScene.activeCamera = this.originalScene.activeCamera;
  127955. }
  127956. };
  127957. UtilityLayerRenderer._DefaultUtilityLayer = null;
  127958. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  127959. return UtilityLayerRenderer;
  127960. }());
  127961. /***/ }),
  127962. /***/ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts":
  127963. /*!*****************************************************************!*\
  127964. !*** ./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts ***!
  127965. \*****************************************************************/
  127966. /*! exports provided: backgroundFragmentDeclaration */
  127967. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127968. "use strict";
  127969. __webpack_require__.r(__webpack_exports__);
  127970. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundFragmentDeclaration", function() { return backgroundFragmentDeclaration; });
  127971. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127972. var name = 'backgroundFragmentDeclaration';
  127973. 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";
  127974. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127975. /** @hidden */
  127976. var backgroundFragmentDeclaration = { name: name, shader: shader };
  127977. /***/ }),
  127978. /***/ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts":
  127979. /*!************************************************************!*\
  127980. !*** ./Shaders/ShadersInclude/backgroundUboDeclaration.ts ***!
  127981. \************************************************************/
  127982. /*! exports provided: backgroundUboDeclaration */
  127983. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127984. "use strict";
  127985. __webpack_require__.r(__webpack_exports__);
  127986. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundUboDeclaration", function() { return backgroundUboDeclaration; });
  127987. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  127988. var name = 'backgroundUboDeclaration';
  127989. var shader = "layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec4 vPrimaryColor;\nuniform vec4 vPrimaryColorShadow;\nuniform vec2 vDiffuseInfos;\nuniform vec2 vReflectionInfos;\nuniform mat4 diffuseMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float fFovMultiplier;\nuniform float pointSize;\nuniform float shadowLevel;\nuniform float alpha;\n#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)\nuniform vec3 vBackgroundCenter;\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 vReflectionControl;\n#endif\n};\nuniform Scene {\nmat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif\nmat4 view;\n};";
  127990. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  127991. /** @hidden */
  127992. var backgroundUboDeclaration = { name: name, shader: shader };
  127993. /***/ }),
  127994. /***/ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts":
  127995. /*!***************************************************************!*\
  127996. !*** ./Shaders/ShadersInclude/backgroundVertexDeclaration.ts ***!
  127997. \***************************************************************/
  127998. /*! exports provided: backgroundVertexDeclaration */
  127999. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128000. "use strict";
  128001. __webpack_require__.r(__webpack_exports__);
  128002. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexDeclaration", function() { return backgroundVertexDeclaration; });
  128003. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128004. var name = 'backgroundVertexDeclaration';
  128005. 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";
  128006. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128007. /** @hidden */
  128008. var backgroundVertexDeclaration = { name: name, shader: shader };
  128009. /***/ }),
  128010. /***/ "./Shaders/ShadersInclude/bonesDeclaration.ts":
  128011. /*!****************************************************!*\
  128012. !*** ./Shaders/ShadersInclude/bonesDeclaration.ts ***!
  128013. \****************************************************/
  128014. /*! exports provided: bonesDeclaration */
  128015. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128016. "use strict";
  128017. __webpack_require__.r(__webpack_exports__);
  128018. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesDeclaration", function() { return bonesDeclaration; });
  128019. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128020. var name = 'bonesDeclaration';
  128021. 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";
  128022. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128023. /** @hidden */
  128024. var bonesDeclaration = { name: name, shader: shader };
  128025. /***/ }),
  128026. /***/ "./Shaders/ShadersInclude/bonesVertex.ts":
  128027. /*!***********************************************!*\
  128028. !*** ./Shaders/ShadersInclude/bonesVertex.ts ***!
  128029. \***********************************************/
  128030. /*! exports provided: bonesVertex */
  128031. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128032. "use strict";
  128033. __webpack_require__.r(__webpack_exports__);
  128034. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesVertex", function() { return bonesVertex; });
  128035. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128036. var name = 'bonesVertex';
  128037. 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";
  128038. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128039. /** @hidden */
  128040. var bonesVertex = { name: name, shader: shader };
  128041. /***/ }),
  128042. /***/ "./Shaders/ShadersInclude/bumpFragment.ts":
  128043. /*!************************************************!*\
  128044. !*** ./Shaders/ShadersInclude/bumpFragment.ts ***!
  128045. \************************************************/
  128046. /*! exports provided: bumpFragment */
  128047. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128048. "use strict";
  128049. __webpack_require__.r(__webpack_exports__);
  128050. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragment", function() { return bumpFragment; });
  128051. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128052. var name = 'bumpFragment';
  128053. 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";
  128054. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128055. /** @hidden */
  128056. var bumpFragment = { name: name, shader: shader };
  128057. /***/ }),
  128058. /***/ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts":
  128059. /*!*********************************************************!*\
  128060. !*** ./Shaders/ShadersInclude/bumpFragmentFunctions.ts ***!
  128061. \*********************************************************/
  128062. /*! exports provided: bumpFragmentFunctions */
  128063. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128064. "use strict";
  128065. __webpack_require__.r(__webpack_exports__);
  128066. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragmentFunctions", function() { return bumpFragmentFunctions; });
  128067. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128068. var name = 'bumpFragmentFunctions';
  128069. 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";
  128070. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128071. /** @hidden */
  128072. var bumpFragmentFunctions = { name: name, shader: shader };
  128073. /***/ }),
  128074. /***/ "./Shaders/ShadersInclude/bumpVertex.ts":
  128075. /*!**********************************************!*\
  128076. !*** ./Shaders/ShadersInclude/bumpVertex.ts ***!
  128077. \**********************************************/
  128078. /*! exports provided: bumpVertex */
  128079. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128080. "use strict";
  128081. __webpack_require__.r(__webpack_exports__);
  128082. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertex", function() { return bumpVertex; });
  128083. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128084. var name = 'bumpVertex';
  128085. 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";
  128086. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128087. /** @hidden */
  128088. var bumpVertex = { name: name, shader: shader };
  128089. /***/ }),
  128090. /***/ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts":
  128091. /*!*********************************************************!*\
  128092. !*** ./Shaders/ShadersInclude/bumpVertexDeclaration.ts ***!
  128093. \*********************************************************/
  128094. /*! exports provided: bumpVertexDeclaration */
  128095. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128096. "use strict";
  128097. __webpack_require__.r(__webpack_exports__);
  128098. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertexDeclaration", function() { return bumpVertexDeclaration; });
  128099. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128100. var name = 'bumpVertexDeclaration';
  128101. var shader = "#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#endif\n";
  128102. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128103. /** @hidden */
  128104. var bumpVertexDeclaration = { name: name, shader: shader };
  128105. /***/ }),
  128106. /***/ "./Shaders/ShadersInclude/clipPlaneFragment.ts":
  128107. /*!*****************************************************!*\
  128108. !*** ./Shaders/ShadersInclude/clipPlaneFragment.ts ***!
  128109. \*****************************************************/
  128110. /*! exports provided: clipPlaneFragment */
  128111. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128112. "use strict";
  128113. __webpack_require__.r(__webpack_exports__);
  128114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragment", function() { return clipPlaneFragment; });
  128115. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128116. var name = 'clipPlaneFragment';
  128117. 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";
  128118. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128119. /** @hidden */
  128120. var clipPlaneFragment = { name: name, shader: shader };
  128121. /***/ }),
  128122. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts":
  128123. /*!****************************************************************!*\
  128124. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts ***!
  128125. \****************************************************************/
  128126. /*! exports provided: clipPlaneFragmentDeclaration */
  128127. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128128. "use strict";
  128129. __webpack_require__.r(__webpack_exports__);
  128130. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration", function() { return clipPlaneFragmentDeclaration; });
  128131. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128132. var name = 'clipPlaneFragmentDeclaration';
  128133. 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";
  128134. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128135. /** @hidden */
  128136. var clipPlaneFragmentDeclaration = { name: name, shader: shader };
  128137. /***/ }),
  128138. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts":
  128139. /*!*****************************************************************!*\
  128140. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts ***!
  128141. \*****************************************************************/
  128142. /*! exports provided: clipPlaneFragmentDeclaration2 */
  128143. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128144. "use strict";
  128145. __webpack_require__.r(__webpack_exports__);
  128146. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration2", function() { return clipPlaneFragmentDeclaration2; });
  128147. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128148. var name = 'clipPlaneFragmentDeclaration2';
  128149. 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";
  128150. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128151. /** @hidden */
  128152. var clipPlaneFragmentDeclaration2 = { name: name, shader: shader };
  128153. /***/ }),
  128154. /***/ "./Shaders/ShadersInclude/clipPlaneVertex.ts":
  128155. /*!***************************************************!*\
  128156. !*** ./Shaders/ShadersInclude/clipPlaneVertex.ts ***!
  128157. \***************************************************/
  128158. /*! exports provided: clipPlaneVertex */
  128159. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128160. "use strict";
  128161. __webpack_require__.r(__webpack_exports__);
  128162. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertex", function() { return clipPlaneVertex; });
  128163. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128164. var name = 'clipPlaneVertex';
  128165. 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";
  128166. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128167. /** @hidden */
  128168. var clipPlaneVertex = { name: name, shader: shader };
  128169. /***/ }),
  128170. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts":
  128171. /*!**************************************************************!*\
  128172. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts ***!
  128173. \**************************************************************/
  128174. /*! exports provided: clipPlaneVertexDeclaration */
  128175. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128176. "use strict";
  128177. __webpack_require__.r(__webpack_exports__);
  128178. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration", function() { return clipPlaneVertexDeclaration; });
  128179. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128180. var name = 'clipPlaneVertexDeclaration';
  128181. 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";
  128182. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128183. /** @hidden */
  128184. var clipPlaneVertexDeclaration = { name: name, shader: shader };
  128185. /***/ }),
  128186. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts":
  128187. /*!***************************************************************!*\
  128188. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts ***!
  128189. \***************************************************************/
  128190. /*! exports provided: clipPlaneVertexDeclaration2 */
  128191. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128192. "use strict";
  128193. __webpack_require__.r(__webpack_exports__);
  128194. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration2", function() { return clipPlaneVertexDeclaration2; });
  128195. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128196. var name = 'clipPlaneVertexDeclaration2';
  128197. 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";
  128198. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128199. /** @hidden */
  128200. var clipPlaneVertexDeclaration2 = { name: name, shader: shader };
  128201. /***/ }),
  128202. /***/ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts":
  128203. /*!**************************************************************!*\
  128204. !*** ./Shaders/ShadersInclude/defaultFragmentDeclaration.ts ***!
  128205. \**************************************************************/
  128206. /*! exports provided: defaultFragmentDeclaration */
  128207. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128208. "use strict";
  128209. __webpack_require__.r(__webpack_exports__);
  128210. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultFragmentDeclaration", function() { return defaultFragmentDeclaration; });
  128211. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128212. var name = 'defaultFragmentDeclaration';
  128213. var shader = "uniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nuniform vec3 vEmissiveColor;\nuniform float visibility;\n\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\n#ifndef REFRACTIONMAP_3D\nuniform mat4 refractionMatrix;\n#endif\n#ifdef REFRACTIONFRESNEL\nuniform vec4 refractionLeftColor;\nuniform vec4 refractionRightColor;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\n#endif\n#ifdef DIFFUSEFRESNEL\nuniform vec4 diffuseLeftColor;\nuniform vec4 diffuseRightColor;\n#endif\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;\nuniform vec4 emissiveRightColor;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#ifdef REFLECTIONMAP_SKYBOX\n#else\n#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION)\nuniform mat4 reflectionMatrix;\n#endif\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\n#endif\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#endif";
  128214. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128215. /** @hidden */
  128216. var defaultFragmentDeclaration = { name: name, shader: shader };
  128217. /***/ }),
  128218. /***/ "./Shaders/ShadersInclude/defaultUboDeclaration.ts":
  128219. /*!*********************************************************!*\
  128220. !*** ./Shaders/ShadersInclude/defaultUboDeclaration.ts ***!
  128221. \*********************************************************/
  128222. /*! exports provided: defaultUboDeclaration */
  128223. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128224. "use strict";
  128225. __webpack_require__.r(__webpack_exports__);
  128226. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultUboDeclaration", function() { return defaultUboDeclaration; });
  128227. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128228. var name = 'defaultUboDeclaration';
  128229. var shader = "layout(std140,column_major) uniform;\nuniform Material\n{\nvec4 diffuseLeftColor;\nvec4 diffuseRightColor;\nvec4 opacityParts;\nvec4 reflectionLeftColor;\nvec4 reflectionRightColor;\nvec4 refractionLeftColor;\nvec4 refractionRightColor;\nvec4 emissiveLeftColor;\nvec4 emissiveRightColor;\nvec2 vDiffuseInfos;\nvec2 vAmbientInfos;\nvec2 vOpacityInfos;\nvec2 vReflectionInfos;\nvec3 vReflectionPosition;\nvec3 vReflectionSize;\nvec2 vEmissiveInfos;\nvec2 vLightmapInfos;\nvec2 vSpecularInfos;\nvec3 vBumpInfos;\nmat4 diffuseMatrix;\nmat4 ambientMatrix;\nmat4 opacityMatrix;\nmat4 reflectionMatrix;\nmat4 emissiveMatrix;\nmat4 lightmapMatrix;\nmat4 specularMatrix;\nmat4 bumpMatrix;\nvec2 vTangentSpaceParams;\nfloat pointSize;\nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nfloat visibility;\nvec4 vDiffuseColor;\n};\nuniform Scene {\nmat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif\nmat4 view;\n};\n";
  128230. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128231. /** @hidden */
  128232. var defaultUboDeclaration = { name: name, shader: shader };
  128233. /***/ }),
  128234. /***/ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts":
  128235. /*!************************************************************!*\
  128236. !*** ./Shaders/ShadersInclude/defaultVertexDeclaration.ts ***!
  128237. \************************************************************/
  128238. /*! exports provided: defaultVertexDeclaration */
  128239. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128240. "use strict";
  128241. __webpack_require__.r(__webpack_exports__);
  128242. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexDeclaration", function() { return defaultVertexDeclaration; });
  128243. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128244. var name = 'defaultVertexDeclaration';
  128245. 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";
  128246. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128247. /** @hidden */
  128248. var defaultVertexDeclaration = { name: name, shader: shader };
  128249. /***/ }),
  128250. /***/ "./Shaders/ShadersInclude/depthPrePass.ts":
  128251. /*!************************************************!*\
  128252. !*** ./Shaders/ShadersInclude/depthPrePass.ts ***!
  128253. \************************************************/
  128254. /*! exports provided: depthPrePass */
  128255. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128256. "use strict";
  128257. __webpack_require__.r(__webpack_exports__);
  128258. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPrePass", function() { return depthPrePass; });
  128259. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128260. var name = 'depthPrePass';
  128261. var shader = "#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif";
  128262. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128263. /** @hidden */
  128264. var depthPrePass = { name: name, shader: shader };
  128265. /***/ }),
  128266. /***/ "./Shaders/ShadersInclude/fogFragment.ts":
  128267. /*!***********************************************!*\
  128268. !*** ./Shaders/ShadersInclude/fogFragment.ts ***!
  128269. \***********************************************/
  128270. /*! exports provided: fogFragment */
  128271. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128272. "use strict";
  128273. __webpack_require__.r(__webpack_exports__);
  128274. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragment", function() { return fogFragment; });
  128275. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128276. var name = 'fogFragment';
  128277. var shader = "#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif";
  128278. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128279. /** @hidden */
  128280. var fogFragment = { name: name, shader: shader };
  128281. /***/ }),
  128282. /***/ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts":
  128283. /*!**********************************************************!*\
  128284. !*** ./Shaders/ShadersInclude/fogFragmentDeclaration.ts ***!
  128285. \**********************************************************/
  128286. /*! exports provided: fogFragmentDeclaration */
  128287. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128288. "use strict";
  128289. __webpack_require__.r(__webpack_exports__);
  128290. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragmentDeclaration", function() { return fogFragmentDeclaration; });
  128291. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128292. var name = 'fogFragmentDeclaration';
  128293. 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";
  128294. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128295. /** @hidden */
  128296. var fogFragmentDeclaration = { name: name, shader: shader };
  128297. /***/ }),
  128298. /***/ "./Shaders/ShadersInclude/fogVertex.ts":
  128299. /*!*********************************************!*\
  128300. !*** ./Shaders/ShadersInclude/fogVertex.ts ***!
  128301. \*********************************************/
  128302. /*! exports provided: fogVertex */
  128303. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128304. "use strict";
  128305. __webpack_require__.r(__webpack_exports__);
  128306. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertex", function() { return fogVertex; });
  128307. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128308. var name = 'fogVertex';
  128309. var shader = "#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif";
  128310. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128311. /** @hidden */
  128312. var fogVertex = { name: name, shader: shader };
  128313. /***/ }),
  128314. /***/ "./Shaders/ShadersInclude/fogVertexDeclaration.ts":
  128315. /*!********************************************************!*\
  128316. !*** ./Shaders/ShadersInclude/fogVertexDeclaration.ts ***!
  128317. \********************************************************/
  128318. /*! exports provided: fogVertexDeclaration */
  128319. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128320. "use strict";
  128321. __webpack_require__.r(__webpack_exports__);
  128322. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertexDeclaration", function() { return fogVertexDeclaration; });
  128323. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128324. var name = 'fogVertexDeclaration';
  128325. var shader = "#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";
  128326. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128327. /** @hidden */
  128328. var fogVertexDeclaration = { name: name, shader: shader };
  128329. /***/ }),
  128330. /***/ "./Shaders/ShadersInclude/fresnelFunction.ts":
  128331. /*!***************************************************!*\
  128332. !*** ./Shaders/ShadersInclude/fresnelFunction.ts ***!
  128333. \***************************************************/
  128334. /*! exports provided: fresnelFunction */
  128335. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128336. "use strict";
  128337. __webpack_require__.r(__webpack_exports__);
  128338. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fresnelFunction", function() { return fresnelFunction; });
  128339. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128340. var name = 'fresnelFunction';
  128341. 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";
  128342. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128343. /** @hidden */
  128344. var fresnelFunction = { name: name, shader: shader };
  128345. /***/ }),
  128346. /***/ "./Shaders/ShadersInclude/harmonicsFunctions.ts":
  128347. /*!******************************************************!*\
  128348. !*** ./Shaders/ShadersInclude/harmonicsFunctions.ts ***!
  128349. \******************************************************/
  128350. /*! exports provided: harmonicsFunctions */
  128351. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128352. "use strict";
  128353. __webpack_require__.r(__webpack_exports__);
  128354. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "harmonicsFunctions", function() { return harmonicsFunctions; });
  128355. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128356. var name = 'harmonicsFunctions';
  128357. 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";
  128358. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128359. /** @hidden */
  128360. var harmonicsFunctions = { name: name, shader: shader };
  128361. /***/ }),
  128362. /***/ "./Shaders/ShadersInclude/helperFunctions.ts":
  128363. /*!***************************************************!*\
  128364. !*** ./Shaders/ShadersInclude/helperFunctions.ts ***!
  128365. \***************************************************/
  128366. /*! exports provided: helperFunctions */
  128367. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128368. "use strict";
  128369. __webpack_require__.r(__webpack_exports__);
  128370. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "helperFunctions", function() { return helperFunctions; });
  128371. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128372. var name = 'helperFunctions';
  128373. var shader = "const float PI=3.1415926535897932384626433832795;\nconst float LinearEncodePowerApprox=2.2;\nconst float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;\nconst vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);\nconst float Epsilon=0.0000001;\n#define saturate(x) clamp(x,0.0,1.0)\n#define absEps(x) abs(x)+Epsilon\n#define maxEps(x) max(x,Epsilon)\n#define saturateEps(x) clamp(x,Epsilon,1.0)\nmat3 transposeMat3(mat3 inMatrix) {\nvec3 i0=inMatrix[0];\nvec3 i1=inMatrix[1];\nvec3 i2=inMatrix[2];\nmat3 outMatrix=mat3(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);\nreturn outMatrix;\n}\n\nmat3 inverseMat3(mat3 inMatrix) {\nfloat a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];\nfloat a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];\nfloat a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];\nfloat b01=a22*a11-a12*a21;\nfloat b11=-a22*a10+a12*a20;\nfloat b21=a21*a10-a11*a20;\nfloat det=a00*b01+a01*b11+a02*b21;\nreturn mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),\nb11,(a22*a00-a02*a20),(-a12*a00+a02*a10),\nb21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;\n}\nvec3 toLinearSpace(vec3 color)\n{\nreturn pow(color,vec3(LinearEncodePowerApprox));\n}\nvec3 toGammaSpace(vec3 color)\n{\nreturn pow(color,vec3(GammaEncodePowerApprox));\n}\nfloat square(float value)\n{\nreturn value*value;\n}\nfloat pow5(float value) {\nfloat sq=value*value;\nreturn sq*sq*value;\n}\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,LuminanceEncodeApprox),0.,1.);\n}\n\nfloat getRand(vec2 seed) {\nreturn fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);\n}\nfloat dither(vec2 seed,float varianceAmount) {\nfloat rand=getRand(seed);\nfloat dither=mix(-varianceAmount/255.0,varianceAmount/255.0,rand);\nreturn dither;\n}\n\nconst float rgbdMaxRange=255.0;\nvec4 toRGBD(vec3 color) {\nfloat maxRGB=maxEps(max(color.r,max(color.g,color.b)));\nfloat D=max(rgbdMaxRange/maxRGB,1.);\nD=clamp(floor(D)/255.0,0.,1.);\n\nvec3 rgb=color.rgb*D;\n\nrgb=toGammaSpace(rgb);\nreturn vec4(rgb,D);\n}\nvec3 fromRGBD(vec4 rgbd) {\n\nrgbd.rgb=toLinearSpace(rgbd.rgb);\n\nreturn rgbd.rgb/rgbd.a;\n}";
  128374. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128375. /** @hidden */
  128376. var helperFunctions = { name: name, shader: shader };
  128377. /***/ }),
  128378. /***/ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts":
  128379. /*!**************************************************************!*\
  128380. !*** ./Shaders/ShadersInclude/imageProcessingDeclaration.ts ***!
  128381. \**************************************************************/
  128382. /*! exports provided: imageProcessingDeclaration */
  128383. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128384. "use strict";
  128385. __webpack_require__.r(__webpack_exports__);
  128386. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingDeclaration", function() { return imageProcessingDeclaration; });
  128387. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128388. var name = 'imageProcessingDeclaration';
  128389. 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";
  128390. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128391. /** @hidden */
  128392. var imageProcessingDeclaration = { name: name, shader: shader };
  128393. /***/ }),
  128394. /***/ "./Shaders/ShadersInclude/imageProcessingFunctions.ts":
  128395. /*!************************************************************!*\
  128396. !*** ./Shaders/ShadersInclude/imageProcessingFunctions.ts ***!
  128397. \************************************************************/
  128398. /*! exports provided: imageProcessingFunctions */
  128399. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128400. "use strict";
  128401. __webpack_require__.r(__webpack_exports__);
  128402. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingFunctions", function() { return imageProcessingFunctions; });
  128403. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128404. var name = 'imageProcessingFunctions';
  128405. var shader = "#if defined(COLORGRADING) && !defined(COLORGRADING3D)\n\nvec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)\n{\nfloat sliceSize=2.0*sampler3dSetting.x;\n#ifdef SAMPLER3DGREENDEPTH\nfloat sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;\n#else\nfloat sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;\n#endif\nfloat sliceInteger=floor(sliceContinuous);\n\n\nfloat sliceFraction=sliceContinuous-sliceInteger;\n#ifdef SAMPLER3DGREENDEPTH\nvec2 sliceUV=color.rb;\n#else\nvec2 sliceUV=color.rg;\n#endif\nsliceUV.x*=sliceSize;\nsliceUV.x+=sliceInteger*sliceSize;\nsliceUV=saturate(sliceUV);\nvec4 slice0Color=texture2D(colorTransform,sliceUV);\nsliceUV.x+=sliceSize;\nsliceUV=saturate(sliceUV);\nvec4 slice1Color=texture2D(colorTransform,sliceUV);\nvec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);\n#ifdef SAMPLER3DBGRMAP\ncolor.rgb=result.rgb;\n#else\ncolor.rgb=result.bgr;\n#endif\nreturn color;\n}\n#endif\n#ifdef TONEMAPPING_ACES\n\n\n\n\n\nconst mat3 ACESInputMat=mat3(\nvec3(0.59719,0.07600,0.02840),\nvec3(0.35458,0.90834,0.13383),\nvec3(0.04823,0.01566,0.83777)\n);\n\nconst mat3 ACESOutputMat=mat3(\nvec3( 1.60475,-0.10208,-0.00327),\nvec3(-0.53108,1.10813,-0.07276),\nvec3(-0.07367,-0.00605,1.07602)\n);\nvec3 RRTAndODTFit(vec3 v)\n{\nvec3 a=v*(v+0.0245786)-0.000090537;\nvec3 b=v*(0.983729*v+0.4329510)+0.238081;\nreturn a/b;\n}\nvec3 ACESFitted(vec3 color)\n{\ncolor=ACESInputMat*color;\n\ncolor=RRTAndODTFit(color);\ncolor=ACESOutputMat*color;\n\ncolor=saturate(color);\nreturn color;\n}\n#endif\nvec4 applyImageProcessing(vec4 result) {\n#ifdef EXPOSURE\nresult.rgb*=exposureLinear;\n#endif\n#ifdef VIGNETTE\n\nvec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;\nviewportXY=viewportXY*2.0-1.0;\nvec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);\nfloat vignetteTerm=dot(vignetteXY1,vignetteXY1);\nfloat vignette=pow(vignetteTerm,vignetteSettings2.w);\n\nvec3 vignetteColor=vignetteSettings2.rgb;\n#ifdef VIGNETTEBLENDMODEMULTIPLY\nvec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);\nresult.rgb*=vignetteColorMultiplier;\n#endif\n#ifdef VIGNETTEBLENDMODEOPAQUE\nresult.rgb=mix(vignetteColor,result.rgb,vignette);\n#endif\n#endif\n#ifdef TONEMAPPING\n#ifdef TONEMAPPING_ACES\nresult.rgb=ACESFitted(result.rgb);\n#else\nconst float tonemappingCalibration=1.590579;\nresult.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);\n#endif\n#endif\n\nresult.rgb=toGammaSpace(result.rgb);\nresult.rgb=saturate(result.rgb);\n#ifdef CONTRAST\n\nvec3 resultHighContrast=result.rgb*result.rgb*(3.0-2.0*result.rgb);\nif (contrast<1.0) {\n\nresult.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);\n} else {\n\nresult.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);\n}\n#endif\n\n#ifdef COLORGRADING\nvec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;\n#ifdef COLORGRADING3D\nvec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb;\n#else\nvec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;\n#endif\nresult.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);\n#endif\n#ifdef COLORCURVES\n\nfloat luma=getLuminance(result.rgb);\nvec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));\nvec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;\nresult.rgb*=colorCurve.rgb;\nresult.rgb=mix(vec3(luma),result.rgb,colorCurve.a);\n#endif\nreturn result;\n}";
  128406. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128407. /** @hidden */
  128408. var imageProcessingFunctions = { name: name, shader: shader };
  128409. /***/ }),
  128410. /***/ "./Shaders/ShadersInclude/instancesDeclaration.ts":
  128411. /*!********************************************************!*\
  128412. !*** ./Shaders/ShadersInclude/instancesDeclaration.ts ***!
  128413. \********************************************************/
  128414. /*! exports provided: instancesDeclaration */
  128415. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128416. "use strict";
  128417. __webpack_require__.r(__webpack_exports__);
  128418. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesDeclaration", function() { return instancesDeclaration; });
  128419. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128420. var name = 'instancesDeclaration';
  128421. var shader = "#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif";
  128422. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128423. /** @hidden */
  128424. var instancesDeclaration = { name: name, shader: shader };
  128425. /***/ }),
  128426. /***/ "./Shaders/ShadersInclude/instancesVertex.ts":
  128427. /*!***************************************************!*\
  128428. !*** ./Shaders/ShadersInclude/instancesVertex.ts ***!
  128429. \***************************************************/
  128430. /*! exports provided: instancesVertex */
  128431. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128432. "use strict";
  128433. __webpack_require__.r(__webpack_exports__);
  128434. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesVertex", function() { return instancesVertex; });
  128435. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128436. var name = 'instancesVertex';
  128437. var shader = "#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif";
  128438. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128439. /** @hidden */
  128440. var instancesVertex = { name: name, shader: shader };
  128441. /***/ }),
  128442. /***/ "./Shaders/ShadersInclude/kernelBlurFragment.ts":
  128443. /*!******************************************************!*\
  128444. !*** ./Shaders/ShadersInclude/kernelBlurFragment.ts ***!
  128445. \******************************************************/
  128446. /*! exports provided: kernelBlurFragment */
  128447. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128448. "use strict";
  128449. __webpack_require__.r(__webpack_exports__);
  128450. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment", function() { return kernelBlurFragment; });
  128451. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128452. var name = 'kernelBlurFragment';
  128453. 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";
  128454. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128455. /** @hidden */
  128456. var kernelBlurFragment = { name: name, shader: shader };
  128457. /***/ }),
  128458. /***/ "./Shaders/ShadersInclude/kernelBlurFragment2.ts":
  128459. /*!*******************************************************!*\
  128460. !*** ./Shaders/ShadersInclude/kernelBlurFragment2.ts ***!
  128461. \*******************************************************/
  128462. /*! exports provided: kernelBlurFragment2 */
  128463. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128464. "use strict";
  128465. __webpack_require__.r(__webpack_exports__);
  128466. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment2", function() { return kernelBlurFragment2; });
  128467. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128468. var name = 'kernelBlurFragment2';
  128469. 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";
  128470. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128471. /** @hidden */
  128472. var kernelBlurFragment2 = { name: name, shader: shader };
  128473. /***/ }),
  128474. /***/ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts":
  128475. /*!****************************************************************!*\
  128476. !*** ./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts ***!
  128477. \****************************************************************/
  128478. /*! exports provided: kernelBlurVaryingDeclaration */
  128479. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128480. "use strict";
  128481. __webpack_require__.r(__webpack_exports__);
  128482. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVaryingDeclaration", function() { return kernelBlurVaryingDeclaration; });
  128483. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128484. var name = 'kernelBlurVaryingDeclaration';
  128485. var shader = "varying vec2 sampleCoord{X};";
  128486. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128487. /** @hidden */
  128488. var kernelBlurVaryingDeclaration = { name: name, shader: shader };
  128489. /***/ }),
  128490. /***/ "./Shaders/ShadersInclude/kernelBlurVertex.ts":
  128491. /*!****************************************************!*\
  128492. !*** ./Shaders/ShadersInclude/kernelBlurVertex.ts ***!
  128493. \****************************************************/
  128494. /*! exports provided: kernelBlurVertex */
  128495. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128496. "use strict";
  128497. __webpack_require__.r(__webpack_exports__);
  128498. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertex", function() { return kernelBlurVertex; });
  128499. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128500. var name = 'kernelBlurVertex';
  128501. var shader = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";
  128502. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128503. /** @hidden */
  128504. var kernelBlurVertex = { name: name, shader: shader };
  128505. /***/ }),
  128506. /***/ "./Shaders/ShadersInclude/lightFragment.ts":
  128507. /*!*************************************************!*\
  128508. !*** ./Shaders/ShadersInclude/lightFragment.ts ***!
  128509. \*************************************************/
  128510. /*! exports provided: lightFragment */
  128511. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128512. "use strict";
  128513. __webpack_require__.r(__webpack_exports__);
  128514. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragment", function() { return lightFragment; });
  128515. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128516. var name = 'lightFragment';
  128517. 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";
  128518. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128519. /** @hidden */
  128520. var lightFragment = { name: name, shader: shader };
  128521. /***/ }),
  128522. /***/ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts":
  128523. /*!************************************************************!*\
  128524. !*** ./Shaders/ShadersInclude/lightFragmentDeclaration.ts ***!
  128525. \************************************************************/
  128526. /*! exports provided: lightFragmentDeclaration */
  128527. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128528. "use strict";
  128529. __webpack_require__.r(__webpack_exports__);
  128530. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragmentDeclaration", function() { return lightFragmentDeclaration; });
  128531. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128532. var name = 'lightFragmentDeclaration';
  128533. 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";
  128534. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128535. /** @hidden */
  128536. var lightFragmentDeclaration = { name: name, shader: shader };
  128537. /***/ }),
  128538. /***/ "./Shaders/ShadersInclude/lightUboDeclaration.ts":
  128539. /*!*******************************************************!*\
  128540. !*** ./Shaders/ShadersInclude/lightUboDeclaration.ts ***!
  128541. \*******************************************************/
  128542. /*! exports provided: lightUboDeclaration */
  128543. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128544. "use strict";
  128545. __webpack_require__.r(__webpack_exports__);
  128546. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightUboDeclaration", function() { return lightUboDeclaration; });
  128547. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128548. var name = 'lightUboDeclaration';
  128549. 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";
  128550. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128551. /** @hidden */
  128552. var lightUboDeclaration = { name: name, shader: shader };
  128553. /***/ }),
  128554. /***/ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts":
  128555. /*!***********************************************************!*\
  128556. !*** ./Shaders/ShadersInclude/lightsFragmentFunctions.ts ***!
  128557. \***********************************************************/
  128558. /*! exports provided: lightsFragmentFunctions */
  128559. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128560. "use strict";
  128561. __webpack_require__.r(__webpack_exports__);
  128562. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightsFragmentFunctions", function() { return lightsFragmentFunctions; });
  128563. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128564. var name = 'lightsFragmentFunctions';
  128565. 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}";
  128566. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128567. /** @hidden */
  128568. var lightsFragmentFunctions = { name: name, shader: shader };
  128569. /***/ }),
  128570. /***/ "./Shaders/ShadersInclude/logDepthDeclaration.ts":
  128571. /*!*******************************************************!*\
  128572. !*** ./Shaders/ShadersInclude/logDepthDeclaration.ts ***!
  128573. \*******************************************************/
  128574. /*! exports provided: logDepthDeclaration */
  128575. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128576. "use strict";
  128577. __webpack_require__.r(__webpack_exports__);
  128578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthDeclaration", function() { return logDepthDeclaration; });
  128579. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128580. var name = 'logDepthDeclaration';
  128581. var shader = "#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";
  128582. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128583. /** @hidden */
  128584. var logDepthDeclaration = { name: name, shader: shader };
  128585. /***/ }),
  128586. /***/ "./Shaders/ShadersInclude/logDepthFragment.ts":
  128587. /*!****************************************************!*\
  128588. !*** ./Shaders/ShadersInclude/logDepthFragment.ts ***!
  128589. \****************************************************/
  128590. /*! exports provided: logDepthFragment */
  128591. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128592. "use strict";
  128593. __webpack_require__.r(__webpack_exports__);
  128594. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthFragment", function() { return logDepthFragment; });
  128595. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128596. var name = 'logDepthFragment';
  128597. var shader = "#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif";
  128598. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128599. /** @hidden */
  128600. var logDepthFragment = { name: name, shader: shader };
  128601. /***/ }),
  128602. /***/ "./Shaders/ShadersInclude/logDepthVertex.ts":
  128603. /*!**************************************************!*\
  128604. !*** ./Shaders/ShadersInclude/logDepthVertex.ts ***!
  128605. \**************************************************/
  128606. /*! exports provided: logDepthVertex */
  128607. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128608. "use strict";
  128609. __webpack_require__.r(__webpack_exports__);
  128610. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthVertex", function() { return logDepthVertex; });
  128611. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128612. var name = 'logDepthVertex';
  128613. var shader = "#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif";
  128614. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128615. /** @hidden */
  128616. var logDepthVertex = { name: name, shader: shader };
  128617. /***/ }),
  128618. /***/ "./Shaders/ShadersInclude/morphTargetsVertex.ts":
  128619. /*!******************************************************!*\
  128620. !*** ./Shaders/ShadersInclude/morphTargetsVertex.ts ***!
  128621. \******************************************************/
  128622. /*! exports provided: morphTargetsVertex */
  128623. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128624. "use strict";
  128625. __webpack_require__.r(__webpack_exports__);
  128626. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertex", function() { return morphTargetsVertex; });
  128627. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128628. var name = 'morphTargetsVertex';
  128629. 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";
  128630. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128631. /** @hidden */
  128632. var morphTargetsVertex = { name: name, shader: shader };
  128633. /***/ }),
  128634. /***/ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts":
  128635. /*!*****************************************************************!*\
  128636. !*** ./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts ***!
  128637. \*****************************************************************/
  128638. /*! exports provided: morphTargetsVertexDeclaration */
  128639. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128640. "use strict";
  128641. __webpack_require__.r(__webpack_exports__);
  128642. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexDeclaration", function() { return morphTargetsVertexDeclaration; });
  128643. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128644. var name = 'morphTargetsVertexDeclaration';
  128645. 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";
  128646. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128647. /** @hidden */
  128648. var morphTargetsVertexDeclaration = { name: name, shader: shader };
  128649. /***/ }),
  128650. /***/ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts":
  128651. /*!***********************************************************************!*\
  128652. !*** ./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts ***!
  128653. \***********************************************************************/
  128654. /*! exports provided: morphTargetsVertexGlobalDeclaration */
  128655. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128656. "use strict";
  128657. __webpack_require__.r(__webpack_exports__);
  128658. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexGlobalDeclaration", function() { return morphTargetsVertexGlobalDeclaration; });
  128659. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128660. var name = 'morphTargetsVertexGlobalDeclaration';
  128661. var shader = "#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";
  128662. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128663. /** @hidden */
  128664. var morphTargetsVertexGlobalDeclaration = { name: name, shader: shader };
  128665. /***/ }),
  128666. /***/ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts":
  128667. /*!**********************************************************!*\
  128668. !*** ./Shaders/ShadersInclude/mrtFragmentDeclaration.ts ***!
  128669. \**********************************************************/
  128670. /*! exports provided: mrtFragmentDeclaration */
  128671. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128672. "use strict";
  128673. __webpack_require__.r(__webpack_exports__);
  128674. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mrtFragmentDeclaration", function() { return mrtFragmentDeclaration; });
  128675. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128676. var name = 'mrtFragmentDeclaration';
  128677. var shader = "#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";
  128678. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128679. /** @hidden */
  128680. var mrtFragmentDeclaration = { name: name, shader: shader };
  128681. /***/ }),
  128682. /***/ "./Shaders/ShadersInclude/pbrBRDFFunctions.ts":
  128683. /*!****************************************************!*\
  128684. !*** ./Shaders/ShadersInclude/pbrBRDFFunctions.ts ***!
  128685. \****************************************************/
  128686. /*! exports provided: pbrBRDFFunctions */
  128687. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128688. "use strict";
  128689. __webpack_require__.r(__webpack_exports__);
  128690. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrBRDFFunctions", function() { return pbrBRDFFunctions; });
  128691. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128692. var name = 'pbrBRDFFunctions';
  128693. var shader = "\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n\n\n\n\n#ifdef MS_BRDF_ENERGY_CONSERVATION\n\n\nvec3 getEnergyConservationFactor(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {\nreturn 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);\n}\n#endif\n#ifdef ENVIRONMENTBRDF\nvec3 getBRDFLookup(float NdotV,float perceptualRoughness,sampler2D brdfSampler) {\n\nvec2 UV=vec2(NdotV,perceptualRoughness);\n\nvec4 brdfLookup=texture2D(brdfSampler,UV);\n#ifdef ENVIRONMENTBRDF_RGBD\nbrdfLookup.rgb=fromRGBD(brdfLookup.rgba);\n#endif\nreturn brdfLookup.rgb;\n}\nvec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {\n#ifdef BRDF_V_HEIGHT_CORRELATED\nvec3 reflectance=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0);\n#else\nvec3 reflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;\n#endif\nreturn reflectance;\n}\n#endif\n#if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL)\nvec3 getReflectanceFromAnalyticalBRDFLookup_Jones(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));\n}\n#endif\n#if defined(SHEEN) && defined(REFLECTION)\n\nvec3 getSheenReflectanceFromBRDFLookup(const vec3 reflectance0,const vec3 environmentBrdf) {\nvec3 sheenEnvironmentReflectance=reflectance0*environmentBrdf.b;\nreturn sheenEnvironmentReflectance;\n}\n#endif\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);\n}\nfloat fresnelSchlickGGX(float VdotH,float reflectance0,float reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);\n}\n#ifdef CLEARCOAT\n\n\n\n\n\nvec3 getR0RemappedForClearCoat(vec3 f0) {\n#ifdef CLEARCOAT_DEFAULTIOR\n#ifdef MOBILE\nreturn saturate(f0*(f0*0.526868+0.529324)-0.0482256);\n#else\nreturn saturate(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998);\n#endif\n#else\nvec3 s=sqrt(f0);\nvec3 t=(vClearCoatRefractionParams.z+vClearCoatRefractionParams.w*s)/(vClearCoatRefractionParams.w+vClearCoatRefractionParams.z*s);\nreturn t*t;\n#endif\n}\n#endif\n\n\n\n\n\n\nfloat normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)\n{\n\n\n\nfloat a2=square(alphaG);\nfloat d=NdotH*NdotH*(a2-1.0)+1.0;\nreturn a2/(PI*d*d);\n}\n#ifdef SHEEN\n\nfloat normalDistributionFunction_CharlieSheen(float NdotH,float alphaG)\n{\nfloat invR=1./alphaG;\nfloat cos2h=NdotH*NdotH;\nfloat sin2h=1.-cos2h;\nreturn (2.+invR)*pow(sin2h,invR*.5)/(2.*PI);\n}\n#endif\n#ifdef ANISOTROPIC\n\n\nfloat normalDistributionFunction_BurleyGGX_Anisotropic(float NdotH,float TdotH,float BdotH,const vec2 alphaTB) {\nfloat a2=alphaTB.x*alphaTB.y;\nvec3 v=vec3(alphaTB.y*TdotH,alphaTB.x*BdotH,a2*NdotH);\nfloat v2=dot(v,v);\nfloat w2=a2/v2;\nreturn a2*w2*w2*RECIPROCAL_PI;\n}\n#endif\n\n\n\n\n#ifdef BRDF_V_HEIGHT_CORRELATED\n\n\n\nfloat smithVisibility_GGXCorrelated(float NdotL,float NdotV,float alphaG) {\n#ifdef MOBILE\n\nfloat GGXV=NdotL*(NdotV*(1.0-alphaG)+alphaG);\nfloat GGXL=NdotV*(NdotL*(1.0-alphaG)+alphaG);\nreturn 0.5/(GGXV+GGXL);\n#else\nfloat a2=alphaG*alphaG;\nfloat GGXV=NdotL*sqrt(NdotV*(NdotV-a2*NdotV)+a2);\nfloat GGXL=NdotV*sqrt(NdotL*(NdotL-a2*NdotL)+a2);\nreturn 0.5/(GGXV+GGXL);\n#endif\n}\n#else\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfloat smithVisibilityG1_TrowbridgeReitzGGXFast(float dot,float alphaG)\n{\n#ifdef MOBILE\n\nreturn 1.0/(dot+alphaG+(1.0-alphaG)*dot ));\n#else\nfloat alphaSquared=alphaG*alphaG;\nreturn 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot));\n#endif\n}\nfloat smithVisibility_TrowbridgeReitzGGXFast(float NdotL,float NdotV,float alphaG)\n{\nfloat visibility=smithVisibilityG1_TrowbridgeReitzGGXFast(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGXFast(NdotV,alphaG);\n\nreturn visibility;\n}\n#endif\n#ifdef ANISOTROPIC\n\n\nfloat smithVisibility_GGXCorrelated_Anisotropic(float NdotL,float NdotV,float TdotV,float BdotV,float TdotL,float BdotL,const vec2 alphaTB) {\nfloat lambdaV=NdotL*length(vec3(alphaTB.x*TdotV,alphaTB.y*BdotV,NdotV));\nfloat lambdaL=NdotV*length(vec3(alphaTB.x*TdotL,alphaTB.y*BdotL,NdotL));\nfloat v=0.5/(lambdaV+lambdaL);\nreturn v;\n}\n#endif\n#ifdef CLEARCOAT\nfloat visibility_Kelemen(float VdotH) {\n\n\n\nreturn 0.25/(VdotH*VdotH);\n}\n#endif\n#ifdef SHEEN\n\n\n\nfloat visibility_Ashikhmin(float NdotL,float NdotV)\n{\nreturn 1./(4.*(NdotL+NdotV-NdotL*NdotV));\n}\n#endif\n\n\n\n\n\n\n\nfloat diffuseBRDF_Burley(float NdotL,float NdotV,float VdotH,float roughness) {\n\n\nfloat diffuseFresnelNV=pow5(saturateEps(1.0-NdotL));\nfloat diffuseFresnelNL=pow5(saturateEps(1.0-NdotV));\nfloat diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;\nfloat fresnel =\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);\nreturn fresnel/PI;\n}\n";
  128694. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128695. /** @hidden */
  128696. var pbrBRDFFunctions = { name: name, shader: shader };
  128697. /***/ }),
  128698. /***/ "./Shaders/ShadersInclude/pbrDebug.ts":
  128699. /*!********************************************!*\
  128700. !*** ./Shaders/ShadersInclude/pbrDebug.ts ***!
  128701. \********************************************/
  128702. /*! exports provided: pbrDebug */
  128703. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128704. "use strict";
  128705. __webpack_require__.r(__webpack_exports__);
  128706. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDebug", function() { return pbrDebug; });
  128707. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128708. var name = 'pbrDebug';
  128709. var shader = "#if DEBUGMODE>0\nif (vClipSpacePosition.x/vClipSpacePosition.w<vDebugMode.x) {\nreturn;\n}\n\n#if DEBUGMODE == 1\ngl_FragColor.rgb=vPositionW.rgb;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 2 && defined(NORMAL)\ngl_FragColor.rgb=vNormalW.rgb;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 3 && (defined(BUMP) || defined(PARALLAX) || defined(ANISOTROPIC))\n\ngl_FragColor.rgb=TBN[0];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 4 && (defined(BUMP) || defined(PARALLAX) || defined(ANISOTROPIC))\n\ngl_FragColor.rgb=TBN[1];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 5\n\ngl_FragColor.rgb=normalW;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 6 && defined(MAINUV1)\ngl_FragColor.rgb=vec3(vMainUV1,0.0);\n#elif DEBUGMODE == 7 && defined(MAINUV2)\ngl_FragColor.rgb=vec3(vMainUV2,0.0);\n#elif DEBUGMODE == 8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)\n\ngl_FragColor.rgb=TBNClearCoat[0];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)\n\ngl_FragColor.rgb=TBNClearCoat[1];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 10 && defined(CLEARCOAT)\n\ngl_FragColor.rgb=clearCoatNormalW;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 11 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicNormal;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 12 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicTangent;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 13 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicBitangent;\n#define DEBUGMODE_NORMALIZE\n\n#elif DEBUGMODE == 20 && defined(ALBEDO)\ngl_FragColor.rgb=albedoTexture.rgb;\n#elif DEBUGMODE == 21 && defined(AMBIENT)\ngl_FragColor.rgb=ambientOcclusionColorMap.rgb;\n#elif DEBUGMODE == 22 && defined(OPACITY)\ngl_FragColor.rgb=opacityMap.rgb;\n#elif DEBUGMODE == 23 && defined(EMISSIVE)\ngl_FragColor.rgb=emissiveColorTex.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 24 && defined(LIGHTMAP)\ngl_FragColor.rgb=lightmapColor.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW)\ngl_FragColor.rgb=surfaceMetallicColorMap.rgb;\n#elif DEBUGMODE == 26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW)\ngl_FragColor.rgb=surfaceReflectivityColorMap.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE)\ngl_FragColor.rgb=clearCoatMapData.rgb;\n#elif DEBUGMODE == 28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)\ngl_FragColor.rgb=clearCoatTintMapData.rgb;\n#elif DEBUGMODE == 29 && defined(SHEEN) && defined(SHEEN_TEXTURE)\ngl_FragColor.rgb=sheenMapData.rgb;\n#elif DEBUGMODE == 30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE)\ngl_FragColor.rgb=anisotropyMapData.rgb;\n\n#elif DEBUGMODE == 40 && defined(REFRACTION)\n\ngl_FragColor.rgb=environmentRefraction.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 41 && defined(REFLECTION)\ngl_FragColor.rgb=environmentRadiance.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 42 && defined(CLEARCOAT) && defined(REFLECTION)\ngl_FragColor.rgb=environmentClearCoatRadiance;\n#define DEBUGMODE_GAMMA\n\n#elif DEBUGMODE == 50\ngl_FragColor.rgb=diffuseBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 51 && defined(SPECULARTERM)\ngl_FragColor.rgb=specularBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 52 && defined(CLEARCOAT)\ngl_FragColor.rgb=clearCoatBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 53 && defined(SHEEN)\ngl_FragColor.rgb=sheenBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 54 && defined(REFLECTION)\ngl_FragColor.rgb=environmentIrradiance.rgb;\n#define DEBUGMODE_GAMMA\n\n#elif DEBUGMODE == 60\ngl_FragColor.rgb=surfaceAlbedo.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 61\ngl_FragColor.rgb=specularEnvironmentR0;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 62\ngl_FragColor.rgb=vec3(roughness);\n#elif DEBUGMODE == 63\ngl_FragColor.rgb=vec3(alphaG);\n#elif DEBUGMODE == 64\ngl_FragColor.rgb=vec3(NdotV);\n#elif DEBUGMODE == 65 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT)\ngl_FragColor.rgb=clearCoatColor.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 66 && defined(CLEARCOAT)\ngl_FragColor.rgb=vec3(clearCoatRoughness);\n#elif DEBUGMODE == 67 && defined(CLEARCOAT)\ngl_FragColor.rgb=vec3(clearCoatNdotV);\n\n#elif DEBUGMODE == 70 && defined(RADIANCEOCCLUSION)\ngl_FragColor.rgb=vec3(seo);\n#elif DEBUGMODE == 71 && defined(HORIZONOCCLUSION)\ngl_FragColor.rgb=vec3(eho);\n#elif DEBUGMODE == 72 && defined(MS_BRDF_ENERGY_CONSERVATION)\ngl_FragColor.rgb=vec3(energyConservationFactor);\n#elif DEBUGMODE == 73 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\ngl_FragColor.rgb=specularEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 74 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\ngl_FragColor.rgb=clearCoatEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 75 && defined(SHEEN) && defined(REFLECTION)\ngl_FragColor.rgb=sheenEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 76 && defined(ALPHABLEND)\ngl_FragColor.rgb=vec3(luminanceOverAlpha);\n#elif DEBUGMODE == 77\ngl_FragColor.rgb=vec3(alpha);\n#endif\ngl_FragColor.rgb*=vDebugMode.y;\n#ifdef DEBUGMODE_NORMALIZE\ngl_FragColor.rgb=normalize(gl_FragColor.rgb)*0.5+0.5;\n#endif\n#ifdef DEBUGMODE_GAMMA\ngl_FragColor.rgb=toGammaSpace(gl_FragColor.rgb);\n#endif\ngl_FragColor.a=1.0;\n#endif";
  128710. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128711. /** @hidden */
  128712. var pbrDebug = { name: name, shader: shader };
  128713. /***/ }),
  128714. /***/ "./Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.ts":
  128715. /*!*********************************************************************!*\
  128716. !*** ./Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.ts ***!
  128717. \*********************************************************************/
  128718. /*! exports provided: pbrDirectLightingFalloffFunctions */
  128719. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128720. "use strict";
  128721. __webpack_require__.r(__webpack_exports__);
  128722. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDirectLightingFalloffFunctions", function() { return pbrDirectLightingFalloffFunctions; });
  128723. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128724. var name = 'pbrDirectLightingFalloffFunctions';
  128725. var shader = "float computeDistanceLightFalloff_Standard(vec3 lightOffset,float range)\n{\nreturn max(0.,1.0-length(lightOffset)/range);\n}\nfloat computeDistanceLightFalloff_Physical(float lightDistanceSquared)\n{\nreturn 1.0/maxEps(lightDistanceSquared);\n}\nfloat computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)\n{\nfloat lightDistanceFalloff=1.0/maxEps(lightDistanceSquared);\nfloat factor=lightDistanceSquared*inverseSquaredRange;\nfloat attenuation=saturate(1.0-factor*factor);\nattenuation*=attenuation;\n\nlightDistanceFalloff*=attenuation;\nreturn lightDistanceFalloff;\n}\nfloat computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDistanceLightFalloff_Physical(lightDistanceSquared);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);\n#else\nreturn computeDistanceLightFalloff_Standard(lightOffset,range);\n#endif\n}\nfloat computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent)\n{\nfloat falloff=0.0;\nfloat cosAngle=maxEps(dot(-lightDirection,directionToLightCenterW));\nif (cosAngle>=cosHalfAngle)\n{\nfalloff=max(0.,pow(cosAngle,exponent));\n}\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle)\n{\nconst float kMinusLog2ConeAngleIntensityRatio=6.64385618977;\n\n\n\n\n\nfloat concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);\n\n\nvec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);\nfloat falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset)\n{\n\n\n\nfloat cd=dot(-lightDirection,directionToLightCenterW);\nfloat falloff=saturate(cd*lightAngleScale+lightAngleOffset);\n\nfalloff*=falloff;\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);\n#else\nreturn computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);\n#endif\n}";
  128726. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128727. /** @hidden */
  128728. var pbrDirectLightingFalloffFunctions = { name: name, shader: shader };
  128729. /***/ }),
  128730. /***/ "./Shaders/ShadersInclude/pbrDirectLightingFunctions.ts":
  128731. /*!**************************************************************!*\
  128732. !*** ./Shaders/ShadersInclude/pbrDirectLightingFunctions.ts ***!
  128733. \**************************************************************/
  128734. /*! exports provided: pbrDirectLightingFunctions */
  128735. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128736. "use strict";
  128737. __webpack_require__.r(__webpack_exports__);
  128738. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDirectLightingFunctions", function() { return pbrDirectLightingFunctions; });
  128739. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128740. var name = 'pbrDirectLightingFunctions';
  128741. var shader = "#define CLEARCOATREFLECTANCE90 1.0\n\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef CLEARCOAT\n\n\nvec4 clearCoat;\n#endif\n#ifdef SHEEN\nvec3 sheen;\n#endif\n};\n\nfloat adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance) {\n#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)\n\nfloat lightRoughness=lightRadius/lightDistance;\n\nfloat totalRoughness=saturate(lightRoughness+roughness);\nreturn totalRoughness;\n#else\nreturn roughness;\n#endif\n}\nvec3 computeHemisphericDiffuseLighting(preLightingInfo info,vec3 lightColor,vec3 groundColor) {\nreturn mix(groundColor,lightColor,info.NdotL);\n}\nvec3 computeDiffuseLighting(preLightingInfo info,vec3 lightColor) {\nfloat diffuseTerm=diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness);\nreturn diffuseTerm*info.attenuation*info.NdotL*lightColor;\n}\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\nstrq/=strq.w;\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\nreturn toLinearSpace(textureColor);\n}\n#ifdef SPECULARTERM\nvec3 computeSpecularLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat roughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nvec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);\n#ifdef BRDF_V_HEIGHT_CORRELATED\nfloat visibility=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG);\n#else\nfloat visibility=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG);\n#endif\nvec3 specTerm=fresnel*distribution*visibility;\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n#ifdef ANISOTROPIC\nvec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat TdotH=dot(T,info.H);\nfloat BdotH=dot(B,info.H);\nfloat TdotV=dot(T,V);\nfloat BdotV=dot(B,V);\nfloat TdotL=dot(T,info.L);\nfloat BdotL=dot(B,info.L);\nfloat alphaG=convertRoughnessToAverageSlope(info.roughness);\nvec2 alphaTB=getAnisotropicRoughness(alphaG,anisotropy);\nalphaTB=max(alphaTB,square(geometricRoughnessFactor));\nvec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);\nfloat distribution=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);\nfloat visibility=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);\nvec3 specTerm=fresnel*distribution*visibility;\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n#ifdef CLEARCOAT\nvec4 computeClearCoatLighting(preLightingInfo info,vec3 Ncc,float geometricRoughnessFactor,float clearCoatIntensity,vec3 lightColor) {\nfloat NccdotL=saturateEps(dot(Ncc,info.L));\nfloat NccdotH=saturateEps(dot(Ncc,info.H));\nfloat clearCoatRoughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(clearCoatRoughness);\nfloat fresnel=fresnelSchlickGGX(info.VdotH,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);\nfresnel*=clearCoatIntensity;\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NccdotH,alphaG);\nfloat visibility=visibility_Kelemen(info.VdotH);\nfloat clearCoatTerm=fresnel*distribution*visibility;\nreturn vec4(\nclearCoatTerm*info.attenuation*NccdotL*lightColor,\n1.0-fresnel\n);\n}\nvec3 computeClearCoatLightingAbsorption(float NdotVRefract,vec3 L,vec3 Ncc,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\nvec3 LRefract=-refract(L,Ncc,vClearCoatRefractionParams.y);\nfloat NdotLRefract=saturateEps(dot(Ncc,LRefract));\nvec3 absorption=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);\nreturn absorption;\n}\n#endif\n#ifdef SHEEN\nvec3 computeSheenLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat roughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\n\n\nvec3 fresnel=reflectance0;\nfloat distribution=normalDistributionFunction_CharlieSheen(NdotH,alphaG);\nfloat visibility=visibility_Ashikhmin(info.NdotL,info.NdotV);\nvec3 sheenTerm=fresnel*distribution*visibility;\nreturn sheenTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n";
  128742. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128743. /** @hidden */
  128744. var pbrDirectLightingFunctions = { name: name, shader: shader };
  128745. /***/ }),
  128746. /***/ "./Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.ts":
  128747. /*!*******************************************************************!*\
  128748. !*** ./Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.ts ***!
  128749. \*******************************************************************/
  128750. /*! exports provided: pbrDirectLightingSetupFunctions */
  128751. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128752. "use strict";
  128753. __webpack_require__.r(__webpack_exports__);
  128754. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDirectLightingSetupFunctions", function() { return pbrDirectLightingSetupFunctions; });
  128755. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128756. var name = 'pbrDirectLightingSetupFunctions';
  128757. var shader = "\nstruct preLightingInfo\n{\n\nvec3 lightOffset;\nfloat lightDistanceSquared;\nfloat lightDistance;\n\nfloat attenuation;\n\nvec3 L;\nvec3 H;\nfloat NdotV;\nfloat NdotL;\nfloat VdotH;\nfloat roughness;\n};\npreLightingInfo computePointAndSpotPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\n\nresult.lightDistance=sqrt(result.lightDistanceSquared);\n\nresult.L=normalize(result.lightOffset);\nresult.H=normalize(V+result.L);\nresult.NdotL=saturateEps(dot(N,result.L));\nresult.VdotH=saturate(dot(V,result.H));\nreturn result;\n}\npreLightingInfo computeDirectionalPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\nresult.lightDistance=length(-lightData.xyz);\n\nresult.L=normalize(-lightData.xyz);\nresult.H=normalize(V+result.L);\nresult.NdotL=saturateEps(dot(N,result.L));\nresult.VdotH=saturate(dot(V,result.H));\nreturn result;\n}\npreLightingInfo computeHemisphericPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\nresult.NdotL=dot(N,lightData.xyz)*0.5+0.5;\nresult.NdotL=saturateEps(result.NdotL);\n#ifdef SPECULARTERM\nresult.L=normalize(lightData.xyz);\nresult.H=normalize(V+result.L);\nresult.VdotH=saturate(dot(V,result.H));\n#endif\nreturn result;\n}";
  128758. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128759. /** @hidden */
  128760. var pbrDirectLightingSetupFunctions = { name: name, shader: shader };
  128761. /***/ }),
  128762. /***/ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts":
  128763. /*!**********************************************************!*\
  128764. !*** ./Shaders/ShadersInclude/pbrFragmentDeclaration.ts ***!
  128765. \**********************************************************/
  128766. /*! exports provided: pbrFragmentDeclaration */
  128767. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128768. "use strict";
  128769. __webpack_require__.r(__webpack_exports__);
  128770. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentDeclaration", function() { return pbrFragmentDeclaration; });
  128771. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128772. var name = 'pbrFragmentDeclaration';
  128773. var shader = "uniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\n\nuniform vec4 vLightingIntensity;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float visibility;\n\n#ifdef ALBEDO\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#ifdef OPACITY\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\n#endif\n\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(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";
  128774. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128775. /** @hidden */
  128776. var pbrFragmentDeclaration = { name: name, shader: shader };
  128777. /***/ }),
  128778. /***/ "./Shaders/ShadersInclude/pbrFragmentExtraDeclaration.ts":
  128779. /*!***************************************************************!*\
  128780. !*** ./Shaders/ShadersInclude/pbrFragmentExtraDeclaration.ts ***!
  128781. \***************************************************************/
  128782. /*! exports provided: pbrFragmentExtraDeclaration */
  128783. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128784. "use strict";
  128785. __webpack_require__.r(__webpack_exports__);
  128786. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentExtraDeclaration", function() { return pbrFragmentExtraDeclaration; });
  128787. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128788. var name = 'pbrFragmentExtraDeclaration';
  128789. var shader = "uniform vec4 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vCameraInfos;\n\nvarying vec3 vPositionW;\n#if DEBUGMODE>0\nuniform vec2 vDebugMode;\nvarying vec4 vClipSpacePosition;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif";
  128790. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128791. /** @hidden */
  128792. var pbrFragmentExtraDeclaration = { name: name, shader: shader };
  128793. /***/ }),
  128794. /***/ "./Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.ts":
  128795. /*!******************************************************************!*\
  128796. !*** ./Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.ts ***!
  128797. \******************************************************************/
  128798. /*! exports provided: pbrFragmentSamplersDeclaration */
  128799. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128800. "use strict";
  128801. __webpack_require__.r(__webpack_exports__);
  128802. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentSamplersDeclaration", function() { return pbrFragmentSamplersDeclaration; });
  128803. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128804. var name = 'pbrFragmentSamplersDeclaration';
  128805. var shader = "#ifdef ALBEDO\n#if ALBEDODIRECTUV == 1\n#define vAlbedoUV vMainUV1\n#elif ALBEDODIRECTUV == 2\n#define vAlbedoUV vMainUV2\n#else\nvarying vec2 vAlbedoUV;\n#endif\nuniform sampler2D albedoSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFLECTIVITY\n#if REFLECTIVITYDIRECTUV == 1\n#define vReflectivityUV vMainUV1\n#elif REFLECTIVITYDIRECTUV == 2\n#define vReflectivityUV vMainUV2\n#else\nvarying vec2 vReflectivityUV;\n#endif\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef MICROSURFACEMAP\n#if MICROSURFACEMAPDIRECTUV == 1\n#define vMicroSurfaceSamplerUV vMainUV1\n#elif MICROSURFACEMAPDIRECTUV == 2\n#define vMicroSurfaceSamplerUV vMainUV2\n#else\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\nuniform sampler2D microSurfaceSampler;\n#endif\n#ifdef CLEARCOAT\n#ifdef CLEARCOAT_TEXTURE\n#if CLEARCOAT_TEXTUREDIRECTUV == 1\n#define vClearCoatUV vMainUV1\n#elif CLEARCOAT_TEXTUREDIRECTUV == 2\n#define vClearCoatUV vMainUV2\n#else\nvarying vec2 vClearCoatUV;\n#endif\nuniform sampler2D clearCoatSampler;\n#endif\n#ifdef CLEARCOAT_BUMP\n#if CLEARCOAT_BUMPDIRECTUV == 1\n#define vClearCoatBumpUV vMainUV1\n#elif CLEARCOAT_BUMPDIRECTUV == 2\n#define vClearCoatBumpUV vMainUV2\n#else\nvarying vec2 vClearCoatBumpUV;\n#endif\nuniform sampler2D clearCoatBumpSampler;\n#endif\n#ifdef CLEARCOAT_TINT_TEXTURE\n#if CLEARCOAT_TINT_TEXTUREDIRECTUV == 1\n#define vClearCoatTintUV vMainUV1\n#elif CLEARCOAT_TINT_TEXTUREDIRECTUV == 2\n#define vClearCoatTintUV vMainUV2\n#else\nvarying vec2 vClearCoatTintUV;\n#endif\nuniform sampler2D clearCoatTintSampler;\n#endif\n#endif\n#ifdef SHEEN\n#ifdef SHEEN_TEXTURE\n#if SHEEN_TEXTUREDIRECTUV == 1\n#define vSheenUV vMainUV1\n#elif SHEEN_TEXTUREDIRECTUV == 2\n#define vSheenUV vMainUV2\n#else\nvarying vec2 vSheenUV;\n#endif\nuniform sampler2D sheenSampler;\n#endif\n#endif\n#ifdef ANISOTROPIC\n#ifdef ANISOTROPIC_TEXTURE\n#if ANISOTROPIC_TEXTUREDIRECTUV == 1\n#define vAnisotropyUV vMainUV1\n#elif ANISOTROPIC_TEXTUREDIRECTUV == 2\n#define vAnisotropyUV vMainUV2\n#else\nvarying vec2 vAnisotropyUV;\n#endif\nuniform sampler2D anisotropySampler;\n#endif\n#endif\n\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\n#define sampleRefraction(s,c) textureCube(s,c)\nuniform samplerCube refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#else\n#define sampleRefraction(s,c) texture2D(s,c)\nuniform sampler2D refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#endif\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#endif\n#ifdef ENVIRONMENTBRDF\nuniform sampler2D environmentBrdfSampler;\n#endif";
  128806. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128807. /** @hidden */
  128808. var pbrFragmentSamplersDeclaration = { name: name, shader: shader };
  128809. /***/ }),
  128810. /***/ "./Shaders/ShadersInclude/pbrHelperFunctions.ts":
  128811. /*!******************************************************!*\
  128812. !*** ./Shaders/ShadersInclude/pbrHelperFunctions.ts ***!
  128813. \******************************************************/
  128814. /*! exports provided: pbrHelperFunctions */
  128815. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128816. "use strict";
  128817. __webpack_require__.r(__webpack_exports__);
  128818. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrHelperFunctions", function() { return pbrHelperFunctions; });
  128819. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128820. var name = 'pbrHelperFunctions';
  128821. var shader = "\n#define RECIPROCAL_PI2 0.15915494\n#define RECIPROCAL_PI 0.31830988618\n\n#define MINIMUMVARIANCE 0.0005\nfloat convertRoughnessToAverageSlope(float roughness)\n{\n\nreturn square(roughness)+MINIMUMVARIANCE;\n}\nfloat fresnelGrazingReflectance(float reflectance0) {\n\n\nfloat reflectance90=saturate(reflectance0*25.0);\nreturn reflectance90;\n}\nvec2 getAARoughnessFactors(vec3 normalVector) {\n#ifdef SPECULARAA\nvec3 nDfdx=dFdx(normalVector.xyz);\nvec3 nDfdy=dFdy(normalVector.xyz);\nfloat slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));\n\nfloat geometricRoughnessFactor=pow(saturate(slopeSquare),0.333);\n\nfloat geometricAlphaGFactor=sqrt(slopeSquare);\n\ngeometricAlphaGFactor*=0.75;\nreturn vec2(geometricRoughnessFactor,geometricAlphaGFactor);\n#else\nreturn vec2(0.);\n#endif\n}\n#ifdef ANISOTROPIC\n\n\nvec2 getAnisotropicRoughness(float alphaG,float anisotropy) {\nfloat alphaT=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);\nfloat alphaB=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);\nreturn vec2(alphaT,alphaB);\n}\n\n\nvec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy) {\nvec3 anisotropicFrameDirection=anisotropy>=0.0 ? B : T;\nvec3 anisotropicFrameTangent=cross(normalize(anisotropicFrameDirection),V);\nvec3 anisotropicFrameNormal=cross(anisotropicFrameTangent,anisotropicFrameDirection);\nvec3 anisotropicNormal=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));\nreturn anisotropicNormal;\n\n}\n#endif\n#ifdef CLEARCOAT\n\n\n\n\nvec3 cocaLambert(float NdotVRefract,float NdotLRefract,vec3 alpha,float thickness) {\nreturn exp(alpha*-(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));\n}\n\nvec3 computeColorAtDistanceInMedia(vec3 color,float distance) {\nreturn -log(color)/distance;\n}\nvec3 computeClearCoatAbsorption(float NdotVRefract,float NdotLRefract,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\nvec3 clearCoatAbsorption=mix(vec3(1.0),\ncocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness),\nclearCoatIntensity);\nreturn clearCoatAbsorption;\n}\n#endif\n\n\n\n\n#ifdef MICROSURFACEAUTOMATIC\nfloat computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)\n{\nconst float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;\nfloat reflectivityLuminance=getLuminance(reflectivityColor);\nfloat reflectivityLuma=sqrt(reflectivityLuminance);\nmicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;\nreturn microSurface;\n}\n#endif";
  128822. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128823. /** @hidden */
  128824. var pbrHelperFunctions = { name: name, shader: shader };
  128825. /***/ }),
  128826. /***/ "./Shaders/ShadersInclude/pbrIBLFunctions.ts":
  128827. /*!***************************************************!*\
  128828. !*** ./Shaders/ShadersInclude/pbrIBLFunctions.ts ***!
  128829. \***************************************************/
  128830. /*! exports provided: pbrIBLFunctions */
  128831. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128832. "use strict";
  128833. __webpack_require__.r(__webpack_exports__);
  128834. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrIBLFunctions", function() { return pbrIBLFunctions; });
  128835. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128836. var name = 'pbrIBLFunctions';
  128837. var shader = "#if defined(REFLECTION) || defined(REFRACTION)\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float microsurfaceAverageSlope) {\nfloat microsurfaceAverageSlopeTexels=microsurfaceAverageSlope*cubeMapDimensionPixels;\nfloat lod=log2(microsurfaceAverageSlopeTexels);\nreturn lod;\n}\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION)\nfloat environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {\n\n\nfloat temp=NdotVUnclamped+ambientOcclusion;\nreturn saturate(square(temp)-1.0+ambientOcclusion);\n}\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION)\nfloat environmentHorizonOcclusion(vec3 view,vec3 normal) {\n\nvec3 reflection=reflect(view,normal);\nfloat temp=saturate(1.0+1.1*dot(reflection,normal));\nreturn square(temp);\n}\n#endif\n\n\n\n\n#if defined(LODINREFLECTIONALPHA) || defined(LODINREFRACTIONALPHA)\n\n\n#define UNPACK_LOD(x) (1.0-x)*255.0\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {\nfloat microsurfaceAverageSlope=alphaG;\n\n\n\n\n\n\nmicrosurfaceAverageSlope*=sqrt(abs(NdotV));\nreturn getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);\n}\n#endif";
  128838. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128839. /** @hidden */
  128840. var pbrIBLFunctions = { name: name, shader: shader };
  128841. /***/ }),
  128842. /***/ "./Shaders/ShadersInclude/pbrUboDeclaration.ts":
  128843. /*!*****************************************************!*\
  128844. !*** ./Shaders/ShadersInclude/pbrUboDeclaration.ts ***!
  128845. \*****************************************************/
  128846. /*! exports provided: pbrUboDeclaration */
  128847. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128848. "use strict";
  128849. __webpack_require__.r(__webpack_exports__);
  128850. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrUboDeclaration", function() { return pbrUboDeclaration; });
  128851. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128852. var name = 'pbrUboDeclaration';
  128853. 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 float pointSize;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float visibility;\nuniform vec2 vClearCoatParams;\nuniform vec4 vClearCoatRefractionParams;\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\nuniform vec2 vClearCoatBumpInfos;\nuniform vec2 vClearCoatTangentSpaceParams;\nuniform mat4 clearCoatBumpMatrix;\nuniform vec4 vClearCoatTintParams;\nuniform float clearCoatColorAtDistance;\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\nuniform vec3 vAnisotropy;\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\nuniform vec4 vSheenColor;\nuniform vec2 vSheenInfos;\nuniform mat4 sheenMatrix;\n};\nuniform Scene {\nmat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif\nmat4 view;\n};";
  128854. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128855. /** @hidden */
  128856. var pbrUboDeclaration = { name: name, shader: shader };
  128857. /***/ }),
  128858. /***/ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts":
  128859. /*!********************************************************!*\
  128860. !*** ./Shaders/ShadersInclude/pbrVertexDeclaration.ts ***!
  128861. \********************************************************/
  128862. /*! exports provided: pbrVertexDeclaration */
  128863. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128864. "use strict";
  128865. __webpack_require__.r(__webpack_exports__);
  128866. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexDeclaration", function() { return pbrVertexDeclaration; });
  128867. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128868. var name = 'pbrVertexDeclaration';
  128869. 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";
  128870. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128871. /** @hidden */
  128872. var pbrVertexDeclaration = { name: name, shader: shader };
  128873. /***/ }),
  128874. /***/ "./Shaders/ShadersInclude/pointCloudVertex.ts":
  128875. /*!****************************************************!*\
  128876. !*** ./Shaders/ShadersInclude/pointCloudVertex.ts ***!
  128877. \****************************************************/
  128878. /*! exports provided: pointCloudVertex */
  128879. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128880. "use strict";
  128881. __webpack_require__.r(__webpack_exports__);
  128882. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pointCloudVertex", function() { return pointCloudVertex; });
  128883. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128884. var name = 'pointCloudVertex';
  128885. var shader = "#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif";
  128886. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128887. /** @hidden */
  128888. var pointCloudVertex = { name: name, shader: shader };
  128889. /***/ }),
  128890. /***/ "./Shaders/ShadersInclude/reflectionFunction.ts":
  128891. /*!******************************************************!*\
  128892. !*** ./Shaders/ShadersInclude/reflectionFunction.ts ***!
  128893. \******************************************************/
  128894. /*! exports provided: reflectionFunction */
  128895. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128896. "use strict";
  128897. __webpack_require__.r(__webpack_exports__);
  128898. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "reflectionFunction", function() { return reflectionFunction; });
  128899. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128900. var name = 'reflectionFunction';
  128901. 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}";
  128902. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128903. /** @hidden */
  128904. var reflectionFunction = { name: name, shader: shader };
  128905. /***/ }),
  128906. /***/ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts":
  128907. /*!************************************************************!*\
  128908. !*** ./Shaders/ShadersInclude/shadowsFragmentFunctions.ts ***!
  128909. \************************************************************/
  128910. /*! exports provided: shadowsFragmentFunctions */
  128911. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128912. "use strict";
  128913. __webpack_require__.r(__webpack_exports__);
  128914. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsFragmentFunctions", function() { return shadowsFragmentFunctions; });
  128915. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128916. var name = 'shadowsFragmentFunctions';
  128917. var shader = "#ifdef SHADOWS\n#ifndef SHADOWFLOAT\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}\n#endif\nfloat computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)\n{\nfloat mask=smoothstep(1.0-frustumEdgeFalloff,1.0,clamp(dot(clipSpace,clipSpace),0.,1.));\nreturn mix(value,1.0,mask);\n}\nfloat computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x;\n#endif\nif (depth>shadow)\n{\nreturn darkness;\n}\nreturn 1.0;\n}\nfloat computeShadowWithPoissonSamplingCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\nfloat visibility=1.;\nvec3 poissonDisk[4];\npoissonDisk[0]=vec3(-1.0,1.0,-1.0);\npoissonDisk[1]=vec3(1.0,-1.0,-1.0);\npoissonDisk[2]=vec3(-1.0,-1.0,-1.0);\npoissonDisk[3]=vec3(1.0,-1.0,1.0);\n\n#ifndef SHADOWFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) visibility-=0.25;\n#else\nif (textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) visibility-=0.25;\n#endif\nreturn min(1.0,visibility+darkness);\n}\nfloat computeShadowWithESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn esm;\n}\nfloat computeShadowWithCloseESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn esm;\n}\nfloat computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadow=texture2D(shadowSampler,uv).x;\n#endif\nif (shadowPixelDepth>shadow)\n{\nreturn computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff);\n}\nreturn 1.;\n}\nfloat computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\nfloat visibility=1.;\nvec2 poissonDisk[4];\npoissonDisk[0]=vec2(-0.94201624,-0.39906216);\npoissonDisk[1]=vec2(0.94558609,-0.76890725);\npoissonDisk[2]=vec2(-0.094184101,-0.92938870);\npoissonDisk[3]=vec2(0.34495938,0.29387760);\n\n#ifndef SHADOWFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[1]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[2]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[3]*mapSize))<shadowPixelDepth) visibility-=0.25;\n#else\nif (texture2D(shadowSampler,uv+poissonDisk[0]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[1]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[2]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[3]*mapSize).x<shadowPixelDepth) visibility-=0.25;\n#endif\nreturn computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\n#ifdef WEBGL2\n\nfloat computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nfloat shadow=texture2D(shadowSampler,uvDepth);\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\nfloat computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\n\n\nvec2 uvw0=3.-2.*st;\nvec2 uvw1=1.+2.*st;\nvec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;\nvec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow=shadow/16.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\nfloat computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\nvec2 uvw0=4.-3.*st;\nvec2 uvw1=vec2(7.);\nvec2 uvw2=1.+3.*st;\nvec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;\nvec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z));\nshadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z));\nshadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z));\nshadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z));\nshadow=shadow/144.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\nconst vec3 PoissonSamplers32[64]=vec3[64](\nvec3(0.06407013,0.05409927,0.),\nvec3(0.7366577,0.5789394,0.),\nvec3(-0.6270542,-0.5320278,0.),\nvec3(-0.4096107,0.8411095,0.),\nvec3(0.6849564,-0.4990818,0.),\nvec3(-0.874181,-0.04579735,0.),\nvec3(0.9989998,0.0009880066,0.),\nvec3(-0.004920578,-0.9151649,0.),\nvec3(0.1805763,0.9747483,0.),\nvec3(-0.2138451,0.2635818,0.),\nvec3(0.109845,0.3884785,0.),\nvec3(0.06876755,-0.3581074,0.),\nvec3(0.374073,-0.7661266,0.),\nvec3(0.3079132,-0.1216763,0.),\nvec3(-0.3794335,-0.8271583,0.),\nvec3(-0.203878,-0.07715034,0.),\nvec3(0.5912697,0.1469799,0.),\nvec3(-0.88069,0.3031784,0.),\nvec3(0.5040108,0.8283722,0.),\nvec3(-0.5844124,0.5494877,0.),\nvec3(0.6017799,-0.1726654,0.),\nvec3(-0.5554981,0.1559997,0.),\nvec3(-0.3016369,-0.3900928,0.),\nvec3(-0.5550632,-0.1723762,0.),\nvec3(0.925029,0.2995041,0.),\nvec3(-0.2473137,0.5538505,0.),\nvec3(0.9183037,-0.2862392,0.),\nvec3(0.2469421,0.6718712,0.),\nvec3(0.3916397,-0.4328209,0.),\nvec3(-0.03576927,-0.6220032,0.),\nvec3(-0.04661255,0.7995201,0.),\nvec3(0.4402924,0.3640312,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.)\n);\nconst vec3 PoissonSamplers64[64]=vec3[64](\nvec3(-0.613392,0.617481,0.),\nvec3(0.170019,-0.040254,0.),\nvec3(-0.299417,0.791925,0.),\nvec3(0.645680,0.493210,0.),\nvec3(-0.651784,0.717887,0.),\nvec3(0.421003,0.027070,0.),\nvec3(-0.817194,-0.271096,0.),\nvec3(-0.705374,-0.668203,0.),\nvec3(0.977050,-0.108615,0.),\nvec3(0.063326,0.142369,0.),\nvec3(0.203528,0.214331,0.),\nvec3(-0.667531,0.326090,0.),\nvec3(-0.098422,-0.295755,0.),\nvec3(-0.885922,0.215369,0.),\nvec3(0.566637,0.605213,0.),\nvec3(0.039766,-0.396100,0.),\nvec3(0.751946,0.453352,0.),\nvec3(0.078707,-0.715323,0.),\nvec3(-0.075838,-0.529344,0.),\nvec3(0.724479,-0.580798,0.),\nvec3(0.222999,-0.215125,0.),\nvec3(-0.467574,-0.405438,0.),\nvec3(-0.248268,-0.814753,0.),\nvec3(0.354411,-0.887570,0.),\nvec3(0.175817,0.382366,0.),\nvec3(0.487472,-0.063082,0.),\nvec3(-0.084078,0.898312,0.),\nvec3(0.488876,-0.783441,0.),\nvec3(0.470016,0.217933,0.),\nvec3(-0.696890,-0.549791,0.),\nvec3(-0.149693,0.605762,0.),\nvec3(0.034211,0.979980,0.),\nvec3(0.503098,-0.308878,0.),\nvec3(-0.016205,-0.872921,0.),\nvec3(0.385784,-0.393902,0.),\nvec3(-0.146886,-0.859249,0.),\nvec3(0.643361,0.164098,0.),\nvec3(0.634388,-0.049471,0.),\nvec3(-0.688894,0.007843,0.),\nvec3(0.464034,-0.188818,0.),\nvec3(-0.440840,0.137486,0.),\nvec3(0.364483,0.511704,0.),\nvec3(0.034028,0.325968,0.),\nvec3(0.099094,-0.308023,0.),\nvec3(0.693960,-0.366253,0.),\nvec3(0.678884,-0.204688,0.),\nvec3(0.001801,0.780328,0.),\nvec3(0.145177,-0.898984,0.),\nvec3(0.062655,-0.611866,0.),\nvec3(0.315226,-0.604297,0.),\nvec3(-0.780145,0.486251,0.),\nvec3(-0.371868,0.882138,0.),\nvec3(0.200476,0.494430,0.),\nvec3(-0.494552,-0.711051,0.),\nvec3(0.612476,0.705252,0.),\nvec3(-0.578845,-0.768792,0.),\nvec3(-0.772454,-0.090976,0.),\nvec3(0.504440,0.372295,0.),\nvec3(0.155736,0.065157,0.),\nvec3(0.391522,0.849605,0.),\nvec3(-0.620106,-0.328104,0.),\nvec3(0.789239,-0.419965,0.),\nvec3(-0.545396,0.538133,0.),\nvec3(-0.178564,-0.596057,0.)\n);\n\n\n\n\n\nfloat computeShadowWithPCSS(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nfloat blockerDepth=0.0;\nfloat sumBlockerDepth=0.0;\nfloat numBlocker=0.0;\nfor (int i=0; i<searchTapCount; i ++) {\nblockerDepth=texture(depthSampler,uvDepth.xy+(lightSizeUV*shadowMapSizeInverse*PoissonSamplers32[i].xy)).r;\nif (blockerDepth<depthMetric) {\nsumBlockerDepth+=blockerDepth;\nnumBlocker++;\n}\n}\nif (numBlocker<1.0) {\nreturn 1.0;\n}\nfloat avgBlockerDepth=sumBlockerDepth/numBlocker;\n\nfloat AAOffset=shadowMapSizeInverse*10.;\n\n\nfloat penumbraRatio=((depthMetric-avgBlockerDepth)+AAOffset);\nfloat filterRadius=penumbraRatio*lightSizeUV*shadowMapSizeInverse;\nfloat random=getRand(vPositionFromLight.xy);\nfloat rotationAngle=random*3.1415926;\nvec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));\nfloat shadow=0.;\nfor (int i=0; i<pcfTapCount; i++) {\nvec3 offset=poissonSamplers[i];\n\noffset=vec3(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.);\nshadow+=texture2D(shadowSampler,uvDepth+offset*filterRadius);\n}\nshadow/=float(pcfTapCount);\n\nshadow=mix(shadow,1.,depthMetric-avgBlockerDepth);\n\nshadow=mix(darkness,1.,shadow);\n\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithPCSS16(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32);\n}\nfloat computeShadowWithPCSS32(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32);\n}\nfloat computeShadowWithPCSS64(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64);\n}\n#endif\n#endif\n";
  128918. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128919. /** @hidden */
  128920. var shadowsFragmentFunctions = { name: name, shader: shader };
  128921. /***/ }),
  128922. /***/ "./Shaders/ShadersInclude/shadowsVertex.ts":
  128923. /*!*************************************************!*\
  128924. !*** ./Shaders/ShadersInclude/shadowsVertex.ts ***!
  128925. \*************************************************/
  128926. /*! exports provided: shadowsVertex */
  128927. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128928. "use strict";
  128929. __webpack_require__.r(__webpack_exports__);
  128930. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsVertex", function() { return shadowsVertex; });
  128931. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128932. var name = 'shadowsVertex';
  128933. 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";
  128934. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128935. /** @hidden */
  128936. var shadowsVertex = { name: name, shader: shader };
  128937. /***/ }),
  128938. /***/ "./Shaders/anaglyph.fragment.ts":
  128939. /*!**************************************!*\
  128940. !*** ./Shaders/anaglyph.fragment.ts ***!
  128941. \**************************************/
  128942. /*! exports provided: anaglyphPixelShader */
  128943. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128944. "use strict";
  128945. __webpack_require__.r(__webpack_exports__);
  128946. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "anaglyphPixelShader", function() { return anaglyphPixelShader; });
  128947. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128948. var name = 'anaglyphPixelShader';
  128949. 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}";
  128950. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128951. /** @hidden */
  128952. var anaglyphPixelShader = { name: name, shader: shader };
  128953. /***/ }),
  128954. /***/ "./Shaders/background.fragment.ts":
  128955. /*!****************************************!*\
  128956. !*** ./Shaders/background.fragment.ts ***!
  128957. \****************************************/
  128958. /*! exports provided: backgroundPixelShader */
  128959. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128960. "use strict";
  128961. __webpack_require__.r(__webpack_exports__);
  128962. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundPixelShader", function() { return backgroundPixelShader; });
  128963. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128964. /* harmony import */ var _ShadersInclude_backgroundFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundFragmentDeclaration */ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts");
  128965. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  128966. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  128967. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  128968. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  128969. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  128970. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  128971. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  128972. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  128973. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  128974. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  128975. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  128976. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  128977. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  128978. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  128979. var name = 'backgroundPixelShader';
  128980. var shader = "#ifdef TEXTURELODSUPPORT\n#extension GL_EXT_shader_texture_lod : enable\n#endif\nprecision highp float;\n#include<__decl__backgroundFragment>\n#define RECIPROCAL_PI2 0.15915494\n\nuniform vec3 vEyePosition;\n\nvarying vec3 vPositionW;\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n\n#ifndef SHADOWONLY\n#define SHADOWONLY;\n#endif\n#include<imageProcessingDeclaration>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<helperFunctions>\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<imageProcessingFunctions>\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\n#ifdef REFLECTIONFRESNEL\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\nvec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));\n}\n#endif\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(0.0,1.0,0.0);\n#endif\n\nfloat shadow=1.;\nfloat globalShadow=0.;\nfloat shadowLightCount=0.;\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef SHADOWINUSE\nglobalShadow/=shadowLightCount;\n#else\nglobalShadow=1.0;\n#endif\n\nvec4 reflectionColor=vec4(1.,1.,1.,1.);\n#ifdef REFLECTION\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#ifdef REFLECTIONBLUR\nfloat reflectionLOD=vReflectionInfos.y;\n#ifdef TEXTURELODSUPPORT\n\nreflectionLOD=reflectionLOD*log2(vReflectionMicrosurfaceInfos.x)*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nreflectionColor=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);\n#else\nfloat lodReflectionNormalized=saturate(reflectionLOD);\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 reflectionSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodReflectionNormalizedDoubled<1.0){\nreflectionColor=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nreflectionSpecularMid,\nlodReflectionNormalizedDoubled\n);\n} else {\nreflectionColor=mix(\nreflectionSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#else\nvec4 reflectionSample=sampleReflection(reflectionSampler,reflectionCoords);\nreflectionColor=reflectionSample;\n#endif\n#ifdef RGBDREFLECTION\nreflectionColor.rgb=fromRGBD(reflectionColor);\n#endif\n#ifdef GAMMAREFLECTION\nreflectionColor.rgb=toLinearSpace(reflectionColor.rgb);\n#endif\n#ifdef REFLECTIONBGR\nreflectionColor.rgb=reflectionColor.bgr;\n#endif\n\nreflectionColor.rgb*=vReflectionInfos.x;\n#endif\n\nvec3 diffuseColor=vec3(1.,1.,1.);\nfloat finalAlpha=alpha;\n#ifdef DIFFUSE\nvec4 diffuseMap=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef GAMMADIFFUSE\ndiffuseMap.rgb=toLinearSpace(diffuseMap.rgb);\n#endif\n\ndiffuseMap.rgb*=vDiffuseInfos.y;\n#ifdef DIFFUSEHASALPHA\nfinalAlpha*=diffuseMap.a;\n#endif\ndiffuseColor=diffuseMap.rgb;\n#endif\n\n#ifdef REFLECTIONFRESNEL\nvec3 colorBase=diffuseColor;\n#else\nvec3 colorBase=reflectionColor.rgb*diffuseColor;\n#endif\ncolorBase=max(colorBase,0.0);\n\n#ifdef USERGBCOLOR\nvec3 finalColor=colorBase;\n#else\n#ifdef USEHIGHLIGHTANDSHADOWCOLORS\nvec3 mainColor=mix(vPrimaryColorShadow.rgb,vPrimaryColor.rgb,colorBase);\n#else\nvec3 mainColor=vPrimaryColor.rgb;\n#endif\nvec3 finalColor=colorBase*mainColor;\n#endif\n\n#ifdef REFLECTIONFRESNEL\nvec3 reflectionAmount=vReflectionControl.xxx;\nvec3 reflectionReflectance0=vReflectionControl.yyy;\nvec3 reflectionReflectance90=vReflectionControl.zzz;\nfloat VdotN=dot(normalize(vEyePosition),normalW);\nvec3 planarReflectionFresnel=fresnelSchlickEnvironmentGGX(saturate(VdotN),reflectionReflectance0,reflectionReflectance90,1.0);\nreflectionAmount*=planarReflectionFresnel;\n#ifdef REFLECTIONFALLOFF\nfloat reflectionDistanceFalloff=1.0-saturate(length(vPositionW.xyz-vBackgroundCenter)*vReflectionControl.w);\nreflectionDistanceFalloff*=reflectionDistanceFalloff;\nreflectionAmount*=reflectionDistanceFalloff;\n#endif\nfinalColor=mix(finalColor,reflectionColor.rgb,saturate(reflectionAmount));\n#endif\n#ifdef OPACITYFRESNEL\nfloat viewAngleToFloor=dot(normalW,normalize(vEyePosition-vBackgroundCenter));\n\nconst float startAngle=0.1;\nfloat fadeFactor=saturate(viewAngleToFloor/startAngle);\nfinalAlpha*=fadeFactor*fadeFactor;\n#endif\n\n#ifdef SHADOWINUSE\nfinalColor=mix(finalColor*shadowLevel,finalColor,globalShadow);\n#endif\n\nvec4 color=vec4(finalColor,finalAlpha);\n#include<fogFragment>\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\ncolor.rgb=clamp(color.rgb,0.,30.0);\n#else\n\ncolor=applyImageProcessing(color);\n#endif\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\n#ifdef NOISE\ncolor.rgb+=dither(vPositionW.xy,0.5);\ncolor=max(color,0.0);\n#endif\ngl_FragColor=color;\n}\n";
  128981. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  128982. /** @hidden */
  128983. var backgroundPixelShader = { name: name, shader: shader };
  128984. /***/ }),
  128985. /***/ "./Shaders/background.vertex.ts":
  128986. /*!**************************************!*\
  128987. !*** ./Shaders/background.vertex.ts ***!
  128988. \**************************************/
  128989. /*! exports provided: backgroundVertexShader */
  128990. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128991. "use strict";
  128992. __webpack_require__.r(__webpack_exports__);
  128993. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexShader", function() { return backgroundVertexShader; });
  128994. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  128995. /* harmony import */ var _ShadersInclude_backgroundVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundVertexDeclaration */ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts");
  128996. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  128997. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  128998. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  128999. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  129000. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  129001. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  129002. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  129003. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  129004. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  129005. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  129006. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  129007. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  129008. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  129009. var name = 'backgroundVertexShader';
  129010. var shader = "precision highp float;\n#include<__decl__backgroundVertex>\n#include<helperFunctions>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\nvoid main(void) {\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(position,1.0)).xyz;\n#else\nvPositionUVW=position;\n#endif\n#endif\n#include<instancesVertex>\n#include<bonesVertex>\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR == 0u) {\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n} else {\ngl_Position=viewProjectionR*finalWorld*vec4(position,1.0);\n}\n#else\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#endif\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normal);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(position,0.0)));\n#ifdef EQUIRECTANGULAR_RELFECTION_FOV\nmat3 screenToWorld=inverseMat3(mat3(finalWorld*viewProjection));\nvec3 segment=mix(vDirectionW,screenToWorld*vec3(0.0,0.0,1.0),abs(fFovMultiplier-1.0));\nif (fFovMultiplier<=1.0) {\nvDirectionW=normalize(segment);\n} else {\nvDirectionW=normalize(vDirectionW+(vDirectionW-segment));\n}\n#endif\n#endif\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
  129011. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129012. /** @hidden */
  129013. var backgroundVertexShader = { name: name, shader: shader };
  129014. /***/ }),
  129015. /***/ "./Shaders/blackAndWhite.fragment.ts":
  129016. /*!*******************************************!*\
  129017. !*** ./Shaders/blackAndWhite.fragment.ts ***!
  129018. \*******************************************/
  129019. /*! exports provided: blackAndWhitePixelShader */
  129020. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129021. "use strict";
  129022. __webpack_require__.r(__webpack_exports__);
  129023. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "blackAndWhitePixelShader", function() { return blackAndWhitePixelShader; });
  129024. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129025. var name = 'blackAndWhitePixelShader';
  129026. 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}";
  129027. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129028. /** @hidden */
  129029. var blackAndWhitePixelShader = { name: name, shader: shader };
  129030. /***/ }),
  129031. /***/ "./Shaders/bloomMerge.fragment.ts":
  129032. /*!****************************************!*\
  129033. !*** ./Shaders/bloomMerge.fragment.ts ***!
  129034. \****************************************/
  129035. /*! exports provided: bloomMergePixelShader */
  129036. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129037. "use strict";
  129038. __webpack_require__.r(__webpack_exports__);
  129039. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bloomMergePixelShader", function() { return bloomMergePixelShader; });
  129040. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129041. var name = 'bloomMergePixelShader';
  129042. 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";
  129043. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129044. /** @hidden */
  129045. var bloomMergePixelShader = { name: name, shader: shader };
  129046. /***/ }),
  129047. /***/ "./Shaders/chromaticAberration.fragment.ts":
  129048. /*!*************************************************!*\
  129049. !*** ./Shaders/chromaticAberration.fragment.ts ***!
  129050. \*************************************************/
  129051. /*! exports provided: chromaticAberrationPixelShader */
  129052. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129053. "use strict";
  129054. __webpack_require__.r(__webpack_exports__);
  129055. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "chromaticAberrationPixelShader", function() { return chromaticAberrationPixelShader; });
  129056. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129057. var name = 'chromaticAberrationPixelShader';
  129058. 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}";
  129059. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129060. /** @hidden */
  129061. var chromaticAberrationPixelShader = { name: name, shader: shader };
  129062. /***/ }),
  129063. /***/ "./Shaders/circleOfConfusion.fragment.ts":
  129064. /*!***********************************************!*\
  129065. !*** ./Shaders/circleOfConfusion.fragment.ts ***!
  129066. \***********************************************/
  129067. /*! exports provided: circleOfConfusionPixelShader */
  129068. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129069. "use strict";
  129070. __webpack_require__.r(__webpack_exports__);
  129071. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "circleOfConfusionPixelShader", function() { return circleOfConfusionPixelShader; });
  129072. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129073. var name = 'circleOfConfusionPixelShader';
  129074. 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";
  129075. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129076. /** @hidden */
  129077. var circleOfConfusionPixelShader = { name: name, shader: shader };
  129078. /***/ }),
  129079. /***/ "./Shaders/color.fragment.ts":
  129080. /*!***********************************!*\
  129081. !*** ./Shaders/color.fragment.ts ***!
  129082. \***********************************/
  129083. /*! exports provided: colorPixelShader */
  129084. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129085. "use strict";
  129086. __webpack_require__.r(__webpack_exports__);
  129087. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorPixelShader", function() { return colorPixelShader; });
  129088. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129089. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  129090. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  129091. var name = 'colorPixelShader';
  129092. var shader = "#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#else\nuniform vec4 color;\n#endif\n#include<clipPlaneFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\n#ifdef VERTEXCOLOR\ngl_FragColor=vColor;\n#else\ngl_FragColor=color;\n#endif\n}";
  129093. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129094. /** @hidden */
  129095. var colorPixelShader = { name: name, shader: shader };
  129096. /***/ }),
  129097. /***/ "./Shaders/color.vertex.ts":
  129098. /*!*********************************!*\
  129099. !*** ./Shaders/color.vertex.ts ***!
  129100. \*********************************/
  129101. /*! exports provided: colorVertexShader */
  129102. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129103. "use strict";
  129104. __webpack_require__.r(__webpack_exports__);
  129105. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorVertexShader", function() { return colorVertexShader; });
  129106. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129107. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  129108. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  129109. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  129110. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  129111. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  129112. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  129113. var name = 'colorVertexShader';
  129114. var shader = "\nattribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n#include<clipPlaneVertexDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\n\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\n#include<clipPlaneVertex>\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n}";
  129115. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129116. /** @hidden */
  129117. var colorVertexShader = { name: name, shader: shader };
  129118. /***/ }),
  129119. /***/ "./Shaders/colorCorrection.fragment.ts":
  129120. /*!*********************************************!*\
  129121. !*** ./Shaders/colorCorrection.fragment.ts ***!
  129122. \*********************************************/
  129123. /*! exports provided: colorCorrectionPixelShader */
  129124. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129125. "use strict";
  129126. __webpack_require__.r(__webpack_exports__);
  129127. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorCorrectionPixelShader", function() { return colorCorrectionPixelShader; });
  129128. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129129. var name = 'colorCorrectionPixelShader';
  129130. 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}";
  129131. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129132. /** @hidden */
  129133. var colorCorrectionPixelShader = { name: name, shader: shader };
  129134. /***/ }),
  129135. /***/ "./Shaders/convolution.fragment.ts":
  129136. /*!*****************************************!*\
  129137. !*** ./Shaders/convolution.fragment.ts ***!
  129138. \*****************************************/
  129139. /*! exports provided: convolutionPixelShader */
  129140. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129141. "use strict";
  129142. __webpack_require__.r(__webpack_exports__);
  129143. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "convolutionPixelShader", function() { return convolutionPixelShader; });
  129144. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129145. var name = 'convolutionPixelShader';
  129146. 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}";
  129147. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129148. /** @hidden */
  129149. var convolutionPixelShader = { name: name, shader: shader };
  129150. /***/ }),
  129151. /***/ "./Shaders/default.fragment.ts":
  129152. /*!*************************************!*\
  129153. !*** ./Shaders/default.fragment.ts ***!
  129154. \*************************************/
  129155. /*! exports provided: defaultPixelShader */
  129156. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129157. "use strict";
  129158. __webpack_require__.r(__webpack_exports__);
  129159. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultPixelShader", function() { return defaultPixelShader; });
  129160. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129161. /* harmony import */ var _ShadersInclude_defaultFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultFragmentDeclaration */ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts");
  129162. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  129163. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  129164. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  129165. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  129166. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  129167. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  129168. /* harmony import */ var _ShadersInclude_fresnelFunction__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fresnelFunction */ "./Shaders/ShadersInclude/fresnelFunction.ts");
  129169. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  129170. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  129171. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  129172. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  129173. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  129174. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  129175. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  129176. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  129177. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  129178. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  129179. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  129180. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  129181. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  129182. var name = 'defaultPixelShader';
  129183. var shader = "#include<__decl__defaultFragment>\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#define CUSTOM_FRAGMENT_BEGIN\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n\n#define RECIPROCAL_PI2 0.15915494\nuniform vec3 vEyePosition;\nuniform vec3 vAmbientColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\n#if SPECULARDIRECTUV == 1\n#define vSpecularUV vMainUV1\n#elif SPECULARDIRECTUV == 2\n#define vSpecularUV vMainUV2\n#else\nvarying vec2 vSpecularUV;\n#endif\nuniform sampler2D specularSampler;\n#endif\n#ifdef ALPHATEST\nuniform float alphaCutOff;\n#endif\n\n#include<fresnelFunction>\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\nuniform samplerCube reflectionCubeSampler;\n#else\nuniform sampler2D reflection2DSampler;\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#include<imageProcessingDeclaration>\n#include<imageProcessingFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));\n#endif\n#include<bumpFragment>\n#ifdef TWOSIDEDLIGHTING\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\n#ifdef ALPHATEST\nif (baseColor.a<alphaCutOff)\ndiscard;\n#endif\n#ifdef ALPHAFROMDIFFUSE\nalpha*=baseColor.a;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_ALPHA\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE\n\nvec3 baseAmbientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nbaseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\n\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#ifdef SPECULAR\nvec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);\nspecularColor=specularMapColor.rgb;\n#ifdef GLOSSINESS\nglossiness=glossiness*specularMapColor.a;\n#endif\n#endif\n#else\nfloat glossiness=0.;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\nfloat shadow=1.;\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n\nvec3 refractionColor=vec3(0.,0.,0.);\n#ifdef REFRACTION\nvec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nif (dot(refractionVector,viewDirectionW)<1.0) {\nrefractionColor=textureCube(refractionCubeSampler,refractionVector).rgb;\n}\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\nrefractionColor=texture2D(refraction2DSampler,refractionCoords).rgb;\n#endif\n#ifdef IS_REFRACTION_LINEAR\nrefractionColor=toGammaSpace(refractionColor);\n#endif\nrefractionColor*=vRefractionInfos.x;\n#endif\n\nvec3 reflectionColor=vec3(0.,0.,0.);\n#ifdef REFLECTION\nvec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_3D\n#ifdef ROUGHNESS\nfloat bias=vReflectionInfos.y;\n#ifdef SPECULARTERM\n#ifdef SPECULAR\n#ifdef GLOSSINESS\nbias*=(1.0-specularMapColor.a);\n#endif\n#endif\n#endif\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias).rgb;\n#else\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW).rgb;\n#endif\n#else\nvec2 coords=vReflectionUVW.xy;\n#ifdef REFLECTIONMAP_PROJECTION\ncoords/=vReflectionUVW.z;\n#endif\ncoords.y=1.0-coords.y;\nreflectionColor=texture2D(reflection2DSampler,coords).rgb;\n#endif\n#ifdef IS_REFLECTION_LINEAR\nreflectionColor=toGammaSpace(reflectionColor);\n#endif\nreflectionColor*=vReflectionInfos.x;\n#ifdef REFLECTIONFRESNEL\nfloat reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);\n#ifdef REFLECTIONFRESNELFROMSPECULAR\n#ifdef SPECULARTERM\nreflectionColor*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#endif\n#endif\n#ifdef REFRACTIONFRESNEL\nfloat refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);\nrefractionColor*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nopacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);\nalpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;\n#else\nalpha*=opacityMap.a*vOpacityInfos.y;\n#endif\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef OPACITYFRESNEL\nfloat opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);\nalpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;\n#endif\n\nvec3 emissiveColor=vEmissiveColor;\n#ifdef EMISSIVE\nemissiveColor+=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y;\n#endif\n#ifdef EMISSIVEFRESNEL\nfloat emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);\nemissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;\n#endif\n\n#ifdef DIFFUSEFRESNEL\nfloat diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);\ndiffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\n#ifdef LINKEMISSIVEWITHDIFFUSE\nvec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#endif\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#ifdef SPECULAROVERALPHA\nalpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#ifdef REFLECTIONOVERALPHA\nalpha=clamp(alpha+dot(reflectionColor,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+emissiveColor+refractionColor,0.0,1.0),alpha);\n#else\nvec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+refractionColor,alpha);\n#endif\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor;\n#else\ncolor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FOG\ncolor.rgb=max(color.rgb,0.);\n#include<logDepthFragment>\n#include<fogFragment>\n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\ncolor.rgb=toLinearSpace(color.rgb);\n#else\n#ifdef IMAGEPROCESSING\ncolor.rgb=toLinearSpace(color.rgb);\ncolor=applyImageProcessing(color);\n#endif\n#endif\ncolor.a*=visibility;\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\ngl_FragColor=color;\n}\n";
  129184. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129185. /** @hidden */
  129186. var defaultPixelShader = { name: name, shader: shader };
  129187. /***/ }),
  129188. /***/ "./Shaders/default.vertex.ts":
  129189. /*!***********************************!*\
  129190. !*** ./Shaders/default.vertex.ts ***!
  129191. \***********************************/
  129192. /*! exports provided: defaultVertexShader */
  129193. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129194. "use strict";
  129195. __webpack_require__.r(__webpack_exports__);
  129196. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexShader", function() { return defaultVertexShader; });
  129197. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129198. /* harmony import */ var _ShadersInclude_defaultVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultVertexDeclaration */ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts");
  129199. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  129200. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  129201. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  129202. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  129203. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  129204. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  129205. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  129206. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  129207. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  129208. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  129209. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  129210. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  129211. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  129212. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  129213. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  129214. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  129215. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  129216. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  129217. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  129218. /* harmony import */ var _ShadersInclude_pointCloudVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/pointCloudVertex */ "./Shaders/ShadersInclude/pointCloudVertex.ts");
  129219. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  129220. var name = 'defaultVertexShader';
  129221. var shader = "#include<__decl__defaultVertex>\n\n#define CUSTOM_VERTEX_BEGIN\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nvarying vec2 vSpecularUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(position,1.0)).xyz;\n#else\nvPositionUVW=position;\n#endif\n#endif\n#define CUSTOM_VERTEX_UPDATE_POSITION\n#define CUSTOM_VERTEX_UPDATE_NORMAL\n#include<instancesVertex>\n#include<bonesVertex>\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR == 0u) {\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n} else {\ngl_Position=viewProjectionR*finalWorld*vec4(positionUpdated,1.0);\n}\n#else\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#endif\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nif (vSpecularInfos.x == 0.)\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#include<bumpVertex>\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n#include<pointCloudVertex>\n#include<logDepthVertex>\n#define CUSTOM_VERTEX_MAIN_END\n}\n";
  129222. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129223. /** @hidden */
  129224. var defaultVertexShader = { name: name, shader: shader };
  129225. /***/ }),
  129226. /***/ "./Shaders/depth.fragment.ts":
  129227. /*!***********************************!*\
  129228. !*** ./Shaders/depth.fragment.ts ***!
  129229. \***********************************/
  129230. /*! exports provided: depthPixelShader */
  129231. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129232. "use strict";
  129233. __webpack_require__.r(__webpack_exports__);
  129234. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPixelShader", function() { return depthPixelShader; });
  129235. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129236. var name = 'depthPixelShader';
  129237. 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}";
  129238. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129239. /** @hidden */
  129240. var depthPixelShader = { name: name, shader: shader };
  129241. /***/ }),
  129242. /***/ "./Shaders/depth.vertex.ts":
  129243. /*!*********************************!*\
  129244. !*** ./Shaders/depth.vertex.ts ***!
  129245. \*********************************/
  129246. /*! exports provided: depthVertexShader */
  129247. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129248. "use strict";
  129249. __webpack_require__.r(__webpack_exports__);
  129250. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthVertexShader", function() { return depthVertexShader; });
  129251. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129252. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  129253. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  129254. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  129255. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  129256. var name = 'depthVertexShader';
  129257. 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}";
  129258. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129259. /** @hidden */
  129260. var depthVertexShader = { name: name, shader: shader };
  129261. /***/ }),
  129262. /***/ "./Shaders/depthBoxBlur.fragment.ts":
  129263. /*!******************************************!*\
  129264. !*** ./Shaders/depthBoxBlur.fragment.ts ***!
  129265. \******************************************/
  129266. /*! exports provided: depthBoxBlurPixelShader */
  129267. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129268. "use strict";
  129269. __webpack_require__.r(__webpack_exports__);
  129270. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthBoxBlurPixelShader", function() { return depthBoxBlurPixelShader; });
  129271. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129272. var name = 'depthBoxBlurPixelShader';
  129273. 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}";
  129274. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129275. /** @hidden */
  129276. var depthBoxBlurPixelShader = { name: name, shader: shader };
  129277. /***/ }),
  129278. /***/ "./Shaders/depthOfField.fragment.ts":
  129279. /*!******************************************!*\
  129280. !*** ./Shaders/depthOfField.fragment.ts ***!
  129281. \******************************************/
  129282. /*! exports provided: depthOfFieldPixelShader */
  129283. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129284. "use strict";
  129285. __webpack_require__.r(__webpack_exports__);
  129286. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldPixelShader", function() { return depthOfFieldPixelShader; });
  129287. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129288. var name = 'depthOfFieldPixelShader';
  129289. 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";
  129290. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129291. /** @hidden */
  129292. var depthOfFieldPixelShader = { name: name, shader: shader };
  129293. /***/ }),
  129294. /***/ "./Shaders/depthOfFieldMerge.fragment.ts":
  129295. /*!***********************************************!*\
  129296. !*** ./Shaders/depthOfFieldMerge.fragment.ts ***!
  129297. \***********************************************/
  129298. /*! exports provided: depthOfFieldMergePixelShader */
  129299. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129300. "use strict";
  129301. __webpack_require__.r(__webpack_exports__);
  129302. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldMergePixelShader", function() { return depthOfFieldMergePixelShader; });
  129303. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129304. var name = 'depthOfFieldMergePixelShader';
  129305. 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";
  129306. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129307. /** @hidden */
  129308. var depthOfFieldMergePixelShader = { name: name, shader: shader };
  129309. /***/ }),
  129310. /***/ "./Shaders/displayPass.fragment.ts":
  129311. /*!*****************************************!*\
  129312. !*** ./Shaders/displayPass.fragment.ts ***!
  129313. \*****************************************/
  129314. /*! exports provided: displayPassPixelShader */
  129315. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129316. "use strict";
  129317. __webpack_require__.r(__webpack_exports__);
  129318. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayPassPixelShader", function() { return displayPassPixelShader; });
  129319. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129320. var name = 'displayPassPixelShader';
  129321. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D passSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(passSampler,vUV);\n}";
  129322. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129323. /** @hidden */
  129324. var displayPassPixelShader = { name: name, shader: shader };
  129325. /***/ }),
  129326. /***/ "./Shaders/extractHighlights.fragment.ts":
  129327. /*!***********************************************!*\
  129328. !*** ./Shaders/extractHighlights.fragment.ts ***!
  129329. \***********************************************/
  129330. /*! exports provided: extractHighlightsPixelShader */
  129331. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129332. "use strict";
  129333. __webpack_require__.r(__webpack_exports__);
  129334. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "extractHighlightsPixelShader", function() { return extractHighlightsPixelShader; });
  129335. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129336. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  129337. var name = 'extractHighlightsPixelShader';
  129338. 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}";
  129339. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129340. /** @hidden */
  129341. var extractHighlightsPixelShader = { name: name, shader: shader };
  129342. /***/ }),
  129343. /***/ "./Shaders/filter.fragment.ts":
  129344. /*!************************************!*\
  129345. !*** ./Shaders/filter.fragment.ts ***!
  129346. \************************************/
  129347. /*! exports provided: filterPixelShader */
  129348. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129349. "use strict";
  129350. __webpack_require__.r(__webpack_exports__);
  129351. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "filterPixelShader", function() { return filterPixelShader; });
  129352. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129353. var name = 'filterPixelShader';
  129354. 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}";
  129355. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129356. /** @hidden */
  129357. var filterPixelShader = { name: name, shader: shader };
  129358. /***/ }),
  129359. /***/ "./Shaders/fxaa.fragment.ts":
  129360. /*!**********************************!*\
  129361. !*** ./Shaders/fxaa.fragment.ts ***!
  129362. \**********************************/
  129363. /*! exports provided: fxaaPixelShader */
  129364. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129365. "use strict";
  129366. __webpack_require__.r(__webpack_exports__);
  129367. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaPixelShader", function() { return fxaaPixelShader; });
  129368. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129369. var name = 'fxaaPixelShader';
  129370. 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}";
  129371. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129372. /** @hidden */
  129373. var fxaaPixelShader = { name: name, shader: shader };
  129374. /***/ }),
  129375. /***/ "./Shaders/fxaa.vertex.ts":
  129376. /*!********************************!*\
  129377. !*** ./Shaders/fxaa.vertex.ts ***!
  129378. \********************************/
  129379. /*! exports provided: fxaaVertexShader */
  129380. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129381. "use strict";
  129382. __webpack_require__.r(__webpack_exports__);
  129383. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaVertexShader", function() { return fxaaVertexShader; });
  129384. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129385. var name = 'fxaaVertexShader';
  129386. 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}";
  129387. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129388. /** @hidden */
  129389. var fxaaVertexShader = { name: name, shader: shader };
  129390. /***/ }),
  129391. /***/ "./Shaders/geometry.fragment.ts":
  129392. /*!**************************************!*\
  129393. !*** ./Shaders/geometry.fragment.ts ***!
  129394. \**************************************/
  129395. /*! exports provided: geometryPixelShader */
  129396. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129397. "use strict";
  129398. __webpack_require__.r(__webpack_exports__);
  129399. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryPixelShader", function() { return geometryPixelShader; });
  129400. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129401. /* harmony import */ var _ShadersInclude_mrtFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/mrtFragmentDeclaration */ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts");
  129402. var name = 'geometryPixelShader';
  129403. 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}";
  129404. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129405. /** @hidden */
  129406. var geometryPixelShader = { name: name, shader: shader };
  129407. /***/ }),
  129408. /***/ "./Shaders/geometry.vertex.ts":
  129409. /*!************************************!*\
  129410. !*** ./Shaders/geometry.vertex.ts ***!
  129411. \************************************/
  129412. /*! exports provided: geometryVertexShader */
  129413. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129414. "use strict";
  129415. __webpack_require__.r(__webpack_exports__);
  129416. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryVertexShader", function() { return geometryVertexShader; });
  129417. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129418. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  129419. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  129420. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  129421. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  129422. var name = 'geometryVertexShader';
  129423. 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}";
  129424. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129425. /** @hidden */
  129426. var geometryVertexShader = { name: name, shader: shader };
  129427. /***/ }),
  129428. /***/ "./Shaders/glowBlurPostProcess.fragment.ts":
  129429. /*!*************************************************!*\
  129430. !*** ./Shaders/glowBlurPostProcess.fragment.ts ***!
  129431. \*************************************************/
  129432. /*! exports provided: glowBlurPostProcessPixelShader */
  129433. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129434. "use strict";
  129435. __webpack_require__.r(__webpack_exports__);
  129436. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowBlurPostProcessPixelShader", function() { return glowBlurPostProcessPixelShader; });
  129437. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129438. var name = 'glowBlurPostProcessPixelShader';
  129439. 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}";
  129440. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129441. /** @hidden */
  129442. var glowBlurPostProcessPixelShader = { name: name, shader: shader };
  129443. /***/ }),
  129444. /***/ "./Shaders/glowMapGeneration.fragment.ts":
  129445. /*!***********************************************!*\
  129446. !*** ./Shaders/glowMapGeneration.fragment.ts ***!
  129447. \***********************************************/
  129448. /*! exports provided: glowMapGenerationPixelShader */
  129449. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129450. "use strict";
  129451. __webpack_require__.r(__webpack_exports__);
  129452. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationPixelShader", function() { return glowMapGenerationPixelShader; });
  129453. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129454. var name = 'glowMapGenerationPixelShader';
  129455. 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}";
  129456. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129457. /** @hidden */
  129458. var glowMapGenerationPixelShader = { name: name, shader: shader };
  129459. /***/ }),
  129460. /***/ "./Shaders/glowMapGeneration.vertex.ts":
  129461. /*!*********************************************!*\
  129462. !*** ./Shaders/glowMapGeneration.vertex.ts ***!
  129463. \*********************************************/
  129464. /*! exports provided: glowMapGenerationVertexShader */
  129465. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129466. "use strict";
  129467. __webpack_require__.r(__webpack_exports__);
  129468. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationVertexShader", function() { return glowMapGenerationVertexShader; });
  129469. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129470. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  129471. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  129472. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  129473. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  129474. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  129475. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  129476. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  129477. var name = 'glowMapGenerationVertexShader';
  129478. 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}";
  129479. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129480. /** @hidden */
  129481. var glowMapGenerationVertexShader = { name: name, shader: shader };
  129482. /***/ }),
  129483. /***/ "./Shaders/glowMapMerge.fragment.ts":
  129484. /*!******************************************!*\
  129485. !*** ./Shaders/glowMapMerge.fragment.ts ***!
  129486. \******************************************/
  129487. /*! exports provided: glowMapMergePixelShader */
  129488. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129489. "use strict";
  129490. __webpack_require__.r(__webpack_exports__);
  129491. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergePixelShader", function() { return glowMapMergePixelShader; });
  129492. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129493. var name = 'glowMapMergePixelShader';
  129494. 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}";
  129495. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129496. /** @hidden */
  129497. var glowMapMergePixelShader = { name: name, shader: shader };
  129498. /***/ }),
  129499. /***/ "./Shaders/glowMapMerge.vertex.ts":
  129500. /*!****************************************!*\
  129501. !*** ./Shaders/glowMapMerge.vertex.ts ***!
  129502. \****************************************/
  129503. /*! exports provided: glowMapMergeVertexShader */
  129504. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129505. "use strict";
  129506. __webpack_require__.r(__webpack_exports__);
  129507. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergeVertexShader", function() { return glowMapMergeVertexShader; });
  129508. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129509. var name = 'glowMapMergeVertexShader';
  129510. 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}";
  129511. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129512. /** @hidden */
  129513. var glowMapMergeVertexShader = { name: name, shader: shader };
  129514. /***/ }),
  129515. /***/ "./Shaders/gpuRenderParticles.fragment.ts":
  129516. /*!************************************************!*\
  129517. !*** ./Shaders/gpuRenderParticles.fragment.ts ***!
  129518. \************************************************/
  129519. /*! exports provided: gpuRenderParticlesPixelShader */
  129520. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129521. "use strict";
  129522. __webpack_require__.r(__webpack_exports__);
  129523. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesPixelShader", function() { return gpuRenderParticlesPixelShader; });
  129524. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129525. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts");
  129526. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  129527. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  129528. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  129529. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  129530. var name = 'gpuRenderParticlesPixelShader';
  129531. 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";
  129532. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129533. /** @hidden */
  129534. var gpuRenderParticlesPixelShader = { name: name, shader: shader };
  129535. /***/ }),
  129536. /***/ "./Shaders/gpuRenderParticles.vertex.ts":
  129537. /*!**********************************************!*\
  129538. !*** ./Shaders/gpuRenderParticles.vertex.ts ***!
  129539. \**********************************************/
  129540. /*! exports provided: gpuRenderParticlesVertexShader */
  129541. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129542. "use strict";
  129543. __webpack_require__.r(__webpack_exports__);
  129544. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesVertexShader", function() { return gpuRenderParticlesVertexShader; });
  129545. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129546. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts");
  129547. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  129548. var name = 'gpuRenderParticlesVertexShader';
  129549. 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}";
  129550. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129551. /** @hidden */
  129552. var gpuRenderParticlesVertexShader = { name: name, shader: shader };
  129553. /***/ }),
  129554. /***/ "./Shaders/gpuUpdateParticles.fragment.ts":
  129555. /*!************************************************!*\
  129556. !*** ./Shaders/gpuUpdateParticles.fragment.ts ***!
  129557. \************************************************/
  129558. /*! exports provided: gpuUpdateParticlesPixelShader */
  129559. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129560. "use strict";
  129561. __webpack_require__.r(__webpack_exports__);
  129562. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesPixelShader", function() { return gpuUpdateParticlesPixelShader; });
  129563. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129564. var name = 'gpuUpdateParticlesPixelShader';
  129565. var shader = "#version 300 es\nvoid main() {\ndiscard;\n}\n";
  129566. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129567. /** @hidden */
  129568. var gpuUpdateParticlesPixelShader = { name: name, shader: shader };
  129569. /***/ }),
  129570. /***/ "./Shaders/gpuUpdateParticles.vertex.ts":
  129571. /*!**********************************************!*\
  129572. !*** ./Shaders/gpuUpdateParticles.vertex.ts ***!
  129573. \**********************************************/
  129574. /*! exports provided: gpuUpdateParticlesVertexShader */
  129575. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129576. "use strict";
  129577. __webpack_require__.r(__webpack_exports__);
  129578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesVertexShader", function() { return gpuUpdateParticlesVertexShader; });
  129579. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129580. var name = 'gpuUpdateParticlesVertexShader';
  129581. 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}";
  129582. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129583. /** @hidden */
  129584. var gpuUpdateParticlesVertexShader = { name: name, shader: shader };
  129585. /***/ }),
  129586. /***/ "./Shaders/grain.fragment.ts":
  129587. /*!***********************************!*\
  129588. !*** ./Shaders/grain.fragment.ts ***!
  129589. \***********************************/
  129590. /*! exports provided: grainPixelShader */
  129591. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129592. "use strict";
  129593. __webpack_require__.r(__webpack_exports__);
  129594. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "grainPixelShader", function() { return grainPixelShader; });
  129595. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129596. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  129597. var name = 'grainPixelShader';
  129598. 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}";
  129599. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129600. /** @hidden */
  129601. var grainPixelShader = { name: name, shader: shader };
  129602. /***/ }),
  129603. /***/ "./Shaders/highlights.fragment.ts":
  129604. /*!****************************************!*\
  129605. !*** ./Shaders/highlights.fragment.ts ***!
  129606. \****************************************/
  129607. /*! exports provided: highlightsPixelShader */
  129608. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129609. "use strict";
  129610. __webpack_require__.r(__webpack_exports__);
  129611. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "highlightsPixelShader", function() { return highlightsPixelShader; });
  129612. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129613. var name = 'highlightsPixelShader';
  129614. 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}";
  129615. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129616. /** @hidden */
  129617. var highlightsPixelShader = { name: name, shader: shader };
  129618. /***/ }),
  129619. /***/ "./Shaders/imageProcessing.fragment.ts":
  129620. /*!*********************************************!*\
  129621. !*** ./Shaders/imageProcessing.fragment.ts ***!
  129622. \*********************************************/
  129623. /*! exports provided: imageProcessingPixelShader */
  129624. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129625. "use strict";
  129626. __webpack_require__.r(__webpack_exports__);
  129627. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingPixelShader", function() { return imageProcessingPixelShader; });
  129628. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129629. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  129630. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  129631. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  129632. var name = 'imageProcessingPixelShader';
  129633. 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}";
  129634. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129635. /** @hidden */
  129636. var imageProcessingPixelShader = { name: name, shader: shader };
  129637. /***/ }),
  129638. /***/ "./Shaders/kernelBlur.fragment.ts":
  129639. /*!****************************************!*\
  129640. !*** ./Shaders/kernelBlur.fragment.ts ***!
  129641. \****************************************/
  129642. /*! exports provided: kernelBlurPixelShader */
  129643. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129644. "use strict";
  129645. __webpack_require__.r(__webpack_exports__);
  129646. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurPixelShader", function() { return kernelBlurPixelShader; });
  129647. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129648. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  129649. /* harmony import */ var _ShadersInclude_kernelBlurFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment */ "./Shaders/ShadersInclude/kernelBlurFragment.ts");
  129650. /* harmony import */ var _ShadersInclude_kernelBlurFragment2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment2 */ "./Shaders/ShadersInclude/kernelBlurFragment2.ts");
  129651. var name = 'kernelBlurPixelShader';
  129652. 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}";
  129653. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129654. /** @hidden */
  129655. var kernelBlurPixelShader = { name: name, shader: shader };
  129656. /***/ }),
  129657. /***/ "./Shaders/kernelBlur.vertex.ts":
  129658. /*!**************************************!*\
  129659. !*** ./Shaders/kernelBlur.vertex.ts ***!
  129660. \**************************************/
  129661. /*! exports provided: kernelBlurVertexShader */
  129662. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129663. "use strict";
  129664. __webpack_require__.r(__webpack_exports__);
  129665. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertexShader", function() { return kernelBlurVertexShader; });
  129666. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129667. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  129668. /* harmony import */ var _ShadersInclude_kernelBlurVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVertex */ "./Shaders/ShadersInclude/kernelBlurVertex.ts");
  129669. var name = 'kernelBlurVertexShader';
  129670. 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}";
  129671. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129672. /** @hidden */
  129673. var kernelBlurVertexShader = { name: name, shader: shader };
  129674. /***/ }),
  129675. /***/ "./Shaders/layer.fragment.ts":
  129676. /*!***********************************!*\
  129677. !*** ./Shaders/layer.fragment.ts ***!
  129678. \***********************************/
  129679. /*! exports provided: layerPixelShader */
  129680. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129681. "use strict";
  129682. __webpack_require__.r(__webpack_exports__);
  129683. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerPixelShader", function() { return layerPixelShader; });
  129684. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129685. var name = 'layerPixelShader';
  129686. 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}";
  129687. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129688. /** @hidden */
  129689. var layerPixelShader = { name: name, shader: shader };
  129690. /***/ }),
  129691. /***/ "./Shaders/layer.vertex.ts":
  129692. /*!*********************************!*\
  129693. !*** ./Shaders/layer.vertex.ts ***!
  129694. \*********************************/
  129695. /*! exports provided: layerVertexShader */
  129696. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129697. "use strict";
  129698. __webpack_require__.r(__webpack_exports__);
  129699. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerVertexShader", function() { return layerVertexShader; });
  129700. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129701. var name = 'layerVertexShader';
  129702. 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}";
  129703. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129704. /** @hidden */
  129705. var layerVertexShader = { name: name, shader: shader };
  129706. /***/ }),
  129707. /***/ "./Shaders/lensFlare.fragment.ts":
  129708. /*!***************************************!*\
  129709. !*** ./Shaders/lensFlare.fragment.ts ***!
  129710. \***************************************/
  129711. /*! exports provided: lensFlarePixelShader */
  129712. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129713. "use strict";
  129714. __webpack_require__.r(__webpack_exports__);
  129715. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlarePixelShader", function() { return lensFlarePixelShader; });
  129716. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129717. var name = 'lensFlarePixelShader';
  129718. 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}";
  129719. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129720. /** @hidden */
  129721. var lensFlarePixelShader = { name: name, shader: shader };
  129722. /***/ }),
  129723. /***/ "./Shaders/lensFlare.vertex.ts":
  129724. /*!*************************************!*\
  129725. !*** ./Shaders/lensFlare.vertex.ts ***!
  129726. \*************************************/
  129727. /*! exports provided: lensFlareVertexShader */
  129728. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129729. "use strict";
  129730. __webpack_require__.r(__webpack_exports__);
  129731. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlareVertexShader", function() { return lensFlareVertexShader; });
  129732. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129733. var name = 'lensFlareVertexShader';
  129734. 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}";
  129735. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129736. /** @hidden */
  129737. var lensFlareVertexShader = { name: name, shader: shader };
  129738. /***/ }),
  129739. /***/ "./Shaders/lensHighlights.fragment.ts":
  129740. /*!********************************************!*\
  129741. !*** ./Shaders/lensHighlights.fragment.ts ***!
  129742. \********************************************/
  129743. /*! exports provided: lensHighlightsPixelShader */
  129744. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129745. "use strict";
  129746. __webpack_require__.r(__webpack_exports__);
  129747. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensHighlightsPixelShader", function() { return lensHighlightsPixelShader; });
  129748. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129749. var name = 'lensHighlightsPixelShader';
  129750. 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}";
  129751. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129752. /** @hidden */
  129753. var lensHighlightsPixelShader = { name: name, shader: shader };
  129754. /***/ }),
  129755. /***/ "./Shaders/line.fragment.ts":
  129756. /*!**********************************!*\
  129757. !*** ./Shaders/line.fragment.ts ***!
  129758. \**********************************/
  129759. /*! exports provided: linePixelShader */
  129760. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129761. "use strict";
  129762. __webpack_require__.r(__webpack_exports__);
  129763. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "linePixelShader", function() { return linePixelShader; });
  129764. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129765. var name = 'linePixelShader';
  129766. var shader = "uniform vec4 color;\nvoid main(void) {\ngl_FragColor=color;\n}";
  129767. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129768. /** @hidden */
  129769. var linePixelShader = { name: name, shader: shader };
  129770. /***/ }),
  129771. /***/ "./Shaders/line.vertex.ts":
  129772. /*!********************************!*\
  129773. !*** ./Shaders/line.vertex.ts ***!
  129774. \********************************/
  129775. /*! exports provided: lineVertexShader */
  129776. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129777. "use strict";
  129778. __webpack_require__.r(__webpack_exports__);
  129779. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lineVertexShader", function() { return lineVertexShader; });
  129780. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129781. var name = 'lineVertexShader';
  129782. 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}";
  129783. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129784. /** @hidden */
  129785. var lineVertexShader = { name: name, shader: shader };
  129786. /***/ }),
  129787. /***/ "./Shaders/motionBlur.fragment.ts":
  129788. /*!****************************************!*\
  129789. !*** ./Shaders/motionBlur.fragment.ts ***!
  129790. \****************************************/
  129791. /*! exports provided: motionBlurPixelShader */
  129792. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129793. "use strict";
  129794. __webpack_require__.r(__webpack_exports__);
  129795. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "motionBlurPixelShader", function() { return motionBlurPixelShader; });
  129796. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129797. var name = 'motionBlurPixelShader';
  129798. 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";
  129799. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129800. /** @hidden */
  129801. var motionBlurPixelShader = { name: name, shader: shader };
  129802. /***/ }),
  129803. /***/ "./Shaders/noise.fragment.ts":
  129804. /*!***********************************!*\
  129805. !*** ./Shaders/noise.fragment.ts ***!
  129806. \***********************************/
  129807. /*! exports provided: noisePixelShader */
  129808. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129809. "use strict";
  129810. __webpack_require__.r(__webpack_exports__);
  129811. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "noisePixelShader", function() { return noisePixelShader; });
  129812. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129813. var name = 'noisePixelShader';
  129814. 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";
  129815. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129816. /** @hidden */
  129817. var noisePixelShader = { name: name, shader: shader };
  129818. /***/ }),
  129819. /***/ "./Shaders/outline.fragment.ts":
  129820. /*!*************************************!*\
  129821. !*** ./Shaders/outline.fragment.ts ***!
  129822. \*************************************/
  129823. /*! exports provided: outlinePixelShader */
  129824. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129825. "use strict";
  129826. __webpack_require__.r(__webpack_exports__);
  129827. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlinePixelShader", function() { return outlinePixelShader; });
  129828. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129829. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  129830. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  129831. var name = 'outlinePixelShader';
  129832. 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}";
  129833. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129834. /** @hidden */
  129835. var outlinePixelShader = { name: name, shader: shader };
  129836. /***/ }),
  129837. /***/ "./Shaders/outline.vertex.ts":
  129838. /*!***********************************!*\
  129839. !*** ./Shaders/outline.vertex.ts ***!
  129840. \***********************************/
  129841. /*! exports provided: outlineVertexShader */
  129842. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129843. "use strict";
  129844. __webpack_require__.r(__webpack_exports__);
  129845. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlineVertexShader", function() { return outlineVertexShader; });
  129846. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129847. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  129848. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  129849. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  129850. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  129851. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  129852. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  129853. var name = 'outlineVertexShader';
  129854. 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";
  129855. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129856. /** @hidden */
  129857. var outlineVertexShader = { name: name, shader: shader };
  129858. /***/ }),
  129859. /***/ "./Shaders/particles.fragment.ts":
  129860. /*!***************************************!*\
  129861. !*** ./Shaders/particles.fragment.ts ***!
  129862. \***************************************/
  129863. /*! exports provided: particlesPixelShader */
  129864. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129865. "use strict";
  129866. __webpack_require__.r(__webpack_exports__);
  129867. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesPixelShader", function() { return particlesPixelShader; });
  129868. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129869. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  129870. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  129871. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  129872. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  129873. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  129874. var name = 'particlesPixelShader';
  129875. 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}";
  129876. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129877. /** @hidden */
  129878. var particlesPixelShader = { name: name, shader: shader };
  129879. /***/ }),
  129880. /***/ "./Shaders/particles.vertex.ts":
  129881. /*!*************************************!*\
  129882. !*** ./Shaders/particles.vertex.ts ***!
  129883. \*************************************/
  129884. /*! exports provided: particlesVertexShader */
  129885. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129886. "use strict";
  129887. __webpack_require__.r(__webpack_exports__);
  129888. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesVertexShader", function() { return particlesVertexShader; });
  129889. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129890. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  129891. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  129892. var name = 'particlesVertexShader';
  129893. 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}";
  129894. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129895. /** @hidden */
  129896. var particlesVertexShader = { name: name, shader: shader };
  129897. /***/ }),
  129898. /***/ "./Shaders/pass.fragment.ts":
  129899. /*!**********************************!*\
  129900. !*** ./Shaders/pass.fragment.ts ***!
  129901. \**********************************/
  129902. /*! exports provided: passPixelShader */
  129903. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129904. "use strict";
  129905. __webpack_require__.r(__webpack_exports__);
  129906. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passPixelShader", function() { return passPixelShader; });
  129907. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129908. var name = 'passPixelShader';
  129909. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";
  129910. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129911. /** @hidden */
  129912. var passPixelShader = { name: name, shader: shader };
  129913. /***/ }),
  129914. /***/ "./Shaders/passCube.fragment.ts":
  129915. /*!**************************************!*\
  129916. !*** ./Shaders/passCube.fragment.ts ***!
  129917. \**************************************/
  129918. /*! exports provided: passCubePixelShader */
  129919. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129920. "use strict";
  129921. __webpack_require__.r(__webpack_exports__);
  129922. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passCubePixelShader", function() { return passCubePixelShader; });
  129923. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129924. var name = 'passCubePixelShader';
  129925. 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}";
  129926. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129927. /** @hidden */
  129928. var passCubePixelShader = { name: name, shader: shader };
  129929. /***/ }),
  129930. /***/ "./Shaders/pbr.fragment.ts":
  129931. /*!*********************************!*\
  129932. !*** ./Shaders/pbr.fragment.ts ***!
  129933. \*********************************/
  129934. /*! exports provided: pbrPixelShader */
  129935. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129936. "use strict";
  129937. __webpack_require__.r(__webpack_exports__);
  129938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrPixelShader", function() { return pbrPixelShader; });
  129939. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129940. /* harmony import */ var _ShadersInclude_pbrFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentDeclaration */ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts");
  129941. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  129942. /* harmony import */ var _ShadersInclude_pbrFragmentExtraDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentExtraDeclaration */ "./Shaders/ShadersInclude/pbrFragmentExtraDeclaration.ts");
  129943. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  129944. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  129945. /* harmony import */ var _ShadersInclude_pbrFragmentSamplersDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentSamplersDeclaration */ "./Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.ts");
  129946. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  129947. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  129948. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  129949. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  129950. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  129951. /* harmony import */ var _ShadersInclude_pbrHelperFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/pbrHelperFunctions */ "./Shaders/ShadersInclude/pbrHelperFunctions.ts");
  129952. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  129953. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  129954. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  129955. /* harmony import */ var _ShadersInclude_pbrDirectLightingSetupFunctions__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/pbrDirectLightingSetupFunctions */ "./Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.ts");
  129956. /* harmony import */ var _ShadersInclude_pbrDirectLightingFalloffFunctions__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/pbrDirectLightingFalloffFunctions */ "./Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.ts");
  129957. /* harmony import */ var _ShadersInclude_pbrBRDFFunctions__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/pbrBRDFFunctions */ "./Shaders/ShadersInclude/pbrBRDFFunctions.ts");
  129958. /* harmony import */ var _ShadersInclude_pbrDirectLightingFunctions__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/pbrDirectLightingFunctions */ "./Shaders/ShadersInclude/pbrDirectLightingFunctions.ts");
  129959. /* harmony import */ var _ShadersInclude_pbrIBLFunctions__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/pbrIBLFunctions */ "./Shaders/ShadersInclude/pbrIBLFunctions.ts");
  129960. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  129961. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  129962. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  129963. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  129964. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  129965. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  129966. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  129967. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  129968. /* harmony import */ var _ShadersInclude_pbrDebug__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./ShadersInclude/pbrDebug */ "./Shaders/ShadersInclude/pbrDebug.ts");
  129969. var name = 'pbrPixelShader';
  129970. var shader = "#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LODBASEDMICROSFURACE\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#define CUSTOM_FRAGMENT_BEGIN\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nprecision highp float;\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n\n#include<__decl__pbrFragment>\n#include<pbrFragmentExtraDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<pbrFragmentSamplersDeclaration>\n#include<imageProcessingDeclaration>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n\n#include<helperFunctions>\n#include<pbrHelperFunctions>\n#include<imageProcessingFunctions>\n#include<shadowsFragmentFunctions>\n#include<harmonicsFunctions>\n#include<pbrDirectLightingSetupFunctions>\n#include<pbrDirectLightingFalloffFunctions>\n#include<pbrBRDFFunctions>\n#include<pbrDirectLightingFunctions>\n#include<pbrIBLFunctions>\n#include<bumpFragmentFunctions>\n#ifdef REFLECTION\n#include<reflectionFunction>\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\n\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\n\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#endif\n#ifdef CLEARCOAT\n\nvec3 clearCoatNormalW=normalW;\n#endif\n#include<bumpFragment>\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nvec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#if defined(TWOSIDEDLIGHTING)\nfaceNormal=gl_FrontFacing ? faceNormal : -faceNormal;\n#endif\nnormalW*=sign(dot(normalW,faceNormal));\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n\n\nvec3 surfaceAlbedo=vAlbedoColor.rgb;\n\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\nvec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);\n#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)\nalpha*=albedoTexture.a;\n#endif\nsurfaceAlbedo*=toLinearSpace(albedoTexture.rgb);\nsurfaceAlbedo*=vAlbedoInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nsurfaceAlbedo*=vColor.rgb;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_ALBEDO\n\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nalpha=getLuminance(opacityMap.rgb);\n#else\nalpha*=opacityMap.a;\n#endif\nalpha*=vOpacityInfos.y;\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#if !defined(LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_ALPHA\n#include<depthPrePass>\n#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\n\nvec3 ambientOcclusionColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nvec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#ifdef AMBIENTINGRAYSCALE\nambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);\n#endif\nambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);\n#endif\n#ifdef UNLIT\nvec3 diffuseBase=vec3(1.,1.,1.);\n#else\n\nfloat microSurface=vReflectivityColor.a;\nvec3 surfaceReflectivityColor=vReflectivityColor.rgb;\n#ifdef METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef REFLECTIVITY\nvec4 surfaceMetallicColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\n#ifdef AOSTOREINMETALMAPRED\nvec3 aoStoreInMetalMap=vec3(surfaceMetallicColorMap.r,surfaceMetallicColorMap.r,surfaceMetallicColorMap.r);\nambientOcclusionColor=mix(ambientOcclusionColor,aoStoreInMetalMap,vReflectivityInfos.z);\n#endif\n#ifdef METALLNESSSTOREINMETALMAPBLUE\nmetallicRoughness.r*=surfaceMetallicColorMap.b;\n#else\nmetallicRoughness.r*=surfaceMetallicColorMap.r;\n#endif\n#ifdef ROUGHNESSSTOREINMETALMAPALPHA\nmetallicRoughness.g*=surfaceMetallicColorMap.a;\n#else\n#ifdef ROUGHNESSSTOREINMETALMAPGREEN\nmetallicRoughness.g*=surfaceMetallicColorMap.g;\n#endif\n#endif\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmetallicRoughness.g*=microSurfaceTexel.r;\n#endif\n\nmicroSurface=1.0-metallicRoughness.g;\n\nvec3 baseColor=surfaceAlbedo;\n#ifdef REFLECTANCE\n\n\n\n\n\nsurfaceAlbedo=baseColor.rgb*(1.0-metallicRoughness.r);\n\nsurfaceReflectivityColor=mix(0.16*reflectance*reflectance,baseColor,metallicRoughness.r);\n#else\n\n\n\nconst vec3 DefaultSpecularReflectanceDielectric=vec3(0.04,0.04,0.04);\n\nsurfaceAlbedo=mix(baseColor.rgb*(1.0-DefaultSpecularReflectanceDielectric.r),vec3(0.,0.,0.),metallicRoughness.r);\n\nsurfaceReflectivityColor=mix(DefaultSpecularReflectanceDielectric,baseColor,metallicRoughness.r);\n#endif\n#else\n#ifdef REFLECTIVITY\nvec4 surfaceReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\nsurfaceReflectivityColor*=toLinearSpace(surfaceReflectivityColorMap.rgb);\nsurfaceReflectivityColor*=vReflectivityInfos.y;\n#ifdef MICROSURFACEFROMREFLECTIVITYMAP\nmicroSurface*=surfaceReflectivityColorMap.a;\nmicroSurface*=vReflectivityInfos.z;\n#else\n#ifdef MICROSURFACEAUTOMATIC\nmicroSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmicroSurface*=microSurfaceTexel.r;\n#endif\n#endif\n#endif\n#endif\n\nmicroSurface=saturate(microSurface);\n\nfloat roughness=1.-microSurface;\n\n#ifdef ALPHAFRESNEL\n#if defined(ALPHATEST) || defined(ALPHABLEND)\n\n\n\nfloat opacityPerceptual=alpha;\n#ifdef LINEARALPHAFRESNEL\nfloat opacity0=opacityPerceptual;\n#else\nfloat opacity0=opacityPerceptual*opacityPerceptual;\n#endif\nfloat opacity90=fresnelGrazingReflectance(opacity0);\nvec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);\n\nalpha=getReflectanceFromAnalyticalBRDFLookup_Jones(saturate(dot(viewDirectionW,normalForward)),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#endif\n\nfloat NdotVUnclamped=dot(normalW,viewDirectionW);\n\nfloat NdotV=absEps(NdotVUnclamped);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nvec2 AARoughnessFactors=getAARoughnessFactors(normalW.xyz);\n#ifdef SPECULARAA\n\nalphaG+=AARoughnessFactors.y;\n#endif\n#ifdef ANISOTROPIC\nfloat anisotropy=vAnisotropy.b;\nvec3 anisotropyDirection=vec3(vAnisotropy.xy,0.);\n#ifdef ANISOTROPIC_TEXTURE\nvec3 anisotropyMapData=texture2D(anisotropySampler,vAnisotropyUV+uvOffset).rgb*vAnisotropyInfos.y;\nanisotropy*=anisotropyMapData.b;\nanisotropyDirection.rg*=anisotropyMapData.rg*2.0-1.0;\n#endif\nmat3 anisoTBN=mat3(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));\nvec3 anisotropicTangent=normalize(anisoTBN*anisotropyDirection);\nvec3 anisotropicBitangent=normalize(cross(anisoTBN[2],anisotropicTangent));\nvec3 anisotropicNormal=getAnisotropicBentNormals(anisotropicTangent,anisotropicBitangent,normalW,viewDirectionW,anisotropy);\n#endif\n\n#ifdef REFRACTION\nvec4 environmentRefraction=vec4(0.,0.,0.,0.);\n#ifdef ANISOTROPIC\nvec3 refractionVector=refract(-viewDirectionW,anisotropicNormal,vRefractionInfos.y);\n#else\nvec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);\n#endif\n#ifdef REFRACTIONMAP_OPPOSITEZ\nrefractionVector.z*=-1.0;\n#endif\n\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nvec3 refractionCoords=refractionVector;\nrefractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\n#endif\n#ifdef LODINREFRACTIONALPHA\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nrefractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;\n#ifdef LODINREFRACTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);\nfloat requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);\n#else\nfloat requestedRefractionLOD=refractionLOD;\n#endif\nenvironmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD);\n#else\nfloat lodRefractionNormalized=saturate(refractionLOD/log2(vRefractionMicrosurfaceInfos.x));\nfloat lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;\nvec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords);\nif(lodRefractionNormalizedDoubled<1.0){\nenvironmentRefraction=mix(\nsampleRefraction(refractionSamplerHigh,refractionCoords),\nenvironmentRefractionMid,\nlodRefractionNormalizedDoubled\n);\n}else{\nenvironmentRefraction=mix(\nenvironmentRefractionMid,\nsampleRefraction(refractionSamplerLow,refractionCoords),\nlodRefractionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFRACTION\nenvironmentRefraction.rgb=fromRGBD(environmentRefraction);\n#endif\n#ifdef GAMMAREFRACTION\nenvironmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb);\n#endif\n\nenvironmentRefraction.rgb*=vRefractionInfos.x;\n#endif\n\n#ifdef REFLECTION\nvec4 environmentRadiance=vec4(0.,0.,0.,0.);\nvec3 environmentIrradiance=vec3(0.,0.,0.);\n#ifdef ANISOTROPIC\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),anisotropicNormal);\n#else\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#endif\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nreflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\n#ifdef LODINREFLECTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);\nfloat requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);\n#else\nfloat requestedReflectionLOD=reflectionLOD;\n#endif\nenvironmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,requestedReflectionLOD);\n#else\nfloat lodReflectionNormalized=saturate(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x));\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 environmentSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodReflectionNormalizedDoubled<1.0){\nenvironmentRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nenvironmentSpecularMid,\nlodReflectionNormalizedDoubled\n);\n}else{\nenvironmentRadiance=mix(\nenvironmentSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentRadiance.rgb=fromRGBD(environmentRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);\n#endif\n\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nenvironmentIrradiance=vEnvironmentIrradiance;\n#else\n#ifdef ANISOTROPIC\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(anisotropicNormal,0)).xyz;\n#else\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\n#endif\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;\n#endif\nenvironmentIrradiance=environmentIrradianceJones(irradianceVector);\n#endif\n#endif\n\nenvironmentRadiance.rgb*=vReflectionInfos.x;\nenvironmentRadiance.rgb*=vReflectionColor.rgb;\nenvironmentIrradiance*=vReflectionColor.rgb;\n#endif\n\nfloat reflectance=max(max(surfaceReflectivityColor.r,surfaceReflectivityColor.g),surfaceReflectivityColor.b);\nfloat reflectance90=fresnelGrazingReflectance(reflectance);\nvec3 specularEnvironmentR0=surfaceReflectivityColor.rgb;\nvec3 specularEnvironmentR90=vec3(1.0,1.0,1.0)*reflectance90;\n\n#ifdef SHEEN\nfloat sheenIntensity=vSheenColor.a;\n#ifdef SHEEN_TEXTURE\nvec4 sheenMapData=texture2D(sheenSampler,vSheenUV+uvOffset)*vSheenInfos.y;\nsheenIntensity*=sheenMapData.a;\n#endif\n#ifdef SHEEN_LINKWITHALBEDO\nfloat sheenFactor=pow5(1.0-sheenIntensity);\nvec3 sheenColor=baseColor.rgb*(1.0-sheenFactor);\nfloat sheenRoughness=sheenIntensity;\n\nsurfaceAlbedo.rgb*=sheenFactor;\n#else\nvec3 sheenColor=vSheenColor.rgb;\n#ifdef SHEEN_TEXTURE\nsheenColor.rgb*=toLinearSpace(sheenMapData.rgb);\n#endif\nfloat sheenRoughness=roughness;\n\nsheenIntensity*=(1.-reflectance);\n\nsheenColor*=sheenIntensity;\n#endif\n\n#if defined(REFLECTION)\nfloat sheenAlphaG=convertRoughnessToAverageSlope(sheenRoughness);\n#ifdef SPECULARAA\n\nsheenAlphaG+=AARoughnessFactors.y;\n#endif\nvec4 environmentSheenRadiance=vec4(0.,0.,0.,0.);\n\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat sheenReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,sheenAlphaG,NdotVUnclamped);\n#else\nfloat sheenReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,sheenAlphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nsheenReflectionLOD=sheenReflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nenvironmentSheenRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,sheenReflectionLOD);\n#else\nfloat lodSheenReflectionNormalized=saturate(sheenReflectionLOD/log2(vReflectionMicrosurfaceInfos.x));\nfloat lodSheenReflectionNormalizedDoubled=lodSheenReflectionNormalized*2.0;\nvec4 environmentSheenMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodSheenReflectionNormalizedDoubled<1.0){\nenvironmentSheenRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nenvironmentSheenMid,\nlodSheenReflectionNormalizedDoubled\n);\n}else{\nenvironmentSheenRadiance=mix(\nenvironmentSheenMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodSheenReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentSheenRadiance.rgb=fromRGBD(environmentSheenRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentSheenRadiance.rgb=toLinearSpace(environmentSheenRadiance.rgb);\n#endif\n\nenvironmentSheenRadiance.rgb*=vReflectionInfos.x;\nenvironmentSheenRadiance.rgb*=vReflectionColor.rgb;\n#endif\n#endif\n\n#ifdef CLEARCOAT\n\nfloat clearCoatIntensity=vClearCoatParams.x;\nfloat clearCoatRoughness=vClearCoatParams.y;\n#ifdef CLEARCOAT_TEXTURE\nvec2 clearCoatMapData=texture2D(clearCoatSampler,vClearCoatUV+uvOffset).rg*vClearCoatInfos.y;\nclearCoatIntensity*=clearCoatMapData.x;\nclearCoatRoughness*=clearCoatMapData.y;\n#endif\n#ifdef CLEARCOAT_TINT\nvec3 clearCoatColor=vClearCoatTintParams.rgb;\nfloat clearCoatThickness=vClearCoatTintParams.a;\n#ifdef CLEARCOAT_TINT_TEXTURE\nvec4 clearCoatTintMapData=texture2D(clearCoatTintSampler,vClearCoatTintUV+uvOffset);\nclearCoatColor*=toLinearSpace(clearCoatTintMapData.rgb);\nclearCoatThickness*=clearCoatTintMapData.a;\n#endif\nclearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance);\n#endif\n\n\n\n\nvec3 specularEnvironmentR0Updated=getR0RemappedForClearCoat(specularEnvironmentR0);\nspecularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity);\n#ifdef CLEARCOAT_BUMP\n#ifdef NORMALXYSCALE\nfloat clearCoatNormalScale=1.0;\n#else\nfloat clearCoatNormalScale=vClearCoatBumpInfos.y;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBNClearCoat=vTBN;\n#else\nmat3 TBNClearCoat=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,vClearCoatBumpUV,vClearCoatTangentSpaceParams);\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nclearCoatNormalW=normalize(texture2D(clearCoatBumpSampler,vClearCoatBumpUV+uvOffset).xyz*2.0-1.0);\nclearCoatNormalW=normalize(mat3(normalMatrix)*clearCoatNormalW);\n#else\nclearCoatNormalW=perturbNormal(TBN,vClearCoatBumpUV+uvOffset,clearCoatBumpSampler,vClearCoatBumpInfos.y);\n#endif\n#endif\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nclearCoatNormalW*=sign(dot(clearCoatNormalW,faceNormal));\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nclearCoatNormalW=gl_FrontFacing ? clearCoatNormalW : -clearCoatNormalW;\n#endif\n\nvec2 clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz);\n\nfloat clearCoatNdotVUnclamped=dot(clearCoatNormalW,viewDirectionW);\n\nfloat clearCoatNdotV=absEps(clearCoatNdotVUnclamped);\n\n#if defined(REFLECTION)\nfloat clearCoatAlphaG=convertRoughnessToAverageSlope(clearCoatRoughness);\n#ifdef SPECULARAA\n\nclearCoatAlphaG+=clearCoatAARoughnessFactors.y;\n#endif\nvec4 environmentClearCoatRadiance=vec4(0.,0.,0.,0.);\nvec3 clearCoatReflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),clearCoatNormalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nclearCoatReflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 clearCoatReflectionCoords=clearCoatReflectionVector;\n#else\nvec2 clearCoatReflectionCoords=clearCoatReflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nclearCoatReflectionCoords/=clearCoatReflectionVector.z;\n#endif\nclearCoatReflectionCoords.y=1.0-clearCoatReflectionCoords.y;\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat clearCoatReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,clearCoatAlphaG,clearCoatNdotVUnclamped);\n#else\nfloat clearCoatReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,clearCoatAlphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nclearCoatReflectionLOD=clearCoatReflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nfloat requestedClearCoatReflectionLOD=clearCoatReflectionLOD;\nenvironmentClearCoatRadiance=sampleReflectionLod(reflectionSampler,clearCoatReflectionCoords,requestedClearCoatReflectionLOD);\n#else\nfloat lodClearCoatReflectionNormalized=saturate(clearCoatReflectionLOD/log2(vReflectionMicrosurfaceInfos.x));\nfloat lodClearCoatReflectionNormalizedDoubled=lodClearCoatReflectionNormalized*2.0;\nvec4 environmentClearCoatMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodClearCoatReflectionNormalizedDoubled<1.0){\nenvironmentClearCoatRadiance=mix(\nsampleReflection(reflectionSamplerHigh,clearCoatReflectionCoords),\nenvironmentClearCoatMid,\nlodClearCoatReflectionNormalizedDoubled\n);\n}else{\nenvironmentClearCoatRadiance=mix(\nenvironmentClearCoatMid,\nsampleReflection(reflectionSamplerLow,clearCoatReflectionCoords),\nlodClearCoatReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentClearCoatRadiance.rgb=fromRGBD(environmentClearCoatRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentClearCoatRadiance.rgb=toLinearSpace(environmentClearCoatRadiance.rgb);\n#endif\n#ifdef CLEARCOAT_TINT\n\nvec3 clearCoatVRefract=-refract(vPositionW,clearCoatNormalW,vClearCoatRefractionParams.y);\n\nfloat clearCoatNdotVRefract=absEps(dot(clearCoatNormalW,clearCoatVRefract));\nvec3 absorption=vec3(0.);\n#endif\n\nenvironmentClearCoatRadiance.rgb*=vReflectionInfos.x;\nenvironmentClearCoatRadiance.rgb*=vReflectionColor.rgb;\n#endif\n#endif\n\n#if defined(ENVIRONMENTBRDF)\n\nvec3 environmentBrdf=getBRDFLookup(NdotV,roughness,environmentBrdfSampler);\n#ifdef MS_BRDF_ENERGY_CONSERVATION\nvec3 energyConservationFactor=getEnergyConservationFactor(specularEnvironmentR0,environmentBrdf);\n#endif\n#endif\n\n\nvec3 diffuseBase=vec3(0.,0.,0.);\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#ifdef CLEARCOAT\nvec3 clearCoatBase=vec3(0.,0.,0.);\n#endif\n#ifdef SHEEN\nvec3 sheenBase=vec3(0.,0.,0.);\n#endif\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb;\n#ifdef GAMMALIGHTMAP\nlightmapColor=toLinearSpace(lightmapColor);\n#endif\nlightmapColor*=vLightmapInfos.y;\n#endif\n\npreLightingInfo preInfo;\nlightingInfo info;\nfloat shadow=1.;\n#include<lightFragment>[0..maxSimultaneousLights]\n\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\nvec3 specularEnvironmentReflectance=getReflectanceFromBRDFLookup(specularEnvironmentR0,environmentBrdf);\n#ifdef RADIANCEOCCLUSION\n#ifdef AMBIENTINGRAYSCALE\nfloat ambientMonochrome=ambientOcclusionColor.r;\n#else\nfloat ambientMonochrome=getLuminance(ambientOcclusionColor);\n#endif\nfloat seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);\nspecularEnvironmentReflectance*=seo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat eho=environmentHorizonOcclusion(-viewDirectionW,normalW);\nspecularEnvironmentReflectance*=eho;\n#endif\n#endif\n#endif\n#else\n\nvec3 specularEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\n#endif\n\n#if defined(SHEEN) && defined(REFLECTION)\nvec3 sheenEnvironmentReflectance=getSheenReflectanceFromBRDFLookup(sheenColor,environmentBrdf);\n#ifdef RADIANCEOCCLUSION\nsheenEnvironmentReflectance*=seo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nsheenEnvironmentReflectance*=eho;\n#endif\n#endif\n#endif\n#endif\n\n#ifdef CLEARCOAT\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n\nvec3 environmentClearCoatBrdf=getBRDFLookup(clearCoatNdotV,clearCoatRoughness,environmentBrdfSampler);\nvec3 clearCoatEnvironmentReflectance=getReflectanceFromBRDFLookup(vec3(vClearCoatRefractionParams.x),environmentClearCoatBrdf);\n#ifdef RADIANCEOCCLUSION\nfloat clearCoatSeo=environmentRadianceOcclusion(ambientMonochrome,clearCoatNdotVUnclamped);\nclearCoatEnvironmentReflectance*=clearCoatSeo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat clearCoatEho=environmentHorizonOcclusion(-viewDirectionW,clearCoatNormalW);\nclearCoatEnvironmentReflectance*=clearCoatEho;\n#endif\n#endif\n#endif\n#else\n\nvec3 clearCoatEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(clearCoatNdotV,vec3(1.),vec3(1.),sqrt(1.-clearCoatRoughness));\n#endif\nclearCoatEnvironmentReflectance*=clearCoatIntensity;\n#ifdef CLEARCOAT_TINT\n\nabsorption=computeClearCoatAbsorption(clearCoatNdotVRefract,clearCoatNdotVRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);\n#ifdef REFLECTION\nenvironmentIrradiance*=absorption;\n#endif\n#ifdef SHEEN\nsheenEnvironmentReflectance*=absorption;\n#endif\nspecularEnvironmentReflectance*=absorption;\n#endif\n\nfloat fresnelIBLClearCoat=fresnelSchlickGGX(clearCoatNdotV,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);\nfresnelIBLClearCoat*=clearCoatIntensity;\nfloat conservationFactor=(1.-fresnelIBLClearCoat);\n#ifdef REFLECTION\nenvironmentIrradiance*=conservationFactor;\n#endif\n#ifdef SHEEN\nsheenEnvironmentReflectance*=(conservationFactor*conservationFactor);\n#endif\nspecularEnvironmentReflectance*=(conservationFactor*conservationFactor);\n#endif\n\n#ifdef REFRACTION\nvec3 refractance=vec3(0.0,0.0,0.0);\nvec3 transmission=vec3(1.0,1.0,1.0);\n#ifdef LINKREFRACTIONTOTRANSPARENCY\n\ntransmission*=(1.0-alpha);\n\n\nvec3 mixedAlbedo=surfaceAlbedo;\nfloat maxChannel=max(max(mixedAlbedo.r,mixedAlbedo.g),mixedAlbedo.b);\nvec3 tint=saturate(maxChannel*mixedAlbedo);\n\nsurfaceAlbedo*=alpha;\n\nenvironmentIrradiance*=alpha;\n\nenvironmentRefraction.rgb*=tint;\n\nalpha=1.0;\n#endif\n\nvec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);\nspecularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,alpha);\n\ntransmission*=1.0-specularEnvironmentReflectance;\n\nrefractance=transmission;\n#endif\n\n\n\n#ifndef METALLICWORKFLOW\nsurfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;\n#endif\n\n#ifdef REFLECTION\nvec3 finalIrradiance=environmentIrradiance;\nfinalIrradiance*=surfaceAlbedo.rgb;\n#endif\n\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase;\nfinalSpecular=max(finalSpecular,0.0);\n\nvec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalSpecularScaled*=energyConservationFactor;\n#endif\n#endif\n\n#ifdef REFLECTION\nvec3 finalRadiance=environmentRadiance.rgb;\nfinalRadiance*=specularEnvironmentReflectance;\n\nvec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalRadianceScaled*=energyConservationFactor;\n#endif\n#endif\n\n#ifdef REFRACTION\nvec3 finalRefraction=environmentRefraction.rgb;\nfinalRefraction*=refractance;\n#endif\n\n#ifdef CLEARCOAT\nvec3 finalClearCoat=clearCoatBase;\nfinalClearCoat=max(finalClearCoat,0.0);\n\nvec3 finalClearCoatScaled=finalClearCoat*vLightingIntensity.x*vLightingIntensity.w;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalClearCoatScaled*=energyConservationFactor;\n#endif\n\n#ifdef REFLECTION\nvec3 finalClearCoatRadiance=environmentClearCoatRadiance.rgb;\nfinalClearCoatRadiance*=clearCoatEnvironmentReflectance;\n\nvec3 finalClearCoatRadianceScaled=finalClearCoatRadiance*vLightingIntensity.z;\n#endif\n#ifdef REFRACTION\nfinalRefraction*=(conservationFactor*conservationFactor);\n#ifdef CLEARCOAT_TINT\nfinalRefraction*=absorption;\n#endif\n#endif\n#endif\n\n#ifdef SHEEN\nvec3 finalSheen=sheenBase*sheenColor;\nfinalSheen=max(finalSheen,0.0);\nvec3 finalSheenScaled=finalSheen*vLightingIntensity.x*vLightingIntensity.w;\n\n\n\n\n\n#ifdef REFLECTION\nvec3 finalSheenRadiance=environmentSheenRadiance.rgb;\nfinalSheenRadiance*=sheenEnvironmentReflectance;\n\nvec3 finalSheenRadianceScaled=finalSheenRadiance*vLightingIntensity.z;\n#endif\n#endif\n\n#ifdef ALPHABLEND\nfloat luminanceOverAlpha=0.0;\n#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalRadianceScaled);\n#if defined(CLEARCOAT)\nluminanceOverAlpha+=getLuminance(finalClearCoatRadianceScaled);\n#endif\n#endif\n#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)\nluminanceOverAlpha+=getLuminance(finalSpecularScaled);\n#endif\n#if defined(CLEARCOAT) && defined(CLEARCOATOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalClearCoatScaled);\n#endif\n#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA)\nalpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha);\n#endif\n#endif\n#endif\n\n\nvec3 finalDiffuse=diffuseBase;\nfinalDiffuse*=surfaceAlbedo.rgb;\nfinalDiffuse=max(finalDiffuse,0.0);\n\nvec3 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#define CUSTOM_FRAGMENT_BEFORE_FOG\n\nfinalColor=max(finalColor,0.0);\n#include<logDepthFragment>\n#include<fogFragment>(color,finalColor)\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\nfinalColor.rgb=clamp(finalColor.rgb,0.,30.0);\n#else\n\nfinalColor=applyImageProcessing(finalColor);\n#endif\nfinalColor.a*=visibility;\n#ifdef PREMULTIPLYALPHA\n\nfinalColor.rgb*=finalColor.a;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\ngl_FragColor=finalColor;\n#include<pbrDebug>\n}\n";
  129971. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129972. /** @hidden */
  129973. var pbrPixelShader = { name: name, shader: shader };
  129974. /***/ }),
  129975. /***/ "./Shaders/pbr.vertex.ts":
  129976. /*!*******************************!*\
  129977. !*** ./Shaders/pbr.vertex.ts ***!
  129978. \*******************************/
  129979. /*! exports provided: pbrVertexShader */
  129980. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129981. "use strict";
  129982. __webpack_require__.r(__webpack_exports__);
  129983. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexShader", function() { return pbrVertexShader; });
  129984. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129985. /* harmony import */ var _ShadersInclude_pbrVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrVertexDeclaration */ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts");
  129986. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  129987. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  129988. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  129989. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  129990. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  129991. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  129992. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  129993. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  129994. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  129995. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  129996. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  129997. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  129998. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  129999. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  130000. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  130001. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  130002. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  130003. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  130004. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  130005. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  130006. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  130007. var name = 'pbrVertexShader';
  130008. var shader = "precision highp float;\n#include<__decl__pbrVertex>\n#define CUSTOM_VERTEX_BEGIN\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nvarying vec2 vAlbedoUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nvarying vec2 vReflectivityUV;\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n#ifdef CLEARCOAT\n#if defined(CLEARCOAT_TEXTURE) && CLEARCOAT_TEXTUREDIRECTUV == 0\nvarying vec2 vClearCoatUV;\n#endif\n#if defined(CLEARCOAT_BUMP) && CLEARCOAT_BUMPDIRECTUV == 0\nvarying vec2 vClearCoatBumpUV;\n#endif\n#if defined(CLEARCOAT_TINT_TEXTURE) && CLEARCOAT_TINT_TEXTUREDIRECTUV == 0\nvarying vec2 vClearCoatTintUV;\n#endif\n#endif\n#ifdef SHEEN\n#if defined(SHEEN_TEXTURE) && SHEEN_TEXTUREDIRECTUV == 0\nvarying vec2 vSheenUV;\n#endif\n#endif\n#ifdef ANISOTROPIC\n#if defined(ANISOTROPIC_TEXTURE) && ANISOTROPIC_TEXTUREDIRECTUV == 0\nvarying vec2 vAnisotropyUV;\n#endif\n#endif\n\nvarying vec3 vPositionW;\n#if DEBUGMODE>0\nvarying vec4 vClipSpacePosition;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#include<harmonicsFunctions>\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(positionUpdated,1.0)).xyz;\n#else\nvPositionUVW=positionUpdated;\n#endif\n#endif\n#define CUSTOM_VERTEX_UPDATE_POSITION\n#define CUSTOM_VERTEX_UPDATE_NORMAL\n#include<instancesVertex>\n#include<bonesVertex>\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR == 0u) {\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n} else {\ngl_Position=viewProjectionR*finalWorld*vec4(positionUpdated,1.0);\n}\n#else\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#endif\n#if DEBUGMODE>0\nvClipSpacePosition=gl_Position;\n#endif\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\nvEnvironmentIrradiance=environmentIrradianceJones(reflectionVector);\n#endif\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nif (vAlbedoInfos.x == 0.)\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nif (vReflectivityInfos.x == 0.)\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nif (vMicroSurfaceSamplerInfos.x == 0.)\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef CLEARCOAT\n#if defined(CLEARCOAT_TEXTURE) && CLEARCOAT_TEXTUREDIRECTUV == 0\nif (vClearCoatInfos.x == 0.)\n{\nvClearCoatUV=vec2(clearCoatMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvClearCoatUV=vec2(clearCoatMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(CLEARCOAT_BUMP) && CLEARCOAT_BUMPDIRECTUV == 0\nif (vClearCoatBumpInfos.x == 0.)\n{\nvClearCoatBumpUV=vec2(clearCoatBumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvClearCoatBumpUV=vec2(clearCoatBumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(CLEARCOAT_TINT_TEXTURE) && CLEARCOAT_TINT_TEXTUREDIRECTUV == 0\nif (vClearCoatTintInfos.x == 0.)\n{\nvClearCoatTintUV=vec2(clearCoatTintMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvClearCoatTintUV=vec2(clearCoatTintMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#endif\n#ifdef SHEEN\n#if defined(SHEEN_TEXTURE) && SHEEN_TEXTUREDIRECTUV == 0\nif (vSheenInfos.x == 0.)\n{\nvSheenUV=vec2(sheenMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvSheenUV=vec2(sheenMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#endif\n#ifdef ANISOTROPIC\n#if defined(ANISOTROPIC_TEXTURE) && ANISOTROPIC_TEXTUREDIRECTUV == 0\nif (vAnisotropyInfos.x == 0.)\n{\nvAnisotropyUV=vec2(anisotropyMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAnisotropyUV=vec2(anisotropyMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#endif\n\n#include<bumpVertex>\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n\n#include<logDepthVertex>\n#define CUSTOM_VERTEX_MAIN_END\n}";
  130009. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130010. /** @hidden */
  130011. var pbrVertexShader = { name: name, shader: shader };
  130012. /***/ }),
  130013. /***/ "./Shaders/postprocess.vertex.ts":
  130014. /*!***************************************!*\
  130015. !*** ./Shaders/postprocess.vertex.ts ***!
  130016. \***************************************/
  130017. /*! exports provided: postprocessVertexShader */
  130018. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130019. "use strict";
  130020. __webpack_require__.r(__webpack_exports__);
  130021. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "postprocessVertexShader", function() { return postprocessVertexShader; });
  130022. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130023. var name = 'postprocessVertexShader';
  130024. 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}";
  130025. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130026. /** @hidden */
  130027. var postprocessVertexShader = { name: name, shader: shader };
  130028. /***/ }),
  130029. /***/ "./Shaders/procedural.vertex.ts":
  130030. /*!**************************************!*\
  130031. !*** ./Shaders/procedural.vertex.ts ***!
  130032. \**************************************/
  130033. /*! exports provided: proceduralVertexShader */
  130034. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130035. "use strict";
  130036. __webpack_require__.r(__webpack_exports__);
  130037. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "proceduralVertexShader", function() { return proceduralVertexShader; });
  130038. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130039. var name = 'proceduralVertexShader';
  130040. 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}";
  130041. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130042. /** @hidden */
  130043. var proceduralVertexShader = { name: name, shader: shader };
  130044. /***/ }),
  130045. /***/ "./Shaders/refraction.fragment.ts":
  130046. /*!****************************************!*\
  130047. !*** ./Shaders/refraction.fragment.ts ***!
  130048. \****************************************/
  130049. /*! exports provided: refractionPixelShader */
  130050. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130051. "use strict";
  130052. __webpack_require__.r(__webpack_exports__);
  130053. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "refractionPixelShader", function() { return refractionPixelShader; });
  130054. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130055. var name = 'refractionPixelShader';
  130056. 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}";
  130057. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130058. /** @hidden */
  130059. var refractionPixelShader = { name: name, shader: shader };
  130060. /***/ }),
  130061. /***/ "./Shaders/rgbdDecode.fragment.ts":
  130062. /*!****************************************!*\
  130063. !*** ./Shaders/rgbdDecode.fragment.ts ***!
  130064. \****************************************/
  130065. /*! exports provided: rgbdDecodePixelShader */
  130066. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130067. "use strict";
  130068. __webpack_require__.r(__webpack_exports__);
  130069. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdDecodePixelShader", function() { return rgbdDecodePixelShader; });
  130070. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130071. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130072. var name = 'rgbdDecodePixelShader';
  130073. 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}";
  130074. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130075. /** @hidden */
  130076. var rgbdDecodePixelShader = { name: name, shader: shader };
  130077. /***/ }),
  130078. /***/ "./Shaders/rgbdEncode.fragment.ts":
  130079. /*!****************************************!*\
  130080. !*** ./Shaders/rgbdEncode.fragment.ts ***!
  130081. \****************************************/
  130082. /*! exports provided: rgbdEncodePixelShader */
  130083. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130084. "use strict";
  130085. __webpack_require__.r(__webpack_exports__);
  130086. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdEncodePixelShader", function() { return rgbdEncodePixelShader; });
  130087. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130088. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130089. var name = 'rgbdEncodePixelShader';
  130090. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void)\n{\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\n}";
  130091. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130092. /** @hidden */
  130093. var rgbdEncodePixelShader = { name: name, shader: shader };
  130094. /***/ }),
  130095. /***/ "./Shaders/shadowMap.fragment.ts":
  130096. /*!***************************************!*\
  130097. !*** ./Shaders/shadowMap.fragment.ts ***!
  130098. \***************************************/
  130099. /*! exports provided: shadowMapPixelShader */
  130100. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130101. "use strict";
  130102. __webpack_require__.r(__webpack_exports__);
  130103. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapPixelShader", function() { return shadowMapPixelShader; });
  130104. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130105. var name = 'shadowMapPixelShader';
  130106. 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}";
  130107. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130108. /** @hidden */
  130109. var shadowMapPixelShader = { name: name, shader: shader };
  130110. /***/ }),
  130111. /***/ "./Shaders/shadowMap.vertex.ts":
  130112. /*!*************************************!*\
  130113. !*** ./Shaders/shadowMap.vertex.ts ***!
  130114. \*************************************/
  130115. /*! exports provided: shadowMapVertexShader */
  130116. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130117. "use strict";
  130118. __webpack_require__.r(__webpack_exports__);
  130119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapVertexShader", function() { return shadowMapVertexShader; });
  130120. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130121. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  130122. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  130123. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  130124. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  130125. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130126. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  130127. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  130128. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  130129. var name = 'shadowMapVertexShader';
  130130. 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}";
  130131. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130132. /** @hidden */
  130133. var shadowMapVertexShader = { name: name, shader: shader };
  130134. /***/ }),
  130135. /***/ "./Shaders/sharpen.fragment.ts":
  130136. /*!*************************************!*\
  130137. !*** ./Shaders/sharpen.fragment.ts ***!
  130138. \*************************************/
  130139. /*! exports provided: sharpenPixelShader */
  130140. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130141. "use strict";
  130142. __webpack_require__.r(__webpack_exports__);
  130143. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sharpenPixelShader", function() { return sharpenPixelShader; });
  130144. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130145. var name = 'sharpenPixelShader';
  130146. 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}";
  130147. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130148. /** @hidden */
  130149. var sharpenPixelShader = { name: name, shader: shader };
  130150. /***/ }),
  130151. /***/ "./Shaders/sprites.fragment.ts":
  130152. /*!*************************************!*\
  130153. !*** ./Shaders/sprites.fragment.ts ***!
  130154. \*************************************/
  130155. /*! exports provided: spritesPixelShader */
  130156. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130157. "use strict";
  130158. __webpack_require__.r(__webpack_exports__);
  130159. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesPixelShader", function() { return spritesPixelShader; });
  130160. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130161. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  130162. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  130163. var name = 'spritesPixelShader';
  130164. 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}";
  130165. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130166. /** @hidden */
  130167. var spritesPixelShader = { name: name, shader: shader };
  130168. /***/ }),
  130169. /***/ "./Shaders/sprites.vertex.ts":
  130170. /*!***********************************!*\
  130171. !*** ./Shaders/sprites.vertex.ts ***!
  130172. \***********************************/
  130173. /*! exports provided: spritesVertexShader */
  130174. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130175. "use strict";
  130176. __webpack_require__.r(__webpack_exports__);
  130177. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesVertexShader", function() { return spritesVertexShader; });
  130178. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130179. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  130180. var name = 'spritesVertexShader';
  130181. 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}";
  130182. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130183. /** @hidden */
  130184. var spritesVertexShader = { name: name, shader: shader };
  130185. /***/ }),
  130186. /***/ "./Shaders/ssao.fragment.ts":
  130187. /*!**********************************!*\
  130188. !*** ./Shaders/ssao.fragment.ts ***!
  130189. \**********************************/
  130190. /*! exports provided: ssaoPixelShader */
  130191. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130192. "use strict";
  130193. __webpack_require__.r(__webpack_exports__);
  130194. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoPixelShader", function() { return ssaoPixelShader; });
  130195. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130196. var name = 'ssaoPixelShader';
  130197. 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";
  130198. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130199. /** @hidden */
  130200. var ssaoPixelShader = { name: name, shader: shader };
  130201. /***/ }),
  130202. /***/ "./Shaders/ssao2.fragment.ts":
  130203. /*!***********************************!*\
  130204. !*** ./Shaders/ssao2.fragment.ts ***!
  130205. \***********************************/
  130206. /*! exports provided: ssao2PixelShader */
  130207. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130208. "use strict";
  130209. __webpack_require__.r(__webpack_exports__);
  130210. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssao2PixelShader", function() { return ssao2PixelShader; });
  130211. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130212. var name = 'ssao2PixelShader';
  130213. 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";
  130214. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130215. /** @hidden */
  130216. var ssao2PixelShader = { name: name, shader: shader };
  130217. /***/ }),
  130218. /***/ "./Shaders/ssaoCombine.fragment.ts":
  130219. /*!*****************************************!*\
  130220. !*** ./Shaders/ssaoCombine.fragment.ts ***!
  130221. \*****************************************/
  130222. /*! exports provided: ssaoCombinePixelShader */
  130223. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130224. "use strict";
  130225. __webpack_require__.r(__webpack_exports__);
  130226. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoCombinePixelShader", function() { return ssaoCombinePixelShader; });
  130227. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130228. var name = 'ssaoCombinePixelShader';
  130229. 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";
  130230. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130231. /** @hidden */
  130232. var ssaoCombinePixelShader = { name: name, shader: shader };
  130233. /***/ }),
  130234. /***/ "./Shaders/standard.fragment.ts":
  130235. /*!**************************************!*\
  130236. !*** ./Shaders/standard.fragment.ts ***!
  130237. \**************************************/
  130238. /*! exports provided: standardPixelShader */
  130239. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130240. "use strict";
  130241. __webpack_require__.r(__webpack_exports__);
  130242. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "standardPixelShader", function() { return standardPixelShader; });
  130243. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130244. var name = 'standardPixelShader';
  130245. var shader = "uniform sampler2D textureSampler;\nvarying vec2 vUV;\n#if defined(PASS_POST_PROCESS)\nvoid main(void)\n{\nvec4 color=texture2D(textureSampler,vUV);\ngl_FragColor=color;\n}\n#endif\n#if defined(DOWN_SAMPLE_X4)\nuniform vec2 dsOffsets[16];\nvoid main(void)\n{\nvec4 average=vec4(0.0,0.0,0.0,0.0);\naverage=texture2D(textureSampler,vUV+dsOffsets[0]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[1]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[2]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[3]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[4]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[5]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[6]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[7]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[8]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[9]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[10]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[11]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[12]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[13]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[14]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[15]);\naverage/=16.0;\ngl_FragColor=average;\n}\n#endif\n#if defined(BRIGHT_PASS)\nuniform vec2 dsOffsets[4];\nuniform float brightThreshold;\nvoid main(void)\n{\nvec4 average=vec4(0.0,0.0,0.0,0.0);\naverage=texture2D(textureSampler,vUV+vec2(dsOffsets[0].x,dsOffsets[0].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[1].x,dsOffsets[1].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[2].x,dsOffsets[2].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[3].x,dsOffsets[3].y));\naverage*=0.25;\nfloat luminance=length(average.rgb);\nif (luminance<brightThreshold) {\naverage=vec4(0.0,0.0,0.0,1.0);\n}\ngl_FragColor=average;\n}\n#endif\n#if defined(TEXTURE_ADDER)\nuniform sampler2D otherSampler;\nuniform sampler2D lensSampler;\nuniform float exposure;\nvoid main(void)\n{\nvec3 colour=texture2D(textureSampler,vUV).rgb;\ncolour*=exposure;\nvec3 X=max(vec3(0.0,0.0,0.0),colour-0.004);\nvec3 retColor=(X*(6.2*X+0.5))/(X*(6.2*X+1.7)+0.06);\ncolour=retColor*retColor;\ncolour+=colour*texture2D(lensSampler,vUV).rgb;\nvec4 finalColor=vec4(colour.rgb,1.0)+texture2D(otherSampler,vUV);\ngl_FragColor=finalColor;\n}\n#endif\n#if defined(VLS)\n#define PI 3.1415926535897932384626433832795\nuniform mat4 shadowViewProjection;\nuniform mat4 lightWorld;\nuniform vec3 cameraPosition;\nuniform vec3 sunDirection;\nuniform vec3 sunColor;\nuniform vec2 depthValues;\nuniform float scatteringCoefficient;\nuniform float scatteringPower;\nuniform sampler2D shadowMapSampler;\nuniform sampler2D positionSampler;\nfloat computeScattering(float lightDotView)\n{\nfloat result=1.0-scatteringCoefficient*scatteringCoefficient;\nresult/=(4.0*PI*pow(1.0+scatteringCoefficient*scatteringCoefficient-(2.0*scatteringCoefficient)*lightDotView,1.5));\nreturn result;\n}\nvoid main(void)\n{\n\nvec3 worldPos=texture2D(positionSampler,vUV).rgb;\nvec3 startPosition=cameraPosition;\nvec3 rayVector=worldPos-startPosition;\nfloat rayLength=length(rayVector);\nvec3 rayDirection=rayVector/rayLength;\nfloat stepLength=rayLength/NB_STEPS;\nvec3 stepL=rayDirection*stepLength;\nvec3 currentPosition=startPosition;\nvec3 accumFog=vec3(0.0);\nfor (int i=0; i<int(NB_STEPS); i++)\n{\nvec4 worldInShadowCameraSpace=shadowViewProjection*vec4(currentPosition,1.0);\nfloat depthMetric=(worldInShadowCameraSpace.z+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depthMetric,0.0,1.0);\nworldInShadowCameraSpace.xyz/=worldInShadowCameraSpace.w;\nworldInShadowCameraSpace.xyz=0.5*worldInShadowCameraSpace.xyz+vec3(0.5);\nfloat shadowMapValue=texture2D(shadowMapSampler,worldInShadowCameraSpace.xy).r;\nif (shadowMapValue>shadowPixelDepth)\naccumFog+=sunColor*computeScattering(dot(rayDirection,sunDirection));\ncurrentPosition+=stepL;\n}\naccumFog/=NB_STEPS;\nvec3 color=accumFog*scatteringPower;\ngl_FragColor=vec4(color*exp(color) ,1.0);\n}\n#endif\n#if defined(VLSMERGE)\nuniform sampler2D originalSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(originalSampler,vUV)+texture2D(textureSampler,vUV);\n}\n#endif\n#if defined(LUMINANCE)\nuniform vec2 lumOffsets[4];\nvoid main()\n{\nfloat average=0.0;\nvec4 color=vec4(0.0);\nfloat maximum=-1e20;\nvec3 weight=vec3(0.299,0.587,0.114);\nfor (int i=0; i<4; i++)\n{\ncolor=texture2D(textureSampler,vUV+ lumOffsets[i]);\n\nfloat GreyValue=dot(color.rgb,vec3(0.33,0.33,0.33));\n\n#ifdef WEIGHTED_AVERAGE\nfloat GreyValue=dot(color.rgb,weight);\n#endif\n#ifdef BRIGHTNESS\nfloat GreyValue=max(color.r,max(color.g,color.b));\n#endif\n#ifdef HSL_COMPONENT\nfloat GreyValue=0.5*(max(color.r,max(color.g,color.b))+min(color.r,min(color.g,color.b)));\n#endif\n#ifdef MAGNITUDE\nfloat GreyValue=length(color.rgb);\n#endif\nmaximum=max(maximum,GreyValue);\naverage+=(0.25*log(1e-5+GreyValue));\n}\naverage=exp(average);\ngl_FragColor=vec4(average,maximum,0.0,1.0);\n}\n#endif\n#if defined(LUMINANCE_DOWN_SAMPLE)\nuniform vec2 dsOffsets[9];\nuniform float halfDestPixelSize;\n#ifdef FINAL_DOWN_SAMPLER\nvec4 pack(float value) {\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(value*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\n#endif\nvoid main()\n{\nvec4 color=vec4(0.0);\nfloat average=0.0;\nfor (int i=0; i<9; i++)\n{\ncolor=texture2D(textureSampler,vUV+vec2(halfDestPixelSize,halfDestPixelSize)+dsOffsets[i]);\naverage+=color.r;\n}\naverage/=9.0;\n#ifdef FINAL_DOWN_SAMPLER\ngl_FragColor=pack(average);\n#else\ngl_FragColor=vec4(average,average,0.0,1.0);\n#endif\n}\n#endif\n#if defined(HDR)\nuniform sampler2D textureAdderSampler;\nuniform float averageLuminance;\nvoid main()\n{\nvec4 color=texture2D(textureAdderSampler,vUV);\n#ifndef AUTO_EXPOSURE\nvec4 adjustedColor=color/averageLuminance;\ncolor=adjustedColor;\ncolor.a=1.0;\n#endif\ngl_FragColor=color;\n}\n#endif\n#if defined(LENS_FLARE)\n#define GHOSTS 3\nuniform sampler2D lensColorSampler;\nuniform float strength;\nuniform float ghostDispersal;\nuniform float haloWidth;\nuniform vec2 resolution;\nuniform float distortionStrength;\nfloat hash(vec2 p)\n{\nfloat h=dot(p,vec2(127.1,311.7));\nreturn -1.0+2.0*fract(sin(h)*43758.5453123);\n}\nfloat noise(in vec2 p)\n{\nvec2 i=floor(p);\nvec2 f=fract(p);\nvec2 u=f*f*(3.0-2.0*f);\nreturn mix(mix(hash(i+vec2(0.0,0.0)),\nhash(i+vec2(1.0,0.0)),u.x),\nmix(hash(i+vec2(0.0,1.0)),\nhash(i+vec2(1.0,1.0)),u.x),u.y);\n}\nfloat fbm(vec2 p)\n{\nfloat f=0.0;\nf+=0.5000*noise(p); p*=2.02;\nf+=0.2500*noise(p); p*=2.03;\nf+=0.1250*noise(p); p*=2.01;\nf+=0.0625*noise(p); p*=2.04;\nf/=0.9375;\nreturn f;\n}\nvec3 pattern(vec2 uv)\n{\nvec2 p=-1.0+2.0*uv;\nfloat p2=dot(p,p);\nfloat f=fbm(vec2(15.0*p2))/2.0;\nfloat r=0.2+0.6*sin(12.5*length(uv-vec2(0.5)));\nfloat g=0.2+0.6*sin(20.5*length(uv-vec2(0.5)));\nfloat b=0.2+0.6*sin(17.2*length(uv-vec2(0.5)));\nreturn (1.0-f)*vec3(r,g,b);\n}\nfloat luminance(vec3 color)\n{\nreturn dot(color.rgb,vec3(0.2126,0.7152,0.0722));\n}\nvec4 textureDistorted(sampler2D tex,vec2 texcoord,vec2 direction,vec3 distortion)\n{\nreturn vec4(\ntexture2D(tex,texcoord+direction*distortion.r).r,\ntexture2D(tex,texcoord+direction*distortion.g).g,\ntexture2D(tex,texcoord+direction*distortion.b).b,\n1.0\n);\n}\nvoid main(void)\n{\nvec2 uv=-vUV+vec2(1.0);\nvec2 ghostDir=(vec2(0.5)-uv)*ghostDispersal;\nvec2 texelSize=1.0/resolution;\nvec3 distortion=vec3(-texelSize.x*distortionStrength,0.0,texelSize.x*distortionStrength);\nvec4 result=vec4(0.0);\nfloat ghostIndice=1.0;\nfor (int i=0; i<GHOSTS; ++i)\n{\nvec2 offset=fract(uv+ghostDir*ghostIndice);\nfloat weight=length(vec2(0.5)-offset)/length(vec2(0.5));\nweight=pow(1.0-weight,10.0);\nresult+=textureDistorted(textureSampler,offset,normalize(ghostDir),distortion)*weight*strength;\nghostIndice+=1.0;\n}\nvec2 haloVec=normalize(ghostDir)*haloWidth;\nfloat weight=length(vec2(0.5)-fract(uv+haloVec))/length(vec2(0.5));\nweight=pow(1.0-weight,10.0);\nresult+=textureDistorted(textureSampler,fract(uv+haloVec),normalize(ghostDir),distortion)*weight*strength;\nresult*=texture2D(lensColorSampler,vec2(length(vec2(0.5)-uv)/length(vec2(0.5))));\ngl_FragColor=result;\n}\n#endif\n#if defined(LENS_FLARE_COMPOSE)\nuniform sampler2D otherSampler;\nuniform sampler2D lensDirtSampler;\nuniform sampler2D lensStarSampler;\nuniform mat4 lensStarMatrix;\nvoid main(void)\n{\nvec2 lensFlareCoords=(lensStarMatrix*vec4(vUV,1.0,1.0)).xy;\nvec4 lensMod=texture2D(lensDirtSampler,vUV);\nlensMod+=texture2D(lensStarSampler,vUV);\nvec4 result=texture2D(textureSampler,vUV)*lensMod;\ngl_FragColor=texture2D(otherSampler,vUV)+result;\n}\n#endif\n#if defined(DEPTH_OF_FIELD)\nuniform sampler2D otherSampler;\nuniform sampler2D depthSampler;\nuniform float distance;\nvoid main(void)\n{\nvec4 sharp=texture2D(otherSampler,vUV);\nvec4 blur=texture2D(textureSampler,vUV);\nfloat dist=clamp(texture2D(depthSampler,vUV).r*distance,0.0,1.0);\nfloat factor=0.0;\nif (dist<0.05)\nfactor=1.0;\nelse if (dist<0.1)\nfactor=20.0*(0.1-dist);\nelse if (dist<0.5)\nfactor=0.0;\nelse\nfactor=2.0*(dist-0.5);\nfactor=clamp(factor,0.0,0.90);\ngl_FragColor=mix(sharp,blur,factor);\n}\n#endif\n#if defined(MOTION_BLUR)\nuniform mat4 inverseViewProjection;\nuniform mat4 prevViewProjection;\nuniform vec2 screenSize;\nuniform float motionScale;\nuniform float motionStrength;\nuniform sampler2D depthSampler;\nvoid main(void)\n{\nvec2 texelSize=1.0/screenSize;\nfloat depth=texture2D(depthSampler,vUV).r;\nvec4 cpos=vec4(vUV*2.0-1.0,depth,1.0);\ncpos=cpos*inverseViewProjection;\nvec4 ppos=cpos*prevViewProjection;\nppos.xyz/=ppos.w;\nppos.xy=ppos.xy*0.5+0.5;\nvec2 velocity=(ppos.xy-vUV)*motionScale*motionStrength;\nfloat speed=length(velocity/texelSize);\nint nSamples=int(clamp(speed,1.0,MAX_MOTION_SAMPLES));\nvec4 result=texture2D(textureSampler,vUV);\nfor (int i=1; i<int(MAX_MOTION_SAMPLES); ++i) {\nif (i>=nSamples)\nbreak;\nvec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5);\nresult+=texture2D(textureSampler,offset1);\n}\ngl_FragColor=result/float(nSamples);\n}\n#endif\n";
  130246. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130247. /** @hidden */
  130248. var standardPixelShader = { name: name, shader: shader };
  130249. /***/ }),
  130250. /***/ "./Shaders/stereoscopicInterlace.fragment.ts":
  130251. /*!***************************************************!*\
  130252. !*** ./Shaders/stereoscopicInterlace.fragment.ts ***!
  130253. \***************************************************/
  130254. /*! exports provided: stereoscopicInterlacePixelShader */
  130255. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130256. "use strict";
  130257. __webpack_require__.r(__webpack_exports__);
  130258. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stereoscopicInterlacePixelShader", function() { return stereoscopicInterlacePixelShader; });
  130259. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130260. var name = 'stereoscopicInterlacePixelShader';
  130261. 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}";
  130262. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130263. /** @hidden */
  130264. var stereoscopicInterlacePixelShader = { name: name, shader: shader };
  130265. /***/ }),
  130266. /***/ "./Shaders/tonemap.fragment.ts":
  130267. /*!*************************************!*\
  130268. !*** ./Shaders/tonemap.fragment.ts ***!
  130269. \*************************************/
  130270. /*! exports provided: tonemapPixelShader */
  130271. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130272. "use strict";
  130273. __webpack_require__.r(__webpack_exports__);
  130274. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tonemapPixelShader", function() { return tonemapPixelShader; });
  130275. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130276. var name = 'tonemapPixelShader';
  130277. 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}";
  130278. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130279. /** @hidden */
  130280. var tonemapPixelShader = { name: name, shader: shader };
  130281. /***/ }),
  130282. /***/ "./Shaders/volumetricLightScattering.fragment.ts":
  130283. /*!*******************************************************!*\
  130284. !*** ./Shaders/volumetricLightScattering.fragment.ts ***!
  130285. \*******************************************************/
  130286. /*! exports provided: volumetricLightScatteringPixelShader */
  130287. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130288. "use strict";
  130289. __webpack_require__.r(__webpack_exports__);
  130290. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPixelShader", function() { return volumetricLightScatteringPixelShader; });
  130291. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130292. var name = 'volumetricLightScatteringPixelShader';
  130293. 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";
  130294. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130295. /** @hidden */
  130296. var volumetricLightScatteringPixelShader = { name: name, shader: shader };
  130297. /***/ }),
  130298. /***/ "./Shaders/volumetricLightScatteringPass.fragment.ts":
  130299. /*!***********************************************************!*\
  130300. !*** ./Shaders/volumetricLightScatteringPass.fragment.ts ***!
  130301. \***********************************************************/
  130302. /*! exports provided: volumetricLightScatteringPassPixelShader */
  130303. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130304. "use strict";
  130305. __webpack_require__.r(__webpack_exports__);
  130306. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPassPixelShader", function() { return volumetricLightScatteringPassPixelShader; });
  130307. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130308. var name = 'volumetricLightScatteringPassPixelShader';
  130309. 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";
  130310. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130311. /** @hidden */
  130312. var volumetricLightScatteringPassPixelShader = { name: name, shader: shader };
  130313. /***/ }),
  130314. /***/ "./Shaders/vrDistortionCorrection.fragment.ts":
  130315. /*!****************************************************!*\
  130316. !*** ./Shaders/vrDistortionCorrection.fragment.ts ***!
  130317. \****************************************************/
  130318. /*! exports provided: vrDistortionCorrectionPixelShader */
  130319. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130320. "use strict";
  130321. __webpack_require__.r(__webpack_exports__);
  130322. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vrDistortionCorrectionPixelShader", function() { return vrDistortionCorrectionPixelShader; });
  130323. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130324. var name = 'vrDistortionCorrectionPixelShader';
  130325. 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}";
  130326. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130327. /** @hidden */
  130328. var vrDistortionCorrectionPixelShader = { name: name, shader: shader };
  130329. /***/ }),
  130330. /***/ "./Shaders/vrMultiviewToSingleview.fragment.ts":
  130331. /*!*****************************************************!*\
  130332. !*** ./Shaders/vrMultiviewToSingleview.fragment.ts ***!
  130333. \*****************************************************/
  130334. /*! exports provided: vrMultiviewToSingleviewPixelShader */
  130335. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130336. "use strict";
  130337. __webpack_require__.r(__webpack_exports__);
  130338. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vrMultiviewToSingleviewPixelShader", function() { return vrMultiviewToSingleviewPixelShader; });
  130339. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130340. var name = 'vrMultiviewToSingleviewPixelShader';
  130341. var shader = "#ifdef GL_ES\nprecision mediump sampler2DArray;\n#endif\nvarying vec2 vUV;\nuniform sampler2DArray multiviewSampler;\nuniform int imageIndex;\nvoid main(void)\n{\ngl_FragColor=texture(multiviewSampler,vec3(vUV,imageIndex));\n}";
  130342. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130343. /** @hidden */
  130344. var vrMultiviewToSingleviewPixelShader = { name: name, shader: shader };
  130345. /***/ }),
  130346. /***/ "./Sprites/index.ts":
  130347. /*!**************************!*\
  130348. !*** ./Sprites/index.ts ***!
  130349. \**************************/
  130350. /*! exports provided: Sprite, SpriteManager, SpriteSceneComponent */
  130351. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130352. "use strict";
  130353. __webpack_require__.r(__webpack_exports__);
  130354. /* harmony import */ var _sprite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sprite */ "./Sprites/sprite.ts");
  130355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _sprite__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  130356. /* harmony import */ var _spriteManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./spriteManager */ "./Sprites/spriteManager.ts");
  130357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _spriteManager__WEBPACK_IMPORTED_MODULE_1__["SpriteManager"]; });
  130358. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  130359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__["SpriteSceneComponent"]; });
  130360. /***/ }),
  130361. /***/ "./Sprites/sprite.ts":
  130362. /*!***************************!*\
  130363. !*** ./Sprites/sprite.ts ***!
  130364. \***************************/
  130365. /*! exports provided: Sprite */
  130366. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130367. "use strict";
  130368. __webpack_require__.r(__webpack_exports__);
  130369. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return Sprite; });
  130370. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  130371. /**
  130372. * Class used to represent a sprite
  130373. * @see http://doc.babylonjs.com/babylon101/sprites
  130374. */
  130375. var Sprite = /** @class */ (function () {
  130376. /**
  130377. * Creates a new Sprite
  130378. * @param name defines the name
  130379. * @param manager defines the manager
  130380. */
  130381. function Sprite(
  130382. /** defines the name */
  130383. name, manager) {
  130384. this.name = name;
  130385. /** Gets or sets the main color */
  130386. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  130387. /** Gets or sets the width */
  130388. this.width = 1.0;
  130389. /** Gets or sets the height */
  130390. this.height = 1.0;
  130391. /** Gets or sets rotation angle */
  130392. this.angle = 0;
  130393. /** Gets or sets the cell index in the sprite sheet */
  130394. this.cellIndex = 0;
  130395. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  130396. this.invertU = 0;
  130397. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  130398. this.invertV = 0;
  130399. /** Gets the list of attached animations */
  130400. this.animations = new Array();
  130401. /** Gets or sets a boolean indicating if the sprite can be picked */
  130402. this.isPickable = false;
  130403. this._animationStarted = false;
  130404. this._loopAnimation = false;
  130405. this._fromIndex = 0;
  130406. this._toIndex = 0;
  130407. this._delay = 0;
  130408. this._direction = 1;
  130409. this._time = 0;
  130410. /**
  130411. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  130412. */
  130413. this.isVisible = true;
  130414. this._manager = manager;
  130415. this._manager.sprites.push(this);
  130416. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  130417. }
  130418. Object.defineProperty(Sprite.prototype, "size", {
  130419. /**
  130420. * Gets or sets the sprite size
  130421. */
  130422. get: function () {
  130423. return this.width;
  130424. },
  130425. set: function (value) {
  130426. this.width = value;
  130427. this.height = value;
  130428. },
  130429. enumerable: true,
  130430. configurable: true
  130431. });
  130432. /**
  130433. * Starts an animation
  130434. * @param from defines the initial key
  130435. * @param to defines the end key
  130436. * @param loop defines if the animation must loop
  130437. * @param delay defines the start delay (in ms)
  130438. * @param onAnimationEnd defines a callback to call when animation ends
  130439. */
  130440. Sprite.prototype.playAnimation = function (from, to, loop, delay, onAnimationEnd) {
  130441. this._fromIndex = from;
  130442. this._toIndex = to;
  130443. this._loopAnimation = loop;
  130444. this._delay = delay;
  130445. this._animationStarted = true;
  130446. this._direction = from < to ? 1 : -1;
  130447. this.cellIndex = from;
  130448. this._time = 0;
  130449. this._onAnimationEnd = onAnimationEnd;
  130450. };
  130451. /** Stops current animation (if any) */
  130452. Sprite.prototype.stopAnimation = function () {
  130453. this._animationStarted = false;
  130454. };
  130455. /** @hidden */
  130456. Sprite.prototype._animate = function (deltaTime) {
  130457. if (!this._animationStarted) {
  130458. return;
  130459. }
  130460. this._time += deltaTime;
  130461. if (this._time > this._delay) {
  130462. this._time = this._time % this._delay;
  130463. this.cellIndex += this._direction;
  130464. if (this.cellIndex > this._toIndex) {
  130465. if (this._loopAnimation) {
  130466. this.cellIndex = this._fromIndex;
  130467. }
  130468. else {
  130469. this.cellIndex = this._toIndex;
  130470. this._animationStarted = false;
  130471. if (this._onAnimationEnd) {
  130472. this._onAnimationEnd();
  130473. }
  130474. if (this.disposeWhenFinishedAnimating) {
  130475. this.dispose();
  130476. }
  130477. }
  130478. }
  130479. }
  130480. };
  130481. /** Release associated resources */
  130482. Sprite.prototype.dispose = function () {
  130483. for (var i = 0; i < this._manager.sprites.length; i++) {
  130484. if (this._manager.sprites[i] == this) {
  130485. this._manager.sprites.splice(i, 1);
  130486. }
  130487. }
  130488. };
  130489. return Sprite;
  130490. }());
  130491. /***/ }),
  130492. /***/ "./Sprites/spriteManager.ts":
  130493. /*!**********************************!*\
  130494. !*** ./Sprites/spriteManager.ts ***!
  130495. \**********************************/
  130496. /*! exports provided: SpriteManager */
  130497. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130498. "use strict";
  130499. __webpack_require__.r(__webpack_exports__);
  130500. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return SpriteManager; });
  130501. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  130502. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  130503. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  130504. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  130505. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  130506. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  130507. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  130508. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  130509. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  130510. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  130511. /* harmony import */ var _Shaders_sprites_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/sprites.fragment */ "./Shaders/sprites.fragment.ts");
  130512. /* harmony import */ var _Shaders_sprites_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/sprites.vertex */ "./Shaders/sprites.vertex.ts");
  130513. /**
  130514. * Class used to manage multiple sprites on the same spritesheet
  130515. * @see http://doc.babylonjs.com/babylon101/sprites
  130516. */
  130517. var SpriteManager = /** @class */ (function () {
  130518. /**
  130519. * Creates a new sprite manager
  130520. * @param name defines the manager's name
  130521. * @param imgUrl defines the sprite sheet url
  130522. * @param capacity defines the maximum allowed number of sprites
  130523. * @param cellSize defines the size of a sprite cell
  130524. * @param scene defines the hosting scene
  130525. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  130526. * @param samplingMode defines the smapling mode to use with spritesheet
  130527. */
  130528. function SpriteManager(
  130529. /** defines the manager's name */
  130530. name, imgUrl, capacity, cellSize, scene, epsilon, samplingMode) {
  130531. if (epsilon === void 0) { epsilon = 0.01; }
  130532. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].TRILINEAR_SAMPLINGMODE; }
  130533. this.name = name;
  130534. /** Gets the list of sprites */
  130535. this.sprites = new Array();
  130536. /** Gets or sets the rendering group id (0 by default) */
  130537. this.renderingGroupId = 0;
  130538. /** Gets or sets camera layer mask */
  130539. this.layerMask = 0x0FFFFFFF;
  130540. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  130541. this.fogEnabled = true;
  130542. /** Gets or sets a boolean indicating if the sprites are pickable */
  130543. this.isPickable = false;
  130544. /**
  130545. * An event triggered when the manager is disposed.
  130546. */
  130547. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  130548. this._vertexBuffers = {};
  130549. if (!scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_8__["SceneComponentConstants"].NAME_SPRITE)) {
  130550. scene._addComponent(new _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__["SpriteSceneComponent"](scene));
  130551. }
  130552. this._capacity = capacity;
  130553. this._spriteTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](imgUrl, scene, true, false, samplingMode);
  130554. this._spriteTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  130555. this._spriteTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  130556. if (cellSize.width && cellSize.height) {
  130557. this.cellWidth = cellSize.width;
  130558. this.cellHeight = cellSize.height;
  130559. }
  130560. else if (cellSize !== undefined) {
  130561. this.cellWidth = cellSize;
  130562. this.cellHeight = cellSize;
  130563. }
  130564. else {
  130565. return;
  130566. }
  130567. this._epsilon = epsilon;
  130568. this._scene = scene;
  130569. this._scene.spriteManagers.push(this);
  130570. var indices = [];
  130571. var index = 0;
  130572. for (var count = 0; count < capacity; count++) {
  130573. indices.push(index);
  130574. indices.push(index + 1);
  130575. indices.push(index + 2);
  130576. indices.push(index);
  130577. indices.push(index + 2);
  130578. indices.push(index + 3);
  130579. index += 4;
  130580. }
  130581. this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
  130582. // VBO
  130583. // 16 floats per sprite (x, y, z, angle, sizeX, sizeY, offsetX, offsetY, invertU, invertV, cellIndexX, cellIndexY, color r, color g, color b, color a)
  130584. this._vertexData = new Float32Array(capacity * 16 * 4);
  130585. this._buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["Buffer"](scene.getEngine(), this._vertexData, true, 16);
  130586. var positions = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, 0, 4);
  130587. var options = this._buffer.createVertexBuffer("options", 4, 4);
  130588. var cellInfo = this._buffer.createVertexBuffer("cellInfo", 8, 4);
  130589. var colors = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, 12, 4);
  130590. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind] = positions;
  130591. this._vertexBuffers["options"] = options;
  130592. this._vertexBuffers["cellInfo"] = cellInfo;
  130593. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind] = colors;
  130594. // Effects
  130595. 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"], "");
  130596. 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");
  130597. }
  130598. Object.defineProperty(SpriteManager.prototype, "onDispose", {
  130599. /**
  130600. * Callback called when the manager is disposed
  130601. */
  130602. set: function (callback) {
  130603. if (this._onDisposeObserver) {
  130604. this.onDisposeObservable.remove(this._onDisposeObserver);
  130605. }
  130606. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  130607. },
  130608. enumerable: true,
  130609. configurable: true
  130610. });
  130611. Object.defineProperty(SpriteManager.prototype, "texture", {
  130612. /**
  130613. * Gets or sets the spritesheet texture
  130614. */
  130615. get: function () {
  130616. return this._spriteTexture;
  130617. },
  130618. set: function (value) {
  130619. this._spriteTexture = value;
  130620. },
  130621. enumerable: true,
  130622. configurable: true
  130623. });
  130624. SpriteManager.prototype._appendSpriteVertex = function (index, sprite, offsetX, offsetY, rowSize) {
  130625. var arrayOffset = index * 16;
  130626. if (offsetX === 0) {
  130627. offsetX = this._epsilon;
  130628. }
  130629. else if (offsetX === 1) {
  130630. offsetX = 1 - this._epsilon;
  130631. }
  130632. if (offsetY === 0) {
  130633. offsetY = this._epsilon;
  130634. }
  130635. else if (offsetY === 1) {
  130636. offsetY = 1 - this._epsilon;
  130637. }
  130638. this._vertexData[arrayOffset] = sprite.position.x;
  130639. this._vertexData[arrayOffset + 1] = sprite.position.y;
  130640. this._vertexData[arrayOffset + 2] = sprite.position.z;
  130641. this._vertexData[arrayOffset + 3] = sprite.angle;
  130642. this._vertexData[arrayOffset + 4] = sprite.width;
  130643. this._vertexData[arrayOffset + 5] = sprite.height;
  130644. this._vertexData[arrayOffset + 6] = offsetX;
  130645. this._vertexData[arrayOffset + 7] = offsetY;
  130646. this._vertexData[arrayOffset + 8] = sprite.invertU ? 1 : 0;
  130647. this._vertexData[arrayOffset + 9] = sprite.invertV ? 1 : 0;
  130648. var offset = (sprite.cellIndex / rowSize) >> 0;
  130649. this._vertexData[arrayOffset + 10] = sprite.cellIndex - offset * rowSize;
  130650. this._vertexData[arrayOffset + 11] = offset;
  130651. // Color
  130652. this._vertexData[arrayOffset + 12] = sprite.color.r;
  130653. this._vertexData[arrayOffset + 13] = sprite.color.g;
  130654. this._vertexData[arrayOffset + 14] = sprite.color.b;
  130655. this._vertexData[arrayOffset + 15] = sprite.color.a;
  130656. };
  130657. /**
  130658. * Intersects the sprites with a ray
  130659. * @param ray defines the ray to intersect with
  130660. * @param camera defines the current active camera
  130661. * @param predicate defines a predicate used to select candidate sprites
  130662. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  130663. * @returns null if no hit or a PickingInfo
  130664. */
  130665. SpriteManager.prototype.intersects = function (ray, camera, predicate, fastCheck) {
  130666. var count = Math.min(this._capacity, this.sprites.length);
  130667. var min = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  130668. var max = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  130669. var distance = Number.MAX_VALUE;
  130670. var currentSprite = null;
  130671. var pickedPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  130672. var cameraSpacePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  130673. var cameraView = camera.getViewMatrix();
  130674. for (var index = 0; index < count; index++) {
  130675. var sprite = this.sprites[index];
  130676. if (!sprite) {
  130677. continue;
  130678. }
  130679. if (predicate) {
  130680. if (!predicate(sprite)) {
  130681. continue;
  130682. }
  130683. }
  130684. else if (!sprite.isPickable) {
  130685. continue;
  130686. }
  130687. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(sprite.position, cameraView, cameraSpacePosition);
  130688. min.copyFromFloats(cameraSpacePosition.x - sprite.width / 2, cameraSpacePosition.y - sprite.height / 2, cameraSpacePosition.z);
  130689. max.copyFromFloats(cameraSpacePosition.x + sprite.width / 2, cameraSpacePosition.y + sprite.height / 2, cameraSpacePosition.z);
  130690. if (ray.intersectsBoxMinMax(min, max)) {
  130691. var currentDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(cameraSpacePosition, ray.origin);
  130692. if (distance > currentDistance) {
  130693. distance = currentDistance;
  130694. currentSprite = sprite;
  130695. if (fastCheck) {
  130696. break;
  130697. }
  130698. }
  130699. }
  130700. }
  130701. if (currentSprite) {
  130702. var result = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__["PickingInfo"]();
  130703. cameraView.invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  130704. result.hit = true;
  130705. result.pickedSprite = currentSprite;
  130706. result.distance = distance;
  130707. // Get picked point
  130708. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  130709. direction.copyFrom(ray.direction);
  130710. direction.normalize();
  130711. direction.scaleInPlace(distance);
  130712. ray.origin.addToRef(direction, pickedPoint);
  130713. result.pickedPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(pickedPoint, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  130714. return result;
  130715. }
  130716. return null;
  130717. };
  130718. /**
  130719. * Render all child sprites
  130720. */
  130721. SpriteManager.prototype.render = function () {
  130722. // Check
  130723. if (!this._effectBase.isReady() || !this._effectFog.isReady() || !this._spriteTexture
  130724. || !this._spriteTexture.isReady() || !this.sprites.length) {
  130725. return;
  130726. }
  130727. var engine = this._scene.getEngine();
  130728. var baseSize = this._spriteTexture.getBaseSize();
  130729. // Sprites
  130730. var deltaTime = engine.getDeltaTime();
  130731. var max = Math.min(this._capacity, this.sprites.length);
  130732. var rowSize = baseSize.width / this.cellWidth;
  130733. var offset = 0;
  130734. var noSprite = true;
  130735. for (var index = 0; index < max; index++) {
  130736. var sprite = this.sprites[index];
  130737. if (!sprite || !sprite.isVisible) {
  130738. continue;
  130739. }
  130740. noSprite = false;
  130741. sprite._animate(deltaTime);
  130742. this._appendSpriteVertex(offset++, sprite, 0, 0, rowSize);
  130743. this._appendSpriteVertex(offset++, sprite, 1, 0, rowSize);
  130744. this._appendSpriteVertex(offset++, sprite, 1, 1, rowSize);
  130745. this._appendSpriteVertex(offset++, sprite, 0, 1, rowSize);
  130746. }
  130747. if (noSprite) {
  130748. return;
  130749. }
  130750. this._buffer.update(this._vertexData);
  130751. // Render
  130752. var effect = this._effectBase;
  130753. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  130754. effect = this._effectFog;
  130755. }
  130756. engine.enableEffect(effect);
  130757. var viewMatrix = this._scene.getViewMatrix();
  130758. effect.setTexture("diffuseSampler", this._spriteTexture);
  130759. effect.setMatrix("view", viewMatrix);
  130760. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  130761. effect.setFloat2("textureInfos", this.cellWidth / baseSize.width, this.cellHeight / baseSize.height);
  130762. // Fog
  130763. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  130764. effect.setFloat4("vFogInfos", this._scene.fogMode, this._scene.fogStart, this._scene.fogEnd, this._scene.fogDensity);
  130765. effect.setColor3("vFogColor", this._scene.fogColor);
  130766. }
  130767. // VBOs
  130768. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  130769. // Draw order
  130770. engine.setDepthFunctionToLessOrEqual();
  130771. effect.setBool("alphaTest", true);
  130772. engine.setColorWrite(false);
  130773. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  130774. engine.setColorWrite(true);
  130775. effect.setBool("alphaTest", false);
  130776. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_COMBINE);
  130777. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  130778. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_DISABLE);
  130779. };
  130780. /**
  130781. * Release associated resources
  130782. */
  130783. SpriteManager.prototype.dispose = function () {
  130784. if (this._buffer) {
  130785. this._buffer.dispose();
  130786. this._buffer = null;
  130787. }
  130788. if (this._indexBuffer) {
  130789. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  130790. this._indexBuffer = null;
  130791. }
  130792. if (this._spriteTexture) {
  130793. this._spriteTexture.dispose();
  130794. this._spriteTexture = null;
  130795. }
  130796. // Remove from scene
  130797. var index = this._scene.spriteManagers.indexOf(this);
  130798. this._scene.spriteManagers.splice(index, 1);
  130799. // Callback
  130800. this.onDisposeObservable.notifyObservers(this);
  130801. this.onDisposeObservable.clear();
  130802. };
  130803. return SpriteManager;
  130804. }());
  130805. /***/ }),
  130806. /***/ "./Sprites/spriteSceneComponent.ts":
  130807. /*!*****************************************!*\
  130808. !*** ./Sprites/spriteSceneComponent.ts ***!
  130809. \*****************************************/
  130810. /*! exports provided: SpriteSceneComponent */
  130811. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130812. "use strict";
  130813. __webpack_require__.r(__webpack_exports__);
  130814. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return SpriteSceneComponent; });
  130815. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  130816. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  130817. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  130818. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  130819. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  130820. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Actions/actionEvent */ "./Actions/actionEvent.ts");
  130821. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  130822. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype._internalPickSprites = function (ray, predicate, fastCheck, camera) {
  130823. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]) {
  130824. return null;
  130825. }
  130826. var pickingInfo = null;
  130827. if (!camera) {
  130828. if (!this.activeCamera) {
  130829. return null;
  130830. }
  130831. camera = this.activeCamera;
  130832. }
  130833. if (this.spriteManagers.length > 0) {
  130834. for (var spriteIndex = 0; spriteIndex < this.spriteManagers.length; spriteIndex++) {
  130835. var spriteManager = this.spriteManagers[spriteIndex];
  130836. if (!spriteManager.isPickable) {
  130837. continue;
  130838. }
  130839. var result = spriteManager.intersects(ray, camera, predicate, fastCheck);
  130840. if (!result || !result.hit) {
  130841. continue;
  130842. }
  130843. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  130844. continue;
  130845. }
  130846. pickingInfo = result;
  130847. if (fastCheck) {
  130848. break;
  130849. }
  130850. }
  130851. }
  130852. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]();
  130853. };
  130854. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSprite = function (x, y, predicate, fastCheck, camera) {
  130855. this.createPickingRayInCameraSpaceToRef(x, y, this._tempSpritePickingRay, camera);
  130856. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  130857. };
  130858. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSpriteWithRay = function (ray, predicate, fastCheck, camera) {
  130859. if (!this._tempSpritePickingRay) {
  130860. return null;
  130861. }
  130862. if (!camera) {
  130863. if (!this.activeCamera) {
  130864. return null;
  130865. }
  130866. camera = this.activeCamera;
  130867. }
  130868. _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].TransformToRef(ray, camera.getViewMatrix(), this._tempSpritePickingRay);
  130869. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  130870. };
  130871. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.setPointerOverSprite = function (sprite) {
  130872. if (this._pointerOverSprite === sprite) {
  130873. return;
  130874. }
  130875. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  130876. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  130877. }
  130878. this._pointerOverSprite = sprite;
  130879. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  130880. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  130881. }
  130882. };
  130883. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.getPointerOverSprite = function () {
  130884. return this._pointerOverSprite;
  130885. };
  130886. /**
  130887. * Defines the sprite scene component responsible to manage sprites
  130888. * in a given scene.
  130889. */
  130890. var SpriteSceneComponent = /** @class */ (function () {
  130891. /**
  130892. * Creates a new instance of the component for the given scene
  130893. * @param scene Defines the scene to register the component in
  130894. */
  130895. function SpriteSceneComponent(scene) {
  130896. /**
  130897. * The component name helpfull to identify the component in the list of scene components.
  130898. */
  130899. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_SPRITE;
  130900. this.scene = scene;
  130901. this.scene.spriteManagers = new Array();
  130902. this.scene._tempSpritePickingRay = _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"] ? _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].Zero() : null;
  130903. this.scene.onBeforeSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  130904. this.scene.onAfterSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  130905. this._spritePredicate = function (sprite) {
  130906. if (!sprite.actionManager) {
  130907. return false;
  130908. }
  130909. return sprite.isPickable && sprite.actionManager.hasPointerTriggers;
  130910. };
  130911. }
  130912. /**
  130913. * Registers the component in a given scene
  130914. */
  130915. SpriteSceneComponent.prototype.register = function () {
  130916. this.scene._pointerMoveStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERMOVE_SPRITE, this, this._pointerMove);
  130917. this.scene._pointerDownStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERDOWN_SPRITE, this, this._pointerDown);
  130918. this.scene._pointerUpStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERUP_SPRITE, this, this._pointerUp);
  130919. };
  130920. /**
  130921. * Rebuilds the elements related to this component in case of
  130922. * context lost for instance.
  130923. */
  130924. SpriteSceneComponent.prototype.rebuild = function () {
  130925. /** Nothing to do for sprites */
  130926. };
  130927. /**
  130928. * Disposes the component and the associated ressources.
  130929. */
  130930. SpriteSceneComponent.prototype.dispose = function () {
  130931. this.scene.onBeforeSpritesRenderingObservable.clear();
  130932. this.scene.onAfterSpritesRenderingObservable.clear();
  130933. var spriteManagers = this.scene.spriteManagers;
  130934. while (spriteManagers.length) {
  130935. spriteManagers[0].dispose();
  130936. }
  130937. };
  130938. SpriteSceneComponent.prototype._pickSpriteButKeepRay = function (originalPointerInfo, x, y, fastCheck, camera) {
  130939. var result = this.scene.pickSprite(x, y, this._spritePredicate, fastCheck, camera);
  130940. if (result) {
  130941. result.ray = originalPointerInfo ? originalPointerInfo.ray : null;
  130942. }
  130943. return result;
  130944. };
  130945. SpriteSceneComponent.prototype._pointerMove = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, isMeshPicked, canvas) {
  130946. var scene = this.scene;
  130947. if (isMeshPicked) {
  130948. scene.setPointerOverSprite(null);
  130949. }
  130950. else {
  130951. pickResult = this._pickSpriteButKeepRay(pickResult, unTranslatedPointerX, unTranslatedPointerY, false, scene.cameraToUseForPointers || undefined);
  130952. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  130953. scene.setPointerOverSprite(pickResult.pickedSprite);
  130954. if (scene._pointerOverSprite && scene._pointerOverSprite.actionManager && scene._pointerOverSprite.actionManager.hoverCursor) {
  130955. canvas.style.cursor = scene._pointerOverSprite.actionManager.hoverCursor;
  130956. }
  130957. else {
  130958. canvas.style.cursor = scene.hoverCursor;
  130959. }
  130960. }
  130961. else {
  130962. scene.setPointerOverSprite(null);
  130963. }
  130964. }
  130965. return pickResult;
  130966. };
  130967. SpriteSceneComponent.prototype._pointerDown = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  130968. var scene = this.scene;
  130969. scene._pickedDownSprite = null;
  130970. if (scene.spriteManagers.length > 0) {
  130971. pickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  130972. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  130973. if (pickResult.pickedSprite.actionManager) {
  130974. scene._pickedDownSprite = pickResult.pickedSprite;
  130975. switch (evt.button) {
  130976. case 0:
  130977. 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));
  130978. break;
  130979. case 1:
  130980. 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));
  130981. break;
  130982. case 2:
  130983. 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));
  130984. break;
  130985. }
  130986. if (pickResult.pickedSprite.actionManager) {
  130987. 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));
  130988. }
  130989. }
  130990. }
  130991. }
  130992. return pickResult;
  130993. };
  130994. SpriteSceneComponent.prototype._pointerUp = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  130995. var scene = this.scene;
  130996. if (scene.spriteManagers.length > 0) {
  130997. var spritePickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  130998. if (spritePickResult) {
  130999. if (spritePickResult.hit && spritePickResult.pickedSprite) {
  131000. if (spritePickResult.pickedSprite.actionManager) {
  131001. 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));
  131002. if (spritePickResult.pickedSprite.actionManager) {
  131003. if (!this.scene._isPointerSwiping()) {
  131004. 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));
  131005. }
  131006. }
  131007. }
  131008. }
  131009. if (scene._pickedDownSprite && scene._pickedDownSprite.actionManager && scene._pickedDownSprite !== spritePickResult.pickedSprite) {
  131010. 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));
  131011. }
  131012. }
  131013. }
  131014. return pickResult;
  131015. };
  131016. return SpriteSceneComponent;
  131017. }());
  131018. /***/ }),
  131019. /***/ "./States/alphaCullingState.ts":
  131020. /*!*************************************!*\
  131021. !*** ./States/alphaCullingState.ts ***!
  131022. \*************************************/
  131023. /*! exports provided: _AlphaState */
  131024. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131025. "use strict";
  131026. __webpack_require__.r(__webpack_exports__);
  131027. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _AlphaState; });
  131028. /**
  131029. * @hidden
  131030. **/
  131031. var _AlphaState = /** @class */ (function () {
  131032. /**
  131033. * Initializes the state.
  131034. */
  131035. function _AlphaState() {
  131036. this._isAlphaBlendDirty = false;
  131037. this._isBlendFunctionParametersDirty = false;
  131038. this._isBlendEquationParametersDirty = false;
  131039. this._isBlendConstantsDirty = false;
  131040. this._alphaBlend = false;
  131041. this._blendFunctionParameters = new Array(4);
  131042. this._blendEquationParameters = new Array(2);
  131043. this._blendConstants = new Array(4);
  131044. this.reset();
  131045. }
  131046. Object.defineProperty(_AlphaState.prototype, "isDirty", {
  131047. get: function () {
  131048. return this._isAlphaBlendDirty || this._isBlendFunctionParametersDirty;
  131049. },
  131050. enumerable: true,
  131051. configurable: true
  131052. });
  131053. Object.defineProperty(_AlphaState.prototype, "alphaBlend", {
  131054. get: function () {
  131055. return this._alphaBlend;
  131056. },
  131057. set: function (value) {
  131058. if (this._alphaBlend === value) {
  131059. return;
  131060. }
  131061. this._alphaBlend = value;
  131062. this._isAlphaBlendDirty = true;
  131063. },
  131064. enumerable: true,
  131065. configurable: true
  131066. });
  131067. _AlphaState.prototype.setAlphaBlendConstants = function (r, g, b, a) {
  131068. if (this._blendConstants[0] === r &&
  131069. this._blendConstants[1] === g &&
  131070. this._blendConstants[2] === b &&
  131071. this._blendConstants[3] === a) {
  131072. return;
  131073. }
  131074. this._blendConstants[0] = r;
  131075. this._blendConstants[1] = g;
  131076. this._blendConstants[2] = b;
  131077. this._blendConstants[3] = a;
  131078. this._isBlendConstantsDirty = true;
  131079. };
  131080. _AlphaState.prototype.setAlphaBlendFunctionParameters = function (value0, value1, value2, value3) {
  131081. if (this._blendFunctionParameters[0] === value0 &&
  131082. this._blendFunctionParameters[1] === value1 &&
  131083. this._blendFunctionParameters[2] === value2 &&
  131084. this._blendFunctionParameters[3] === value3) {
  131085. return;
  131086. }
  131087. this._blendFunctionParameters[0] = value0;
  131088. this._blendFunctionParameters[1] = value1;
  131089. this._blendFunctionParameters[2] = value2;
  131090. this._blendFunctionParameters[3] = value3;
  131091. this._isBlendFunctionParametersDirty = true;
  131092. };
  131093. _AlphaState.prototype.setAlphaEquationParameters = function (rgb, alpha) {
  131094. if (this._blendEquationParameters[0] === rgb &&
  131095. this._blendEquationParameters[1] === alpha) {
  131096. return;
  131097. }
  131098. this._blendEquationParameters[0] = rgb;
  131099. this._blendEquationParameters[1] = alpha;
  131100. this._isBlendEquationParametersDirty = true;
  131101. };
  131102. _AlphaState.prototype.reset = function () {
  131103. this._alphaBlend = false;
  131104. this._blendFunctionParameters[0] = null;
  131105. this._blendFunctionParameters[1] = null;
  131106. this._blendFunctionParameters[2] = null;
  131107. this._blendFunctionParameters[3] = null;
  131108. this._blendEquationParameters[0] = null;
  131109. this._blendEquationParameters[1] = null;
  131110. this._blendConstants[0] = null;
  131111. this._blendConstants[1] = null;
  131112. this._blendConstants[2] = null;
  131113. this._blendConstants[3] = null;
  131114. this._isAlphaBlendDirty = true;
  131115. this._isBlendFunctionParametersDirty = false;
  131116. this._isBlendEquationParametersDirty = false;
  131117. this._isBlendConstantsDirty = false;
  131118. };
  131119. _AlphaState.prototype.apply = function (gl) {
  131120. if (!this.isDirty) {
  131121. return;
  131122. }
  131123. // Alpha blend
  131124. if (this._isAlphaBlendDirty) {
  131125. if (this._alphaBlend) {
  131126. gl.enable(gl.BLEND);
  131127. }
  131128. else {
  131129. gl.disable(gl.BLEND);
  131130. }
  131131. this._isAlphaBlendDirty = false;
  131132. }
  131133. // Alpha function
  131134. if (this._isBlendFunctionParametersDirty) {
  131135. gl.blendFuncSeparate(this._blendFunctionParameters[0], this._blendFunctionParameters[1], this._blendFunctionParameters[2], this._blendFunctionParameters[3]);
  131136. this._isBlendFunctionParametersDirty = false;
  131137. }
  131138. // Alpha equation
  131139. if (this._isBlendEquationParametersDirty) {
  131140. gl.blendEquationSeparate(this._blendEquationParameters[0], this._blendEquationParameters[1]);
  131141. this._isBlendEquationParametersDirty = false;
  131142. }
  131143. // Constants
  131144. if (this._isBlendConstantsDirty) {
  131145. gl.blendColor(this._blendConstants[0], this._blendConstants[1], this._blendConstants[2], this._blendConstants[3]);
  131146. this._isBlendConstantsDirty = false;
  131147. }
  131148. };
  131149. return _AlphaState;
  131150. }());
  131151. /***/ }),
  131152. /***/ "./States/depthCullingState.ts":
  131153. /*!*************************************!*\
  131154. !*** ./States/depthCullingState.ts ***!
  131155. \*************************************/
  131156. /*! exports provided: _DepthCullingState */
  131157. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131158. "use strict";
  131159. __webpack_require__.r(__webpack_exports__);
  131160. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _DepthCullingState; });
  131161. /**
  131162. * @hidden
  131163. **/
  131164. var _DepthCullingState = /** @class */ (function () {
  131165. /**
  131166. * Initializes the state.
  131167. */
  131168. function _DepthCullingState() {
  131169. this._isDepthTestDirty = false;
  131170. this._isDepthMaskDirty = false;
  131171. this._isDepthFuncDirty = false;
  131172. this._isCullFaceDirty = false;
  131173. this._isCullDirty = false;
  131174. this._isZOffsetDirty = false;
  131175. this._isFrontFaceDirty = false;
  131176. this.reset();
  131177. }
  131178. Object.defineProperty(_DepthCullingState.prototype, "isDirty", {
  131179. get: function () {
  131180. return this._isDepthFuncDirty || this._isDepthTestDirty || this._isDepthMaskDirty || this._isCullFaceDirty || this._isCullDirty || this._isZOffsetDirty || this._isFrontFaceDirty;
  131181. },
  131182. enumerable: true,
  131183. configurable: true
  131184. });
  131185. Object.defineProperty(_DepthCullingState.prototype, "zOffset", {
  131186. get: function () {
  131187. return this._zOffset;
  131188. },
  131189. set: function (value) {
  131190. if (this._zOffset === value) {
  131191. return;
  131192. }
  131193. this._zOffset = value;
  131194. this._isZOffsetDirty = true;
  131195. },
  131196. enumerable: true,
  131197. configurable: true
  131198. });
  131199. Object.defineProperty(_DepthCullingState.prototype, "cullFace", {
  131200. get: function () {
  131201. return this._cullFace;
  131202. },
  131203. set: function (value) {
  131204. if (this._cullFace === value) {
  131205. return;
  131206. }
  131207. this._cullFace = value;
  131208. this._isCullFaceDirty = true;
  131209. },
  131210. enumerable: true,
  131211. configurable: true
  131212. });
  131213. Object.defineProperty(_DepthCullingState.prototype, "cull", {
  131214. get: function () {
  131215. return this._cull;
  131216. },
  131217. set: function (value) {
  131218. if (this._cull === value) {
  131219. return;
  131220. }
  131221. this._cull = value;
  131222. this._isCullDirty = true;
  131223. },
  131224. enumerable: true,
  131225. configurable: true
  131226. });
  131227. Object.defineProperty(_DepthCullingState.prototype, "depthFunc", {
  131228. get: function () {
  131229. return this._depthFunc;
  131230. },
  131231. set: function (value) {
  131232. if (this._depthFunc === value) {
  131233. return;
  131234. }
  131235. this._depthFunc = value;
  131236. this._isDepthFuncDirty = true;
  131237. },
  131238. enumerable: true,
  131239. configurable: true
  131240. });
  131241. Object.defineProperty(_DepthCullingState.prototype, "depthMask", {
  131242. get: function () {
  131243. return this._depthMask;
  131244. },
  131245. set: function (value) {
  131246. if (this._depthMask === value) {
  131247. return;
  131248. }
  131249. this._depthMask = value;
  131250. this._isDepthMaskDirty = true;
  131251. },
  131252. enumerable: true,
  131253. configurable: true
  131254. });
  131255. Object.defineProperty(_DepthCullingState.prototype, "depthTest", {
  131256. get: function () {
  131257. return this._depthTest;
  131258. },
  131259. set: function (value) {
  131260. if (this._depthTest === value) {
  131261. return;
  131262. }
  131263. this._depthTest = value;
  131264. this._isDepthTestDirty = true;
  131265. },
  131266. enumerable: true,
  131267. configurable: true
  131268. });
  131269. Object.defineProperty(_DepthCullingState.prototype, "frontFace", {
  131270. get: function () {
  131271. return this._frontFace;
  131272. },
  131273. set: function (value) {
  131274. if (this._frontFace === value) {
  131275. return;
  131276. }
  131277. this._frontFace = value;
  131278. this._isFrontFaceDirty = true;
  131279. },
  131280. enumerable: true,
  131281. configurable: true
  131282. });
  131283. _DepthCullingState.prototype.reset = function () {
  131284. this._depthMask = true;
  131285. this._depthTest = true;
  131286. this._depthFunc = null;
  131287. this._cullFace = null;
  131288. this._cull = null;
  131289. this._zOffset = 0;
  131290. this._frontFace = null;
  131291. this._isDepthTestDirty = true;
  131292. this._isDepthMaskDirty = true;
  131293. this._isDepthFuncDirty = false;
  131294. this._isCullFaceDirty = false;
  131295. this._isCullDirty = false;
  131296. this._isZOffsetDirty = false;
  131297. this._isFrontFaceDirty = false;
  131298. };
  131299. _DepthCullingState.prototype.apply = function (gl) {
  131300. if (!this.isDirty) {
  131301. return;
  131302. }
  131303. // Cull
  131304. if (this._isCullDirty) {
  131305. if (this.cull) {
  131306. gl.enable(gl.CULL_FACE);
  131307. }
  131308. else {
  131309. gl.disable(gl.CULL_FACE);
  131310. }
  131311. this._isCullDirty = false;
  131312. }
  131313. // Cull face
  131314. if (this._isCullFaceDirty) {
  131315. gl.cullFace(this.cullFace);
  131316. this._isCullFaceDirty = false;
  131317. }
  131318. // Depth mask
  131319. if (this._isDepthMaskDirty) {
  131320. gl.depthMask(this.depthMask);
  131321. this._isDepthMaskDirty = false;
  131322. }
  131323. // Depth test
  131324. if (this._isDepthTestDirty) {
  131325. if (this.depthTest) {
  131326. gl.enable(gl.DEPTH_TEST);
  131327. }
  131328. else {
  131329. gl.disable(gl.DEPTH_TEST);
  131330. }
  131331. this._isDepthTestDirty = false;
  131332. }
  131333. // Depth func
  131334. if (this._isDepthFuncDirty) {
  131335. gl.depthFunc(this.depthFunc);
  131336. this._isDepthFuncDirty = false;
  131337. }
  131338. // zOffset
  131339. if (this._isZOffsetDirty) {
  131340. if (this.zOffset) {
  131341. gl.enable(gl.POLYGON_OFFSET_FILL);
  131342. gl.polygonOffset(this.zOffset, 0);
  131343. }
  131344. else {
  131345. gl.disable(gl.POLYGON_OFFSET_FILL);
  131346. }
  131347. this._isZOffsetDirty = false;
  131348. }
  131349. // Front face
  131350. if (this._isFrontFaceDirty) {
  131351. gl.frontFace(this.frontFace);
  131352. this._isFrontFaceDirty = false;
  131353. }
  131354. };
  131355. return _DepthCullingState;
  131356. }());
  131357. /***/ }),
  131358. /***/ "./States/index.ts":
  131359. /*!*************************!*\
  131360. !*** ./States/index.ts ***!
  131361. \*************************/
  131362. /*! exports provided: _AlphaState, _DepthCullingState, _StencilState */
  131363. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131364. "use strict";
  131365. __webpack_require__.r(__webpack_exports__);
  131366. /* harmony import */ var _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./alphaCullingState */ "./States/alphaCullingState.ts");
  131367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  131368. /* harmony import */ var _depthCullingState__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthCullingState */ "./States/depthCullingState.ts");
  131369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _depthCullingState__WEBPACK_IMPORTED_MODULE_1__["_DepthCullingState"]; });
  131370. /* harmony import */ var _stencilState__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stencilState */ "./States/stencilState.ts");
  131371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _stencilState__WEBPACK_IMPORTED_MODULE_2__["_StencilState"]; });
  131372. /***/ }),
  131373. /***/ "./States/stencilState.ts":
  131374. /*!********************************!*\
  131375. !*** ./States/stencilState.ts ***!
  131376. \********************************/
  131377. /*! exports provided: _StencilState */
  131378. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131379. "use strict";
  131380. __webpack_require__.r(__webpack_exports__);
  131381. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _StencilState; });
  131382. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  131383. /**
  131384. * @hidden
  131385. **/
  131386. var _StencilState = /** @class */ (function () {
  131387. function _StencilState() {
  131388. this._isStencilTestDirty = false;
  131389. this._isStencilMaskDirty = false;
  131390. this._isStencilFuncDirty = false;
  131391. this._isStencilOpDirty = false;
  131392. this.reset();
  131393. }
  131394. Object.defineProperty(_StencilState.prototype, "isDirty", {
  131395. get: function () {
  131396. return this._isStencilTestDirty || this._isStencilMaskDirty || this._isStencilFuncDirty || this._isStencilOpDirty;
  131397. },
  131398. enumerable: true,
  131399. configurable: true
  131400. });
  131401. Object.defineProperty(_StencilState.prototype, "stencilFunc", {
  131402. get: function () {
  131403. return this._stencilFunc;
  131404. },
  131405. set: function (value) {
  131406. if (this._stencilFunc === value) {
  131407. return;
  131408. }
  131409. this._stencilFunc = value;
  131410. this._isStencilFuncDirty = true;
  131411. },
  131412. enumerable: true,
  131413. configurable: true
  131414. });
  131415. Object.defineProperty(_StencilState.prototype, "stencilFuncRef", {
  131416. get: function () {
  131417. return this._stencilFuncRef;
  131418. },
  131419. set: function (value) {
  131420. if (this._stencilFuncRef === value) {
  131421. return;
  131422. }
  131423. this._stencilFuncRef = value;
  131424. this._isStencilFuncDirty = true;
  131425. },
  131426. enumerable: true,
  131427. configurable: true
  131428. });
  131429. Object.defineProperty(_StencilState.prototype, "stencilFuncMask", {
  131430. get: function () {
  131431. return this._stencilFuncMask;
  131432. },
  131433. set: function (value) {
  131434. if (this._stencilFuncMask === value) {
  131435. return;
  131436. }
  131437. this._stencilFuncMask = value;
  131438. this._isStencilFuncDirty = true;
  131439. },
  131440. enumerable: true,
  131441. configurable: true
  131442. });
  131443. Object.defineProperty(_StencilState.prototype, "stencilOpStencilFail", {
  131444. get: function () {
  131445. return this._stencilOpStencilFail;
  131446. },
  131447. set: function (value) {
  131448. if (this._stencilOpStencilFail === value) {
  131449. return;
  131450. }
  131451. this._stencilOpStencilFail = value;
  131452. this._isStencilOpDirty = true;
  131453. },
  131454. enumerable: true,
  131455. configurable: true
  131456. });
  131457. Object.defineProperty(_StencilState.prototype, "stencilOpDepthFail", {
  131458. get: function () {
  131459. return this._stencilOpDepthFail;
  131460. },
  131461. set: function (value) {
  131462. if (this._stencilOpDepthFail === value) {
  131463. return;
  131464. }
  131465. this._stencilOpDepthFail = value;
  131466. this._isStencilOpDirty = true;
  131467. },
  131468. enumerable: true,
  131469. configurable: true
  131470. });
  131471. Object.defineProperty(_StencilState.prototype, "stencilOpStencilDepthPass", {
  131472. get: function () {
  131473. return this._stencilOpStencilDepthPass;
  131474. },
  131475. set: function (value) {
  131476. if (this._stencilOpStencilDepthPass === value) {
  131477. return;
  131478. }
  131479. this._stencilOpStencilDepthPass = value;
  131480. this._isStencilOpDirty = true;
  131481. },
  131482. enumerable: true,
  131483. configurable: true
  131484. });
  131485. Object.defineProperty(_StencilState.prototype, "stencilMask", {
  131486. get: function () {
  131487. return this._stencilMask;
  131488. },
  131489. set: function (value) {
  131490. if (this._stencilMask === value) {
  131491. return;
  131492. }
  131493. this._stencilMask = value;
  131494. this._isStencilMaskDirty = true;
  131495. },
  131496. enumerable: true,
  131497. configurable: true
  131498. });
  131499. Object.defineProperty(_StencilState.prototype, "stencilTest", {
  131500. get: function () {
  131501. return this._stencilTest;
  131502. },
  131503. set: function (value) {
  131504. if (this._stencilTest === value) {
  131505. return;
  131506. }
  131507. this._stencilTest = value;
  131508. this._isStencilTestDirty = true;
  131509. },
  131510. enumerable: true,
  131511. configurable: true
  131512. });
  131513. _StencilState.prototype.reset = function () {
  131514. this._stencilTest = false;
  131515. this._stencilMask = 0xFF;
  131516. this._stencilFunc = _StencilState.ALWAYS;
  131517. this._stencilFuncRef = 1;
  131518. this._stencilFuncMask = 0xFF;
  131519. this._stencilOpStencilFail = _StencilState.KEEP;
  131520. this._stencilOpDepthFail = _StencilState.KEEP;
  131521. this._stencilOpStencilDepthPass = _StencilState.REPLACE;
  131522. this._isStencilTestDirty = true;
  131523. this._isStencilMaskDirty = true;
  131524. this._isStencilFuncDirty = true;
  131525. this._isStencilOpDirty = true;
  131526. };
  131527. _StencilState.prototype.apply = function (gl) {
  131528. if (!this.isDirty) {
  131529. return;
  131530. }
  131531. // Stencil test
  131532. if (this._isStencilTestDirty) {
  131533. if (this.stencilTest) {
  131534. gl.enable(gl.STENCIL_TEST);
  131535. }
  131536. else {
  131537. gl.disable(gl.STENCIL_TEST);
  131538. }
  131539. this._isStencilTestDirty = false;
  131540. }
  131541. // Stencil mask
  131542. if (this._isStencilMaskDirty) {
  131543. gl.stencilMask(this.stencilMask);
  131544. this._isStencilMaskDirty = false;
  131545. }
  131546. // Stencil func
  131547. if (this._isStencilFuncDirty) {
  131548. gl.stencilFunc(this.stencilFunc, this.stencilFuncRef, this.stencilFuncMask);
  131549. this._isStencilFuncDirty = false;
  131550. }
  131551. // Stencil op
  131552. if (this._isStencilOpDirty) {
  131553. gl.stencilOp(this.stencilOpStencilFail, this.stencilOpDepthFail, this.stencilOpStencilDepthPass);
  131554. this._isStencilOpDirty = false;
  131555. }
  131556. };
  131557. /** 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 */
  131558. _StencilState.ALWAYS = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ALWAYS;
  131559. /** Passed to stencilOperation to specify that stencil value must be kept */
  131560. _StencilState.KEEP = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].KEEP;
  131561. /** Passed to stencilOperation to specify that stencil value must be replaced */
  131562. _StencilState.REPLACE = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].REPLACE;
  131563. return _StencilState;
  131564. }());
  131565. /***/ }),
  131566. /***/ "./abstractScene.ts":
  131567. /*!**************************!*\
  131568. !*** ./abstractScene.ts ***!
  131569. \**************************/
  131570. /*! exports provided: AbstractScene */
  131571. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131572. "use strict";
  131573. __webpack_require__.r(__webpack_exports__);
  131574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return AbstractScene; });
  131575. /**
  131576. * Base class of the scene acting as a container for the different elements composing a scene.
  131577. * This class is dynamically extended by the different components of the scene increasing
  131578. * flexibility and reducing coupling
  131579. */
  131580. var AbstractScene = /** @class */ (function () {
  131581. function AbstractScene() {
  131582. /**
  131583. * Gets the list of root nodes (ie. nodes with no parent)
  131584. */
  131585. this.rootNodes = new Array();
  131586. /** All of the cameras added to this scene
  131587. * @see http://doc.babylonjs.com/babylon101/cameras
  131588. */
  131589. this.cameras = new Array();
  131590. /**
  131591. * All of the lights added to this scene
  131592. * @see http://doc.babylonjs.com/babylon101/lights
  131593. */
  131594. this.lights = new Array();
  131595. /**
  131596. * All of the (abstract) meshes added to this scene
  131597. */
  131598. this.meshes = new Array();
  131599. /**
  131600. * The list of skeletons added to the scene
  131601. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  131602. */
  131603. this.skeletons = new Array();
  131604. /**
  131605. * All of the particle systems added to this scene
  131606. * @see http://doc.babylonjs.com/babylon101/particles
  131607. */
  131608. this.particleSystems = new Array();
  131609. /**
  131610. * Gets a list of Animations associated with the scene
  131611. */
  131612. this.animations = [];
  131613. /**
  131614. * All of the animation groups added to this scene
  131615. * @see http://doc.babylonjs.com/how_to/group
  131616. */
  131617. this.animationGroups = new Array();
  131618. /**
  131619. * All of the multi-materials added to this scene
  131620. * @see http://doc.babylonjs.com/how_to/multi_materials
  131621. */
  131622. this.multiMaterials = new Array();
  131623. /**
  131624. * All of the materials added to this scene
  131625. * In the context of a Scene, it is not supposed to be modified manually.
  131626. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  131627. * Note also that the order of the Material wihin the array is not significant and might change.
  131628. * @see http://doc.babylonjs.com/babylon101/materials
  131629. */
  131630. this.materials = new Array();
  131631. /**
  131632. * The list of morph target managers added to the scene
  131633. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  131634. */
  131635. this.morphTargetManagers = new Array();
  131636. /**
  131637. * The list of geometries used in the scene.
  131638. */
  131639. this.geometries = new Array();
  131640. /**
  131641. * All of the tranform nodes added to this scene
  131642. * In the context of a Scene, it is not supposed to be modified manually.
  131643. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  131644. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  131645. * @see http://doc.babylonjs.com/how_to/transformnode
  131646. */
  131647. this.transformNodes = new Array();
  131648. /**
  131649. * ActionManagers available on the scene.
  131650. */
  131651. this.actionManagers = new Array();
  131652. /**
  131653. * Textures to keep.
  131654. */
  131655. this.textures = new Array();
  131656. /**
  131657. * Environment texture for the scene
  131658. */
  131659. this.environmentTexture = null;
  131660. }
  131661. /**
  131662. * Adds a parser in the list of available ones
  131663. * @param name Defines the name of the parser
  131664. * @param parser Defines the parser to add
  131665. */
  131666. AbstractScene.AddParser = function (name, parser) {
  131667. this._BabylonFileParsers[name] = parser;
  131668. };
  131669. /**
  131670. * Gets a general parser from the list of avaialble ones
  131671. * @param name Defines the name of the parser
  131672. * @returns the requested parser or null
  131673. */
  131674. AbstractScene.GetParser = function (name) {
  131675. if (this._BabylonFileParsers[name]) {
  131676. return this._BabylonFileParsers[name];
  131677. }
  131678. return null;
  131679. };
  131680. /**
  131681. * Adds n individual parser in the list of available ones
  131682. * @param name Defines the name of the parser
  131683. * @param parser Defines the parser to add
  131684. */
  131685. AbstractScene.AddIndividualParser = function (name, parser) {
  131686. this._IndividualBabylonFileParsers[name] = parser;
  131687. };
  131688. /**
  131689. * Gets an individual parser from the list of avaialble ones
  131690. * @param name Defines the name of the parser
  131691. * @returns the requested parser or null
  131692. */
  131693. AbstractScene.GetIndividualParser = function (name) {
  131694. if (this._IndividualBabylonFileParsers[name]) {
  131695. return this._IndividualBabylonFileParsers[name];
  131696. }
  131697. return null;
  131698. };
  131699. /**
  131700. * Parser json data and populate both a scene and its associated container object
  131701. * @param jsonData Defines the data to parse
  131702. * @param scene Defines the scene to parse the data for
  131703. * @param container Defines the container attached to the parsing sequence
  131704. * @param rootUrl Defines the root url of the data
  131705. */
  131706. AbstractScene.Parse = function (jsonData, scene, container, rootUrl) {
  131707. for (var parserName in this._BabylonFileParsers) {
  131708. if (this._BabylonFileParsers.hasOwnProperty(parserName)) {
  131709. this._BabylonFileParsers[parserName](jsonData, scene, container, rootUrl);
  131710. }
  131711. }
  131712. };
  131713. /**
  131714. * Stores the list of available parsers in the application.
  131715. */
  131716. AbstractScene._BabylonFileParsers = {};
  131717. /**
  131718. * Stores the list of available individual parsers in the application.
  131719. */
  131720. AbstractScene._IndividualBabylonFileParsers = {};
  131721. return AbstractScene;
  131722. }());
  131723. /***/ }),
  131724. /***/ "./assetContainer.ts":
  131725. /*!***************************!*\
  131726. !*** ./assetContainer.ts ***!
  131727. \***************************/
  131728. /*! exports provided: KeepAssets, AssetContainer */
  131729. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131730. "use strict";
  131731. __webpack_require__.r(__webpack_exports__);
  131732. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return KeepAssets; });
  131733. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return AssetContainer; });
  131734. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  131735. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  131736. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Meshes/mesh */ "./Meshes/mesh.ts");
  131737. /**
  131738. * Set of assets to keep when moving a scene into an asset container.
  131739. */
  131740. var KeepAssets = /** @class */ (function (_super) {
  131741. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeepAssets, _super);
  131742. function KeepAssets() {
  131743. return _super !== null && _super.apply(this, arguments) || this;
  131744. }
  131745. return KeepAssets;
  131746. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  131747. /**
  131748. * Container with a set of assets that can be added or removed from a scene.
  131749. */
  131750. var AssetContainer = /** @class */ (function (_super) {
  131751. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AssetContainer, _super);
  131752. /**
  131753. * Instantiates an AssetContainer.
  131754. * @param scene The scene the AssetContainer belongs to.
  131755. */
  131756. function AssetContainer(scene) {
  131757. var _this = _super.call(this) || this;
  131758. _this.scene = scene;
  131759. _this["sounds"] = [];
  131760. _this["effectLayers"] = [];
  131761. _this["layers"] = [];
  131762. _this["lensFlareSystems"] = [];
  131763. _this["proceduralTextures"] = [];
  131764. _this["reflectionProbes"] = [];
  131765. return _this;
  131766. }
  131767. /**
  131768. * Adds all the assets from the container to the scene.
  131769. */
  131770. AssetContainer.prototype.addAllToScene = function () {
  131771. var _this = this;
  131772. this.cameras.forEach(function (o) {
  131773. _this.scene.addCamera(o);
  131774. });
  131775. this.lights.forEach(function (o) {
  131776. _this.scene.addLight(o);
  131777. });
  131778. this.meshes.forEach(function (o) {
  131779. _this.scene.addMesh(o);
  131780. });
  131781. this.skeletons.forEach(function (o) {
  131782. _this.scene.addSkeleton(o);
  131783. });
  131784. this.animations.forEach(function (o) {
  131785. _this.scene.addAnimation(o);
  131786. });
  131787. this.animationGroups.forEach(function (o) {
  131788. _this.scene.addAnimationGroup(o);
  131789. });
  131790. this.multiMaterials.forEach(function (o) {
  131791. _this.scene.addMultiMaterial(o);
  131792. });
  131793. this.materials.forEach(function (o) {
  131794. _this.scene.addMaterial(o);
  131795. });
  131796. this.morphTargetManagers.forEach(function (o) {
  131797. _this.scene.addMorphTargetManager(o);
  131798. });
  131799. this.geometries.forEach(function (o) {
  131800. _this.scene.addGeometry(o);
  131801. });
  131802. this.transformNodes.forEach(function (o) {
  131803. _this.scene.addTransformNode(o);
  131804. });
  131805. this.actionManagers.forEach(function (o) {
  131806. _this.scene.addActionManager(o);
  131807. });
  131808. this.textures.forEach(function (o) {
  131809. _this.scene.addTexture(o);
  131810. });
  131811. this.reflectionProbes.forEach(function (o) {
  131812. _this.scene.addReflectionProbe(o);
  131813. });
  131814. if (this.environmentTexture) {
  131815. this.scene.environmentTexture = this.environmentTexture;
  131816. }
  131817. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  131818. var component = _a[_i];
  131819. component.addFromContainer(this);
  131820. }
  131821. };
  131822. /**
  131823. * Removes all the assets in the container from the scene
  131824. */
  131825. AssetContainer.prototype.removeAllFromScene = function () {
  131826. var _this = this;
  131827. this.cameras.forEach(function (o) {
  131828. _this.scene.removeCamera(o);
  131829. });
  131830. this.lights.forEach(function (o) {
  131831. _this.scene.removeLight(o);
  131832. });
  131833. this.meshes.forEach(function (o) {
  131834. _this.scene.removeMesh(o);
  131835. });
  131836. this.skeletons.forEach(function (o) {
  131837. _this.scene.removeSkeleton(o);
  131838. });
  131839. this.animations.forEach(function (o) {
  131840. _this.scene.removeAnimation(o);
  131841. });
  131842. this.animationGroups.forEach(function (o) {
  131843. _this.scene.removeAnimationGroup(o);
  131844. });
  131845. this.multiMaterials.forEach(function (o) {
  131846. _this.scene.removeMultiMaterial(o);
  131847. });
  131848. this.materials.forEach(function (o) {
  131849. _this.scene.removeMaterial(o);
  131850. });
  131851. this.morphTargetManagers.forEach(function (o) {
  131852. _this.scene.removeMorphTargetManager(o);
  131853. });
  131854. this.geometries.forEach(function (o) {
  131855. _this.scene.removeGeometry(o);
  131856. });
  131857. this.transformNodes.forEach(function (o) {
  131858. _this.scene.removeTransformNode(o);
  131859. });
  131860. this.actionManagers.forEach(function (o) {
  131861. _this.scene.removeActionManager(o);
  131862. });
  131863. this.textures.forEach(function (o) {
  131864. _this.scene.removeTexture(o);
  131865. });
  131866. this.reflectionProbes.forEach(function (o) {
  131867. _this.scene.removeReflectionProbe(o);
  131868. });
  131869. if (this.environmentTexture === this.scene.environmentTexture) {
  131870. this.scene.environmentTexture = null;
  131871. }
  131872. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  131873. var component = _a[_i];
  131874. component.removeFromContainer(this);
  131875. }
  131876. };
  131877. /**
  131878. * Disposes all the assets in the container
  131879. */
  131880. AssetContainer.prototype.dispose = function () {
  131881. this.cameras.forEach(function (o) {
  131882. o.dispose();
  131883. });
  131884. this.cameras = [];
  131885. this.lights.forEach(function (o) {
  131886. o.dispose();
  131887. });
  131888. this.lights = [];
  131889. this.meshes.forEach(function (o) {
  131890. o.dispose();
  131891. });
  131892. this.meshes = [];
  131893. this.skeletons.forEach(function (o) {
  131894. o.dispose();
  131895. });
  131896. this.skeletons = [];
  131897. this.animationGroups.forEach(function (o) {
  131898. o.dispose();
  131899. });
  131900. this.animationGroups = [];
  131901. this.multiMaterials.forEach(function (o) {
  131902. o.dispose();
  131903. });
  131904. this.multiMaterials = [];
  131905. this.materials.forEach(function (o) {
  131906. o.dispose();
  131907. });
  131908. this.materials = [];
  131909. this.geometries.forEach(function (o) {
  131910. o.dispose();
  131911. });
  131912. this.geometries = [];
  131913. this.transformNodes.forEach(function (o) {
  131914. o.dispose();
  131915. });
  131916. this.transformNodes = [];
  131917. this.actionManagers.forEach(function (o) {
  131918. o.dispose();
  131919. });
  131920. this.actionManagers = [];
  131921. this.textures.forEach(function (o) {
  131922. o.dispose();
  131923. });
  131924. this.textures = [];
  131925. this.reflectionProbes.forEach(function (o) {
  131926. o.dispose();
  131927. });
  131928. this.reflectionProbes = [];
  131929. if (this.environmentTexture) {
  131930. this.environmentTexture.dispose();
  131931. this.environmentTexture = null;
  131932. }
  131933. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  131934. var component = _a[_i];
  131935. component.removeFromContainer(this, true);
  131936. }
  131937. };
  131938. AssetContainer.prototype._moveAssets = function (sourceAssets, targetAssets, keepAssets) {
  131939. if (!sourceAssets) {
  131940. return;
  131941. }
  131942. for (var _i = 0, sourceAssets_1 = sourceAssets; _i < sourceAssets_1.length; _i++) {
  131943. var asset = sourceAssets_1[_i];
  131944. var move = true;
  131945. if (keepAssets) {
  131946. for (var _a = 0, keepAssets_1 = keepAssets; _a < keepAssets_1.length; _a++) {
  131947. var keepAsset = keepAssets_1[_a];
  131948. if (asset === keepAsset) {
  131949. move = false;
  131950. break;
  131951. }
  131952. }
  131953. }
  131954. if (move) {
  131955. targetAssets.push(asset);
  131956. }
  131957. }
  131958. };
  131959. /**
  131960. * Removes all the assets contained in the scene and adds them to the container.
  131961. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  131962. */
  131963. AssetContainer.prototype.moveAllFromScene = function (keepAssets) {
  131964. if (keepAssets === undefined) {
  131965. keepAssets = new KeepAssets();
  131966. }
  131967. for (var key in this) {
  131968. if (this.hasOwnProperty(key)) {
  131969. this[key] = this[key] || [];
  131970. this._moveAssets(this.scene[key], this[key], keepAssets[key]);
  131971. }
  131972. }
  131973. this.removeAllFromScene();
  131974. };
  131975. /**
  131976. * 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.
  131977. * @returns the root mesh
  131978. */
  131979. AssetContainer.prototype.createRootMesh = function () {
  131980. var rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("assetContainerRootMesh", this.scene);
  131981. this.meshes.forEach(function (m) {
  131982. if (!m.parent) {
  131983. rootMesh.addChild(m);
  131984. }
  131985. });
  131986. this.meshes.unshift(rootMesh);
  131987. return rootMesh;
  131988. };
  131989. return AssetContainer;
  131990. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  131991. /***/ }),
  131992. /***/ "./index.ts":
  131993. /*!******************!*\
  131994. !*** ./index.ts ***!
  131995. \******************/
  131996. /*! exports provided: AbstractScene, KeepAssets, AssetContainer, Node, Scene, SceneComponentConstants, Stage, Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction, Animatable, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange, Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound, Bone, BoneIKController, BoneLookController, Skeleton, CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, EquiRectangularCubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, TrailMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, BoxBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, MorphTarget, MorphTargetManager, Database, BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEventOptions, PhysicsUpdraftEventOptions, PhysicsVortexEventOptions, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, AnaglyphPostProcess, BlackAndWhitePostProcess, BloomEffect, BloomMergePostProcess, BlurPostProcess, ChromaticAberrationPostProcess, CircleOfConfusionPostProcess, ColorCorrectionPostProcess, ConvolutionPostProcess, DepthOfFieldBlurPostProcess, DepthOfFieldEffectBlurLevel, DepthOfFieldEffect, DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess, DisplayPassPostProcess, ExtractHighlightsPostProcess, FilterPostProcess, FxaaPostProcess, GrainPostProcess, HighlightsPostProcess, ImageProcessingPostProcess, MotionBlurPostProcess, PassPostProcess, PassCubePostProcess, PostProcess, PostProcessManager, RefractionPostProcess, SharpenPostProcess, StereoscopicInterlacePostProcess, TonemappingOperator, TonemapPostProcess, VolumetricLightScatteringPostProcess, VRDistortionCorrectionPostProcess, VRMultiviewToSingleviewPostProcess, ReflectionProbe, BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer, Sprite, SpriteManager, SpriteSceneComponent, _AlphaState, _DepthCullingState, _StencilState, AndOrNotEvaluator, AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, EquiRectangularCubeTextureAssetTask, AssetsManager, DDSTools, expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsMatrix, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, MeshExploder, FilesInput, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, WebRequest, InspectableType, AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRMaterialDefines, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, DracoCompression, DiscBuilder, RibbonBuilder, HemisphereBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  131997. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131998. "use strict";
  131999. __webpack_require__.r(__webpack_exports__);
  132000. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  132001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _abstractScene__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  132002. /* harmony import */ var _Actions_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Actions/index */ "./Actions/index.ts");
  132003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Action"]; });
  132004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  132005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionManager"]; });
  132006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Condition"]; });
  132007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ValueCondition"]; });
  132008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PredicateCondition"]; });
  132009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StateCondition"]; });
  132010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SwitchBooleanAction"]; });
  132011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetStateAction"]; });
  132012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetValueAction"]; });
  132013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["IncrementValueAction"]; });
  132014. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlayAnimationAction"]; });
  132015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopAnimationAction"]; });
  132016. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["DoNothingAction"]; });
  132017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["CombineAction"]; });
  132018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ExecuteCodeAction"]; });
  132019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetParentAction"]; });
  132020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlaySoundAction"]; });
  132021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopSoundAction"]; });
  132022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["InterpolateValueAction"]; });
  132023. /* harmony import */ var _Animations_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Animations/index */ "./Animations/index.ts");
  132024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animatable"]; });
  132025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animation"]; });
  132026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  132027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  132028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationPropertiesOverride"]; });
  132029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["EasingFunction"]; });
  132030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CircleEase"]; });
  132031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BackEase"]; });
  132032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BounceEase"]; });
  132033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CubicEase"]; });
  132034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ElasticEase"]; });
  132035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ExponentialEase"]; });
  132036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["PowerEase"]; });
  132037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuadraticEase"]; });
  132038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuarticEase"]; });
  132039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuinticEase"]; });
  132040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["SineEase"]; });
  132041. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BezierCurveEase"]; });
  132042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["RuntimeAnimation"]; });
  132043. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationEvent"]; });
  132044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationKeyInterpolation"]; });
  132045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationRange"]; });
  132046. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./assetContainer */ "./assetContainer.ts");
  132047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["KeepAssets"]; });
  132048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["AssetContainer"]; });
  132049. /* harmony import */ var _Audio_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Audio/index */ "./Audio/index.ts");
  132050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Analyser"]; });
  132051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioEngine"]; });
  132052. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioSceneComponent"]; });
  132053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Sound"]; });
  132054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  132055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["WeightedSound"]; });
  132056. /* harmony import */ var _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Behaviors/index */ "./Behaviors/index.ts");
  132057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AutoRotationBehavior"]; });
  132058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["BouncingBehavior"]; });
  132059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FramingBehavior"]; });
  132060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AttachToBoxBehavior"]; });
  132061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FadeInOutBehavior"]; });
  132062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["MultiPointerScaleBehavior"]; });
  132063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]; });
  132064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]; });
  132065. /* harmony import */ var _Bones_index__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Bones/index */ "./Bones/index.ts");
  132066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Bone"]; });
  132067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneIKController"]; });
  132068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneLookController"]; });
  132069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Skeleton"]; });
  132070. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Cameras/index */ "./Cameras/index.ts");
  132071. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputTypes"]; });
  132072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputsManager"]; });
  132073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["Camera"]; });
  132074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TargetCamera"]; });
  132075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCamera"]; });
  132076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraInputsManager"]; });
  132077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TouchCamera"]; });
  132078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  132079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraInputsManager"]; });
  132080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["DeviceOrientationCamera"]; });
  132081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCamera"]; });
  132082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraInputsManager"]; });
  132083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCamera"]; });
  132084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcFollowCamera"]; });
  132085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["GamepadCamera"]; });
  132086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["UniversalCamera"]; });
  132087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VirtualJoysticksCamera"]; });
  132088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraGamepadInput"]; });
  132089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraKeyboardMoveInput"]; });
  132090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraMouseWheelInput"]; });
  132091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraPointersInput"]; });
  132092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraVRDeviceOrientationInput"]; });
  132093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraKeyboardInput"]; });
  132094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraMouseInput"]; });
  132095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraKeyboardMoveInput"]; });
  132096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraMouseWheelInput"]; });
  132097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraPointersInput"]; });
  132098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  132099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraGamepadInput"]; });
  132100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraKeyboardMoveInput"]; });
  132101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraMouseInput"]; });
  132102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraTouchInput"]; });
  132103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraVirtualJoystickInput"]; });
  132104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphArcRotateCamera"]; });
  132105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphFreeCamera"]; });
  132106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphGamepadCamera"]; });
  132107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphUniversalCamera"]; });
  132108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicArcRotateCamera"]; });
  132109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicFreeCamera"]; });
  132110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicGamepadCamera"]; });
  132111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  132112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRCameraMetrics"]; });
  132113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationArcRotateCamera"]; });
  132114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationFreeCamera"]; });
  132115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationGamepadCamera"]; });
  132116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["OnAfterEnteringVRObservableEvent"]; });
  132117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRExperienceHelper"]; });
  132118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]; });
  132119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRCamera"]; });
  132120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIButton"]; });
  132121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIOptions"]; });
  132122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUI"]; });
  132123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRState"]; });
  132124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRExperienceHelper"]; });
  132125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRController"]; });
  132126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRInput"]; });
  132127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRManagedOutputCanvas"]; });
  132128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRSessionManager"]; });
  132129. /* harmony import */ var _Collisions_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Collisions/index */ "./Collisions/index.ts");
  132130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["Collider"]; });
  132131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["DefaultCollisionCoordinator"]; });
  132132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]; });
  132133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["IntersectionInfo"]; });
  132134. /* harmony import */ var _Culling_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Culling/index */ "./Culling/index.ts");
  132135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingBox"]; });
  132136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"]; });
  132137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingSphere"]; });
  132138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Ray"]; });
  132139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Octree"]; });
  132140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeBlock"]; });
  132141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeSceneComponent"]; });
  132142. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Debug/index */ "./Debug/index.ts");
  132143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["AxesViewer"]; });
  132144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["BoneAxesViewer"]; });
  132145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["DebugLayer"]; });
  132146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["PhysicsViewer"]; });
  132147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["RayHelper"]; });
  132148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["SkeletonViewer"]; });
  132149. /* harmony import */ var _Engines_index__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Engines/index */ "./Engines/index.ts");
  132150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Constants"]; });
  132151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["InstancingAttributeInfo"]; });
  132152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["DepthTextureCreationOptions"]; });
  132153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineCapabilities"]; });
  132154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Engine"]; });
  132155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineStore"]; });
  132156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngineOptions"]; });
  132157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngine"]; });
  132158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_OcclusionDataStorage"]; });
  132159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_forceTransformFeedbackToBundle"]; });
  132160. /* harmony import */ var _Events_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Events/index */ "./Events/index.ts");
  132161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardEventTypes"]; });
  132162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfo"]; });
  132163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfoPre"]; });
  132164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerEventTypes"]; });
  132165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoBase"]; });
  132166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoPre"]; });
  132167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfo"]; });
  132168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardEventTypes"]; });
  132169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardInfo"]; });
  132170. /* harmony import */ var _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Gamepads/index */ "./Gamepads/index.ts");
  132171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["DaydreamController"]; });
  132172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GearVRController"]; });
  132173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericController"]; });
  132174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["OculusTouchController"]; });
  132175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerType"]; });
  132176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerHelper"]; });
  132177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledController"]; });
  132178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["ViveController"]; });
  132179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WebVRController"]; });
  132180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WindowsMotionController"]; });
  132181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["StickValues"]; });
  132182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Gamepad"]; });
  132183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericPad"]; });
  132184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadManager"]; });
  132185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadSystemSceneComponent"]; });
  132186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"]; });
  132187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Dpad"]; });
  132188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Pad"]; });
  132189. /* harmony import */ var _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Gizmos/index */ "./Gizmos/index.ts");
  132190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisDragGizmo"]; });
  132191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisScaleGizmo"]; });
  132192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["BoundingBoxGizmo"]; });
  132193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["Gizmo"]; });
  132194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["GizmoManager"]; });
  132195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PlaneRotationGizmo"]; });
  132196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PositionGizmo"]; });
  132197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["RotationGizmo"]; });
  132198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["ScaleGizmo"]; });
  132199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["LightGizmo"]; });
  132200. /* harmony import */ var _Helpers_index__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Helpers/index */ "./Helpers/index.ts");
  132201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["EnvironmentHelper"]; });
  132202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["PhotoDome"]; });
  132203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["_forceSceneHelpersToBundle"]; });
  132204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["VideoDome"]; });
  132205. /* harmony import */ var _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Instrumentation/index */ "./Instrumentation/index.ts");
  132206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["EngineInstrumentation"]; });
  132207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["SceneInstrumentation"]; });
  132208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["_TimeToken"]; });
  132209. /* harmony import */ var _Layers_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Layers/index */ "./Layers/index.ts");
  132210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayer"]; });
  132211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayerSceneComponent"]; });
  132212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["GlowLayer"]; });
  132213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["HighlightLayer"]; });
  132214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["Layer"]; });
  132215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["LayerSceneComponent"]; });
  132216. /* harmony import */ var _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./LensFlares/index */ "./LensFlares/index.ts");
  132217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlare"]; });
  132218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystem"]; });
  132219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystemSceneComponent"]; });
  132220. /* harmony import */ var _Lights_index__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Lights/index */ "./Lights/index.ts");
  132221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["Light"]; });
  132222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowLight"]; });
  132223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["DirectionalLight"]; });
  132224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["HemisphericLight"]; });
  132225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["PointLight"]; });
  132226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["SpotLight"]; });
  132227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGenerator"]; });
  132228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGeneratorSceneComponent"]; });
  132229. /* harmony import */ var _Loading_index__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Loading/index */ "./Loading/index.ts");
  132230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["DefaultLoadingScreen"]; });
  132231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderProgressEvent"]; });
  132232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoader"]; });
  132233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderFlags"]; });
  132234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["_BabylonLoaderRegistered"]; });
  132235. /* harmony import */ var _Materials_index__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Materials/index */ "./Materials/index.ts");
  132236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorCurves"]; });
  132237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectFallbacks"]; });
  132238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectCreationOptions"]; });
  132239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Effect"]; });
  132240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["FresnelParameters"]; });
  132241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfigurationDefines"]; });
  132242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfiguration"]; });
  132243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Material"]; });
  132244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialDefines"]; });
  132245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialHelper"]; });
  132246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiMaterial"]; });
  132247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PushMaterial"]; });
  132248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ShaderMaterial"]; });
  132249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterialDefines"]; });
  132250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterial"]; });
  132251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BaseTexture"]; });
  132252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CubeTexture"]; });
  132253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EquiRectangularCubeTexture"]; });
  132254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["HDRCubeTexture"]; });
  132255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["InternalTexture"]; });
  132256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DummyInternalTextureTracker"]; });
  132257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MirrorTexture"]; });
  132258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiRenderTarget"]; });
  132259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture"]; });
  132260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RenderTargetTexture"]; });
  132261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Texture"]; });
  132262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["UniformBuffer"]; });
  132263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialFlags"]; });
  132264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BackgroundMaterial"]; });
  132265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMaterialDefines"]; });
  132266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseMaterial"]; });
  132267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseSimpleMaterial"]; });
  132268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMaterial"]; });
  132269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMetallicRoughnessMaterial"]; });
  132270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRSpecularGlossinessMaterial"]; });
  132271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorGradingTexture"]; });
  132272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DynamicTexture"]; });
  132273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTexture"]; });
  132274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawCubeTexture"]; });
  132275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture3D"]; });
  132276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RefractionTexture"]; });
  132277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["VideoTexture"]; });
  132278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_DDSTextureLoader"]; });
  132279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_ENVTextureLoader"]; });
  132280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_KTXTextureLoader"]; });
  132281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_TGATextureLoader"]; });
  132282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CustomProceduralTexture"]; });
  132283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["NoiseProceduralTexture"]; });
  132284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTextureSceneComponent"]; });
  132285. /* harmony import */ var _Maths_index__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Maths/index */ "./Maths/index.ts");
  132286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Scalar"]; });
  132287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToGammaSpace"]; });
  132288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToLinearSpace"]; });
  132289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Epsilon"]; });
  132290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color3"]; });
  132291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color4"]; });
  132292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector2"]; });
  132293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector3"]; });
  132294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector4"]; });
  132295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Size"]; });
  132296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Quaternion"]; });
  132297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Matrix"]; });
  132298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Plane"]; });
  132299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Viewport"]; });
  132300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Frustum"]; });
  132301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Space"]; });
  132302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Axis"]; });
  132303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["BezierCurve"]; });
  132304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Orientation"]; });
  132305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Angle"]; });
  132306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Arc2"]; });
  132307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path2"]; });
  132308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path3D"]; });
  132309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Curve3"]; });
  132310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalVertex"]; });
  132311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalTextureVertex"]; });
  132312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Tmp"]; });
  132313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalPolynomial"]; });
  132314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalHarmonics"]; });
  132315. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Meshes/index */ "./Meshes/index.ts");
  132316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["AbstractMesh"]; });
  132317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Buffer"]; });
  132318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexBuffer"]; });
  132319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CSG"]; });
  132320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Geometry"]; });
  132321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundMesh"]; });
  132322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TrailMesh"]; });
  132323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedMesh"]; });
  132324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesMesh"]; });
  132325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedLinesMesh"]; });
  132326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshLODLevel"]; });
  132327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_CreationDataStorage"]; });
  132328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_InstancesBatch"]; });
  132329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Mesh"]; });
  132330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexData"]; });
  132331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshBuilder"]; });
  132332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationSettings"]; });
  132333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationQueue"]; });
  132334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationType"]; });
  132335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplicationQueueSceneComponent"]; });
  132336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Polygon"]; });
  132337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonMeshBuilder"]; });
  132338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BaseSubMesh"]; });
  132339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SubMesh"]; });
  132340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TransformNode"]; });
  132341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BoxBuilder"]; });
  132342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SphereBuilder"]; });
  132343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CylinderBuilder"]; });
  132344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesBuilder"]; });
  132345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PlaneBuilder"]; });
  132346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DracoCompression"]; });
  132347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DiscBuilder"]; });
  132348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["RibbonBuilder"]; });
  132349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["HemisphereBuilder"]; });
  132350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusBuilder"]; });
  132351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusKnotBuilder"]; });
  132352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonBuilder"]; });
  132353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["ShapeBuilder"]; });
  132354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LatheBuilder"]; });
  132355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundBuilder"]; });
  132356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TubeBuilder"]; });
  132357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolyhedronBuilder"]; });
  132358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["IcoSphereBuilder"]; });
  132359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DecalBuilder"]; });
  132360. /* harmony import */ var _Morph_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Morph/index */ "./Morph/index.ts");
  132361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTarget"]; });
  132362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTargetManager"]; });
  132363. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./node */ "./node.ts");
  132364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _node__WEBPACK_IMPORTED_MODULE_25__["Node"]; });
  132365. /* harmony import */ var _Offline_index__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Offline/index */ "./Offline/index.ts");
  132366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _Offline_index__WEBPACK_IMPORTED_MODULE_26__["Database"]; });
  132367. /* harmony import */ var _Particles_index__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Particles/index */ "./Particles/index.ts");
  132368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BaseParticleSystem"]; });
  132369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["GPUParticleSystem"]; });
  132370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["Particle"]; });
  132371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleHelper"]; });
  132372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystem"]; });
  132373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["_IDoNeedToBeInTheBuild"]; });
  132374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystemSet"]; });
  132375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticle"]; });
  132376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ModelShape"]; });
  132377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["DepthSortedParticle"]; });
  132378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticleSystem"]; });
  132379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitterType"]; });
  132380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitter"]; });
  132381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BoxParticleEmitter"]; });
  132382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ConeParticleEmitter"]; });
  132383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderParticleEmitter"]; });
  132384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderDirectedParticleEmitter"]; });
  132385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["HemisphericParticleEmitter"]; });
  132386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["PointParticleEmitter"]; });
  132387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereParticleEmitter"]; });
  132388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereDirectedParticleEmitter"]; });
  132389. /* harmony import */ var _Physics_index__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./Physics/index */ "./Physics/index.ts");
  132390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngine"]; });
  132391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngineSceneComponent"]; });
  132392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsHelper"]; });
  132393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialExplosionEventOptions"]; });
  132394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftEventOptions"]; });
  132395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsVortexEventOptions"]; });
  132396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialImpulseFalloff"]; });
  132397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftMode"]; });
  132398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsImpostor"]; });
  132399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsJoint"]; });
  132400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["DistanceJoint"]; });
  132401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["MotorEnabledJoint"]; });
  132402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["HingeJoint"]; });
  132403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["Hinge2Joint"]; });
  132404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["CannonJSPlugin"]; });
  132405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["AmmoJSPlugin"]; });
  132406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["OimoJSPlugin"]; });
  132407. /* harmony import */ var _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./PostProcesses/index */ "./PostProcesses/index.ts");
  132408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["AnaglyphPostProcess"]; });
  132409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlackAndWhitePostProcess"]; });
  132410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomEffect"]; });
  132411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomMergePostProcess"]; });
  132412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlurPostProcess"]; });
  132413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ChromaticAberrationPostProcess"]; });
  132414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["CircleOfConfusionPostProcess"]; });
  132415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ColorCorrectionPostProcess"]; });
  132416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ConvolutionPostProcess"]; });
  132417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldBlurPostProcess"]; });
  132418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffectBlurLevel"]; });
  132419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffect"]; });
  132420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcessOptions"]; });
  132421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcess"]; });
  132422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DisplayPassPostProcess"]; });
  132423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ExtractHighlightsPostProcess"]; });
  132424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FilterPostProcess"]; });
  132425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FxaaPostProcess"]; });
  132426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["GrainPostProcess"]; });
  132427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["HighlightsPostProcess"]; });
  132428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ImageProcessingPostProcess"]; });
  132429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["MotionBlurPostProcess"]; });
  132430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassPostProcess"]; });
  132431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassCubePostProcess"]; });
  132432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcess"]; });
  132433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessManager"]; });
  132434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["RefractionPostProcess"]; });
  132435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SharpenPostProcess"]; });
  132436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StereoscopicInterlacePostProcess"]; });
  132437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemappingOperator"]; });
  132438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemapPostProcess"]; });
  132439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VolumetricLightScatteringPostProcess"]; });
  132440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  132441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleviewPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VRMultiviewToSingleviewPostProcess"]; });
  132442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderEffect"]; });
  132443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipeline"]; });
  132444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManager"]; });
  132445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManagerSceneComponent"]; });
  132446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DefaultRenderingPipeline"]; });
  132447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["LensRenderingPipeline"]; });
  132448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAO2RenderingPipeline"]; });
  132449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAORenderingPipeline"]; });
  132450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StandardRenderingPipeline"]; });
  132451. /* harmony import */ var _Probes_index__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./Probes/index */ "./Probes/index.ts");
  132452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _Probes_index__WEBPACK_IMPORTED_MODULE_30__["ReflectionProbe"]; });
  132453. /* harmony import */ var _Rendering_index__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./Rendering/index */ "./Rendering/index.ts");
  132454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["BoundingBoxRenderer"]; });
  132455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRenderer"]; });
  132456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRendererSceneComponent"]; });
  132457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["EdgesRenderer"]; });
  132458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["LineEdgesRenderer"]; });
  132459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRenderer"]; });
  132460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRendererSceneComponent"]; });
  132461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["OutlineRenderer"]; });
  132462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroup"]; });
  132463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroupInfo"]; });
  132464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingManager"]; });
  132465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["UtilityLayerRenderer"]; });
  132466. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./scene */ "./scene.ts");
  132467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _scene__WEBPACK_IMPORTED_MODULE_32__["Scene"]; });
  132468. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  132469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["SceneComponentConstants"]; });
  132470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["Stage"]; });
  132471. /* harmony import */ var _Sprites_index__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./Sprites/index */ "./Sprites/index.ts");
  132472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["Sprite"]; });
  132473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteManager"]; });
  132474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteSceneComponent"]; });
  132475. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./States/index */ "./States/index.ts");
  132476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_AlphaState"]; });
  132477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_DepthCullingState"]; });
  132478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_StencilState"]; });
  132479. /* harmony import */ var _Misc_index__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./Misc/index */ "./Misc/index.ts");
  132480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AndOrNotEvaluator"]; });
  132481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetTaskState"]; });
  132482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AbstractAssetTask"]; });
  132483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsProgressEvent"]; });
  132484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MeshAssetTask"]; });
  132485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextFileAssetTask"]; });
  132486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["BinaryFileAssetTask"]; });
  132487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ImageAssetTask"]; });
  132488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureAssetTask"]; });
  132489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeTextureAssetTask"]; });
  132490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRCubeTextureAssetTask"]; });
  132491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EquiRectangularCubeTextureAssetTask"]; });
  132492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsManager"]; });
  132493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DDSTools"]; });
  132494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["expandToProperty"]; });
  132495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serialize"]; });
  132496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsTexture"]; });
  132497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor3"]; });
  132498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsFresnelParameters"]; });
  132499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector2"]; });
  132500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector3"]; });
  132501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsMeshReference"]; });
  132502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColorCurves"]; });
  132503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor4"]; });
  132504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsImageProcessingConfiguration"]; });
  132505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsQuaternion"]; });
  132506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsMatrix"]; });
  132507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsCameraReference"]; });
  132508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SerializationHelper"]; });
  132509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Deferred"]; });
  132510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EnvironmentTextureTools"]; });
  132511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MeshExploder"]; });
  132512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInput"]; });
  132513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["KhronosTextureContainer"]; });
  132514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EventState"]; });
  132515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observer"]; });
  132516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MultiObserver"]; });
  132517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observable"]; });
  132518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerformanceMonitor"]; });
  132519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RollingAverage"]; });
  132520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PromisePolyfill"]; });
  132521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimization"]; });
  132522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureOptimization"]; });
  132523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HardwareScalingOptimization"]; });
  132524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ShadowsOptimization"]; });
  132525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PostProcessesOptimization"]; });
  132526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LensFlaresOptimization"]; });
  132527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CustomOptimization"]; });
  132528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ParticlesOptimization"]; });
  132529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RenderTargetsOptimization"]; });
  132530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MergeMeshesOptimization"]; });
  132531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizerOptions"]; });
  132532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizer"]; });
  132533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneSerializer"]; });
  132534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArray"]; });
  132535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArrayNoDuplicate"]; });
  132536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["StringDictionary"]; });
  132537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tags"]; });
  132538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureTools"]; });
  132539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TGATools"]; });
  132540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ColorGradient"]; });
  132541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Color3Gradient"]; });
  132542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FactorGradient"]; });
  132543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LoadFileError"]; });
  132544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RetryStrategy"]; });
  132545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tools"]; });
  132546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerfCounter"]; });
  132547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["className"]; });
  132548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AsyncLoop"]; });
  132549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VideoRecorder"]; });
  132550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["JoystickAxis"]; });
  132551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VirtualJoystick"]; });
  132552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["WorkerPool"]; });
  132553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Logger"]; });
  132554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["_TypeStore"]; });
  132555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInputStore"]; });
  132556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DeepCopier"]; });
  132557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PivotTools"]; });
  132558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PrecisionDate"]; });
  132559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ScreenshotTools"]; });
  132560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["WebRequest"]; });
  132561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["InspectableType"]; });
  132562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeMapToSphericalPolynomialTools"]; });
  132563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRTools"]; });
  132564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PanoramaToCubeMapTools"]; });
  132565. /***/ }),
  132566. /***/ "./node.ts":
  132567. /*!*****************!*\
  132568. !*** ./node.ts ***!
  132569. \*****************/
  132570. /*! exports provided: Node */
  132571. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132572. "use strict";
  132573. __webpack_require__.r(__webpack_exports__);
  132574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return Node; });
  132575. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  132576. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  132577. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/decorators */ "./Misc/decorators.ts");
  132578. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  132579. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  132580. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  132581. /**
  132582. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  132583. */
  132584. var Node = /** @class */ (function () {
  132585. /**
  132586. * Creates a new Node
  132587. * @param name the name and id to be given to this node
  132588. * @param scene the scene this node will be added to
  132589. * @param addToRootNodes the node will be added to scene.rootNodes
  132590. */
  132591. function Node(name, scene, addToRootNodes) {
  132592. if (scene === void 0) { scene = null; }
  132593. if (addToRootNodes === void 0) { addToRootNodes = true; }
  132594. /**
  132595. * Gets or sets a string used to store user defined state for the node
  132596. */
  132597. this.state = "";
  132598. /**
  132599. * Gets or sets an object used to store user defined information for the node
  132600. */
  132601. this.metadata = null;
  132602. /**
  132603. * For internal use only. Please do not use.
  132604. */
  132605. this.reservedDataStore = null;
  132606. /**
  132607. * Gets or sets a boolean used to define if the node must be serialized
  132608. */
  132609. this.doNotSerialize = false;
  132610. /** @hidden */
  132611. this._isDisposed = false;
  132612. /**
  132613. * Gets a list of Animations associated with the node
  132614. */
  132615. this.animations = new Array();
  132616. this._ranges = {};
  132617. this._isEnabled = true;
  132618. this._isParentEnabled = true;
  132619. this._isReady = true;
  132620. /** @hidden */
  132621. this._currentRenderId = -1;
  132622. this._parentUpdateId = -1;
  132623. this._childUpdateId = -1;
  132624. /** @hidden */
  132625. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  132626. /** @hidden */
  132627. this._worldMatrixDeterminant = 0;
  132628. /** @hidden */
  132629. this._sceneRootNodesIndex = -1;
  132630. this._animationPropertiesOverride = null;
  132631. /** @hidden */
  132632. this._isNode = true;
  132633. /**
  132634. * An event triggered when the mesh is disposed
  132635. */
  132636. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  132637. // Behaviors
  132638. this._behaviors = new Array();
  132639. this.name = name;
  132640. this.id = name;
  132641. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene);
  132642. this.uniqueId = this._scene.getUniqueId();
  132643. this._initCache();
  132644. if (addToRootNodes) {
  132645. this.addToSceneRootNodes();
  132646. }
  132647. }
  132648. /**
  132649. * Add a new node constructor
  132650. * @param type defines the type name of the node to construct
  132651. * @param constructorFunc defines the constructor function
  132652. */
  132653. Node.AddNodeConstructor = function (type, constructorFunc) {
  132654. this._NodeConstructors[type] = constructorFunc;
  132655. };
  132656. /**
  132657. * Returns a node constructor based on type name
  132658. * @param type defines the type name
  132659. * @param name defines the new node name
  132660. * @param scene defines the hosting scene
  132661. * @param options defines optional options to transmit to constructors
  132662. * @returns the new constructor or null
  132663. */
  132664. Node.Construct = function (type, name, scene, options) {
  132665. var constructorFunc = this._NodeConstructors[type];
  132666. if (!constructorFunc) {
  132667. return null;
  132668. }
  132669. return constructorFunc(name, scene, options);
  132670. };
  132671. /**
  132672. * Gets a boolean indicating if the node has been disposed
  132673. * @returns true if the node was disposed
  132674. */
  132675. Node.prototype.isDisposed = function () {
  132676. return this._isDisposed;
  132677. };
  132678. Object.defineProperty(Node.prototype, "parent", {
  132679. get: function () {
  132680. return this._parentNode;
  132681. },
  132682. /**
  132683. * Gets or sets the parent of the node (without keeping the current position in the scene)
  132684. * @see https://doc.babylonjs.com/how_to/parenting
  132685. */
  132686. set: function (parent) {
  132687. if (this._parentNode === parent) {
  132688. return;
  132689. }
  132690. var previousParentNode = this._parentNode;
  132691. // Remove self from list of children of parent
  132692. if (this._parentNode && this._parentNode._children !== undefined && this._parentNode._children !== null) {
  132693. var index = this._parentNode._children.indexOf(this);
  132694. if (index !== -1) {
  132695. this._parentNode._children.splice(index, 1);
  132696. }
  132697. if (!parent && !this._isDisposed) {
  132698. this.addToSceneRootNodes();
  132699. }
  132700. }
  132701. // Store new parent
  132702. this._parentNode = parent;
  132703. // Add as child to new parent
  132704. if (this._parentNode) {
  132705. if (this._parentNode._children === undefined || this._parentNode._children === null) {
  132706. this._parentNode._children = new Array();
  132707. }
  132708. this._parentNode._children.push(this);
  132709. if (!previousParentNode) {
  132710. this.removeFromSceneRootNodes();
  132711. }
  132712. }
  132713. // Enabled state
  132714. this._syncParentEnabledState();
  132715. },
  132716. enumerable: true,
  132717. configurable: true
  132718. });
  132719. Node.prototype.addToSceneRootNodes = function () {
  132720. if (this._sceneRootNodesIndex === -1) {
  132721. this._sceneRootNodesIndex = this._scene.rootNodes.length;
  132722. this._scene.rootNodes.push(this);
  132723. }
  132724. };
  132725. Node.prototype.removeFromSceneRootNodes = function () {
  132726. if (this._sceneRootNodesIndex !== -1) {
  132727. var rootNodes = this._scene.rootNodes;
  132728. var lastIdx = rootNodes.length - 1;
  132729. rootNodes[this._sceneRootNodesIndex] = rootNodes[lastIdx];
  132730. rootNodes[this._sceneRootNodesIndex]._sceneRootNodesIndex = this._sceneRootNodesIndex;
  132731. this._scene.rootNodes.pop();
  132732. this._sceneRootNodesIndex = -1;
  132733. }
  132734. };
  132735. Object.defineProperty(Node.prototype, "animationPropertiesOverride", {
  132736. /**
  132737. * Gets or sets the animation properties override
  132738. */
  132739. get: function () {
  132740. if (!this._animationPropertiesOverride) {
  132741. return this._scene.animationPropertiesOverride;
  132742. }
  132743. return this._animationPropertiesOverride;
  132744. },
  132745. set: function (value) {
  132746. this._animationPropertiesOverride = value;
  132747. },
  132748. enumerable: true,
  132749. configurable: true
  132750. });
  132751. /**
  132752. * Gets a string idenfifying the name of the class
  132753. * @returns "Node" string
  132754. */
  132755. Node.prototype.getClassName = function () {
  132756. return "Node";
  132757. };
  132758. Object.defineProperty(Node.prototype, "onDispose", {
  132759. /**
  132760. * Sets a callback that will be raised when the node will be disposed
  132761. */
  132762. set: function (callback) {
  132763. if (this._onDisposeObserver) {
  132764. this.onDisposeObservable.remove(this._onDisposeObserver);
  132765. }
  132766. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  132767. },
  132768. enumerable: true,
  132769. configurable: true
  132770. });
  132771. /**
  132772. * Gets the scene of the node
  132773. * @returns a scene
  132774. */
  132775. Node.prototype.getScene = function () {
  132776. return this._scene;
  132777. };
  132778. /**
  132779. * Gets the engine of the node
  132780. * @returns a Engine
  132781. */
  132782. Node.prototype.getEngine = function () {
  132783. return this._scene.getEngine();
  132784. };
  132785. /**
  132786. * Attach a behavior to the node
  132787. * @see http://doc.babylonjs.com/features/behaviour
  132788. * @param behavior defines the behavior to attach
  132789. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  132790. * @returns the current Node
  132791. */
  132792. Node.prototype.addBehavior = function (behavior, attachImmediately) {
  132793. var _this = this;
  132794. if (attachImmediately === void 0) { attachImmediately = false; }
  132795. var index = this._behaviors.indexOf(behavior);
  132796. if (index !== -1) {
  132797. return this;
  132798. }
  132799. behavior.init();
  132800. if (this._scene.isLoading && !attachImmediately) {
  132801. // We defer the attach when the scene will be loaded
  132802. this._scene.onDataLoadedObservable.addOnce(function () {
  132803. behavior.attach(_this);
  132804. });
  132805. }
  132806. else {
  132807. behavior.attach(this);
  132808. }
  132809. this._behaviors.push(behavior);
  132810. return this;
  132811. };
  132812. /**
  132813. * Remove an attached behavior
  132814. * @see http://doc.babylonjs.com/features/behaviour
  132815. * @param behavior defines the behavior to attach
  132816. * @returns the current Node
  132817. */
  132818. Node.prototype.removeBehavior = function (behavior) {
  132819. var index = this._behaviors.indexOf(behavior);
  132820. if (index === -1) {
  132821. return this;
  132822. }
  132823. this._behaviors[index].detach();
  132824. this._behaviors.splice(index, 1);
  132825. return this;
  132826. };
  132827. Object.defineProperty(Node.prototype, "behaviors", {
  132828. /**
  132829. * Gets the list of attached behaviors
  132830. * @see http://doc.babylonjs.com/features/behaviour
  132831. */
  132832. get: function () {
  132833. return this._behaviors;
  132834. },
  132835. enumerable: true,
  132836. configurable: true
  132837. });
  132838. /**
  132839. * Gets an attached behavior by name
  132840. * @param name defines the name of the behavior to look for
  132841. * @see http://doc.babylonjs.com/features/behaviour
  132842. * @returns null if behavior was not found else the requested behavior
  132843. */
  132844. Node.prototype.getBehaviorByName = function (name) {
  132845. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  132846. var behavior = _a[_i];
  132847. if (behavior.name === name) {
  132848. return behavior;
  132849. }
  132850. }
  132851. return null;
  132852. };
  132853. /**
  132854. * Returns the latest update of the World matrix
  132855. * @returns a Matrix
  132856. */
  132857. Node.prototype.getWorldMatrix = function () {
  132858. if (this._currentRenderId !== this._scene.getRenderId()) {
  132859. this.computeWorldMatrix();
  132860. }
  132861. return this._worldMatrix;
  132862. };
  132863. /** @hidden */
  132864. Node.prototype._getWorldMatrixDeterminant = function () {
  132865. return this._worldMatrixDeterminant;
  132866. };
  132867. Object.defineProperty(Node.prototype, "worldMatrixFromCache", {
  132868. /**
  132869. * Returns directly the latest state of the mesh World matrix.
  132870. * A Matrix is returned.
  132871. */
  132872. get: function () {
  132873. return this._worldMatrix;
  132874. },
  132875. enumerable: true,
  132876. configurable: true
  132877. });
  132878. // override it in derived class if you add new variables to the cache
  132879. // and call the parent class method
  132880. /** @hidden */
  132881. Node.prototype._initCache = function () {
  132882. this._cache = {};
  132883. this._cache.parent = undefined;
  132884. };
  132885. /** @hidden */
  132886. Node.prototype.updateCache = function (force) {
  132887. if (!force && this.isSynchronized()) {
  132888. return;
  132889. }
  132890. this._cache.parent = this.parent;
  132891. this._updateCache();
  132892. };
  132893. /** @hidden */
  132894. Node.prototype._getActionManagerForTrigger = function (trigger, initialCall) {
  132895. if (initialCall === void 0) { initialCall = true; }
  132896. if (!this.parent) {
  132897. return null;
  132898. }
  132899. return this.parent._getActionManagerForTrigger(trigger, false);
  132900. };
  132901. // override it in derived class if you add new variables to the cache
  132902. // and call the parent class method if !ignoreParentClass
  132903. /** @hidden */
  132904. Node.prototype._updateCache = function (ignoreParentClass) {
  132905. };
  132906. // override it in derived class if you add new variables to the cache
  132907. /** @hidden */
  132908. Node.prototype._isSynchronized = function () {
  132909. return true;
  132910. };
  132911. /** @hidden */
  132912. Node.prototype._markSyncedWithParent = function () {
  132913. if (this._parentNode) {
  132914. this._parentUpdateId = this._parentNode._childUpdateId;
  132915. }
  132916. };
  132917. /** @hidden */
  132918. Node.prototype.isSynchronizedWithParent = function () {
  132919. if (!this._parentNode) {
  132920. return true;
  132921. }
  132922. if (this._parentUpdateId !== this._parentNode._childUpdateId) {
  132923. return false;
  132924. }
  132925. return this._parentNode.isSynchronized();
  132926. };
  132927. /** @hidden */
  132928. Node.prototype.isSynchronized = function () {
  132929. if (this._cache.parent != this._parentNode) {
  132930. this._cache.parent = this._parentNode;
  132931. return false;
  132932. }
  132933. if (this._parentNode && !this.isSynchronizedWithParent()) {
  132934. return false;
  132935. }
  132936. return this._isSynchronized();
  132937. };
  132938. /**
  132939. * Is this node ready to be used/rendered
  132940. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  132941. * @return true if the node is ready
  132942. */
  132943. Node.prototype.isReady = function (completeCheck) {
  132944. if (completeCheck === void 0) { completeCheck = false; }
  132945. return this._isReady;
  132946. };
  132947. /**
  132948. * Is this node enabled?
  132949. * 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
  132950. * @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
  132951. * @return whether this node (and its parent) is enabled
  132952. */
  132953. Node.prototype.isEnabled = function (checkAncestors) {
  132954. if (checkAncestors === void 0) { checkAncestors = true; }
  132955. if (checkAncestors === false) {
  132956. return this._isEnabled;
  132957. }
  132958. if (!this._isEnabled) {
  132959. return false;
  132960. }
  132961. return this._isParentEnabled;
  132962. };
  132963. /** @hidden */
  132964. Node.prototype._syncParentEnabledState = function () {
  132965. this._isParentEnabled = this._parentNode ? this._parentNode.isEnabled() : true;
  132966. if (this._children) {
  132967. this._children.forEach(function (c) {
  132968. c._syncParentEnabledState(); // Force children to update accordingly
  132969. });
  132970. }
  132971. };
  132972. /**
  132973. * Set the enabled state of this node
  132974. * @param value defines the new enabled state
  132975. */
  132976. Node.prototype.setEnabled = function (value) {
  132977. this._isEnabled = value;
  132978. this._syncParentEnabledState();
  132979. };
  132980. /**
  132981. * Is this node a descendant of the given node?
  132982. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  132983. * @param ancestor defines the parent node to inspect
  132984. * @returns a boolean indicating if this node is a descendant of the given node
  132985. */
  132986. Node.prototype.isDescendantOf = function (ancestor) {
  132987. if (this.parent) {
  132988. if (this.parent === ancestor) {
  132989. return true;
  132990. }
  132991. return this.parent.isDescendantOf(ancestor);
  132992. }
  132993. return false;
  132994. };
  132995. /** @hidden */
  132996. Node.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  132997. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  132998. if (!this._children) {
  132999. return;
  133000. }
  133001. for (var index = 0; index < this._children.length; index++) {
  133002. var item = this._children[index];
  133003. if (!predicate || predicate(item)) {
  133004. results.push(item);
  133005. }
  133006. if (!directDescendantsOnly) {
  133007. item._getDescendants(results, false, predicate);
  133008. }
  133009. }
  133010. };
  133011. /**
  133012. * Will return all nodes that have this node as ascendant
  133013. * @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
  133014. * @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
  133015. * @return all children nodes of all types
  133016. */
  133017. Node.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  133018. var results = new Array();
  133019. this._getDescendants(results, directDescendantsOnly, predicate);
  133020. return results;
  133021. };
  133022. /**
  133023. * Get all child-meshes of this node
  133024. * @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)
  133025. * @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
  133026. * @returns an array of AbstractMesh
  133027. */
  133028. Node.prototype.getChildMeshes = function (directDescendantsOnly, predicate) {
  133029. var results = [];
  133030. this._getDescendants(results, directDescendantsOnly, function (node) {
  133031. return ((!predicate || predicate(node)) && (node.cullingStrategy !== undefined));
  133032. });
  133033. return results;
  133034. };
  133035. /**
  133036. * Get all direct children of this node
  133037. * @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
  133038. * @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)
  133039. * @returns an array of Node
  133040. */
  133041. Node.prototype.getChildren = function (predicate, directDescendantsOnly) {
  133042. if (directDescendantsOnly === void 0) { directDescendantsOnly = true; }
  133043. return this.getDescendants(directDescendantsOnly, predicate);
  133044. };
  133045. /** @hidden */
  133046. Node.prototype._setReady = function (state) {
  133047. if (state === this._isReady) {
  133048. return;
  133049. }
  133050. if (!state) {
  133051. this._isReady = false;
  133052. return;
  133053. }
  133054. if (this.onReady) {
  133055. this.onReady(this);
  133056. }
  133057. this._isReady = true;
  133058. };
  133059. /**
  133060. * Get an animation by name
  133061. * @param name defines the name of the animation to look for
  133062. * @returns null if not found else the requested animation
  133063. */
  133064. Node.prototype.getAnimationByName = function (name) {
  133065. for (var i = 0; i < this.animations.length; i++) {
  133066. var animation = this.animations[i];
  133067. if (animation.name === name) {
  133068. return animation;
  133069. }
  133070. }
  133071. return null;
  133072. };
  133073. /**
  133074. * Creates an animation range for this node
  133075. * @param name defines the name of the range
  133076. * @param from defines the starting key
  133077. * @param to defines the end key
  133078. */
  133079. Node.prototype.createAnimationRange = function (name, from, to) {
  133080. // check name not already in use
  133081. if (!this._ranges[name]) {
  133082. this._ranges[name] = Node._AnimationRangeFactory(name, from, to);
  133083. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  133084. if (this.animations[i]) {
  133085. this.animations[i].createRange(name, from, to);
  133086. }
  133087. }
  133088. }
  133089. };
  133090. /**
  133091. * Delete a specific animation range
  133092. * @param name defines the name of the range to delete
  133093. * @param deleteFrames defines if animation frames from the range must be deleted as well
  133094. */
  133095. Node.prototype.deleteAnimationRange = function (name, deleteFrames) {
  133096. if (deleteFrames === void 0) { deleteFrames = true; }
  133097. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  133098. if (this.animations[i]) {
  133099. this.animations[i].deleteRange(name, deleteFrames);
  133100. }
  133101. }
  133102. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  133103. };
  133104. /**
  133105. * Get an animation range by name
  133106. * @param name defines the name of the animation range to look for
  133107. * @returns null if not found else the requested animation range
  133108. */
  133109. Node.prototype.getAnimationRange = function (name) {
  133110. return this._ranges[name];
  133111. };
  133112. /**
  133113. * Gets the list of all animation ranges defined on this node
  133114. * @returns an array
  133115. */
  133116. Node.prototype.getAnimationRanges = function () {
  133117. var animationRanges = [];
  133118. var name;
  133119. for (name in this._ranges) {
  133120. animationRanges.push(this._ranges[name]);
  133121. }
  133122. return animationRanges;
  133123. };
  133124. /**
  133125. * Will start the animation sequence
  133126. * @param name defines the range frames for animation sequence
  133127. * @param loop defines if the animation should loop (false by default)
  133128. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  133129. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  133130. * @returns the object created for this animation. If range does not exist, it will return null
  133131. */
  133132. Node.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  133133. var range = this.getAnimationRange(name);
  133134. if (!range) {
  133135. return null;
  133136. }
  133137. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  133138. };
  133139. /**
  133140. * Serialize animation ranges into a JSON compatible object
  133141. * @returns serialization object
  133142. */
  133143. Node.prototype.serializeAnimationRanges = function () {
  133144. var serializationRanges = [];
  133145. for (var name in this._ranges) {
  133146. var localRange = this._ranges[name];
  133147. if (!localRange) {
  133148. continue;
  133149. }
  133150. var range = {};
  133151. range.name = name;
  133152. range.from = localRange.from;
  133153. range.to = localRange.to;
  133154. serializationRanges.push(range);
  133155. }
  133156. return serializationRanges;
  133157. };
  133158. /**
  133159. * Computes the world matrix of the node
  133160. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  133161. * @returns the world matrix
  133162. */
  133163. Node.prototype.computeWorldMatrix = function (force) {
  133164. if (!this._worldMatrix) {
  133165. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  133166. }
  133167. return this._worldMatrix;
  133168. };
  133169. /**
  133170. * Releases resources associated with this node.
  133171. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  133172. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  133173. */
  133174. Node.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  133175. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  133176. this._isDisposed = true;
  133177. if (!doNotRecurse) {
  133178. var nodes = this.getDescendants(true);
  133179. for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
  133180. var node = nodes_1[_i];
  133181. node.dispose(doNotRecurse, disposeMaterialAndTextures);
  133182. }
  133183. }
  133184. if (!this.parent) {
  133185. this.removeFromSceneRootNodes();
  133186. }
  133187. else {
  133188. this.parent = null;
  133189. }
  133190. // Callback
  133191. this.onDisposeObservable.notifyObservers(this);
  133192. this.onDisposeObservable.clear();
  133193. // Behaviors
  133194. for (var _a = 0, _b = this._behaviors; _a < _b.length; _a++) {
  133195. var behavior = _b[_a];
  133196. behavior.detach();
  133197. }
  133198. this._behaviors = [];
  133199. };
  133200. /**
  133201. * Parse animation range data from a serialization object and store them into a given node
  133202. * @param node defines where to store the animation ranges
  133203. * @param parsedNode defines the serialization object to read data from
  133204. * @param scene defines the hosting scene
  133205. */
  133206. Node.ParseAnimationRanges = function (node, parsedNode, scene) {
  133207. if (parsedNode.ranges) {
  133208. for (var index = 0; index < parsedNode.ranges.length; index++) {
  133209. var data = parsedNode.ranges[index];
  133210. node.createAnimationRange(data.name, data.from, data.to);
  133211. }
  133212. }
  133213. };
  133214. /** @hidden */
  133215. Node._AnimationRangeFactory = function (name, from, to) {
  133216. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AnimationRange");
  133217. };
  133218. Node._NodeConstructors = {};
  133219. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  133220. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  133221. ], Node.prototype, "name", void 0);
  133222. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  133223. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  133224. ], Node.prototype, "id", void 0);
  133225. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  133226. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  133227. ], Node.prototype, "uniqueId", void 0);
  133228. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  133229. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  133230. ], Node.prototype, "state", void 0);
  133231. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  133232. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  133233. ], Node.prototype, "metadata", void 0);
  133234. return Node;
  133235. }());
  133236. /***/ }),
  133237. /***/ "./scene.ts":
  133238. /*!******************!*\
  133239. !*** ./scene.ts ***!
  133240. \******************/
  133241. /*! exports provided: Scene */
  133242. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133243. "use strict";
  133244. __webpack_require__.r(__webpack_exports__);
  133245. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return Scene; });
  133246. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  133247. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Misc/tools */ "./Misc/tools.ts");
  133248. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/precisionDate */ "./Misc/precisionDate.ts");
  133249. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  133250. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Misc/smartArray */ "./Misc/smartArray.ts");
  133251. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  133252. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Misc/tags */ "./Misc/tags.ts");
  133253. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  133254. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  133255. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Cameras/camera */ "./Cameras/camera.ts");
  133256. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  133257. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  133258. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  133259. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Lights/light */ "./Lights/light.ts");
  133260. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  133261. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Events/pointerEvents */ "./Events/pointerEvents.ts");
  133262. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  133263. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Actions/actionEvent */ "./Actions/actionEvent.ts");
  133264. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  133265. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  133266. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  133267. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Engines/constants */ "./Engines/constants.ts");
  133268. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Misc/domManagement */ "./Misc/domManagement.ts");
  133269. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Misc/logger */ "./Misc/logger.ts");
  133270. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  133271. /* harmony import */ var _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./Actions/abstractActionManager */ "./Actions/abstractActionManager.ts");
  133272. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  133273. /** @hidden */
  133274. var ClickInfo = /** @class */ (function () {
  133275. function ClickInfo() {
  133276. this._singleClick = false;
  133277. this._doubleClick = false;
  133278. this._hasSwiped = false;
  133279. this._ignore = false;
  133280. }
  133281. Object.defineProperty(ClickInfo.prototype, "singleClick", {
  133282. get: function () {
  133283. return this._singleClick;
  133284. },
  133285. set: function (b) {
  133286. this._singleClick = b;
  133287. },
  133288. enumerable: true,
  133289. configurable: true
  133290. });
  133291. Object.defineProperty(ClickInfo.prototype, "doubleClick", {
  133292. get: function () {
  133293. return this._doubleClick;
  133294. },
  133295. set: function (b) {
  133296. this._doubleClick = b;
  133297. },
  133298. enumerable: true,
  133299. configurable: true
  133300. });
  133301. Object.defineProperty(ClickInfo.prototype, "hasSwiped", {
  133302. get: function () {
  133303. return this._hasSwiped;
  133304. },
  133305. set: function (b) {
  133306. this._hasSwiped = b;
  133307. },
  133308. enumerable: true,
  133309. configurable: true
  133310. });
  133311. Object.defineProperty(ClickInfo.prototype, "ignore", {
  133312. get: function () {
  133313. return this._ignore;
  133314. },
  133315. set: function (b) {
  133316. this._ignore = b;
  133317. },
  133318. enumerable: true,
  133319. configurable: true
  133320. });
  133321. return ClickInfo;
  133322. }());
  133323. /**
  133324. * Represents a scene to be rendered by the engine.
  133325. * @see http://doc.babylonjs.com/features/scene
  133326. */
  133327. var Scene = /** @class */ (function (_super) {
  133328. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Scene, _super);
  133329. /**
  133330. * Creates a new Scene
  133331. * @param engine defines the engine to use to render this scene
  133332. * @param options defines the scene options
  133333. */
  133334. function Scene(engine, options) {
  133335. var _this = _super.call(this) || this;
  133336. // Members
  133337. /** @hidden */
  133338. _this._isScene = true;
  133339. /**
  133340. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  133341. */
  133342. _this.autoClear = true;
  133343. /**
  133344. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  133345. */
  133346. _this.autoClearDepthAndStencil = true;
  133347. /**
  133348. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  133349. */
  133350. _this.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color4"](0.2, 0.2, 0.3, 1.0);
  133351. /**
  133352. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  133353. */
  133354. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0, 0, 0);
  133355. _this._forceWireframe = false;
  133356. _this._forcePointsCloud = false;
  133357. /**
  133358. * Gets or sets a boolean indicating if animations are enabled
  133359. */
  133360. _this.animationsEnabled = true;
  133361. _this._animationPropertiesOverride = null;
  133362. /**
  133363. * Gets or sets a boolean indicating if a constant deltatime has to be used
  133364. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  133365. */
  133366. _this.useConstantAnimationDeltaTime = false;
  133367. /**
  133368. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  133369. * Please note that it requires to run a ray cast through the scene on every frame
  133370. */
  133371. _this.constantlyUpdateMeshUnderPointer = false;
  133372. /**
  133373. * Defines the HTML cursor to use when hovering over interactive elements
  133374. */
  133375. _this.hoverCursor = "pointer";
  133376. /**
  133377. * Defines the HTML default cursor to use (empty by default)
  133378. */
  133379. _this.defaultCursor = "";
  133380. /**
  133381. * This is used to call preventDefault() on pointer down
  133382. * in order to block unwanted artifacts like system double clicks
  133383. */
  133384. _this.preventDefaultOnPointerDown = true;
  133385. /**
  133386. * This is used to call preventDefault() on pointer up
  133387. * in order to block unwanted artifacts like system double clicks
  133388. */
  133389. _this.preventDefaultOnPointerUp = true;
  133390. // Metadata
  133391. /**
  133392. * Gets or sets user defined metadata
  133393. */
  133394. _this.metadata = null;
  133395. /**
  133396. * For internal use only. Please do not use.
  133397. */
  133398. _this.reservedDataStore = null;
  133399. /**
  133400. * Use this array to add regular expressions used to disable offline support for specific urls
  133401. */
  133402. _this.disableOfflineSupportExceptionRules = new Array();
  133403. /**
  133404. * An event triggered when the scene is disposed.
  133405. */
  133406. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133407. _this._onDisposeObserver = null;
  133408. /**
  133409. * An event triggered before rendering the scene (right after animations and physics)
  133410. */
  133411. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133412. _this._onBeforeRenderObserver = null;
  133413. /**
  133414. * An event triggered after rendering the scene
  133415. */
  133416. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133417. _this._onAfterRenderObserver = null;
  133418. /**
  133419. * An event triggered before animating the scene
  133420. */
  133421. _this.onBeforeAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133422. /**
  133423. * An event triggered after animations processing
  133424. */
  133425. _this.onAfterAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133426. /**
  133427. * An event triggered before draw calls are ready to be sent
  133428. */
  133429. _this.onBeforeDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133430. /**
  133431. * An event triggered after draw calls have been sent
  133432. */
  133433. _this.onAfterDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133434. /**
  133435. * An event triggered when the scene is ready
  133436. */
  133437. _this.onReadyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133438. /**
  133439. * An event triggered before rendering a camera
  133440. */
  133441. _this.onBeforeCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133442. _this._onBeforeCameraRenderObserver = null;
  133443. /**
  133444. * An event triggered after rendering a camera
  133445. */
  133446. _this.onAfterCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133447. _this._onAfterCameraRenderObserver = null;
  133448. /**
  133449. * An event triggered when active meshes evaluation is about to start
  133450. */
  133451. _this.onBeforeActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133452. /**
  133453. * An event triggered when active meshes evaluation is done
  133454. */
  133455. _this.onAfterActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133456. /**
  133457. * An event triggered when particles rendering is about to start
  133458. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  133459. */
  133460. _this.onBeforeParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133461. /**
  133462. * An event triggered when particles rendering is done
  133463. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  133464. */
  133465. _this.onAfterParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133466. /**
  133467. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  133468. */
  133469. _this.onDataLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133470. /**
  133471. * An event triggered when a camera is created
  133472. */
  133473. _this.onNewCameraAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133474. /**
  133475. * An event triggered when a camera is removed
  133476. */
  133477. _this.onCameraRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133478. /**
  133479. * An event triggered when a light is created
  133480. */
  133481. _this.onNewLightAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133482. /**
  133483. * An event triggered when a light is removed
  133484. */
  133485. _this.onLightRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133486. /**
  133487. * An event triggered when a geometry is created
  133488. */
  133489. _this.onNewGeometryAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133490. /**
  133491. * An event triggered when a geometry is removed
  133492. */
  133493. _this.onGeometryRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133494. /**
  133495. * An event triggered when a transform node is created
  133496. */
  133497. _this.onNewTransformNodeAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133498. /**
  133499. * An event triggered when a transform node is removed
  133500. */
  133501. _this.onTransformNodeRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133502. /**
  133503. * An event triggered when a mesh is created
  133504. */
  133505. _this.onNewMeshAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133506. /**
  133507. * An event triggered when a mesh is removed
  133508. */
  133509. _this.onMeshRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133510. /**
  133511. * An event triggered when a skeleton is created
  133512. */
  133513. _this.onNewSkeletonAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133514. /**
  133515. * An event triggered when a skeleton is removed
  133516. */
  133517. _this.onSkeletonRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133518. /**
  133519. * An event triggered when a material is created
  133520. */
  133521. _this.onNewMaterialAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133522. /**
  133523. * An event triggered when a material is removed
  133524. */
  133525. _this.onMaterialRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133526. /**
  133527. * An event triggered when a texture is created
  133528. */
  133529. _this.onNewTextureAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133530. /**
  133531. * An event triggered when a texture is removed
  133532. */
  133533. _this.onTextureRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133534. /**
  133535. * An event triggered when render targets are about to be rendered
  133536. * Can happen multiple times per frame.
  133537. */
  133538. _this.onBeforeRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133539. /**
  133540. * An event triggered when render targets were rendered.
  133541. * Can happen multiple times per frame.
  133542. */
  133543. _this.onAfterRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133544. /**
  133545. * An event triggered before calculating deterministic simulation step
  133546. */
  133547. _this.onBeforeStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133548. /**
  133549. * An event triggered after calculating deterministic simulation step
  133550. */
  133551. _this.onAfterStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133552. /**
  133553. * An event triggered when the activeCamera property is updated
  133554. */
  133555. _this.onActiveCameraChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133556. /**
  133557. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  133558. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  133559. * 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)
  133560. */
  133561. _this.onBeforeRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133562. /**
  133563. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  133564. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  133565. * 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)
  133566. */
  133567. _this.onAfterRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133568. /**
  133569. * This Observable will when a mesh has been imported into the scene.
  133570. */
  133571. _this.onMeshImportedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133572. // Animations
  133573. /** @hidden */
  133574. _this._registeredForLateAnimationBindings = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  133575. /**
  133576. * 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).
  133577. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  133578. */
  133579. _this.onPrePointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133580. /**
  133581. * Observable event triggered each time an input event is received from the rendering canvas
  133582. */
  133583. _this.onPointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133584. _this._meshPickProceed = false;
  133585. _this._currentPickResult = null;
  133586. _this._previousPickResult = null;
  133587. _this._totalPointersPressed = 0;
  133588. _this._doubleClickOccured = false;
  133589. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  133590. _this.cameraToUseForPointers = null;
  133591. _this._pointerX = 0;
  133592. _this._pointerY = 0;
  133593. _this._startingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  133594. _this._previousStartingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  133595. _this._startingPointerTime = 0;
  133596. _this._previousStartingPointerTime = 0;
  133597. _this._pointerCaptures = {};
  133598. // Deterministic lockstep
  133599. _this._timeAccumulator = 0;
  133600. _this._currentStepId = 0;
  133601. _this._currentInternalStep = 0;
  133602. // Keyboard
  133603. /**
  133604. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  133605. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  133606. */
  133607. _this.onPreKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133608. /**
  133609. * Observable event triggered each time an keyboard event is received from the hosting window
  133610. */
  133611. _this.onKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133612. // Coordinates system
  133613. _this._useRightHandedSystem = false;
  133614. // Fog
  133615. _this._fogEnabled = true;
  133616. _this._fogMode = Scene.FOGMODE_NONE;
  133617. /**
  133618. * Gets or sets the fog color to use
  133619. * @see http://doc.babylonjs.com/babylon101/environment#fog
  133620. * (Default is Color3(0.2, 0.2, 0.3))
  133621. */
  133622. _this.fogColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0.2, 0.2, 0.3);
  133623. /**
  133624. * Gets or sets the fog density to use
  133625. * @see http://doc.babylonjs.com/babylon101/environment#fog
  133626. * (Default is 0.1)
  133627. */
  133628. _this.fogDensity = 0.1;
  133629. /**
  133630. * Gets or sets the fog start distance to use
  133631. * @see http://doc.babylonjs.com/babylon101/environment#fog
  133632. * (Default is 0)
  133633. */
  133634. _this.fogStart = 0;
  133635. /**
  133636. * Gets or sets the fog end distance to use
  133637. * @see http://doc.babylonjs.com/babylon101/environment#fog
  133638. * (Default is 1000)
  133639. */
  133640. _this.fogEnd = 1000.0;
  133641. // Lights
  133642. _this._shadowsEnabled = true;
  133643. _this._lightsEnabled = true;
  133644. /** All of the active cameras added to this scene. */
  133645. _this.activeCameras = new Array();
  133646. // Textures
  133647. _this._texturesEnabled = true;
  133648. // Particles
  133649. /**
  133650. * Gets or sets a boolean indicating if particles are enabled on this scene
  133651. */
  133652. _this.particlesEnabled = true;
  133653. // Sprites
  133654. /**
  133655. * Gets or sets a boolean indicating if sprites are enabled on this scene
  133656. */
  133657. _this.spritesEnabled = true;
  133658. // Skeletons
  133659. _this._skeletonsEnabled = true;
  133660. // Lens flares
  133661. /**
  133662. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  133663. */
  133664. _this.lensFlaresEnabled = true;
  133665. // Collisions
  133666. /**
  133667. * Gets or sets a boolean indicating if collisions are enabled on this scene
  133668. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  133669. */
  133670. _this.collisionsEnabled = true;
  133671. /**
  133672. * Defines the gravity applied to this scene (used only for collisions)
  133673. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  133674. */
  133675. _this.gravity = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](0, -9.807, 0);
  133676. // Postprocesses
  133677. /**
  133678. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  133679. */
  133680. _this.postProcessesEnabled = true;
  133681. /**
  133682. * The list of postprocesses added to the scene
  133683. */
  133684. _this.postProcesses = new Array();
  133685. // Customs render targets
  133686. /**
  133687. * Gets or sets a boolean indicating if render targets are enabled on this scene
  133688. */
  133689. _this.renderTargetsEnabled = true;
  133690. /**
  133691. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  133692. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  133693. */
  133694. _this.dumpNextRenderTargets = false;
  133695. /**
  133696. * The list of user defined render targets added to the scene
  133697. */
  133698. _this.customRenderTargets = new Array();
  133699. /**
  133700. * Gets the list of meshes imported to the scene through SceneLoader
  133701. */
  133702. _this.importedMeshesFiles = new Array();
  133703. // Probes
  133704. /**
  133705. * Gets or sets a boolean indicating if probes are enabled on this scene
  133706. */
  133707. _this.probesEnabled = true;
  133708. _this._meshesForIntersections = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  133709. // Procedural textures
  133710. /**
  133711. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  133712. */
  133713. _this.proceduralTexturesEnabled = true;
  133714. // Performance counters
  133715. _this._totalVertices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  133716. /** @hidden */
  133717. _this._activeIndices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  133718. /** @hidden */
  133719. _this._activeParticles = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  133720. /** @hidden */
  133721. _this._activeBones = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  133722. /** @hidden */
  133723. _this._animationTime = 0;
  133724. /**
  133725. * Gets or sets a general scale for animation speed
  133726. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  133727. */
  133728. _this.animationTimeScale = 1;
  133729. _this._renderId = 0;
  133730. _this._frameId = 0;
  133731. _this._executeWhenReadyTimeoutId = -1;
  133732. _this._intermediateRendering = false;
  133733. _this._viewUpdateFlag = -1;
  133734. _this._projectionUpdateFlag = -1;
  133735. /** @hidden */
  133736. _this._toBeDisposed = new Array(256);
  133737. _this._activeRequests = new Array();
  133738. /** @hidden */
  133739. _this._pendingData = new Array();
  133740. _this._isDisposed = false;
  133741. /**
  133742. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  133743. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  133744. */
  133745. _this.dispatchAllSubMeshesOfActiveMeshes = false;
  133746. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  133747. _this._processedMaterials = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  133748. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  133749. /** @hidden */
  133750. _this._activeParticleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  133751. _this._activeSkeletons = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  133752. _this._softwareSkinnedMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  133753. /** @hidden */
  133754. _this._activeAnimatables = new Array();
  133755. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  133756. _this._wheelEventName = "";
  133757. /**
  133758. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  133759. * This is useful if there are more lights that the maximum simulteanous authorized
  133760. */
  133761. _this.requireLightSorting = false;
  133762. /**
  133763. * @hidden
  133764. * Backing store of defined scene components.
  133765. */
  133766. _this._components = [];
  133767. /**
  133768. * @hidden
  133769. * Backing store of defined scene components.
  133770. */
  133771. _this._serializableComponents = [];
  133772. /**
  133773. * List of components to register on the next registration step.
  133774. */
  133775. _this._transientComponents = [];
  133776. /**
  133777. * @hidden
  133778. * Defines the actions happening before camera updates.
  133779. */
  133780. _this._beforeCameraUpdateStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133781. /**
  133782. * @hidden
  133783. * Defines the actions happening before clear the canvas.
  133784. */
  133785. _this._beforeClearStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133786. /**
  133787. * @hidden
  133788. * Defines the actions when collecting render targets for the frame.
  133789. */
  133790. _this._gatherRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133791. /**
  133792. * @hidden
  133793. * Defines the actions happening for one camera in the frame.
  133794. */
  133795. _this._gatherActiveCameraRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133796. /**
  133797. * @hidden
  133798. * Defines the actions happening during the per mesh ready checks.
  133799. */
  133800. _this._isReadyForMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133801. /**
  133802. * @hidden
  133803. * Defines the actions happening before evaluate active mesh checks.
  133804. */
  133805. _this._beforeEvaluateActiveMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133806. /**
  133807. * @hidden
  133808. * Defines the actions happening during the evaluate sub mesh checks.
  133809. */
  133810. _this._evaluateSubMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133811. /**
  133812. * @hidden
  133813. * Defines the actions happening during the active mesh stage.
  133814. */
  133815. _this._activeMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133816. /**
  133817. * @hidden
  133818. * Defines the actions happening during the per camera render target step.
  133819. */
  133820. _this._cameraDrawRenderTargetStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133821. /**
  133822. * @hidden
  133823. * Defines the actions happening just before the active camera is drawing.
  133824. */
  133825. _this._beforeCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133826. /**
  133827. * @hidden
  133828. * Defines the actions happening just before a render target is drawing.
  133829. */
  133830. _this._beforeRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133831. /**
  133832. * @hidden
  133833. * Defines the actions happening just before a rendering group is drawing.
  133834. */
  133835. _this._beforeRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133836. /**
  133837. * @hidden
  133838. * Defines the actions happening just before a mesh is drawing.
  133839. */
  133840. _this._beforeRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133841. /**
  133842. * @hidden
  133843. * Defines the actions happening just after a mesh has been drawn.
  133844. */
  133845. _this._afterRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133846. /**
  133847. * @hidden
  133848. * Defines the actions happening just after a rendering group has been drawn.
  133849. */
  133850. _this._afterRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133851. /**
  133852. * @hidden
  133853. * Defines the actions happening just after the active camera has been drawn.
  133854. */
  133855. _this._afterCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133856. /**
  133857. * @hidden
  133858. * Defines the actions happening just after a render target has been drawn.
  133859. */
  133860. _this._afterRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133861. /**
  133862. * @hidden
  133863. * Defines the actions happening just after rendering all cameras and computing intersections.
  133864. */
  133865. _this._afterRenderStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133866. /**
  133867. * @hidden
  133868. * Defines the actions happening when a pointer move event happens.
  133869. */
  133870. _this._pointerMoveStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133871. /**
  133872. * @hidden
  133873. * Defines the actions happening when a pointer down event happens.
  133874. */
  133875. _this._pointerDownStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133876. /**
  133877. * @hidden
  133878. * Defines the actions happening when a pointer up event happens.
  133879. */
  133880. _this._pointerUpStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  133881. /**
  133882. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  133883. */
  133884. _this.geometriesByUniqueId = null;
  133885. _this._defaultMeshCandidates = {
  133886. data: [],
  133887. length: 0
  133888. };
  133889. _this._defaultSubMeshCandidates = {
  133890. data: [],
  133891. length: 0
  133892. };
  133893. _this._preventFreeActiveMeshesAndRenderingGroups = false;
  133894. _this._activeMeshesFrozen = false;
  133895. /** @hidden */
  133896. _this._allowPostProcessClearColor = true;
  133897. /**
  133898. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  133899. */
  133900. _this.getDeterministicFrameTime = function () {
  133901. return 1000.0 / 60.0; // frame time in ms
  133902. };
  133903. _this._blockMaterialDirtyMechanism = false;
  133904. _this._engine = engine || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_24__["EngineStore"].LastCreatedEngine;
  133905. _this._engine.scenes.push(_this);
  133906. _this._uid = null;
  133907. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_19__["RenderingManager"](_this);
  133908. if (_PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__["PostProcessManager"]) {
  133909. _this.postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__["PostProcessManager"](_this);
  133910. }
  133911. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_22__["DomManagement"].IsWindowObjectExist()) {
  133912. _this.attachControl();
  133913. }
  133914. // Uniform Buffer
  133915. _this._createUbo();
  133916. // Default Image processing definition
  133917. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]) {
  133918. _this._imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]();
  133919. }
  133920. _this.setDefaultCandidateProviders();
  133921. if (options && options.useGeometryUniqueIdsMap === true) {
  133922. _this.geometriesByUniqueId = {};
  133923. }
  133924. _this.useMaterialMeshMap = options && options.useGeometryUniqueIdsMap || false;
  133925. _this.useClonedMeshhMap = options && options.useClonedMeshhMap || false;
  133926. _this._engine.onNewSceneAddedObservable.notifyObservers(_this);
  133927. return _this;
  133928. }
  133929. /**
  133930. * Factory used to create the default material.
  133931. * @param name The name of the material to create
  133932. * @param scene The scene to create the material for
  133933. * @returns The default material
  133934. */
  133935. Scene.DefaultMaterialFactory = function (scene) {
  133936. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("StandardMaterial");
  133937. };
  133938. /**
  133939. * Factory used to create the a collision coordinator.
  133940. * @returns The collision coordinator
  133941. */
  133942. Scene.CollisionCoordinatorFactory = function () {
  133943. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("DefaultCollisionCoordinator");
  133944. };
  133945. Object.defineProperty(Scene.prototype, "environmentTexture", {
  133946. /**
  133947. * Texture used in all pbr material as the reflection texture.
  133948. * As in the majority of the scene they are the same (exception for multi room and so on),
  133949. * this is easier to reference from here than from all the materials.
  133950. */
  133951. get: function () {
  133952. return this._environmentTexture;
  133953. },
  133954. /**
  133955. * Texture used in all pbr material as the reflection texture.
  133956. * As in the majority of the scene they are the same (exception for multi room and so on),
  133957. * this is easier to set here than in all the materials.
  133958. */
  133959. set: function (value) {
  133960. if (this._environmentTexture === value) {
  133961. return;
  133962. }
  133963. this._environmentTexture = value;
  133964. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  133965. },
  133966. enumerable: true,
  133967. configurable: true
  133968. });
  133969. Object.defineProperty(Scene.prototype, "imageProcessingConfiguration", {
  133970. /**
  133971. * Default image processing configuration used either in the rendering
  133972. * Forward main pass or through the imageProcessingPostProcess if present.
  133973. * As in the majority of the scene they are the same (exception for multi camera),
  133974. * this is easier to reference from here than from all the materials and post process.
  133975. *
  133976. * No setter as we it is a shared configuration, you can set the values instead.
  133977. */
  133978. get: function () {
  133979. return this._imageProcessingConfiguration;
  133980. },
  133981. enumerable: true,
  133982. configurable: true
  133983. });
  133984. Object.defineProperty(Scene.prototype, "forceWireframe", {
  133985. get: function () {
  133986. return this._forceWireframe;
  133987. },
  133988. /**
  133989. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  133990. */
  133991. set: function (value) {
  133992. if (this._forceWireframe === value) {
  133993. return;
  133994. }
  133995. this._forceWireframe = value;
  133996. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  133997. },
  133998. enumerable: true,
  133999. configurable: true
  134000. });
  134001. Object.defineProperty(Scene.prototype, "forcePointsCloud", {
  134002. get: function () {
  134003. return this._forcePointsCloud;
  134004. },
  134005. /**
  134006. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  134007. */
  134008. set: function (value) {
  134009. if (this._forcePointsCloud === value) {
  134010. return;
  134011. }
  134012. this._forcePointsCloud = value;
  134013. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  134014. },
  134015. enumerable: true,
  134016. configurable: true
  134017. });
  134018. Object.defineProperty(Scene.prototype, "animationPropertiesOverride", {
  134019. /**
  134020. * Gets or sets the animation properties override
  134021. */
  134022. get: function () {
  134023. return this._animationPropertiesOverride;
  134024. },
  134025. set: function (value) {
  134026. this._animationPropertiesOverride = value;
  134027. },
  134028. enumerable: true,
  134029. configurable: true
  134030. });
  134031. Object.defineProperty(Scene.prototype, "onDispose", {
  134032. /** Sets a function to be executed when this scene is disposed. */
  134033. set: function (callback) {
  134034. if (this._onDisposeObserver) {
  134035. this.onDisposeObservable.remove(this._onDisposeObserver);
  134036. }
  134037. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  134038. },
  134039. enumerable: true,
  134040. configurable: true
  134041. });
  134042. Object.defineProperty(Scene.prototype, "beforeRender", {
  134043. /** Sets a function to be executed before rendering this scene */
  134044. set: function (callback) {
  134045. if (this._onBeforeRenderObserver) {
  134046. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  134047. }
  134048. if (callback) {
  134049. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  134050. }
  134051. },
  134052. enumerable: true,
  134053. configurable: true
  134054. });
  134055. Object.defineProperty(Scene.prototype, "afterRender", {
  134056. /** Sets a function to be executed after rendering this scene */
  134057. set: function (callback) {
  134058. if (this._onAfterRenderObserver) {
  134059. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  134060. }
  134061. if (callback) {
  134062. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  134063. }
  134064. },
  134065. enumerable: true,
  134066. configurable: true
  134067. });
  134068. Object.defineProperty(Scene.prototype, "beforeCameraRender", {
  134069. /** Sets a function to be executed before rendering a camera*/
  134070. set: function (callback) {
  134071. if (this._onBeforeCameraRenderObserver) {
  134072. this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  134073. }
  134074. this._onBeforeCameraRenderObserver = this.onBeforeCameraRenderObservable.add(callback);
  134075. },
  134076. enumerable: true,
  134077. configurable: true
  134078. });
  134079. Object.defineProperty(Scene.prototype, "afterCameraRender", {
  134080. /** Sets a function to be executed after rendering a camera*/
  134081. set: function (callback) {
  134082. if (this._onAfterCameraRenderObserver) {
  134083. this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  134084. }
  134085. this._onAfterCameraRenderObserver = this.onAfterCameraRenderObservable.add(callback);
  134086. },
  134087. enumerable: true,
  134088. configurable: true
  134089. });
  134090. Object.defineProperty(Scene.prototype, "unTranslatedPointer", {
  134091. /**
  134092. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  134093. */
  134094. get: function () {
  134095. return new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](this._unTranslatedPointerX, this._unTranslatedPointerY);
  134096. },
  134097. enumerable: true,
  134098. configurable: true
  134099. });
  134100. Object.defineProperty(Scene.prototype, "useRightHandedSystem", {
  134101. get: function () {
  134102. return this._useRightHandedSystem;
  134103. },
  134104. /**
  134105. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  134106. */
  134107. set: function (value) {
  134108. if (this._useRightHandedSystem === value) {
  134109. return;
  134110. }
  134111. this._useRightHandedSystem = value;
  134112. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  134113. },
  134114. enumerable: true,
  134115. configurable: true
  134116. });
  134117. /**
  134118. * Sets the step Id used by deterministic lock step
  134119. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  134120. * @param newStepId defines the step Id
  134121. */
  134122. Scene.prototype.setStepId = function (newStepId) {
  134123. this._currentStepId = newStepId;
  134124. };
  134125. /**
  134126. * Gets the step Id used by deterministic lock step
  134127. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  134128. * @returns the step Id
  134129. */
  134130. Scene.prototype.getStepId = function () {
  134131. return this._currentStepId;
  134132. };
  134133. /**
  134134. * Gets the internal step used by deterministic lock step
  134135. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  134136. * @returns the internal step
  134137. */
  134138. Scene.prototype.getInternalStep = function () {
  134139. return this._currentInternalStep;
  134140. };
  134141. Object.defineProperty(Scene.prototype, "fogEnabled", {
  134142. get: function () {
  134143. return this._fogEnabled;
  134144. },
  134145. /**
  134146. * Gets or sets a boolean indicating if fog is enabled on this scene
  134147. * @see http://doc.babylonjs.com/babylon101/environment#fog
  134148. * (Default is true)
  134149. */
  134150. set: function (value) {
  134151. if (this._fogEnabled === value) {
  134152. return;
  134153. }
  134154. this._fogEnabled = value;
  134155. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  134156. },
  134157. enumerable: true,
  134158. configurable: true
  134159. });
  134160. Object.defineProperty(Scene.prototype, "fogMode", {
  134161. get: function () {
  134162. return this._fogMode;
  134163. },
  134164. /**
  134165. * Gets or sets the fog mode to use
  134166. * @see http://doc.babylonjs.com/babylon101/environment#fog
  134167. * | mode | value |
  134168. * | --- | --- |
  134169. * | FOGMODE_NONE | 0 |
  134170. * | FOGMODE_EXP | 1 |
  134171. * | FOGMODE_EXP2 | 2 |
  134172. * | FOGMODE_LINEAR | 3 |
  134173. */
  134174. set: function (value) {
  134175. if (this._fogMode === value) {
  134176. return;
  134177. }
  134178. this._fogMode = value;
  134179. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  134180. },
  134181. enumerable: true,
  134182. configurable: true
  134183. });
  134184. Object.defineProperty(Scene.prototype, "shadowsEnabled", {
  134185. get: function () {
  134186. return this._shadowsEnabled;
  134187. },
  134188. /**
  134189. * Gets or sets a boolean indicating if shadows are enabled on this scene
  134190. */
  134191. set: function (value) {
  134192. if (this._shadowsEnabled === value) {
  134193. return;
  134194. }
  134195. this._shadowsEnabled = value;
  134196. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_LightDirtyFlag);
  134197. },
  134198. enumerable: true,
  134199. configurable: true
  134200. });
  134201. Object.defineProperty(Scene.prototype, "lightsEnabled", {
  134202. get: function () {
  134203. return this._lightsEnabled;
  134204. },
  134205. /**
  134206. * Gets or sets a boolean indicating if lights are enabled on this scene
  134207. */
  134208. set: function (value) {
  134209. if (this._lightsEnabled === value) {
  134210. return;
  134211. }
  134212. this._lightsEnabled = value;
  134213. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_LightDirtyFlag);
  134214. },
  134215. enumerable: true,
  134216. configurable: true
  134217. });
  134218. Object.defineProperty(Scene.prototype, "activeCamera", {
  134219. /** Gets or sets the current active camera */
  134220. get: function () {
  134221. return this._activeCamera;
  134222. },
  134223. set: function (value) {
  134224. if (value === this._activeCamera) {
  134225. return;
  134226. }
  134227. this._activeCamera = value;
  134228. this.onActiveCameraChanged.notifyObservers(this);
  134229. },
  134230. enumerable: true,
  134231. configurable: true
  134232. });
  134233. Object.defineProperty(Scene.prototype, "defaultMaterial", {
  134234. /** The default material used on meshes when no material is affected */
  134235. get: function () {
  134236. if (!this._defaultMaterial) {
  134237. this._defaultMaterial = Scene.DefaultMaterialFactory(this);
  134238. }
  134239. return this._defaultMaterial;
  134240. },
  134241. /** The default material used on meshes when no material is affected */
  134242. set: function (value) {
  134243. this._defaultMaterial = value;
  134244. },
  134245. enumerable: true,
  134246. configurable: true
  134247. });
  134248. Object.defineProperty(Scene.prototype, "texturesEnabled", {
  134249. get: function () {
  134250. return this._texturesEnabled;
  134251. },
  134252. /**
  134253. * Gets or sets a boolean indicating if textures are enabled on this scene
  134254. */
  134255. set: function (value) {
  134256. if (this._texturesEnabled === value) {
  134257. return;
  134258. }
  134259. this._texturesEnabled = value;
  134260. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  134261. },
  134262. enumerable: true,
  134263. configurable: true
  134264. });
  134265. Object.defineProperty(Scene.prototype, "skeletonsEnabled", {
  134266. get: function () {
  134267. return this._skeletonsEnabled;
  134268. },
  134269. /**
  134270. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  134271. */
  134272. set: function (value) {
  134273. if (this._skeletonsEnabled === value) {
  134274. return;
  134275. }
  134276. this._skeletonsEnabled = value;
  134277. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_AttributesDirtyFlag);
  134278. },
  134279. enumerable: true,
  134280. configurable: true
  134281. });
  134282. Object.defineProperty(Scene.prototype, "collisionCoordinator", {
  134283. /** @hidden */
  134284. get: function () {
  134285. if (!this._collisionCoordinator) {
  134286. this._collisionCoordinator = Scene.CollisionCoordinatorFactory();
  134287. this._collisionCoordinator.init(this);
  134288. }
  134289. return this._collisionCoordinator;
  134290. },
  134291. enumerable: true,
  134292. configurable: true
  134293. });
  134294. Object.defineProperty(Scene.prototype, "frustumPlanes", {
  134295. /**
  134296. * Gets the list of frustum planes (built from the active camera)
  134297. */
  134298. get: function () {
  134299. return this._frustumPlanes;
  134300. },
  134301. enumerable: true,
  134302. configurable: true
  134303. });
  134304. /**
  134305. * Registers the transient components if needed.
  134306. */
  134307. Scene.prototype._registerTransientComponents = function () {
  134308. // Register components that have been associated lately to the scene.
  134309. if (this._transientComponents.length > 0) {
  134310. for (var _i = 0, _a = this._transientComponents; _i < _a.length; _i++) {
  134311. var component = _a[_i];
  134312. component.register();
  134313. }
  134314. this._transientComponents = [];
  134315. }
  134316. };
  134317. /**
  134318. * @hidden
  134319. * Add a component to the scene.
  134320. * Note that the ccomponent could be registered on th next frame if this is called after
  134321. * the register component stage.
  134322. * @param component Defines the component to add to the scene
  134323. */
  134324. Scene.prototype._addComponent = function (component) {
  134325. this._components.push(component);
  134326. this._transientComponents.push(component);
  134327. var serializableComponent = component;
  134328. if (serializableComponent.addFromContainer) {
  134329. this._serializableComponents.push(serializableComponent);
  134330. }
  134331. };
  134332. /**
  134333. * @hidden
  134334. * Gets a component from the scene.
  134335. * @param name defines the name of the component to retrieve
  134336. * @returns the component or null if not present
  134337. */
  134338. Scene.prototype._getComponent = function (name) {
  134339. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  134340. var component = _a[_i];
  134341. if (component.name === name) {
  134342. return component;
  134343. }
  134344. }
  134345. return null;
  134346. };
  134347. /**
  134348. * Gets a string idenfifying the name of the class
  134349. * @returns "Scene" string
  134350. */
  134351. Scene.prototype.getClassName = function () {
  134352. return "Scene";
  134353. };
  134354. /**
  134355. * @hidden
  134356. */
  134357. Scene.prototype._getDefaultMeshCandidates = function () {
  134358. this._defaultMeshCandidates.data = this.meshes;
  134359. this._defaultMeshCandidates.length = this.meshes.length;
  134360. return this._defaultMeshCandidates;
  134361. };
  134362. /**
  134363. * @hidden
  134364. */
  134365. Scene.prototype._getDefaultSubMeshCandidates = function (mesh) {
  134366. this._defaultSubMeshCandidates.data = mesh.subMeshes;
  134367. this._defaultSubMeshCandidates.length = mesh.subMeshes.length;
  134368. return this._defaultSubMeshCandidates;
  134369. };
  134370. /**
  134371. * Sets the default candidate providers for the scene.
  134372. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  134373. * and getCollidingSubMeshCandidates to their default function
  134374. */
  134375. Scene.prototype.setDefaultCandidateProviders = function () {
  134376. this.getActiveMeshCandidates = this._getDefaultMeshCandidates.bind(this);
  134377. this.getActiveSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  134378. this.getIntersectingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  134379. this.getCollidingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  134380. };
  134381. Object.defineProperty(Scene.prototype, "meshUnderPointer", {
  134382. /**
  134383. * Gets the mesh that is currently under the pointer
  134384. */
  134385. get: function () {
  134386. return this._pointerOverMesh;
  134387. },
  134388. enumerable: true,
  134389. configurable: true
  134390. });
  134391. Object.defineProperty(Scene.prototype, "pointerX", {
  134392. /**
  134393. * Gets or sets the current on-screen X position of the pointer
  134394. */
  134395. get: function () {
  134396. return this._pointerX;
  134397. },
  134398. set: function (value) {
  134399. this._pointerX = value;
  134400. },
  134401. enumerable: true,
  134402. configurable: true
  134403. });
  134404. Object.defineProperty(Scene.prototype, "pointerY", {
  134405. /**
  134406. * Gets or sets the current on-screen Y position of the pointer
  134407. */
  134408. get: function () {
  134409. return this._pointerY;
  134410. },
  134411. set: function (value) {
  134412. this._pointerY = value;
  134413. },
  134414. enumerable: true,
  134415. configurable: true
  134416. });
  134417. /**
  134418. * Gets the cached material (ie. the latest rendered one)
  134419. * @returns the cached material
  134420. */
  134421. Scene.prototype.getCachedMaterial = function () {
  134422. return this._cachedMaterial;
  134423. };
  134424. /**
  134425. * Gets the cached effect (ie. the latest rendered one)
  134426. * @returns the cached effect
  134427. */
  134428. Scene.prototype.getCachedEffect = function () {
  134429. return this._cachedEffect;
  134430. };
  134431. /**
  134432. * Gets the cached visibility state (ie. the latest rendered one)
  134433. * @returns the cached visibility state
  134434. */
  134435. Scene.prototype.getCachedVisibility = function () {
  134436. return this._cachedVisibility;
  134437. };
  134438. /**
  134439. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  134440. * @param material defines the current material
  134441. * @param effect defines the current effect
  134442. * @param visibility defines the current visibility state
  134443. * @returns true if one parameter is not cached
  134444. */
  134445. Scene.prototype.isCachedMaterialInvalid = function (material, effect, visibility) {
  134446. if (visibility === void 0) { visibility = 1; }
  134447. return this._cachedEffect !== effect || this._cachedMaterial !== material || this._cachedVisibility !== visibility;
  134448. };
  134449. /**
  134450. * Gets the engine associated with the scene
  134451. * @returns an Engine
  134452. */
  134453. Scene.prototype.getEngine = function () {
  134454. return this._engine;
  134455. };
  134456. /**
  134457. * Gets the total number of vertices rendered per frame
  134458. * @returns the total number of vertices rendered per frame
  134459. */
  134460. Scene.prototype.getTotalVertices = function () {
  134461. return this._totalVertices.current;
  134462. };
  134463. Object.defineProperty(Scene.prototype, "totalVerticesPerfCounter", {
  134464. /**
  134465. * Gets the performance counter for total vertices
  134466. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  134467. */
  134468. get: function () {
  134469. return this._totalVertices;
  134470. },
  134471. enumerable: true,
  134472. configurable: true
  134473. });
  134474. /**
  134475. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  134476. * @returns the total number of active indices rendered per frame
  134477. */
  134478. Scene.prototype.getActiveIndices = function () {
  134479. return this._activeIndices.current;
  134480. };
  134481. Object.defineProperty(Scene.prototype, "totalActiveIndicesPerfCounter", {
  134482. /**
  134483. * Gets the performance counter for active indices
  134484. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  134485. */
  134486. get: function () {
  134487. return this._activeIndices;
  134488. },
  134489. enumerable: true,
  134490. configurable: true
  134491. });
  134492. /**
  134493. * Gets the total number of active particles rendered per frame
  134494. * @returns the total number of active particles rendered per frame
  134495. */
  134496. Scene.prototype.getActiveParticles = function () {
  134497. return this._activeParticles.current;
  134498. };
  134499. Object.defineProperty(Scene.prototype, "activeParticlesPerfCounter", {
  134500. /**
  134501. * Gets the performance counter for active particles
  134502. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  134503. */
  134504. get: function () {
  134505. return this._activeParticles;
  134506. },
  134507. enumerable: true,
  134508. configurable: true
  134509. });
  134510. /**
  134511. * Gets the total number of active bones rendered per frame
  134512. * @returns the total number of active bones rendered per frame
  134513. */
  134514. Scene.prototype.getActiveBones = function () {
  134515. return this._activeBones.current;
  134516. };
  134517. Object.defineProperty(Scene.prototype, "activeBonesPerfCounter", {
  134518. /**
  134519. * Gets the performance counter for active bones
  134520. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  134521. */
  134522. get: function () {
  134523. return this._activeBones;
  134524. },
  134525. enumerable: true,
  134526. configurable: true
  134527. });
  134528. /**
  134529. * Gets the array of active meshes
  134530. * @returns an array of AbstractMesh
  134531. */
  134532. Scene.prototype.getActiveMeshes = function () {
  134533. return this._activeMeshes;
  134534. };
  134535. /**
  134536. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  134537. * @returns a number
  134538. */
  134539. Scene.prototype.getAnimationRatio = function () {
  134540. return this._animationRatio !== undefined ? this._animationRatio : 1;
  134541. };
  134542. /**
  134543. * Gets an unique Id for the current render phase
  134544. * @returns a number
  134545. */
  134546. Scene.prototype.getRenderId = function () {
  134547. return this._renderId;
  134548. };
  134549. /**
  134550. * Gets an unique Id for the current frame
  134551. * @returns a number
  134552. */
  134553. Scene.prototype.getFrameId = function () {
  134554. return this._frameId;
  134555. };
  134556. /** Call this function if you want to manually increment the render Id*/
  134557. Scene.prototype.incrementRenderId = function () {
  134558. this._renderId++;
  134559. };
  134560. Scene.prototype._updatePointerPosition = function (evt) {
  134561. var canvasRect = this._engine.getRenderingCanvasClientRect();
  134562. if (!canvasRect) {
  134563. return;
  134564. }
  134565. this._pointerX = evt.clientX - canvasRect.left;
  134566. this._pointerY = evt.clientY - canvasRect.top;
  134567. this._unTranslatedPointerX = this._pointerX;
  134568. this._unTranslatedPointerY = this._pointerY;
  134569. };
  134570. Scene.prototype._createUbo = function () {
  134571. this._sceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__["UniformBuffer"](this._engine, undefined, true);
  134572. this._sceneUbo.addUniform("viewProjection", 16);
  134573. this._sceneUbo.addUniform("view", 16);
  134574. };
  134575. // Pointers handling
  134576. Scene.prototype._setRayOnPointerInfo = function (pointerInfo) {
  134577. if (pointerInfo.pickInfo && !pointerInfo.pickInfo._pickingUnavailable) {
  134578. if (!pointerInfo.pickInfo.ray) {
  134579. pointerInfo.pickInfo.ray = this.createPickingRay(pointerInfo.event.offsetX, pointerInfo.event.offsetY, _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity(), this.activeCamera);
  134580. }
  134581. }
  134582. };
  134583. /**
  134584. * Use this method to simulate a pointer move on a mesh
  134585. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  134586. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  134587. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  134588. * @returns the current scene
  134589. */
  134590. Scene.prototype.simulatePointerMove = function (pickResult, pointerEventInit) {
  134591. var evt = new PointerEvent("pointermove", pointerEventInit);
  134592. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERMOVE)) {
  134593. return this;
  134594. }
  134595. return this._processPointerMove(pickResult, evt);
  134596. };
  134597. Scene.prototype._processPointerMove = function (pickResult, evt) {
  134598. var canvas = this._engine.getRenderingCanvas();
  134599. if (!canvas) {
  134600. return this;
  134601. }
  134602. // Restore pointer
  134603. canvas.style.cursor = this.defaultCursor;
  134604. var isMeshPicked = (pickResult && pickResult.hit && pickResult.pickedMesh) ? true : false;
  134605. if (isMeshPicked) {
  134606. this.setPointerOverMesh(pickResult.pickedMesh);
  134607. if (this._pointerOverMesh && this._pointerOverMesh.actionManager && this._pointerOverMesh.actionManager.hasPointerTriggers) {
  134608. if (this._pointerOverMesh.actionManager.hoverCursor) {
  134609. canvas.style.cursor = this._pointerOverMesh.actionManager.hoverCursor;
  134610. }
  134611. else {
  134612. canvas.style.cursor = this.hoverCursor;
  134613. }
  134614. }
  134615. }
  134616. else {
  134617. this.setPointerOverMesh(null);
  134618. }
  134619. for (var _i = 0, _a = this._pointerMoveStage; _i < _a.length; _i++) {
  134620. var step = _a[_i];
  134621. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, isMeshPicked, canvas);
  134622. }
  134623. if (pickResult) {
  134624. var type = evt.type === this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERMOVE;
  134625. if (this.onPointerMove) {
  134626. this.onPointerMove(evt, pickResult, type);
  134627. }
  134628. if (this.onPointerObservable.hasObservers()) {
  134629. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  134630. this._setRayOnPointerInfo(pi);
  134631. this.onPointerObservable.notifyObservers(pi, type);
  134632. }
  134633. }
  134634. return this;
  134635. };
  134636. Scene.prototype._checkPrePointerObservable = function (pickResult, evt, type) {
  134637. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfoPre"](type, evt, this._unTranslatedPointerX, this._unTranslatedPointerY);
  134638. if (pickResult) {
  134639. pi.ray = pickResult.ray;
  134640. }
  134641. this.onPrePointerObservable.notifyObservers(pi, type);
  134642. if (pi.skipOnPointerObservable) {
  134643. return true;
  134644. }
  134645. else {
  134646. return false;
  134647. }
  134648. };
  134649. /**
  134650. * Use this method to simulate a pointer down on a mesh
  134651. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  134652. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  134653. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  134654. * @returns the current scene
  134655. */
  134656. Scene.prototype.simulatePointerDown = function (pickResult, pointerEventInit) {
  134657. var evt = new PointerEvent("pointerdown", pointerEventInit);
  134658. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN)) {
  134659. return this;
  134660. }
  134661. return this._processPointerDown(pickResult, evt);
  134662. };
  134663. Scene.prototype._processPointerDown = function (pickResult, evt) {
  134664. var _this = this;
  134665. if (pickResult && pickResult.hit && pickResult.pickedMesh) {
  134666. this._pickedDownMesh = pickResult.pickedMesh;
  134667. var actionManager = pickResult.pickedMesh.actionManager;
  134668. if (actionManager) {
  134669. if (actionManager.hasPickTriggers) {
  134670. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  134671. switch (evt.button) {
  134672. case 0:
  134673. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLeftPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  134674. break;
  134675. case 1:
  134676. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnCenterPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  134677. break;
  134678. case 2:
  134679. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnRightPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  134680. break;
  134681. }
  134682. }
  134683. if (actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLongPressTrigger)) {
  134684. window.setTimeout(function () {
  134685. 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);
  134686. if (pickResult && pickResult.hit && pickResult.pickedMesh && actionManager) {
  134687. if (_this._totalPointersPressed !== 0 &&
  134688. ((Date.now() - _this._startingPointerTime) > Scene.LongPressDelay) &&
  134689. !_this._isPointerSwiping()) {
  134690. _this._startingPointerTime = 0;
  134691. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLongPressTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  134692. }
  134693. }
  134694. }, Scene.LongPressDelay);
  134695. }
  134696. }
  134697. }
  134698. else {
  134699. for (var _i = 0, _a = this._pointerDownStage; _i < _a.length; _i++) {
  134700. var step = _a[_i];
  134701. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  134702. }
  134703. }
  134704. if (pickResult) {
  134705. var type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN;
  134706. if (this.onPointerDown) {
  134707. this.onPointerDown(evt, pickResult, type);
  134708. }
  134709. if (this.onPointerObservable.hasObservers()) {
  134710. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  134711. this._setRayOnPointerInfo(pi);
  134712. this.onPointerObservable.notifyObservers(pi, type);
  134713. }
  134714. }
  134715. return this;
  134716. };
  134717. /**
  134718. * Use this method to simulate a pointer up on a mesh
  134719. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  134720. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  134721. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  134722. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  134723. * @returns the current scene
  134724. */
  134725. Scene.prototype.simulatePointerUp = function (pickResult, pointerEventInit, doubleTap) {
  134726. var evt = new PointerEvent("pointerup", pointerEventInit);
  134727. var clickInfo = new ClickInfo();
  134728. if (doubleTap) {
  134729. clickInfo.doubleClick = true;
  134730. }
  134731. else {
  134732. clickInfo.singleClick = true;
  134733. }
  134734. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP)) {
  134735. return this;
  134736. }
  134737. return this._processPointerUp(pickResult, evt, clickInfo);
  134738. };
  134739. Scene.prototype._processPointerUp = function (pickResult, evt, clickInfo) {
  134740. if (pickResult && pickResult && pickResult.pickedMesh) {
  134741. this._pickedUpMesh = pickResult.pickedMesh;
  134742. if (this._pickedDownMesh === this._pickedUpMesh) {
  134743. if (this.onPointerPick) {
  134744. this.onPointerPick(evt, pickResult);
  134745. }
  134746. if (clickInfo.singleClick && !clickInfo.ignore && this.onPointerObservable.hasObservers()) {
  134747. var type_1 = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK;
  134748. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type_1, evt, pickResult);
  134749. this._setRayOnPointerInfo(pi);
  134750. this.onPointerObservable.notifyObservers(pi, type_1);
  134751. }
  134752. }
  134753. var actionManager = pickResult.pickedMesh._getActionManagerForTrigger();
  134754. if (actionManager && !clickInfo.ignore) {
  134755. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  134756. if (!clickInfo.hasSwiped && clickInfo.singleClick) {
  134757. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  134758. }
  134759. var doubleClickActionManager = pickResult.pickedMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger);
  134760. if (clickInfo.doubleClick && doubleClickActionManager) {
  134761. doubleClickActionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  134762. }
  134763. }
  134764. }
  134765. else {
  134766. if (!clickInfo.ignore) {
  134767. for (var _i = 0, _a = this._pointerUpStage; _i < _a.length; _i++) {
  134768. var step = _a[_i];
  134769. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  134770. }
  134771. }
  134772. }
  134773. if (this._pickedDownMesh && this._pickedDownMesh !== this._pickedUpMesh) {
  134774. var pickedDownActionManager = this._pickedDownMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickOutTrigger);
  134775. if (pickedDownActionManager) {
  134776. pickedDownActionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pickedDownMesh, evt));
  134777. }
  134778. }
  134779. var type = 0;
  134780. if (this.onPointerObservable.hasObservers()) {
  134781. if (!clickInfo.ignore && !clickInfo.hasSwiped) {
  134782. if (clickInfo.singleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  134783. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP;
  134784. }
  134785. else if (clickInfo.doubleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  134786. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP;
  134787. }
  134788. if (type) {
  134789. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  134790. this._setRayOnPointerInfo(pi);
  134791. this.onPointerObservable.notifyObservers(pi, type);
  134792. }
  134793. }
  134794. if (!clickInfo.ignore) {
  134795. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP;
  134796. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  134797. this._setRayOnPointerInfo(pi);
  134798. this.onPointerObservable.notifyObservers(pi, type);
  134799. }
  134800. }
  134801. if (this.onPointerUp && !clickInfo.ignore) {
  134802. this.onPointerUp(evt, pickResult, type);
  134803. }
  134804. return this;
  134805. };
  134806. /**
  134807. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  134808. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  134809. * @returns true if the pointer was captured
  134810. */
  134811. Scene.prototype.isPointerCaptured = function (pointerId) {
  134812. if (pointerId === void 0) { pointerId = 0; }
  134813. return this._pointerCaptures[pointerId];
  134814. };
  134815. /** @hidden */
  134816. Scene.prototype._isPointerSwiping = function () {
  134817. return Math.abs(this._startingPointerPosition.x - this._pointerX) > Scene.DragMovementThreshold ||
  134818. Math.abs(this._startingPointerPosition.y - this._pointerY) > Scene.DragMovementThreshold;
  134819. };
  134820. /**
  134821. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  134822. * @param attachUp defines if you want to attach events to pointerup
  134823. * @param attachDown defines if you want to attach events to pointerdown
  134824. * @param attachMove defines if you want to attach events to pointermove
  134825. */
  134826. Scene.prototype.attachControl = function (attachUp, attachDown, attachMove) {
  134827. var _this = this;
  134828. if (attachUp === void 0) { attachUp = true; }
  134829. if (attachDown === void 0) { attachDown = true; }
  134830. if (attachMove === void 0) { attachMove = true; }
  134831. this._initActionManager = function (act, clickInfo) {
  134832. if (!_this._meshPickProceed) {
  134833. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  134834. _this._currentPickResult = pickResult;
  134835. if (pickResult) {
  134836. act = (pickResult.hit && pickResult.pickedMesh) ? pickResult.pickedMesh.actionManager : null;
  134837. }
  134838. _this._meshPickProceed = true;
  134839. }
  134840. return act;
  134841. };
  134842. this._delayedSimpleClick = function (btn, clickInfo, cb) {
  134843. // double click delay is over and that no double click has been raised since, or the 2 consecutive keys pressed are different
  134844. if ((Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay && !_this._doubleClickOccured) ||
  134845. btn !== _this._previousButtonPressed) {
  134846. _this._doubleClickOccured = false;
  134847. clickInfo.singleClick = true;
  134848. clickInfo.ignore = false;
  134849. cb(clickInfo, _this._currentPickResult);
  134850. }
  134851. };
  134852. this._initClickEvent = function (obs1, obs2, evt, cb) {
  134853. var clickInfo = new ClickInfo();
  134854. _this._currentPickResult = null;
  134855. var act = null;
  134856. var checkPicking = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK)
  134857. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)
  134858. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  134859. if (!checkPicking && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"]) {
  134860. act = _this._initActionManager(act, clickInfo);
  134861. if (act) {
  134862. checkPicking = act.hasPickTriggers;
  134863. }
  134864. }
  134865. var needToIgnoreNext = false;
  134866. if (checkPicking) {
  134867. var btn = evt.button;
  134868. clickInfo.hasSwiped = _this._isPointerSwiping();
  134869. if (!clickInfo.hasSwiped) {
  134870. var checkSingleClickImmediately = !Scene.ExclusiveDoubleClickMode;
  134871. if (!checkSingleClickImmediately) {
  134872. checkSingleClickImmediately = !obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) &&
  134873. !obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  134874. if (checkSingleClickImmediately && !_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger)) {
  134875. act = _this._initActionManager(act, clickInfo);
  134876. if (act) {
  134877. checkSingleClickImmediately = !act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger);
  134878. }
  134879. }
  134880. }
  134881. if (checkSingleClickImmediately) {
  134882. // single click detected if double click delay is over or two different successive keys pressed without exclusive double click or no double click required
  134883. if (Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay ||
  134884. btn !== _this._previousButtonPressed) {
  134885. clickInfo.singleClick = true;
  134886. cb(clickInfo, _this._currentPickResult);
  134887. needToIgnoreNext = true;
  134888. }
  134889. }
  134890. // at least one double click is required to be check and exclusive double click is enabled
  134891. else {
  134892. // wait that no double click has been raised during the double click delay
  134893. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  134894. _this._delayedSimpleClickTimeout = window.setTimeout(_this._delayedSimpleClick.bind(_this, btn, clickInfo, cb), Scene.DoubleClickDelay);
  134895. }
  134896. var checkDoubleClick = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) ||
  134897. obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  134898. if (!checkDoubleClick && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger)) {
  134899. act = _this._initActionManager(act, clickInfo);
  134900. if (act) {
  134901. checkDoubleClick = act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger);
  134902. }
  134903. }
  134904. if (checkDoubleClick) {
  134905. // two successive keys pressed are equal, double click delay is not over and double click has not just occurred
  134906. if (btn === _this._previousButtonPressed &&
  134907. Date.now() - _this._previousStartingPointerTime < Scene.DoubleClickDelay &&
  134908. !_this._doubleClickOccured) {
  134909. // pointer has not moved for 2 clicks, it's a double click
  134910. if (!clickInfo.hasSwiped &&
  134911. !_this._isPointerSwiping()) {
  134912. _this._previousStartingPointerTime = 0;
  134913. _this._doubleClickOccured = true;
  134914. clickInfo.doubleClick = true;
  134915. clickInfo.ignore = false;
  134916. if (Scene.ExclusiveDoubleClickMode && _this._previousDelayedSimpleClickTimeout) {
  134917. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  134918. }
  134919. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  134920. cb(clickInfo, _this._currentPickResult);
  134921. }
  134922. // if the two successive clicks are too far, it's just two simple clicks
  134923. else {
  134924. _this._doubleClickOccured = false;
  134925. _this._previousStartingPointerTime = _this._startingPointerTime;
  134926. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  134927. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  134928. _this._previousButtonPressed = btn;
  134929. if (Scene.ExclusiveDoubleClickMode) {
  134930. if (_this._previousDelayedSimpleClickTimeout) {
  134931. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  134932. }
  134933. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  134934. cb(clickInfo, _this._previousPickResult);
  134935. }
  134936. else {
  134937. cb(clickInfo, _this._currentPickResult);
  134938. }
  134939. }
  134940. needToIgnoreNext = true;
  134941. }
  134942. // just the first click of the double has been raised
  134943. else {
  134944. _this._doubleClickOccured = false;
  134945. _this._previousStartingPointerTime = _this._startingPointerTime;
  134946. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  134947. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  134948. _this._previousButtonPressed = btn;
  134949. }
  134950. }
  134951. }
  134952. }
  134953. if (!needToIgnoreNext) {
  134954. cb(clickInfo, _this._currentPickResult);
  134955. }
  134956. };
  134957. this._onPointerMove = function (evt) {
  134958. _this._updatePointerPosition(evt);
  134959. // PreObservable support
  134960. 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)) {
  134961. return;
  134962. }
  134963. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  134964. return;
  134965. }
  134966. if (!_this.pointerMovePredicate) {
  134967. _this.pointerMovePredicate = function (mesh) { return (mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (mesh.enablePointerMoveEvents || _this.constantlyUpdateMeshUnderPointer || (mesh.actionManager !== null && mesh.actionManager !== undefined)) && (!_this.cameraToUseForPointers || (_this.cameraToUseForPointers.layerMask & mesh.layerMask) !== 0)); };
  134968. }
  134969. // Meshes
  134970. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerMovePredicate, false, _this.cameraToUseForPointers);
  134971. _this._processPointerMove(pickResult, evt);
  134972. };
  134973. this._onPointerDown = function (evt) {
  134974. _this._totalPointersPressed++;
  134975. _this._pickedDownMesh = null;
  134976. _this._meshPickProceed = false;
  134977. _this._updatePointerPosition(evt);
  134978. if (_this.preventDefaultOnPointerDown && canvas) {
  134979. evt.preventDefault();
  134980. canvas.focus();
  134981. }
  134982. _this._startingPointerPosition.x = _this._pointerX;
  134983. _this._startingPointerPosition.y = _this._pointerY;
  134984. _this._startingPointerTime = Date.now();
  134985. // PreObservable support
  134986. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN)) {
  134987. return;
  134988. }
  134989. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  134990. return;
  134991. }
  134992. _this._pointerCaptures[evt.pointerId] = true;
  134993. if (!_this.pointerDownPredicate) {
  134994. _this.pointerDownPredicate = function (mesh) {
  134995. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (!_this.cameraToUseForPointers || (_this.cameraToUseForPointers.layerMask & mesh.layerMask) !== 0);
  134996. };
  134997. }
  134998. // Meshes
  134999. _this._pickedDownMesh = null;
  135000. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  135001. _this._processPointerDown(pickResult, evt);
  135002. };
  135003. this._onPointerUp = function (evt) {
  135004. if (_this._totalPointersPressed === 0) { // We are attaching the pointer up to windows because of a bug in FF
  135005. return; // So we need to test it the pointer down was pressed before.
  135006. }
  135007. _this._totalPointersPressed--;
  135008. _this._pickedUpMesh = null;
  135009. _this._meshPickProceed = false;
  135010. _this._updatePointerPosition(evt);
  135011. if (_this.preventDefaultOnPointerUp && canvas) {
  135012. evt.preventDefault();
  135013. canvas.focus();
  135014. }
  135015. _this._initClickEvent(_this.onPrePointerObservable, _this.onPointerObservable, evt, function (clickInfo, pickResult) {
  135016. // PreObservable support
  135017. if (_this.onPrePointerObservable.hasObservers()) {
  135018. if (!clickInfo.ignore) {
  135019. if (!clickInfo.hasSwiped) {
  135020. if (clickInfo.singleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  135021. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  135022. return;
  135023. }
  135024. }
  135025. if (clickInfo.doubleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  135026. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  135027. return;
  135028. }
  135029. }
  135030. }
  135031. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP)) {
  135032. return;
  135033. }
  135034. }
  135035. }
  135036. if (!_this._pointerCaptures[evt.pointerId]) {
  135037. return;
  135038. }
  135039. _this._pointerCaptures[evt.pointerId] = false;
  135040. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  135041. return;
  135042. }
  135043. if (!_this.pointerUpPredicate) {
  135044. _this.pointerUpPredicate = function (mesh) {
  135045. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (!_this.cameraToUseForPointers || (_this.cameraToUseForPointers.layerMask & mesh.layerMask) !== 0);
  135046. };
  135047. }
  135048. // Meshes
  135049. if (!_this._meshPickProceed && (_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"] && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasTriggers || _this.onPointerObservable.hasObservers())) {
  135050. _this._initActionManager(null, clickInfo);
  135051. }
  135052. if (!pickResult) {
  135053. pickResult = _this._currentPickResult;
  135054. }
  135055. _this._processPointerUp(pickResult, evt, clickInfo);
  135056. _this._previousPickResult = _this._currentPickResult;
  135057. });
  135058. };
  135059. this._onKeyDown = function (evt) {
  135060. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardEventTypes"].KEYDOWN;
  135061. if (_this.onPreKeyboardObservable.hasObservers()) {
  135062. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfoPre"](type, evt);
  135063. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  135064. if (pi.skipOnPointerObservable) {
  135065. return;
  135066. }
  135067. }
  135068. if (_this.onKeyboardObservable.hasObservers()) {
  135069. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfo"](type, evt);
  135070. _this.onKeyboardObservable.notifyObservers(pi, type);
  135071. }
  135072. if (_this.actionManager) {
  135073. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnKeyDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNewFromScene(_this, evt));
  135074. }
  135075. };
  135076. this._onKeyUp = function (evt) {
  135077. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardEventTypes"].KEYUP;
  135078. if (_this.onPreKeyboardObservable.hasObservers()) {
  135079. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfoPre"](type, evt);
  135080. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  135081. if (pi.skipOnPointerObservable) {
  135082. return;
  135083. }
  135084. }
  135085. if (_this.onKeyboardObservable.hasObservers()) {
  135086. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfo"](type, evt);
  135087. _this.onKeyboardObservable.notifyObservers(pi, type);
  135088. }
  135089. if (_this.actionManager) {
  135090. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnKeyUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNewFromScene(_this, evt));
  135091. }
  135092. };
  135093. var engine = this.getEngine();
  135094. this._onCanvasFocusObserver = engine.onCanvasFocusObservable.add(function () {
  135095. if (!canvas) {
  135096. return;
  135097. }
  135098. canvas.addEventListener("keydown", _this._onKeyDown, false);
  135099. canvas.addEventListener("keyup", _this._onKeyUp, false);
  135100. });
  135101. this._onCanvasBlurObserver = engine.onCanvasBlurObservable.add(function () {
  135102. if (!canvas) {
  135103. return;
  135104. }
  135105. canvas.removeEventListener("keydown", _this._onKeyDown);
  135106. canvas.removeEventListener("keyup", _this._onKeyUp);
  135107. });
  135108. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  135109. var canvas = this._engine.getRenderingCanvas();
  135110. if (!canvas) {
  135111. return;
  135112. }
  135113. if (attachMove) {
  135114. canvas.addEventListener(eventPrefix + "move", this._onPointerMove, false);
  135115. // Wheel
  135116. this._wheelEventName = "onwheel" in document.createElement("div") ? "wheel" : // Modern browsers support "wheel"
  135117. document.onmousewheel !== undefined ? "mousewheel" : // Webkit and IE support at least "mousewheel"
  135118. "DOMMouseScroll"; // let's assume that remaining browsers are older Firefox
  135119. canvas.addEventListener(this._wheelEventName, this._onPointerMove, false);
  135120. }
  135121. if (attachDown) {
  135122. canvas.addEventListener(eventPrefix + "down", this._onPointerDown, false);
  135123. }
  135124. if (attachUp) {
  135125. window.addEventListener(eventPrefix + "up", this._onPointerUp, false);
  135126. }
  135127. canvas.tabIndex = 1;
  135128. };
  135129. /** Detaches all event handlers*/
  135130. Scene.prototype.detachControl = function () {
  135131. var engine = this.getEngine();
  135132. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  135133. var canvas = engine.getRenderingCanvas();
  135134. if (!canvas) {
  135135. return;
  135136. }
  135137. canvas.removeEventListener(eventPrefix + "move", this._onPointerMove);
  135138. canvas.removeEventListener(eventPrefix + "down", this._onPointerDown);
  135139. window.removeEventListener(eventPrefix + "up", this._onPointerUp);
  135140. if (this._onCanvasBlurObserver) {
  135141. engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  135142. }
  135143. if (this._onCanvasFocusObserver) {
  135144. engine.onCanvasFocusObservable.remove(this._onCanvasFocusObserver);
  135145. }
  135146. // Wheel
  135147. canvas.removeEventListener(this._wheelEventName, this._onPointerMove);
  135148. // Keyboard
  135149. canvas.removeEventListener("keydown", this._onKeyDown);
  135150. canvas.removeEventListener("keyup", this._onKeyUp);
  135151. // Observables
  135152. this.onKeyboardObservable.clear();
  135153. this.onPreKeyboardObservable.clear();
  135154. this.onPointerObservable.clear();
  135155. this.onPrePointerObservable.clear();
  135156. };
  135157. /**
  135158. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  135159. * Delay loaded resources are not taking in account
  135160. * @return true if all required resources are ready
  135161. */
  135162. Scene.prototype.isReady = function () {
  135163. if (this._isDisposed) {
  135164. return false;
  135165. }
  135166. var index;
  135167. var engine = this.getEngine();
  135168. // Effects
  135169. if (!engine.areAllEffectsReady()) {
  135170. return false;
  135171. }
  135172. // Pending data
  135173. if (this._pendingData.length > 0) {
  135174. return false;
  135175. }
  135176. // Meshes
  135177. for (index = 0; index < this.meshes.length; index++) {
  135178. var mesh = this.meshes[index];
  135179. if (!mesh.isEnabled()) {
  135180. continue;
  135181. }
  135182. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  135183. continue;
  135184. }
  135185. if (!mesh.isReady(true)) {
  135186. return false;
  135187. }
  135188. var hardwareInstancedRendering = mesh.getClassName() === "InstancedMesh" || mesh.getClassName() === "InstancedLinesMesh" || engine.getCaps().instancedArrays && mesh.instances.length > 0;
  135189. // Is Ready For Mesh
  135190. for (var _i = 0, _a = this._isReadyForMeshStage; _i < _a.length; _i++) {
  135191. var step = _a[_i];
  135192. if (!step.action(mesh, hardwareInstancedRendering)) {
  135193. return false;
  135194. }
  135195. }
  135196. }
  135197. // Geometries
  135198. for (index = 0; index < this.geometries.length; index++) {
  135199. var geometry = this.geometries[index];
  135200. if (geometry.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].DELAYLOADSTATE_LOADING) {
  135201. return false;
  135202. }
  135203. }
  135204. // Post-processes
  135205. if (this.activeCameras && this.activeCameras.length > 0) {
  135206. for (var _b = 0, _c = this.activeCameras; _b < _c.length; _b++) {
  135207. var camera = _c[_b];
  135208. if (!camera.isReady(true)) {
  135209. return false;
  135210. }
  135211. }
  135212. }
  135213. else if (this.activeCamera) {
  135214. if (!this.activeCamera.isReady(true)) {
  135215. return false;
  135216. }
  135217. }
  135218. // Particles
  135219. for (var _d = 0, _e = this.particleSystems; _d < _e.length; _d++) {
  135220. var particleSystem = _e[_d];
  135221. if (!particleSystem.isReady()) {
  135222. return false;
  135223. }
  135224. }
  135225. return true;
  135226. };
  135227. /** Resets all cached information relative to material (including effect and visibility) */
  135228. Scene.prototype.resetCachedMaterial = function () {
  135229. this._cachedMaterial = null;
  135230. this._cachedEffect = null;
  135231. this._cachedVisibility = null;
  135232. };
  135233. /**
  135234. * Registers a function to be called before every frame render
  135235. * @param func defines the function to register
  135236. */
  135237. Scene.prototype.registerBeforeRender = function (func) {
  135238. this.onBeforeRenderObservable.add(func);
  135239. };
  135240. /**
  135241. * Unregisters a function called before every frame render
  135242. * @param func defines the function to unregister
  135243. */
  135244. Scene.prototype.unregisterBeforeRender = function (func) {
  135245. this.onBeforeRenderObservable.removeCallback(func);
  135246. };
  135247. /**
  135248. * Registers a function to be called after every frame render
  135249. * @param func defines the function to register
  135250. */
  135251. Scene.prototype.registerAfterRender = function (func) {
  135252. this.onAfterRenderObservable.add(func);
  135253. };
  135254. /**
  135255. * Unregisters a function called after every frame render
  135256. * @param func defines the function to unregister
  135257. */
  135258. Scene.prototype.unregisterAfterRender = function (func) {
  135259. this.onAfterRenderObservable.removeCallback(func);
  135260. };
  135261. Scene.prototype._executeOnceBeforeRender = function (func) {
  135262. var _this = this;
  135263. var execFunc = function () {
  135264. func();
  135265. setTimeout(function () {
  135266. _this.unregisterBeforeRender(execFunc);
  135267. });
  135268. };
  135269. this.registerBeforeRender(execFunc);
  135270. };
  135271. /**
  135272. * The provided function will run before render once and will be disposed afterwards.
  135273. * A timeout delay can be provided so that the function will be executed in N ms.
  135274. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  135275. * @param func The function to be executed.
  135276. * @param timeout optional delay in ms
  135277. */
  135278. Scene.prototype.executeOnceBeforeRender = function (func, timeout) {
  135279. var _this = this;
  135280. if (timeout !== undefined) {
  135281. setTimeout(function () {
  135282. _this._executeOnceBeforeRender(func);
  135283. }, timeout);
  135284. }
  135285. else {
  135286. this._executeOnceBeforeRender(func);
  135287. }
  135288. };
  135289. /** @hidden */
  135290. Scene.prototype._addPendingData = function (data) {
  135291. this._pendingData.push(data);
  135292. };
  135293. /** @hidden */
  135294. Scene.prototype._removePendingData = function (data) {
  135295. var wasLoading = this.isLoading;
  135296. var index = this._pendingData.indexOf(data);
  135297. if (index !== -1) {
  135298. this._pendingData.splice(index, 1);
  135299. }
  135300. if (wasLoading && !this.isLoading) {
  135301. this.onDataLoadedObservable.notifyObservers(this);
  135302. }
  135303. };
  135304. /**
  135305. * Returns the number of items waiting to be loaded
  135306. * @returns the number of items waiting to be loaded
  135307. */
  135308. Scene.prototype.getWaitingItemsCount = function () {
  135309. return this._pendingData.length;
  135310. };
  135311. Object.defineProperty(Scene.prototype, "isLoading", {
  135312. /**
  135313. * Returns a boolean indicating if the scene is still loading data
  135314. */
  135315. get: function () {
  135316. return this._pendingData.length > 0;
  135317. },
  135318. enumerable: true,
  135319. configurable: true
  135320. });
  135321. /**
  135322. * Registers a function to be executed when the scene is ready
  135323. * @param {Function} func - the function to be executed
  135324. */
  135325. Scene.prototype.executeWhenReady = function (func) {
  135326. var _this = this;
  135327. this.onReadyObservable.add(func);
  135328. if (this._executeWhenReadyTimeoutId !== -1) {
  135329. return;
  135330. }
  135331. this._executeWhenReadyTimeoutId = setTimeout(function () {
  135332. _this._checkIsReady();
  135333. }, 150);
  135334. };
  135335. /**
  135336. * Returns a promise that resolves when the scene is ready
  135337. * @returns A promise that resolves when the scene is ready
  135338. */
  135339. Scene.prototype.whenReadyAsync = function () {
  135340. var _this = this;
  135341. return new Promise(function (resolve) {
  135342. _this.executeWhenReady(function () {
  135343. resolve();
  135344. });
  135345. });
  135346. };
  135347. /** @hidden */
  135348. Scene.prototype._checkIsReady = function () {
  135349. var _this = this;
  135350. this._registerTransientComponents();
  135351. if (this.isReady()) {
  135352. this.onReadyObservable.notifyObservers(this);
  135353. this.onReadyObservable.clear();
  135354. this._executeWhenReadyTimeoutId = -1;
  135355. return;
  135356. }
  135357. this._executeWhenReadyTimeoutId = setTimeout(function () {
  135358. _this._checkIsReady();
  135359. }, 150);
  135360. };
  135361. Object.defineProperty(Scene.prototype, "animatables", {
  135362. /**
  135363. * Gets all animatable attached to the scene
  135364. */
  135365. get: function () {
  135366. return this._activeAnimatables;
  135367. },
  135368. enumerable: true,
  135369. configurable: true
  135370. });
  135371. /**
  135372. * Resets the last animation time frame.
  135373. * Useful to override when animations start running when loading a scene for the first time.
  135374. */
  135375. Scene.prototype.resetLastAnimationTimeFrame = function () {
  135376. this._animationTimeLast = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__["PrecisionDate"].Now;
  135377. };
  135378. // Matrix
  135379. /**
  135380. * Gets the current view matrix
  135381. * @returns a Matrix
  135382. */
  135383. Scene.prototype.getViewMatrix = function () {
  135384. return this._viewMatrix;
  135385. };
  135386. /**
  135387. * Gets the current projection matrix
  135388. * @returns a Matrix
  135389. */
  135390. Scene.prototype.getProjectionMatrix = function () {
  135391. return this._projectionMatrix;
  135392. };
  135393. /**
  135394. * Gets the current transform matrix
  135395. * @returns a Matrix made of View * Projection
  135396. */
  135397. Scene.prototype.getTransformMatrix = function () {
  135398. return this._transformMatrix;
  135399. };
  135400. /**
  135401. * Sets the current transform matrix
  135402. * @param viewL defines the View matrix to use
  135403. * @param projectionL defines the Projection matrix to use
  135404. * @param viewR defines the right View matrix to use (if provided)
  135405. * @param projectionR defines the right Projection matrix to use (if provided)
  135406. */
  135407. Scene.prototype.setTransformMatrix = function (viewL, projectionL, viewR, projectionR) {
  135408. if (this._viewUpdateFlag === viewL.updateFlag && this._projectionUpdateFlag === projectionL.updateFlag) {
  135409. return;
  135410. }
  135411. this._viewUpdateFlag = viewL.updateFlag;
  135412. this._projectionUpdateFlag = projectionL.updateFlag;
  135413. this._viewMatrix = viewL;
  135414. this._projectionMatrix = projectionL;
  135415. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  135416. // Update frustum
  135417. if (!this._frustumPlanes) {
  135418. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanes(this._transformMatrix);
  135419. }
  135420. else {
  135421. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  135422. }
  135423. if (this._multiviewSceneUbo && this._multiviewSceneUbo.useUbo) {
  135424. this._updateMultiviewUbo(viewR, projectionR);
  135425. }
  135426. else if (this._sceneUbo.useUbo) {
  135427. this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix);
  135428. this._sceneUbo.updateMatrix("view", this._viewMatrix);
  135429. this._sceneUbo.update();
  135430. }
  135431. };
  135432. /**
  135433. * Gets the uniform buffer used to store scene data
  135434. * @returns a UniformBuffer
  135435. */
  135436. Scene.prototype.getSceneUniformBuffer = function () {
  135437. return this._multiviewSceneUbo ? this._multiviewSceneUbo : this._sceneUbo;
  135438. };
  135439. /**
  135440. * Gets an unique (relatively to the current scene) Id
  135441. * @returns an unique number for the scene
  135442. */
  135443. Scene.prototype.getUniqueId = function () {
  135444. var result = Scene._uniqueIdCounter;
  135445. Scene._uniqueIdCounter++;
  135446. return result;
  135447. };
  135448. /**
  135449. * Add a mesh to the list of scene's meshes
  135450. * @param newMesh defines the mesh to add
  135451. * @param recursive if all child meshes should also be added to the scene
  135452. */
  135453. Scene.prototype.addMesh = function (newMesh, recursive) {
  135454. var _this = this;
  135455. if (recursive === void 0) { recursive = false; }
  135456. this.meshes.push(newMesh);
  135457. newMesh._resyncLightSources();
  135458. this.onNewMeshAddedObservable.notifyObservers(newMesh);
  135459. if (recursive) {
  135460. newMesh.getChildMeshes().forEach(function (m) {
  135461. _this.addMesh(m);
  135462. });
  135463. }
  135464. };
  135465. /**
  135466. * Remove a mesh for the list of scene's meshes
  135467. * @param toRemove defines the mesh to remove
  135468. * @param recursive if all child meshes should also be removed from the scene
  135469. * @returns the index where the mesh was in the mesh list
  135470. */
  135471. Scene.prototype.removeMesh = function (toRemove, recursive) {
  135472. var _this = this;
  135473. if (recursive === void 0) { recursive = false; }
  135474. var index = this.meshes.indexOf(toRemove);
  135475. if (index !== -1) {
  135476. // Remove from the scene if mesh found
  135477. this.meshes[index] = this.meshes[this.meshes.length - 1];
  135478. this.meshes.pop();
  135479. }
  135480. this.onMeshRemovedObservable.notifyObservers(toRemove);
  135481. if (recursive) {
  135482. toRemove.getChildMeshes().forEach(function (m) {
  135483. _this.removeMesh(m);
  135484. });
  135485. }
  135486. return index;
  135487. };
  135488. /**
  135489. * Add a transform node to the list of scene's transform nodes
  135490. * @param newTransformNode defines the transform node to add
  135491. */
  135492. Scene.prototype.addTransformNode = function (newTransformNode) {
  135493. newTransformNode._indexInSceneTransformNodesArray = this.transformNodes.length;
  135494. this.transformNodes.push(newTransformNode);
  135495. this.onNewTransformNodeAddedObservable.notifyObservers(newTransformNode);
  135496. };
  135497. /**
  135498. * Remove a transform node for the list of scene's transform nodes
  135499. * @param toRemove defines the transform node to remove
  135500. * @returns the index where the transform node was in the transform node list
  135501. */
  135502. Scene.prototype.removeTransformNode = function (toRemove) {
  135503. var index = toRemove._indexInSceneTransformNodesArray;
  135504. if (index !== -1) {
  135505. if (index !== this.transformNodes.length - 1) {
  135506. var lastNode = this.transformNodes[this.transformNodes.length - 1];
  135507. this.transformNodes[index] = lastNode;
  135508. lastNode._indexInSceneTransformNodesArray = index;
  135509. }
  135510. toRemove._indexInSceneTransformNodesArray = -1;
  135511. this.transformNodes.pop();
  135512. }
  135513. this.onTransformNodeRemovedObservable.notifyObservers(toRemove);
  135514. return index;
  135515. };
  135516. /**
  135517. * Remove a skeleton for the list of scene's skeletons
  135518. * @param toRemove defines the skeleton to remove
  135519. * @returns the index where the skeleton was in the skeleton list
  135520. */
  135521. Scene.prototype.removeSkeleton = function (toRemove) {
  135522. var index = this.skeletons.indexOf(toRemove);
  135523. if (index !== -1) {
  135524. // Remove from the scene if found
  135525. this.skeletons.splice(index, 1);
  135526. this.onSkeletonRemovedObservable.notifyObservers(toRemove);
  135527. }
  135528. return index;
  135529. };
  135530. /**
  135531. * Remove a morph target for the list of scene's morph targets
  135532. * @param toRemove defines the morph target to remove
  135533. * @returns the index where the morph target was in the morph target list
  135534. */
  135535. Scene.prototype.removeMorphTargetManager = function (toRemove) {
  135536. var index = this.morphTargetManagers.indexOf(toRemove);
  135537. if (index !== -1) {
  135538. // Remove from the scene if found
  135539. this.morphTargetManagers.splice(index, 1);
  135540. }
  135541. return index;
  135542. };
  135543. /**
  135544. * Remove a light for the list of scene's lights
  135545. * @param toRemove defines the light to remove
  135546. * @returns the index where the light was in the light list
  135547. */
  135548. Scene.prototype.removeLight = function (toRemove) {
  135549. var index = this.lights.indexOf(toRemove);
  135550. if (index !== -1) {
  135551. // Remove from meshes
  135552. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  135553. var mesh = _a[_i];
  135554. mesh._removeLightSource(toRemove);
  135555. }
  135556. // Remove from the scene if mesh found
  135557. this.lights.splice(index, 1);
  135558. this.sortLightsByPriority();
  135559. }
  135560. this.onLightRemovedObservable.notifyObservers(toRemove);
  135561. return index;
  135562. };
  135563. /**
  135564. * Remove a camera for the list of scene's cameras
  135565. * @param toRemove defines the camera to remove
  135566. * @returns the index where the camera was in the camera list
  135567. */
  135568. Scene.prototype.removeCamera = function (toRemove) {
  135569. var index = this.cameras.indexOf(toRemove);
  135570. if (index !== -1) {
  135571. // Remove from the scene if mesh found
  135572. this.cameras.splice(index, 1);
  135573. }
  135574. // Remove from activeCameras
  135575. var index2 = this.activeCameras.indexOf(toRemove);
  135576. if (index2 !== -1) {
  135577. // Remove from the scene if mesh found
  135578. this.activeCameras.splice(index2, 1);
  135579. }
  135580. // Reset the activeCamera
  135581. if (this.activeCamera === toRemove) {
  135582. if (this.cameras.length > 0) {
  135583. this.activeCamera = this.cameras[0];
  135584. }
  135585. else {
  135586. this.activeCamera = null;
  135587. }
  135588. }
  135589. this.onCameraRemovedObservable.notifyObservers(toRemove);
  135590. return index;
  135591. };
  135592. /**
  135593. * Remove a particle system for the list of scene's particle systems
  135594. * @param toRemove defines the particle system to remove
  135595. * @returns the index where the particle system was in the particle system list
  135596. */
  135597. Scene.prototype.removeParticleSystem = function (toRemove) {
  135598. var index = this.particleSystems.indexOf(toRemove);
  135599. if (index !== -1) {
  135600. this.particleSystems.splice(index, 1);
  135601. }
  135602. return index;
  135603. };
  135604. /**
  135605. * Remove a animation for the list of scene's animations
  135606. * @param toRemove defines the animation to remove
  135607. * @returns the index where the animation was in the animation list
  135608. */
  135609. Scene.prototype.removeAnimation = function (toRemove) {
  135610. var index = this.animations.indexOf(toRemove);
  135611. if (index !== -1) {
  135612. this.animations.splice(index, 1);
  135613. }
  135614. return index;
  135615. };
  135616. /**
  135617. * Removes the given animation group from this scene.
  135618. * @param toRemove The animation group to remove
  135619. * @returns The index of the removed animation group
  135620. */
  135621. Scene.prototype.removeAnimationGroup = function (toRemove) {
  135622. var index = this.animationGroups.indexOf(toRemove);
  135623. if (index !== -1) {
  135624. this.animationGroups.splice(index, 1);
  135625. }
  135626. return index;
  135627. };
  135628. /**
  135629. * Removes the given multi-material from this scene.
  135630. * @param toRemove The multi-material to remove
  135631. * @returns The index of the removed multi-material
  135632. */
  135633. Scene.prototype.removeMultiMaterial = function (toRemove) {
  135634. var index = this.multiMaterials.indexOf(toRemove);
  135635. if (index !== -1) {
  135636. this.multiMaterials.splice(index, 1);
  135637. }
  135638. return index;
  135639. };
  135640. /**
  135641. * Removes the given material from this scene.
  135642. * @param toRemove The material to remove
  135643. * @returns The index of the removed material
  135644. */
  135645. Scene.prototype.removeMaterial = function (toRemove) {
  135646. var index = toRemove._indexInSceneMaterialArray;
  135647. if (index !== -1 && index < this.materials.length) {
  135648. if (index !== this.materials.length - 1) {
  135649. var lastMaterial = this.materials[this.materials.length - 1];
  135650. this.materials[index] = lastMaterial;
  135651. lastMaterial._indexInSceneMaterialArray = index;
  135652. }
  135653. toRemove._indexInSceneMaterialArray = -1;
  135654. this.materials.pop();
  135655. }
  135656. this.onMaterialRemovedObservable.notifyObservers(toRemove);
  135657. return index;
  135658. };
  135659. /**
  135660. * Removes the given action manager from this scene.
  135661. * @param toRemove The action manager to remove
  135662. * @returns The index of the removed action manager
  135663. */
  135664. Scene.prototype.removeActionManager = function (toRemove) {
  135665. var index = this.actionManagers.indexOf(toRemove);
  135666. if (index !== -1) {
  135667. this.actionManagers.splice(index, 1);
  135668. }
  135669. return index;
  135670. };
  135671. /**
  135672. * Removes the given texture from this scene.
  135673. * @param toRemove The texture to remove
  135674. * @returns The index of the removed texture
  135675. */
  135676. Scene.prototype.removeTexture = function (toRemove) {
  135677. var index = this.textures.indexOf(toRemove);
  135678. if (index !== -1) {
  135679. this.textures.splice(index, 1);
  135680. }
  135681. this.onTextureRemovedObservable.notifyObservers(toRemove);
  135682. return index;
  135683. };
  135684. /**
  135685. * Adds the given light to this scene
  135686. * @param newLight The light to add
  135687. */
  135688. Scene.prototype.addLight = function (newLight) {
  135689. this.lights.push(newLight);
  135690. this.sortLightsByPriority();
  135691. // Add light to all meshes (To support if the light is removed and then readded)
  135692. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  135693. var mesh = _a[_i];
  135694. if (mesh._lightSources.indexOf(newLight) === -1) {
  135695. mesh._lightSources.push(newLight);
  135696. mesh._resyncLightSources();
  135697. }
  135698. }
  135699. this.onNewLightAddedObservable.notifyObservers(newLight);
  135700. };
  135701. /**
  135702. * Sorts the list list based on light priorities
  135703. */
  135704. Scene.prototype.sortLightsByPriority = function () {
  135705. if (this.requireLightSorting) {
  135706. this.lights.sort(_Lights_light__WEBPACK_IMPORTED_MODULE_13__["Light"].CompareLightsPriority);
  135707. }
  135708. };
  135709. /**
  135710. * Adds the given camera to this scene
  135711. * @param newCamera The camera to add
  135712. */
  135713. Scene.prototype.addCamera = function (newCamera) {
  135714. this.cameras.push(newCamera);
  135715. this.onNewCameraAddedObservable.notifyObservers(newCamera);
  135716. };
  135717. /**
  135718. * Adds the given skeleton to this scene
  135719. * @param newSkeleton The skeleton to add
  135720. */
  135721. Scene.prototype.addSkeleton = function (newSkeleton) {
  135722. this.skeletons.push(newSkeleton);
  135723. this.onNewSkeletonAddedObservable.notifyObservers(newSkeleton);
  135724. };
  135725. /**
  135726. * Adds the given particle system to this scene
  135727. * @param newParticleSystem The particle system to add
  135728. */
  135729. Scene.prototype.addParticleSystem = function (newParticleSystem) {
  135730. this.particleSystems.push(newParticleSystem);
  135731. };
  135732. /**
  135733. * Adds the given animation to this scene
  135734. * @param newAnimation The animation to add
  135735. */
  135736. Scene.prototype.addAnimation = function (newAnimation) {
  135737. this.animations.push(newAnimation);
  135738. };
  135739. /**
  135740. * Adds the given animation group to this scene.
  135741. * @param newAnimationGroup The animation group to add
  135742. */
  135743. Scene.prototype.addAnimationGroup = function (newAnimationGroup) {
  135744. this.animationGroups.push(newAnimationGroup);
  135745. };
  135746. /**
  135747. * Adds the given multi-material to this scene
  135748. * @param newMultiMaterial The multi-material to add
  135749. */
  135750. Scene.prototype.addMultiMaterial = function (newMultiMaterial) {
  135751. this.multiMaterials.push(newMultiMaterial);
  135752. };
  135753. /**
  135754. * Adds the given material to this scene
  135755. * @param newMaterial The material to add
  135756. */
  135757. Scene.prototype.addMaterial = function (newMaterial) {
  135758. newMaterial._indexInSceneMaterialArray = this.materials.length;
  135759. this.materials.push(newMaterial);
  135760. this.onNewMaterialAddedObservable.notifyObservers(newMaterial);
  135761. };
  135762. /**
  135763. * Adds the given morph target to this scene
  135764. * @param newMorphTargetManager The morph target to add
  135765. */
  135766. Scene.prototype.addMorphTargetManager = function (newMorphTargetManager) {
  135767. this.morphTargetManagers.push(newMorphTargetManager);
  135768. };
  135769. /**
  135770. * Adds the given geometry to this scene
  135771. * @param newGeometry The geometry to add
  135772. */
  135773. Scene.prototype.addGeometry = function (newGeometry) {
  135774. if (this.geometriesByUniqueId) {
  135775. this.geometriesByUniqueId[newGeometry.uniqueId] = this.geometries.length;
  135776. }
  135777. this.geometries.push(newGeometry);
  135778. };
  135779. /**
  135780. * Adds the given action manager to this scene
  135781. * @param newActionManager The action manager to add
  135782. */
  135783. Scene.prototype.addActionManager = function (newActionManager) {
  135784. this.actionManagers.push(newActionManager);
  135785. };
  135786. /**
  135787. * Adds the given texture to this scene.
  135788. * @param newTexture The texture to add
  135789. */
  135790. Scene.prototype.addTexture = function (newTexture) {
  135791. this.textures.push(newTexture);
  135792. this.onNewTextureAddedObservable.notifyObservers(newTexture);
  135793. };
  135794. /**
  135795. * Switch active camera
  135796. * @param newCamera defines the new active camera
  135797. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  135798. */
  135799. Scene.prototype.switchActiveCamera = function (newCamera, attachControl) {
  135800. if (attachControl === void 0) { attachControl = true; }
  135801. var canvas = this._engine.getRenderingCanvas();
  135802. if (!canvas) {
  135803. return;
  135804. }
  135805. if (this.activeCamera) {
  135806. this.activeCamera.detachControl(canvas);
  135807. }
  135808. this.activeCamera = newCamera;
  135809. if (attachControl) {
  135810. newCamera.attachControl(canvas);
  135811. }
  135812. };
  135813. /**
  135814. * sets the active camera of the scene using its ID
  135815. * @param id defines the camera's ID
  135816. * @return the new active camera or null if none found.
  135817. */
  135818. Scene.prototype.setActiveCameraByID = function (id) {
  135819. var camera = this.getCameraByID(id);
  135820. if (camera) {
  135821. this.activeCamera = camera;
  135822. return camera;
  135823. }
  135824. return null;
  135825. };
  135826. /**
  135827. * sets the active camera of the scene using its name
  135828. * @param name defines the camera's name
  135829. * @returns the new active camera or null if none found.
  135830. */
  135831. Scene.prototype.setActiveCameraByName = function (name) {
  135832. var camera = this.getCameraByName(name);
  135833. if (camera) {
  135834. this.activeCamera = camera;
  135835. return camera;
  135836. }
  135837. return null;
  135838. };
  135839. /**
  135840. * get an animation group using its name
  135841. * @param name defines the material's name
  135842. * @return the animation group or null if none found.
  135843. */
  135844. Scene.prototype.getAnimationGroupByName = function (name) {
  135845. for (var index = 0; index < this.animationGroups.length; index++) {
  135846. if (this.animationGroups[index].name === name) {
  135847. return this.animationGroups[index];
  135848. }
  135849. }
  135850. return null;
  135851. };
  135852. /**
  135853. * Get a material using its unique id
  135854. * @param uniqueId defines the material's unique id
  135855. * @return the material or null if none found.
  135856. */
  135857. Scene.prototype.getMaterialByUniqueID = function (uniqueId) {
  135858. for (var index = 0; index < this.materials.length; index++) {
  135859. if (this.materials[index].uniqueId === uniqueId) {
  135860. return this.materials[index];
  135861. }
  135862. }
  135863. return null;
  135864. };
  135865. /**
  135866. * get a material using its id
  135867. * @param id defines the material's ID
  135868. * @return the material or null if none found.
  135869. */
  135870. Scene.prototype.getMaterialByID = function (id) {
  135871. for (var index = 0; index < this.materials.length; index++) {
  135872. if (this.materials[index].id === id) {
  135873. return this.materials[index];
  135874. }
  135875. }
  135876. return null;
  135877. };
  135878. /**
  135879. * Gets a material using its name
  135880. * @param name defines the material's name
  135881. * @return the material or null if none found.
  135882. */
  135883. Scene.prototype.getMaterialByName = function (name) {
  135884. for (var index = 0; index < this.materials.length; index++) {
  135885. if (this.materials[index].name === name) {
  135886. return this.materials[index];
  135887. }
  135888. }
  135889. return null;
  135890. };
  135891. /**
  135892. * Gets a camera using its id
  135893. * @param id defines the id to look for
  135894. * @returns the camera or null if not found
  135895. */
  135896. Scene.prototype.getCameraByID = function (id) {
  135897. for (var index = 0; index < this.cameras.length; index++) {
  135898. if (this.cameras[index].id === id) {
  135899. return this.cameras[index];
  135900. }
  135901. }
  135902. return null;
  135903. };
  135904. /**
  135905. * Gets a camera using its unique id
  135906. * @param uniqueId defines the unique id to look for
  135907. * @returns the camera or null if not found
  135908. */
  135909. Scene.prototype.getCameraByUniqueID = function (uniqueId) {
  135910. for (var index = 0; index < this.cameras.length; index++) {
  135911. if (this.cameras[index].uniqueId === uniqueId) {
  135912. return this.cameras[index];
  135913. }
  135914. }
  135915. return null;
  135916. };
  135917. /**
  135918. * Gets a camera using its name
  135919. * @param name defines the camera's name
  135920. * @return the camera or null if none found.
  135921. */
  135922. Scene.prototype.getCameraByName = function (name) {
  135923. for (var index = 0; index < this.cameras.length; index++) {
  135924. if (this.cameras[index].name === name) {
  135925. return this.cameras[index];
  135926. }
  135927. }
  135928. return null;
  135929. };
  135930. /**
  135931. * Gets a bone using its id
  135932. * @param id defines the bone's id
  135933. * @return the bone or null if not found
  135934. */
  135935. Scene.prototype.getBoneByID = function (id) {
  135936. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  135937. var skeleton = this.skeletons[skeletonIndex];
  135938. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  135939. if (skeleton.bones[boneIndex].id === id) {
  135940. return skeleton.bones[boneIndex];
  135941. }
  135942. }
  135943. }
  135944. return null;
  135945. };
  135946. /**
  135947. * Gets a bone using its id
  135948. * @param name defines the bone's name
  135949. * @return the bone or null if not found
  135950. */
  135951. Scene.prototype.getBoneByName = function (name) {
  135952. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  135953. var skeleton = this.skeletons[skeletonIndex];
  135954. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  135955. if (skeleton.bones[boneIndex].name === name) {
  135956. return skeleton.bones[boneIndex];
  135957. }
  135958. }
  135959. }
  135960. return null;
  135961. };
  135962. /**
  135963. * Gets a light node using its name
  135964. * @param name defines the the light's name
  135965. * @return the light or null if none found.
  135966. */
  135967. Scene.prototype.getLightByName = function (name) {
  135968. for (var index = 0; index < this.lights.length; index++) {
  135969. if (this.lights[index].name === name) {
  135970. return this.lights[index];
  135971. }
  135972. }
  135973. return null;
  135974. };
  135975. /**
  135976. * Gets a light node using its id
  135977. * @param id defines the light's id
  135978. * @return the light or null if none found.
  135979. */
  135980. Scene.prototype.getLightByID = function (id) {
  135981. for (var index = 0; index < this.lights.length; index++) {
  135982. if (this.lights[index].id === id) {
  135983. return this.lights[index];
  135984. }
  135985. }
  135986. return null;
  135987. };
  135988. /**
  135989. * Gets a light node using its scene-generated unique ID
  135990. * @param uniqueId defines the light's unique id
  135991. * @return the light or null if none found.
  135992. */
  135993. Scene.prototype.getLightByUniqueID = function (uniqueId) {
  135994. for (var index = 0; index < this.lights.length; index++) {
  135995. if (this.lights[index].uniqueId === uniqueId) {
  135996. return this.lights[index];
  135997. }
  135998. }
  135999. return null;
  136000. };
  136001. /**
  136002. * Gets a particle system by id
  136003. * @param id defines the particle system id
  136004. * @return the corresponding system or null if none found
  136005. */
  136006. Scene.prototype.getParticleSystemByID = function (id) {
  136007. for (var index = 0; index < this.particleSystems.length; index++) {
  136008. if (this.particleSystems[index].id === id) {
  136009. return this.particleSystems[index];
  136010. }
  136011. }
  136012. return null;
  136013. };
  136014. /**
  136015. * Gets a geometry using its ID
  136016. * @param id defines the geometry's id
  136017. * @return the geometry or null if none found.
  136018. */
  136019. Scene.prototype.getGeometryByID = function (id) {
  136020. for (var index = 0; index < this.geometries.length; index++) {
  136021. if (this.geometries[index].id === id) {
  136022. return this.geometries[index];
  136023. }
  136024. }
  136025. return null;
  136026. };
  136027. Scene.prototype._getGeometryByUniqueID = function (uniqueId) {
  136028. if (this.geometriesByUniqueId) {
  136029. var index_1 = this.geometriesByUniqueId[uniqueId];
  136030. if (index_1 !== undefined) {
  136031. return this.geometries[index_1];
  136032. }
  136033. }
  136034. else {
  136035. for (var index = 0; index < this.geometries.length; index++) {
  136036. if (this.geometries[index].uniqueId === uniqueId) {
  136037. return this.geometries[index];
  136038. }
  136039. }
  136040. }
  136041. return null;
  136042. };
  136043. /**
  136044. * Add a new geometry to this scene
  136045. * @param geometry defines the geometry to be added to the scene.
  136046. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  136047. * @return a boolean defining if the geometry was added or not
  136048. */
  136049. Scene.prototype.pushGeometry = function (geometry, force) {
  136050. if (!force && this._getGeometryByUniqueID(geometry.uniqueId)) {
  136051. return false;
  136052. }
  136053. this.addGeometry(geometry);
  136054. this.onNewGeometryAddedObservable.notifyObservers(geometry);
  136055. return true;
  136056. };
  136057. /**
  136058. * Removes an existing geometry
  136059. * @param geometry defines the geometry to be removed from the scene
  136060. * @return a boolean defining if the geometry was removed or not
  136061. */
  136062. Scene.prototype.removeGeometry = function (geometry) {
  136063. var index;
  136064. if (this.geometriesByUniqueId) {
  136065. index = this.geometriesByUniqueId[geometry.uniqueId];
  136066. if (index === undefined) {
  136067. return false;
  136068. }
  136069. }
  136070. else {
  136071. index = this.geometries.indexOf(geometry);
  136072. if (index < 0) {
  136073. return false;
  136074. }
  136075. }
  136076. if (index !== this.geometries.length - 1) {
  136077. var lastGeometry = this.geometries[this.geometries.length - 1];
  136078. this.geometries[index] = lastGeometry;
  136079. if (this.geometriesByUniqueId) {
  136080. this.geometriesByUniqueId[lastGeometry.uniqueId] = index;
  136081. this.geometriesByUniqueId[geometry.uniqueId] = undefined;
  136082. }
  136083. }
  136084. this.geometries.pop();
  136085. this.onGeometryRemovedObservable.notifyObservers(geometry);
  136086. return true;
  136087. };
  136088. /**
  136089. * Gets the list of geometries attached to the scene
  136090. * @returns an array of Geometry
  136091. */
  136092. Scene.prototype.getGeometries = function () {
  136093. return this.geometries;
  136094. };
  136095. /**
  136096. * Gets the first added mesh found of a given ID
  136097. * @param id defines the id to search for
  136098. * @return the mesh found or null if not found at all
  136099. */
  136100. Scene.prototype.getMeshByID = function (id) {
  136101. for (var index = 0; index < this.meshes.length; index++) {
  136102. if (this.meshes[index].id === id) {
  136103. return this.meshes[index];
  136104. }
  136105. }
  136106. return null;
  136107. };
  136108. /**
  136109. * Gets a list of meshes using their id
  136110. * @param id defines the id to search for
  136111. * @returns a list of meshes
  136112. */
  136113. Scene.prototype.getMeshesByID = function (id) {
  136114. return this.meshes.filter(function (m) {
  136115. return m.id === id;
  136116. });
  136117. };
  136118. /**
  136119. * Gets the first added transform node found of a given ID
  136120. * @param id defines the id to search for
  136121. * @return the found transform node or null if not found at all.
  136122. */
  136123. Scene.prototype.getTransformNodeByID = function (id) {
  136124. for (var index = 0; index < this.transformNodes.length; index++) {
  136125. if (this.transformNodes[index].id === id) {
  136126. return this.transformNodes[index];
  136127. }
  136128. }
  136129. return null;
  136130. };
  136131. /**
  136132. * Gets a transform node with its auto-generated unique id
  136133. * @param uniqueId efines the unique id to search for
  136134. * @return the found transform node or null if not found at all.
  136135. */
  136136. Scene.prototype.getTransformNodeByUniqueID = function (uniqueId) {
  136137. for (var index = 0; index < this.transformNodes.length; index++) {
  136138. if (this.transformNodes[index].uniqueId === uniqueId) {
  136139. return this.transformNodes[index];
  136140. }
  136141. }
  136142. return null;
  136143. };
  136144. /**
  136145. * Gets a list of transform nodes using their id
  136146. * @param id defines the id to search for
  136147. * @returns a list of transform nodes
  136148. */
  136149. Scene.prototype.getTransformNodesByID = function (id) {
  136150. return this.transformNodes.filter(function (m) {
  136151. return m.id === id;
  136152. });
  136153. };
  136154. /**
  136155. * Gets a mesh with its auto-generated unique id
  136156. * @param uniqueId defines the unique id to search for
  136157. * @return the found mesh or null if not found at all.
  136158. */
  136159. Scene.prototype.getMeshByUniqueID = function (uniqueId) {
  136160. for (var index = 0; index < this.meshes.length; index++) {
  136161. if (this.meshes[index].uniqueId === uniqueId) {
  136162. return this.meshes[index];
  136163. }
  136164. }
  136165. return null;
  136166. };
  136167. /**
  136168. * Gets a the last added mesh using a given id
  136169. * @param id defines the id to search for
  136170. * @return the found mesh or null if not found at all.
  136171. */
  136172. Scene.prototype.getLastMeshByID = function (id) {
  136173. for (var index = this.meshes.length - 1; index >= 0; index--) {
  136174. if (this.meshes[index].id === id) {
  136175. return this.meshes[index];
  136176. }
  136177. }
  136178. return null;
  136179. };
  136180. /**
  136181. * Gets a the last added node (Mesh, Camera, Light) using a given id
  136182. * @param id defines the id to search for
  136183. * @return the found node or null if not found at all
  136184. */
  136185. Scene.prototype.getLastEntryByID = function (id) {
  136186. var index;
  136187. for (index = this.meshes.length - 1; index >= 0; index--) {
  136188. if (this.meshes[index].id === id) {
  136189. return this.meshes[index];
  136190. }
  136191. }
  136192. for (index = this.transformNodes.length - 1; index >= 0; index--) {
  136193. if (this.transformNodes[index].id === id) {
  136194. return this.transformNodes[index];
  136195. }
  136196. }
  136197. for (index = this.cameras.length - 1; index >= 0; index--) {
  136198. if (this.cameras[index].id === id) {
  136199. return this.cameras[index];
  136200. }
  136201. }
  136202. for (index = this.lights.length - 1; index >= 0; index--) {
  136203. if (this.lights[index].id === id) {
  136204. return this.lights[index];
  136205. }
  136206. }
  136207. return null;
  136208. };
  136209. /**
  136210. * Gets a node (Mesh, Camera, Light) using a given id
  136211. * @param id defines the id to search for
  136212. * @return the found node or null if not found at all
  136213. */
  136214. Scene.prototype.getNodeByID = function (id) {
  136215. var mesh = this.getMeshByID(id);
  136216. if (mesh) {
  136217. return mesh;
  136218. }
  136219. var transformNode = this.getTransformNodeByID(id);
  136220. if (transformNode) {
  136221. return transformNode;
  136222. }
  136223. var light = this.getLightByID(id);
  136224. if (light) {
  136225. return light;
  136226. }
  136227. var camera = this.getCameraByID(id);
  136228. if (camera) {
  136229. return camera;
  136230. }
  136231. var bone = this.getBoneByID(id);
  136232. if (bone) {
  136233. return bone;
  136234. }
  136235. return null;
  136236. };
  136237. /**
  136238. * Gets a node (Mesh, Camera, Light) using a given name
  136239. * @param name defines the name to search for
  136240. * @return the found node or null if not found at all.
  136241. */
  136242. Scene.prototype.getNodeByName = function (name) {
  136243. var mesh = this.getMeshByName(name);
  136244. if (mesh) {
  136245. return mesh;
  136246. }
  136247. var transformNode = this.getTransformNodeByName(name);
  136248. if (transformNode) {
  136249. return transformNode;
  136250. }
  136251. var light = this.getLightByName(name);
  136252. if (light) {
  136253. return light;
  136254. }
  136255. var camera = this.getCameraByName(name);
  136256. if (camera) {
  136257. return camera;
  136258. }
  136259. var bone = this.getBoneByName(name);
  136260. if (bone) {
  136261. return bone;
  136262. }
  136263. return null;
  136264. };
  136265. /**
  136266. * Gets a mesh using a given name
  136267. * @param name defines the name to search for
  136268. * @return the found mesh or null if not found at all.
  136269. */
  136270. Scene.prototype.getMeshByName = function (name) {
  136271. for (var index = 0; index < this.meshes.length; index++) {
  136272. if (this.meshes[index].name === name) {
  136273. return this.meshes[index];
  136274. }
  136275. }
  136276. return null;
  136277. };
  136278. /**
  136279. * Gets a transform node using a given name
  136280. * @param name defines the name to search for
  136281. * @return the found transform node or null if not found at all.
  136282. */
  136283. Scene.prototype.getTransformNodeByName = function (name) {
  136284. for (var index = 0; index < this.transformNodes.length; index++) {
  136285. if (this.transformNodes[index].name === name) {
  136286. return this.transformNodes[index];
  136287. }
  136288. }
  136289. return null;
  136290. };
  136291. /**
  136292. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  136293. * @param id defines the id to search for
  136294. * @return the found skeleton or null if not found at all.
  136295. */
  136296. Scene.prototype.getLastSkeletonByID = function (id) {
  136297. for (var index = this.skeletons.length - 1; index >= 0; index--) {
  136298. if (this.skeletons[index].id === id) {
  136299. return this.skeletons[index];
  136300. }
  136301. }
  136302. return null;
  136303. };
  136304. /**
  136305. * Gets a skeleton using a given auto generated unique id
  136306. * @param uniqueId defines the unique id to search for
  136307. * @return the found skeleton or null if not found at all.
  136308. */
  136309. Scene.prototype.getSkeletonByUniqueId = function (uniqueId) {
  136310. for (var index = 0; index < this.skeletons.length; index++) {
  136311. if (this.skeletons[index].uniqueId === uniqueId) {
  136312. return this.skeletons[index];
  136313. }
  136314. }
  136315. return null;
  136316. };
  136317. /**
  136318. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  136319. * @param id defines the id to search for
  136320. * @return the found skeleton or null if not found at all.
  136321. */
  136322. Scene.prototype.getSkeletonById = function (id) {
  136323. for (var index = 0; index < this.skeletons.length; index++) {
  136324. if (this.skeletons[index].id === id) {
  136325. return this.skeletons[index];
  136326. }
  136327. }
  136328. return null;
  136329. };
  136330. /**
  136331. * Gets a skeleton using a given name
  136332. * @param name defines the name to search for
  136333. * @return the found skeleton or null if not found at all.
  136334. */
  136335. Scene.prototype.getSkeletonByName = function (name) {
  136336. for (var index = 0; index < this.skeletons.length; index++) {
  136337. if (this.skeletons[index].name === name) {
  136338. return this.skeletons[index];
  136339. }
  136340. }
  136341. return null;
  136342. };
  136343. /**
  136344. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  136345. * @param id defines the id to search for
  136346. * @return the found morph target manager or null if not found at all.
  136347. */
  136348. Scene.prototype.getMorphTargetManagerById = function (id) {
  136349. for (var index = 0; index < this.morphTargetManagers.length; index++) {
  136350. if (this.morphTargetManagers[index].uniqueId === id) {
  136351. return this.morphTargetManagers[index];
  136352. }
  136353. }
  136354. return null;
  136355. };
  136356. /**
  136357. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  136358. * @param id defines the id to search for
  136359. * @return the found morph target or null if not found at all.
  136360. */
  136361. Scene.prototype.getMorphTargetById = function (id) {
  136362. for (var managerIndex = 0; managerIndex < this.morphTargetManagers.length; ++managerIndex) {
  136363. var morphTargetManager = this.morphTargetManagers[managerIndex];
  136364. for (var index = 0; index < morphTargetManager.numTargets; ++index) {
  136365. var target = morphTargetManager.getTarget(index);
  136366. if (target.id === id) {
  136367. return target;
  136368. }
  136369. }
  136370. }
  136371. return null;
  136372. };
  136373. /**
  136374. * Gets a boolean indicating if the given mesh is active
  136375. * @param mesh defines the mesh to look for
  136376. * @returns true if the mesh is in the active list
  136377. */
  136378. Scene.prototype.isActiveMesh = function (mesh) {
  136379. return (this._activeMeshes.indexOf(mesh) !== -1);
  136380. };
  136381. Object.defineProperty(Scene.prototype, "uid", {
  136382. /**
  136383. * Return a unique id as a string which can serve as an identifier for the scene
  136384. */
  136385. get: function () {
  136386. if (!this._uid) {
  136387. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].RandomId();
  136388. }
  136389. return this._uid;
  136390. },
  136391. enumerable: true,
  136392. configurable: true
  136393. });
  136394. /**
  136395. * Add an externaly attached data from its key.
  136396. * This method call will fail and return false, if such key already exists.
  136397. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  136398. * @param key the unique key that identifies the data
  136399. * @param data the data object to associate to the key for this Engine instance
  136400. * @return true if no such key were already present and the data was added successfully, false otherwise
  136401. */
  136402. Scene.prototype.addExternalData = function (key, data) {
  136403. if (!this._externalData) {
  136404. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  136405. }
  136406. return this._externalData.add(key, data);
  136407. };
  136408. /**
  136409. * Get an externaly attached data from its key
  136410. * @param key the unique key that identifies the data
  136411. * @return the associated data, if present (can be null), or undefined if not present
  136412. */
  136413. Scene.prototype.getExternalData = function (key) {
  136414. if (!this._externalData) {
  136415. return null;
  136416. }
  136417. return this._externalData.get(key);
  136418. };
  136419. /**
  136420. * Get an externaly attached data from its key, create it using a factory if it's not already present
  136421. * @param key the unique key that identifies the data
  136422. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  136423. * @return the associated data, can be null if the factory returned null.
  136424. */
  136425. Scene.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  136426. if (!this._externalData) {
  136427. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  136428. }
  136429. return this._externalData.getOrAddWithFactory(key, factory);
  136430. };
  136431. /**
  136432. * Remove an externaly attached data from the Engine instance
  136433. * @param key the unique key that identifies the data
  136434. * @return true if the data was successfully removed, false if it doesn't exist
  136435. */
  136436. Scene.prototype.removeExternalData = function (key) {
  136437. return this._externalData.remove(key);
  136438. };
  136439. Scene.prototype._evaluateSubMesh = function (subMesh, mesh) {
  136440. if (this.dispatchAllSubMeshesOfActiveMeshes || mesh.alwaysSelectAsActiveMesh || mesh.subMeshes.length === 1 || subMesh.isInFrustum(this._frustumPlanes)) {
  136441. for (var _i = 0, _a = this._evaluateSubMeshStage; _i < _a.length; _i++) {
  136442. var step = _a[_i];
  136443. step.action(mesh, subMesh);
  136444. }
  136445. var material = subMesh.getMaterial();
  136446. if (material !== null && material !== undefined) {
  136447. // Render targets
  136448. if (material.hasRenderTargetTextures && material.getRenderTargetTextures !== undefined) {
  136449. if (this._processedMaterials.indexOf(material) === -1) {
  136450. this._processedMaterials.push(material);
  136451. this._renderTargets.concatWithNoDuplicate(material.getRenderTargetTextures());
  136452. }
  136453. }
  136454. // Dispatch
  136455. this._activeIndices.addCount(subMesh.indexCount, false);
  136456. this._renderingManager.dispatch(subMesh, mesh, material);
  136457. }
  136458. }
  136459. };
  136460. /**
  136461. * Clear the processed materials smart array preventing retention point in material dispose.
  136462. */
  136463. Scene.prototype.freeProcessedMaterials = function () {
  136464. this._processedMaterials.dispose();
  136465. };
  136466. Object.defineProperty(Scene.prototype, "blockfreeActiveMeshesAndRenderingGroups", {
  136467. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  136468. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  136469. * when disposing several meshes in a row or a hierarchy of meshes.
  136470. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  136471. */
  136472. get: function () {
  136473. return this._preventFreeActiveMeshesAndRenderingGroups;
  136474. },
  136475. set: function (value) {
  136476. if (this._preventFreeActiveMeshesAndRenderingGroups === value) {
  136477. return;
  136478. }
  136479. if (value) {
  136480. this.freeActiveMeshes();
  136481. this.freeRenderingGroups();
  136482. }
  136483. this._preventFreeActiveMeshesAndRenderingGroups = value;
  136484. },
  136485. enumerable: true,
  136486. configurable: true
  136487. });
  136488. /**
  136489. * Clear the active meshes smart array preventing retention point in mesh dispose.
  136490. */
  136491. Scene.prototype.freeActiveMeshes = function () {
  136492. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  136493. return;
  136494. }
  136495. this._activeMeshes.dispose();
  136496. if (this.activeCamera && this.activeCamera._activeMeshes) {
  136497. this.activeCamera._activeMeshes.dispose();
  136498. }
  136499. if (this.activeCameras) {
  136500. for (var i = 0; i < this.activeCameras.length; i++) {
  136501. var activeCamera = this.activeCameras[i];
  136502. if (activeCamera && activeCamera._activeMeshes) {
  136503. activeCamera._activeMeshes.dispose();
  136504. }
  136505. }
  136506. }
  136507. };
  136508. /**
  136509. * Clear the info related to rendering groups preventing retention points during dispose.
  136510. */
  136511. Scene.prototype.freeRenderingGroups = function () {
  136512. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  136513. return;
  136514. }
  136515. if (this._renderingManager) {
  136516. this._renderingManager.freeRenderingGroups();
  136517. }
  136518. if (this.textures) {
  136519. for (var i = 0; i < this.textures.length; i++) {
  136520. var texture = this.textures[i];
  136521. if (texture && texture.renderList) {
  136522. texture.freeRenderingGroups();
  136523. }
  136524. }
  136525. }
  136526. };
  136527. /** @hidden */
  136528. Scene.prototype._isInIntermediateRendering = function () {
  136529. return this._intermediateRendering;
  136530. };
  136531. /**
  136532. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  136533. * @returns the current scene
  136534. */
  136535. Scene.prototype.freezeActiveMeshes = function () {
  136536. if (!this.activeCamera) {
  136537. return this;
  136538. }
  136539. if (!this._frustumPlanes) {
  136540. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  136541. }
  136542. this._evaluateActiveMeshes();
  136543. this._activeMeshesFrozen = true;
  136544. return this;
  136545. };
  136546. /**
  136547. * Use this function to restart evaluating active meshes on every frame
  136548. * @returns the current scene
  136549. */
  136550. Scene.prototype.unfreezeActiveMeshes = function () {
  136551. this._activeMeshesFrozen = false;
  136552. return this;
  136553. };
  136554. Scene.prototype._evaluateActiveMeshes = function () {
  136555. if (this._activeMeshesFrozen && this._activeMeshes.length) {
  136556. return;
  136557. }
  136558. if (!this.activeCamera) {
  136559. return;
  136560. }
  136561. this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this);
  136562. this.activeCamera._activeMeshes.reset();
  136563. this._activeMeshes.reset();
  136564. this._renderingManager.reset();
  136565. this._processedMaterials.reset();
  136566. this._activeParticleSystems.reset();
  136567. this._activeSkeletons.reset();
  136568. this._softwareSkinnedMeshes.reset();
  136569. for (var _i = 0, _a = this._beforeEvaluateActiveMeshStage; _i < _a.length; _i++) {
  136570. var step = _a[_i];
  136571. step.action();
  136572. }
  136573. // Determine mesh candidates
  136574. var meshes = this.getActiveMeshCandidates();
  136575. // Check each mesh
  136576. var len = meshes.length;
  136577. for (var i = 0; i < len; i++) {
  136578. var mesh = meshes.data[i];
  136579. if (mesh.isBlocked) {
  136580. continue;
  136581. }
  136582. this._totalVertices.addCount(mesh.getTotalVertices(), false);
  136583. if (!mesh.isReady() || !mesh.isEnabled()) {
  136584. continue;
  136585. }
  136586. mesh.computeWorldMatrix();
  136587. // Intersections
  136588. if (mesh.actionManager && mesh.actionManager.hasSpecificTriggers2(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger, _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger)) {
  136589. this._meshesForIntersections.pushNoDuplicate(mesh);
  136590. }
  136591. // Switch to current LOD
  136592. var meshLOD = this.customLODSelector ? this.customLODSelector(mesh, this.activeCamera) : mesh.getLOD(this.activeCamera);
  136593. if (meshLOD === undefined || meshLOD === null) {
  136594. continue;
  136595. }
  136596. mesh._preActivate();
  136597. if (mesh.isVisible && mesh.visibility > 0 && ((mesh.layerMask & this.activeCamera.layerMask) !== 0) && (mesh.alwaysSelectAsActiveMesh || mesh.isInFrustum(this._frustumPlanes))) {
  136598. this._activeMeshes.push(mesh);
  136599. this.activeCamera._activeMeshes.push(mesh);
  136600. mesh._activate(this._renderId);
  136601. if (meshLOD !== mesh) {
  136602. meshLOD._activate(this._renderId);
  136603. }
  136604. this._activeMesh(mesh, meshLOD);
  136605. }
  136606. }
  136607. this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this);
  136608. // Particle systems
  136609. if (this.particlesEnabled) {
  136610. this.onBeforeParticlesRenderingObservable.notifyObservers(this);
  136611. for (var particleIndex = 0; particleIndex < this.particleSystems.length; particleIndex++) {
  136612. var particleSystem = this.particleSystems[particleIndex];
  136613. if (!particleSystem.isStarted() || !particleSystem.emitter) {
  136614. continue;
  136615. }
  136616. var emitter = particleSystem.emitter;
  136617. if (!emitter.position || emitter.isEnabled()) {
  136618. this._activeParticleSystems.push(particleSystem);
  136619. particleSystem.animate();
  136620. this._renderingManager.dispatchParticles(particleSystem);
  136621. }
  136622. }
  136623. this.onAfterParticlesRenderingObservable.notifyObservers(this);
  136624. }
  136625. };
  136626. Scene.prototype._activeMesh = function (sourceMesh, mesh) {
  136627. if (this._skeletonsEnabled && mesh.skeleton !== null && mesh.skeleton !== undefined) {
  136628. if (this._activeSkeletons.pushNoDuplicate(mesh.skeleton)) {
  136629. mesh.skeleton.prepare();
  136630. }
  136631. if (!mesh.computeBonesUsingShaders) {
  136632. this._softwareSkinnedMeshes.pushNoDuplicate(mesh);
  136633. }
  136634. }
  136635. for (var _i = 0, _a = this._activeMeshStage; _i < _a.length; _i++) {
  136636. var step = _a[_i];
  136637. step.action(sourceMesh, mesh);
  136638. }
  136639. if (mesh !== undefined && mesh !== null
  136640. && mesh.subMeshes !== undefined && mesh.subMeshes !== null && mesh.subMeshes.length > 0) {
  136641. var subMeshes = this.getActiveSubMeshCandidates(mesh);
  136642. var len = subMeshes.length;
  136643. for (var i = 0; i < len; i++) {
  136644. var subMesh = subMeshes.data[i];
  136645. this._evaluateSubMesh(subMesh, mesh);
  136646. }
  136647. }
  136648. };
  136649. /**
  136650. * Update the transform matrix to update from the current active camera
  136651. * @param force defines a boolean used to force the update even if cache is up to date
  136652. */
  136653. Scene.prototype.updateTransformMatrix = function (force) {
  136654. if (!this.activeCamera) {
  136655. return;
  136656. }
  136657. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(force));
  136658. };
  136659. Scene.prototype._bindFrameBuffer = function () {
  136660. if (this.activeCamera && this.activeCamera._multiviewTexture) {
  136661. this.activeCamera._multiviewTexture._bindFrameBuffer();
  136662. }
  136663. else if (this.activeCamera && this.activeCamera.outputRenderTarget) {
  136664. var useMultiview = this.getEngine().getCaps().multiview && this.activeCamera.outputRenderTarget && this.activeCamera.outputRenderTarget.getViewCount() > 1;
  136665. if (useMultiview) {
  136666. this.activeCamera.outputRenderTarget._bindFrameBuffer();
  136667. }
  136668. else {
  136669. var internalTexture = this.activeCamera.outputRenderTarget.getInternalTexture();
  136670. if (internalTexture) {
  136671. this.getEngine().bindFramebuffer(internalTexture);
  136672. }
  136673. else {
  136674. _Misc_logger__WEBPACK_IMPORTED_MODULE_23__["Logger"].Error("Camera contains invalid customDefaultRenderTarget");
  136675. }
  136676. }
  136677. }
  136678. else {
  136679. this.getEngine().restoreDefaultFramebuffer(); // Restore back buffer if needed
  136680. }
  136681. };
  136682. /** @hidden */
  136683. Scene.prototype._renderForCamera = function (camera, rigParent) {
  136684. if (camera && camera._skipRendering) {
  136685. return;
  136686. }
  136687. var engine = this._engine;
  136688. // Use _activeCamera instead of activeCamera to avoid onActiveCameraChanged
  136689. this._activeCamera = camera;
  136690. if (!this.activeCamera) {
  136691. throw new Error("Active camera not set");
  136692. }
  136693. // Viewport
  136694. engine.setViewport(this.activeCamera.viewport);
  136695. // Camera
  136696. this.resetCachedMaterial();
  136697. this._renderId++;
  136698. var useMultiview = this.getEngine().getCaps().multiview && camera.outputRenderTarget && camera.outputRenderTarget.getViewCount() > 1;
  136699. if (useMultiview) {
  136700. this.setTransformMatrix(camera._rigCameras[0].getViewMatrix(), camera._rigCameras[0].getProjectionMatrix(), camera._rigCameras[1].getViewMatrix(), camera._rigCameras[1].getProjectionMatrix());
  136701. }
  136702. else {
  136703. this.updateTransformMatrix();
  136704. }
  136705. this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera);
  136706. // Meshes
  136707. this._evaluateActiveMeshes();
  136708. // Software skinning
  136709. for (var softwareSkinnedMeshIndex = 0; softwareSkinnedMeshIndex < this._softwareSkinnedMeshes.length; softwareSkinnedMeshIndex++) {
  136710. var mesh = this._softwareSkinnedMeshes.data[softwareSkinnedMeshIndex];
  136711. mesh.applySkeleton(mesh.skeleton);
  136712. }
  136713. // Render targets
  136714. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  136715. if (camera.customRenderTargets && camera.customRenderTargets.length > 0) {
  136716. this._renderTargets.concatWithNoDuplicate(camera.customRenderTargets);
  136717. }
  136718. if (rigParent && rigParent.customRenderTargets && rigParent.customRenderTargets.length > 0) {
  136719. this._renderTargets.concatWithNoDuplicate(rigParent.customRenderTargets);
  136720. }
  136721. // Collects render targets from external components.
  136722. for (var _i = 0, _a = this._gatherActiveCameraRenderTargetsStage; _i < _a.length; _i++) {
  136723. var step = _a[_i];
  136724. step.action(this._renderTargets);
  136725. }
  136726. if (this.renderTargetsEnabled) {
  136727. this._intermediateRendering = true;
  136728. if (this._renderTargets.length > 0) {
  136729. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
  136730. for (var renderIndex = 0; renderIndex < this._renderTargets.length; renderIndex++) {
  136731. var renderTarget = this._renderTargets.data[renderIndex];
  136732. if (renderTarget._shouldRender()) {
  136733. this._renderId++;
  136734. var hasSpecialRenderTargetCamera = renderTarget.activeCamera && renderTarget.activeCamera !== this.activeCamera;
  136735. renderTarget.render(hasSpecialRenderTargetCamera, this.dumpNextRenderTargets);
  136736. }
  136737. }
  136738. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Render targets", this._renderTargets.length > 0);
  136739. this._renderId++;
  136740. }
  136741. for (var _b = 0, _c = this._cameraDrawRenderTargetStage; _b < _c.length; _b++) {
  136742. var step = _c[_b];
  136743. step.action(this.activeCamera);
  136744. }
  136745. this._intermediateRendering = false;
  136746. // Restore framebuffer after rendering to targets
  136747. this._bindFrameBuffer();
  136748. }
  136749. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  136750. // Prepare Frame
  136751. if (this.postProcessManager && !camera._multiviewTexture) {
  136752. this.postProcessManager._prepareFrame();
  136753. }
  136754. // Before Camera Draw
  136755. for (var _d = 0, _e = this._beforeCameraDrawStage; _d < _e.length; _d++) {
  136756. var step = _e[_d];
  136757. step.action(this.activeCamera);
  136758. }
  136759. // Render
  136760. this.onBeforeDrawPhaseObservable.notifyObservers(this);
  136761. this._renderingManager.render(null, null, true, true);
  136762. this.onAfterDrawPhaseObservable.notifyObservers(this);
  136763. // After Camera Draw
  136764. for (var _f = 0, _g = this._afterCameraDrawStage; _f < _g.length; _f++) {
  136765. var step = _g[_f];
  136766. step.action(this.activeCamera);
  136767. }
  136768. // Finalize frame
  136769. if (this.postProcessManager && !camera._multiviewTexture) {
  136770. this.postProcessManager._finalizeFrame(camera.isIntermediate);
  136771. }
  136772. // Reset some special arrays
  136773. this._renderTargets.reset();
  136774. this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera);
  136775. };
  136776. Scene.prototype._processSubCameras = function (camera) {
  136777. if (camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE || (camera.outputRenderTarget && camera.outputRenderTarget.getViewCount() > 1 && this.getEngine().getCaps().multiview)) {
  136778. this._renderForCamera(camera);
  136779. return;
  136780. }
  136781. if (camera._useMultiviewToSingleView) {
  136782. this._renderMultiviewToSingleView(camera);
  136783. }
  136784. else {
  136785. // rig cameras
  136786. for (var index = 0; index < camera._rigCameras.length; index++) {
  136787. this._renderForCamera(camera._rigCameras[index], camera);
  136788. }
  136789. }
  136790. // Use _activeCamera instead of activeCamera to avoid onActiveCameraChanged
  136791. this._activeCamera = camera;
  136792. this.setTransformMatrix(this._activeCamera.getViewMatrix(), this._activeCamera.getProjectionMatrix());
  136793. };
  136794. Scene.prototype._checkIntersections = function () {
  136795. for (var index = 0; index < this._meshesForIntersections.length; index++) {
  136796. var sourceMesh = this._meshesForIntersections.data[index];
  136797. if (!sourceMesh.actionManager) {
  136798. continue;
  136799. }
  136800. for (var actionIndex = 0; sourceMesh.actionManager && actionIndex < sourceMesh.actionManager.actions.length; actionIndex++) {
  136801. var action = sourceMesh.actionManager.actions[actionIndex];
  136802. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  136803. var parameters = action.getTriggerParameter();
  136804. var otherMesh = parameters instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameters : parameters.mesh;
  136805. var areIntersecting = otherMesh.intersectsMesh(sourceMesh, parameters.usePreciseIntersection);
  136806. var currentIntersectionInProgress = sourceMesh._intersectionsInProgress.indexOf(otherMesh);
  136807. if (areIntersecting && currentIntersectionInProgress === -1) {
  136808. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger) {
  136809. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  136810. sourceMesh._intersectionsInProgress.push(otherMesh);
  136811. }
  136812. else if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  136813. sourceMesh._intersectionsInProgress.push(otherMesh);
  136814. }
  136815. }
  136816. else if (!areIntersecting && currentIntersectionInProgress > -1) {
  136817. //They intersected, and now they don't.
  136818. //is this trigger an exit trigger? execute an event.
  136819. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  136820. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  136821. }
  136822. //if this is an exit trigger, or no exit trigger exists, remove the id from the intersection in progress array.
  136823. if (!sourceMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger, function (parameter) {
  136824. var parameterMesh = parameter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameter : parameter.mesh;
  136825. return otherMesh === parameterMesh;
  136826. }) || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  136827. sourceMesh._intersectionsInProgress.splice(currentIntersectionInProgress, 1);
  136828. }
  136829. }
  136830. }
  136831. }
  136832. }
  136833. };
  136834. /** @hidden */
  136835. Scene.prototype._advancePhysicsEngineStep = function (step) {
  136836. // Do nothing. Code will be replaced if physics engine component is referenced
  136837. };
  136838. /** @hidden */
  136839. Scene.prototype._animate = function () {
  136840. // Nothing to do as long as Animatable have not been imported.
  136841. };
  136842. /**
  136843. * Render the scene
  136844. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  136845. */
  136846. Scene.prototype.render = function (updateCameras) {
  136847. if (updateCameras === void 0) { updateCameras = true; }
  136848. if (this.isDisposed) {
  136849. return;
  136850. }
  136851. this._frameId++;
  136852. // Register components that have been associated lately to the scene.
  136853. this._registerTransientComponents();
  136854. this._activeParticles.fetchNewFrame();
  136855. this._totalVertices.fetchNewFrame();
  136856. this._activeIndices.fetchNewFrame();
  136857. this._activeBones.fetchNewFrame();
  136858. this._meshesForIntersections.reset();
  136859. this.resetCachedMaterial();
  136860. this.onBeforeAnimationsObservable.notifyObservers(this);
  136861. // Actions
  136862. if (this.actionManager) {
  136863. this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnEveryFrameTrigger);
  136864. }
  136865. if (this._engine.isDeterministicLockStep()) {
  136866. var deltaTime = Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime)) + this._timeAccumulator;
  136867. var defaultFPS = (60.0 / 1000.0);
  136868. var defaultFrameTime = this.getDeterministicFrameTime();
  136869. var stepsTaken = 0;
  136870. var maxSubSteps = this._engine.getLockstepMaxSteps();
  136871. var internalSteps = Math.floor(deltaTime / (1000 * defaultFPS));
  136872. internalSteps = Math.min(internalSteps, maxSubSteps);
  136873. do {
  136874. this.onBeforeStepObservable.notifyObservers(this);
  136875. // Animations
  136876. this._animationRatio = defaultFrameTime * defaultFPS;
  136877. this._animate();
  136878. this.onAfterAnimationsObservable.notifyObservers(this);
  136879. // Physics
  136880. this._advancePhysicsEngineStep(defaultFrameTime);
  136881. this.onAfterStepObservable.notifyObservers(this);
  136882. this._currentStepId++;
  136883. stepsTaken++;
  136884. deltaTime -= defaultFrameTime;
  136885. } while (deltaTime > 0 && stepsTaken < internalSteps);
  136886. this._timeAccumulator = deltaTime < 0 ? 0 : deltaTime;
  136887. }
  136888. else {
  136889. // Animations
  136890. var deltaTime = this.useConstantAnimationDeltaTime ? 16 : Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime));
  136891. this._animationRatio = deltaTime * (60.0 / 1000.0);
  136892. this._animate();
  136893. this.onAfterAnimationsObservable.notifyObservers(this);
  136894. // Physics
  136895. this._advancePhysicsEngineStep(deltaTime);
  136896. }
  136897. // Before camera update steps
  136898. for (var _i = 0, _a = this._beforeCameraUpdateStage; _i < _a.length; _i++) {
  136899. var step = _a[_i];
  136900. step.action();
  136901. }
  136902. // Update Cameras
  136903. if (updateCameras) {
  136904. if (this.activeCameras.length > 0) {
  136905. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  136906. var camera = this.activeCameras[cameraIndex];
  136907. camera.update();
  136908. if (camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  136909. // rig cameras
  136910. for (var index = 0; index < camera._rigCameras.length; index++) {
  136911. camera._rigCameras[index].update();
  136912. }
  136913. }
  136914. }
  136915. }
  136916. else if (this.activeCamera) {
  136917. this.activeCamera.update();
  136918. if (this.activeCamera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  136919. // rig cameras
  136920. for (var index = 0; index < this.activeCamera._rigCameras.length; index++) {
  136921. this.activeCamera._rigCameras[index].update();
  136922. }
  136923. }
  136924. }
  136925. }
  136926. // Before render
  136927. this.onBeforeRenderObservable.notifyObservers(this);
  136928. // Customs render targets
  136929. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  136930. var engine = this.getEngine();
  136931. var currentActiveCamera = this.activeCamera;
  136932. if (this.renderTargetsEnabled) {
  136933. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  136934. this._intermediateRendering = true;
  136935. for (var customIndex = 0; customIndex < this.customRenderTargets.length; customIndex++) {
  136936. var renderTarget = this.customRenderTargets[customIndex];
  136937. if (renderTarget._shouldRender()) {
  136938. this._renderId++;
  136939. this.activeCamera = renderTarget.activeCamera || this.activeCamera;
  136940. if (!this.activeCamera) {
  136941. throw new Error("Active camera not set");
  136942. }
  136943. // Viewport
  136944. engine.setViewport(this.activeCamera.viewport);
  136945. // Camera
  136946. this.updateTransformMatrix();
  136947. renderTarget.render(currentActiveCamera !== this.activeCamera, this.dumpNextRenderTargets);
  136948. }
  136949. }
  136950. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  136951. this._intermediateRendering = false;
  136952. this._renderId++;
  136953. }
  136954. // Restore back buffer
  136955. this.activeCamera = currentActiveCamera;
  136956. this._bindFrameBuffer();
  136957. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  136958. for (var _b = 0, _c = this._beforeClearStage; _b < _c.length; _b++) {
  136959. var step = _c[_b];
  136960. step.action();
  136961. }
  136962. // Clear
  136963. if (this.autoClearDepthAndStencil || this.autoClear) {
  136964. this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil);
  136965. }
  136966. // Collects render targets from external components.
  136967. for (var _d = 0, _e = this._gatherRenderTargetsStage; _d < _e.length; _d++) {
  136968. var step = _e[_d];
  136969. step.action(this._renderTargets);
  136970. }
  136971. // Multi-cameras?
  136972. if (this.activeCameras.length > 0) {
  136973. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  136974. if (cameraIndex > 0) {
  136975. this._engine.clear(null, false, true, true);
  136976. }
  136977. this._processSubCameras(this.activeCameras[cameraIndex]);
  136978. }
  136979. }
  136980. else {
  136981. if (!this.activeCamera) {
  136982. throw new Error("No camera defined");
  136983. }
  136984. this._processSubCameras(this.activeCamera);
  136985. }
  136986. // Intersection checks
  136987. this._checkIntersections();
  136988. // Executes the after render stage actions.
  136989. for (var _f = 0, _g = this._afterRenderStage; _f < _g.length; _f++) {
  136990. var step = _g[_f];
  136991. step.action();
  136992. }
  136993. // After render
  136994. if (this.afterRender) {
  136995. this.afterRender();
  136996. }
  136997. this.onAfterRenderObservable.notifyObservers(this);
  136998. // Cleaning
  136999. if (this._toBeDisposed.length) {
  137000. for (var index = 0; index < this._toBeDisposed.length; index++) {
  137001. var data = this._toBeDisposed[index];
  137002. if (data) {
  137003. data.dispose();
  137004. }
  137005. }
  137006. this._toBeDisposed = [];
  137007. }
  137008. if (this.dumpNextRenderTargets) {
  137009. this.dumpNextRenderTargets = false;
  137010. }
  137011. this._activeBones.addCount(0, true);
  137012. this._activeIndices.addCount(0, true);
  137013. this._activeParticles.addCount(0, true);
  137014. };
  137015. /**
  137016. * Freeze all materials
  137017. * A frozen material will not be updatable but should be faster to render
  137018. */
  137019. Scene.prototype.freezeMaterials = function () {
  137020. for (var i = 0; i < this.materials.length; i++) {
  137021. this.materials[i].freeze();
  137022. }
  137023. };
  137024. /**
  137025. * Unfreeze all materials
  137026. * A frozen material will not be updatable but should be faster to render
  137027. */
  137028. Scene.prototype.unfreezeMaterials = function () {
  137029. for (var i = 0; i < this.materials.length; i++) {
  137030. this.materials[i].unfreeze();
  137031. }
  137032. };
  137033. /**
  137034. * Releases all held ressources
  137035. */
  137036. Scene.prototype.dispose = function () {
  137037. this.beforeRender = null;
  137038. this.afterRender = null;
  137039. this.skeletons = [];
  137040. this.morphTargetManagers = [];
  137041. this._transientComponents = [];
  137042. this._isReadyForMeshStage.clear();
  137043. this._beforeEvaluateActiveMeshStage.clear();
  137044. this._evaluateSubMeshStage.clear();
  137045. this._activeMeshStage.clear();
  137046. this._cameraDrawRenderTargetStage.clear();
  137047. this._beforeCameraDrawStage.clear();
  137048. this._beforeRenderTargetDrawStage.clear();
  137049. this._beforeRenderingGroupDrawStage.clear();
  137050. this._beforeRenderingMeshStage.clear();
  137051. this._afterRenderingMeshStage.clear();
  137052. this._afterRenderingGroupDrawStage.clear();
  137053. this._afterCameraDrawStage.clear();
  137054. this._afterRenderTargetDrawStage.clear();
  137055. this._afterRenderStage.clear();
  137056. this._beforeCameraUpdateStage.clear();
  137057. this._beforeClearStage.clear();
  137058. this._gatherRenderTargetsStage.clear();
  137059. this._gatherActiveCameraRenderTargetsStage.clear();
  137060. this._pointerMoveStage.clear();
  137061. this._pointerDownStage.clear();
  137062. this._pointerUpStage.clear();
  137063. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  137064. var component = _a[_i];
  137065. component.dispose();
  137066. }
  137067. this.importedMeshesFiles = new Array();
  137068. this.stopAllAnimations();
  137069. this.resetCachedMaterial();
  137070. // Smart arrays
  137071. if (this.activeCamera) {
  137072. this.activeCamera._activeMeshes.dispose();
  137073. this.activeCamera = null;
  137074. }
  137075. this._activeMeshes.dispose();
  137076. this._renderingManager.dispose();
  137077. this._processedMaterials.dispose();
  137078. this._activeParticleSystems.dispose();
  137079. this._activeSkeletons.dispose();
  137080. this._softwareSkinnedMeshes.dispose();
  137081. this._renderTargets.dispose();
  137082. this._registeredForLateAnimationBindings.dispose();
  137083. this._meshesForIntersections.dispose();
  137084. this._toBeDisposed = [];
  137085. // Abort active requests
  137086. for (var _b = 0, _c = this._activeRequests; _b < _c.length; _b++) {
  137087. var request = _c[_b];
  137088. request.abort();
  137089. }
  137090. // Events
  137091. this.onDisposeObservable.notifyObservers(this);
  137092. this.onDisposeObservable.clear();
  137093. this.onBeforeRenderObservable.clear();
  137094. this.onAfterRenderObservable.clear();
  137095. this.onBeforeRenderTargetsRenderObservable.clear();
  137096. this.onAfterRenderTargetsRenderObservable.clear();
  137097. this.onAfterStepObservable.clear();
  137098. this.onBeforeStepObservable.clear();
  137099. this.onBeforeActiveMeshesEvaluationObservable.clear();
  137100. this.onAfterActiveMeshesEvaluationObservable.clear();
  137101. this.onBeforeParticlesRenderingObservable.clear();
  137102. this.onAfterParticlesRenderingObservable.clear();
  137103. this.onBeforeDrawPhaseObservable.clear();
  137104. this.onAfterDrawPhaseObservable.clear();
  137105. this.onBeforeAnimationsObservable.clear();
  137106. this.onAfterAnimationsObservable.clear();
  137107. this.onDataLoadedObservable.clear();
  137108. this.onBeforeRenderingGroupObservable.clear();
  137109. this.onAfterRenderingGroupObservable.clear();
  137110. this.onMeshImportedObservable.clear();
  137111. this.onBeforeCameraRenderObservable.clear();
  137112. this.onAfterCameraRenderObservable.clear();
  137113. this.onReadyObservable.clear();
  137114. this.onNewCameraAddedObservable.clear();
  137115. this.onCameraRemovedObservable.clear();
  137116. this.onNewLightAddedObservable.clear();
  137117. this.onLightRemovedObservable.clear();
  137118. this.onNewGeometryAddedObservable.clear();
  137119. this.onGeometryRemovedObservable.clear();
  137120. this.onNewTransformNodeAddedObservable.clear();
  137121. this.onTransformNodeRemovedObservable.clear();
  137122. this.onNewMeshAddedObservable.clear();
  137123. this.onMeshRemovedObservable.clear();
  137124. this.onNewSkeletonAddedObservable.clear();
  137125. this.onSkeletonRemovedObservable.clear();
  137126. this.onNewMaterialAddedObservable.clear();
  137127. this.onMaterialRemovedObservable.clear();
  137128. this.onNewTextureAddedObservable.clear();
  137129. this.onTextureRemovedObservable.clear();
  137130. this.onPrePointerObservable.clear();
  137131. this.onPointerObservable.clear();
  137132. this.onPreKeyboardObservable.clear();
  137133. this.onKeyboardObservable.clear();
  137134. this.onActiveCameraChanged.clear();
  137135. this.detachControl();
  137136. // Detach cameras
  137137. var canvas = this._engine.getRenderingCanvas();
  137138. if (canvas) {
  137139. var index;
  137140. for (index = 0; index < this.cameras.length; index++) {
  137141. this.cameras[index].detachControl(canvas);
  137142. }
  137143. }
  137144. // Release animation groups
  137145. while (this.animationGroups.length) {
  137146. this.animationGroups[0].dispose();
  137147. }
  137148. // Release lights
  137149. while (this.lights.length) {
  137150. this.lights[0].dispose();
  137151. }
  137152. // Release meshes
  137153. while (this.meshes.length) {
  137154. this.meshes[0].dispose(true);
  137155. }
  137156. while (this.transformNodes.length) {
  137157. this.transformNodes[0].dispose(true);
  137158. }
  137159. // Release cameras
  137160. while (this.cameras.length) {
  137161. this.cameras[0].dispose();
  137162. }
  137163. // Release materials
  137164. if (this.defaultMaterial) {
  137165. this.defaultMaterial.dispose();
  137166. }
  137167. while (this.multiMaterials.length) {
  137168. this.multiMaterials[0].dispose();
  137169. }
  137170. while (this.materials.length) {
  137171. this.materials[0].dispose();
  137172. }
  137173. // Release particles
  137174. while (this.particleSystems.length) {
  137175. this.particleSystems[0].dispose();
  137176. }
  137177. // Release postProcesses
  137178. while (this.postProcesses.length) {
  137179. this.postProcesses[0].dispose();
  137180. }
  137181. // Release textures
  137182. while (this.textures.length) {
  137183. this.textures[0].dispose();
  137184. }
  137185. // Release UBO
  137186. this._sceneUbo.dispose();
  137187. if (this._multiviewSceneUbo) {
  137188. this._multiviewSceneUbo.dispose();
  137189. }
  137190. // Post-processes
  137191. this.postProcessManager.dispose();
  137192. // Remove from engine
  137193. index = this._engine.scenes.indexOf(this);
  137194. if (index > -1) {
  137195. this._engine.scenes.splice(index, 1);
  137196. }
  137197. this._engine.wipeCaches(true);
  137198. this._isDisposed = true;
  137199. };
  137200. Object.defineProperty(Scene.prototype, "isDisposed", {
  137201. /**
  137202. * Gets if the scene is already disposed
  137203. */
  137204. get: function () {
  137205. return this._isDisposed;
  137206. },
  137207. enumerable: true,
  137208. configurable: true
  137209. });
  137210. /**
  137211. * Call this function to reduce memory footprint of the scene.
  137212. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  137213. */
  137214. Scene.prototype.clearCachedVertexData = function () {
  137215. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  137216. var mesh = this.meshes[meshIndex];
  137217. var geometry = mesh.geometry;
  137218. if (geometry) {
  137219. geometry._indices = [];
  137220. for (var vbName in geometry._vertexBuffers) {
  137221. if (!geometry._vertexBuffers.hasOwnProperty(vbName)) {
  137222. continue;
  137223. }
  137224. geometry._vertexBuffers[vbName]._buffer._data = null;
  137225. }
  137226. }
  137227. }
  137228. };
  137229. /**
  137230. * This function will remove the local cached buffer data from texture.
  137231. * It will save memory but will prevent the texture from being rebuilt
  137232. */
  137233. Scene.prototype.cleanCachedTextureBuffer = function () {
  137234. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  137235. var baseTexture = _a[_i];
  137236. var buffer = baseTexture._buffer;
  137237. if (buffer) {
  137238. baseTexture._buffer = null;
  137239. }
  137240. }
  137241. };
  137242. /**
  137243. * Get the world extend vectors with an optional filter
  137244. *
  137245. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  137246. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  137247. */
  137248. Scene.prototype.getWorldExtends = function (filterPredicate) {
  137249. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  137250. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  137251. filterPredicate = filterPredicate || (function () { return true; });
  137252. this.meshes.filter(filterPredicate).forEach(function (mesh) {
  137253. mesh.computeWorldMatrix(true);
  137254. if (!mesh.subMeshes || mesh.subMeshes.length === 0 || mesh.infiniteDistance) {
  137255. return;
  137256. }
  137257. var boundingInfo = mesh.getBoundingInfo();
  137258. var minBox = boundingInfo.boundingBox.minimumWorld;
  137259. var maxBox = boundingInfo.boundingBox.maximumWorld;
  137260. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  137261. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  137262. });
  137263. return {
  137264. min: min,
  137265. max: max
  137266. };
  137267. };
  137268. // Picking
  137269. /**
  137270. * Creates a ray that can be used to pick in the scene
  137271. * @param x defines the x coordinate of the origin (on-screen)
  137272. * @param y defines the y coordinate of the origin (on-screen)
  137273. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  137274. * @param camera defines the camera to use for the picking
  137275. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  137276. * @returns a Ray
  137277. */
  137278. Scene.prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  137279. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  137280. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  137281. };
  137282. /**
  137283. * Creates a ray that can be used to pick in the scene
  137284. * @param x defines the x coordinate of the origin (on-screen)
  137285. * @param y defines the y coordinate of the origin (on-screen)
  137286. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  137287. * @param result defines the ray where to store the picking ray
  137288. * @param camera defines the camera to use for the picking
  137289. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  137290. * @returns the current scene
  137291. */
  137292. Scene.prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  137293. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  137294. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  137295. };
  137296. /**
  137297. * Creates a ray that can be used to pick in the scene
  137298. * @param x defines the x coordinate of the origin (on-screen)
  137299. * @param y defines the y coordinate of the origin (on-screen)
  137300. * @param camera defines the camera to use for the picking
  137301. * @returns a Ray
  137302. */
  137303. Scene.prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  137304. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  137305. };
  137306. /**
  137307. * Creates a ray that can be used to pick in the scene
  137308. * @param x defines the x coordinate of the origin (on-screen)
  137309. * @param y defines the y coordinate of the origin (on-screen)
  137310. * @param result defines the ray where to store the picking ray
  137311. * @param camera defines the camera to use for the picking
  137312. * @returns the current scene
  137313. */
  137314. Scene.prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  137315. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  137316. };
  137317. /** Launch a ray to try to pick a mesh in the scene
  137318. * @param x position on screen
  137319. * @param y position on screen
  137320. * @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
  137321. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  137322. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  137323. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  137324. * @returns a PickingInfo
  137325. */
  137326. Scene.prototype.pick = function (x, y, predicate, fastCheck, camera, trianglePredicate) {
  137327. // Dummy info if picking as not been imported
  137328. var pi = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_14__["PickingInfo"]();
  137329. pi._pickingUnavailable = true;
  137330. return pi;
  137331. };
  137332. /** Use the given ray to pick a mesh in the scene
  137333. * @param ray The ray to use to pick meshes
  137334. * @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
  137335. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  137336. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  137337. * @returns a PickingInfo
  137338. */
  137339. Scene.prototype.pickWithRay = function (ray, predicate, fastCheck, trianglePredicate) {
  137340. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  137341. };
  137342. /**
  137343. * Launch a ray to try to pick a mesh in the scene
  137344. * @param x X position on screen
  137345. * @param y Y position on screen
  137346. * @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
  137347. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  137348. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  137349. * @returns an array of PickingInfo
  137350. */
  137351. Scene.prototype.multiPick = function (x, y, predicate, camera, trianglePredicate) {
  137352. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  137353. };
  137354. /**
  137355. * Launch a ray to try to pick a mesh in the scene
  137356. * @param ray Ray to use
  137357. * @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
  137358. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  137359. * @returns an array of PickingInfo
  137360. */
  137361. Scene.prototype.multiPickWithRay = function (ray, predicate, trianglePredicate) {
  137362. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  137363. };
  137364. /**
  137365. * Force the value of meshUnderPointer
  137366. * @param mesh defines the mesh to use
  137367. */
  137368. Scene.prototype.setPointerOverMesh = function (mesh) {
  137369. if (this._pointerOverMesh === mesh) {
  137370. return;
  137371. }
  137372. var actionManager;
  137373. if (this._pointerOverMesh) {
  137374. actionManager = this._pointerOverMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOutTrigger);
  137375. if (actionManager) {
  137376. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pointerOverMesh));
  137377. }
  137378. }
  137379. this._pointerOverMesh = mesh;
  137380. if (this._pointerOverMesh) {
  137381. actionManager = this._pointerOverMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOverTrigger);
  137382. if (actionManager) {
  137383. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pointerOverMesh));
  137384. }
  137385. }
  137386. };
  137387. /**
  137388. * Gets the mesh under the pointer
  137389. * @returns a Mesh or null if no mesh is under the pointer
  137390. */
  137391. Scene.prototype.getPointerOverMesh = function () {
  137392. return this._pointerOverMesh;
  137393. };
  137394. // Misc.
  137395. /** @hidden */
  137396. Scene.prototype._rebuildGeometries = function () {
  137397. for (var _i = 0, _a = this.geometries; _i < _a.length; _i++) {
  137398. var geometry = _a[_i];
  137399. geometry._rebuild();
  137400. }
  137401. for (var _b = 0, _c = this.meshes; _b < _c.length; _b++) {
  137402. var mesh = _c[_b];
  137403. mesh._rebuild();
  137404. }
  137405. if (this.postProcessManager) {
  137406. this.postProcessManager._rebuild();
  137407. }
  137408. for (var _d = 0, _e = this._components; _d < _e.length; _d++) {
  137409. var component = _e[_d];
  137410. component.rebuild();
  137411. }
  137412. for (var _f = 0, _g = this.particleSystems; _f < _g.length; _f++) {
  137413. var system = _g[_f];
  137414. system.rebuild();
  137415. }
  137416. };
  137417. /** @hidden */
  137418. Scene.prototype._rebuildTextures = function () {
  137419. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  137420. var texture = _a[_i];
  137421. texture._rebuild();
  137422. }
  137423. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  137424. };
  137425. // Tags
  137426. Scene.prototype._getByTags = function (list, tagsQuery, forEach) {
  137427. if (tagsQuery === undefined) {
  137428. // returns the complete list (could be done with Tags.MatchesQuery but no need to have a for-loop here)
  137429. return list;
  137430. }
  137431. var listByTags = [];
  137432. forEach = forEach || (function (item) { return; });
  137433. for (var i in list) {
  137434. var item = list[i];
  137435. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"].MatchesQuery(item, tagsQuery)) {
  137436. listByTags.push(item);
  137437. forEach(item);
  137438. }
  137439. }
  137440. return listByTags;
  137441. };
  137442. /**
  137443. * Get a list of meshes by tags
  137444. * @param tagsQuery defines the tags query to use
  137445. * @param forEach defines a predicate used to filter results
  137446. * @returns an array of Mesh
  137447. */
  137448. Scene.prototype.getMeshesByTags = function (tagsQuery, forEach) {
  137449. return this._getByTags(this.meshes, tagsQuery, forEach);
  137450. };
  137451. /**
  137452. * Get a list of cameras by tags
  137453. * @param tagsQuery defines the tags query to use
  137454. * @param forEach defines a predicate used to filter results
  137455. * @returns an array of Camera
  137456. */
  137457. Scene.prototype.getCamerasByTags = function (tagsQuery, forEach) {
  137458. return this._getByTags(this.cameras, tagsQuery, forEach);
  137459. };
  137460. /**
  137461. * Get a list of lights by tags
  137462. * @param tagsQuery defines the tags query to use
  137463. * @param forEach defines a predicate used to filter results
  137464. * @returns an array of Light
  137465. */
  137466. Scene.prototype.getLightsByTags = function (tagsQuery, forEach) {
  137467. return this._getByTags(this.lights, tagsQuery, forEach);
  137468. };
  137469. /**
  137470. * Get a list of materials by tags
  137471. * @param tagsQuery defines the tags query to use
  137472. * @param forEach defines a predicate used to filter results
  137473. * @returns an array of Material
  137474. */
  137475. Scene.prototype.getMaterialByTags = function (tagsQuery, forEach) {
  137476. return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
  137477. };
  137478. /**
  137479. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  137480. * This allowed control for front to back rendering or reversly depending of the special needs.
  137481. *
  137482. * @param renderingGroupId The rendering group id corresponding to its index
  137483. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  137484. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  137485. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  137486. */
  137487. Scene.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  137488. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  137489. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  137490. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  137491. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  137492. };
  137493. /**
  137494. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  137495. *
  137496. * @param renderingGroupId The rendering group id corresponding to its index
  137497. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  137498. * @param depth Automatically clears depth between groups if true and autoClear is true.
  137499. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  137500. */
  137501. Scene.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  137502. if (depth === void 0) { depth = true; }
  137503. if (stencil === void 0) { stencil = true; }
  137504. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil, depth, stencil);
  137505. };
  137506. /**
  137507. * Gets the current auto clear configuration for one rendering group of the rendering
  137508. * manager.
  137509. * @param index the rendering group index to get the information for
  137510. * @returns The auto clear setup for the requested rendering group
  137511. */
  137512. Scene.prototype.getAutoClearDepthStencilSetup = function (index) {
  137513. return this._renderingManager.getAutoClearDepthStencilSetup(index);
  137514. };
  137515. Object.defineProperty(Scene.prototype, "blockMaterialDirtyMechanism", {
  137516. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  137517. get: function () {
  137518. return this._blockMaterialDirtyMechanism;
  137519. },
  137520. set: function (value) {
  137521. if (this._blockMaterialDirtyMechanism === value) {
  137522. return;
  137523. }
  137524. this._blockMaterialDirtyMechanism = value;
  137525. if (!value) { // Do a complete update
  137526. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_AllDirtyFlag);
  137527. }
  137528. },
  137529. enumerable: true,
  137530. configurable: true
  137531. });
  137532. /**
  137533. * Will flag all materials as dirty to trigger new shader compilation
  137534. * @param flag defines the flag used to specify which material part must be marked as dirty
  137535. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  137536. */
  137537. Scene.prototype.markAllMaterialsAsDirty = function (flag, predicate) {
  137538. if (this._blockMaterialDirtyMechanism) {
  137539. return;
  137540. }
  137541. for (var _i = 0, _a = this.materials; _i < _a.length; _i++) {
  137542. var material = _a[_i];
  137543. if (predicate && !predicate(material)) {
  137544. continue;
  137545. }
  137546. material.markAsDirty(flag);
  137547. }
  137548. };
  137549. /** @hidden */
  137550. Scene.prototype._loadFile = function (url, onSuccess, onProgress, useOfflineSupport, useArrayBuffer, onError) {
  137551. var _this = this;
  137552. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadFile(url, onSuccess, onProgress, useOfflineSupport ? this.offlineProvider : undefined, useArrayBuffer, onError);
  137553. this._activeRequests.push(request);
  137554. request.onCompleteObservable.add(function (request) {
  137555. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  137556. });
  137557. return request;
  137558. };
  137559. /** @hidden */
  137560. Scene.prototype._loadFileAsync = function (url, useOfflineSupport, useArrayBuffer) {
  137561. var _this = this;
  137562. return new Promise(function (resolve, reject) {
  137563. _this._loadFile(url, function (data) {
  137564. resolve(data);
  137565. }, undefined, useOfflineSupport, useArrayBuffer, function (request, exception) {
  137566. reject(exception);
  137567. });
  137568. });
  137569. };
  137570. // Statics
  137571. Scene._uniqueIdCounter = 0;
  137572. /** The fog is deactivated */
  137573. Scene.FOGMODE_NONE = 0;
  137574. /** The fog density is following an exponential function */
  137575. Scene.FOGMODE_EXP = 1;
  137576. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  137577. Scene.FOGMODE_EXP2 = 2;
  137578. /** The fog density is following a linear function. */
  137579. Scene.FOGMODE_LINEAR = 3;
  137580. /**
  137581. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  137582. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137583. */
  137584. Scene.MinDeltaTime = 1.0;
  137585. /**
  137586. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  137587. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137588. */
  137589. Scene.MaxDeltaTime = 1000.0;
  137590. /** The distance in pixel that you have to move to prevent some events */
  137591. Scene.DragMovementThreshold = 10; // in pixels
  137592. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  137593. Scene.LongPressDelay = 500; // in milliseconds
  137594. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  137595. Scene.DoubleClickDelay = 300; // in milliseconds
  137596. /** If you need to check double click without raising a single click at first click, enable this flag */
  137597. Scene.ExclusiveDoubleClickMode = false;
  137598. return Scene;
  137599. }(_abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"]));
  137600. /***/ }),
  137601. /***/ "./sceneComponent.ts":
  137602. /*!***************************!*\
  137603. !*** ./sceneComponent.ts ***!
  137604. \***************************/
  137605. /*! exports provided: SceneComponentConstants, Stage */
  137606. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  137607. "use strict";
  137608. __webpack_require__.r(__webpack_exports__);
  137609. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return SceneComponentConstants; });
  137610. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return Stage; });
  137611. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  137612. /**
  137613. * Groups all the scene component constants in one place to ease maintenance.
  137614. * @hidden
  137615. */
  137616. var SceneComponentConstants = /** @class */ (function () {
  137617. function SceneComponentConstants() {
  137618. }
  137619. SceneComponentConstants.NAME_EFFECTLAYER = "EffectLayer";
  137620. SceneComponentConstants.NAME_LAYER = "Layer";
  137621. SceneComponentConstants.NAME_LENSFLARESYSTEM = "LensFlareSystem";
  137622. SceneComponentConstants.NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer";
  137623. SceneComponentConstants.NAME_PARTICLESYSTEM = "ParticleSystem";
  137624. SceneComponentConstants.NAME_GAMEPAD = "Gamepad";
  137625. SceneComponentConstants.NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue";
  137626. SceneComponentConstants.NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer";
  137627. SceneComponentConstants.NAME_DEPTHRENDERER = "DepthRenderer";
  137628. SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager";
  137629. SceneComponentConstants.NAME_SPRITE = "Sprite";
  137630. SceneComponentConstants.NAME_OUTLINERENDERER = "Outline";
  137631. SceneComponentConstants.NAME_PROCEDURALTEXTURE = "ProceduralTexture";
  137632. SceneComponentConstants.NAME_SHADOWGENERATOR = "ShadowGenerator";
  137633. SceneComponentConstants.NAME_OCTREE = "Octree";
  137634. SceneComponentConstants.NAME_PHYSICSENGINE = "PhysicsEngine";
  137635. SceneComponentConstants.NAME_AUDIO = "Audio";
  137636. SceneComponentConstants.STEP_ISREADYFORMESH_EFFECTLAYER = 0;
  137637. SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  137638. SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0;
  137639. SceneComponentConstants.STEP_ACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  137640. SceneComponentConstants.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1;
  137641. SceneComponentConstants.STEP_BEFORECAMERADRAW_EFFECTLAYER = 0;
  137642. SceneComponentConstants.STEP_BEFORECAMERADRAW_LAYER = 1;
  137643. SceneComponentConstants.STEP_BEFORERENDERTARGETDRAW_LAYER = 0;
  137644. SceneComponentConstants.STEP_BEFORERENDERINGMESH_OUTLINE = 0;
  137645. SceneComponentConstants.STEP_AFTERRENDERINGMESH_OUTLINE = 0;
  137646. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0;
  137647. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1;
  137648. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0;
  137649. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1;
  137650. SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0;
  137651. SceneComponentConstants.STEP_AFTERRENDERTARGETDRAW_LAYER = 0;
  137652. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER = 0;
  137653. SceneComponentConstants.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 1;
  137654. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 2;
  137655. SceneComponentConstants.STEP_AFTERCAMERADRAW_LAYER = 3;
  137656. SceneComponentConstants.STEP_AFTERRENDER_AUDIO = 0;
  137657. SceneComponentConstants.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 0;
  137658. SceneComponentConstants.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1;
  137659. SceneComponentConstants.STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 2;
  137660. SceneComponentConstants.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3;
  137661. SceneComponentConstants.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0;
  137662. SceneComponentConstants.STEP_POINTERMOVE_SPRITE = 0;
  137663. SceneComponentConstants.STEP_POINTERDOWN_SPRITE = 0;
  137664. SceneComponentConstants.STEP_POINTERUP_SPRITE = 0;
  137665. return SceneComponentConstants;
  137666. }());
  137667. /**
  137668. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  137669. * @hidden
  137670. */
  137671. var Stage = /** @class */ (function (_super) {
  137672. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Stage, _super);
  137673. /**
  137674. * Hide ctor from the rest of the world.
  137675. * @param items The items to add.
  137676. */
  137677. function Stage(items) {
  137678. return _super.apply(this, items) || this;
  137679. }
  137680. /**
  137681. * Creates a new Stage.
  137682. * @returns A new instance of a Stage
  137683. */
  137684. Stage.Create = function () {
  137685. return Object.create(Stage.prototype);
  137686. };
  137687. /**
  137688. * Registers a step in an ordered way in the targeted stage.
  137689. * @param index Defines the position to register the step in
  137690. * @param component Defines the component attached to the step
  137691. * @param action Defines the action to launch during the step
  137692. */
  137693. Stage.prototype.registerStep = function (index, component, action) {
  137694. var i = 0;
  137695. var maxIndex = Number.MAX_VALUE;
  137696. for (; i < this.length; i++) {
  137697. var step = this[i];
  137698. maxIndex = step.index;
  137699. if (index < maxIndex) {
  137700. break;
  137701. }
  137702. }
  137703. this.splice(i, 0, { index: index, component: component, action: action.bind(component) });
  137704. };
  137705. /**
  137706. * Clears all the steps from the stage.
  137707. */
  137708. Stage.prototype.clear = function () {
  137709. this.length = 0;
  137710. };
  137711. return Stage;
  137712. }(Array));
  137713. /***/ })
  137714. /******/ });
  137715. });
  137716. //# sourceMappingURL=babylon.max.js.map